Question 2    Write the result of the expression (as evaluated by Python): int(5.7) // 2

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Answer the following questions and fill and the blanks 

 

Question 1

 

Match these function names with the most accurate statement about them.

Function names: 

a

 

2nd_name 

 

getName 

 

input 

 

Calculate_total 

 

user_name 

 

statements: 

 

This is a good function name.

 

This name is the same as a Python built-in name (and so should not be used).

 

This name sounds like a noun/variable.

 

This name does not use the standard naming convention.

 

This name does not give enough information about the meaning of the function.

 

This name is invalid (breaks Python naming rule) 

 

Question 2 

 

Write the result of the expression (as evaluated by Python):

int(5.7) // 2

 

Blank 1 - add your answer 

 

Question 3 

 

Which one of the following is a correct way to get the user to enter their salary and store it in a Python variable?

 


a) variable = input(float("salary"))


b) input = float("salary")



c) salary = float(input())


d) float(input("salary))

 

Question 4

 

What is wrong with the following code?

 

def main():

      age = get_age()

      print(f"At {age}, you are half-way to {age * 2}")

 

 

def get_age():

      x = int(input("Age: "))

      return x

 

 

main()

 


a) Something is wrong with the f-string in the print function

b) The variable in get_age must be called age, not x

c) The get_age function breaches the Single Responsibility Principle (SRP)

D) None of the above - there are no problems with this code

 

 

Question 5

 

Consider a program that calculates total pay. Which one of the following decision patterns would be the most appropriate choice for the situation where a bonus is applied when the pay is over a certain threshold?

 

a) if, no else

B) if-else

C) if-elif-else

 D) if-elif no else

E) if, if, if...

 

Question 6

 

What is the result of the following expression?

 

float(int(5.7)) ** 2

 


A) 32.49

B) 11.4

C) 10.0

D) 25.0

E) None of the above

 

Question 7 

 

Which one of the following statements about using global variables is False?

 


A) Global variables are defined inside functions and their scope is only within their own functions

B) Global variables can lead to problems and make debugging more difficult

C) Global variables make programs with functions harder to read and understand


D) Global constants are acceptable

 

 

Question 8 

 

Which one of the following is the correct keyword argument to use in Python's print function when you want to change the default value that is printed between (multiple) arguments provided?

 


A) end

B) sep

C) line

D)printline

 

Question 9

 

What is the output of the following code?

 

def main():

      x = do_something(3)

      y = do_something(x)

      print(x + y)

 

def do_something(a):

      x = a - 1

      b = a * 2

      return b

 

main()

 

 

Blank 1 - add your answer 

 

 

Question 10 

 

Consider the following code:

 

import random

 

x = random.randint(1, 10)

y = random.randint(5, 11 * x)

print(y)

 

What is the lowest value that could be printed?

Blank 1 - add your answer 

What is the highest value that could be printed?

Blank 2 - add your answer 

 

 

Question 11

 

Which one of the following is the best name for a function that converts colour values from RGB format to HSV format?

 

A) rgb_hsv

B) RGB_to_HSV

C) convert_colour_formats

D) convert_rgb_to_hsv

 

 

Question 12

 

Consider the following code:

 

import random

print(random.randint(random.randint(1, 10), random.randint(10, 20)))

 

What are the lowest and highest values that could be printed?


A) 1 and 10

B) 1 and 20

C) 10 and 20

D) None of the above









 

 























Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY