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

Slot2

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 1

Slot 2:

1 Write a function in python to count the number of lines from a text file "story.txt"
which is not starting with an alphabet "T".
Example: If the file "story.txt" contains the following lines:
A boy is playing there.
There is a playground.
An aeroplane is in the sky.
The sky is pink.
Alphabets and numbers are allowed in the password.
The function should display the output as 3

2 Write a function in Python to count words in a text file those are ending with
alphabet "e".

Input: India is the fastest-growing economy. India is looking for more investments around
the globe.
Output: Total count: 2
3 Using a lambda function to sort a list of strings by the last character

Input: ["apple", "banana", "cherry"]


Output: ["banana", "apple", "cherry"]

4 Write a function that accepts a variable number of arguments, where each


argument is a tuple of numbers. Return the sum of all numbers.

Input: nested_args_sum((1, 2), (3, 4, 5), (6,))


Output: 21

You might also like