How can you prevent the print() function from moving to a new line after output?
print("Hello", end=" ")
a = 5
b = "5"
c = [a, b]
c[0] += 1
print(a, c[0])
5 6
for i in range(1, 5):
if i % 2 == 0:
continue
print(i, end=" ")
1 3
x = 0
if x:
print("Yes")
else:
print("No")
No
Which of the following is used to get user input in Python?
x = "5"
y = 3
print(x*y)
555
[i**2 for i in range(1,5) if i%2==0]
[4, 16]
x = 3
while x < 5:
if x % 2 == 0:
print("Even inside loop")
break
else:
print("Odd inside loop")
x += 1
Odd inside loop
What is the default end character in the print() function?
\n (newline)
a = [1,2,3]
b = a
b.append(4)
print(a, b)
[1,2,3,4] [1,2,3,4]
for i in range(2):
for j in range(3):
if i == j:
break
print(i, j)
0 1
0 2
1 0
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']