-Write a program to prompt for a score between 0.0 and 1.0.
If the score
is out of range, print an error. If the score is between 0.0 and 1.0, print a
grade using the following:
Score Grade >= 0.9 A
>= 0.8 B
>= 0.7 C
>= 0.6 D
<0.6 F
If the user enters a value out of range print a suitable message and exit.
Ans:
x=float(input('please enter your score '))
if 0.0<x<1.0:
if x>=0.9:
print("A")
elif x>=0.8:
print("B")
elif x>=0.7:
print("C")
elif x>=0.6:
print("D")
elif x<0.6:
print("F")
else:
print("the value is out of range")
-Write a program to prompt the user for hours and rate per hour using
input to compute gross pay. Pay should be the normal rate for hours up
to 40 and time-and-a-half for the hourly rate for convert all hours
worked above 40 hours. You should use input to read a string and float()
to the string to a number.
Ans:
num_hours=int(input("enter the number of hours "))
rate=float(input("enter the rate per hour "))
normal_hours=40
if num_hours<=normal_hours:
print(f"your salar is {num_hours*rate:.3f}")
else:
normal_pay=normal_hours*rate
over_time=num_hours-normal_hours
salary=normal_pay+over_time*1.5*rate
print(f"your salary is: {salary:.3f}")
-Write a program that repeatedly prompts a user for integer numbers
until the user enters 'done'. Once 'done' is entered, print out the largest
and smallest of the numbers. If the user enters anything other than a
valid number catch it with a try/except and put out an appropriate
message and ignore the number.
Ans:
lis=[]
z=0
while z==0:
x=(input('enter integers '))
if x == "done":
break
try:
y=int(x)
lis.append(y)
except:
print('not valid')
print(max(lis))
print(min(lis))