Professional Documents
Culture Documents
# print()
# practice:
# Print Function
# The function is declared like this:
# print('print("what to print")') ##### picture1
# print("Hello world")
# print("Hello world")
# print("Hello world")
# or using \n
# print("Hello world\nHello world\nHello world")
# randomisatiom TETRIS
# site : askpython.com
# import random
# random_int = random.randint(1,10)
# print(random_int)
# random module
# what is module:
# imagen that a person wants to creat a car! that is crazy if he want to do that
by self
# peaple recagnize the work into the bunch of part and each group do the specific
work<<<<<in car example we have tier_module
# python create some module for us to use them without have to create them
fundomentally
# random.random()
# Exsersize:
# Hint : you may have to use len() function
# import random
# people = input("give the of owners: ").split(",")
# choosen_people = random.choice(people)
# print(choosen_people+" is going to pay the bill today.)
# Alireza,Amirhossein,Shadi,Hasti
# name = input("give me your names: ").split(",")
# print(name")
# nested List:
# delish.com
# dirty_dozen =
["Strawberries","Spinach","Kale","Nectarines","Apples","Grapes","Peaches",]
# "Cherries","Pears","Tomatoes","Celery","Potatoes"]
# fruits =
[Straeberries,Nectarines,"Apples","Grapes","Peaches","Cherries","Pears"]
# vegetables = ["Spinach","Kale","Tomatoes","Celery","Potatoes"
# nested_list = [fruits,vegetables]
# print(nested_list)
###############################
# row1 = ["😍","😍","😍"]
# row2 = ["😍","😍","😍"]
# row3 = ["😍","😍","😍"]
# map = [row1,row2,row3]
# print(f'{row1}\n{row2}\n{row3}')
################################
# sulotion:
# day 9 Dictionary
# dictionary have two part: Key > value pcs: dictionary in real life
# programing_dictionary = {
# "Bug":"An error in a program that prevent the program from running as
expected",
# "function":"A piece of code that you can easily call over and over again",
# }
# exercize
# student_scores = {
# "barsam": 92,
# "Araz": 87,
# "Sahand": 99,
# "Ali": 86,
# "Hasti": 71,
# "niloofar": 50
# }
# create an empty dictionary here named student_grades:
# print(student_grades)
# student_scores = {
# "barsam": 92,
# "Araz": 87,
# "Sahand": 99,
# "Ali": 86,
# "Hasti": 71,
# "niloofar": 50
# }
# create an empty dictionary here named student_grades:
# student_grades = {}
# write your code here:
# print(student_grades)
# nesting dic
# my_dic = {
# "key1": list,
# "key2": dict
# }
# Capitals = {
# "France": "Paris",
# "Germany": "Berlin"
# }
# city_country = {
# "Italy":"Rome","Milano","Napoli",
# "Germany":"Berlin","Humburg"
# }
# exersize
############################
# travel_log = [
# {
# "country": "France",
# "Visits": 12,
# "Cities": ["Paris","Lille","Dijon"]
# },
# {
# "country": "Germany",
# "Visits": 5,
# "cities": ["Berlin","Humburg"]
# }
# ]
################################################
# write a function that add a new country ... to the travel_log.
#################################################
# add_new_country("Russia",2,["Moscow","Saint petersburg"])
# print(travel_log)
# sulotion:
# travel_log = [
# {
# "country": "France",
# "Visits": 12,
# "Cities": ["Paris","Lille","Dijon"]
# },
# {
# "country": "Germany",
# "Visits": 5,
# "cities": ["Berlin","Humburg"]
# }
# ]
# ################################################
# # write a function that add a new country ... to the travel_log.
# def add_new_country(country_visited,times_visited,cities_visited):
# new_country = {"country":country_visited,
# "visits": times_visited,
# "cities": cities_visited
# }
# travel_log.append(new_country)
# #################################################
# add_new_country("Russia",2,["Moscow","Saint petersburg"])
# print(travel_log)