Print
VARIABLES
LOOPS
CONDITIONS
100

How can you prevent the print() function from moving to a new line after output?

  • print("Hello", stop=" ")
  • print("Hello", next=" ")
  • print("Hello", end=" ")
  • print("Hello", skip=" ")

print("Hello", end=" ")

100

a = 5
b = "5"
c = [a, b]
c[0] += 1
print(a, c[0])

5 6

100

for i in range(1, 5):
    if i % 2 == 0:
        continue
    print(i, end=" ")

1 3

100

x = 0
if x:
    print("Yes")
else:
    print("No")

No

200

Which of the following is used to get user input in Python?

  • get()
  • print()
  • output()
  • input()
  • input()
200

x = "5"
y = 3
print(x*y)

555

200

[i**2 for i in range(1,5) if i%2==0]

[4, 16]

200

x = 3
while x < 5:
    if x % 2 == 0:
        print("Even inside loop")
        break
    else:
        print("Odd inside loop")
    x += 1

Odd inside loop

300

What is the default end character in the print() function?

  • \n (newline)
  • ; (semicolon)
  • , (comma)
  • . (dot)

\n (newline)

300

a = [1,2,3]

b = a

b.append(4) 

print(a, b)

[1,2,3,4] [1,2,3,4]

300

for i in range(2):
    for j in range(3):
        if i == j:
            break
        print(i, j)

0 1
0 2
1 0

300

nums = [0, 3, 4, None, 7]
results = []

for n in nums:
    if n is None:
        results.append("N")
    elif n and n % 2 == 0:
        results.append("E")
    elif not n:
        results.append("Z")
    else:
        results.append("d")

print(results)

['Z', 'd', 'E', 'N', 'd']

M
e
n
u