Instructions

  • 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
  • 2. Thoroughly review each solution before proceeding to ensure full understanding.
  • 3. Final results will be available after submission to provide insights into areas for further improvement.
  • 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
  • 5. Once submitted, responses are final, so ensure you’re confident in your answers.
  • 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.

All Problems

Question

Action

What will be the result of the following code: x = 5; y = x + 10; print(y)?

View

Which of the following is a correct way to declare multiple variables in one line in Python?

View

Which of the following is true about Python variable scope?

View

What will be the output of this code: x = 10; def my_func(): x = 5; print(x); my_func(); print(x)?

View

Which keyword is used to modify a global variable inside a function?

View

What will be the output of this code: x = 7; def change(): global x; x = 10; change(); print(x)?

View

In Python, which of the following data types can be used as variable names?

View

What will happen if you assign a variable name that already exists in the global scope inside a function?

View

What is the result of this code: x, y = 5, 10; x, y = y, x; print(x, y)?

View

What will be the output of this code: def func(a, b = 5): return a + b; print(func(10))?

View

What will be the result of the following code: x = 5; y = x + 10; print(y)?

10
5
15
Error

Which of the following is a correct way to declare multiple variables in one line in Python?

a, b, c = 1, 2, 3
a = b = c = 3
Both A and B
Neither A nor B

Which of the following is true about Python variable scope?

Variables defined inside a function are local to that function
Global variables are available inside functions by default
Local variables can be accessed outside their function
There is no concept of variable scope in Python

What will be the output of this code: x = 10; def my_func(): x = 5; print(x); my_func(); print(x)?

10, 5
5, 5
5, 10
Error

Which keyword is used to modify a global variable inside a function?

global
def
var
globalize

What will be the output of this code: x = 7; def change(): global x; x = 10; change(); print(x)?

7
10
Error
None

In Python, which of the following data types can be used as variable names?

Numbers
Strings
Lists
Variables cannot be named after data types

What will happen if you assign a variable name that already exists in the global scope inside a function?

The global variable will be modified
A local variable will be created
An error will be thrown
Python will ask for clarification

What is the result of this code: x, y = 5, 10; x, y = y, x; print(x, y)?

5, 10
10, 5
5, 5
10, 10

What will be the output of this code: def func(a, b = 5): return a + b; print(func(10))?

15
10
Error
None