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

Python Application Programming Assignments

Uploaded by

baswanthrao
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)
26 views3 pages

Python Application Programming Assignments

Uploaded by

baswanthrao
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

Faculty of Engineering & Technology (Co-Edu)

(OFFERED BY COMPUTER SCIENCE AND ENGINEERING DEPARTMENT)

Academic Year: 2024 – 2025 Programme: [Link]


Semester: IV Section: B
Course Title: PYTHON APLLICATION PROGRAMMING Course Code: 22CS44

Assignment Given Details

Sl. No. Assignment Name Date Remarks

01 26/4/2024 02
a) With syntax illustrate the following functions used in python print(), input(),
len() and str().

26/4/2024 02
b) What are user defined functions? How can we pass parameters in user
defined functions? Explain with suitable example.

02 a) Write a function named collatz() that has one parameter named number. If 3/5/2025 02
number is even, then collatz() should print number // 2 and return this value.
If number is odd, then collatz() should print and return 3 * number + 1.
b) Input Validation 3/5/2025 02
Add try and except statements to the collatz() to detect whether the
user types in a noninteger string. Normally, the int() function will raise a
ValueError error if it is passed a noninteger string, as in int('puppy'). In the
except clause, print a message to the user saying they must enter an integer.
03 a) commaCode() function takes a list value as an argument and returns a string 6/5/2025 02
with all the items seperated by comma and a space, with and inserted before
the last item.

 spam=['apples','bananas','tofu','cats']
 For example, passing the above spam list to the function would
return 'apples, bananas, tofu, and cats'.

b) write code that uses it to print the image. 6/5/2025 02


..[Link]..
.OOOOOOO.
.OOOOOOO.
..OOOOO..
...OOO...
....O....
Hint: You will need to use a loop in a loop in order to print grid[0][0],
then grid[1][0], then grid[2][0], and so on, up to grid[8][0]. This will finish
the first row, so then print a newline. Then your program should print
grid[0][1], then grid[1][1], then grid[2][1], and so on. The last thing your
program will print is grid[8][5].
Also, remember to pass the end keyword argument to print() if you

04 a) List to Dictionary Function for Fantasy Game Inventory 13/5/2025 02


Imagine that a vanquished dragon’s loot is represented as a list of strings
like this:
dragonLoot = ['gold coin', 'dagger', 'gold coin', 'gold coin', 'ruby']
Write a function named addToInventory(inventory, addedItems), where the

inventory parameter is a dictionary representing the player’s inventory


and the addedItems parameter is a list like dragonLoot.

b) Table Printer: 13/5/2025 02

 Write a function named printTable() that takes a list of lists of strings


and displays it in a well-organized table with each column right-
justified. Assume that all the inner lists will contain the same number
of strings. For example, the value could look like this:

tableData = [['apples', 'oranges', 'cherries', 'banana'], ['Alice', 'Bob', 'Carol',


'David'], ['dogs', 'cats', 'moose', 'goose']]

05 a) Strong Password Detection 16/5/2025 02


Write a function that uses regular expressions to make sure the password
string it is passed is strong. A strong password is defined as one that is at
least eight characters long, contains both uppercase and lowercase characters,
and has at least one digit. You may need to test the string against multiple
regex patterns to validate its strength.
b) Extending the Multiclipboard 16/5/2025 02
Extend the multiclipboard program in this chapter so that it has a delete
<keyword> command line argument that will delete a keyword from the shelf.
Then add a delete command line argument that will delete all keywords.

06 29/5/2025 02
a) write a python function to Reads a text file, prompts the user for Mad
Libs words, and creates a new text file with the completed story.

b) Write a program that finds all files with a given prefix, such as 29/5/2025 02
[Link], [Link], and so on, in a single folder and locates any gaps
in the numbering (such as if there is a [Link] and [Link] but no
[Link]). Have the program rename all the later files to close this gap.
07 a) Write a program to create a class Time to represent time in HH:MM:SS 6/6/2025 02
format. Perform following operations:
[Link] + to add two time objects
b. Overload + to add a numeric value to a time object
(commutative)
c. Overload __str__() to display time in appropriate format
6/6/2025 02
b) Identify the key differences between [Link]() and [Link]()
with suitable examples.

08 a) Discuss the significance of __init__() method in Python with a proper 13/6/2025 02


example code snippet
13/6/2025 02
b) Differentiate pure functions and modifiers with suitable examples
09 a) Using the following array build command for the following: array 20/6/2025 02

([[10, 11, 12, 13],

[14, 15, 16, 17],

[18, 19, 20, 21]])

a) Find the sum of all elements.

b) Find the sum of all elements row-wise.

c) Find the sum of all element’s column-wise.

d) Find the min of all elements in each row.

e) Find the mean of all elements in each row.

d) Find the transpose of a given matrix


b) Consider the following Series object, “company” and its profit in Crores 20/6/2025 02

TCS 350

Reliance 200

L&T 800

Wipro 150

i. Write the command which will display the name of the company having
profit>250. ii. Write the command to name the series as Profit.
10 a) How to create Imopting and exporting data between CSV files and Data 2/7/2025 02
frames, explain it with an example

b) How to perform mathematical operations on series in pandas ?explain with 2/7/2025 02


example.

You might also like