Introductiontobasicsofpythonslideshare 230507134929 1e1c6402
Introductiontobasicsofpythonslideshare 230507134929 1e1c6402
www.elewayte.com
01
DATA TYPES
02
VARIABLES
iNTRODUCTION 03
OPERATORS
TO PYTHON 04
CONDITIONAL
STATEMENTS
Python is a high-level programming
language that is widely used in various
fields, including data 05
LOOPS
science, web development, and artificial
intelligence. Some of the key elements of
06
FUNCTIONS
Python include:
07
LIBRARIES
TYPES DESCRIPTION EXAMPLES
Represents numerical
Numeric 'int' , 'float' , 'complex'
values
So Many Flavors, So
Represents a sequence of
Little Time!
Text 'str'
characters
Represents a collection of
In Python, data types are categories of Mapping
key-value pairs
'dict'
values that determine how the values
behave and what operations can be
Represents a collection of
performed on them. Here are some Set
unique elements
'set' , 'frozenset'
'bytes' , 'bytearray' ,
Binary Represents binary data
'memoryview'
Examples that shows how different data types can be used in
Python:
In Python, we’ll try to create a variable called "age" and
assign a value to it, like this:
Variables:
Now, whenever you need to use that age value in your
Party Time! Get program, you can just use the variable name "age". For
example:
Operators: Arithmetic
Operators
Used to perform arithmetic
operations
'2 + 3' returns '5'
Calculations!
Operators values
Used to check if a
Membership
value is present in a '2 in [1, 2, 3]' return 'True'
Operators sequence
TYPES DESCRIPTION EXAMPLES
Conditional
Statements: If
statement
Executes a block
of code if a condition
'x=5' <br>
'if x>3:'<br>
'x=2' <br>
code! If else
statement
Executes one block
of code if a condition
is true and another
'if x>3: '<br>
'print("x is greater than 3")' <br>
'else:' <br>
block if it is false
Conditional statements in allow you to control 'print("x is less than or equal to 3")'
Functions: Built-in
Functions that are built in python and can be
used without needing to define them.
functions
The Superheroes Examples - 'print()' , 'len()' and 'range()'
INPUT OUTPUT
In this example, we define a function called
add_numbers() that takes two parameters, a and b.
The function adds a and b together and returns the
sum. We then call the function with the values 2
User-
and 3, which returns 5. Finally, we print the result. defined
function
Functions
Continue...
Here's an example of using the math library to
calculate the square root of a number: