Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Homework Session 6

1)
def main():
hours = (float(input("Insert amount of hours worked in week:")))
wages = (hours * 50)
if hours>40:
doubled = (wages*0.5)+wages
print("$", doubled)
else:
wages = (hours * 50)
print("$", wages)

main()

2)
def main():
grades = int(input("Insert grade that student earned from 0-5:"))

if grades == 5:
print("student earned letter grade: A")
elif grades == 4:
print("student earned letter grade: B")
elif grades == 3:
print("student earned letter grade: C")
elif grades == 2:
print("student earned letter grade: D")
elif grades == 1:
print("student earned letter grade: E")
elif grades == 0:
print("student earned letter grade: F")
else:
print("this score is not supported in this program")

main()

3)
def main():
import random
counter = int(input("how many times do you want the coin flipped?"))
heads = 0
tails = 0
for i in range(counter):
coin = random.randint(0, 1)
if coin == 0:
heads += 1
else:
tails += 1

print("Heads:", heads, "Tails:", tails)

main()
4)
def main():
import random
counter = int(input("how many times do you want the dice thrown?"))
result1 = 0
result2 = 0
result3 = 0
for i in range(counter):
dice = random.randint(1, 6)
if dice < 3:
result1 += 1
elif dice <=4:
result2 += 1
elif dice > 4:
result3 += 1
else:
result3 += 1

print("Number of throws lower than 3:", result1)


print("Number of throws that are 3 or 4:", result2)
print("Number of throws higher than 4:", result3)

main()

You might also like