Course Name: Programming in Python
Course code: R1UC405C
Assignment 1(Winter2023-2024)
Submission Date: 19th March, 2024 before 5PM
Note: Assignment should be Handwritten on A4 sheet. After the respective deadline
no assignments are accepted, and it will be considering zero marks for non-submission.
Therefore, Submit the assignment on time.
Problem 1
Write about the history of Python from origin to present status with different version of python.[K2][CO1]
Problem 2
List out any ten keywords used in python and its function. Explain its working with python code
and its output.[K1][CO1]
Problem 3
Discuss any ten built-in functions in Python. Analysis of its execution through python code. Also,
mention the output of your respective python code.[K4][CO1]
Problem 4
Identify any ten-string methods. Illustrate its role with python code and its output.[K3][CO1]
Problem 5
Explain all list methods with proper python code and its output. Also, apply python code to
manipulate every element in a list with a list comprehension.[K2][CO1]
Problem 6
The purpose of this exercise is to understand conditionals. Tiberius is looking for his dream job,
but has some restrictions. He loves California and would take a job there if it paid over 40,000 a
year. He hates Massachusetts and demands at least 100,000 to work there. Any other place he’s
content to work for 60,000 a year, unless he can work in space in which case he would work for free.
Write the Python code to shows his basic strategy for evaluating a job offer.[K6][CO2]
Problem 7
Describe the concept of Iterators, Generators, Comprehensions Loops in Python and justify your
answer with proper python code.[K5][CO2]
1
Problem 8
Take two lists, say for example these two:
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
and write a program that returns a list that contains only the elements that are common between the
lists (without duplicates). Make sure your program works on two lists of different sizes.[K3][CO2]
Problem 9
”Python has a built-in module that you can use for mathematical tasks. The math module has a
set of methods and constants.” Investigate any five Methods and constants under the Math module
with proper python code.[K4][CO4]
Problem 10
Consider, a tree is represented as a nested list of lists. The tree would be represented as the list.
[4,[10,[33],[2]],[3],[14,[12]],[1]]
Notice that this tree is neither binary nor ordered in any way and that each of the levels is a list
of length 1.
Write two functions:bfs(tree,elem) and dfs(tree,elem) that perform a breadth-first search and depth-
first search respectively of the tree to return whether or not the element is in a tree. write the
python code for the given scenario.
[hint : use stacks and Queues concept][K5][CO2]