CSE – Problem Solving
Assignment 2
Om Singh (20BCE10990)
Python Code Exercise
Table of Contents
PROBLEM 1 ........................................................................................................3
PROBLEM 2 ........................................................................................................4
PROBLEM 3 ........................................................................................................5
PROBLEM 4 ........................................................................................................6
PROBLEM 5 ........................................................................................................8
PROBLEM 6 ........................................................................................................9
PROBLEM 7 ..................................................................................................... 10
PROBLEM 8 ..................................................................................................... 11
PROBLEM 9 ..................................................................................................... 12
PROBLEM 10 ................................................................................................... 13
PROBLEM 11 ................................................................................................... 14
PROBLEM 12 ................................................................................................... 15
PROBLEM 13 ................................................................................................... 16
PROBLEM 14 ................................................................................................... 17
PROBLEM 15 ................................................................................................... 18
PROBLEM 16 ................................................................................................... 19
PROBLEM 17 ................................................................................................... 20
PROBLEM 18 ................................................................................................... 21
Problem 1 :-
Write a python program to print Hello World! :
Problem 2 :-
Write a python program to add two numbers :
Problem 3 :-
Write a python program to find the square root :
Problem 4 :-
Write a python program to calculate the area of a triangle :
Problem 5 :-
Write a python program to convert kilometres to miles:
Problem 6 :-
Write a python program to convert Celsius to Fahrenheit:
Problem 7 :-
Write a python program to check if a number is positive,
negative or 0 :
Problem 8 :-
Write a python program to check if a number is odd or even :
Problem 9 :-
Write a python program to find the largest among three
numbers :
Problem 10 :-
Write a python program to check a prime number:
Problem 11 :-
Write a python program to display the multiplication table :
Problem 12 :-
Write a python program to get a number from user and print
‘n’ numbers odd or even :
Problem 13 :-
Write a python program to count odd and even numbers:
Problem 14 :-
Write a python program to compute the sum of n natural
numbers:
Problem 15 :-
Write a program to print ‘Hello’ 5 times:
Problem 16 :-
Write a python program to find the area of a circle:
Problem 17 :-
Write a python program to find the age validity (valid voter
or not):
Problem 18 :-
Write a python program to find the sum of first 100 natural
numbers: