0% found this document useful (0 votes)
16 views14 pages

Introductiontobasicsofpythonslideshare 230507134929 1e1c6402

Uploaded by

masuma
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)
16 views14 pages

Introductiontobasicsofpythonslideshare 230507134929 1e1c6402

Uploaded by

masuma
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
You are on page 1/ 14

GET READY TO SSSSSSINK

INTO PYTHON BASICS,


ITS POWER & VERSATILITY

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

Data Types: Sequence


Represents a collection of
ordered and indexed values
'list' , 'tuple' , 'range'

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'

common data types and their examples:


Represents a binary truth
Boolean 'bool'
value

'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:

Your Data On!


A variable in Python is just a name that
represents a value, and you can use it to The output will be:
store and manipulate data throughout
your program.

Let’s understand the same with a small


example: In this example, the variable "age" is assigned the value 15.
Then, the print statement uses the value of the variable
"age" to output the string "I am 15 years old."

Note: We use the str() function to convert the integer value


of "age" into a string, so we can concatenate it with the
other strings in the output statement.
TYPES DESCRIPTION EXAMPLES

Operators: Arithmetic
Operators
Used to perform arithmetic
operations
'2 + 3' returns '5'

Go crazy with Comparison Used to compare


'2 < 3' returns 'True'

Calculations!
Operators values

Logical Used to combine and 'True and False' returns


In Python, operators are symbols or Operators manipulate boolean values 'False'

special characters that allow you to


perform different kinds of operations on Bitwise Used to perform
'5 & 3' returns '1'
variables and values. Operators bitwise operations

Here's a table that summarizes the Assignment Used to assign values


'x=5'
Operators to variables
different types of operators in Python,
along with their descriptions and
Used to compare the
examples: Identity
memory location of 'x is y' returns 'True'
Operators two objects

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>

Be the boss of your


is true 'print("x is greater than 3")'

'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")'

the flow of your program based on certain


'x = 5' <br>
conditions. They are used to make decisions in 'if x > 7: ' <br>
your code, and they help your program to be 'print("x is
Executes a block of
more flexible and responsive to different inputs. elif code if a condition is true,
greater than 7")' <br>
'elif x > 3: '<br>
statement and if not, checks
'print("x is greater than 3 but less
another condition
than or equal to 7")' <br>
Here's a detailed description along with 'else:' <br>
examples that demonstrates the different types 'print("x is less than or equal to 3")'

of conditional statements in Python to perform


various kinds of checks, such as checking if a 'x = 5' <br>
number is greater than a certain value, or if it 'if x > 3:' <br>
Executes a block of
'if x < 7:' <br>
falls within a certain range. When you run this nested if
code if a condition is true,
'print("x is between 3 and7")' <br>
and that block
code, you will see the output for each statement 'else:' <br>
can contain another
conditional statement. if statement
'print("x is greater than or equal to 7")' <br>
'else:'<br>
'print("x is less than or equal to 3")'
Loops: LOOP TYPE DESCRIPTION

Repeat After Me! 'for' loop


Used to iterate over a sequence of elements,
such as a list or string

Loops are used to repeat a block of code multiple


Used to repeat a block of code while a certain
times until a certain condition is met. There are 'while' loop
condition is true
two main types of loops in Python: for loops and
while loops.

Here's an example of a for loop that iterates over


a list of numbers and prints each number along
with the output. In this example, the loop will FOR
continue to run as long as count is greater than LOOP
0. Each time the loop runs, it prints the value of
count, then subtracts 1 from it. Eventually, count
becomes 0, and the loop stops running.
INPUT OUTPUT
There are also other types of loops in Python,
such as nested loops, which allow you to put one
loop inside another, and break and continue
statements, which allow you to control the flow WHILE
of the loop. LOOP
FUNCTION TYPE DESCRIPTION

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()'

Functions that you create yourself to perform


User-defined
of Code! functions
a specific task. They can be reused multiple
times throughout your code.

Functions are reusable blocks of code that perform


a specific task. They allow you to write a piece of
code once and use it multiple times without having Built-in
to rewrite the code. There are two main types of
function
functions in Python: built-in functions and user-
defined functions.

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:

Another example is using the pandas library to


read a CSV file and display its contents:
Python's Top Guns:
Example for importing NumPy
The Most Important Library in Python
Libraries
1. NumPy
NumPy is a library for numerical computing in
Python. It provides fast and efficient array
operations and linear algebra routines.

Example for importing Pandas


2. Pandas Library in Python
Pandas is a library for data manipulation
and analysis in Python. It provides
powerful tools for working with structured
data, such as dataframes and series.
Libraries Example for importing
Matplotlib Library in Python
Continue...
3. Matplotlib
Matplotlib is a library for data visualization
in Python. It provides a variety of plots and
charts for visualizing data, including line
plots, scatter plots, and histograms.
Example for importing Scikit-
4. Scikit-learn learn library in Python

Scikit-learn is a library for machine


learning in Python. It provides tools for
data preprocessing, model selection, and
evaluation, as well as a range of machine
learning algorithms.
FOLLOW FOR MORE
SUCH CONTENTS
www.elewayte.com

elewayte_edu Elewayte elewayte_ Elewayte

You might also like