0% found this document useful (0 votes)
8 views

Python Basics 1

Python basics definitions theory

Uploaded by

thekrish360
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Python Basics 1

Python basics definitions theory

Uploaded by

thekrish360
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

PYTHON

Python, an interpreted high-level programming language, has


gained immense popularity due to its readability, simplicity,
and wide range of applications. Created by Guido van Rossum
and first released in 1991, Python supports multiple
programming paradigms, including procedural, object-
oriented, and functional programming. This essay explores the
fundamental definitions and theories underpinning Python,
providing a comprehensive understanding of its core concepts.

PYTHON BASICS
Python is designed to be easy to read and write, with a syntax
that emphasizes clarity. This readability makes it an excellent
choice for beginners, while its powerful libraries and
frameworks attract seasoned developers.

VARIABLES AND DATATYPES


In Python, variables are used to store data values. A
variable is created when a value is assigned to it. Unlike
some languages, Python does not require explicit
declaration of the variable type. For example
x=5 # Integer
y = 3.14 # Float
name = "Alice" # String
is_active = True # Boolean
Python supports various data types, including integers
(int), floating-point numbers (float), strings (str), and
booleans (bool). Additionally, Python has complex data
types like lists, tuples, sets, and dictionaries.
Python supports various data types, including integers (int), floating-
point numbers (float), strings (str), and booleans (bool). Additionally,
Python has complex data types like lists, tuples, sets, and dictionaries.

CONTROL STRUCTURES
Control structures in Python allow for conditional execution and
repeated execution of code blocks. The primary control structures are:

Conditional Statements: if, elif, and else statements enable decision-


making in code.

python
if x > y:
print("x is greater than y")
elif x == y:
print("x is equal to y")
else:
print("x is less than y")

LOOPS : for and while loops enable iteration over a


sequence of items or until a condition is met.

for i in range(5):
print(i) # Prints numbers from 0 to 4

count = 0
while count < 5:
print(count)
count += 1
FUNCTIONS AND MODULES
Functions
Functions in Python are defined using the def
keyword. They encapsulate reusable code blocks
that can be called with arguments and can
return values.

def greet(name):
return f"Hello, {name}!"

print(greet("Bob")) # Output: Hello, Bob!


Python supports various types of functions,
including lambda functions (anonymous
functions defined with the lambda keyword),
which are often used for short, throwaway
functions.

You might also like