PYTHON
PROJECT
Disclaimer:
The results produced by this Python program may vary
depending on the input values selected. Different inputs
will lead to different outputs, highlighting the
program's flexibility and the importance of input
choice in determining the final results. Users are
encouraged to experiment with various values to
observe how the output changes accordingly.
Question 1
Code:
a=int(input('Enter the first integer:'))
b=int(input('Enter the second integer:'))
Sum=a+b
print('The two integers are:', a, b)
print('The sum of two integers are:', Sum)
Output:
Enter the first Integer : 5
Enter the second integer : 5
The two integers are: 5, 5
The sum of two integers are: 10
Question 2
Code:
r=int(input('Enter the radius of circle:'))
Area=3.14*r**2
print('The area of the circle is:', Area)
Output:
Enter the Radius of circle: 2
The area of the circle is: 12.566
Question 3
Code:
b=float(input('Enter the base of triangle:'))
h=float(input('Enter the height of triangle:'))
Area=(1/2)*b*h
print('The area of triangle is:', Area)
Output:
Enter the base of triangle: 30
Enter the height of triangle: 20
Area triangle is: 300
Question 4
Code:
num = 4
square = num ** 2
print(square)
Output:
16
Question 5
Code:
celsius = 25
fahrenheit = (celsius * 9/5) + 32
print(fahrenheit)
Output:
77.0
Question 6
Code:
a, b, c = 5, 10, 8
largest = max(a, b, c)
print(largest)
Output:
10
Question 7
Code:
print('Enter the marks of three subject out of 100')
a=float(input('Enter the marks of first subject:'))
b=float(input('Enter the marks of second subject:'))
c=float(input('Enter the marks of third subject:'))
P=(a+b+c)/3
print('The percentage marks are:', P,'%')
Output:
Enter the marks of three subjects 0ut of 100
Enter the marks of first subject: 60
Enter the marks of second Subject:80
Enter the marks of Third subject: 89
The percentage Marks are: 76.3333333333333%
Question 8
Code:
P=float(input('Enter the principal amount : '))
R=float(input('Enter the rate of interest: '))
T=float(input('Enter the time in years: '))
SI=(P*R*T)/100
print('The simple interest is : ', SI)
Output:
Enter The principal amount: 200000
Enter the rate of Interest: 2
Enter the time in years: 4
The simple interest is: 16000
Question 9
Code:
num = 5
factorial = 1
for i in range(1, num + 1):
factorial *= i
print(factorial)
Output:
120
Question 10
Code:
num = 7
is_prime = True
for i in range(2, num):
if num % i == 0:
is_prime = False
break
if is_prime:
print('Prime')
else:
print('Not Prime')
Output:
Prime
Question 11
Code:
a=int(input('Enter the first integer:'))
b=int(input('Enter the second integer:'))
c=int(input('Enter the third integer:'))
ifa<b and a<c:
print(a, 'is the smallest integer')
ifb<a and b<c:
print(b, 'is the smallest integer')
ifc<a and c<b:
print(c, 'is the smallest integer')
Output:
Enter the first integer: 1
Enter the second Integer: 2
Enter the third integer: 3
1 is the smallest integer
Question 12
Code:
a=float(input('Enter your height in centimeters:'))
Feet=a*0.032
Inch=a*0.393
print('Your height in feet is:', Feet)
print('Your height in inch is:', Inch)
Output:
Enter your height inCentimeter: 182
Your height in feet is: 5.97113
Your Height in inch is: 71.65356
Question 13
Code:
s = 'Python'
print(len(s))
Output:
Question 14
Code:
a=int(input('Enter your age:'))
if a>=18:
print('You are eligible to vote')
else:
print('You are not eligible to vote')
Output:
Enter your age: 15
You are not eligible to vote
Question 15
Code:
s = input(“Enter a word: ”)
vowels = 'aeiou'
count = 0
for char in s:
if char in vowels:
count += 1
print(“Vowels in the word”,S, “are”, count)
Output:
Enter a word: Education
Vowels in the word Education are 5
Question 16
Code:
a=float(input('Enter the percentage marks:'))
if a>=90:
print('The student has got an A grade')
elif a>=75 and a<90:
print('The student has got a B grade')
elif a>=60 and a<75:
print('The student has got a C grade')
else:
print('The student has got a D grade')
output:
Enter the Percentage marks: 90
The student has got an a grade
Question 17
Code:
ch=input('Enter a single character:')
if ch>='A'and ch<='Z':
print('You have entered an uppercase character.')
elif ch>='a'and ch<='z':
print('You have entered an lowercase character.')
elif ch>='0'and ch<='9':
print('You have entered a digit.')
else:
print('You have entered a special character.')
Output:
Enter a single character: @
You have entered a special character
Question 18
Code:
import math
gcd = math.gcd(12, 8)
print(gcd)
Output:
4
Question 19
Code:
totalTrans, totalsales = 0, 0
count = 1
while count<= 7:
Trans = int(input(“Transation made on day”
+str(count)+ “ : ”))
Items = int(input(“Items sold on day” +str(count)+ “ : ”))
Totaltrans += trans
Totalsales += items
Count += 1
Avgsales = totalsales/totaltrans
Print(“Total Sales made: ”, totalsales)
Print(“total transaction made: ”, Total trans)
Print(“Average sales per transation : ”, avgsales)
Output:
Transation made on day 1 : 70
Items sold on day 1 : 240
Transation made on day 2 : 110
Items sold on day 2 : 310
Transation made on day 3 : 77
Items sold on day 3 : 290
Total sales made: 840
Total transactions made: 257
Average sales per transaction : 3.268482902723735
Question 20
Code:
year = 2020
if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
print('Leap Year')
else:
print('Not a Leap Year')
Output:
Leap Year
Question 21
Code:
L= [2, 7,12, 5,10,15,23]
for i in L:
if i%2!=0:
L.remove (i)
print (L)
Output:
2, 12 ,10
Question 22
Code:
a, b = 5, 10
a, b = b, a
print(a, b)
Output:
10, 5
Question 23
Code:
import math
radius = 7
area = math.pi * radius ** 2
print(area)
Output:
153.93804002589985
Question 24
Code:
numbers = [1, 2, 3, 4, 5]
print(sum(numbers))
Output:
15
Question 25
Code:
numbers = [1, 2, 3, 4, 5]
average = sum(numbers) / len(numbers)
print(average)
Output:
3.0
Question 26
Code:
numbers = [1, 2, 3, 4, 5]
print(max(numbers))
Output:
5
Question 27
Code:
numbers = [1, 2, 3, 4, 5]
print(min(numbers))
Output:
Question 28
Code:
numbers = [1, 2, 3, 4, 5, 3, 3]
print(numbers.count(3))
Output:
Question 29
Code:
numbers = [1, 2, 3, 4, 5, 3, 3]
unique_numbers = list(set(numbers))
print(unique_numbers)
Output:
[1, 2, 3, 4, 5]
Question 30
Code:
numbers = [5, 2, 9, 1, 5, 6]
numbers.sort()
print(numbers)
Output:
[1, 2, 5, 5, 6, 9]
Thanks for reading this project on Python. I hope it has
further enriched the understanding of what's possible
through language. Whether new to Python or familiar
with its great features, I hope it has in any event made
aware of the very role Python fills within the world of
modern programming. Your interest and attention are
greatly appreciated; look forward to delving into related
subjects in depth in the future