print 이용해서 문구 출력하기
print(“Day 1 - Python Print Function”)
print(“The Function is declared like this:”)
print(“print(‘what to print’)”)
출력내용
Day 1 - Python Print Function
The Function is declared like this:
print(‘what to print’)
마지막줄 print(“print(‘what to print’)”)
에서
’what to print’
를 ”what to print”
로 작성하는 경우에는
””
가 중복되어 오류가 발생하니 주의해야 한다.
오류 수정하기
# Missing double quotes before the word Day.
print(Day 1 - String Manipulation")
# Outer double quotes changed to single quotes.
print(“String Concatenation is done with the "+" sign.”)
# Extra indentation removed.
print('e.g. print("Hello " + "world")')
# Extra ( in print function removed.
print(("New lines can be created with a backslash and n.")
입력 받은 문자 길이 출력하기
print(len(input(“What is your name? “)
출력내용
What is your name? awesomee
8
a 값과 b 값 대체하기
커피가 든 잔과 우유가 든 컵을 연상하면 된다.
a = input(“a: ”)
b = input(“b: ”)
c = a
a = b
b = c
print(“a: ” = a)
print(“b: ” = b)
입력내용
a: 3
b: 5
출력내용
a: 5
b: 3
밴드이름 만들기
#1. Create a greeting for your program.
print(“Welcome to the Band Name Generator.”)
#2. Ask the user for the city that they grew up in.
city = input(“What’s name of the city you grown up in?\n”)
#3. Ask the user for the name of a pet.
pet = input(“What is your pet’s name?\n”)
#4. Combine the name of their city and pet and show them their band name.
print(“Your band name could be “ + city + “ “ + pet)
출력내용
Welcome to the Band Name Generator.
What’s name of the city you grown up in? London
What is your pet’s name? Mimi
Your band name could be London Mimi