You are on page 1of 1

SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY

SOFTWARE ENGINEERING DEPARTMENT


Fall 2022F
Programming Fundamentals (SWE-102)
Assignment # 2
Semester: I Batch:2022F
Max. Marks 10
Instructions:

• Attempt all questions


• Do not copy or cheat from anyone, make your own effort. If any assignment found copied it will
straight away be rejected.
• Take the help from internet or any other online sources is allowed. If the data has been taken
• from any online source, then please organize it properly, do not copy and paste exactly.
• There is no maximum page limit.
• Assignment should be handwritten.
• Mention your full name and roll number on the first / front page.
• The page numbers must be mentioned at the right bottom corner in the whole assignment.
• Last date of submission of assignment is: 03-Jan-2023 [Tuesday]

Question 1 (2)
1- Write difference between List, Tuple and Dictionary with examples.
2- Write difference between sort() and sorted.
3- What are membership operator and also write their uses and examples.
4- Is for and while loop is applicable for the traversing of List, Tuple and Dictionary elements? Support
your answer with an appropriate example.
Question 2 (2)
A number raised to the third power is called a cube. For example, the cube of 2 is written as 2**3 in Python.
Make a list of the first 10 cubes (that is, the cube of each integer from 1 through 10), and use a for loop to
print out the value of each cube.

Question 3 (2)
Write a program which implements linear search in tuple using function.
 Input 7 elements and 2 keys from user
 The algorithm consists of iterating over a tuple and returning the index of the first occurrence of an item
once it is found.
 If the element is not in the tuple it should print not found message

Question 4
(a) Take a list from user of maximum length 10 and apply Sorting algorithm (1)
(b) Write a program for tuple which take elements by user input and perform following task (1)
 append(9)
 remove(7)
 [5] = 1
 [1:]
 [-3]
 [ : :2]
Question 5 (2)
Make a dictionary called cities. Use the names of three cities as keys in your dictionary. Create a dictionary of
information about each city and include the country that the city is in, its approximate population, and one fact
about that city. The keys for each city’s dictionary should be something like country, population, and fact.
Print the name of each city and all of the information you have stored about it.

You might also like