<jupyter_start><jupyter_text>![How to speak python](Pics/harry.png)  Python A high-level language & Interpreted language![](Pics/comVSinter.png) Why python* Simple and fast to /learn/implement/diagnostic .... everything.* Modern Where is python* Everywhere  Python Shortcomings* **Fast to code, Slow to run**![](Pics/execution.png)* **Python is interpreted language can raise mistakes*** **Python is Dynamically Typed rather than Statically Typed no optimization*** **GIL**  Solution* **Python has FOSS (Free and Open Source Software) spirit soeverything is solvable**![](Pics/pack.png)  Let's say Hello<jupyter_code>print('Hello world')
print("Hello world")
print("Hello people's of the world")
print('this is double quotation:"')
print("Hello","World",1,"time")<jupyter_output>Hello World 1 time<jupyter_text>Variables: * **A reserved space with a name:** ![](Pics/memory.png)   * **Assignment (meghdar dehi!):**  ![](Pics/name.png) VariableName (left) = value (right)<jupyter_code>age = 50
height = 175.2
letter = "M"
letter
print(letter)
full_name = "<NAME>"
TorFalse = True
# this is comment
age = 30 # this is age of the user
_name = 'M'
firstName = "M"
if = 1
_print = 2
print(_print)
GPA = 3.8
GPA = GPA * 0.1
GPA
print(GPA+1)
full_name = "Reza"+" "+"1"
print(full_name)
"Reza"*2
a = 1 
b = 2
a = b
a = 1 
b = 2
c = a
a = b
b = c
print("a=",a,"b=",b)
Name = "Reza"
age = "34"
print("My Name is ",Name,"And I am",age,"Y.O.")
Name = input("Enter you name ")
age = input("Enter your age ")
print("My Name is ",Name,"And I am",age,"Y.O.")
type(age)<jupyter_output><empty_output><jupyter_text>String Options<jupyter_code>g = -9.8
t = 10.0
v = 100.0
y0 = 0

y = 0.5*g*t**2 + v*t+y0
y
"With GA = %.2f, time = %.0f, and velocity = %.2e, initial position =%d; y = %f"%(g,t,v,y0,y)
print("%d"%100.9)
print("1/3=%.2e"%(1/3))
print("my name is %s"%("reza"))<jupyter_output>my name is reza<jupyter_text>Escape sequence<jupyter_code>my_str = "First Line \nSecond line"
my_str
print(my_str)
my_str = r"First segment \t Second Segment"
print(my_str)
my_str = "this is a looooooooooooooooooooooooooooooooooooooooo\
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooog line"
print(my_str)
i = 5
j = \
5
print(j)
my_str = """
%dst line
%dndline
%drdline
...
"""%(1,2,3)
print(my_str)
# this comment
# 1line
# 2ndline
# 3rd line
i = 5; print(i); 
print("HW")
type("<NAME>")
int(float("123.3434"))
float("2")
bool(-10.121212)
x = input("Enter something")
type(x)
type(eval(x))
name = input("Enter the var name ")
value = input("Enter the var value")
exec("%s = %s"%(name, value))
age<jupyter_output><empty_output><jupyter_text>()** */ + -<jupyter_code>a = 1
res = a <= 1
type(res)
False or False
False or True
True or True
not(bool(0))
a = 1
(a >= 0) and (a == 1 )
| &<jupyter_output><empty_output><jupyter_text>IF; IF, ELIF; ELSE<jupyter_code>x = eval(input("Enter a number"))

if (x>0): 
    print("+")
elif (x==0):
    print("Adad is sefr")
else:
    print("Manfi")


x = eval(input("Enter a number"))
if (x%2 == 0):
    print("Zooj")
else:
    print("Fard")
x = 1 , y = 2
if (x<y):
    print("x<y")
elif (x==y):
    print("x=y")
else:
    print("x>y")
a = 1; b = 3 ; c = 10
max_num = a
if (b>a):
    max_num = b
if (c>b):
    max_num = c
    
print(max_num)
max_number = 10
counter = 1
while (counter <= max_number):
    print(counter)
    counter = counter + 1
upper_lim = 10
step = 2
while (step<=upper_lim):
    print(step)
    step = step*2<jupyter_output>2
4
8<jupyter_text>Break, Continue<jupyter_code>upper_lim = 10
step = 2
while (step<=upper_lim):
    if(step==5):
         step +=1
         continue
    print(step)
    step += 1
hidden_num = 10
x = eval(input("Enter your number"))

while (x!= hidden_num ):
    if (x>hidden_num):
        print("Kemtre")
        x = eval(input("Enter your number"))
    else:
        print("Bishtare")
        x = eval(input("Enter your number"))
        
print("BorD")<jupyter_output>Enter your number12
Kemtre
Enter your number11
Kemtre
Enter your number10
BorD<jupyter_text>Function<jupyter_code>def say_hello(name):
    print("Hello %s"%name)
say_hello(1)
def Zarb2(x):
    print(x*2.1)
Zarb2("m")
def do_nothing():
    pass
    
do_nothing()
def my_func(havij):
    havij=2
    print(havij)
x= 50
my_func(x)
print(x)
def my_func():
    global x
    x=2
    print(x)
my_func()
f = lambda x,y: x*y
f(1,2)
def my_func(havij):
    havij=2
    return havij
a = my_func(2)
print(a)
def location(v0,t,g=9.8):
    """
    
    """
    return -0.5*g*t**2+v0*t
location()
x = eval(input("Enter your number"))

while (x!= hidden_num ):
    if (x>hidden_num):
        print("Kemtre")
        x = eval(input("Enter your number"))
    else:
        print("Bishtare")
        x = eval(input("Enter your number"))
        
print("BorD")
def hads(x, hidden_num = 10):
    while (x!= hidden_num ):
        if (x>hidden_num):
            print("Kemtre")
            x = eval(input("Enter your number"))
        else:
            print("Bishtare")
            x = eval(input("Enter your number"))

    print("BorD")
    
    
hads(10,100)
def max3(x,y,z):
    """
    this fucntion return the maximum number of three number
    """
    max_res = x
    if y>max_res:
        max_res=y
    if z>max_res:
        max_res = z
    return max_res

? max3
max3(3,20,100)
type.__doc__
help()<jupyter_output><empty_output><jupyter_text>Data Structure * Int, Float, String* List* Tuple* Dictionary* Set* ===========> create new data type with "class"  List![](Pics/darray.png)<jupyter_code>my_list = [1,2,3,4,5]
my_list2 = [1, "String",True, my_list]
my_list2
my_list2[3][3]
my_list2[1:3]
my_list2[:]
my_list
len(my_list2)
my_list2[len(my_list2)-1]
my_list2
my_list2[1:-1]
my_list2.index("String")
myList1 = [1, 2,2, 'String', False, [2, 3, 4, 5]]
myList1.index(2)
myList1.count(0)
myList = [1,2,3,40]
myList.sort()
myList
a= [1,2,3]
b = a
b[0] = 100
b
a
id(a)
id(b)
b = a.copy()
b
id(b)
id(a)
b[0]= 1
b
a
a = [1,2,3,4]; b = [5,6,7,8]
a+b
[1,2,3,4]*4.0
a = [1,2,3,4]
a + [1]
a = []

type(a)
a.append(1)
a.append(2)
a
A = 1
A = A+1
A
a = a+[3]
a = [0]+a
a<jupyter_output><empty_output><jupyter_text>String<jupyter_code>my_str = "Well, Hello there"
len(my_str)
my_str[:4]
my_str.replace("e","")
my_str<jupyter_output><empty_output><jupyter_text>For loop<jupyter_code>for i in [1,2,3]:
    print(i)
elements = [1,2,3, "Havij"]
for element in elements:
    print(element)
elements[:2]
for i in range(3,9,2):
    print(i)
print(type(range(3,9,2)))
list(range(1,20))
mstr = 'Majid'
list(mstr)
'-'.join(list(mstr))
myL = []
for i in range(100):
    myL.append(i**2+3)
a = [item**2 for  item in range(100)] 
def myfunction(x):
    return x**2+3
[myfunction(x) for x in range(100)]

[(lambda x:x**2+3)(havij) for havij in range(100)]
# f = lambda x:x**2+3
# [lambda x:x**2+3(havij) for havij in range(100)]

[lambda havij:havij**2+3 for havij in range(100)]<jupyter_output><empty_output><jupyter_text>Tuple<jupyter_code>my_tuple = 1,2,3,4
type(my_tuple)
my_tuple = 1,2,3,4
type(my_tuple)
my_tuple = (1,2,3,4)

type(my_tuple)
my_tuple = (1,)
type(my_tuple)
len(my_tuple)
my_tuple[0] = 10
a = my_tuple
id(a)
id(tuple)
def myf(a,b):
    return a+b, a-b
type(myf(1,2))
a =1 
b = 2

a, b = b, a
a

b
a = "mmm"
b = 'mmm'
for i,j in zip(a,b):
    print(i,j)
a = ['m','n','k']
for i,j in enumerate(a):
    print(i,j)
for i,j in zip(range(len(a)),a):
    print(i,j)
m = {2:1}
m[2]
m = dict()
m['Apple'] = "Mooz"
m["Banana"] = 'Seed'
m
my_set = {1,2,3,4,5,"mmm"}
my_set 
set(range(10))
mList = [1,1,1,1,1,1,1,1,11,1,1,1]
mList = set(mList)
mList.add(10)
mList
ty
print(type(1))<jupyter_output><class 'int'><jupyter_text>Class and InstanceClass creates a new data structureClass: a group things with common featurea Car:* 4 wheel* Engine* some doors* windows* lights...Instance is a thing that belongs to the classwhat make this things distinct? Class CarInstance 1: <NAME>raInstance 2: Pride![](Pics/class.png)  Module  funtion and data structure* Variables of a Module called Attributes* Functions of a Module called Methods<jupyter_code>import math
math.pi
from math import pi, sin
sin(pi)
math.sin(math.pi)
for i in [pi,pi]:
    print(sin(i))
import os
os.getcwd()
os.listdir()
os.path.isfile('How to speak python.ipynb')
os.mkdir("M")
os.listdir()
os.path.join(os.getcwd(),"M")
import time
t0 = time.time()
time.sleep(2)
    
print(time.time()-t0)
    
    
help(time)
dir(time)
havij = open("output1.txt","a")
havij.write("first line\n")
havij.close()
havij = open("output1.txt","r")
a = havij.readlines()
a[1]
print(a)
havij.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17999299638146377, 'fraction_numerical': 0.03887008287615268, 'mean_word_length': 4.275862068965517, 'pattern_counts': {'":': 0, '<': 58, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '13', 'dir': 'jupyter-structured-clean-dedup', 'id': '133161', 'license': 'MIT', 'n_tokens_mistral': 3796, 'n_tokens_neox': 3636, 'n_words': 886, 'path': 'notebooks/1 - Python intro.ipynb', 'repo_name': 'Gamein-SUT/DataMining-With-Python---Gamein2020', 'size': '8584'}