0% found this document useful (0 votes)
15 views9 pages

Default Folder

Uploaded by

hridayanmann19
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)
15 views9 pages

Default Folder

Uploaded by

hridayanmann19
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
You are on page 1/ 9

them as out

and section from user and print


Write a program to input name age
, , class
1.
name= input("Enter your full name :")
age= input ("Enter your age :")
cl= input ( "Enter your class ")
:
section= input ("Enter your section :")
print( "Your name name
:" , )
print ("Your age : " ,age )
print("Your class :" ,cl )
Your
print ( " section :" s
, ection )
2. Write a program to convert hours into minutes and seconds .
hours - int(input ( "Enter the hours y
, ou want to convert :" ) )
minutes - hours * 60
seconds minutes 60
print (hours hours into minutes are
,"
:" m
, inutes )
print (hours hours
," into seconds are ." s
, econds )
3. Write a program to input height in inches and display it in cms .
inch int(input (" Enter
height into inches .
" ))
cms - inch 2.54
print (inch "inch
, into cms are :" .cms )
4. Write a program to find
fuel= float (input ( "Enter the amount of fuel filled in the vehicle :" ))
kms = float (input ( "Total kms :") )
mileage= kms /fuel
print( "mileage of your vehicle is "
: ,mileage )
Write a program to input your
mm
5.
first name last name dd
, , , , yr and display it the following
format :
Neha Sharma was born on 16 09 2000
= input ( "Enter your
first first name :")
= input ( "Enter
last your last name :"
)
date= input ( "Enter your birth date :")
month = input ( " Enter your birth month .")
year- input ( "Enter your birth year :")
print (first,last,"was
born on " ,date ,month year )
6. Write a program to convert kelvin measurement
to Celsius .
kel- int(input (" Enter
the temperature into kelvin ))
:"
celsius- kel- 273.15
print( kel temperature
,"
into celsius :" ,celsius )
7. Write a program to check whether a number is even or not .
num = int(input (" Please enter a number : "))
if( num% 2== 0 ) :
print (num ," is an even number ")
else :
print num
( ," is a odd number ")
8. Write a program to input a number from the user and find out whether it is positive , negative or
zero .
num int(input ( "Please enter a number ") )
:
if(num >0 ) :
print ( num ," is positive ")
(num
elif <0 ) :
print(num ," is negative ")
else :
num
print( , " is zero " )
9. Write a program to input a number from the user and display the sum starting from that
particular number till 1( using while loop ).
n- int(input ( " Enter n u m b e r :" ) )
sum = 0
-
i 1
while in .
sum -sum -
Q
i
=
i i+ 1
Page 2 / 4 +
print ("The sum sum
is ." , )
10. Write a program to print odd numbers from 1 to 10 .
for i in range (1,11,2) :
print ( i)
11. Write a program to print odd numbers (1-10 ) in reverse order .
for i in range (9,0 ,-2) :

FILTERTEMPLE
print(i)
1947 .

SZER SAREE
EXERCENT
12. Write a program to input a number from the user and display its table using for loop ( e.g. 2* =2
1 ) .
num - int( input ("Please enter a number ")
: )
if num >0 :
for x in range ( 1,11,1 ) .
print num
( ,X
" " x
, "-
, " num
, *x )
else :
print (" Entered number should be greater than zero ")
13. W r i t e a program to input a number from the user and
display its factorial .
For 0 it displays the message "The factorial of 0 is "
1 .
For negative numbers displays "Factorials of negative
it
numbers doesn't exists " .
num = int(input("Please enter a number :") )
factorial= 1
num < 0 ) :
if(
print(" Factorials of negative
numbers doesn't exists ")
elif( num == 0 ):
print("The factorial of 0 is 1 ")
else :
for i in range (2 num +
, 1) :
factorial factorial * i
print("The factorial of " num, ," is " factorial )
,
Write a program to input a number from the user to check whether th amber is prime or not
using while loop .
num1 = int (input ("Enter any number : ") )
k=0
ifnum1 0 or num1 == 1
=

: :
print( "Not a prime number ")
else :
i= 2
while( i<num 1) :
ifnum1 % i== 0 :
k = k+ 1
=
i +
i l
ifk == 0 :
print ( num1 , " is prime number ")
else :
print num1
( , "is not prime number " )
Write a program to create a list of 5 names and display it with its index value .
15. Write a program
to create a list of 5 names and display it with its index value .
list1= [ Sam
" " John "
" "Sophia "
Mae
,
," "Jack " ]
,
" ,
print (list1 [0 ] )
print (list! [ 1] )
print (list 2
][ ])
print( list1[3 ])
print( list1 [4 ] )
16. Write a program to create a list with the following numbers and perform
the given tasks:
a.
b.
c .

Add 21 in the last of the


Delete the fourth item on the
Print the 5th element from the

10,23456789
list.
list.
.
list
d . Remove 18 from the list and display the final list with all the elements in it.
list1= { 10,11,12,13,14,15,16,17,18,19,20 ]
list1 append (21 )
print( list !)
list1 pop (3 )
print ( list )
print ( list1[4 ] )
list1 remove( 18 )
print (list )
17. W r i t e a program to create a list of 3 numbers and perform the following given tasks :
a. Insert any two numbers at the beginning of the list.
b . Remove the item (number ) at 3rd position .
c. Display the sum of first two items of a list.
d . Display the reverse of list.
list1 (10,11,12 ]
list1.insert(0,6 )
list1.insert( 1,7)
print( list1 )
list1.pop(4 )
print ( list1 )
print (list1 [0 ]+ list1[ 1])
list1.reverse()
print ( list1 )
Page 4 / 4

You might also like