0% found this document useful (0 votes)
3 views1 page

Python Sample Questions

The document contains a series of Python programming tasks, including temperature conversion, tuple manipulation, set membership checking, string concatenation and trimming, positivity check, palindrome verification, tuple sum computation, heterogram and pangram checking, FizzBuzz implementation, and perfect number identification. Each task requires the use of built-in functions and provides specific examples or outputs. The tasks are designed to test various programming skills and concepts in Python.

Uploaded by

gigganegga6969
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Python Sample Questions

The document contains a series of Python programming tasks, including temperature conversion, tuple manipulation, set membership checking, string concatenation and trimming, positivity check, palindrome verification, tuple sum computation, heterogram and pangram checking, FizzBuzz implementation, and perfect number identification. Each task requires the use of built-in functions and provides specific examples or outputs. The tasks are designed to test various programming skills and concepts in Python.

Uploaded by

gigganegga6969
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Q1.

Write a Python program to (Using built-in functions)

a) convert temperature from Celsius to Fahrenheit [Fahrenheit = (Celsius * 1.8) + 32]


b) get the 4th element from the last in a tuple, t= (‘h’, ‘s’, ‘r’, ‘e’,‘k’, ‘a’, ‘c’, ‘m’)
c) Check whether 5 is a member of the set or not; s= {2,4,7,1,8,10,5}
d) Read two strings from user and concatenate them.
e) Trim trailing character in the string “HelloPython$”
f) Check if a number is positive or negative.

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.

Input : S = "hello Python"


Output : No
Since alphabet ‘h', ‘l', 'o' occurred more than 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".

You might also like