RESOURCES: Class slides: https://docs.google.com/presentation/d/1zIPSvXFg7eEVjguovCNHKpuojvqCq6eA5tjJpfGnSKc/edit?usp=sharing
Coding platform: replit.com
Discord: https://discord.gg/FKKAcmrr
HOMEWORK:
Give 3 examples of each data type (2 examples for Booleans).
Take user input and tell an interactive story using f-strings and concatenation of variables and print statements.
Example of a starting point:
username = input(“What is your name?”)
print(username + “, you know my name, not my story”)
Post your answers as a comment! Solutions will be posted later.
Feel free to email shravyassathish@gmail.com (mentor) or kingericwu@gmail.com (TA) if you're stuck or have questions! See you next class :)
username = input("What is your name? ")
hasSiblingStr = input("Do you have sibling? True or False: ")
hasSibling = eval(hasSiblingStr)
numOfSibling = 0
if hasSibling:
numOfSibling = int(input("How many sibling do you have? "))
Age = input("How old are you? ")
Age = int(Age)
candyName = input("What is your favorite candy? ")
isAteAlready = input("Have you ate one today? yes or no: ")
if isAteAlready == "yes":
ateToday = True
else :
ateToday = False
weight = input("How many lbs do you weight ? ")
'''print(type(weight))'''
w=int(weight)
if ateToday :
verb ="have"
else:
verb = "haven't"
print("----------------We start to analyzing you---------------")
print('Hi '+ username +' How are you doing today?')
print(f"You have {numOfSibling} sibling")
print(f'you are {Age} years old')
if Age<=12:
print("You are a kid")
elif Age <=18:
print("You are a teenager")
elif Age<=45:
print("You are an adult")
elif Age<=80:
print("You are old")
else:
print("You are too too old")
print("Your favorite candy is "+ candyName +" you "+verb+ " eaten candies today")
print("your weight is "+weight)
if w > 90:
print(f'You are overweight. It is never too late to quit {candyName}')
else:
print("your weight is fine. But "+candyName+" are not good for your teeth. Please eat more apples")