Home >Backend Development >Python Tutorial >Basics of Python in inute

Basics of Python in inute

DDD
DDDOriginal
2024-12-28 20:32:09431browse

Basics of Python in inute

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")

The above is the detailed content of Basics of Python in inute. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn