DEV Community

Cover image for Basics of Python in 1 minute
Mehfila A Parkkulthil
Mehfila A Parkkulthil

Posted on

Basics of Python in 1 minute

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
"""
Enter fullscreen mode Exit fullscreen mode

Variables and datatypes

Integer 
x = 10  

Float 
y = 3.14    

String
name = "Alice" 

Boolean
is_valid = True   
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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")
Enter fullscreen mode Exit fullscreen mode

Top comments (0)