Our Services

Get 15% Discount on your First Order

[rank_math_breadcrumb]

Week 4 Quiz: 20 minutes Thank you 1) What would be output by the following function definition and function call? def decrement(x, y): if x >= 0 or y

Week 4 Quiz: 20 minutes

Thank you 

1) What would be output by the following function definition and function call?

def decrement(x, y):    if x >= 0 or y <= 0:        return x + 3    else:        return y + 1

print(decrement(4, 1))

– 2

– 7

– 4

– 5

2) Which of the following function calls would return the number of characters in the string ‘welcome’?

– length(‘welcome’)

– characters(‘welcome’)

– count(‘welcome’)

– len(‘welcome’)

3) What would be output by the following statements?

import mathx = math.sqrt(16)print(x)

– 256.0

– 8.0

– 4.0

– 32.0

4) What would be output by the following statements?

x = max(min(5, 3), 4, 2)print(x)

– 4

– 2

– 3

– 5

5) Which of the following is the syntactically correct definition of a function to print the string hello?

a- def print_hello()    print(‘hello’)

b- def hello():    print(‘hello’)

c- defun hello    print(‘hello’)

d- defun print_hello:    print(‘hello’)

6) Which of the following functions would return the smaller of the two parameters if the first parameter is evenly divisible by three and zero, otherwise?

a- def smaller(x, y):    if x % 3 != 0:        return 0    else:        return min(x, y)

b- def smaller(x, y):    if x % 3 == 0:        return 0    else:        return min(x, y)

c- def smaller(x, y):    if x % 3 == 0:        return min(x, y)    else:        return 0

d- def smaller(x, y):    if x % 3 != 0:        return min(x, y)    else:        return 0

7) What would be output by the following function definitions and function calls?

def print_numbers():    print(‘123’)

def print_letters():    print(‘abc’)

print_letters()print_numbers()

a- 123abc

b- a1b2c3

c- abc123

d- 1a2b3c

8) What would be output by the following function definitions and function call?

def choose(x, y):    if x + 5 > y:        print(x – 5)    else:        print(y – 2)

choose(3, 8)

a) 3

b) 1

c) -2

d) 6

9) Which of the following is the best reason for dividing a program into functions?

– Dividing a large program into functions allows debugging the parts one at a time and then assemble them into a working whole

– By subdividing a program into multiple functions, it makes the program more secure

– sing multiple functions reduces the possiblity of code reuse

– Increasing the number of functions in a program greatly increases the speed of the program

10) Which of the following functions would display the average of the two parameters passed to it?

a-  def average(x, y):    print(y + x / 2)

b- def average(x, y):    avg = x + y    print(avg)

c- def average(x, y):     print(x + y /2)

d- def average(x, y):    print((x + y) / 2)

Share This Post

Email
WhatsApp
Facebook
Twitter
LinkedIn
Pinterest
Reddit

Order a Similar Paper and get 15% Discount on your First Order

Related Questions

Excel 365/2021 Capstone – Level 2 Working with Sales Data These instructions are compatible with both Microsoft Windows and Mac operating systems. In this project, you will work with sales data from T

Excel 365/2021 Capstone – Level 2 Working with Sales Data These instructions are compatible with both Microsoft Windows and Mac operating systems. In this project, you will work with sales data from Top’t Corn, a popcorn company with an online store, multiple food trucks, and two retail stores. You will

Hello Students, As discussed in class, the Workspaces and Challenges are now active. Required Challenges for Full Credit To earn full credit (30% of the assignment), you must complete 6 challenges fro

Hello Students, As discussed in class, the Workspaces and Challenges are now active. Required Challenges for Full Credit To earn full credit (30% of the assignment), you must complete 8 challenges from the following list: Interns & HR on the Domain Controller Help Desk Fun: User Workstation Nightmares Dangerous Drives Preventative Protection: Thwarting the Imminent Threat Security

Hello Students, As discussed in class, the Workspaces and Challenges are now active. Please read the instrutions carefully before you accept the order. This labs should be done on xp cyber range websi

Hello Students, As discussed in class, the Workspaces and Challenges are now active. Please read the instrutions carefully before you accept the order. This labs should be done on xp cyber range website. It has to submit minimum 10 challenges with proper documentation. The questions and the website protal is attached below. A Database

Individual Assignment 3 (50 Points) Case Problem 1 (Slate & Pencil Tutoring – pages: HTML 269 – HTML 270) Data files are provided to you with this assignment in a zipped folder. Unzip the folder

Individual Assignment 3 (50 Points)Case Problem 1 (Slate & Pencil Tutoring – pages: HTML 269 – HTML 270) Data files are provided to you with this assignment in a zipped folder. Unzip the folder tosee the data files needed for this case problem.Follow the instructions (Steps 1-16) and complete the

Please read the instructions below carefully. Required Challenges for Full Credit Vulnerability Scan Complete, Begin System Hardening [NG]Volatile Vulnerabilities [NG]The Network is Down! Internal Iss

Please read the instructions below carefully. Required Challenges for Full Credit Vulnerability Scan Complete, Begin System Hardening [NG] Volatile Vulnerabilities [NG] The Network is Down! Internal Issues Edition [NG] The Network is Down! Contractor Edition [NG] (Complexity 1) The Network is Down! Contractor Edition [NG] Systems Security Analyst Crash Course

Hello Students, Please pay attention to the instructions below. Required Challenges for Full Credit To earn full credit (30% of the assignment), you must complete 6 challenges from the following list:

Hello Students, Please pay attention to the instructions below. Required Challenges for Full Credit To earn full credit (30% of the assignment), you must complete 6 challenges from the following list: Interns & HR on the Domain Controller Help Desk Fun: User Workstation Nightmares Dangerous Drives Preventative Protection: Thwarting the Imminent Threat Security

Hello This is XP Cyberrange Challenges twe need to complete the challenge by reading a conversaation between the people dicussing on cyber topics. We need to resolve the issues by working on each task

Hello This is XP Cyberrange Challenges we need to complete the challenge by reading a conversaation between the people dicussing on cyber topics. We need to resolve the issues by working on each task which are discussed in that conversation meet. Please pay attention to the instructions below. Finish the

● NCP- NICE Challenge Project ● VM- Virtual Machine ● VMRC- Virtual Machine Remote Console ❖ NICE Framework- This is shorthand for the NICE Cybersecurity Workforce Framework. ❖ Webportal- The web appl

Hello friends this is the step by step guidance to work on task these are not the questions don’t be panic ./ ● NCP- NICE Challenge Project ● VM- Virtual Machine ● VMRC- Virtual Machine Remote Console ❖ NICE Framework- This is shorthand for the NICE Cybersecurity Workforce Framework. ❖

Course : Analyzing and Visualizing Data Textbook Used: Title: Data VisualisationISBN: 9781526468925Authors: Andy KirkPublisher: SAGE Publications LimitedPublication Date: 2019-10-07Edition: 2nd ED.

Course : Analyzing and Visualizing Data Textbook Used: Title: Data VisualisationISBN: 9781526468925Authors: Andy KirkPublisher: SAGE Publications LimitedPublication Date: 2019-10-07Edition: 2nd ED. Practical Connection Assignment At UC, it is a priority that students are provided with strong educational programs and courses that allow them to be servant-leaders in their disciplines and communities, linking research with practice and

Hello Students, As discussed in class, the Workspaces and Challengesare now active. Required Challenges for Full Credit To earn full credit (30% of the assignment), you must complete 6 challenges from

Hello Students, As discussed in class, the Workspaces and Challengesare now active. Required Challenges for Full Credit To earn full credit (30% of the assignment), you must complete 6 challenges from the following list: Interns & HR on the Domain Controller Help Desk Fun: User Workstation Nightmares Dangerous Drives Preventative Protection: Thwarting the Imminent Threat Security

Part 1Title: Computer Hardware Using bullet points, briefly describe a computing device you use often, such as your desktop, laptop, tablet, or smartphone. Identify the make and model, and at least th

Part 1Title: Computer Hardware Using bullet points, briefly describe a computing device you use often, such as your desktop, laptop, tablet, or smartphone. Identify the make and model, and at least three other components of the computing device. In the speaker notes, discuss in detail what you use the device