Python Variables Naming Rules Quiz

ThoughtfulDogwood avatar
ThoughtfulDogwood
·
·
Download

Start Quiz

Study Flashcards

18 Questions

What keyword is used to create a global variable inside a function in Python?

global

If you want to assign names of three different fruits to variables x, y, and z in one line, what syntax would you use?

x, y, z = 'Apple', 'Banana', 'Cherry'

In Python, what is the correct keyword to make a variable belong to the global scope?

global

Which data type would the variable x be when the following code is executed: x = str(5) print(type(x)) x = 20.5 print(type(x)) ?

float

To display the sum of 5 + 10 using variables x and y in Python, what code would you write?

sum = x + y; print(sum)

What is the correct way to assign the value of x + y to a variable called z in Python?

z = x + y

Which of the following is a valid Python variable name?

_myVar

What will happen if you create a variable inside a function with the same name as a global variable?

The local variable will overwrite the global variable within the function scope.

Which of the following is true about Python variable names?

Variable names cannot be any of the Python keywords.

What is the purpose of using the 'print()' function in Python?

To output variables.

What type of variables are created outside of a function in Python?

Global variables

Which of the following cannot be a valid Python variable name?

@name

What type of operators are used with numeric values to perform common mathematical operations?

Arithmetic operators

Which operator is used to assign values to variables in Python?

Assignment operators

What is the main purpose of comparison operators in Python?

Comparing two values

Which group of operators is used to combine conditional statements in Python?

Logical operators

What do membership operators in Python verify?

The data structure membership of a value

In Python, which operator has the highest precedence?

** (exponentiation)

Test your understanding of the rules for naming variables in Python. Learn about variable names, starting characters, and allowed characters in Python programming.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free
Use Quizgecko on...
Browser
Browser