Homework:
Which operator makes each of these expressions true? (There’s more than one right answer!)
“i can” ? “CODE”
float(True) // 7 ? 0.0
“yEET” ? “y e e t”
2. Is each expression true or false?
(6.3 + 7.2 / 2 == (6.3 + 7.2) / 2) OR NOT(2 * int(7.4) > 14)
(“mat ” > “mate”) != (“for” > “Forward”) AND (7 > 8) != (9 > 6)
3. Use if-elif-else statements to create a grading system where user inputs a percent grade (0 to 100).
If grade is between 100 and 90: print “A”
else if grade is between 90 and 80: print “B”
else if 70-80: print “C”
else if 60-70: print “D”
else: print “F”
Resources:
Class slides: https://docs.google.com/presentation/d/1Y9xOne9n70BlgKDi_uHrZ7gNNp_xivcQchEAE60kgvY/edit?usp=sharing
Class code: https://replit.com/@ShravyaS/IntroToPython-Class3#main.py
Contact info:
shravyassathish@gmail.com (mentor)
kingericwu@gmail.com (TA)
felixguo41@gmail.com (TA)
Solutions (there may be more than one):
1a. "i can" != "CODE"
1b. float(True)//7==0.0
1c. "yEET" > "y e e t"
2a. True
2b. True
3.
grade=float(input())
if grade >= 90:
print("A")
elif grade >= 80:
print("B")
elif grade >= 70:
print("C")
elif grade >= 60:
print("D")
else:
print("F")