Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
7 views6 pages

New OpenDocument Text

Python is a high-level, versatile programming language known for its readability and ease of use, making it suitable for web development, data science, and automation. It features dynamic typing, garbage collection, and supports multiple programming paradigms, backed by a large community and extensive libraries. Learning Python opens up numerous job opportunities and allows for cross-platform development, with major companies like Google and Netflix utilizing it.

Uploaded by

vu1f2223022
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views6 pages

New OpenDocument Text

Python is a high-level, versatile programming language known for its readability and ease of use, making it suitable for web development, data science, and automation. It features dynamic typing, garbage collection, and supports multiple programming paradigms, backed by a large community and extensive libraries. Learning Python opens up numerous job opportunities and allows for cross-platform development, with major companies like Google and Netflix utilizing it.

Uploaded by

vu1f2223022
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 6

Python is a high-level, versatile programming language known for its readability and ease of use.

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.

Input and Output in Python


Taking input in Python
Python input() function is used to take user input. By default, it returns the user input in form of a
string.
Example:
name = input("Enter your name: ")

print("Hello,", name, "! Welcome!")

Enter your name: GeeksforGeeks


Hello, GeeksforGeeks ! Welcome!

EXAMPLE 2

# Single variable

s = "Bob"

print(s)

# Multiple Variables

s = "Alice"

age = 25

city = "New York"

print(s, age, city)

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)

# taking three inputs at a time


x, y, z = input("Enter three values: ").split()
print("Total number of students: ", x)
print("Number of boys is : ", y)
print("Number of girls is : ", z)

Enter two values: 5 10


Number of boys: 5
Number of girls: 10
Enter three values: 5 10 15
Total number of students: 5
Number of boys is : 10
Number of girls is : 15

Take Conditional Input from user in Python


In this example, the program prompts the user to enter their age. The input is converted to an integer
using the int() function.
# Prompting the user for input

age_input = input("Enter your age: ")

# Converting the input to an integer

age = int(age_input)

# Checking conditions based on user input


EXAMPLE:
if age < 0:
print("Please enter a valid age.")
elif age < 18:
print("You are a minor.")
elif age >= 18 and age < 65:
print("You are an adult.")
else:
print("You are a senior citizen.")

Enter your age: 22


You are an adult.

Print Numbers in Python


# Taking input as int
# Typecasting to int
n = int(input("How many roses?: "))
print(n)

Print Float/Decimal Number in Python


# Taking input as float
# Typecasting to float
price = float(input("Price of each rose?: "))
print(price)

Find DataType of Input in Python


a = "Hello World"
b = 10
c = 11.22
d = ("Geeks", "for", "Geeks")
e = ["Geeks", "for", "Geeks"]
f = {"Geeks": 1, "for":2, "Geeks":3}

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

Example 2: Using sep and end parameter


# end Parameter with '@'
print("Python", end='@')
print("GeeksforGeeks")

# Seprating with Comma


print('G', 'F', 'G', sep='')
# for formatting a date
print('09', '12', '2016', sep='-')

# another example
print('pratik', 'geeksforgeeks', sep='@')

OUTPUT
Python@GeeksforGeeks
GFG
09-12-2016
pratik@geeksforgeeks

Example 3: Using f-string


name = 'Tushar'
age = 23
print(f"Hello, My name is {name} and I'm {age} years old.")

Output
Hello, My name is Tushar and I'm 23 years old.

Example 4: Using % Operator


We can use '%' operator. % values are replaced with zero or more value of elements. The formatting
using % is similar to that of ‘printf’ in the C programming language.
• %d –integer
• %f – float
• %s – string
• %x –hexadecimal
• %o – octal
# Taking input from the user
num = int(input("Enter a value: "))

add = num + 5

# Output
print("The sum is %d" %add)

Enter a value: 50The sum is 55

You might also like