0% found this document useful (0 votes)
4 views2 pages

Python Class 9

Python is a high-level, interpreted, and object-oriented programming language created by Guido Van Rossum in 1991. It features platform independence, simplicity, and ease of learning, making it suitable for beginners. Python operates in two modes: Interactive Mode for one command at a time and Script Mode for executing saved code, and it utilizes tokens, keywords, literals, variables, and operators for programming.

Uploaded by

manav1209gaming
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)
4 views2 pages

Python Class 9

Python is a high-level, interpreted, and object-oriented programming language created by Guido Van Rossum in 1991. It features platform independence, simplicity, and ease of learning, making it suitable for beginners. Python operates in two modes: Interactive Mode for one command at a time and Script Mode for executing saved code, and it utilizes tokens, keywords, literals, variables, and operators for programming.

Uploaded by

manav1209gaming
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

PYTHON UNIT I

1. Define Python.
Python was created by Guido Van Rossum in Feb 1991. Python is free and open-source, high-
level, interpreted, dynamic, object oriented programming language that supports GUI programming.

2. What are the popular features of Python?


 It is a platform independent programming language.
 It is a very simple high level language with vast library of add-on modules.
 It is excellent for beginners as the language is interpreted, hence gives immediate results.
 It is easy to learn and use. Programs in Python are easily readable and understandable.

3. What are the two modes of Python?


Interactive Mode
Interactive mode of working means you type the command  one command at a time, and the
Python executes the given command and gives you Output. Working in interactive mode is
convenient for beginners and for testing small pieces of code. In this mode, user type the command
in front of Python command Prompt (>>>).

Script Mode
In script mode, the Python program is written in a file and then interpreter is used to execute the
content from the file. When there is coding more than few lines, one should always save code so
that one may modify and reuse the code.

4. What do you mean by Tokens?


The smallest individual unit in a program is known as tokens or lexical units. Python has following tokens:
a) Keyword b) Identifiers c) Literals d) Operators e) Punctuators

5. Define Keyword.
Keywords are the words that convey a special meaning to the language. These are reserved for special
purpose and not be used as normal identifier names. Example
and del from Not or with for
assert else if Pass yield break Input
except import print Class exec in try
raise continue finally Is return def

6. Define Literal.
Literals are data items that have fixed value. Python allows several kind of literals:
String literals Numeric literals Boolean literals Special literal

String Literals: The text enclosed in single or double quotes is a string literal. “Akshat” ‘Mannat’

Numeric literals: The numeric literal in python can belong to any of the followings:
int These are the +ive or –ive whole numbers with no decimal point. e.g. 34, 890, -99
float These are the real numbers and are written with a decimal point. e.g. 34.5, 890.889, -99.9

Boolean literals: A Boolean literal can either have value as True or False.

Special literal: Python has one special literal, which is None. The None literal is used to indicate
absence of value.

Class IX 1 Palvinder Singh [9811546114]


7. What do you mean by Variable?
A Variable represents named location that refers to a value and whose value can be used and
processed during program run. Every variable has:
An It is the variable's address in memory and does not change once it has been created.
identity It can be known using id (variable). We can say it lvalue of a variable.
A type It means the data type of a variable and it can be checked using type () function.
A value Value stored in a variable. We can say it rvalue of a variable.

8. How to assign same value to multiple variables?


a=b=c=10
It will assign value 10 to all three variables a,b,c.

9. How to assign multiple values to multiple variables?


a,b,c=10,20,30
It will assign values orderwise like 10 to a, 20 to b and 30 to c.

10. How to swap two or more values?


a,b=b,a
It will interchange the values of a and b.

11. What are the rules for Naming a variables?


A Variable name:
1) Can be of any size.
2) Allows characters, which are a-z, A-Z, 0-9 and underscore (_).
3) Should begin with an alphabet or underscore.
4) Should not be a keyword/reserved word.

Some Valid Variable name Some Invalid Variable name


Myfile ROLL-NO contains special character(-)
Date9_9_77 29CLCT starting with a digit
_DS break reserved word
z3456 [Link] contains special character(.)

12. What do you mean by Operators and Operands?


Operators are special symbols which represents computation. They are applied on operand(s),
which can be values or variables.
 OPERATORS: These are the special symbols. e.g.- + , * , /, etc.
 OPERAND: It is the value on which the operator is applied.

Class IX 2 Palvinder Singh [9811546114]

You might also like