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

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay