### Hello World print("*** Hello world") print("hello world") ### 연산자 print("\n*** 연산자") print(8 * 3.57) print(5 + 30 * 20) print((5 + 30) * 20) print(((5 + 30) * 20) / 10) ### 변수 print("\n*** 변수") fred = 100 print(fred) fred = 200 john = fred print(john) ### 문자열 print("\n*** 문자열") fred = "Why do gorillas have big nostrils? Big fingers!!" print(fred) fred = '''\nHow do dinosaurs pay their bills? With tyrannosaurus checks!''' print(fred) # 문자열에 값을 포함하기 %s myscore = 1000 message = 'I scored %s points' print("\n" + message % myscore) joke_text = '%s : a devide for finding furniture in the dart' bodypart1 = 'Knee' bodypart2 = 'Shin' print("\n" + joke_text % bodypart1) print(joke_text % bodypart2) nums = 'What did the number %s say to the number %s? Nice belt!!' print("\n" + nums % (0, 8)) # 문자열 곱하기 print("\n" + 10 * 'a') spaces = ' ' * 25; print("\n" + '%s 12 Butts Wynd' % spaces)
노트/Python 연습
- Hello world, 연산자, 변수, 문자열 2014.03.20
Hello world, 연산자, 변수, 문자열
2014. 3. 20. 23:21