0% found this document useful (0 votes)
4 views8 pages

Python1 Invert

The document contains a series of Python programming tasks that involve various operations such as truncating digits, calculating statistics, modifying lists, and implementing recursive functions. Each task focuses on different programming concepts including loops, conditionals, data structures, and string manipulation. The tasks are designed to enhance problem-solving skills and understanding of Python programming.

Uploaded by

kumarpatel96604
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)
4 views8 pages

Python1 Invert

The document contains a series of Python programming tasks that involve various operations such as truncating digits, calculating statistics, modifying lists, and implementing recursive functions. Each task focuses on different programming concepts including loops, conditionals, data structures, and string manipulation. The tasks are designed to enhance problem-solving skills and understanding of Python programming.

Uploaded by

kumarpatel96604
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

1.

Write a Python program to take 10 three digit numbers, truncate the first and last digits of

each, print the resul ng list, and count how many truncated digits are even.

2. Write a Python program to accept 5 integers from the user, calculate their sum, average,

maximum, and minimum values, and then display which and how many results are perfect

squares.
3. Write a Python program to create a list [10, 20, 30, 40, 50], replace the middle element with

the square of the maximum element minus the minimum element and print the final updated

list.

4. Write a Python program to take a list of integers from the user and create a new list that

contains only the first occurrence of each element (i.e., removes duplicates without using a set),

then display the list in reverse order and print the sum of its unique elements.
5. Write a recursive Python func on sum_of_digits(n) that returns the sum of the digits of a

given integer n.

6. Given three inputs that are stored in the variables a, b, and c. You need to print ‘a’ b mes and

‘b’ a mes in a single line separated by ‘c’.

7. Create two sets of city names represen ng ci es visited by Person A and Person B. Display

the ci es both visited (intersec on), visited by either (union), and ci es unique to A

(difference).
8. Write a program that takes a sentence as input and creates a dic onary where keys are words

and values are their frequencies.

9. Write a recursive func on power(base, exp) to compute base raised to exp without using **

or pow().

10. Write a func on that counts the frequency of each vowel in a user-given string and stores
it in a dic onary. Ignore case sensi vity.

11. Write a func on evaluate_expression(expr) that evaluates arithme c expressions given as

strings (only +, -, *, /) without using eval().


12. Write a recursive func on fla en(data) that fla ens a nested list (e.g., [1, [2, [3, 4]], 5] →

[1, 2, 3, 4, 5]).

13. Create two sets of product IDs and use logical operators to find items sold by both shops,

only one shop, and not sold by either.

14. Given a string s, and a pa ern p. You need to find if p exists in s or not and return

the star ng index of p in s. If p does not exist in s then -1 will be returned.

Here p and s both are case-sensi ve.


15. Write a Python program to find the first repea ng element in a given list of integers such

that it appears more than once and its first occurrence index is the smallest. Addi onally,

display the count of how many mes that element appears and remove all its later occurrences

from the list before prin ng the updated list.

You might also like