1.
Write a Python program that accepts the user's first and last name and
prints them in reverse order with a space between them.
2. Write a Python program to display the first and last colors from the
following list.
color_list = ["Red","Green","White" ,"Black"]
3. Write a Python program that accepts an integer (n) and computes the
value of n+nn+nnn.
Sample value of n is 5
4. Expected Result : 615
5. Write a Python program to get the volume of a sphere with radius six.
6. Write a Python program to test whether a number is within 100 of 1000 or
2000.
7. Write a Python program to calculate the sum of three given numbers. If the
values are equal, return three times their sum.
8. Write a Python program that determines whether a given number
(accepted from the user) is even or odd, and prints an appropriate
message to the user.
9. Write a Python program to count the number 4 in a given list.
10. Write a Python program to print all even numbers from a given list of
numbers in the same order and stop printing any after 237 in the
sequence.
Sample numbers list :
numbers = [
386, 462, 47, 418, 907, 344, 236, 375, 823, 566, 597, 978, 328, 615, 953, 345,
399, 162, 758, 219, 918, 237, 412, 566, 826, 248, 866, 950, 626, 949, 687, 217,
815, 67, 104, 58, 512, 24, 892, 894, 767, 553, 81, 379, 843, 831, 445, 742, 717,
958,743, 527
]
(PTO)
11.Write a Python program that prints out all colors from color_list_1 that are
not present in color_list_2.
Test Data :
color_list_1 = set(["White", "Black", "Red"])
color_list_2 = set(["Red", "Green"])
Expected Output :
{'Black', 'White'}
12. Write a Python program to find the least common multiple (LCM) of two
positive integers.
13. Write a Python program to compute the future value of a specified
principal amount, rate of interest, and number of years.
Test Data : amt = 10000, int = 3.5, years = 7
Expected Output : 12722.79
14. Write a Python program to convert height (in feet and inches) to
centimeters.
15. Write a Python program to calculate the hypotenuse of a right angled
triangle.
16. Write a Python program to calculate sum of digits of a number.
17. Write a Python program to swap two variables.
Ex. : . a = 5 and b = 6 ⇒ a = 6, b = 5
18. Write a Python program to compute the product of a list of integers
19. Write a Python program to get a string made of the first 2 and last 2
characters of a given string. If the string length is less than 2, return the
empty string instead.
Sample String : 'w3resource'
Expected Result : 'w3ce'
Sample String : 'w3'
Expected Result : 'w3w3'
Sample String : ' w'
Expected Result : Empty String
20. Write a Python program to get a single string from two given strings,
separated by a space and swap the first two characters of each string.
Sample String : 'abc', 'xyz'
Expected Result : 'xyc abz'
21. Write a Python function that takes a list of words and return the longest
word and the length of the longest one.
Sample Output:
Longest word: Exercises
Length of the longest word: 9
22. Write a Python program to find the maximum number of characters in a
given string.
23. Write a Python program to compute the sum of the digits in a given
string.
24. Write a Python program to print the numbers of a specified list after
removing even numbers from it.
25. Write a Python program to multiply all the items in a list.
26. Write a Python program to find the index of an item in a specified list.
27. Write a Python program to select the odd items from a list.
Eg. my_list = [1,2,3,4,5] ⇒ ans = [1,3,5]
28. Write a Python program to find a list of integers with exactly two
occurrences of nineteen and at least three occurrences of five. Return True
otherwise False.
Input:
[19, 19, 15, 5, 3, 5, 5, 2]
Output:
True
Input:
[19, 15, 15, 5, 3, 3, 5, 2]
Output:
False
Input:
[19, 19, 5, 5, 5, 5, 5]
Output:
True
29. Write a Python program to find the biggest even number between two
numbers inclusive.
Input:
m = 12
n = 51
Output:
50
Input:
m=1
n = 79
Output:
78
Input:
m = 47
n = 53
Output:
52
Input:
m = 100
n = 200
Output:
200
30.