<jupyter_start><jupyter_text>Loop, Conditional Control and Function    Loop and Conditional Control -  for<jupyter_code>print([1,5,8,12,48])
for num in [1,5,8,12,48]:
    print(num)
for .. in ..... :
    .....
    .....
    .....
    .....
    .....
users = ['Saeed', 'Yalda', "Sajjad" , 'Hadise' , 'Javad']
print(users)
users[1]
for user in users:
    print(user)
for user in users:
    print('Hi')
    print(user)
print('Bye')
for user in users:
    print('Hi')
    print('welcome, ' + user + '!')
print('Welcome, We are glad to see you all')
for i in [1,5,8,12,48]:
    print(i*i)
for letter in "Python Course":
    print(letter.upper())
list(range(3, 11))
for i in range(3, 10):
    print(i*3)
squares = []

for i in range(1,25):
    square = i ** 2
    squares.append(square)

print(squares)
print(list(range(1,25)))

len(squares)
list_sum = 0

for i in range(1, 11):
    #print(i)
    list_sum = i + list_sum
    
print(list_sum)<jupyter_output>55<jupyter_text>-  while (pass, continue, break)<jupyter_code>n = 0
while n < 10 :
    print(n)
    n = n + 1
x = 1
while x > 10**(-4):
    print(x)
    x = x / 5
x = 1
while x > 1e-4:
    print(x)
    x = x / 5
x = [ 1 , 2, 3]
for i in x :
    # comment
    pass<jupyter_output><empty_output><jupyter_text>-  if, elif , else<jupyter_code>if 3 < 2 :
    print('That is True!')
age = int(input('Enter your age: '))

if age >= 18:
    print("You are old enough to vote!")
else:
    print('You can nit vote yet')
age = int(input('Enter your age: '))

if age >= 18:
    print("You are old enough to vote!")
else:
    print('You can not vote yet.')
    print("You can will vote after {} years.".format(18 - age))
age = int(input('Enter your age: '))

if age <= 4:
    price = 0
elif age <= 16:
    price = 5
else:
    price = 10
    
print("Your cost is ${}.".format(price))
grade = 'C'

if grade == 'A':
    print('Well done!')
elif grade == 'B':
    print('Try more!')
#elif grade == 'C':
else:
    print('fail')
my_list1 = [1,4,7,8,19,23,112,36]

for num in my_list1:
    if num % 2 == 0:
        print(num, 'is EVEN number!')
    else:
        print('ODD')<jupyter_output>ODD
4 is EVEN number!
ODD
8 is EVEN number!
ODD
ODD
112 is EVEN number!
36 is EVEN number!<jupyter_text><jupyter_code>mystring = 'nothing'

for letter in mystring:
    if letter == 't':
        continue
    print(letter)
mystring = 'nothing'

for letter in mystring:
    if letter == 'h':
        break
    print(letter)
mystring = 'nothing'

for letter in mystring:
    print(letter)
    if letter == 'h':
        break    
x = 0
while x < 5:
    if x == 3:
        break
        
    print(x)
    x = x + 1 
    
    
for i in range(4):
    for j in range(2):
        print(i,j)<jupyter_output>0 0
0 1
1 0
1 1
2 0
2 1
3 0
3 1<jupyter_text>Function  -   frame<jupyter_code>def test_1():
    ....
    ...
    ...
    ...
    return ...
def test_2():
    ...
    ...
    ...
    print(...)
test_1()
test_2()
def test_3(x, y, z):
    ....
    ...
    ...
    ...
    print(....) # return ....
test_3(2, 5 , -98)
def test_4():
    ...
    ...
    ...<jupyter_output><empty_output><jupyter_text>-   Example<jupyter_code>def echo(i):
    print(i)
echo('Salaaam!')
x = echo('Salaaam!')
print(x)
def mean3(x , y , z):
    return (x+y+z)/3
mean3(2 , 45 , -69)
def mean3B(x, y , z):
    sum_ = x + y + z
    ave = sum_ / 3
    return ave
mean3B(2,45,-69)
def mean3C():
    x = float(input('first: '))
    y = float(input('second: '))
    z = float(input('third: '))
    sum_ = x + y + z
    ave = sum_ / 3
    return ave
mean3C()
def hello():
    name = input('Enter your name: ')
    
    if name:
        print('Hello ' + str(name) + ' !')
    else:
        print('Hello World!')
    return


hello()
def price():
    age = int(input('Enter your age: '))

    if age <= 4:
        price = 0
    elif age <= 16:
        price = 5
    else:
        price = 10
        
    print("Your cost is ${}.".format(price))
    
price()
price()
# Guess number
import random

cump_num = random.randint(1 , 100)
cump_num
def guess_number():
    user_num = int(input('Enter your guess number: '))
    
    while user_num != cump_num:
        if user_num > cump_num:
            print('Enter a small one!')
        elif user_num < cump_num:
            print('Enter a bigger one!')
        
        user_num = int(input('Enter your guess number: '))
    
    print('Well DONE!')
    
guess_number()

# guess counter
# contact
# 1
def contact():
    contact = {}
    
    name = input('Enter your name: ')
    phone = input('Enter phone number: ')
    email = input('Enter email id: ')
    
    contact[name] = phone , email
    return contact

contact()
# 2
def contact():
    contact = {}
    
    name = input('Enter your name: ')
    phone = input('Enter phone number: ')
    
    # 09199193216
    while len(phone) != 11 or not phone.isdigit():   # new
        print('Invalid phone number!')               # new
        phone = input('Enter phone number: ')        # new
    
    email = input('Enter email id: ')
    
    while email.find('@') == -1:          # new
        print('Invalid email id')         # new
        email = input('Enter email id: ') # new
    
    
    contact[name] = phone , email
    return contact

contact()
# 3
def contact():
    contact = {}
    
    while True:
        
        name = input('Enter your name: ')
        
        if name == 'end':
            break
        
        phone = input('Enter phone number: ')
        
        # 09199193216
        while len(phone) != 11 or not phone.isdigit():   # new
            print('Invalid phone number!')               # new
            phone = input('Enter phone number: ')        # new
        
        email = input('Enter email id: ')
        
        while email.find('@') == -1:          # new
            print('Invalid email id')         # new
            email = input('Enter email id: ') # new
        
        
        contact[name] = phone , email
    return contact

contact()
list_cont = contact()
list_cont
list_cont['javad']<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15665236051502146, 'fraction_numerical': 0.03152855727963024, 'mean_word_length': 2.06010101010101, 'pattern_counts': {'":': 1, '<': 30, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '486038', 'license': 'MIT', 'n_tokens_mistral': 2319, 'n_tokens_neox': 2173, 'n_words': 617, 'path': 'lecture/.ipynb_checkpoints/2. Conditional Control and Function-checkpoint.ipynb', 'repo_name': 'saeed-saffari/alzahra-workshop-spr2021', 'size': '6058'}