1/49
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
The editor (left) and the console (right).
What two main areas are found in the Edube Sandbox?
A function is a reusable piece of code that can take input (arguments) and produce an output (return value) and/or cause an effect.
What is a function in Python?
Mathematical functions generally focus on producing a value, while Python functions can produce a value and/or an effect.
What is one important difference between mathematical functions and Python functions?
1. Built-in functions
2. Functions from other modules
3. User-defined functions
What are the three categories of functions?
Functions that are already available in Python and can be used directly by writing their function name.
What are built-in functions?
Functions that are not directly available and require their module to be imported first.
What are functions from other modules?
sin(), cos(), and log().
Give examples of functions from the math module.
Import the math module.
What must you do before using functions from the math module?
Functions created by the programmer.
What are user-defined functions?
It displays values or text in the console.
What does print() do?
No. print() displays the value; it does not return that displayed value as its return value.
Does print() return the value that it displays?
function_name(argument)
What is the general format of calling a function?
Spelling and case-sensitivity.
What should you be mindful of when writing function names?
They are used to define strings.
What are quotation marks used for in Python?
Everything inside the quotation marks is treated as string data.
What is treated as data when placed inside quotation marks?
A value passed to a function inside its parentheses.
What is an argument?
A Python function can have any number of arguments, depending on the function.
How many arguments can a Python function have?
It separates the arguments, and print() places a space between them by default.
What does a comma do when separating arguments in print()?
It produces an empty line/newline.
What happens when print() is called with zero arguments?
No. It produces an empty line/newline.
Does print() with zero arguments produce None?
It is treated as part of the string and is printed.
What happens to a comma placed inside quotation marks?
It separates arguments, and print() inserts a space between them by default.
What happens to a comma placed outside quotation marks in print()?
The newline character.
What is \n?
It causes the console to start a new output line.
What does \n do?
Yes. Using \n can produce two output lines from one line of code.
Can one line of Python code produce output on two lines?
A space.
What does print() place between multiple arguments by default?
Yes. Python allows both single (') and double (") quotation marks.
Can you use either single or double quotation marks for a string?
Use single quotation marks around the string, e.g. 'He said "Hello"'.
How can you print a double quotation mark inside a string surrounded by single quotation marks?
Use an escape character (\) before it.
How can you print a quotation mark that would otherwise terminate the string?
The backslash (\) used to give certain characters a special meaning.
What is an escape character?
\'
How do you escape a single quotation mark?
\"
How do you escape a double quotation mark?
Use two backslashes: \\
How do you print a backslash itself?
Six backslashes, because each displayed backslash requires two backslashes in the string.
If you want three backslashes to appear in the output, how many backslashes are needed in the string?
Immediately before the character that needs to be escaped, inside the string
Where should an escape character be placed?
A sequence of characters enclosed within quotation marks (delimiters), either single or double.
What is a string?
Positional arguments and keyword arguments.
What are the two main types of arguments?
Arguments whose meaning is determined by their position.
What are positional arguments?
Arguments whose meaning is determined by the keyword used to identify them, rather than their position.
What are keyword arguments?
After all positional arguments.
Where are keyword arguments generally placed relative to positional arguments?
It determines what is printed at the end of the output.
What does the end keyword argument control in print()?
A newline (\n).
What does print() use for end by default?
It replaces the default newline with a space, allowing consecutive print() calls to appear on the same line.
What happens when you use end=" " in print()?
It determines what separates multiple arguments within the same print() call.
What does sep control in print()?
Between all the arguments of a single print() call.
Where does sep place its separator?
"Hello" and "World" are two positional arguments. print() automatically places the default sep, which is a space, between them.
Explain why print("Hello", "World") produces Hello World.
sep is a keyword argument that controls the separator between arguments. A comma inside quotation marks is simply part of the string data.
Explain the difference between sep and a comma inside quotation marks.
To change the default separator to something else, such as -, ,, or /.
If print() already puts a space between arguments, why would we use sep?
To change what appears at the end of the output, such as replacing the newline with a space.
If print() normally starts a new line after printing, why would we use end?
sep controls what goes between arguments in one print() call. end controls what goes at the end of the entire print() output.
What is the difference between sep and end?