PYTHON is a high-level, interpreted programming language known for its readability and simplicity.
It is widely used for web development, data analysis, artificial intelligence, scientific computing, and more.
Basics stuffs you will learn in python as a beginner.
How to print in python
print("Hello, World!")
How to write comments in python
# This is a single-line comment
"""
This is a
multi-line comment
"""
Variables and datatypes
Integer
x = 10
Float
y = 3.14
String
name = "Alice"
Boolean
is_valid = True
Arithmetic operators - +, -, , /, %, //, *
a = 10
b = 3
print(a + b) # Addition
print(a - b) # Subtraction
print(a == b) # Equals
print(a != b) # Not equal
print(a > b) # Greater than
print(a < b) # Less than
print(a * b) # Multiplication
print(a / b) # Division
print(a % b) # Modulus
print(a // b) # Floor Division
print(a ** b) # Exponentiation
Comparison operators - ==, !=, >, <, >=, <=
a = 10
b = 3
print(a == b) # Equals
print(a != b) # Not equal
print(a > b) # Greater than
print(a < b) # Less than
print(a >= b) # Greater than or equal
print(a <= b) # Less than or equal
Logical operators- and, or,not
a = 10
b = 3
print(a > 5 and b < 5) # Logical AND
print(a > 5 or b > 5) # Logical OR
print(!(a > 5)) # Logical NOT
Conditional statements - else , if, elif
a = 10
b = 3
if a > b:
print("a is greater than b")
elif a < b:
print("a is less than b")
else:
print("a is equal to b")
Top comments (0)