Python Level 2 Summary Sheet
Python Level 2 Summary Sheet
Session 1:
Topics Discussed:
Programs Practised:
Session 2:
Topics Discussed:
User defined functions
Defining and calling functions
Advantage of using functions
Use of parameters in function
Default parameters in function
Programs Practised:
1. Make a function to add two numbers given inside functions
2. Custom greeting generator
3. Add two numbers using parameter passing
4. Add two numbers with one number as default parameter
5. Enter student name, standard and , marks of three subject pass them as argument to a
function and function should return average marks. Create another function which takes
standard as default value 7 as return the same result as above.
Session 3:
Topics Discussed:
Return statement
Using function along with conditional statements.
Programs Practised:
1. WAP to define and call a default parametric function in which one variable is default and the
second is passed ex:my_add(a,b=16)
2. Write a function names volume with parameters length, breadth and height of a
cuboid(passed to it when called).The function should calculate the volume of a cuboid . It
should return the volume to the main function where it is called.The main function should
return the volume.
3. Make a calculator program with four functions /,*,+,-.Ask two number from users , also ask
the operator from the user. Make conditionals for the 4 operator and call the respective
functions. You will have to pass the numbers to the respective functions as parameters like
this.
Session 4:
Topics Discussed:
Inbuilt functions and their examples.
Difference between inbuilt and user defined functions.
Example of home cleaning robot to differentiate between built-in and user defined functions
Built-in functions: print(), input(),
max(),min(),len(),sum(),round(),list(),statistics.mean(),range(),round()
Programs Practised:
1. Ritu sells her 6 hand made toys for the following price 79,89,90,56,98,89.Calculate the
following for Ritu. Use built-in functions.
Total money made by her.
Max and min price of the toys she sold
Average price of the toys she sold.
Session 5:
Topics Discussed:
Revise List concept
ts like displaying all elements of list using its index .
Slicing
Reverse indexing(index from rear)
Changing elements of list using slicing
Programs Practised:
1. List slicing examples like lst[Start:],lst[:stop],lst[start:stop]
2. Players example
3. Players[start,stop,stepsize]
4. Example of changing sentence using slicing
5. Create a list and print every second element
6. Print every third element from end
7. Slice last three characters from list
8. Reverse the list
Session 6:
Topics Discussed:
Built-in functions of
list:index(),append(),extend(),count(),pop(),reverse(),sorted(lst),insert(),in,del,remove(),clear
()
List Comprehension
Programs Practised:
1. Ice cream activity:
2. Using list Comprehension print all even numbers upto 30,
3. Calculating sum of all even numbers till 30.sum([i for i in range(1,30) if i%2==0])
Session 7:
Topics Discussed:
Tuples
Difference between tuples and list
Uses of tuples
Conversion of tuples to list and vice versa
Built-in functions of tuples(in, count,index)
Programs Practised:
1. Create a tuple with 5 fruits in it. Get the input from user…”what fruit you want”,… if user
chooses any of the fruit from tuple.. you display “hey enjoy the fruit”, .. else display…”sorry
you have to starve”.
2. Create a tuple with five sports in it. Get the input from user asking for sport of its choice. If
sport is present in the tuple of sports than display “enjoy the sport “, else add that sport into
the tuple and display the tuple.
Session 8:
Topics Discussed:
Sets
Venn Diagram
Defining of sets
Built-in functions of sets(Union, intersection, Difference, Symmetric_difference() ,
add(),update(),pop(),copy(),remove(), clear(),del)
Actual use of sets
Use of tab keys.
Quiz
Programs Practised:
1. Make a set of rainbow colors . Make another set which have some colors of rainbow and
some other colors. Now add one color to one of the sets. Now find union, intersection,
difference and Symmetric_difference of the sets.
2. Create two list of numbers .Convert it into sets. Calculate union, intersection, difference and
Symmetric_difference of the sets. And also remove duplicate elements of the list
Session 9:
Topics Discussed:
Dictionaries
Properties of keys in key value pair of dictionaries.
Accessing and updating values in dictionaries
Use of dictionary
Built-in functions(get(),update(),pop(),popitem()del(),clear()
Programs Practised:
1. Implementing ice cream activity using dictionaries
2. Create a dictionaries which has all the specifications of a car, like model, make,size, type,
max speed , no of seats etc.
3. Create a dictionary of food outlet. print all the keys, values, and key value pairs .
4. Define two dictionary stock and prices of fruits. Then using a for loop print the total cost of
each fruit by multiplying the stock with the prices of each fruit. Store the total in another
dictionary called total with keys as fruit name and sum total as value.
5. Create a dictionary for library and perform task of updating some values as asked.