0% found this document useful (0 votes)
7 views3 pages

PF Assignment3

This document outlines a Python assignment consisting of ten problems that cover fundamental programming concepts. The tasks include checking for palindromes, computing averages, merging and sorting lists, creating tuples and dictionaries, and performing various operations on them. Additionally, the assignment requires writing programs to analyze strings and lists, focusing on user input and data manipulation.

Uploaded by

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

PF Assignment3

This document outlines a Python assignment consisting of ten problems that cover fundamental programming concepts. The tasks include checking for palindromes, computing averages, merging and sorting lists, creating tuples and dictionaries, and performing various operations on them. Additionally, the assignment requires writing programs to analyze strings and lists, focusing on user input and data manipulation.

Uploaded by

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

Python Fundamentals

(Assignment3)

[Link]@[Link]
Assignment Problems
Q1. Ask the user for a string and check whether it is a palindrome or not.
A palindrome is a string which is same when we read it forward & backward. Eg -
“madam”, “racecar” etc.
[Hint - A palindrome string is equal to the reversed version of the string. We can
use a loop to reverse the string manually. ]
Q2. Given a list of integers compute the average of all numbers in the list.
Q3. Input two lists of integers from the user. Merge them into one list and sort the
result.
Eg - list1 = [1, 2, 7] , list2 = [2, 4, 5]
result = [1, 2, 3, 54, 5, 7]

Q4. Given a tuple of integers, create:


• A tuple of all even numbers
• A tuple of all odd numbers
Q5. Create a dictionary where:
• Keys = student names
• Values = marks (integer)

[Link]@[Link]
Write a menu-based program where user presses a key (’A’, ‘B’, ‘C’, ‘D’)
depending on the operation they want to perform on the dictionary:
1. A - Add a student
2. B - Update marks
3. C - Search for a student
4. D - Display all students and marks
Q6. Given a list of words:
words = ["apple", "banana", "kiwi", "cherry", "mango"]

Create a dictionary that maps each word to its length.


Example:
{"apple": 5, "banana": 6, "kiwi": 4, ...}

Q7. Write a program that takes a string from the user and prints the number of
spaces in the string.
Q8. Write a program to check whether two lists share no common elements.
# share no common elements list1 = [1, 2, 3, 4] list2 = [5, 6, 7, 8]
# share common elements list1 = [1, 2, 3] list2 = [3, 4]

[Hint - use sets]


Q9. Given a list, print all elements that appear more than once in the list.
[Hint - use sets]
Q10. Ask the user for a string and print:
• All unique characters
• The count of unique characters

[Link]@[Link]

You might also like