Menu

[Solved]-Questin 1 Co 2 Following Valid Name Python Lastname Lastname Last Name Lname Question 2 Co Q37186919

Questin 1

(CO 2) Which of the following is not a validname in python?

last_name

lastName

last name

lname

Question 2

(CO 3) How many times will “Hello World” be displayed after thefollowing code executes?

num=2
while num<12:
    print(“Hello world”)
    num+=2

2

12

5

4

Question 3

(CO 1) The following code contains an error, what type of erroris it and what line number is it?

1 count=1
2 while count<4
3    print(“count = “, count)
4    count+=1
5 print(“The loop has ended”)

line 1, syntax error

line 5, runtime error

line 2, syntax error

line 4, runtime error

Question 4

(CO 2) After the following code executes, what will bedisplayed?

guess=10
if guess<20:
    print(“Too low”)
elif guess>20:
    print(“Too high”)

Too low

Too high

The numbers are equal

nothing will display

Question 5

(CO 1) Given: x=23, y=15
What is the value of new_num after the following statementexecutes?
new_num = x%y

1.5333333

1

8

0.533333

Question 6

(CO 1) Which of the following code samples will get a floatingpoint number from the user?

new_number=float input “Please enter a number: “

new_number=input(float(“Please enter a number: “))

new_number=float(input(“Please enter a number: “))

new_number= input(“Please enter a number: “)

Question 7

(CO 3) What will be displayed after the following loop isrun?

sum = 0
for i in range(0, 25, 5):
    sum+=i
print(sum)

30

50

0, 5, 10, 15, 20

0, 5, 10, 15, 20, 25

Question 8

(CO 6) To call a function, you code the function name and

nothing

a set of parentheses that contains zero or more arguments

a set of parentheses that contains one or more arguments

a list of local variables

Question 9

(CO 6) The best way to call the main() function of a program isto code

main()

a while statement that calls the main() function in eachloop

an if statement that calls the main() function in eachmethod

an if statement that calls the main() function only if thecurrent module is the main module

Question 10

(CO 6) A variable that can only be used within the function thatdefines it is known as a ______

local variable

global variable

shadow variable

unknown variable

Question 11

(CO 6) Which of the following statements imports a module?

export temperature

import temperature

from temperature import

global temperature import

Question 12

(CO 5) To insert the item “chewie” after “solo” in the followinglist, which of the following methods would you use?

falcon = [“han”, “leia”, “solo”, “yoda”, “luke”]

falcon.pop(3,”chewie”)

falcon.remove(3,”chewie”)

falcon.insert(3,”chewie”)

falcon.insert(“chewie”, 3)

Question 13

(CO 5) The ______________ method adds an item to the end of alist.

index()

insert()

pop()

append()

Question 14

(CO 5) Given the following list, what is the value ofnames[5]?
names = [“Harry”, “Ron”, “Ginny”, “Draco”, “Rowena” ]

“Harry”

“Rowena”

“Ron”

None – index error

Question 15

(CO 5) What is the value of the total variable after thefollowing code executes?

prices=[66, 22, 47, 30]
total = 0
i=1
while i<len(prices):
    total+=prices[i]
    i+=1
print(total)

35

66

0

99

Expert Answer


Answer to Questin 1 (CO 2) Which of the following is not a valid name in python? last_name lastName last name lname Question 2 (CO… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *