Question

In: Computer Science

Python file def calci(): grade = float(input("Enter your grade:")) while (grade <= 4): if (grade >=...

Python file

def calci(): grade = float(input("Enter your grade:")) while (grade <= 4): if (grade >= 0.00 and grade <= 0.67): print("F") break elif (grade >= 0.67 and grade <= 0.99): print("D-") break elif (grade >= 1.00 and grade <= 1.32): print("D") break elif (grade >= 1.33 and grade <= 1.66): print("D+") break elif (grade >= 1.67 and grade <= 1.99): print("C-") break elif (grade >= 2.00 and grade <= 2.32): print("C") break elif (grade >= 2.33 and grade <= 2.66): print("C+") break elif (grade >= 2.67 and grade <= 2.99): print("B-") break elif (grade >= 3.00 and grade <= 3.32): print("B") break elif (grade >= 3.33 and grade <= 3.66): print("B+") elif (grade >= 3.67 and grade <= 3.99): print("A-") break elif (grade == 4.00): print("A") break elif (grade == 4.00): print("A+") else: print("Invalid input enter FLOAT only") def main2(): question = input("Continue (y/n)") if question == "y" or question == "Y": calci() if question == "n" or question == "N": print("Bye") print("ISQA 4900 quiz") main2() TWO PROBLEM1)it need to ask question everytime 2) it should show an invalid message

Solutions

Expert Solution

def calci():
grade = float(input("Enter your grade:"))
if (grade >= 0.00 and grade <= 0.67):
print("F")
elif (grade >= 0.67 and grade <= 0.99):
print("D-")
elif (grade >= 1.00 and grade <= 1.32):
print("D")
elif (grade >= 1.33 and grade <= 1.66):
print("D+")
elif (grade >= 1.67 and grade <= 1.99):
print("C-")
elif (grade >= 2.00 and grade <= 2.32):
print("C")
elif (grade >= 2.33 and grade <= 2.66):
print("C+")
elif (grade >= 2.67 and grade <= 2.99):
print("B-")
elif (grade >= 3.00 and grade <= 3.32):
print("B")
elif (grade >= 3.33 and grade <= 3.66):
print("B+")
elif (grade >= 3.67 and grade <= 3.99):
print("A-")
elif (grade == 4.00):
print("A")
elif (grade == 4.00):
print("A+")
else:
print("Invalid input enter FLOAT only")

def main2():
calci()
while(True):
question = input("Continue (y/n)")
if question == "y" or question == "Y":
calci()
if question == "n" or question == "N":
print("Bye")
break;
  
print("ISQA 4900 quiz")
main2()


Related Solutions

def main():     print('This program determines whether you have hypertension.')     systolic_pressure = float(input('Enter your systolic...
def main():     print('This program determines whether you have hypertension.')     systolic_pressure = float(input('Enter your systolic pressure: '))     diastolic_pressure = float(input('Enter your diastolic pressure: '))     # insert statement here to call the hypertension_tester function def hypertension_tester(dp, sp):     if sp >= 140 or dp >= 90:         print('You have hypertension')     else:         print('You do not have hypertension') main() A person has hypertension if systolic pressure is 140 or above or diastolic pressure is 90 or above. Which of the...
USING PYTHON 3.7 AND USING def functions. Write a function called GPA that calculates your grade...
USING PYTHON 3.7 AND USING def functions. Write a function called GPA that calculates your grade point average (GPA) on a scale of 0 to 4 where A = 4, B = 3, C = 2, D = 1, and F = 0. Your function should take as input two lists. One list contains the grades received in each course, and the second list contains the corresponding credit hours for each course. The output should be the calculated GPA. To...
Copy the following Python fuction discussed in class into your file: from random import * def...
Copy the following Python fuction discussed in class into your file: from random import * def makeRandomList(size, bound): a = [] for i in range(size): a.append(randint(0, bound)) return a a. Add another function that receives a list as a parameter and computes the sum of the elements of the list. The header of the function should be def sumList(a): The function should return the result and not print it. If the list is empty, the function should return 0. Use...
Please use Python! def getText(file): This function should open the file named file, and return the...
Please use Python! def getText(file): This function should open the file named file, and return the contents of the file formatted as a single string. During processing, you should (i) remove any blank lines, (ii) remove any lines consisting entirely of CAPITALIZED WORDS , and (iii) replace any explicit ’\n’ (newline) characters with spaces unless directly preceeded by a ’-’ (hyphen), in which case you should simply remove both the hyphen and the newline, restoring the original word. def getText(file):...
Write a Python function that takes as input parameters base_cost (a float) and customer_type and prints...
Write a Python function that takes as input parameters base_cost (a float) and customer_type and prints a message with information about the total amount owed and how much the tip was. As a reminder, the tip amounts are 10%, 15% and 20% for stingy, regular, and generous customers. And the tax amount should be 7%. The total amount is calculated as the sum of two amounts: check_amount = base_cost*1.07 tip_amount = tip_percentage*check_amount To receive full credit, you must use string...
Write a Python script that will collect 5 grades (float) from the student via input and...
Write a Python script that will collect 5 grades (float) from the student via input and obtain the average. requirements: a. Collect 5 floating grades from student b. Obtain the average of the grades
def main(): phrase = input('Enter a phrase: ') # take a phrase from user acronym =...
def main(): phrase = input('Enter a phrase: ') # take a phrase from user acronym = '' # initialize empty acronym for word in phrase.split(): # for each word in phrase acronym += word[0].upper() # add uppercase version of first letter to acronym print('Acronym for ' + phrase + ' is ' + acronym) # print results main() The program should then open the input file, treat whatever is on each line as a phrase and make its acronym using...
[In Python] Write a program that takes a .txt file as input. This .txt file contains...
[In Python] Write a program that takes a .txt file as input. This .txt file contains 10,000 points (i.e 10,000 lines) with three co-ordinates (x,y,z) each. From this input, use relevant libraries and compute the convex hull. Now, using all the points of the newly constructed convex hull, find the 50 points that are furthest away from each other, hence giving us an evenly distributed set of points.
How do I get the following code to accept a float input, while also fixing the...
How do I get the following code to accept a float input, while also fixing the syntax errors in the code because I can't figure out what is wrong with it. def chemical_strength(pH): if 0<pH>14: if pH <= 7: if pH = 7: ans = str("neutral") else: # ph < 7 if 0<pH>=1: ans = str("very strong acid") else: # 1<pH>7 if 1<pH>4: ans = str("strong acid") else: # 4=<ph>7 if pH = 4: ans = str("plain acid") else: #...
MATLAB QUESTION Write a python program to request a positive float input from the user, x....
MATLAB QUESTION Write a python program to request a positive float input from the user, x. The program should check for the value of x. If x is larger than or equal to 1.0, the program should display the value of x in addition to the string “is larger than or equal to 1” and then terminate the program. If x is less than 1 the program should calculate y such that: y = 1-x+x^2/2-x^3/3+x^4/4-x^5/5……-x^99/99+x^100/100 The program should then display...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT