Python Programming

Which statement skips the rest of the code inside a loop and starts the next iteration?

Which statement skips the rest of the code inside a loop and starts the next iteration? a) pass b) break c) continue d) return Answer: c) continue Explanation: The continue statement in Python is used within loops to skip the rest of the code inside the current iteration and immediately move to the next iteration

Which statement skips the rest of the code inside a loop and starts the next iteration? Read More »

Which function is commonly used with for loops to generate a sequence of numbers?

Which function is commonly used with for loops to generate a sequence of numbers? a) len() b) range() c) enumerate() d) zip() Answer: b) range() Explanation: The range() function in Python is commonly used with for loops to generate a sequence of numbers. This function returns an immutable sequence of numbers, starting from 0 by

Which function is commonly used with for loops to generate a sequence of numbers? Read More »

Which version of Python introduced the match-case statement?

Which version of Python introduced the match-case statement? a) Python 3.8 b) Python 3.9 c) Python 3.10 d) Python 3.7 Answer: c) Python 3.10 Explanation: The match-case statement was introduced in Python 3.10 as part of the language’s support for structural pattern matching. This feature allows developers to write more expressive and readable code by

Which version of Python introduced the match-case statement? Read More »

What is the match-case statement used for in Python?

What is the match-case statement used for in Python? a) Looping through items b) Handling multiple conditions c) Matching specific patterns d) Importing modules Answer: c) Matching specific patterns Explanation: The match-case statement in Python is used for matching specific patterns in values, providing a way to perform pattern matching. Introduced in Python 3.10, it

What is the match-case statement used for in Python? Read More »

What is the output of the following code? x = 7 if x > 10: print(“Greater than 10”) else: print(“10 or less”)

What is the output of the following code? x = 7 if x > 10: print(“Greater than 10”) else: print(“10 or less”) a) Greater than 10 b) 10 or less c) Error d) None Answer: b) 10 or less Explanation: In this code, the variable x is assigned the value 7. The if statement checks

What is the output of the following code? x = 7 if x > 10: print(“Greater than 10”) else: print(“10 or less”) Read More »

Scroll to Top