Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Prepare the flow diagram for this python code. import math #function to get grade def getGrade(x): if(x>90): return 'A' elif(x>80): return 'B' elif(x>70): return 'C'

Prepare the flow diagram for this python code.

import math

#function to get grade def getGrade(x): if(x>90): return 'A'

elif(x>80): return 'B'

elif(x>70): return 'C'

elif(x>60): return 'D'

elif(x>50): return 'E'

else: return 'F'

# main function def main(): # ask user to enter credit hours and marks #list to store subject name subject = ["Mass Transfer","Heat Transfer","Surface Chemistry","Fuels","Petrochemical"]

# store marks and credit hours credit = [] marks = []

# ask user for i in range(0,5): a = int(input("Enter Credit hours and marks of "+subject[i]+" ")) b = int(input(""))

credit.append(a) marks.append(b)

# now print info temp = "i" temp1 = "Courses" temp2 = "Credit Hours,Wi" temp3 = "Marks" temp4 = "Grade,Gi"

# format all temp = "{0:<2}".format(temp) # left align width 2 temp1 = "{0:<20}".format(temp1) # left align width 20 temp2 = "{0:^20}".format(temp2) # center align width 20 temp3 = "{0:^10}".format(temp3) # center align width 10 temp4 = "{0:^15}".format(temp4) # center align width 15 print(temp+temp1+temp2+temp3+temp4)

# print all for i in range(0,5): temp = "{0:<2}".format(i+1) # left align width 2 temp1 = "{0:<20}".format(subject[i]) # left align width 20 temp2 = "{0:^20}".format(credit[i]) # center align width 20 temp3 = "{0:^10}".format(marks[i]) # center align width 10 temp4 = "{0:^15}".format(getGrade(marks[i])) # center align width 15

print(temp+temp1+temp2+temp3+temp4) # print GPA GPA = 0.0 s = 0.0 for i in range(0,5): GPA = GPA + float(credit[i]*marks[i]) s = s+credit[i]

print("GPA = "+str((GPA/s)));

# PROGRAM EXECUTION STARTS HERE main()

Note: Please prepare the flow diagram for this python code and do not copy from any place .

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions