Python Class
Python Class
to
PYTHON
ASSIGNING A VARIABLE
Assigning a variable in programming refers to the process
of associating a value with a symbolic name (the variable
name) so that the program can refer to and manipulate
that value using the given name. It is essentially storing a
piece of data in a memory location and giving it a label for
convenient reference.
It is a way to give a name to a memory Assignment operator: The variable name will be
location, making it easier to reference followed by the assignment operator. The assignment
and manipulate data. operator is an equal sign (=).
Variables are used in various The value: The value we assign to a variable can be
programming tasks, such as numerical or consist of characters, known as strings. In
calculations, storage, and manipulation this part of the lesson, we will only be focusing on using
of data. numerical values
DATA TYPES
Variables in Python hold values of different kinds. Data
types dictate what kind of data a variable can store and, in
some cases, the amount of memory allocated to it.
• Integers
• Floats
• Strings
• Booleans
1. Numbers
2. Strings (Text)
3. Booleans
1. NUMBERS
This group categorizes all numerical data:
• INTEGERS:
Positive or negative whole numbers with no
fractional components.
Examples:
Examples:
Examples:
Examples:
unique_numbers = {1, 2, 3, 4, 5}
fruits = {"Apple", "Banana", "Cherry"}
mixed_set = {"Python", 3.14, 42}
Conditions, Loops
and Functions
Python
Conditions
if Statement: else Statement
The if statement checks a The else statement runs when
condition. If the condition is the if condition is false.
true, the code inside the if block
runs. Example.
X = 10 x=3
● Positional Arguments.
● Keyword Arguments.
● Default Arguments.
Positional Arguments
These are the most common type of arguments. The
values are assigned to parameters in the order they are
given.
greet("Alice", "Hello")
Keyword Arguments:
These arguments are passed using the parameter
names. They can be provided in any order.
greet(name="Alice")
Remember to share
your learning on
LinkedIn
(Tag @10Alytics)