Python Notes Part 1 1727438232
Python Notes Part 1 1727438232
--------------------------------------------------------------------------------------------------------------------------
INTRODUCTION:
What is Python?
Python is a popular programming language. It was created by Guido Van Rossum and released on 20
Feb 1991.
Python is High Level Object Oriented Programming Language.
Web Development,
Software Development,
Data Analysis,
System Scripting,
Task Automation,
Data Visualisation
--------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------
Jupyter Notebook
PyCharm
IDLE
Visual Studio
Spyder
VARIABLES IN PYTHON
Types Representation
Text str
Numeric int, float, complex
Sequence list, tuple, range
Mapping dict
Set set, frozenset
Boolean bool
--------------------------------------------------------------------------------------------------------------------------------------
PYTHON STRINGS
Strings in python are surrounded by either single quotation or double quotation marks.
Eg: ‘Hello Python here’ or “Hello Python here”
Multiline String
You can assign a multiline string to a variable by using three single or double quotes
Strings as Arrays
Strings in Python are arrays. Square brackets can be used to access elements of the string.
String Length
Check String
--------------------------------------------------------------------------------------------------------------------------------------
SLICING
You can return a range of characters by using the slice syntax.
Specify the start index and the end index, separated by colon, to return a part of the string.
CONCATENATION
Method Description
capitalize() Converts the first character to upper case
count() Returns the number of times a specified value occurs in a string
endswith() Returns true if string ends with the specified value
find() Searches the string for a specified value and returns the position of
where it was found
format() Formats specified values in a string
index() Searches the string for a specified value and returns the position of
where it was found
isalnum() Returns True if all characters in the string are alphanumeric
isalpha() Returns True if all characters in the string are in the alphabet
islower() Returns True if all characters in the string are lower case
isnumeric() Returns True if all characters in the string are numeric
isspace() Returns True if all characters in the string are whitespaces
isupper() Returns True if all characters in the string are upper case
lower() Converts a string into lower case
replace() Returns a string where a specified value is replaced with a specified
value
split() Splits the string at the specified separator, and return a list
strip() Remove whitespace from start and end
swapcase() Swaps cases, lower case becomes upper case and vice versa
title() Converts the first character of each word into upper case
upper() Converts a string into upper case
--------------------------------------------------------------------------------------------------------------------------------------
BOOLEAN
You can evaluate any expression in Python and get one of two answers, True or False.
Almost any value is evaluated to True if it has some sort of content.
Any String is True, except empty strings.
Any number is True, except 0.
Any list, tuple, set and dictionary are True, except empty ones.
PYTHON OPERATORS
ARITHMETIC OPERATORS
ASSIGNMENT OPERATORS
IDENTITY OPERATOR
BITWISE OPERATOR