1. Write a python program to print Hello, world!
print (‘Hello, world!’)
OR
x= “Hello, World!”
print(x)
Output:
Hello, world!
2. Write a python program to print your name and address.
print (“My Address”)
print (“————–“)
print (“Eliza Begum”)
print (“Parbatia, New Colony”)
print (“Gariasi Path”)
print (“Dist: Tinsukia”)
print (“P.O. Tinsukia”)
print (“Pin: 786125”)
print(“Assam”)
Output:

3. Write a program in python to print the following string in the specific format.

print(“Welcome”)
print (“\tto Python”)
print(“\t\tProgramming”)
print (“invented by “)
print (“\tGuido van Rossum”)
print (“in Netherlands”)
OR
print(“Welcome \n\t to Python \n\t\t Programming \n invented by \n\t Guido van Rossum \n in Netherlands”)
4. Write a program in python to add two numbers.
num1 = 10
num2 = 15
result = num1 + num2
print(“Sum:”, result)
#print(“Sum of”, num1, “and”, num2, “is:”, result)
#print(f”Sum of {num1} and {num2} is: {result}”)
OR
num1, num2 = 10, 15
print(“Sum: “, num1+num2)
#print (“Sum of”, num1, “and”, num2, “is: “, num1+num2)
#print (f”Sum of {num1} and {num2} is: {num1+num2}”)
Output:
Sum: 25
5. Write a program to store two integer values in two variables and using them calculate addition, subtraction, multiplication division.
n1, n2=20,15
print (“Addition: “, n1+n2)
print (“Subtraction: “, n1-n2)
print (“Multiplication: “, n1*n2)
print (“Division: “, n1/n2)
Output:
Addition: 35
Subtraction: 5
Multiplication: 300
Division: 1.3333333333333333
6. Write a python program to print your name, city and state taking input from user.
name=input(“Enter name: “)
city=input(“Enter city: “)
state=input(“Enter state: “)
print(“——————-“)
print(“Name: “,name)
print(“City: “,city)
print(“state: “,state)
Output:
Enter name: Eliza Begum
Enter city: Tinsukia
Enter state: Assam
——————-
Name: Eliza Begum
City: Tinsukia
state: Assam
7. Write a python program to add two numbers with user input.
num1 = input (‘Enter 1st number: ‘)
num2 = input (‘Enter 2nd number: ‘)
sum=int(num1) +int(num2)
print (f”Sum of {num1} and {num2} is {sum}”)
OR
num1=int(input(‘Enter 1st number: ‘))
num2=int(input (‘Enter 2nd number: ‘))
sum=num1+num2
print(‘Sum of’, num1, ‘and’, num2, ‘is: ‘, sum)
Output:
Enter 1st number: 4
Enter 2nd number: 6
Sum of 4 and 6 is: 10
8. Write a program in python to add two floating point numbers taking user input.
num1=float(input(‘Enter 1st number:’))
num2=float(input(‘Enter 2nd number:’))
sum=num1+num2
print(‘Sum of’, num1, ‘and’, num2, ‘is:’ ,sum)
Output:
Enter 1st number: 12.5
Enter 2nd number: 45.3
Sum of 12.5 and 45.3 is: 57.8
9. Write a program in python to perform addition, subtraction, multiplication and division on two input numbers taking from user.
num1=int(input(“Enter 1st number:”))
num2=int(input(“Enter 2nd number:”))
print (“Addition: “, num1+num2)
print (“Subtraction: “, num1-num2)
print (“Multiplication: “, num1*num2)
print (“Division: “, num1/num2)
Output:
Enter 1st Number: 56
Enter 2nd Number: 8
Addition: 64
Subtraction: 48
Multiplication: 448
Division: 7.0
10. Write a program in python to add two numbers taking input from user at a time.
num1,num2=map(int,input(“Enter 2 numbers :”).split())
sum=num1+num2
print(“Sum: “,sum)
Output:
Enter 2 numbers: 6 4
Sum: 10
11. Write a python program to add two floating point numbers taking input from user at a time.
num1,num2=map(float, input(“Enter 2 numbers: “).split ())
result=num1+num2
print (“Sum: “, result)
Output:
Enter 2 numbers: 12.3 34.2
Sum: 46.5
12. Write a python program to print your name and city taking input from user at a time.
name,city=map(str,input(“Enter name and city: “).split())
print (“Name: “,name)
print(“City:”,city)
Output:
Enter name and city: Eliza Tinsukia
Name: Eliza
City: Tinsukia
13. Write a python program to add two positive integers without using the ‘+’ operator.
print (“Sum of two numbers: “);
result=sum([5,5])
print(result)
Output:
Sum of two numbers:
10
OR
num1=int(input(“Enter 1st number:”))
num2=int(input(“Enter 2nd number:”))
result=sum ([num1, num2])
print (“Sum: “, result)
Output:
Enter 1st number: 20
Enter 1st number: 30
Sum: 50
14. Write a python program to calculate the Square of a number.
n=int (input (“Enter a number:”))
sqr=n**2
print (f”Square of {n} is {sqr}”)
Output:
Enter a number:4
Square of 4 is 16
15. Write a python program to calculate the Power of a number.
base=int (input (“Enter base: “))
exp=int (input (“Enter exponential value:”))
result=base**exp
print (f”{base} raised to the power of {exp} is {result}”)
Output:
Enter base: 5
Enter exponential value:3
5 raised to the power of 3 is 125
16. Write a python program to calculate the Square Root of a number.
num = float(input(‘Enter a number: ‘))
sqrt = num ** 0.5
print (‘Square root of’, num, ‘is: ‘, sqrt)
Output:
Enter a number: 16
Square root of 16.0 is: 4.0
Note: double-star operator, ** is used for exponentiation, where one number is raised to the power of another. Ex. 2**3 is 8
17. Write a program to calculate the area of a triangle. (Formula: Area = 1/2*Base * Height)
base=int(input(“Enter the value of base: ”))
height= int(input(“Enter the value of height: “))
area=1/2*base*height
print(‘Area of the triangle is: ‘, area)
Output:
Enter the value of base: 8
Enter the value of height: 6
Area of the triangle is: 24.0
18. Write a program to find the area of a circle. ( Formula: Area of circle= πr2, π=22/7)
r=float (input (“Enter the radius of a circle:”))
area=22/7*r*r
print (“Area of the circle:”, area)
print (“Area of circle: %.2f” %area)
Output:
Enter the radius of a circle:3
Area of the circle: 28.285714285714285
Area of circle: 28.29
Note: %.2f specifies 2 numbers after the decimal.
19. Write a program in python to find the volume of a sphere. (Formula: Volume of sphere =4/3 πr3 , π=22/7)
r=float(input(“Enter the radius of the sphere: “))
V = 4/3* 22/7* r**3
print(‘The volume of the sphere is: ‘, V)
Output:
Enter the radius of the sphere: 6
The volume of the sphere is: 905.1428571428572
20. Write a python program to convert Celsius to Fahrenheit.
C = float (input (“Enter Temperature in Celsius: “))
F = (9/5* C) + 32
print (“Temperature in Fahrenheit : “, F)
Output:
Enter Temperature in Celsius : 32
Temperature in Fahrenheit : 89.6
21. Write a program in python to convert Fahrenheit to Celsius.
F = float(input(“Enter the Temperature in Fahrenheit : “))
C= (F-32) * 5/9
print(“Temperature in Celsius:”, C)
Output:
Enter the Temperature in Fahrenheit : 208.4
Temperature in Celsius : 98.0
22. Write a program to find the Sum of First n Natural Numbers.
n=int (input (“Enter a number: “))
sum=n*(n+1)/2
print (“Sum of first “, n, “natural numbers: “, sum)
Output:
Enter a number: 5
Sum of first 5 natural numbers: 15
23. Write a program to print pay-slip using the following data.
Employee number is 100
Basic salary is 5000
DA must be calculated as 10% of basic
HRA must be calculated as 20% of basic
Total salary must be calculated as Basic+DA+HRA
ENo=100
BS=5000
DA=BS*10/100
HRA=BS*20/100
Total=BS+DA+HRA
print(“Pay Slip”)
print(“********************”)
print(“Employee Number:”,ENo)
print(“Basic salary:”,BS)
print(“DA:”,DA)
print(“HRA:”,HRA)
print(“Total Salary:”,BS+DA+HRA)
Output:
Pay Slip
********************
Employee Number: 100
Basic salary: 5000
DA: 500.0
HRA: 1000.0
Total Salary: 6500.0
24. Write a program to swap two variables in python.
x = int(input(‘Enter value of x: ‘))
y = int(input(‘Enter value of y: ‘))
# create a temporary variable and swap the values
temp = x
x = y
y = temp
print(‘The value of x after swapping: ‘,x)
print(‘The value of y after swapping: ‘,y)
Output:
Enter value of x: 5
Enter value of y: 10
The value of x after swapping: 10
The value of y after swapping: 5
25. Write a python program to swap two variables without using third variable.
x = int (input (‘Enter value of x: ‘))
y = int (input (‘Enter value of y: ‘))
x,y=y,x
print (‘The value of x after swapping: ‘, x)
print (‘The value of y after swapping: ‘, y)
Output:
Enter value of x: 10
Enter value of y: 20
The value of x after swapping: 20
The value of y after swapping: 10
26. Write a program in python to calculate Simple Interest.
P = int(input(“Enter the principal amount :”))
T = int(input(“Enter the time period :”))
R = int(input(“Enter the rate of interest :”))
si = (P * T * R) / 100
print(‘The Simple Interest is’, si)
Output:
Enter the principal amount :4000
Enter the time period :2
Enter the rate of interest :4
The Simple Interest is 320.0
27. Write a program to check two numbers are equal or not.
a=int(input(“Enter 1st number: “))
b=int(input(“Enter 2nd number: “))
if(a==b):
print(“Numbers are equal”)
else:
print(“numbers are not equal”)
Output:
Enter 1st number: 7
Enter 2nd number: 9
numbers are not equal
28. Write a program to find the larger number among two numbers.
a=int(input(“Enter 1st number: “))
b=int(input(“Enter 2nd number: “))
if(a>b):
print(“Larger number is: “, a)
else:
print(“Larger number is: “, b)
Output:
Enter 1st number: 4
Enter 2nd number: 7
Larger number is: 7
29. Write a python program to check a number is even or odd.
num = int(input(“Enter a number: “))
if(num % 2 == 0):
print(num, “is even number”)
else:
print(num, “is odd number”)
Output-1
Enter a number: 8
8 is even number
Output-2
Enter a number: 5
5 is odd number
30. Write a program to check a year is leap year or not.
year = int(input(“Enter a year: “))
if (year % 4 ==0):
print(year, “is leap year”)
else:
print(year, “is not a leap year”)
Output:
Enter a year: 2020
2020 is leap year
31. Write a program in python to find the largest number among three numbers.
num1=int(input(“Enter 1st number:”))
num2=int(input(“Enter 2nd number:”))
num3=int(input(“Enter 3rd number: “))
if(num1>num2 and num1>num3):
print(“Largest number is: “,num1)
elif(num2>num1 and num2>num3):
print(“Largest number is: “,num2)
else:
print(“Largest number is”, num3)
Output:
Enter 1st number: 6
Enter 2nd number: 7
Enter 3rd number: 9
The largest number is 9
32. Write a python program to check an alphabet is vowel or not.
x = input(“Enter an alphabet: “)
if(x==’a’ or x==’A’):
print(x,” is vowel”)
elif(x==’e’ or x==’E’):
print(x,” is vowel”)
elif(x==’i’ or x==’I’):
print(x,” is vowel”)
elif(x==’o’ or x==’O’):
print(x,” is vowel”)
elif(x==’u’ or x==’U’):
print(x,” is vowel”)
else:
print(x, ” is not vowel”)
OR
x = input(“Enter an alphabet: “)
if(x==’A’ or x==’a’ or x==’E’ or x==’e’ or x==’I’ or x==’i’ or x==’O’ or x==’o’ or x==’U’ or x==’u’):
print(x, ” is a vowel”)
else:
print(x, ” is not a vowel”)
Output-1:
Enter the alphabet: U
U is a vowel
Output-2
Enter the alphabet: r
r is a consonant
33. Write a program to calculate total marks and percentage of a student of 5 subjects and based on the percentage display the grade according to the following criteria.
Below 30% D
30-45 C
45-55 B
55-65 B+
65-85 A
Above 85% A+
print(“Enter the marks :-“)
eng=int(input(“English: “))
math=int(input(“Mathematics: “))
hindi=int(input(“Hindi: “))
sc=int(input(“Science: “))
geo=int(input(“Geography: “))
total=eng+math+hindi+sc+geo
per = (total/500*100)
print(f”Total marks: {total}”)
print(f”Percentage: {per}”)
if(per<30):
print(“Grade: D”)
elif (per>=30 and per<45):
print(“Grade: C”)
elif(per>=45 and per<55):
print(“Grade: B”)
elif(per>=55 and per<65):
print(“Grade: B+”)
elif(per>=65 and per<=85):
print(“Grade: A”)
else:
print(“Grade: A+”)
Output:
Enter the marks:-
English: 78
Mathematics: 89
Hindi: 67
Science: 90
Geography: 85
Total marks: 409
Percentage: 81.8
Grade: A
OR
s1, s2, s3,s4,s5=map(int,input(“Enter marks of 5 subjects: “).split())
total = s1+s2+s3+s4+s5
per = (total/500*100)
print(f”Total marks: {total}”)
print(f”Percentage: {per}”)
if(per<30):
print(“Grade: D”)
elif (per>=30 and per<45):
print(“Grade: C”)
elif(per>=45 and per<55):
print(“Grade: B”)
elif(per>=55 and per<65):
print(“Grade: B+”)
elif(per>=65 and per<=85):
print(“Grade: A”)
else:
print(“Grade: A+”)
Output:
Enter marks of 5 subjects of a student: 78 75 87 98 95
Total marks: 433
Percentage: 86.6
Grade: A+
34. Write a python program to make a Simple Calculator.
num1=int(input(“Enter 1st number:”))
num2=int(input(“Enter 2nd number:”))
op=input(“Enter any of these operator (+,-,*,/):”)
if op== ‘+’:
result = num1 + num2
elif op== ‘-‘:
result = num1 – num2
elif op== ‘*’:
result = num1 * num2
elif op== ‘/’:
result = num1 / num2
else:
print(“Input character is not recognized!”)
print(num1, op , num2, “:”, result)
Output:
Enter First Number: 45
Enter Second Number: 5
Enter any of these operator (+, -, *, /): /
45 / 5: 9.0
35. Write a python program to print characters of a string.
s=’Hello’
for i in s:
print(i)
Output:
H
e
l
l
o
OR, We can do the above program by taking input from user :
s=input(“Enter a string: “)
for i in s:
print (i, end=’ ‘)
Output:
Enter a string: India
I n d i a
36. Write a program in python to print characters of “python”.
for letter in ‘python’:
print(letter)
Output:
p
y
t
h
OR
for letter in ‘python’:
print(letter, end=’ ‘)
Output:
p y t h o n
37. Write a python program to print elements in a list.
fruits=[‘banana’, ‘apple’, ‘mango’, ‘orange’]
for i in fruits:
print(i)
Output:
banana
apple
mango
orange
OR
fruits=[‘banana’, ‘apple’, ‘mango’, ‘orange’]
for i in fruits:
print(i, end= ‘ ‘)
Output:
banana apple mango orange
38. Write a program to print first 10 natural numbers.
print (“First 10 natural numbers: “)
for i in range (1,11):
print (i, end=’ ‘)
Output:
First 10 natural numbers:
1 2 3 4 5 6 7 8 9 10
39. Write a program to print numbers from series of numbers from 20 to 60.
print(“Numbers from 20 to 60: “)
for i in range(20,61):
print(i,end=’ ‘)
Output:
Numbers from 20 to 60:
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
40. Write a program to print series of number from 100 to 50 in reversing order.
for i in range(100,49,-1):
print(i,end=’ ‘)
Output:
100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50
41. Write a program in python to print multiplication table for any number.
num=int(input (“Enter a number: “))
print (“Multiplication table of”, num)
for i in range (1, 11):
print (num, ‘x’, i, ‘=’, num*i)
Output:
Enter the number: 5
Multiplication Table of 5
5 x 1 = 5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
5 x 6 = 30
5 x 7 = 35
5 x 8 = 40
5 x 9 = 45
5 x 10 = 50
42. Write a python program to print multiplication table upto 5.
print(“Multiplication table up to 5”)
for i in range(1, 6):
for j in range(1,11):
print (i, ‘x’, j, ‘=’, i*j)
print()
Output:
1 x 1 = 1
1 x 2 = 2
1 x 3 = 3
1 x 4 = 4
1 x 5 = 5
1 x 6 = 6
1 x 7 = 7
1 x 8 = 8
1 x 9 = 9
1 x 10 = 10
2 x 1 = 2
2 x 2 = 4
2 x 3 = 6
2 x 4 = 8
2 x 5 = 10
2 x 6 = 12
2 x 7 = 14
2 x 8 = 16
2 x 9 = 18
2 x 10 = 20
…………….
……………..
43. Write a python program to print the following pattern.

n=int(input(“Enter number of rows: “))
for i in range(n):
print(“* ” * (i+1))
Output:
Enter number of rows: 5

44. Write a program in python to print the following pattern.

n=int(input(“Enter number of rows: “))
for i in range(n):
print(“* ” * (n-i))
Output:
Enter number of rows: 5

45. Write a program in python to print first 10 natural numbers using while loop.
i=1
while(i<=10):
print(i, end=’ ‘)
i=i+1
Output:
1 2 3 4 5 6 7 8 9 10
46. Write a program in python to print first 10 even numbers using while loop.
x=int(input(“Enter a number: “))
i=1
while(i<=x):
if(i%2==0):
print(i,end=” “)
i=i+1
Output:
Enter a number: 20
2 4 6 8 10 12 14 16 18 20
47. Write a python program to create an array contains six integers. Also print all the members of the array.
import array
a=array. array (‘i’, [10,20,30,40,50,60])
print (“Elements of the given array: “);
for i in a:
print (i, end=’ ‘)
OR
import array as x
a=x. array (‘i’, [10,20,30,40,50])
print (“Elements of the given array: “);
for i in a:
print (i, end=’ ‘)
OR
from array import *
a=array (‘i’, [10,20,30,40,50,60])
print (“Elements of the given array: “);
for i in a:
print (i, end=’ ‘)
Output:
Elements of given array:
10 20 30 40 50 60
48. Write a python program to print your address details using function.
def address ():
name = “Priya Sharma”
city = “Tinsukia”
dist = “Tinsukia”
state = “Assam”
pin = 786125
print(f”Name: {name}”)
print(f”City: {city}”)
print(f”Dist: {dist}”)
print(f”State: {state}”)
print(f”Pin: {pin}”)
print(“My Address”)
print(“—————–“)
address()
Output:
My Address
—————–
Name: Priya Sharma
City: Tinsukia
Dist: Tinsukia
State: Assam
Pin: 786125
49. Write a program to add two numbers in python using function.
def sum():
n1,n2=5,10
result=n1+n2
print(“Sum: “,result)
sum()
OR
def add (a, b):
return a + b
sum= add (5,10)
print (“Sum: “, sum)
Output:
Sum: 15
50. Write a program to find maximum of two numbers using function.
def maximum(a, b):
if a >= b:
return a
else:
return b
print(“Maximum Number: “,maximum(2, 7))
Output:
Maximum Number: 7
Method 2: Using inbuilt max() Function
a=int(input(“Enter 1st number: “))
b=int(input(“Enter 2nd number: “))
print(“Maximum number is”, max(a,b))
Output:
Enter 1st number: 4
Enter 2nd number: 3
I truly admired the work you’ve put in here. The design is refined, your authored material stylish, however, you seem to have acquired some trepidation about what you intend to present next. Undoubtedly, I’ll revisit more regularly, similar to I have nearly all the time, in the event you sustain this rise.
Thanks a lot for your comment.
This website has quickly become my go-to source for [topic]. The content is consistently top-notch, covering diverse angles with clarity and expertise. I’m constantly recommending it to colleagues and friends. Keep inspiring us!
Thank you for your kind words. Thanks a lot for recommending my site…
What a fantastic resource! The articles are meticulously crafted, offering a perfect balance of depth and accessibility. I always walk away having gained new understanding. My sincere appreciation to the team behind this outstanding website.
Thank you!!!
Thank you for your response! I’m grateful for your willingness to engage in discussions. If there’s anything specific you’d like to explore or if you have any questions, please feel free to share them. Whether it’s about emerging trends in technology, recent breakthroughs in science, intriguing literary analyses, or any other topic, I’m here to assist you. Just let me know how I can be of help, and I’ll do my best to provide valuable insights and information!
Thank you so much…
Hiya, I’m really glad I’ve found this info. Nowadays bloggers publish just about gossips and internet and this is actually frustrating. A good site with exciting content, that is what I need. Thank you for keeping this web site, I will be visiting it. Do you do newsletters? Can not find it.