Created
November 8, 2020 20:32
-
-
Save EphraimB/e9527ae883d6e425d33cd82b48741d19 to your computer and use it in GitHub Desktop.
Midterm 1 makeup exam
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def stars(): | |
print("Enter an integer for m") | |
m = int(input()) | |
m = max(3, m) | |
m = min(6, m) | |
print("Enter an integer for n") | |
n = int(input()) | |
n = max(5, n) | |
n = min(25, n) | |
star = n * "*" + "\n" | |
rows = star * m | |
print(m, "by", n, "stars") | |
print(rows) | |
for i in range(2): | |
stars() | |
for i in range(2): | |
stars() | |
def grade(): | |
A_SCORE = 95 | |
B_SCORE = 90 | |
C_SCORE = 85 | |
D_SCORE = 75 | |
print("Your name is", name) | |
print("Your score is", score) | |
if score >= A_SCORE: | |
print('Your grade is A.') | |
else: | |
if score >= B_SCORE: | |
print('Your grade is B.') | |
else: | |
if score >= C_SCORE: | |
print('Your grade is C.') | |
else: | |
if score >= D_SCORE: | |
print('Your grade is D.') | |
print("Enter your name:") | |
name = str(input()) | |
while True: | |
print("Enter your score:") | |
score = int(input()) | |
if score >= 0: | |
grade() | |
for score in range(1, 101, 3): | |
print("Score =", score) | |
A_SCORE = 95 | |
B_SCORE = 90 | |
C_SCORE = 85 | |
D_SCORE = 75 | |
if score >= A_SCORE: | |
print('Your grade is A.') | |
else: | |
if score >= B_SCORE: | |
print('Your grade is B.') | |
else: | |
if score >= C_SCORE: | |
print('Your grade is C.') | |
else: | |
if score >= D_SCORE: | |
print('Your grade is D.') | |
break | |
print("Enter your name:") | |
name = str(input()) | |
while True: | |
print("Enter your score:") | |
score = int(input()) | |
if score >= 0: | |
grade() | |
for score in range(1, 101, 3): | |
print("Score =", score) | |
A_SCORE = 95 | |
B_SCORE = 90 | |
C_SCORE = 85 | |
D_SCORE = 75 | |
if score >= A_SCORE: | |
print('Your grade is A.') | |
else: | |
if score >= B_SCORE: | |
print('Your grade is B.') | |
else: | |
if score >= C_SCORE: | |
print('Your grade is C.') | |
else: | |
if score >= D_SCORE: | |
print('Your grade is D.') | |
break | |
def RPM(a,b): | |
print("a * b =", a * b) | |
sum = 0 | |
while a > 0: | |
if a / 2 != math.floor(a / 2): | |
sum = sum + b | |
a = a // 2 | |
b = b * 2 | |
print(sum) | |
return sum | |
while True: | |
print("Enter value for a") | |
a = int(input()) | |
print("Enter value for b") | |
b = int(input()) | |
if a < 0 or b < 0: | |
break | |
else: | |
RPM(a, b) | |
break | |
def isLeapYear(y): | |
if y/100 == math.floor(y/100): | |
if y / 400 == math.floor(y / 400): | |
print("True") | |
return True | |
else: | |
print("False") | |
return False | |
else: | |
if y / 4 == math.floor(y / 4): | |
print("True") | |
return True | |
else: | |
print("False") | |
return False | |
print("Enter year") | |
y = int(input()) | |
while y > 0: | |
isLeapYear(y) | |
for i in range(2020, 1899, -5): | |
isLeapYear(i) | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment