Python
Python
After this we seen some errors that often come if you do some
mistakes
Indentation error : Generally comes when you give some extra space
which is not needed for given block
Variables in python
We use variables that acts as storing box for data
#variables in python
x=8
print(x)
Day 2
Strings
Number of characters inside double quotes
# String
name="Shivam"
print(name)
Integer in python
Integer datatype in python is used to denote whole numbers in
python
# Integer
age=18
print(age)
Float
If we want to denote any number in python with floating points ex.
8.8 Then we se Float datatype representation
# Float
roll=8.8
print(roll)
Boolean:
In python Boolean datatype has fixed values that is true or false
# boolean
shivam=True
Teli=False
print(shivam)
print(Teli)
After processing this code we will get error something like this :
Output:
# Type conversion
converted_int = int(number) # Convert string to integer
converted_float = float(decimal) # Convert string to float
converted_bool1 = bool(truthy) # Convert integer to boolean
(True)
converted_bool2 = bool(falsy) # Convert integer to boolean
(False)
converted_str = str(converted_float) # Convert float to string
Output :
# Addition
print("Addition:", 8 + 8 + 8) # Adds the numbers (8 + 8 + 8 = 24)
# Subtraction
print("Subtraction:", 8 - 8) # Subtracts 8 from 8 (8 - 8 = 0)
# Multiplication
print("Multiplication:", 8 * 8) # Multiplies 8 by 8 (8 * 8 = 64)
# Division
print("Division:", 8 / 3) # Divides 8 by 3, returns a float result
(8 / 3 = 2.666...)
# Floor Division (// operator)
print("Floor Division:", 8 // 3) # Divides 8 by 3, returns the integer
part (8 // 3 = 2)
# Modulus (Remainder)
print("Modulus (Remainder):", 8 % 8) # Divides 8 by 8, returns the
remainder (8 % 8 = 0)
# Exponentiation
print("Exponentiation:", 8 ** 2) # Raises 8 to the power of 2 (8^2 =
64)
Output :