0% found this document useful (0 votes)
3 views

Lecture 1_3 Python Basics

The document provides an introduction to Python basics, covering topics such as the Python interpreter, user input, and variables. It explains the nature of variables, including naming conventions, case sensitivity, and reserved keywords, as well as the id() function. Additionally, it outlines various data types in Python and distinguishes between mutable and immutable types.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Lecture 1_3 Python Basics

The document provides an introduction to Python basics, covering topics such as the Python interpreter, user input, and variables. It explains the nature of variables, including naming conventions, case sensitivity, and reserved keywords, as well as the id() function. Additionally, it outlines various data types in Python and distinguishes between mutable and immutable types.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Python Basics

Eng. Emanuel Rashayi


Faculty of Engineering, Dept of Electrical & Electronics Engineering , University of Zimbabwe
[email protected]
Python Interpreter

You can RUN Python in two ways:


✓ Using the Python Interpreter.
✓ Using Scripts.
Python Scripts
User Input
Variables

❑ A variable is nothing more than just a reserved location in your


computer’s memory, used to store information; values, to be more
precise. This means that when you create a variable you reserve
some space in memory.
❑ You can store different types of data using a variable
❑ Now, unlike other programming languages, in Python you don't
have to explicitly declare a variable;
❑ A variable name should always start with a letter, usually
lowercase and never start with a number or any other symbol
Variables

❑ And remember! Python names are case-sensitive, so, a variable


named my_var is a different variable than a variable named
my_Var
❑ you should keep a reasonable name length, so that it will be
easier for you to remember it and reference it inside your code.
❑ Python reserved names are called keywords. You cannot use them
as variables
Variables (Examples)
Variables – Reserved names (Keywords)
About the id() Function….

❑ It shows the address or identity of the variable in the computer's


memory.
Quitting Python
Data Types
• As an overview, let's enumerate the most famous and useful Python 3
data types;
1. strings,
2. numbers,
3. booleans,
4. lists,
5. sets,
6. frozensets,
7. tuples,
8. ranges,
9. dictionaries
10. None
Mutability vs Immutability
• Mutable
CAN be changed ‘in place’
lists, dictionaries and sets
• Immutable
CANNOT be changed ‘in place’
string, int, float, decimal, complex, bool, tuple, range, bytes

You might also like