CS-1113: Chapter 5 Quiz

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

What will be displayed after the following code is executed?def pass_it(x, y):z = x*yresult = get_result(z)return(result)def get_result(number):z = number + 2return(z)num1 = 3num2 = 4answer = pass_it(num1, num2)print(answer)

14

What will display after the following code is executed?def main():print("The answer is", magic(5))def magic(num):answer = num + 2 * 10return answermain()

25

What will be the output after the following code is executed?def pass_it(x, y):z = y**xreturn(z)num1 = 3num2 = 4answer = pass_it(num1, num2)print(answer)

64

What type of function can be used to determine whether a number is even or odd?

Boolean

What will be the output after the following code is executed?def pass_it(x, y):z = x + ", " + yreturn(z)name2 = "Tony"name1 = "Gaddis"fullname = pass_it(name1, name2)print(fullname)

Gaddis, Tony

What does the following program do?import turtledef main():turtle.hideturtle()square(100,0,50,'blue')def square(x, y, width, color):turtle.penup()turtle.goto(x, y)turtle.fillcolor(color)turtle.pendown()turtle.begin_fill()for count in range(4):turtle.forward(width)turtle.left(90)turtle.end_fill()main()

It draws a blue square at coordinates (100, 0), 50 pixels wide, in the lower-left corner.

What will be the output after the following code is executed?def pass_it(x, y):z = x , ", " , ynum1 = 4num2 = 8answer = pass_it(num1, num2)print(answer)

None

What does the following program do?import turtle def main(): turtle.hideturtle() square(100,0,50,'blue') def square(x, y, width, color): turtle.penup() turtle.goto(x, y) turtle.fillcolor(color) turtle.pendown() turtle.begin_fill() for count in range(2): turtle.forward(width) turtle.left(90) turtle.end_fill() main()

The correct answer is: It draws a blue triangle.

What does the following statement mean?num1, num2 = get_num()

The function get_num() is expected to return a value for num1 and for num2.

What is a group of statements that exists within a program for the purpose of performing a specific task?

a function

A value-returning function is

a function that will return a value back to the part of the program that called it

A/An ________ is any piece of data that is passed into a function when the function is called.

argument

A set of statements that belong together as a group and contribute to the function definition is known as a

block

When a function is called by its name during the execution of a program, then it is

executed

Which of the following functions returns the largest integer that is less than or equal to its argument?

floor

A ________ constant is a name that references a value that cannot be changed while the program runs.

global

A ________ variable is accessible to all the functions in a program file.

global

It is recommended that programmers avoid using ________ variables in a program whenever possible.

global

The first line in a function definition is known as the function

header

A/An ________ chart is also known as a structured chart.

hierarchy

Which of the following statements causes the interpreter to load the contents of the random module into memory?

import random

The Python library functions that are built into the Python ________ can be used by simply calling the required function.

interpreter

A ________ variable is created inside a function.

local

The Python standard library's ________ module contains numerous functions that can be used in mathematical calculations.

math

Which of the following will assign a random integer in the range of 1 through 50 to the variable number?

number = random.randint(1, 50)

A/An ________ is a variable that receives an argument that is passed into a function.

parameter

In a value-returning function, the value of the expression that follows the keyword ________ will be sent back to the part of the program that called the function.

return

The ________ of a local variable is the function in which that variable is created.

scope

Python comes with ________ functions that have already been prewritten for the programmer.

standard

The ________ design technique can be used to break down an algorithm into functions.

top-down


Kaugnay na mga set ng pag-aaral

Quiz 2 in Capsim Capstone MAN4900

View Set

Ch. 70 Test Q's: degenerative disc dz and herniation of cervical and lumbar spine

View Set

Chapter VII Insurance Regulations (22 Exam Questions)

View Set

WileyPLUS. Chapter 22. The Lymphatic System and Immunity.

View Set