• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 5 pages
Exam (elaborations)

PE1 Summary Test-Questions and Answers 100%Correct

Document preview thumbnail
Preview 2 out of 5 pages

PE1 Summary Test-Questions and Answers 100%Correct How many stars(*) will the following snippet send to the console? i = 0 while i i+2 : i += 1 print("*") else: print("*") - ANSWER-the snippet will enter an infinite loop, printing one star per line What is the output for the following piece of code? x = 1 y = 2 x, y, z = x, x, y z, y, z, = x, y ,z print(x, y, z) - ANSWER-1 1 2 How many hashes(#) will the following snippet send to the console? lst = [[x for x in range (3)] for y range in (3)] for r in range (3): for c in range (3): if lst [r][c] % 2 != 0: print("#") - ANSWER-three What is the output of the following piece of code if the user enters two lines containing 3 and 2 respectively? x = int(input()) y = int(input()) x = x % y x = x % y y = y % x print(y) - ANSWER-0 The meaning of a positional argument is determined by: - ANSWER-its position within the argument list

Content preview

PE1 Summary Test-Questions and Answers 100%Correct
How many stars(*) will the following snippet send to the console?
i = 0
while i < i+2 : i += 1 print("*")
else: print("*") - ANSWER-the snippet will enter an infinite loop, printing one star per line
What is the output for the following piece of code?
x = 1
y = 2
x, y, z = x, x, y
z, y, z, = x, y ,z
print(x, y, z) - ANSWER-1 1 2
How many hashes(#) will the following snippet send to the console?
lst = [[x for x in range (3)] for y range in (3)]
for r in range (3): for c in range (3): if lst [r][c] % 2 != 0: print("#") - ANSWER-three
What is the output of the following piece of code if the user enters two lines containing 3
and 2 respectively?
x = int(input())
y = int(input())
x = x % y
x = x % y
y = y % x
print(y) - ANSWER-0
The meaning of a positional argument is determined by: - ANSWER-its position within the argument list What is the output of the following piece of code?
x = 1 // 5 + print(x) - ANSWER-0.2
What is the output of the following snippet?
def fun(inp=2, out=3) : return inp * out
print(fun(out=2) - ANSWER-4
The following snippet:
def func(a, b): return b ** a
print(func(b=2, 2)) - ANSWER-is erroneous
What is the output of the following piece of code if the user enters two lines containing 3
and 6 respectively?
y = input()
x = input()
print(x + y) - ANSWER-63
Take a look at the snippet, and choose the true statement: nums = [1, 2, 3] vals = nums del vals[ : ] - ANSWER-nums and vals have the same length
Which of the following lines correctly invoke the function below? (select two answers)
def fun(a, b, c=0): # Body of the function. - ANSWER-fun (0, 1, 2)
fun (b=0, a=0)
Assuming that my_tuple is a correctly created tuple, the fact that tuples are immutable means that the following instruction:
my_tuple [ 1 ] = my_tuple [ 1 ] +my_tuple [ 0 ] - ANSWER-is illegal
What is the output of the following snippet:
dct = {'one': 'two' , 'three': 'one', 'two': 'three'}

Document information

Uploaded on
March 28, 2024
Number of pages
5
Written in
2023/2024
Type
Exam (elaborations)
Contains
Questions & answers
$8.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
0
Followers
0
Items
386
Last sold
-




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions