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")
print('''
Sorry in advance for the wall of text... Please direct all blame to LoL Homework Creators & Co. and not Chris.\n\n
Did you know?
1.
a. '"i can" > "CODE"' and '"i can" != "CODE"' and '"i can" >= "CODE"' are all true?
b. 'float(True) // 7 == 0.0' and 'float(True) // 7 <= 0.0' and 'float(True) // 7 >= 0.0' are all true as well?
c. Guess what? '"yEET" > "y e e t"' and '"yEET" >= "y e e t"' and '"yEET" != "y e e t"' are all... TRUE! woah. never expected that, did you?\n
2.
a. The monstrosity known as '(6.3 + 7.2 / 2 == (6.3 + 7.2) / 2) OR NOT(2 * int(7.4) > 14)' is True if you count the "OR NOT" as lowercase letters. If not, you'll get an error message.
b. '(“mat ” > “mate”) != (“for” > “Forward”) AND (7 > 8) != (9 > 6)' is True, again counting the "AND" as lowercase.\n
3.
''')
grade = input("What's your grade (as a percentage)? ")
try:
grade = int(grade)
if grade > 100:
print("WOOOOAAAAAAAH!!! YOU'RE AMAAAAAAAAAAAAAAAZING")
elif grade < 100 and grade > 90:
print("A A ayyy!")
elif grade < 90 and grade > 80:
print("B. Better be better bud.")
elif grade <= 80 and grade >= 70:
print("C for crap.")
elif grade < 70 and grade >= 60:
print("Dang, Ds don't delight.,,")
elif grade < 60:
print("f in chat for failing friends")
elif grade == 90 or grade == 100:
print("Somehow LoL Homework Creators & Co. forgot about 90 and 100... Not nice, LHC&C...")
except:
print("bruh just enter an integer please make my life easy.")
1a. !=
1b. >
1c. !=, >
2a. True
2b. True
3.
grade = int(input("input grade between 0 and 100: "))
if grade >= 90 and grade <= 100:
print("A")
elif grade < 90 and grade >= 80:
print("B")
elif grade < 80 and grade >= 70:
print("C")
elif grade < 70 and grade >= 60:
print("D")
else:
print("F")
Prompt 1.
A. >
B. ==
C. >
Prompt 2.
A. True
B. False
Prompt 3.
grade = input("Input grade percentile/score from 0-100: ")
grade = float(grade)
if 90<=grade<=100: print("You got an A! Never knew you were smart xD.")
elif 80<=grade<=89: print("You got a B! Keep trying.")
elif 70<=grade<=79: print("You got a C. Keep trying.")
elif 60<=grade<=69: print("You got a D. Keep trying.")
elif 0<=grade<=59: print("You got an F. Keep pushing forward.")
a. >
b. ==
c. >
2.
a. True
b. False
3.
grade = input("Please put in the percentage of your grade from 0-100: ")
grade = float(grade)
if 90<=grade<=100:
print("A")
elif 80<=grade<=90:
print("B")
elif 70<=grade<=80:
print("C")
elif 60<=grade<=70:
print("D")
else:
print("F")