New OpenDocument Text
New OpenDocument Text
It's
widely used in various fields like web development, data science, and automation. Its syntax is
designed to be similar to the English language, making it beginner-friendly.
Here's a more detailed look at Python:
Key Features and Characteristics:
• Readability:
Python's syntax emphasizes code clarity, with significant indentation to define code blocks,
making it easier to read and understand.
• Versatility:
• Python can be used for a wide range of applications, including web development (server-side),
software development, data analysis, automation, and more.
• Large Community and Libraries:
• Python boasts a large and active community, providing extensive support and a vast collection
of libraries and frameworks for various tasks.
• Dynamic Typing:
• Python is dynamically typed, meaning that the type of a variable is checked during runtime,
rather than at compile time.
• Garbage Collection:
• Python automatically manages memory through garbage collection, simplifying development.
• Interpreted Language:
• Python is an interpreted language, meaning that code is executed line by line, making it easy to
test and debug.
• Object-Oriented, Procedural, and Functional:
• Python supports multiple programming paradigms, including object-oriented, procedural, and
functional programming.
Why to Learn Python?
• Python requires fewer lines of code compared to other programming languages.
• Python is in high demand as it provides many job opportunities in Software Development, Data
Science and AI/ML.
• Python provides popular Web Development, AI/ML, Data Science and Data Analysis Libraries
like Django, Flask, Pandas, Tensorflow, Scikit-learn and many more.
• Python is an object oriented programming language which encapsulates code within object
(OOP organizes code around data and the operations that can be performed on that data, making
programs more modular, reusable, and easier to understand and maintain ).
• Python is cross-platform which works on Windows, Mac and Linux without major changes.
• Python is used by big companies like Google, Netflix and NASA.
Python Tutorial – Python is one of the most popular programming languages. It’s simple to use,
packed with features and supported by a wide range of libraries and frameworks. Its clean syntax
makes it beginner-friendly.
Python is:
• A high-level language, used in web development, data science, automation, AI and more.
• Known for its readability, which means code is easier to write, understand and maintain.
• Backed by library support, so we don’t have to build everything from scratch, there’s probably a
library that already does what we need.
EXAMPLE 2
# Single variable
s = "Bob"
print(s)
# Multiple Variables
s = "Alice"
age = 25
Output
Bob
Alice 25 New York
EXAMPLE 3:
# taking two inputs at a time
x, y = input("Enter two values: ").split()
print("Number of boys: ", x)
print("Number of girls: ", y)
age = int(age_input)
print(type(a))
print(type(b))
print(type(c))
print(type(d))
print(type(e))
print(type(f))
<class 'str'>
<class 'int'>
<class 'float'>
<class 'tuple'>
<class 'list'>
<class 'dict'>
Output Formatting
Output formatting in Python with various techniques including the format() method, manipulation of
the sep and end parameters, f-strings and the versatile % operator. These methods enable precise
control over how data is displayed, enhancing the readability and effectiveness of your Python
programs.
Example 1: Using Format()
amount = 150.75
print("Amount: ${:.2f}".format(amount))
# another example
print('pratik', 'geeksforgeeks', sep='@')
OUTPUT
Python@GeeksforGeeks
GFG
09-12-2016
pratik@geeksforgeeks
Output
Hello, My name is Tushar and I'm 23 years old.
add = num + 5
# Output
print("The sum is %d" %add)