Test your understanding of Python's conditional statements and looping constructs with these challenging, concept-driven questions.
What is the output of the following code snippet?nx = 1ny = 2nif x u003E 0:n if y u003E 2:n print('A')n else:n print('B')nelse:n print('C')
Given the code: count = 0nwhile count u003C 5:n count += 2n if count == 4:n breaknelse:n print('End')nWhat is printed after execution?
What will the following code output?nfor a, b in [(1,2), (3,4), (5,6)]:n if b % 2 == 0:n print(a)nelse:n print(0)
How many times does 'Hello' print?nfor i in range(5):n if i == 2:n continuen print('Hello')
In which scenario would using a pass statement be most appropriate?
What is the output?nfor i in range(3):n if i == 1:n breaknelse:n print('Done')
Given the code:nx = 10nif x u003E 5:n print('High')nelif x u003E 3:n print('Medium')nelse:n print('Low')nWhat is printed?
Which value does this code assign to 'result'?nresult = False or True and False
Given:nnums = [1, 2, 3]nfor num in nums:n num += 10nprint(nums)nWhat does nums look like after executing this code?
What does this code print?ni = 0nwhile i u003C 3:n i += 1nelse:n print(i)
Consider:nx = 5nif x == 3:n y = 1nelif x == 5:n y = 2nelif x == 5:n y = 3nWhat is the value of y after execution?
Which of the following will cause the if branch to execute?nx = ''nif x:n print('Yes')nelse:n print('No')
How many times does the body of this loop run?nfor i in range(2, 10, 3): print(i)
What is the output?nfor i in range(5):n if i % 2 == 0:n continuen if i == 3:n breakn print(i)
What will be the result of this statement?nresult = not True or False and True