0% found this document useful (0 votes)
3 views5 pages

Python Into

Uploaded by

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

Python Into

Uploaded by

23wh1db013
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Python-Introduction:

What is Python?
Python is a high-level, interpreted, and general-purpose programming language.
Here, High level means : language that is similar to English, making it easier for humans to
read and write.

It’s called interpreted because you don’t need to compile it before running — you just write
and execute your code, and Python interprets it line by line.

Python reads and executes your code line by line, like how you read and follow a recipe
one step at a time , no need to “compile” it first like C or Java.

Python is a high-level, easy-to-learn programming language that is widely used for web
development, data science, artificial intelligence, automation, and software development.

Why Learn Python?

 Simple syntax: Easy to read and write.

 Versatile: Used in many fields such as web development, machine learning, and
data analysis.

 Large community: Thousands of libraries and tutorials are available.

 Cross-platform: Runs on Windows, macOS, and Linux.

Why do we need Python?

● It is simple and beginner friendly.


● It is a cross platform (i.e. it works on windows,Mac, Linux)
● It is an open source
● It can be used in various domains like: Machine learning, Web development, Data
science, Cyber Security, Game development, IOT.

Advantages of Python:

● Easy to learn and read.


● Interpreted language
● Cross Platform
● Open source
● Extensive libraries like Numpy,Pandas,Matplotlib
● Versatile
● Works well with C,C++,Java i.e. Integration Friendly

Who uses Python?


Google,Netflix,Youtube,Instagram,NASA,Tesla,Amazon,Reddit,Spotify.

Real Life Use Cases :

● Machine Learning and AI : Predicting diseases, chatbots, face recognition, hate


speech detection.
● Data Science and Analytics : Analyzing sales data, predicting stock prices.
● Web development : Building websites using frameworks like Django or Flask.
● Automation / Scripting : Automating emails, cleaning files, downloading data
automatically.

● Learn the difference between print ( total ) and print ( “ total “ )

print(total) → prints the value stored in the variable total

print("total") → prints the text total literally

total=23

print(total)

print("total")

Comments in python :

# Single line comment

""" This is a multi-line comment

and will not be printed """

Variables and Data types:

Variables : Variables are the names that are used to store data in memory.

name = "Ram"

age = 45

height = 6.2
is_student = False

print(name, age, height, is_student)

● Check data types of the following variables

print(type(name))

print(type(age))

print(type(height))

print(type(is_student))

Common Data types:

String -> str -> “Ram” # text

Integer -> Int -> 45 # whole value

Bool -> True/ False #logical value

Float -> 3.14 # decimal number

Taking Input from user :

● By using the input() function we can take input from the user.
● By default input() type is string.
● Using split() we can take multiple inputs at once in python.

age=input()

print(age)

print(type(age))

But to use it as a number:

age=int(input())

print(age)

print(type(age))
Basic Arithmetic Operations:

+,-,*,/

// (floor division) : divides a by b and then rounds down to nearest whole number

% (modulus) : returns the remainder.

** (power) : a**b i.e. 2**2 is 4

a = 10

b = 3

print("Add:", a + b)

print("Sub:", a - b)

print("Mul:", a * b)

print("Div:", a / b)

print("Floor Div:", a // b)

print("Remainder:", a % b)

print("Power:", a ** b)

Your First Python Program

print("Hello, World!")

Output:

Hello, World!

The print() function displays text on the screen.

Variables

Variables store data.

name = "Alice"
age = 20
height = 5.6
print(name)
print(age)
print(height)

Data Types

Python has several built-in data types:

name = "John" # String


age = 25 # Integer
price = 19.99 # Float
is_student = True # Boolean

Taking User Input

name = input("Enter your name: ")


print("Hello,", name)

Basic Operators

a = 10
b=3

print(a + b) # Addition
print(a - b) # Subtraction
print(a * b) # Multiplication
print(a / b) # Division
print(a % b) # Modulus
print(a ** b) # Exponent

You might also like