0% found this document useful (0 votes)
7 views24 pages

Python

Python is a high-level, interpreted, and open-source programming language that emphasizes ease of use and abstraction from computer details. It supports object-oriented programming and is versatile for various applications such as AI, web development, and data analysis. The document also covers fundamental concepts like data types, operators, control structures, and string methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views24 pages

Python

Python is a high-level, interpreted, and open-source programming language that emphasizes ease of use and abstraction from computer details. It supports object-oriented programming and is versatile for various applications such as AI, web development, and data analysis. The document also covers fundamental concepts like data types, operators, control structures, and string methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 24

PYTHON

HIGH-LEVEL PROGRAMMING LANGUAGE

 Provides abstraction from the details of the computer


 Does most of the work in communicating with the computer
 The code is intuitive and easy to understand
 Python is an object-oriented programming (OOP) language which means it's organized around objects rather
than actions.

 Interpreted programming language ( which means it does not need to be compiled or converted from one language
to another. Python is interpreted by a Python interpreter)
 An open-source programming language (which means it's free. Python is powerful, flexible, and intuitive. There are
many libraries and resources available online)

NOTE: This means that sometimes it's difficult to debug your Python programs. So don't make the mistake of typing out
large chunks of code and not testing it at all.

USAGE: Python can be used for artificial intelligence, machine learning, natural language processing, web development,
data analysis and visualization, game programming, desktop GUIs, and many other purposes.

PRINTS

DATA TYPES
TYPE of Input/Output

ARITHMETIC OPERATORS
+ Addition
- Subtraction
* Multiplication
/ Division

DIVISIONS
Boolean value of Comparison

Boolean value
Bool value > 0 is always TRUE

COMPARISION OPERATORS

STRINGS
The backslash is an escape character. It's telling Python, this single quote is to be treated as an ordinary character
and not something that's enclosing the string.

CASTING

Hence cast the integer to str and then using concatenation as shown below

Str concatenated with Boolean

VARIABLE
Variable Substitution

Combining Variables

User input to variables


If…elif…else

Multiple IFs
Name Error

Type Error

Value Error
Functions

Passing value as Function parameter

Lists
Most common data structure
Mutable -after defined the individual elements can be changed
Specify, separated values in between square brackets[].
The values included may not be the same type.
Each item in the list is a signed index value, starting with zero.
FOR LOOP

Iterated over the list


Iterate over the strings

Iterate over string

Exercise
Append lists using functions
1) Extend

Updating LISTS
WHILE LOOP
Some String Functions
Here are some useful built-in string methods:

 string.capitalize() – capitalizes first letter of string


 string.startswith(prefix) – determines if string starts with prefix
 string.endswith(suffix) – determines if string ends with suffix
 string.isupper() – determines if all characters in the string are uppercase
 string.islower() – determines if all characters in the string are lowercase
 string.find(str) – determines if str occurs in string
 string.index(str) – determines index of str in string
 string.replace(old, new) – replaces all occurrences of old in string with new
 string.strip() – trims whitespace from beginning and end of string
 string.upper() - returns uppercased string from given string
 string.lower() - returns lowercased string from given string
All strings have these built-in methods!
OPEN AND READ FILES

You might also like