#phyton ''' Please help me to solve this error. Error: Traceback (most recent call last): File "/Users/mdhossain/Desktop/p4.py", line 91, in main() File "/Users/mdhossain/Desktop/p4.py", line 83, in main (x, y, z) = get_scores() TypeError: cannot unpack non-iterable NoneType object ''' # Please do not use append & tuple def get_scores(): #Ask user to input x = int(input('Enter 1st posative number: ')) #check valid number while x < 0: print('invalid input! Must be posative') x = int(input('Enter 1st posative number: ')) break #Ask user to input y = int(input('Enter 3rd posative number: ')) #check valid number while y < 0: print('invalid input! Must be posative') y = int(input('Enter 1st posative number: ')) break #Ask user to input z = int(input('Enter 3ed posative number: ')) #check valid number while z < 0: print('invalid input! Must be posative') z = int(input('Enter 3rd posative number: ')) # it will return xyz return x, y, z break def calculate_average(score1, score2, score3): #get avg value return (score1 + score2 + score3) / 3 #grade def assign_grade(score): if (score >= 90): return 'A' elif (score >= 80 and score < 90): return 'B' elif (score >= 70 and score < 80): return 'C' elif (score >= 60 and score < 70): return 'D' else: return 'F' def show_results(num, letterGrade): print("Average score:", num) print("Assigned letter grade:", letterGrade) def main(): (x, y, z) = get_scores() avgScore = calculate_average(score1, score2, score3) letterGrade = assign_grade(avgScore) show_results(avgScore, letterGrade) main()
#phyton
''' Please help me to solve this error.
Error:
Traceback (most recent call last):
File "/Users/mdhossain/Desktop/p4.py", line 91, in <module>
main()
File "/Users/mdhossain/Desktop/p4.py", line 83, in main
(x, y, z) = get_scores()
TypeError: cannot unpack non-iterable NoneType object
'''
# Please do not use append & tuple
def get_scores():
#Ask user to input
x = int(input('Enter 1st posative number: '))
#check valid number
while x < 0:
print('invalid input! Must be posative')
x = int(input('Enter 1st posative number: '))
break
#Ask user to input
y = int(input('Enter 3rd posative number: '))
#check valid number
while y < 0:
print('invalid input! Must be posative')
y = int(input('Enter 1st posative number: '))
break
#Ask user to input
z = int(input('Enter 3ed posative number: '))
#check valid number
while z < 0:
print('invalid input! Must be posative')
z = int(input('Enter 3rd posative number: '))
# it will return xyz
return x, y, z
break
def calculate_average(score1, score2, score3):
#get avg value
return (score1 + score2 + score3) / 3
#grade
def assign_grade(score):
if (score >= 90):
return 'A'
elif (score >= 80 and score < 90):
return 'B'
elif (score >= 70 and score < 80):
return 'C'
elif (score >= 60 and score < 70):
return 'D'
else:
return 'F'
def show_results(num, letterGrade):
print("Average score:", num)
print("Assigned letter grade:", letterGrade)
def main():
(x, y, z) = get_scores()
avgScore = calculate_average(score1, score2, score3)
letterGrade = assign_grade(avgScore)
show_results(avgScore, letterGrade)
main()
Exper
Step by step
Solved in 4 steps with 4 images