0% found this document useful (0 votes)
3 views2 pages

Python Programming Skill Course Model Questions

The document contains a list of 24 programming exercises designed to enhance Python programming skills. Each exercise focuses on different concepts such as data types, control structures, functions, and data structures. The tasks range from simple input/output operations to more complex functions involving lists, strings, and sets.

Uploaded by

Phani P
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 views2 pages

Python Programming Skill Course Model Questions

The document contains a list of 24 programming exercises designed to enhance Python programming skills. Each exercise focuses on different concepts such as data types, control structures, functions, and data structures. The tasks range from simple input/output operations to more complex functions involving lists, strings, and sets.

Uploaded by

Phani P
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

Python Programming Skill Course Model Questions

1. Write a program that asks the user for a weight in kilograms and converts it to pounds.
There are 2.2 pounds in a kilogram
2. Write a program that asks the user to enter three numbers (use three separate input
statements). Create variables called total and average that hold the sum and average of
the three numbers and print out the values of total and average
3. Write a program to find power of a number without using loops and built-in functions.
Base and exponent value to be taken from the user
4. Write a program that asks the user to enter a length in feet. The program should then
give the user the option to convert from feet into inches, yards, miles, millimeters,
centimeters, meters, or kilometers. Say if the user enters a 1, then the program
converts to inches, if they enter a 2, then the program converts to yards, etc.
5. Write a program to check whether given character is alphabet or not, if yes check
whether vowel or consonant.
6. Write a program to display ‘Valid’ if the value is odd and lesser than 10000, otherwise
‘Invalid’.
7. Write a program to print next immediate prime number of the given number.
Input: 5 Output: 7
8. Write a program to find the sum of corner elements in the given matrix
9. Write a program that asks the user for an integer and creates a list that consists of the
factors of that integer.
10. Given a string, the task is to write a program to replace every Nth character in a string
by the given value K. String, K and N must be given the user.
11. Write a program to find the reverse of each word in the given list of strings and
display them.
12. Given a string, the task is to write a program to extract overlapping consecutive string
slices from the original string according to size K. K and string is to be given by user.
Input: raghu Output: ['ra', 'ag', 'gh', 'hu']
2
13. Write a program to display first repeating character from the beginning of the given
string.
14. Write a program to count the numbers of characters in the string and store them in a
dictionary data structure.
Sample Input: hello python
Sample Output: 1, e : 1, h : 2, l : 2, n : 1, o : 2, p : 1, t : 1, y : 1
15. Write a program to extract only extreme K elements, i.e maximum and minimum K
elements in Tuple.
Input : test_tup = (3, 7, 1, 18, 9), k = 2
Output : 3, 1, 9, 18
16. Given a list of numbers, write a Python program to create a list of tuples having first
element as the number and second element as the cube of the number.
17. Write a program to print the following pattern when n (no. of rows) is given as input,
If
n=4,
*
**
***
****
18. Write a program that combines two given lists into a dictionary
Sample Input Sample Output
jkl def abc ghi abc:30
10 20 30 40 def:20
ghi:40
jkl:10
19. Write a function ‘ball_collide’ that takes two balls as parameters and computes if they
are colliding. Your function should return a Boolean representing whether or not the
balls are colliding. [functions]
Hint: Represent a ball on a plane as a tuple of (x, y, r), r being the radius. If (distance between
two balls centers) <= (sum of their radii) then (they are colliding)
20. Write a function called ‘first_diff’ that is given two strings and returns the first
location in which the strings differ. If the strings are identical, it should return -1.
21. Write a function called ‘sum_digits’ that is given an integer num and returns the sum
of the digits of num.
22. Write a program to demonstrate the below functions of Set,
i) difference ii) isdisjoint() iii) symmetric_difference()
23. Write a program to demonstrate the below functions of Set,
i) pop() ii) union() iii) intersection()
24. Write a program to demonstrate the below functions of Set,
i) add() ii) update() iii) discard()

You might also like