0% found this document useful (0 votes)
6 views6 pages

Python Basics: 16 Practical Exercises

Uploaded by

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

Python Basics: 16 Practical Exercises

Uploaded by

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

PYTHON

Practical 1: Print “Hello World”

Program:

print("Hello World")

Output:
Hello World

Practical 2: Display Name, Class and Section

Program:

print("Name: Aman Kumar")


print("Class: 9")
print("Section: A")

Output:
Name: Aman Kumar
Class: 9
Section: A

Practical 3: Add Two Numbers

Program:

a = int(input("Enter first number: "))


b = int(input("Enter second number: "))
print("Sum =", a + b)

Output (Example):
Enter first number: 5
Enter second number: 7
Sum = 12
Practical 4: Find Simple Interest

Program:

p = float(input("Enter principal: "))


r = float(input("Enter rate: "))
t = float(input("Enter time: "))

si = (p * r * t) / 100
print("Simple Interest =", si)

Output (Example):
Simple Interest = 500

Practical 5: Find Area of a Circle

Program:

r = float(input("Enter radius: "))


area = 3.14 * r * r
print("Area of Circle =", area)

Output (Example):
Area of Circle = 78.5

Practical 6: Check Even or Odd Number

Program:

num = int(input("Enter a number: "))

if num % 2 == 0:
print("Even Number")
else:
print("Odd Number")

Output (Example):
Even Number
Practical 7: Find Greatest of Two Numbers

Program:

a = int(input("Enter first number: "))


b = int(input("Enter second number: "))

if a > b:
print("Greatest number is", a)
else:
print("Greatest number is", b)

Output (Example):
Greatest number is 20

Practical 8: Check Positive, Negative or Zero

Program:

num = int(input("Enter a number: "))

if num > 0:
print("Positive Number")
elif num < 0:
print("Negative Number")
else:
print("Zero")

Output (Example):
Positive Number

Practical 9: Print Numbers from 1 to 10

Program:

for i in range(1, 11):


print(i)
Output:
1 2 3 4 5 6 7 8 9 10

Practical 10: Sum of First 10 Natural Numbers

Program:

total = 0
for i in range(1, 11):
total = total + i

print("Sum =", total)

Output:
Sum = 55

Practical 11: Multiplication Table

Program:

num = int(input("Enter a number: "))

for i in range(1, 11):


print(num, "x", i, "=", num * i)

Output (Example):
2x1=2
2x2=4

2 x 10 = 20

Practical 12: Factorial of a Number

Program:

num = int(input("Enter a number: "))


fact = 1
for i in range(1, num + 1):
fact = fact * i

print("Factorial =", fact)

Output (Example):
Factorial = 120

Practical 13: Check Palindrome Number

Program:

num = input("Enter a number: ")

if num == num[::-1]:
print("Palindrome")
else:
print("Not Palindrome")

Output :
Palindrome

Practical 14: Print Star Pattern

Program:

for i in range(1, 6):


print("*" * i)

Output:

*
**
***
****
*****
Practical 15: Use of List

Program:

marks = [60, 70, 80, 90]


print("Marks:", marks)
print("Total =", sum(marks))

Output:
Marks: [60, 70, 80, 90]
Total = 300

Practical 16: Take a number from the user and print its square

num = int(input("Enter a number: "))


square = num * num
print("Square of the number =", square)

Output:
Enter a number : 5
Square of the number = 25

You might also like