0% found this document useful (0 votes)
1 views2 pages

Python Variables DataTypes Full Notes

The document provides a comprehensive overview of Python variables and data types, including definitions, rules for naming variables, and the concept of dynamic typing. It explains the differences between local and global variables, variable scope, and various data types such as numeric, boolean, string, list, tuple, dictionary, and set. Additionally, it covers key concepts like mutability, memory management, and comparisons between variables and objects.

Uploaded by

shahnwazhusan521
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views2 pages

Python Variables DataTypes Full Notes

The document provides a comprehensive overview of Python variables and data types, including definitions, rules for naming variables, and the concept of dynamic typing. It explains the differences between local and global variables, variable scope, and various data types such as numeric, boolean, string, list, tuple, dictionary, and set. Additionally, it covers key concepts like mutability, memory management, and comparisons between variables and objects.

Uploaded by

shahnwazhusan521
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python Variables and Data Types - Complete

Question Answers
Q. What is a Variable in Python?
A variable is a named memory location used to store data. Example: x=10.

Q. Rules for Naming Variables


Must start with letter or _, cannot start with digit, keywords not allowed, case-sensitive.

Q. What is Dynamic Typing?


Python automatically determines the data type at runtime.

Q. Multiple Variable Assignment


a,b,c=10,20,30 and x=y=z=100.

Q. Local vs Global Variable


Local variables exist inside functions. Global variables exist outside functions.

Q. What is Variable Scope?


Scope defines where a variable can be accessed.

Q. What is a Data Type?


A data type defines the kind of value a variable stores.

Q. Numeric Data Types


int, float, complex.

Q. Boolean Data Type


Stores True or False.

Q. String Data Type


Sequence of characters enclosed in quotes.

Q. List Data Type


Ordered, mutable collection.

Q. Tuple Data Type


Ordered, immutable collection.

Q. Dictionary Data Type


Stores key-value pairs.

Q. Set Data Type


Unordered collection of unique values.

Q. List vs Tuple
List is mutable; Tuple is immutable.

Q. Mutable vs Immutable
Mutable: list, dict, set. Immutable: int, float, str, tuple.

Q. Deep Q: Why Dynamic Typing?


Types are decided at runtime.

Q. Deep Q: Variable vs Object


Variable is a reference; object is actual data.

Q. Deep Q: Why Strings Immutable?


Improves security, optimization, and performance.

Q. Deep Q: Why Tuples Faster?


Because they are immutable and use less memory.

Q. Deep Q: == vs is
== compares values; is compares object identity.

Q. Deep Q: Memory Management


Python uses references and garbage collection.

You might also like