100-Days OF Python-Day-09

                            Welcome Guys to Day-9


Today we will be discussing about dictionaries and nesting methods 



WAP for changing students score with grades



student_scores = {
  "Harry"81,
  "Ron"78,
  "Hermione"99
  "Draco"74,
  "Neville"62,
}
# 🚨 Don't change the code above 👆

#TODO-1: Create an empty dictionary called student_grades.
student_grades={}

#TODO-2: Write your code below to add the grades to student_grades.👇for key in students
for key in student_scores:
    student_scores1=student_scores[key]
    if student_scores1 > 91:
        student_grades[key]="Outstanding"
    elif student_scores1 > 80:
        student_grades[key]="Exceeds Expectations"
    elif student_scores1 > 70:
        student_grades[key]="Acceptable"
    else:
        student_grades[key]="Fail"
      
    


print(student_grades)

WAP for Travel log and adding country in travel log with function:
travel_log = [
{
  "country""France",
  "visits"12,
  "cities": ["Paris""Lille""Dijon"]
},
{
  "country""Germany",
  "visits"5,
  "cities": ["Berlin""Hamburg""Stuttgart"]
},
]
#🚨 Do NOT change the code above

#TODO: Write the function that will allow new countries
#to be added to the travel_log. 👇
def add_new_country(country_visited,visits_no,cities_visted):
    new_countries={}
    new_countries["country"]=country_visited
    new_countries["visits"]=visits_no
    new_countries["cities"]=cities_visted
    travel_log.append(new_countries)








#🚨 Do not change the code below
add_new_country("Russia"2, ["Moscow""Saint Petersburg"])
print(travel_log)

Comments

Popular posts from this blog

Top 5 Best Books For Python,Data Science & Machine Learning

How To Start A BLOG

Top 50 Most Innovative Companies in 2020

Why Should We learn C Programming?

Blogger Tutorial