You are on page 1of 7

#Day 1

# print()

# what does the print function do?


# What do we put inside the parentheses?
# print("hello world!")
# print('hello world!')

# why we use "" for strings?


# print(Hello world!)
# print("hello world)
# SyntaxError: EOl while scanning string literal

# practice:

# Print Function
# The function is declared like this:
# print('print("what to print")') ##### picture1

# describin about \n:

# print("Hello world")
# print("Hello world")
# print("Hello world")
# or using \n
# print("Hello world\nHello world\nHello world")

# combine tow srings by '+':

# combine tow separate strings into one


# print("Hello" + "name")
# print("Hello"+" "+"name")

# what is string? stirngs of conected characters


# picture "string"
# picture 3
# dey 4

# randomisatiom TETRIS
# site : askpython.com

# how to create random things:


# Deterministics create them by using Algorithms in python: Mersenne
Twister Algorithm

# 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

# create my_madule file and import it in main.py:


# pi = 3.14 import my_module
# print(my_module.pi)

# random.random()

# How we can creat a random float number between 0 and 5

# 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:

# place = input("give your place")


# hight = int(place[0])
# width = int(place[1])
# map[hight-1][width-1]="x"
# print(f'{row1}\n{row2}\n{row3}')

# day 9 Dictionary

# similar in real word for example: code: program instructions

# 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"}

# 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","Loop":"The action of doing something over and over again"}

# 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",
# }

# How can use the special item of dictionary?


# print(programing_dictionary["bug"])
# What if I use "bog" insted of "bug" >>> print(programing_dictionary["bog"])
# Make sure that you provide the key in its actual data type

# what if we want to add new element into dictionary?


# "Loop":"The action of doing something over and over again"
# programing_dictionary["Loop"] = "The action of doing something over and over
again"

# make full an empty dictionary


# empty_dictionary = {}

# edit an item in ditionary is as same as adding new item


# loop through the dictionary
# for thing in programing_dictionary:
# print(thing)

# for key in programin_dictionary:


# print(key)
# print(programing_dictionary[key])

# exercize

# if score higher than 90 >>>> exelent


# if score between 80 and 90 >>> good
# if score between 70 and 80 >>> acceptable
# if score lower than 70 >>> fail

# student_scores = {
# "barsam": 92,
# "Araz": 87,
# "Sahand": 99,
# "Ali": 86,
# "Hasti": 71,
# "niloofar": 50
# }
# create an empty dictionary here named student_grades:

# write your code here:

# 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:

# for student in student_scores:


# score = student_score[student]
# if score>90:
# student_grades[student]="exelent"

# 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"
# }

# nesting a dictionary in a dictionary


# write the number of visit each city then add total visit

# write a dictionary in a list

# 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)

You might also like