KEMBAR78
Hi Coders and Welcome To The Complete Python Series | PDF | Boolean Data Type | Python (Programming Language)
0% found this document useful (0 votes)
15 views16 pages

Hi Coders and Welcome To The Complete Python Series

The document introduces a comprehensive Python programming series aimed at beginners, covering essential concepts and practical coding skills. It emphasizes Python's simplicity, versatility, and the importance of understanding programming languages for effective communication with computers. The series will include hands-on coding practice, installation guidance, and foundational programming concepts, ultimately preparing learners for advanced topics like AI and web development.

Uploaded by

mdrehmani2007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views16 pages

Hi Coders and Welcome To The Complete Python Series

The document introduces a comprehensive Python programming series aimed at beginners, covering essential concepts and practical coding skills. It emphasizes Python's simplicity, versatility, and the importance of understanding programming languages for effective communication with computers. The series will include hands-on coding practice, installation guidance, and foundational programming concepts, ultimately preparing learners for advanced topics like AI and web development.

Uploaded by

mdrehmani2007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Hi Coders and Welcome to the Complete Python Series!

In this series, we will be covering the Python programming language in detail. After
completing this series, if your interest grows toward Artificial Intelligence (AI), Machine
Learning (ML), or Data Science, you’ll be fully capable of starting to learn Machine
Learning.

Or if you later want to enter the domain of Web Development and work with frameworks
like Django to build websites, you’ll be able to start learning that as well.

We’ll be learning in such a way that—even if today you don’t know how to write even a
single line of code—by the end of this series, you will be able to write decent Python
programs. Plus, you will have learned and applied many important programming concepts.

Now, whenever we talk about Python, for the past few years, Python has been the most loved
language in the tech industry. Many good programmers start their coding journey with
Python because it’s one of the easiest languages to start with, and that’s exactly why we’re
starting our journey with Python too.

We will be using PythonAnywhere.com to begin coding. If you've never written a single


line of code in any programming language before today, that’s absolutely fine. We are
starting from zero level, and step-by-step we’ll be leveling up in programming.

In each lecture of this series, we’ll not only study the theory and concepts, but we’ll also
write a lot of code, practice hands-on, and solve practice questions related to each
important topic.

You’ll find the links to slides and notes used in this series in the description box below each
video.

So, let’s begin with Lecture 1 of our Python series, where we’ll cover the Introduction to
Python—including what Python 2 is and other such concepts.

Now, let’s first talk about: What is Programming?

Programming involves two main components:

1. A machine (this could be your laptop or desktop).


2. And the code.

When we write code, we are giving instructions to the machine. These instructions are called
a program.

So, if I want to make my laptop or computer do something, I’ll have to give it instructions.

But computers don’t understand human languages like Hindi, English, Nepali, Marathi,
etc. That’s why we use programming languages like Python, Java, C++, JavaScript, etc.
to communicate with computers.
Let’s understand this with an example:
Suppose you go to France, you’ll have to speak French there.
If you go to Nepal, you’ll speak Nepali.
If you’re in Maharashtra, you may need to speak Marathi.

In the same way, if you want to talk to a computer, you’ll have to speak in a language that
the computer understands.
That’s why we use programming languages.

There are many different programming languages:


You can use Java, C++, C, JavaScript, etc.

But in this course, we’ll be learning Python. So, all the code that we’ll write to make our
computer/laptop/machine do tasks will be written in Python.

Now here’s a small twist:

Even though we write our code in Python, the computer doesn’t directly understand
Python.

Languages like Python, Java, and C++ are easy for us humans to understand, but the
computer only understands 0s and 1s.

That’s because computers or machines only understand binary language (0s and 1s), which
is based on high voltage and low voltage:

 High current (voltage) = 1


 No current = 0

This is basic electronics.

So even though we write code in Python, ultimately it has to be converted into binary (0
and 1) for the machine to execute it.

Even though Python looks like English, the code written in Python needs to be translated for
the machine to understand it. Just like if I travel to France and don’t know how to speak
French, I would take a translator or guide with me who would translate my English or Hindi
into French.

Similarly, since computers only understand the language of 0s and 1s, the role of a
translator here is to translate our Python code into machine language. That’s why Python
is called a high-level language.
The translator's job is to convert high-level code into low-level or machine-level code.
These translators can be compilers or interpreters.

In Python’s case, an interpreter is used, which takes the Python code and translates it line-
by-line into a form the machine can understand.

So, now we clearly understand that if I want to get something done from my computer, I’ll
have to write code in Python.

What is Python?

Before we understand Python in-depth, we should first know some of its basic features:

1. Python is very simple and easy to understand.


Many surveys conducted every year say that Python feels almost like English and
that’s why it’s a perfect language to start learning programming with.
2. Python is free and open-source.
This means anyone can use Python—you, me, anyone—for free. There are versions
like Python 2 as well, but Python in general is a free programming language.
3. Python is a high-level language.
This means that it is easy for humans to understand, even though it cannot directly
operate at the machine-level. It hides the complex machine-level details from us.
4. The code written in Python is the same regardless of operating system. That means
whether you're using Windows, macOS, or Linux, the same code runs across
platforms.
5. Python is very versatile.
With Python, you can build websites using frameworks like Django, create software,
automate tasks, analyze data, or even develop AI/ML applications.

So now, let’s get started with writing our first program in Python.

We’ve talked enough about Python being a coding language, being open-source and versatile.
But now the question is:
What does code actually look like?
What does it mean when we say, “We’ll write code in Python”?

For that, we’ll begin writing code using PythonAnywhere.com.

In school or college, we’ve always written things in notebooks. But we can’t write code on
paper. The correct way to write and run code is to write it inside a code editor.

One of the best free editors available is Visual Studio Code (VS Code), and we’ll be using
it.
Python Installation (Windows)

To install Python on Windows:

 Go to python.org.
 You’ll see a big yellow “Download Python” button (e.g., Python 3.7.2.1).
 If you're watching this lecture later, the version might be different—that’s okay. You
can download any available version.

After clicking download, the installer will start.

Before installing, there will be two checkboxes on the screen:

1. One for admin privileges — tick this.


2. One for adding Python to PATH (python.exe) — tick this as well.

Then, click on "Install Now", and Python will begin installing.

Once installed, you’ll see a message saying "Setup was successful". You can now close that
window.

Python Installation (Mac)

To install Python on a Mac:

 Download the Python package.


 Double-click on it.
 A setup window will open.
 Click Continue, then Agree.
 You may be asked for your Mac password—enter it.
 Then the installation will begin.

Verifying Python Installation

To verify installation:

 Open the Terminal and type:


 python3 --version
 Hit Enter.
If Python is installed correctly, you’ll see the version number printed on screen.

This command works the same on both Mac and Windows.


Installing Visual Studio Code (VS Code)

To install VS Code:

 Search “Download VS Code” in your browser.


 Visit the official site (code.visualstudio.com).
 Choose the version based on your system:
o If your system is 64-bit, download the 64-bit version.
o If it’s 32-bit, choose accordingly.

Most people use 64-bit systems.

Creating Your First Python Program

Once VS Code is installed:

 Open it.
 Click on “New File” to create a text file (which will become your Python program).
 Save the file using Ctrl+S (Windows) or Cmd+S (Mac).
 Name it something like:
first_program.py
o Here, .py is the extension used for Python files.
o Just like .txt is used for text files, .py tells the computer it's a Python file.

You’ll see a small Run button on the top-right. Click it to run your program.

Writing Your First Python Code

Let’s write a very basic Python program:

print("Hello, World!")

Once you run this, the output below will display:

Hello, World!

You can change the text to your name:

print("Shraddha is my name")

Output:

Shraddha is my name
Or change it to your college:

print("XYZ College")

And it will print that. Whatever you write inside the print() function gets printed to the
screen. This is known as the output.

Understanding a Basic Python Program

Any code usually takes input and gives output.


We will soon learn how to take input too.

But for now, our program is printing statements, so the output is what we see on the screen.

Python Character Set

Python only allows certain characters. Just like in English, we have letters A-Z, a-z, etc.,
Python also follows a defined character set:

 Uppercase Letters: A to Z
 Lowercase Letters: a to z
 Digits: 0 to 9
 Special Symbols: +, -, *, /, %, etc.
 Whitespace characters: space, tab, newline
 ASCII & Unicode characters: basic supported ones

You cannot use non-English characters (like Hindi, Marathi, Punjabi letters) in most Python
syntax (except as strings).

That’s why Python is said to be very close to English. When you look at Python code, it’s
often very easy to understand even if you don’t have a programming background.

For example:

print("Hello, World!")

It’s clear just by reading it that it prints something on screen.

Practice Example

Now let’s write some practice code:

Print ("Shraddha is my name")


Print ("My age is 23")
You can try writing your own name, age, or any sentence and run the code to see the output.

Let me know if you want this turned into a PDF, slides, flashcards, video script, or if you’d
like to start interactive coding practice. Here's the complete English translation of your
Python learning notes:

✅ Printing Name and Age

If you want to print your name and then, on the next line, print your age:

print("Shraddha is my name")
print("My age is 23")

If you want both printed on the same line, you can write:

print("Shraddha is my name", "My age is 23")

When you use commas inside print(), all the values are printed on the same line. If you use
separate print() statements, they are printed on different lines.

✅ Printing Numbers and Doing Calculations

Python allows you to print numbers too:

print(23)
print(25, 35)

You can also do arithmetic operations:

print(35 + 23) # Output: 58

You can do addition, subtraction, multiplication, division easily.

✅ What Are Variables?

A variable is a name given to a memory location that stores some value.

In math:

 Area of rectangle = a * b
 Perimeter = 2 * (a + b)
Here, a and b are variables, whose values can change.

In programming, it's the same:

name = "Shraddha"
age = 23
price = 25.99

 "Shraddha" is a string
 23 is an integer
 25.99 is a float

Variables store values in memory. You can later update them:

age = 24 # New value assigned

You can use these variables in print:

print(name) # Shraddha
print(age) # 24
print(price) # 25.99

If you write:

print("age")

You’ll get age as output, not the value. Remove quotes to get the value.

✅ Printing Variables in Sentences


print("My name is:", name)
print("My age is:", age)

Output:

My name is: Shraddha


My age is: 23

✅ Variable Assignment

In math: a = b means both are equal.

In Python: a = 23 means 23 is stored in variable a.

Assignment always goes right to left.

age = 25
age2 = age # age2 now stores the same value as age
print(age2) # Output: 25
✅ Rules for Variable Names (Identifiers)

1. Can use:
o lowercase letters: a to z
o uppercase: A to Z
o digits: 0 to 9
o underscores: _
2. Cannot start with a number:
o ✅ variable1 (valid)
o ❌ 1variable (invalid)
3. Cannot use special symbols like: @, #, %, !, $
4. Variable names should be:
o Simple
o Short
o Meaningful
Example: age, name, count, sum

✅ type() Function in Python

To find the type of a variable:

print(type(name)) # <class 'str'>


print(type(age)) # <class 'int'>
print(type(price)) # <class 'float'>

✅ Primary Data Types in Python

1. Integers (int)
Whole numbers: -25, 0, 100
2. Strings (str)
Words or sentences inside quotes:
3. name1 = "SK"
4. name2 = 'SK'
5. name3 = '''SK'''
6. Floats (float)
Decimal numbers: 3.99, 25.0
7. Boolean (bool)
Only two values:
8. True
9. False
o Must use capital T and F
10. None (NoneType)
Represents no value.
If you'd like, I can give you a Python notebook-style summary or practice exercises based
on this lesson. Just ask!

Here is the full English translation of your Hindi explanation:

Python Data Types: None and Boolean

If we don’t want to store any value in a variable for now, we can assign it the value None. For
example:

a = None

This means that variable a doesn't hold any value currently. It's a special data type that means
"nothing is stored".

Let’s see an example with both a boolean variable and a None variable in code:

age = 23
old = False
a = None

print(type(old))
print(type(a))

Here, type() is a function (we’ll learn more about functions later), and it tells us the data
type of the variable.

 Since old = False, its type will print as bool.


 Since a = None, its type will print as NoneType.

Now, remember:

 If you write false, true, or none with lowercase letters like f, t, or n, Python will
show an error.
 You must write False, True, and None with capital first letters because they are
keywords in Python.

Python Keywords

Just like a dictionary has fixed meanings for words, Python has a set of reserved words
called keywords. These words have specific meanings and purposes in Python.

Examples of Python keywords include:

 True
 False
 None
 if
 else
 break
 and
 or
 assert, etc.

You cannot use these keywords as variable names. For example, writing True = 5 will give
an error.

You don’t need to memorize all keywords right now. As you keep learning Python, you'll
automatically remember them one by one.

Python is Case-Sensitive

Python is a case-sensitive language. That means Apple and apple are two different
variables.

Unlike SQL (which is not case-sensitive), in Python:

 True ≠ true
 False ≠ false
 None ≠ none

So always use the correct capitalizations when using keywords.

Printing Sum of Two Numbers in Python

Let’s say we want to add two numbers and print the result.

a = 2
b = 5
sum = a + b
print(sum)

This will output: 7

If we change the numbers:

a = 1000
b = 500

Now the output will be: 1500

To calculate the difference instead:

difference = a - b
print(difference)

This will print: 500

Comments in Python

Comments are parts of the code that Python ignores during execution. We use them to
explain code for humans.

There are two types:

1. Single-line comments start with #


2. # This is a comment
3. print("Hello World") # This will run, the comment won’t
4. Multi-line comments use triple quotes (''' or """)
5. '''
6. This is a
7. multi-line comment
8. '''

In Visual Studio Code, you can comment multiple lines using:

 Ctrl + / on Windows
 Cmd + / on Mac

Operators in Python

An operator is a symbol that performs operations on values (operands).

Arithmetic Operators

Examples:

a = 5
b = 2

print(a + b) # Addition → 7
print(a - b) # Subtraction → 3
print(a * b) # Multiplication → 10
print(a / b) # Division → 2.5 (always returns float)

Even if a result is a whole number, division will give a decimal (4 / 2 → 2.0)

Modulus Operator (%)

Returns the remainder:

print(5 % 2) # Output: 1
Power Operator (**)

Used for exponentiation:

print(5 ** 2) # Output: 25

Relational / Comparison Operators

These operators compare two values and return True or False.

Examples:

a = 50
b = 20

print(a == b) # Equal to → False


print(a != b) # Not equal to → True
print(a > b) # Greater than → True
print(a >= b) # Greater than or equal to → True
print(a < b) # Less than → False
print(a <= b) # Less than or equal to → False

These are also called Boolean expressions because they return either True or False.

Assignment Operator

The most basic assignment operator is =

a = 50

This means the value 50 is assigned to variable a.

Assignment Operators

We have seen the assignment operator (=), but Python also has many more assignment
operators. For example:

num = 10
num = num + 10

Now, num becomes 20 (10 + 10). Instead of writing num = num + 10, we can use a
shorthand:

num += 10
This also results in num becoming 20.

Other assignment operators include:

 -= (subtract and assign): num -= 10 → 0


 *= (multiply and assign): num *= 5 → 50
 /= (divide and assign): num /= 5 → 2.0
 %= (modulus and assign): num %= 5 → 0
 **= (power and assign): num **= 5 → 100000 (10^5)

All these operators modify the existing variable by applying an operation on it.

Logical Operators

Python has 3 logical operators: not, and, or.

 not: Reverses the Boolean value


not True → False
not False → True

You can use logical operators with expressions too:

a = 50
b = 30
print(not (a > b)) # False, because a > b is True

 and: Returns True only if both values are True


 val1 = True
 val2 = True
 print(val1 and val2) # True

If either is False, result will be False.

 or: Returns True if at least one is True


 val1 = False
 val2 = True
 print(val1 or val2) # True

These operators can be used directly with expressions:

a = 50
b = 30
print(a == b or a > b) # True because a > b

Type Conversion

Type conversion is when one data type is converted into another. There are two types:
1. Implicit Conversion (done automatically by Python)

Example:

a = 2
b = 4.25
sum = a + b
print(sum) # Output: 6.25

Here, a is an integer and b is a float. Python automatically converts a to float before adding.

2. Explicit Conversion (Type Casting)

If you have a string like "2", you must convert it manually to use it in arithmetic:

a = "2"
b = 4.25
a = int(a) # Explicitly converting string to integer
print(a + b) # Output: 6.25

You can use:

 int(): to convert to integer


 float(): to convert to float
 str(): to convert to string

Type casting only works if the data is compatible. For example, "Shraddha" can't be
converted to float — it will raise an error.

Taking Input in Python

You can take input using the input() function.

name = input("Enter your name: ")


print("Welcome", name)

By default, the input() function returns a string, even if you enter a number.

To use numeric inputs:

age = int(input("Enter your age: "))


marks = float(input("Enter your marks: "))

Practice Questions

1. Input two numbers and print their sum:


first = int(input("Enter first number: "))
second = int(input("Enter second number: "))
print("Sum =", first + second)
2. Input the side of a square and print its area:
side = float(input("Enter square side: "))
area = side * side
print("Area =", area)
3. Input two float numbers and print their average:
a = float(input("Enter first number: "))
b = float(input("Enter second number: "))
average = (a + b) / 2
print("Average =", average)
4. Input two integers and print True if the first is greater than or equal to the second:
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
print(a >= b)

These were the basics of Python from Lecture 1: variables, input/output, data types,
operations, logical/assignment operators, and type conversions.

You might also like