User Functions Quizizz Review

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

age = 40 def age_reduce (age): age = 30 age_reduce(age) print(age) The output of the code above is answer choices a. 40 b. 30 c. syntax error

a. 40

Which character must be at the end of the line for if? answer choices a. : b. ; c. . d. {

a. :

What is the difference between a local and a global variable? answer choices a. A global variable is declared so it can be used in any part of the program and a local variable is only available in a specific function b. A local variable is declared so it can be used in any part of the program and a global variable is only available in a specific function c. Both local and global variables can be used in any part of a program

a. A global variable is declared so it can be used in any part of the program and a local variable is only available in a specific function

What is an argument? answer choices a. An argument is a value that is passed into a function. b. An argument is a small section of program c. An argument is the name of the information that is used in a function.

a. An argument is a value that is passed into a function.

What does the = = symbol mean in Python? answer choices a. Equal to or shows equality b. Not Equal c. Code that will be skipped d. End of clause

a. Equal to or shows equality

A variable declared in the main program answer choices a. Global b. Local

a. Global

'If' is a decision making statement answer choices a. TRUE b. FALSE

a. TRUE

Parameter is ...... answer choices a. The variable that information is passed to in a function b. The data that is passed to a function c. Data is sent back to be used by the main program after a function has been run.

a. The variable that information is passed to in a function

What is the purpose of a function? answer choices a. They are reusable pieces of programs. b. They are required by the Python c. They allow us to compile our program d. They make the program larger

a. They are reusable pieces of programs.

Local names cannot be accessed globally. answer choices a. True b. False

a. True

Local variables are deleted when the function is completed answer choices a. True b. False

a. True

Variables can be changed True or False? answer choices a. True b. False

a. True

a=10 def myfunction(): a = 20 return print('a=',a) a. a=10 b. a=20 c. syntax error d. value error

a. a=10

def say (message, times = 1): print(message * times) say('Hello') say('World', 5) times is ________________ type of argument. answer choices a. default arguments b. keyword arguments c. positional arguments d. arbitrary positional arguments e. arbitrary keyword arguments

a. default arguments

Which one of the following is the correct way of calling a function? answer choices a. function_name() b. call function_name() c. ret function_name() d. function function_name()

a. function_name()

spam = 13 if spam > 7: print("more than 7") if spam > 23: print("more than 23") What is the output? answer choices a. more than 7 b. more than 23 c. spam d. 7

a. more than 7

The correct way to write a variable in Python? answer choices a. myVariable = 10 b. my Variable = 10 c. myVariable is 10 d. myVariable: 10

a. myVariable = 10

Function defined to achieve some task as per the programmer's requirement is called a ______________ answer choices a. user defined function b. library function c. built in functions d. All of the above.

a. user defined function

The suite of a function always comes after a _______. answer choices a. ; b. : c. ' d. #

b. :

What are the two main types of functions? answer choices a. Custom function b. Built-in function & User defined function c. User function d. System function

b. Built-in function & User defined function

A variable declared within a function answer choices a. Global b. Local

b. Local

What is a parameter? answer choices a. Parameters are the values that are passed into a function. b. Parameters are the names of the information that is used in a function. c. A parameter is a small section of program

b. Parameters are the names of the information that is used in a function.

chem_grade = 80 math_grade = 94 engl_grade = 76 if chem_grade >= 80: print("Success") else: print("Failure") What will be printed to the screen? answer choices a. Nothing b. Success c. Failure d. Success Failure

b. Success

Argument is ...... answer choices a. The variable that information is passed to in a function b. The data that is passed to a function c. Data is sent back to be used by the main program after a function has been run.

b. The data that is passed to a function

Which of the following is an advantage of using local variables? answer choices a. They allow the variable to be used throughout the whole program b. They allow variable identifiers to be reused each time c. They are easier to program than global variables d. A wider range of data types can be used

b. They allow variable identifiers to be reused each time

Do you call or define a function first? answer choices a. call b. define

b. define

The second part of if, that is executed when the condition is false answer choices a. if b. else c. for d. input

b. else

What is a variable defined outside a function referred to as? answer choices a. local variable b. global variable c. static Variable d. automatic variable

b. global variable

What type of variable is 'avg' in the following code? answer choices a. global variable b. local variable c. none of the mentioned

b. local variable

_________ is the built-in function to know the type of a variable or function. answer choices a. id() b. type() c. data_type() d. none of the above

b. type()

How many individual variables are in this code? name = "Goofy" age = "21" holiday = "Disney" print("Hi", name, "I see you are", age, "would you like to go to" holiday, "?") answer choices a. 1 b. 2 c. 3 d. 4

c. 3

What is a variable defined inside a function referred to as? answer choices a. A global variable b. A volatile variable c. A local variable d. An automatic variable

c. A local variable

A .................... is a named block of code that is used to perform a task and will return one or more values (called the 'return value'). answer choices a. Procedure b. Argument c. Function d. Call

c. Function

Which of the statements below is true about indentation in Python? answer choices a. Indentation only matters in for loops. b. Indentation never matters in Python. c. Indentation always matters in Python. d. Indentation only matters in functions.

c. Indentation always matters in Python.

Variables allow us to: answer choices a. Name different parts of our programs b. Use English words to communicate with Tracy c. Store information to use in our programs d. Change the words Tracy recognizes

c. Store information to use in our programs

Built-in names can be accessed _____ . answer choices a. locally b. globally c. both globally and locally

c. both globally and locally

Which keyword is used for function?* answer choices a. define b. fun c. def d. function

c. def

Leo wants to create a function that will roll a dice. Which is the correct function definition header? answer choices a. def dice roll (): b. def diceroll () c. def diceroll (): d. def diceroll []:

c. def diceroll ():

Leo wants to create a function that will roll a dice. Which syntax is correct? answer choices a. def dice roll (): b. def diceroll () c. def diceroll (): d. def diceroll []:

c. def diceroll ():

Which of the following function headers is correct?* answer choices a. def fun(a = 2, b = 3, c) b. def fun(a = 2, b, c = 3) c. def fun(a, b = 2, c = 3) d. def fun(a, b, c = 3, d)

c. def fun(a, b = 2, c = 3)

How is a function declared in Python?* answer choices a. def function function_name(): b. declare function function_name(): c. def function_name(): d. declare function_name():

c. def function_name():

Which symbol means "not equal to"? answer choices a. == b. <= c. >= d. !=

d. !=

Which of the following are advantages of using function in program? answer choices a. It increases readability of program. b. It increases reusability. c. It makes debugging easier. d. All of the above

d. All of the above

How many parameters can we use in each function? answer choices a. 1 b. 2 c. 3 d. As many as we need

d. As many as we need

def myname (first, surname): name = first+ " "+ surname return name first = input("Enter your name") surname = input("Enter your surname") name = myname(first, surname) print(name) What will be the output of this program if the user enters "Han" and then "Solo"? answer choices a. An error b. Nothing c. first surname d. Han Solo

d. Han Solo

Name the variable in this code: name = "Daffy" print("Hi", name) answer choices a. Daffy b. Print c. Hi d. Name

d. Name

What term is used to describe data passed into/out of a program? answer choices a. Variable b. Loop c. Constant d. Parameter

d. Parameter

Which statement will check to see if a is equal to b? answer choices a. if a == b b. if a = b: c. if a != b: d. if a == b:

d. if a == b:


Set pelajaran terkait

ARCH 249 Exam 3 (Architecture of Ancient India and SE Asia)

View Set

Overview of the digestive system

View Set

Cell Structure and Function - Neural Tissue

View Set

+INFECTIOUS DISEASE UWORLD ROUND 1+

View Set

Chapter 24: Vital Signs : Questions from "The Point"

View Set

lección 4 el masculino y femenino

View Set