0% found this document useful (0 votes)
43 views3 pages

Python Programs For Practical File

The document provides a series of Python programming exercises covering fundamental concepts such as calculating area, swapping numbers, performing arithmetic operations, and handling data. It includes tasks for generating random numbers, calculating statistical measures, checking leap years, and implementing control flow structures. Additionally, it features exercises for series calculations, grade determination based on marks, and pattern printing.

Uploaded by

amritdharapvt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views3 pages

Python Programs For Practical File

The document provides a series of Python programming exercises covering fundamental concepts such as calculating area, swapping numbers, performing arithmetic operations, and handling data. It includes tasks for generating random numbers, calculating statistical measures, checking leap years, and implementing control flow structures. Additionally, it features exercises for series calculations, grade determination based on marks, and pattern printing.

Uploaded by

amritdharapvt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Python Fundamentals

1) Wap to obtain length and bredth of a rectangle and calculate its area.
2) Wap to input two numbers and swap them.
3) Wap to input three numbers and swap them as this: 1st number becomes the 2nd number, 2nd number becomes
the 3rd number and 3rd number becomes the first number.
4) Wap to enter two integers and perform all arithmetic operations on them.

Data Handling

5) Wap to generate two random integers between 450 and 950. Print these numbers along with their average.
import random
num1 = [Link](450, 950)-450
num2 = [Link](450, 950)-450
average = (num1 + num2) / 2

print("First number:", num1)


print("Second number:", num2)
print("Average:", average)

6) Wap to given a list containing these values [22,13,28,13,22,25,7,13,25]. Write code to calculate mean, median
and mode of this list.
7) Wap to obtain x,y,z from user and calculate expression: 4x4 + 3y3 +9z +6π .

ANSWER  import math


x = int(input("Enter x: "))
y = int(input("Enter y: "))
z = int(input("Enter z: "))
res = 4 * x ** 4 + 3 * y ** 3 + 9 * z + 6 * [Link]
print("Result =", res)
Output
Enter x: 2
Enter y: 3
Enter z: 5
Result = 208.84955592153875
8) Wap to take year as input and check if it is leap year or not.

y = int(input("Enter year to check: "))

print(y % 4 and "Not a Leap Year" or "Leap Year")

Flow of Control

9) Wap to take three integers and print the largest of the three Make use of only if
statement.
10) Wap to print whether a given character is an uppercase or a lowercase character or a digit
or any other character.
11) Wap to print table of a number, say 5.
12) Wap to calculate the factorial of a number.

13) Wap to illustrate the difference between break and continue statements.
14) Write a program to find the sum of the series : s=1+x+x ²+x ³+x ⁴…+x ⁿ .
15) Wap to input the value of x and n and print the sum of the series : 1 - x + x2 - x3 + x4 - …. xn .
16) Wap to check if a given number is a palindrome number or not.
17) Wap to print Fibonacci series.
18) Wap to input the value of x and n and print the sum of the following series: x + x2/2 + x3/3 + x4/4 + -------- + xn/n.

19) Write a program in python that accepts marks(out of 100) in five subjects, calculate and display percentage
marks, Grade and Remarks (using table given below).
Percentage Range Grade Remarks
90% - 100% A Excellent
75% - 89% B Very Good
60% - 74% C Good
45% - 59% D Average
Below 45% E Need Improvement

sub1 = int(input("Enter marks of the first subject: "))


sub2 = int(input("Enter marks of the second subject: "))
sub3 = int(input("Enter marks of the third subject: "))
sub4 = int(input("Enter marks of the fourth subject: "))
sub5 = int(input("Enter marks of the fifth subject: "))

avg = (sub1 + sub2 + sub3 + sub4 + sub5) / 5

if avg >= 90:


print("Grade: A ")
print("Remarks : Excellent ")
elif avg >= 80 and avg < 90:
print("Grade: B")
print("Remarks : Very Good ")

elif avg >= 70 and avg < 80:


print("Grade: C")
print("Remarks : Good ")

elif avg >= 60 and avg < 70:


print("Grade: D")
print("Remarks : Average ")

else:
print("Grade: F")
print("Remarks : Need Improvement ")
output
Case 1:
Enter marks of the first subject: 85
Enter marks of the second subject: 95
Enter marks of the third subject: 99
Enter marks of the fourth subject: 93
Enter marks of the fifth subject: 100
Grade: A

Case 2:
Enter marks of the first subject: 81
Enter marks of the second subject: 72
Enter marks of the third subject: 94
Enter marks of the fourth subject: 85
Enter marks of the fifth subject: 80
Grade: B

20) Wap to print the following using a single loop(no nested loops):
1
11
111
1111
11111
21) Wap to print a pattern like: 4321
432
43
4

You might also like