0% found this document useful (0 votes)
3 views30 pages

COMP1117B Tutorial 7: More About Functions

Uploaded by

djhgjgbjhgbh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views30 pages

COMP1117B Tutorial 7: More About Functions

Uploaded by

djhgjgbjhgbh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

COMP1117B Tutorial 7

More about Functions


About the tutorials
• Some MC questions to check your understanding
• Mutable v.s. Immutable Objects in Python
• Local v.s. Global variables in Python
• Hints to tutorial exercises
Q1
• What is the output of the following program?
A1
• What is the output of the following program?
Q2
• What is the output of the following program?
A2
• What is the output of the following program?
Q3
• What is the output of the following program?
A3
• What is the output of the following program?
Q1 v.s. Q3
Q4
• What is the output of the following program?
A4
• What is the output of the following program?
Q5
• What is the output of the following program?
A5
• What is the output of the following program?
Q6
• What is the output of the following program?
A6
• What is the output of the following program?
A6
• What is the output of the following program?
Local v.s. Global Variables
• Variable names are by default local to the function, in which they
get defined
Local v.s. Global Variables
• Variable names are by default local to the function, in which they
get defined
Local v.s. Global Variables
• Variable names are by default local to the function, in which they
get defined
Local v.s. Global Variables
• Variable names are by default local to the function, in which they
get defined
Tutorial 7 Worksheet
• Tutorial objectives
• To practice the use of functions in Python.
• To practice the use of map, filter, lambda in Python.

• Deadline: 23:59 April 9, 2024


Exercise 7.1
Exercise 7.1
• For the commands: ADD, SHOW, COUNT, and AVERAGE, please
write a corresponding function to handle that command. You will
require a while loop to process the commands repeatedly.
Exercise 7.2
Exercise 7.2
Exercise 7.3
Exercise 7.3
Exercise 7.4
Exercise 7.4
Q&A
• Please feel free to post on Moodle forum if you have questions.
• But don’t copy and paste your own code to the Moodle forum.
• You may also contact your Student TA for help.

You might also like