SIMPLE PROGRAMS
PROGRAM 1: HELLO WORLD PROGRAM 2: STATIC
print("Hello World") VARIABLES
print(“Welcome to python”) a=10
print(a)
PROGRAM 3: DYNAMIC VARIABLE PROGRAM 4: TYPE OF
a=input("enter value of a") VARIABLE
print(a) a=input("enter value of a")
print(type(a))
PROGRAM 5: SUM OF TWO STATIC PROGRAM 6: SUM OF TWO
NUMBERS DYNAMIC NUMBERS
a=10 a=int(input("enter value of a"))
b=20 b=int(input("enter value of b"))
c = a+b c=a+b
print("sum= ", c) print("sum=", c)
PROGRAM 7: PRINT CHARACTER PROGRAM 8: PRINT STRING
c=’J’ c=”JACK"
print(c) print(c, ”Computer”)
PROGRAM 9: SUM OF THREE PROGRAM 10: SUM OF THREE
NUMBERS NUMBERS
a,b,c=map(int, input("enter three nos:").split()) a,b,c=map(int, input("enter three no
print("sum=",a+b+c) ").split(“,”))
print("sum=",a+b+c)
PROGRAM 11: CONVERT PRICE INTO PROGRAM 12: AREA AND
RUPEES AND PAISA CIRCUMFERENCE
price=float(input("enter a price")) PI=3.14
rs=int(price) R=float(input("enter the radius"))
ps=int((price-rs)*100) A=PI*R*R
print("Rupees=",rs) print("Area=",A)
print("Paisa=",ps) print("Circumference=",2*PI*R)
PROGRAM 13: MONTH AND DAYS PROGRAM 14: POWER
total=int(input("Enter Total Days")) FUNCTION
print("Month=",int(total/30),"Days=",total%30) base=int(input("enter base"))
power=int(input("enter power"))
print("Ans=",pow(base,power))
PROGRAM 15: SWAP TWO NUMBERS PROGRAM 16: SWAP TWO
a=5 NUMBERS
b=10 a=5, b=10
c=a a=a+b
a=b b=a-b
b=c a=a-b
print("After Swapping a=",a,"and b=",b) print("After Swapping a=",a,"and
b=",b)
PROGRAM 1: HELLO WORLD PROGRAM 2: STATIC
print("Hello World") VARIABLES
print(“Welcome to python”) a=10
print(a)
PROGRAM 3: DYNAMIC VARIABLE PROGRAM 4: TYPE OF
a=input("enter value of a") VARIABLE
print(a) a=input("enter value of a")
print(type(a))
PROGRAM 5: SUM OF TWO STATIC PROGRAM 6: SUM OF TWO
NUMBERS DYNAMIC NUMBERS
a=10 a=int(input("enter value of a"))
b=20 b=int(input("enter value of b"))
c = a+b c=a+b
print("sum= ", c) print("sum=", c)
PROGRAM 7: PRINT CHARACTER PROGRAM 8: PRINT STRING
c=’J’ c=”JACK"
print(c) print(c, ”Computer”)
PROGRAM 9: SUM OF THREE PROGRAM 10: SUM OF THREE
NUMBERS NUMBERS
a,b,c=map(int, input("enter three nos:").split()) a,b,c=map(int, input("enter three no
print("sum=",a+b+c) ").split(“,”))
print("sum=",a+b+c)
PROGRAM 11: CONVERT PRICE INTO PROGRAM 12: AREA AND
RUPEES AND PAISA CIRCUMFERENCE
price=float(input("enter a price")) PI=3.14
rs=int(price) R=float(input("enter the radius"))
ps=int((price-rs)*100) A=PI*R*R
print("Rupees=",rs) print("Area=",A)
print("Paisa=",ps) print("Circumference=",2*PI*R)
PROGRAM 13: MONTH AND DAYS PROGRAM 14: POWER
total=int(input("Enter Total Days")) FUNCTION
print("Month=",int(total/30),"Days=",total%30) base=int(input("enter base"))
power=int(input("enter power"))
print("Ans=",pow(base,power))
PROGRAM 15: SWAP TWO NUMBERS PROGRAM 16: SWAP TWO
a=5 NUMBERS
b=10 a=5, b=10
c=a a=a+b
a=b b=a-b
b=c a=a-b
print("After Swapping a=",a,"and b=",b) print("After Swapping a=",a,"and
b=",b)