전체 글 409

1부터 100까지 숫자중 임의의 숫자 추측하기

1부터 100까지 숫자중 임의의 숫자 추측하기 from random import randint secret = randint(1,100) print("Welcome!") guess=0 while guess!=secret: g=input("Guess the number:") guess=int(g) if guess ==secret: print("You win!") else: if guess > secret : print("Too high") else: print("Too low") print("Game over!") from random import randint secret = randint(1,100) -> 랜덤으로 1부터 100까지 임의의 수로 설정 print(“”) -> 출력하게 함. while gu..

python 처음 시작하기

python이란? 1991년 프로그래머인 Guido van Rossum이 발표한 고급 프로그래밍 언어로, 플랫폼 독립적이며 인터프리터식, 객체지향적, 동적 타이핑 대화형 언어입니다. 파이썬이라는 이름은 guido가 좋아하는 코미디 Monty Python’s Flying Circus에서 따온 것입니다. 구글이나 유튜브 NASA등에서 파이썬을 사용하고 있습니다 python 설치하기 http://www.python.org/ 로 들어가시면 설치가능합니다. 저는 현재 3.2버전을 쓰고있습니다. python 실행하기 python을 설치하시면 IDLE이 있습니다. IDLE을 실행하시면되요! IDLE을 실행하시고 [FILE] - [New window] (단축기 Ctrl+N) 메뉴를 선택하면 편집창이 나타납니다. (+)..

05-07

사용자로부터 0000과 1111사이의 2진수를 입력받아 10진수로 출력하는 프로그램을 작성 #include int main(void) { int first, second, third, fourth, decimal; int dec1, dec2; // for temporary decisions printf("--------Between 0000 and 1111, Convert to Demical Number-------\n"); printf("The First : "), scanf("%d",&first); printf("The Second : "), scanf("%d",&second); printf("The Third : "), scanf("%d",&third); printf("The Fourth : "),..

04-03

소문자 a를 저장하는 변수를 하나 만들고, ASCII 코드 표를 참고하여 대문자 A를 출력하는 프로그램 #include int main (void) { int a_char='a'; int A_char=a_char-32; //a_char은 ASCII코드에서 97이다 printf("The ASCII code of a is %d \n", a_char); printf("The ASCII code %d is the character %C \n", A_char, A_char); //%d는 숫자 %c는 문자열 //따라서 %d에서는 10진수 숫자 65 %c에서는 문자열인 A가 나온다. return 0; }