Python 100 Days Course PDF
Python 100 Days Course PDF
Programming is a way for us to tell computers what to do. Computer is a very dumb
machine and it only does what we tell it to do. Hence we learn programming and tell
computers to do what we are very slow at - computation. If I ask you to calculate
5+6, you will immediately say 11. How about 23453453 X 56456?
You will start searching for a calculator or jump to a new tab to calculate the
same. This 100 days of code series will help you learn python from starting to the
end. We will start from 0 and by the time we end this course, I promise you will be
a Job ready Python developer!
What is Python?
Python is a dynamically typed, general purpose programming language that supports
an object-oriented programming approach as well as a functional programming
approach.
Python is an interpreted and a high-level programming language.
It was created by Guido Van Rossum in 1989.
Features of Python
Python is simple and easy to understand.
It is Interpreted and platform-independent which makes debugging very easy.
Python is an open-source programming language.
Python provides very big library support. Some of the popular libraries include
NumPy, Tensorflow, Selenium, OpenCV, etc.
It is possible to integrate other programming languages within python.
What is Python used for
Python is used in Data Visualization to create plots and graphical representations.
Python helps in Data Analytics to analyze and understand raw data for insights and
trends.
It is used in AI and Machine Learning to simulate human behavior and to learn from
past data without hard coding.
It is used to create web applications.
It can be used to handle databases.
It is used in business and accounting to perform complex mathematical operations
along with quantitative and qualitative analysis.
Why Replit?
Replit is very easy to share tutorials and code.
You can easily fork this repl and continue learning in your own style. Video, code
as well as text tutorial on the same page which makes things easy!
For fellow teachers out there, you create a .tutorial folder to create tutorials
using replit.
I then learnt flask and got to work with Flask with a university professor abroad.
Long story short, Python made a huge impact in my career.
Built in Modules - These modules are ready to import and use and ships with the
python interpreter. there is no need to install such modules explicitly.
External Modules - These modules are imported from a third party file or can be
installed using a package manager like pip or conda. Since this code is written by
someone else, we can install different versions of a same module with time.
The pip command
It can be used as a package manager pip to install a python module. Lets install a
module called pandas using the following command
import pandas
# Read and work with a file named 'words.csv'
df = pandas.read_csv('words.csv')
print(df) # This will display first few rows from the words.csv file
Similarly we can install other modules and look into their documentations for usage
instructions.
We will find ourselved doing this often in the later part of this course
Quick Quiz
Write a program to print a poem in Python. Choose the poem of your choice and
publish your repl
Python Comments
A comment is a part of the coding file that the programmer does not want to
execute, rather the programmer uses it to either explain a block of code or to
avoid the execution of a specific part of code while testing.
Single-Line Comments:
To write a comment just add a ‘#’ at the start of the line.
Example 1
#This is a 'Single-Line Comment'
print("This is a print statement.")
Output:
p is greater than 5.
Example 2: The use of multiline string.
a = 11
b = 11
print(a)
print("+")
print(b)
print(".......")
print(a + b)
#total
a1 = "mofaj" #first name
b1 = "Alam" #last name
print(a1)
print(b1)
print(a1 + b1)
c = True
print(c)
d = None
print(d)
print(type(a))
print(type(b))
print(type(a1))
print(type(b1))
print(type(c))
print(type(d))
list1 = [8, 2.3, [-4, 5], ["apple", "banana"]]
print(list1)
tuple1 = (("parrot", "sparrow"), ("Lion", "Tiger"))
print(tuple1)
dict1 = {"name":"Sakshi", "age":20, "canVote":True}
print(dict1)
Enable "Accessible Terminal" in Workspace Settings to use a screen reader with the
shell.
Results of your code will appear here when you
Run
the project.
a = 1
b = True
c = "Harry"
d = None
These are four variables of different data types.
What is a Data Type?
Data type specifies the type of value a variable holds. This is required in
programming to do various operations without causing an error.
In python, we can print the type of any operator using type function:
a = 1
print(type(a))
b = "1"
print(type(b))
By default, python provides the following built-in data types:
3. Boolean data:
Boolean data consists of values True or False.
Example:
Example:
Example:
Operators
Python has different types of operators for different operations. To create a
calculator we require arithmetic operators.
Arithmetic operators
Operator Operator Name Example
+ Addition 15+7
- Subtraction 15-7
* Multiplication 5*7
** Exponential 5**3
/ Division 5/3
% Modulus 15%7
// Floor Division 15//7
Exercise
n = 15
m = 7
ans1 = n+m
print("Addition of",n,"and",m,"is", ans1)
ans2 = n-m
print("Subtraction of",n,"and",m,"is", ans2)
ans3 = n*m
print("Multiplication of",n,"and",m,"is", ans3)
ans4 = n/m
print("Division of",n,"and",m,"is", ans4)
ans5 = n%m
print("Modulus of",n,"and",m,"is", ans5)
ans6 = n//m
print("Floor Division of",n,"and",m,"is", ans6)
Explaination
Here 'n' and 'm' are two variables in which the integer value is being stored.
Variables 'ans1' , 'ans2' ,'ans3', 'ans4','ans5' and 'ans6' contains the outputs
corresponding to addition, subtraction,multiplication, division, modulus and floor
division respectively.
Exercise 1 - Create a Calculator
Create a calculator capable of performing addition, subtraction, multiplication and
division operations on two numbers. Your program should format the output in a
readable manner!
Typecasting in python
The conversion of one data type into the other data type is known as type casting
in python or type conversion in python.
Python supports a wide variety of functions or methods like: int(), float(), str(),
ord(), hex(), oct(), tuple(), set(), list(), dict(), etc. for the type casting in
python.
Python converts a smaller data type to a higher data type to prevent data loss.
Typecasting in python
The conversion of one data type into the other data type is known as type casting
in python or type conversion in python.
Python supports a wide variety of functions or methods like: int(), float(), str(),
ord(), hex(), oct(), tuple(), set(), list(), dict(), etc. for the type casting in
python.
Python converts a smaller data type to a higher data type to prevent data loss.