Python Basic Learning
Python Basic Learning
Python tutorials
python features
python history
python applications
python installations
python examples
python variables
python keywords
python literals
python operations
python comments
python if/else
python loops
python sets
Page 1 of 10
python Dictionary
python function
python modules
python exceptions
python date
python regex
python Assert
python IDE
Python arrays
===============>>>>>>>>>>================
python constructors
Page 2 of 10
python inheritance
abstractions in Python
================>>>>>>>>>>===============
Advance Python
Python MYSQL
environment setup
database connections
creating tables
insert operations
read operations
update operations
join operations
performing transactions
================>>>>>>>>>>>==============
-------------------------------------------------------------------
Page 3 of 10
Python Beginners
Course
--------------------------------------------------------------------------------
Rule 1: The variable must begin with a letter (uppercase or lowercase),
or an underscore, NOT a number!
Rule 2: Variables in Python are CapsCase Sensitive.
Rule 3: We cannot use Python Keywords as Variables
Example:
False, await, else, import, pass, None, break, except, in, raise, True,
class, finally, is, return, and, continue, for, lambda, try, as, def, from,
nonlocal, while, assert, del, global, not, with, async, elif, if, or, yield.
--------------------------------------------------------------------------------
Syntax: A set of rules we must follow in all form of communication.
Python can only understand what we tell it!
------------------------------------------------------------------------------------
F-String & String
Lists using String, Integer don't require comma's.
------------------------------------------------------------------------------------
Page 4 of 10
List Methods, extend. append: is used to add single item to the end of
the list!
------------------------------------------------------------------------------------
insert then (0 - 100, "(your variable name)")
.reverse = reverses the list for example
.mark - marks how many variables are found
------------------------------------------------------------------------------------
- comment - use # to write a comment or information about the code!
we want the comment to be short and concise to the point! try to explain
once and as best as you can! this will keep your code looking clean. if
needed to write a long comment, it should be broken up into two seprate
lines. comments are the best way to remind and explain to others what
certain pieces of your code do and will save you tonnes of time!
------------------------------------------------------------------------------------
Index: an index error will arise when we try to call a non-existent index
in a list (zero, one, two, three)
eg:
company_one = ["mark", "paul", "owais", "robert"]
print(f"{company_one[1]} is the hardest worker of the month!)
------------------------------------------------------------------------------------
List in python can become extremely long, having info where we
think it is, is very important!
.sort: organizes list alphabetically, the list will be permanently changed
to alphabetically. eg.
Page 5 of 10
(list_name).sort()
print(list_name)
if you want to reverse the sort list for example zyx add reverse=true
in the brackets .sort()
eg:
list_name.sort(reverse=True)
print(list_name)
Now our list in permanently reversed alphabetically
-
what if you wanted to simply reverse this order in our list?
simply type (list_name).reverse()
print(list_name)
-
In python we cannot sort our lists that have both numerical and
string data types
------------------------------------------------------------------------------------
For Loops In Python are an excellent way to work through every
index of a given loop and perform an action n each item or test for a
certain condition and then apply the action!
ex:
one = ["mark", "paul", "owais","omar"]
for company in company_one:
print(f"{company} is an awesome guy!")
Page 6 of 10
it prints that all the employees are awesome!
------------------------------------------------------------------------------------
how to check if one of our piece of data is in our python list.
in = searches for variable in the lists.
- print("your variable name" in (your list name))
true means its available in your list, false means its not available in
your list.
If or Else
x = ("fish", "dog", "cat")
y = ("shark", "outcopus", "green")
if "fish" in x:
print("fish is in x")
else:
print("fish is not in x")
if x == y:
print("fish is equal to shark")
else:
print("fish is not equal to shark")
here in the code, x is fish and y is shark so it will print that x is not equal
to y, but! If we change y to fish it will print that x is equal to y.
Page 8 of 10
9.
print(number)
z = list(range(1,6))
print(z)
Tuples in Python
A tuples in Python is very similar to lists except for one thing, The value
within the tuples cannot be changed or altered, they are immutable while
lists are mutable.
Tuples are amazing for things you know will never be changed like
birthdates, names, size of something you are creating and etc.
List contains [] meanwhile tuples contain ()
We’ll use our friends name as a tuple list.
Page 9 of 10
#friendsname as list
friends_name_list = ["Paul", "Owais", "Basel", "Kader", "Affan", "Khan", "Arhum", "Mauhid", "Rayan"]
#friendsname as tuples
friends_name_tuples = ("Paul", "Owais", "Basel", "Kader", "Affan", "Khan", "Arhum", "Mauhid", "Rayan")
first_name = friends_name_tuples[0]
print(first_name)
second_name = friends_name_tuples[1]
#this continues...
Page 10 of 10