Python Sample Questions
Python Sample Questions
Q2. Write a Python Program to check whether the number entered by +the user is a palindrome or not.
Sample Input: Enter an integer: 1001
Output: 1001 is a palindrome.
Q3. Write a Python program to compute the sum of all the elements of each tuple stored inside a list of tuples.
Original list of tuples: [(1, 2), (2, 3), (3, 4)]
Sum of all the elements of each tuple stored inside the said list of tuples: [3, 5, 7]
Q4. Write a Python program to check whether a string entered by user is Heterogram or not.
A heterogram is a word, phrase, or sentence in which no letter of the alphabet occurs more than once.
Examples:
Input : S = "the big dwarf only jumps"
Output : Yes
Each alphabet in the string S is occurred only once.
Q5. Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead
of the number and for the multiples of five print “Buzz“. For numbers that are multiples of both three and five
print “FizzBuzz“.
Sample output: 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz Fizz 22 23 Fizz Buzz…
Q6. Write a Python program to check Whether the numbers in a list are Perfect Numbers or not. Also print the count
of such numbers.
A perfect number is a number that is equal to the sum of its proper divisors. For example, the divisors of 6 are 1, 2
and 3. The sum of the proper divisors of 6 is 1 + 2 + 3 = 6, which is a perfect number. The sum of the proper divisors
of 28 is 1 + 2 + 4 + 7 + 14 = 28, which is also a perfect number.
Q7. Write a program to check if a string entered by user is a pangram or not.
A pangram is a string that contains all the letters of the English alphabet.
Example of a pangram is "The quick brown fox jumps over the lazy dog".