Questions
1. Write a program to enter a string and print the length and first and last character of the the string .
2. Write a program to enter two strings and print True if both are equal , else print False
3. Write a program to enter a string and a number and display the character at that position in the string
4. Write a program to enter a string and print True if first and last character are same else print False .
5. Write a program to enter a string and print True if first and last character are same ( without finding
length of string)
6. Write a program to enter a number and print it’s quotient and remainder.( do it in interactive mode)
7 Write a program to enter a two digited number and print True if the first digit is equal to second digit
otherwise print False. (do in interactive mode)
For eg. : if n= 22 , it will print True
If n= 23 , it will print False
8. Write code to enter n, and display “Hello” n times. ( do in interactive mode)
9. Write a program to find area of triangle using Hero’n formula.
10. Write a program to enter time in minutes and convert it to hours and minutes.
For eg. : if time entered is = 456 minutes , then output will be 4 hours 56 minutes.
11. Write a program that expresses an object’s mass ( 1 kilogram) and velocity( in meters per
second) as inputs, and displays its momentum and kinetic energy.
Formula : Momentum = mv
Kinetic energy = (1/2)mv2
Where m – object’s mass and v – object’s velocity.
12. Write an equivalent python expression for following :
¿¿
13. Consider the following declaration :
a,b,c=5,10,15
Evaluate the given expression :
S= ((a) && (b-c)) || (!(2b+c-a)&& ( a/b-c))
14. What will be the output of following:
import math
x= -25.7
print(math.ceil(x), math.round(x))
15. what could be the possible minimum and maximum values in following code :
import random
print(random,randint(5,15)*2)
16 Write code to generate a random floating number between 56.0 and 105.0. Print
the number along with its nearest integer greater than and less than the number.
17. Write a program to generate to random integers a and b between 2 and 15 and
print the numbers and the power of a to b also.
18. Write code to display the square root of a random integer generated in the
range 50 to 90 with a step of 10.
19. Consider the following list of marks of 10 students, display the mean , median
and mode .
Marks = [20,10,12,34,56,23,45,34,23]
20 Write code to enter radius and display volume of sphere.
21 Write a program to enter the length, width and height of a parallelogram and
calculate its area and perimeter.
22. Write a program to enter temperature in degree celcius and convert it to degree
9
fahrenheit. F=C × +32
5
23.Write a program to enter mass of an object and determine its energy using the
formula E=m c2 where E – Energy, m is mass and c= 3 X108 m/s (speed of light)
24. Write a program to enter a 3 digited number , reverse the number and print it.
For eg. : if n= 345 then n1 = 543
25. Write a program to enter two numbers a and b and print True if a is divisible by
b otherwise print False.