PROGRAMS ON PYTHON
BASICS
1. Write a python program to add three numbers and print result
2. Write a python program to find average of 5 numbers
3. Write a python program to read marks in 6 subject and calculate
total and percentage
4. Write a Python program to convert all units of time into seconds.
5. Write a Python program to get an absolute file path.
6. Write a Python program to convert seconds to day, hour, minutes
and seconds.
Write a python program to convert temperature from Fahrenheit
to Celsius
7. Write a python program to convert temperature from
Celsius to Fahrenheit
8. Write a program to calculate Simple interest
9. Write a program to calculate area of Rectangle
10. Write a program to calculate area of Square
11. Write a program to calculate area of Circle
12. Write a program to calculate Perimeter of Rectangle
13. Write a Program to print ASCII Value of a character
14. Write a Python program to print the following string in a specific
format (see the output).
Sample String : "Our greatest fear should not be of failure, but of
succeeding at something that doesn't really matter."
Output :
Our greatest fear should not be of failure, *******************************************
**************************but of succeeding at something that doesn't really matter.
15. Write a Python program to display the current date and time.
Sample Output :
Current date and time :
2014-07-05 14:34:14
16. Write a Python program which accepts the user's first and last
name and print them in reverse order with a space between them.
17. Write a Python program which accepts a sequence of comma-
separated numbers from user and generate a list and a tuple with
those numbers.
Sample data : '30', ‘1’,' 15', ' 22', ' 53'
Output :
List : ['30', 1,' 15', ' 22', ' 53']
Tuple : ('30', 1,' 15', ' 22', ' 53')
18. Write a Python program to display the first and last colors from the
following list.
color_list = ["Red","Green","White" ,"Black"]
19. Write a Python program that accepts an integer (n) and computes
the value of n+nn+nnn.
Sample value of n is 5
Expected Result : 615
20. 11. Write a Python program to print the documents (syntax,
description etc.) of Python built-in function(s).
Sample function : abs()
Expected Result :
abs(number) -> number
Return the absolute value of the argument.
21. Write a Python program to get the volume of a sphere with radius
6.
22. Write a Python program to get the difference between a given
number and 17, if the number is greater than 17 return double the
absolute difference.
23. Write a Python program to test whether a number is within 100 of
1000 or 2000.
24. Write a Python program to count the given number in a given list.
25. Write a Python program to get the n (non-negative integer) copies
of the first 3 characters of a given string. Return the n copies of the
whole string if the length is less than 2.
26. Write a Python program to test whether a passed letter is a vowel or
not.
27. 25. Write a Python program to check whether a specified value is
contained in a group of values.
Test Data :
3 -> [1, 5, 8, 3] : True
-1 -> [1, 5, 8, 3] : False
28. Write a Python program that will accept the base and height of a
triangle and compute the area.
29. Write a Python program to compute the greatest common divisor
(GCD) of two positive integers.
30. Write a Python program to get the least common multiple (LCM) of
two positive integers.
31. Write a Python program to sum of three given integers. However, if
two values are equal sum will be zero.
32. Write a Python program to sum of two given integers. However, if
the sum is between 15 to 20 it will return 20.
33. Write a Python program that will return true if the two given integer
values are equal or their sum or difference is 5.
34. Write a Python program to add two objects if both objects are an
integer type.
35. Write a Python program to display your details like name, age,
address in three different lines.
36. Write a Python program to solve (x + y) * (x + y).
Test Data : x = 4, y = 3
Expected Output : (4 + 3) ^ 2) = 49
37. Write a Python program to convert height (in feet and inches) to
centimeters.
38. Write a Python program to convert the distance (in feet) to inches,
yards, and miles.
39. Write a Python program to calculate body mass index.