- 1
What is the largest number this code prints?
for i in range (10): if i>5: print (i) break else: print (7) memo states it's 6 But how if when I <5 it should've already printed 7
13 Respostas
+ 5
If that is the code and the question was, what is the LARGEST number it prints the answer would be 7.
BUT, if the question was what is the LAST number it prints, the answer is 6.
+ 4
No, break exits the loop. Plus that's in an else statement.
Edit:
Nvm I get what you mean, yea 7 would have been printed on the first few i's.
Are you sure it didn't say 'last' number?
+ 2
is this the code?
https://code.sololearn.com/cZnAASxMWIzT/?ref=app
+ 2
What is the largest number this code prints?
for i in range(10):
if i > 5:
print(i)
break
else:
print("7")
Answer :- 6
+ 1
What is the sum of the numbers printed by this code?
try:
print(1)
print(1 + "1" == 2)
print(2)
except TypeError:
print(3)
else:
print(4)
Answer :-4
+ 1
Which variable couldn't be accessed if this code was imported as a module?
x = 1
y = x
if __name__=="__main__":
z = 3
Answer :- Z
+ 1
Which of these is a web framework?
Answer:- Django
+ 1
Which of these does not convert Python scripts to Windows executables?
Answer :- PyExecutable
+ 1
Which variable couldn't be accessed if this code was imported as a module?
x = 1
y = x
if __name__=="__main__":
z = 3
Ans: z
0
You get it but here on solo learn the memo gave wrong for answering 7
0
@Rrestoring faith yeah that's the code
0
Rearrange the code to print "Welcome" if the script is imported, and "Hi" if it is not imported.
Answer :-
if __name__== "__main__":
print("Hi")
else:
print("Welcome")
0
Which file is placed in a directory to make it a package?
Answer :- __init__.py