Pluto Academy Day 1
Pluto Academy Day 1
2. Versatility: Used in web development, machine learning, data science, artificial intelligence,
automation, and more.
3. Extensive Libraries: Python has a vast standard library (e.g., NumPy, Pandas, Matplotlib).
4. Community Support: A large community makes learning resources and problem-solving easy to
find.
We are using the Programiz online compiler to run Python because it offers easy access, is
beginner-friendly, and allows quick debugging. By using this online compiler, we can efficiently focus
on learning and coding without worrying about the technical setup.
print("Hello, World!")
Practice Questions:
1. Write a Python program that prints "Hello, Python!".
2. Install VS Code and run a simple Python program that prints your name.
3. Create a Python program that outputs the message "Learning Python is fun!"
Example:
To check the type of the data in python, we have type() function. For example x is a variable. To find
the type of the data of variable x.
print(type(age)) #int
print(type(pi)) #float
print((type(name)) #string
print((type((is_raining)) #boolean
Output:
Comments in Python:
Comments help explain your code and are ignored by the Python interpreter.
Basic Operators:
Operators are symbols used to perform operations on variables or values. They perform different
operations, such as arithmetic, comparison, logical, etc., depending on the type of operator.
Arithmetic Operators:
These operators are used to perform basic mathematical operations.
Example:
a = 10
b=5
print(a + b) # Output: 15
Example: a = 10
b=5
print(a - b) # Output: 5
Example: a = 10
b=5
print(a * b) # Output: 50
/ (Division): Divides the first value by the second and returns a float result.
Example: a = 10 b = 5
Example: a = 10 b = 3
print(a // b) # Output: 3
% (Modulus): Returns the remainder when the first value is divided by the second.
Example:
a = 10
b=3
print(a % b) # Output: 1
** (Exponentiation): Raises the first value to the power of the second value.
Example:
a= 2
b=3
print(a ** b) # Output:
Comparison Operators:
These operators are used to compare two values and return a boolean result (True or False).
Example: a = 10 b = 5
!= (Not equal to): Returns True if both values are not equal.
Example: a = 10 b = 5
< (Less than): Returns True if the first value is less than the second.
Example: a = 10 b = 5
> (Greater than): Returns True if the first value is greater than the second.
Example: a = 10 b = 5
<= (Less than or equal to): Returns True if the first value is less than or equal to the second.
Example: a = 10 b = 10
>= (Greater than or equal to): Returns True if the first value is greater than or equal to the second.
Example: a = 10 b = 5
Logical Operators
Used to combine conditional statements or perform logical operations.
and True if both conditions are true (5 > 3) and (4 < 6) True or
Example Code:
a = 10 b = 20 # Logical AND
print(a > 5 and b > 15) # True (both conditions are True)# Logical
# Logical NOT
Assignment Operators
Used to assign values to variables. They can also combine operations with assignments.
Operator Description Example Result
Example Code:
a=5
a += 3 # a = 5 + 3
print(a) # Output: 8
a *= 2 # a = 8 * 2
print(a) # Output: 16
a //= 3 # a = 16 // 3
print(a) # Output: 5
Membership Operators
Test if a value is present in a sequence like a string, list, or tuple.
not in True if the value does not exist 'b' not in 'apple' True
Example Code:
5. Identity Operators
Compare the memory locations of two objects.
Example Code:
x = [1, 2, 3]
y = [1, 2, 3]
z=x
These operators are fundamental to programming as they allow us to manipulate and compare data,
performing calculations and logical checks.
Practice Questions:
1. Write a Python program to store your age in a variable and print it.
2. Create a program that takes two numbers as input and prints their product.
3. Write a Python program to compare two numbers and print whether the first is greater than the
second.