26 August 2021
09:30
Why Python?
Language is simple to learn,
Reads like human language
easy to read by a novice user
Have Apis and be useful for general use
Provides errors, most of the time reliable.
Appropriate Data structures
Cost Factor - IDE, Compliers and Dev tools. Advantage of Python is it is Open Source, IDE should be
freely available.
Market Demand - Python number 1 in TIOBE
Popular applications/sites developed using Python:
Uber
Netflix
Spotify
Quora
Drobox
Community Support - High Support, Forums
OS Compatibility - Minimum Platform requirements both OS and Hardware etc.
Extensions and Libraries available for database connectivity, Apis, parsers, GUIS etc.
Can be used in many different programmable application types:
Artificial Intelligence
Web Apps
Desktop Apps
Games
Graphics Design
Image Processing
Web Frameworks
OS Development
Data Science and Analytics
,Why has python grown.
Big Data, Machine Learning and Data Science. And mainly. Because Python is easy to learn
TensorFlow, Skilit and Pandas.
Recommended Tools:
https://www.python.org/downloads/
https://youtu.be/rfscVS0vtbw
Python 3 (python.org)
PyCharm (community, jetbrains.com)
Install pip
Install selenium
## How to install Pip ##
# Open a command prompt
#Check
pip --version
## Setting Up PyCharm Project ##
Note: A python file will have the extension of .py
Open Selenium >
File > New Project > Location
Make sure Virtual env Is selected and a location.
Tick Inherit global site-packages.
Click create.
Right click the folder at the left > File > New > Python file > Name
(.py)
File should open.
Click Add Configuration > Click + > Python >
Select the file created in script path and make sure python
interpreter is green.
Type in the script file print ('Hello World') to test.
Click Run button.
## Basic Commands/Instructions ##
The commands are printed in sequential order.
Print = send some information to show in the console.
\ Is used as an escape character.
\n used to add a new line.
,#Comment
#Comments are ignored by the compiler
# = Comment
#Block Comment
'''
Comment goes here
'''
#Double quotes can be used too
"""
Comment goes here
"""
## Data Types ##
A data type is an attribute which specifies the type of data in
memory.
An identifier is a name assigned to an element.
Identifiers are the user-defined names used to identify the data
stored in the memory.
An Identifier cannot: Start with a number, cannot have special chars
(other than _), Identifiers cannot have spaces and cannot be a
reserved (key) word.
Variables will be overwritten. For example:
Var1 = 10
Var1 = 20
Print(Var1)
This will give you a result of 20.
A literal means a value that is written as it is meant to be
interpreted.
"""
print(type(True))
print(type(12.5))
print(type("Hello World"))
Print(type("One Percent")
c = 210j
, print(type(c))
#<class 'bool'>
#<class 'float'>
#<class 'str'>
#<class 'complex'>
#<class 'str'> # Notice how One Percent is not "translated" or converted, and results in its literal
type of a string!
#String
Can be used to store, words, numbers and special characters.
A calculation can NOT be done with a string.
Cannot mix String and Integers.
#TypeError: can only concatenate str (not "int") to str
#But you can convert a value to string using the str()
Defined by double quotes.
character_name = "Ben"
print(character_name)
print(type(character_name))
print(character_name + str(character_age))
#Integer
An integer is a datatype which is used to store a numeric (whole)
value.
#Defined a variable called character_age and assigned it a numeric
value of 50.
character_age = 50
print(type(character_age))
print(character_age)
print(10)
print(type(10))
#Integer
A float is a decimal value
character_shoe_size = 12.5
print(character_shoe_size)
print(type(character_shoe_size))