Quiz
Lecture 11 (funcitons)
This quiz has question types that open in the usual player.
Questions in this quiz (13)
1Functions are
- Anamed pieces of code that can be called multiple times in a program
- Bnamed pieces of code that can be called one time in a program
- Cnamed pieces of code that can be called multiple times in a while loop
2parameter
- ASetup to a function
- BOutput to a function
- CInput to a function
3We say a function [blank_start]returns[blank_end] a value if it produces [blank_start]output[blank_end]
- Areturns
- Boutput
4A function that produces output can be called a [blank_start]fruitful function[blank_end]
- Afruitful function
5[blank_start]print()[blank_end] – accepts parameters, but never returns a value
[blank_start]input()[blank_end] – may accept a parameter, but always returns a value- Aprint()
- Binput()
- Cwhile
- Dfor
- Edef
- Felse
- Gbreak
6Functions are similar to [blank_start]variables[blank_end] in that they must be defined [blank_start]before[blank_end] they are used
- Avariables
- Bbefore
7Generally it is best to place them at the [blank_start]beginning[blank_end] of the program so the interpreter reads them and has them in memory
- Abeginning
- Bend
- Cmiddle
8Functions follow the same naming rules as variables
- AMay contain upper and lower case letters, digits, and underscores
- BMust start with a letter or digit
- CConvention normally has words separated by underscores
- Dcan be used like ‘return’ or ‘return value
- Emust be defined before they are used
9Whenever the interpreter encounters a ‘return’ inside a function it does not leave the function immediately
- ATrue
- BFalse
10A ‘[blank_start]return[blank_end]’ may be followed by a value to give back to the caller
- Areturn
11There may be multiple returns in a function
- ATrue
- BFalse
12Python functions are defined using the ‘[blank_start]def[blank_end]’ [blank_start]keyword[blank_end]
- Akeyword
- Bdef
13[blank_start]def[blank_end] function_name( [blank_start]param1[blank_end], param2 ):
# stmts
[blank_start]return[blank_end]- Adef
- Bparam1
- Creturn
Information
- Description
- CS 0008
- Author
- Ержан Шынгаев
- Language
- English
- Views
- 4
- Tags
- Rating
- No ratings yet Rate this quiz