Introduction to Computer Science and Programming in Python chap2

Branching and iteration

Strings

concatenate the strings

hi = "hellothere"
name = "ana"
oscar = hi + name  
print(oscar)
ppi = hi+" "+name
print(ppi)
hellothereana
hellothere ana

Input/output

cast \(\rightarrow\) strings

text = input("Type anything... ")
print(5*text)
num = int(input("Type a number... "))
print(5*num)
Type anything... 4
44444
Type a number... 22
110

COMPARISON OPERATORS ON int,float,string

while LOOP

n = input("You are in the LookupErrorost Forest\n****************\n****************\n :)\n****************\n****************\n Go left or right? ")
while n == "right" or n == "Right":
    n = input("You are in the Lost Forest\n****************\n*********\n(╯°□°)╯︵ ┻━┻\n****************\n****************\nGo left or right? ")
print("\n You got out of the Lost Forest!\n\o/")
You are in the LookupErrorost Forest
****************
****************
 :)
****************
****************
 Go left or right? right
You are in the Lost Forest
****************
*********
(╯°□°)╯︵ ┻━┻
****************
****************
Go left or right? left

 You got out of the Lost Forest!
\o/
posted @ 2020-09-02 17:05  _OscarLi  阅读(133)  评论(0编辑  收藏  举报