STD 9 Practical File 22-23
STD 9 Practical File 22-23
1. Write a program that asks for your name and age, and then displays this on the screen.
Source code:
name = input("What is your name?:")
age=input("How old are you?:")
print("Your name is: "+name)
print("You are "+age+" years old")
Output:
---------------------------------------------------------------------------------------------------------------------------------------
2. Create a list with the following numbers. Delete the third number using the pop()
method.
10, 11, 12, 13, 14, 15, 16, 17
Source Code:
a=[1, 2, 3, 4, 5]
print(list)
a.pop(2)
print(list)
Output:
---------------------------------------------------------------------------------------------------------------------------------------
Source code:
friends=[ ]
for i in range(5):
n=input("Enter friend Name:")
friends.append(n)
print(friends)
Output:
---------------------------------------------------------------------------------------------------------------------------------------
4. Write a program to accept three numbers from the user and add them.
Source Code:
number3=int(input("Enter number 1:"))
number2=int(input("Enter number 2:"))
number1=int(input("Enter number 3:"))
Sum=number1+number2+number3
print("The addition of three numbers are:",Sum)
Output:
---------------------------------------------------------------------------------------------------------------------------------------
Output:
---------------------------------------------------------------------------------------------------------------------------------------
6. A program to check if the number is positive print an appropriate
message.
Source code:
num = float(input("Enter a number: "))
if num > 0:
print("Positive number")
elif num == 0:
print("Zero")
else:
print("Negative number")
Output:
---------------------------------------------------------------------------------------------------------------------------------------
Source code:
age = int(input("enter age:"))
if age >=18:
print("Eligible for voting!")
else:
print("not eligible for voting!")
Output:
---------------------------------------------------------------------------------------------------------------------------------------
Source code:
P = 3.14
R= 5
C= P*R*R
print("Area of a Circle is :", C)
Output:
---------------------------------------------------------------------------------------------------------------------------------------
9. A program to calculate average marks of 3 subjects.
Source code:
d = int(input("Enter the marks of first subject: "))
e = int(input("Enter the marks of second subject: "))
f = int(input("Enter the marks of third subject: "))
total = d+e+f
avg = total/3
print("Total marks: ",total)
print("Average marks: ",avg)
Output:
---------------------------------------------------------------------------------------------------------------------------------------
10. Create a list with the three items :
Cpu, Keyboard, Monitor-> Print the list->Add item mouse at the end of the list->print
the list
---------------------------------------------------------------------------------------------------------------------------------------
Source code:
sports=["cricket","Football","Volleyball", "Kabbadi"]
print("list",sports)
sports.sort()
print("list in ascending order",sports)
sports.reverse()
print("list after reversal",sports)
sports.sort(reverse=False)
print("list after descending order",sports)
Output:
---------------------------------------------------------------------------------------------------------------------------------------
12. Write a program to find the area of a rectangle.
Source code:
L=float(input("Length:"))
B=float(input("Breadth:"))
Area=L * B
print("Area is", Area)
Output:
13. Create a list with [5,9,11,13,17 ] & print and check weather [10]
is an element in the list.
Source code:
a = [5,9,11,13,17]
if (9 in a):
print("Element exists")
else:
print("Element doesn't exists")
Output:
________________________________________________________________________
Source code:
b=input("Name: ")
print("Hello")
print(b)
Output:
________________________________________________________________________
15. Write a program to add two numbers.
Source code: