file class ix
file class ix
Ans
Output:
enter the distance in km10
Distance in meter is 10000
Output
Enter the principal amount2000
Enter the time2
Enter the rate4
Simple interest is 160.0
Pr 3
Write a python code to swap two numbers
Output
Enter the first number 20
Enter the second number65
After swap a= 65 b= 20
Pr 4
Wirte a python code to print m raised to power n by user
import math
m=int(input("Enter the first number"))
n=int(input("Enter the second number"))
k=math.pow(m,n)
print("Answer is",k)
Output
Enter the first number5
Enter the second number7
Answer is 78125.0
Pr 5
To calculate Area and Perimeter of a rectangle
Output
Enter the length20
Enter the breadth35
Area is 700
perimeter is 110
Pr6
To calculating percentage of students by entering marks of 3 subjects
Pr 7
Output
Enter the age22
You can vote
Pr 8
Write a python code to check whether a number entered is odd or even
n=int(input("Enter the number"))
if n%2==0:
print("Number is even")
else:
print("Number is odd")
Output
Enter the number65
Number is odd
Pr 9
Write python code to calculate commission of salesman according to the following condition
Sale Commission
>=10000 10% of sales
>=5000 and <10000 8% of sales
<5000 6% of sales
Outptut
Enter the sales12000
commission is 1200.0
Pr 10
Write a python code to print first n natural numbers using while loop
Output
Enter the number10
sum is 55
Output
Enter the number5
Factorial is 120
Q. 13 Write a python code to print number of a table
Output
Enter the number6
6*1=6
6 * 2 = 12
6 * 3 = 18
6 * 4 = 24
6 * 5 = 30
6 * 6 = 36
6 * 7 = 42
6 * 8 = 48
6 * 9 = 54
6 * 10 = 60
Q,14 Create a list in Python of children selected for science quiz with following names-
Arjun, Sonakshi, Vikram, Sandhya, Sonal, Isha, Kartik
Perform the following tasks on the list in sequence-
○ Print the whole list
○ Delete the name “Vikram” from the list
○ Add the name “Jay” at the end
○ Remove the item which is at the second position.
l=["Arjun","Sonakshi","Vikram","Sandhya","Sonal","Isha","Kartik"]
print(l)
print(l.pop(2))
print(l.append("Jay"))
print(l.remove("Arjun"))
Output
['Arjun', 'Sonakshi', 'Vikram', 'Sandhya', 'Sonal', 'Isha', 'Kartik']
Vikram
num=[23,12,5,9,65,44]
print(len(num))
print(num[2:5:1])
print(num[-5:-2])
Output
6
[5, 9, 65]
[12, 5, 9]