Python
Python
User input:
Input:
New website ask User name and password
NAME =input("Enter your name here: ")
print(NAME)
output:
x,y = y,x
print (y)
print (x)
===>Ans ; show x=13 and y =13
1:08
Arithmatic Operation:
+,-,%,//,/,**,*
Comparisaon Opeators:
>,<,==,!=,>=,<=,
Logical operations:
and,or,not
and : bane condition true
or: bane mathi ek conditon
not : avaliable both -false aavase ==> result thi opoostie mate
print (not(3>4 and 5>7))
---1:26
assignment operators:
assign the value
game score 0
+=1 menas + j thasee
-=5 means - j thase
*=3 menas *
identidity operator:
is type
a=1234
b=1234
print(a is b)
answer true
is not type
a=1234
b=1234
print(a isnot b)
answer false
a=10 b=8
print (a & b)
ans 8
OR:
0,0=0
1,0=1
0,1=1
1,1=1
a=10 b =8
print (a|b)
Ans 10
bitwise Xor operations:
0^0=0
1^0=1
0^1=1
1^1=0
a=10 b =8
print (a^b)
Ans 2
zero fill left shift : 10=1010 10>>>2 aagad ni be value add kar se pachad ni kadhi
nakh se
print (10>>1 )
answer 5
zero fill right shift :
10=1010
10<< 2 =40
print (10<<2 ) ans 40
membership operator
In Type:
a="hello"
print ("e" in a)
Ans true
1:47
conditional statments
if : varaible pass kiya ye condition satisfy or not kam karse nahitar next block ma
jase
marks=87
if marks >= 90;
print('you will get a mobile phone')
# scripts above blok 87 na case ma
print ("thank you")
Ans thank you
if else
bane mathi 1 condtion thasej
marks= 87
if marks>=90:
print ("youwill get mobile)
else:
print ("no phone")
Ans no phone
if elif else
multiple condtions last me ye karna he ya hoga
marks= 87
if marks>=90:
print ("youcan get gift")
elif marks>80 and marks<90:
print ("You will get a new phone")
elif marks>=70 and marks<80:
print ("you will get book")
else:
print ("no phone")
Ans you will get a new phone
nested if statements
--2:04
if ni adar if aave nestled
else last ma aapi finished karay jo if wadi na thay
Marks=87
if marks>=80:
pringt ("you will get phone")
if marks>=95:
print("willget iphone")
else:
print("No phone")
Short if else:
Marks=87
Problem Solving:
number postive or negative
num=(int(input("enter number: "))
if num >0:
print("it is postive")
else:
("it is negative")
if num % 2==0:
Print ("it is even")
else:
Print ("It is odd")
Create area calculator:
print("***area calcultor***")
print(""" press 1 to get the area of square
press 2 to ger area rectangle
press 3 to get circle
press 4 to get the area of triangle")
Choice=int(input("enter number 1 to 4: ")
if choice ==1:
side = float(input("enter the length of one side: "))
area= side**2
print("area of sware is",area)
elif_choice ==2:
length = float(input("enter length of retan: "))
width =float(input("enter the widethe of rec: *))
area=lenght* width
print ("the area of rectangle is " : ,area)
elif_choice =3;
radius= float(input("enter the radis circle: "))
2:28
area((22/7)*(radis**2))
print("the are of circle",area)
elif choice == 4;
base =_float(inpute(enter the tiangel:*00
height= floa
area=