PYnative

Python Programming

  • Learn Python
    • Python Tutorials
    • Python Basics
    • Python Interview Q&As
  • Exercises
  • Quizzes
  • Code Editor
Home » Python » Quizzes » Python Variables and Data Types Quiz

Python Variables and Data Types Quiz

Updated on: August 26, 2025 | 62 Comments

This Python variables and data Types quiz provides Multiple Choice Questions (MCQs) to test and enhance your foundational knowledge of Python programming.

This quiz cover various aspects of Python variables and data types, including variable assignment, naming conventions, type casting, and the characteristics of common data types like integers, floats, strings, booleans, lists, tuples, sets, and dictionaries.

Also See:

  • Python Basic Exercise for Beginners
  • 15 Python Quizzes: each focusing on a specific topic
  • The quiz contains 25 questions. There is no time limit.
  • You will get 1 point for each correct answer. Solve 15 correctly to pass the test.

Read Variables in Python and Python Data Types to solve this quiz.

1. What will be the output of the following Python code?

data = (10, 20, 30)
a, b, c = data
print(b)
 
 
 
 

2. What is the output of print(type({}) is set)

 
 

3. What is the data type of print(type(0xFF))

 
 
 
 

4. In Python 3, what is the output of type(range(5)). (What data type it will return).

Hint: range() in Python

 
 
 
 

5. Select the right way to create a string literal Ault'Kelly

 
 

6. What will be the output of the following code?

x = 50
def func1():
    x = 75
    return x
num = func1()
print(num)
 
 
 
 

7. What will be the output of the following Python code?

x = 10
y = x
x += 5
print(y)
 
 
 
 

8. What will be the output of the following Python code?

a = [1, 2, 3]
b = a
b.append(4)
print(a)
print(b)
 
 
 
 

9. What will be the output of the following Python code?

my_tuple = (1, 2, 3)
my_tuple[0] = 5
print(len(my_tuple))
 
 
 
 

10. What will be the output of the following Python code?

my_dict = {"a": 1, "b": 2}
my_dict["c"] = 3
my_dict["a"] = 10
print(my_dict["a"])
 
 
 
 

11. What will be the output of the following code?

x = 75
def myfunc():
    x = x + 1
    print(x)

myfunc()
print(x)

Refer Variables in Python.

 
 
 
 

12. Which function is used to convert a string to an integer?

 
 
 
 

13. What is the data type of the following

aTuple = (1, 'Jhon', 1+3j)
print(type(aTuple[2:3]))

Refer:

  • Python Data types
  • tuples in Python
 
 
 

14. Which built-in function is used to check the data type of a variable?

 
 
 
 

15. What will be the output of the following Python code?

my_string = "Python"
print(my_string[2:5])
 
 

16. What is the data type of print(type(10))

 
 
 

17. What will be the output of the following code?

x = 50
def fun1():
    x = 25
    print(x)
    
fun1()
print(x)
 
 
 

18. Which of the following evaluates to False in a boolean context?

 
 
 
 

19. What will be the output of the following Python code?

my_set = {1, 2, 3, 2, 1}
print(len(my_set))
 
 
 

20. What will be the output of the following Python code?

text = "hello world"
parts = text.split(" ")
print(parts[1])
 
 
 
 

21. If my_string = "hello", what happens when you try to execute my_string[0] = 'H'?

 
 
 
 

22. Which of the following Python data types is mutable?

 
 
 
 

23. Select all valid String creation in Python

 
 
 

24. Which of the following data types can legally be used as a key in a Python dictionary?

 
 
 
 

25. Which of the following characteristics best describes a Python set?

 
 
 
 

Loading ... Loading …

Loading

Filed Under: Python, Python Basics, Python Quizzes

Did you find this page helpful? Let others know about it. Sharing helps me continue to create free Python resources.

TweetF  sharein  shareP  Pin

About Vishal

Image

I’m Vishal Hule, the Founder of PYnative.com. As a Python developer, I enjoy assisting students, developers, and learners. Follow me on Twitter.

Related Tutorial Topics:

Python Python Basics Python Quizzes

All Coding Exercises:

C Exercises
C++ Exercises
Python Exercises

Python Exercises and Quizzes

Free coding exercises and quizzes cover Python basics, data structure, data analytics, and more.

  • 15+ Topic-specific Exercises and Quizzes
  • Each Exercise contains 25+ questions
  • Each Quiz contains 25 MCQ
Exercises
Quizzes

Loading comments... Please wait.

In: Python Python Basics Python Quizzes
TweetF  sharein  shareP  Pin

  Python Quizzes

  • 15 Python Quizzes
  • Python Online MCQ Test
  • Basic Quiz For Beginners
  • Variables and Data Types Quiz
  • Functions Quiz
  • if else and loops Quiz
  • Numbers Quiz
  • String Quiz
  • List Quiz
  • Set Quiz
  • Dictionary Quiz
  • Tuple Quiz
  • Operators and Expression Quiz
  • Input and Output Quiz
  • Multithreading and Multiprocessing Quiz
  • File Handling Quiz
  • Random Data Generation Quiz

 Explore Python

  • Python Tutorials
  • Python Exercises
  • Python Quizzes
  • Python Interview Q&A
  • Python Programs

All Python Topics

Python Basics Python Exercises Python Quizzes Python Interview Python File Handling Python OOP Python Date and Time Python Random Python Regex Python Pandas Python Databases Python MySQL Python PostgreSQL Python SQLite Python JSON

About PYnative

PYnative.com is for Python lovers. Here, You can get Tutorials, Exercises, and Quizzes to practice and improve your Python skills.

Follow Us

To get New Python Tutorials, Exercises, and Quizzes

  • Twitter
  • Facebook
  • Sitemap

Explore Python

  • Learn Python
  • Python Basics
  • Python Databases
  • Python Exercises
  • Python Quizzes
  • Online Python Code Editor
  • Python Tricks

Coding Exercises

  • C Exercises
  • C++ Exercises
  • Python Exercises

Legal Stuff

  • About Us
  • Contact Us

We use cookies to improve your experience. While using PYnative, you agree to have read and accepted our:

  • Terms Of Use
  • Privacy Policy
  • Cookie Policy

Copyright © 2018–2025 pynative.com

Advertisement