A Critique of the Proposed National Education Policy Reform
5 cs xii_python_functions _ passing str list tuple
1. .
Class-XII Computer Science (083)
All the contents used as part of the slides are either self created or from the public domain or textbooks for Class XII.
This presentation is only used for leaning purpose only. Programs used in this presentation are based on Python 3.8.0.
Computational Thinking and Programming - 2
Working with Functions
Passing Strings, Lists, Tuples, Dictionaries to function
S K Mahto, PGT (Computer Science)
J.N.V East Medinipur WB
2. Working with Functions
Topics to be covered
● Passing Strings to function
● Passing Lists to function
● Passing Tuples to function
● Passing Dictionaries to function
Presented by : S K Mahto, PGT Computer Science
3. Working with Functions
Passing String to a Function
● String can be passed in a function as argument but it is used as pass by
value. It can be depicted from below program. As it will not change value of
actual argument.
Presented by : S K Mahto, PGT Computer Science
Output :
Sanjay
4. Working with Functions
Passing List to a Function
● List is mutable data type that’s why it treat as pass by reference.
● It is already discussed in topic Mutable/immutable properties of data
objects.
Presented by : S K Mahto, PGT Computer Science
Output
5. Working with Functions
Passing Tuple to a Function
● In function call, we have to explicitly define/pass the tuple. It is not required
to specify the data type as tuple in formal argument.
Presented by : S K Mahto, PGT Computer Science
Output
3
6. Working with Functions
Passing Dictionary to a Function
● In Python, everything is an object, so the dictionary can be passed as an
argument to a function like other variables are passed.
Presented by : S K Mahto, PGT Compuer Science