Computer Programs
Computer Programs
*******************************************************************
1. Write a Python script that asks the user to enter a length in centimetres. If the
user enters a negative length, the program should tell the user that the entry is
invalid. Otherwise, the program should convert the length to inches and print out the
result. There are 2.54 centimetres in an inch.
SOURCE CODE:
2. A store charges Rs. 120 per item if you buy less than 10 items. If you
buy between 10 and 99 items, the cost is Rs. 100 per item. If you buy 100 or more
items, the cost is Rs 70 per item. Write a program that asks the user how
many items they are buying and print the total cost.
SOURCE CODE:
3.Write a program that reads from user (i) an hour between 1 to 12 and, (ii) number
of hours ahead. The program should then print the time after those many hours.
Eg:
SOURCE CODE:
4. Write a program that asks the user for two numbers and print ‘close’ if the
numbers are within 0.001 of each other and ‘not close’ otherwise .
SOURCE CODE:
SOURCE CODE:
SOURCE CODE:
10. Write a short program to print the following series :
SOURCE CODE:
11. Write a short program to find average of list of numbers entered through
keyboard.
SOURCE CODE:
12. Write a program to input 3 sides of a triangle and print whether it is an
equilateral, scalene or isosceles triangle.
SOURCE CODE:
13. Write a program to take an integer a as an input and check whether it ends
with 4 or 8. If it ends with 4, print "ends with 4", if it ends with 8, print "ends with
8", otherwise print "ends with neither".
SOURCE CODE:
14. Write a program to take N (N > 20) as an input from the user. Print numbers
from 11 to N. When the number is a multiple of 3, print "Tipsy", when it is a
multiple of 7, print "Topsy". When it is a multiple of both, print "TipsyTopsy".
SOURCE CODE:
15. Write a short program to find largest number of a list of numbers entered
through keyboard.
SOURCE CODE:
16. Write a program to input N numbers and then print the second largest
number.
SOURCE CODE:
17. Given a list of integers, write a program to find those which are palindromes.
For example, the number 4321234 is a palindrome as it reads the same from left
to right and from right to left.
SOURCE CODE:
(iv) Output Y.
(For example, if X is equal to 2134, then Y should be 42 as there are 4 digits and
the most significant number is 2).
SOURCE CODE:
19. Write a Python program to print every integer between 1 and n divisible by m.
Also report whether the number that is divisible by m is even or odd.
SOURCE CODE :
SOURCE CODE:
b) Write Python programs to sum the given sequences:
12 + 32 + 52 + ..... + n2 (Input n)
SOURCE CODE:
SOURCE CODE:-
22. Write a program to accept the age of n employees and count the number of
persons in the following age group:
(i) 26 - 35
(ii) 36 - 45
(iii) 46 - 55
SOURCE CODE:
23 a)
SOURCE CODE:
23 b. Write programs to find the sum of the following series:
SOURCE CODE:
b)
SOURCE CODE
C)
SOURCE CODE :
d)
SOURCE CODE:
25. Write programs using nested loops to produce the following patterns:
SOURCE CODE:
b) Write programs using nested loops to produce the following patterns:
SOURCE CODE:
c)
SOURCE CODE:
d)
SOURCE CODE:
26. Write a program using nested loops to produce a rectangle of *'s with 6 rows
and 20 *'s per row.
SOURCE CODE:
27. Given three numbers A, B and C, write a program to write their values in an
ascending order. For example, if A = 12, B = 10, and C = 15, your program should
print out:
Smallest number = 10
Next higher number = 12
Highest number = 15
SOURCE CODE:
28.Write a Python script to input temperature. Then ask them what units, Celsius
or Fahrenheit, the temperature is in. Your program should convert the temperature
SOURCE CODE:
29.
Ask the user to enter a temperature in Celsius. The program should print a
• If the temperature is less than -273.15, print that the temperature is invalid
below freezing.
range.
• If it is above 100, print that the temperature is above the boiling point.
SOURCE CODE: