Chapter 3 Functions

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

The None Value

- None, which represents the absence of a value. The Nonevalue is the only value of the NoneType data type. - This value-without-a-value can be helpful when you need to store something that won't be confused for a real value in a variable. One place where None is used is as the return value of print(). The print() function displays text on the screen, but it doesn't need to return anything in the same way len() or input() does. But since all function calls need to evaluate to a return value, print() returns None

Return

- Video Link: https://www.youtube.com/watch?v=nuNXiEDnM44 -

Exception Handling

Errors can be handled with try and except statements. The code that could potentially have an error is put in a try clause.

Keyword Arguments and the Print Function

Keyword arguments are identified by the keyword put before them in the function call. Keyword arguments are often used for optional parameters.

DEF Function Video

Link: https://www.youtube.com/watch?v=NSbOtYzIQI0

Local and Global Scope

Parameters and variables that are assigned in a called function are said to exist in that function's local scope. Variables that are assigned outside all functions are said to exist in the global scope. A variable that exists in a local scope is called a local variable, while a variable that exists in the global scope is called a global variable. A variable must be one or the other; it cannot be both local and global. - Link: https://www.youtube.com/watch?v=bEhRPZzIHFc

The Call Stack

The call stack is a technical detail that you don't strictly need to know about to write programs. It's enough to understand that function calls return to the line number they were called from.

Optional Parameters of print( )

The print() function has the optional parameters end and sep to specify what should be printed at the end of its arguments and between its arguments (separating them), respectively.

Global Variables Link:

https://www.youtube.com/watch?v=r9LtArXOYjk


Kaugnay na mga set ng pag-aaral

Revel Ch.15 Sph: Tools for Persuading

View Set

Servers Cha 2- Configuring Windows Server 2019

View Set

Chapter 2: The Rise of Astronomy

View Set

microeconomics comprehensive review

View Set

Fundamentals Exam 2 Blueprint Study Guide

View Set

OSHA - PERSONAL PROTECTIVE EQUIPMENT

View Set