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

Class Xi - Python Fundamentals Notes

The document provides an introduction to Python, highlighting its open-source, object-oriented nature and versatility for various programming tasks. It discusses the advantages and disadvantages of Python, as well as how to interact with it using IDLE and basic functions like input() and print(). Additionally, it covers the concept of variables, their components, and dynamic typing in Python.

Uploaded by

ankitraj88094
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)
78 views5 pages

Class Xi - Python Fundamentals Notes

The document provides an introduction to Python, highlighting its open-source, object-oriented nature and versatility for various programming tasks. It discusses the advantages and disadvantages of Python, as well as how to interact with it using IDLE and basic functions like input() and print(). Additionally, it covers the concept of variables, their components, and dynamic typing in Python.

Uploaded by

ankitraj88094
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/ 5

5.

Getting started with Python


Introduction to Python

• Python is an open-source, object oriented, high level


programming language developed by Guido Vann Rossum in
1991 at National Research Institute for Mathematics,
Netherlands. It is presently owned by Python Software
Foundation (PSF).
• It is a general purpose programming language that can be
used effectively to build different kind of programs such as
System Programming, GUI Programming, Gaming, Web
scripting, commercial robots and for scientific applications
also.

Advantages of Python

• Easy to use
• Expressive Language
• Interpreted Language
• Cross-Platform Language
• Free and Open source Language

Disadvantages of Python

• Not the fastest Language


• Lesser Libraries than Java and C
• Not easily convertible to other languages

Interacting with Python


Python IDLE:-
• IDLE stands for Integrated Development Learning Environment.
It is a program that allows the user to edit, run, browse and
debug a python program from a single interface.
• The popular Python IDLEs available are Spyder IDE, PyCharm
IDE, Python IDLE (default installation available from
www.python.org) etc.
• The Python IDLE comprises Python Shell(Interactive mode) and
Python Editor(Script mode)
• Python Shell (Interactive mode), which is a part of Python’s
IDE. In which there is a symbol >>> called prompt, and
instructions are given in front of this prompt gets executed and
shows the result there itself.
• In Python Editor (Script mode) instructions are stored in a file
generally with .py extension and are executed together in one
go as a single unit. These saved instructions are known as
Python Script/Program.

input () function in Python


In Python, To get input from the user interactively, we can use the
built-in function input ().
Syntax:-
<Variable-name>=input (“[message to be displayed]”)
The input () function always returns a value of String type. But string
values cannot be used for numeric operations.
So to input numeric values, Python offers two functions int() and
float() to be used with input () to convert the values received
through input () function.
Syntax:-
Variable-name=int(input(“<message>”)) # convert the value to
integer
Variable-name=float(input(“<message>”)) # convert the value to
floating point number (decimal no.) print () function in Python

To print or display the output, python provides print () function with


the following syntax:- print (value1, value2, value3,-------,sep=’
‘,end=’\n’) where,

sep: The sep parameter of the print() function is used to specify the separator
between the values. The default value of sep parameter is space. (‘ ‘)

end: The end parameter is a useful feature of the print() function in Python
that can be used to control the formatting of output in various ways. The
specified string will be appended after the last value in the print ().The default
value of end parameter is newline. (‘\n‘).

Variables
A variable is a named storage location whose values can be used and processed
during the program run.
Eg: >>>x=3
>>>y=4
>>>z=x+y
>>>x=y
>>>y=5
A variable has three main components:-
1. Identity of the variable
It refers to the address in the memory which does not change once it
has been created. The address of a variable can be checked using the function
id().

Syntax:-
>>>id (variable name)

Eg:- >>>x=100
>>>id(x)
1614996384; which is the address of memory location storing the value 100.

2. Type of the variable


The type of the variable determines the data type of it.
Data type refers to the type of the data associated with a variable.
The function type() determines the data type of a variable.
Syntax:-
>>>type (variable name)
Eg: >>>x=100
>>>type(x)
‘class int’
>>>y=100.5
>>>type(y)
‘class float’
>>>z=’haai’
>>>type(z)
‘class str’
3. Value of the variable
To bind value to a variable, we use the assignment operator (=). This
process is termed as building of a variable.
The concept of assignment operator can be explained as:

➢ There should be one and only one variable on the left hand side of the
assignment operator. This variable is called Left-value or L-Value ➢
There can be any valid expression, literal or variable on the right hand
side of the assignment operator .This expression in called the
Rightvalue or RValue.

➢ The statement L-Value=R-Value is the assignment statement.


Dynamic Typing
A variable pointing to a value of certain type can be made to point to a value of
different type. This is called Dynamic Typing.
For Example:
x=100
print(x)
x=”Hello”
print(x)

Above code will give the o/p as


10
Hello
Here the variable x is first pointing to an integer 10 and then pointing to a
string value that is “Hello”. This feature is called Dynamic Typing.

You might also like