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

Adobe Scan Feb 20, 2025

The document provides a comprehensive guide on downloading and installing Python version 3.10.5, along with an introduction to its features, including the Interactive Development Environment (IDLE) and basic programming concepts such as literals, operators, data types, and functions. It also includes examples of using input and print functions to interact with users and perform calculations. The document serves as a foundational resource for beginners to start programming in Python.

Uploaded by

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

Adobe Scan Feb 20, 2025

The document provides a comprehensive guide on downloading and installing Python version 3.10.5, along with an introduction to its features, including the Interactive Development Environment (IDLE) and basic programming concepts such as literals, operators, data types, and functions. It also includes examples of using input and print functions to interact with users and perform calculations. The document serves as a foundational resource for beginners to start programming in Python.

Uploaded by

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

pWNLOADINGPYTHON

athoncomes in three versions: version 1.0, version 20 and version 30 Many series are
nlable
in
these
versions. In this chapter,
we are using
and go to the version 3.10
The following
foll
official website https //www python og/downloads/ and press
page appears in your
Fnter
key
browser
Python
1 Click on Download
3.10.5.

PPython Doate

Abou Docurnetation Comunity Bucess Sors


nHnloadthelatest version for Windows

wnoe

esetup of Python starts to download on your computer in Downloads folder

NSTALLING PYTHON
downloading, next step is to install it in your computer.
1. Open Downloads folder and double-click
on Python program icon
Installation process starts and Python Setup
dialog box appears

2. Click on Install Now.


Install Python 3.10.5 (64-bit)
Seliect lstNow t0 instal Pythcon eth defut settings or cheose
Custoa te enatle or disabie feutures
Setup Progress shows the installing process as
shown below.
instal No
Cuherdrta ApputocafPcgemPyhPythonio
an doeuetatnny
aon 105 (54-r Senue

Setup Progress
’ Customize instsllatson
Chensr lacun and feures

ngtaling
ingljndher for# uers (reomnended
Pthon 105 s Sert 4 b
CAdd Pthon310 to PATH
IT
PLANET

Setup was successful pythón -


windows (CODE 6
and
ew te Pyhon? Start with the pkor sRA
AE At yout terming tyoe 'oy elauneh Pyhen

When the installation process finishes, Setup was


successful appears AI)
Dsatle oatty iersgths larrt 3. Click on Close button

121
GETTING STARTED WITH PYTHON
WriteCode in Interactive Mode window:
will getthis
Afier installing, when you open Python, you
X

A DLShel 105
1929 64 b
: 13) (MSC v.
(le Ldit Shell Debuo
Options Window Help
Jun 6 2022, 16:14
10.5:f37 7153,
Tytho 310.5 (tags/v3. information.
1 (AMD64)| on win32 "redits" or "license () " for more
"copyj ght ".,
Vpe "he lp",

of Python's integrated development An environment.


This is the Python shell, which is partEnvironment (IDLE) is the most popular graphice k n
Integrated Development and Learning easy to create, edit and debug a program
inu
Python. It is
development environment for
environment.
snows the welce
window is called Interactive mode. The Interactive mode screen
This called the prompt.
with version details and the three greater-than signs (>>>) This is a
message
interpreter is executing the Python statements. All
primary prompt
statements, which indicates that
expressions or commands are written after the primary prompt in the Interactive

mode.
Python" at the prompt and press Enter key.
Let us enter a statement "Welcome to
>> print ("Welcome to Python")

IDLE Shell 3.105*


Eile Edit She<l Debug Options Window Help
Python 3.10.5 (tags/v3. 10.5:f377153,
AMD64) ) on win32
Type "help", "copyright", "credits"
>>>print ("Welcome to Python") Update Your Knowledge
You should always enclose string in single ()
or double (" ") quotes when you use it with
print()) function.
A IDLE Shell 3.10.5

File Ed1t Shell Debug Options Window Help


LTD. Python 3.10.5 (tags/v3. 10.5:f377153,
AMD64)) on win32
PVT. Type "help", " copyr ight", "credits"
|>>>print ("Welcome to Python ")
PUBLISHERSWelcome to Python
|>>>

PM The prompt (>>>) reappears to tell you that the Python shell is ready to accept more comman0.
In the above program, the print() is a type of Python command called afunction, and it pe
out whatever is inside the quotes to the screen.

122 Great! You have just created your first Python program.
keywords are:
Me
of the
True False
None and
assert def class
Contintue break
else finally elif del
ecept
global for if
from import
raise try return pass
nonlocal in not
lambda

ITERALS

data
Items that never change their value throughout the prograrm run are called literals
the
heoretically,literal means any number, text or other any informat1on that represents a value
supportsthe following literals:
ython
Literals Examples
Stringliterals "hello", '12345'
integerliterals 0, 1, 2, -1, -2
Floating-point literals 3.14, 2.05
Boolean literals True or False

OPERATORS
arithmetic and iogical computations The values
Onerators are the special symbols that carry out
are many types of operaiurs in Python like
nnerated by the operator are called operands. There
this chapter, we will learn about Arithmetic
Arithmetic, Relational, Logical, Assignments, etc. In
operators.
ARITHMETICOPERATORS
mathematical operations.
Arthmetic operators are used to perform
Example
Operator Meaning >>> 200+45
Addition and Concatenation in Strings
245
>>> "Good' + "+"Morning
Good Morning
>>> 100-20
Subtraction
80
>>> 80-160
80
Replication in Strings 20
Multiplication and

ovthonvthonov
>>> 284
70
Division
>>> 50/5

33333B4
>>> 20//4
Floor Division/Integer Division
>>> 50/6

>>> 679%9
% Modulus/Remainder
>>> 8**2
Exponentiation 64

Lines and Indentation


and indentation
particular about program layout, especially regarding lines
Python is very line may end wn ;
up of one or more physical lines Each physica
A Python program is made comments are ignored by Python.
comment. The text written in the
is an emot.
indentation to express the block structure of a program. An indentation
Python uses braces
beginning of block of code. Unlike other languages, ython does not wse
space at the way to denot
of statements; indentation is the oniy
other beginning/end symbols around blocks
blocks.

Comments
in any language. Thev are used to exD3
Comments are very important while writing a program
interpreter ignores the text written in
Python code and make it more readable. Python
comment. Python supports the following comments in a program.
SINGLE LINE COMMENTS
Python uses hash symbol (#) for writing a single line comment.
Examples:
>>> #This is the start of program This is a single line comment
>>> #print hello in Python This is a single line comment
>>> print ("Hello") This is a statement
TILINE
COMMENTS
USestriple quotes or
for multi-line comments.

example of
is an
" This
multi-linecomments"

satements
statement0S an instruction that the Python interpreter can execute. When
atementonthe IDLE, Python executes it and displays the result. you type o

Example: >>> num1=10 # This 1S Statement


>>> num2 =20 # This is statement
add=num1+num2 # This is Statemen.

pata Types
used to define the type of value a data can contain. It represents what kind of
Datatype IS
peration can be done on a particular data. Data types define the way to store values in the
memory.

NTEGER
without decimal point such as 1000,
ntegers are the whole numbers consisting of + or - sign
8, etc.

Example: >>> a=12 # This is a positive integer val ue


>>> b=-20 # This is a negative integer value

ELOAT
example,
represents floating point numbers which contain decimal point. For
iOat data type
05, -4.567, 0.001, etc.
This is a float value
>>> a=12.5 #
Example: integer value
>>> b=12 # This is an

SIRING (alphabets, numbers, operators and


punctuation) used to
String is a Sequence of characters
information. Single quotes ( ) and double
quotes (" ") are
and represent text-based
represent strings in Python. name
Stores a string
name="seema "
Example: 'seema @123'
>>> password=
Variables
memory. The data can be numbers. text and/or
Variables are used to store data in the whenever it is needed.
The data is given a name, so that
INITIALIZING VARIABLE
it can be re-called
objects.
Initializing a variable means to assign a value in it.
an assignment operator
For example, to create a variable named num, we use (=) and
Python what information the variable should be hold. then tell
Here, we initialize a variable num with value 100.
initialize With
num =
100 here num the value 100
To find out what value a variable hold, enter print in the shell, followed by the
variable
parentheses, Ilike this: name in
print (num)
200 here print displays the result
We can also use more than one variable for the same item.
num 1 =
100
num2 num1

print (num2 )
103

in this example, we are telling Python that we want the variable num2 to initialize the s.
value as num1 by using the assignment operator (=) between num2 and num1.
You can also write variables like total_marks.
>>> total marks =
500
>>> print (total marks)
500

This example shows that we are talking about 500 marks.


Variable names can be made up of letters, numbers, and/or the
LTD. they cannot start with a number. They also underscore character ), but
cannot use reserved keywords.
Note: Variable name must have an identifier.
PVT.
PUBLISHERS
Defining Input and Qutput Function
An input() and print() functions are used for
in Python. An
PM input() function is used to get input from user.standard input and
This function helps user operations
output to input the values and
text for the operation. An
input() function always returns string
Syntax: value.
variable_name = input("String")
128 Here
variable_name means any name (identifier) where input() function assigns the value
intoit
function is 1sed to print the value of givern
printy input alue or string It helps t0
onscreen. Snow

print(String/
/Variable/Constant)

PythonIDLE in interactive mode and type the following

Variable Function Pre-defined string


/pre-input text
>>> name=input("Enter Your Name : ")
Enter Your Name :Akash

Output
User input
.e Purple color shows Functian nome Green color shows the Stting Blue
shows the Output and Black color shows the Vargble gnd Use npu

ROGRAMS TO UNDERSTAND INPUT() AND PRINT)


rogram 1

rogram to get your name, age and then print it.

le Edit Format Run Options Window Help 1 Create a new file in Python
Script Mode
me=input ("Enter your Name:") 2 Type the given code
age=input ("Enter your Age:") 3 Save and Run the module
pILnt (name) By default IDLE saves the Python iie
pIint (age) with .py extensIon

cKinB on Run module, interactive mode appears with the pre-input text Enter your Name

4. Type your name


Lnter your Name Akasp
Enter your Age :13 5 Press the Enter key

Akash Now, next pre input text Enter your Age appears
13 6 Type your age
7 Press the Enter key

the output
print() function shows the entered name and age as
using int() function
two numbersconverts
Program2 sum of the entered value into
printthe function
Program to input() function. but could not use for the
As
discussed
only be
used
earlier, the print()
to print
using
with an
example. calculation purstrpinose.B, which coua
it
understand Mode Output in
Enter Interactive
in Script
Let us Source Code e
Window Help
Qptions Enter First Mode
Eile Edit
numl=input
format Bun Flrst Nmber ")
("Enter
ter
Number ")
Second
2030 Second Nunber
Nunbe 20 r
30
nun2=input ("n
sum=num1+num2
print(sum)
of 20 and 30 shows 2030 as
the sum
operator concatenatesthe
code,
the source function and the 4'
When you run
converted into string
using
calculation
input()
between these
value, vou need to convert the
(ienteorediginvs)enbotvalhuevalugete:
Now, to show
into integer
function.
using int() string value:
Using Int()
Source Code in Script
Mode Output in Interactive Mode
Options Window Help Enter First Number 20
|Eile Edit Format Run Enter Second Number 30
First Number "))
num1=int (input ("Enter 50
Second Nmber "))
num2=int (input ("Enter
sum=num1 +num2
print (sum)

in the above program, when you run the source code, the Sum of 20 and 30 shows 50 28 the
given value converts into integer using int() function so operator performs the additn
between entered values.

Note: You can also convert string into decimal value, using float() function.

LTD.
PVT.
Self-Evaluation ABree isagree
CHECKLIST
Disag,

After
PUBLISHERS reading the chapter, I know these points:
Tknow that token is the smallest element of a program that is meaningtul to the
interpreter.
I know
W that
operators are special symbols that carry
computations. out arithmetic and logical
I know
that data types
Iknow that
define the type of value a data can
variables are used to store contain.
Iknow that data in the
input() and print() memory.
functions
are used to get input and display output.
EXercises
the correct
(1
fick
answer.
python keywords contain
Al/

lowercase b \etters eCept True, False arnd


are the uppercase tione
special symbols that carry entenc4 cae
a. Literals out
b. Operators arithrnetit and Iogical
values operated
Theva by the
operator are
called
. Identfer orriputation:
a. constants
operands
define the way to store the .. literals
a. Statements b. Variables
values in memory
Write 'T' for True and 'F for C. Data types
False statements.
Pythonis named after Monty
1.
Python interpreter never
Python's
Flying Circus, a comedy prograrm
2. ignores the text written in
cormment.
3. Singgle quotes (' ') and double quotes ("")are used to
initializing a variabie means to assign a value in it represent strings in Python.
: Inout ) function always returns string value
Fill in the blanks.
1. We can also press key to run a progran.
2. are the reserved words in Python.
3 are the data items which never change their value
throughout program run.
4. Python uses to express the block structure of a program.
5 When we type a in IDLE, Python executes it and displays the result.
Define the following.
1. Token:

2. Operator:

3. Comments:

Differentiate between the following.


Literals
Kevwords
sentences.
Answer in 1-2
F. when?
developed Python and
1. Who

identifier?
you mean by
2. What do

variables?
3. What are

?
understand by line and indentation
4. What do you

G. Answer briefly.
Explain in detail.
1. Howmany data types are used in Python?

2. Define input() and print() functions of Python.

H. Application-based Question Problem Solving Skill


Riya has written a program in Python in which she has used input function for
giving input value of a variable. After executing the program that
value is a
string, not a number. She wants to convert this string into a number. By which
function can she do so?
Animation

Group Discussion
Divide the students into two Function for
Calculation'. groups and discuss the topic - 'Importance of int/)

Online Link
To learn more about
Python programming, visit the website:

You might also like