In: Computer Science
Python Coding:
Working with Conditions and Dictionaries.
1. Create three dictionaries (student_1, student_2, student_3).
2. In each student dictionary have a key-value for first_name, last_name, and an id number (6 digit), and a current_course. The values assigned to each of these keys is your choice.
3. Also each student will have in their dictionary a list for grades. You will need to add 3 grade values into the list.
4. Provide the student with a message about each assignment grade based on the grade value.
For each of the grades for each assignment:
Provide a 90-100 grade message. My example used 'Congratulations'
Provide a 80-89 grade message. My example used 'Good job!'
Provide a 70-79 grade message. My example used 'You passed!'
Provide a 60-69 grade message. My example used 'Bad news, below average'
59 or lower grade message would be 'Failed.'
For each grade:
'You have made a {grade value} on assignment {assignment number}.
5. Print out each student's data as shown in the example output below:
Name: Smith, John
Id: 646562
Course: ITSE 1359
Grades: 86, 74, 94
Good job!
You have made a 86 on assignment 1.
You passed!
You have made a 74 on assignment 2.
Congratulations
You have made a 94 on assignment 3.
student1={"firstname":"ramana","lastname":"meesala","id":"101","course":"python","grades":[79,56,12]}
student2={"firstname":"pooja","lastname":"kalsi","id":"102","course":"python","grades":[87,12,99]}
student3={"firstname":"meghana","lastname":"pasam","id":"103","course":"python","grades":[45,65,32]}
print("Name: ",student1["firstname"],",", student1["lastname"])
print("Id: ",student1["id"])
print("Course: ",student1["course"])
l=student1.get("grades")
print("Grades: ",l[0],",",l[1],",",l[2])
for i in range(3):
if(90<=l[i]<=100):
print("Congratulations")
print("You have made a ",l[i]," on assignment ",i+1)
elif(80<=l[i]<=89):
print("Good job!")
print("You have made a ",l[i]," on assignment ",i+1)
elif(70<=l[i]<=79):
print("You passed!")
print("You have made a ",l[i]," on assignment ",i+1)
elif(60<=l[i]<=69):
print("Bad news, below average")
print("You have made a ",l[i]," on assignment ",i+1)
elif(l[i]<=59):
print("Failed")
print("You have made a ",l[i]," on assignment ",i+1)
print("Name: ",student2["firstname"],",", student2["lastname"])
print("Id: ",student2["id"])
print("Course: ",student2["course"])
l=student2.get("grades")
print("Grades: ",l[0],",",l[1],",",l[2])
for i in range(3):
if(90<=l[i]<=100):
print("Congratulations")
print("You have made a ",l[i]," on assignment ",i+1)
elif(80<=l[i]<=89):
print("Good job!")
print("You have made a ",l[i]," on assignment ",i+1)
elif(70<=l[i]<=79):
print("You passed!")
print("You have made a ",l[i]," on assignment ",i+1)
elif(60<=l[i]<=69):
print("Bad news, below average")
print("You have made a ",l[i]," on assignment ",i+1)
elif(l[i]<=59):
print("Failed")
print("You have made a ",l[i]," on assignment ",i+1)
print("Name: ",student3["firstname"],",", student3["lastname"])
print("Id: ",student3["id"])
print("Course: ",student3["course"])
l=student3.get("grades")
print("Grades: ",l[0],",",l[1],",",l[2])
for i in range(3):
if(90<=l[i]<=100):
print("Congratulations")
print("You have made a ",l[i]," on assignment ",i+1)
elif(80<=l[i]<=89):
print("Good job!")
print("You have made a ",l[i]," on assignment ",i+1)
elif(70<=l[i]<=79):
print("You passed!")
print("You have made a ",l[i]," on assignment ",i+1)
elif(60<=l[i]<=69):
print("Bad news, below average")
print("You have made a ",l[i]," on assignment ",i+1)
elif(l[i]<=59):
print("Failed")
print("You have made a ",l[i]," on assignment ",i+1)