a=5
if a>3:
print("a>3 is true")
else:
print("a>3 is false")
a=1.3
if a>1:
if a>2:
print("a>2")
else:
print("1<a<2")
else:
print("a<1")
a=4
if a/2==a//2:
print("a==2n")
else:
print("a!=2n")
a=6
if a/2==a//2 and a/3==a//3:
print("ok")
else:
print("rong!")
a=6
if a/2==a//2 or a/3==a//3:
print("ok")
else:
print("rong!")
name='reza'
if name=='Ali':
print("salam",name)
elif name=='Hasan':
print("byby ",name)
else:
print("nothing.")
$ax^2+bx+c$
a=-3
b=2
c=-2
delta=b**2-4*a*c
if delta>0:
print("ریشه حقیقی",delta)
elif delta<0:
print("ریشه مختلط",delta)
else:
print("ریشه مضاعف",delta)
number = 23
guess = int(input('Enter an integer : '))
if guess == number:
print('Congratulations, you guessed it.') # New block starts here
print("(but you do not win any prizes!)") # New block ends here
elif guess < number:
print('No, it is a little higher than that') # Another block
# You can do whatever you want in a block ...
else:
print('No, it is a little lower than that')
# you must have guess > number to reach here
print('Done')
# This last statement is always executed, after the if statement is executed
guess = int(input('Enter an integer : '))
if guess%2 == 0:
print('x=2c') # New block starts here
else:
print('x!=2c') # New block starts here
x = int(input('Enter an integer 1<x<10 : '))
#1 2 3 5 8
if x == 1:
print('ok') # New block starts here
elif x==2:
print('rong') # New block starts here
#!/usr/bin/python
# Filename: if.py
a= input('Enter a number : ')
afloat=float(a)
aint=int(afloat)
if aint==afloat:
print('It is an integer number') # New block starts here
else:
print('It is a float number') # New block starts here
x=1.236487979646
n=4
x=int(x*10**n)
x=x/10**n
print(x)
x=1.236487979646
sx=str(x)
print(sx)
type(x)
type(sx)
txt='salam ali.'
print(txt)
txt[0]
txt[5]
s=txt[0:-2]
print(s)
x=10.236487979646
n=2
sx=str(x)
print(sx[0:2+1+n])