Class 7 CH 7
Class 7 CH 7
S
1. Python is a ____________________
language.
N
2. Script Area is the area where you type your codes.
_____________
3. interactive mode, Python executes one command at a
In _____________
IO
time.
4. We can download Python for free from the website
www.python.org/download
_________________________________.
b= c
print ( "New Value of variable a" + a)
print ( " New Value of variable b"+b)
2. Write a program to accept a number. Calculate and display its
square and cube.
K
b=a*a
c=a*a*a
print ( "The number is"+a)
print ( "The square is"+b)
print ( "The cube is" +c)
Computer-7
Exercises
(A) Fill in the blanks with the help of the hints.
boolean values as input.
1. Logical operators take ___________
Script mode we can write and execute a Python program.
2. In _________
program is collection of instructions to perform a specific
3. A ____________
task.
S
Delimiter symbol performs grouping, punctuation and
4. ____________
assignment/binding of object to name.
N
(B) State whether these statements are True or False. Correct the
IO
False statements also.
1. print() function is used to accept a value from user.
False. input() function is used to accept a value from the user.
___________________________________________________________________
equal or not. AT
2. != operator checks whether the values of the two operands are
Computer-7
(D) Answer the following questions.
1. Describe print() and input().
Ans. print() function: The print() function is used to display
output in Python. The output can be a string or evaluated
value of any command or expression.
Ex. print (“How are you”)
S
will give output
How are you
N
Ex. print (78)
will give the output
IO
78
Ex. print (“3+4”)
will give the output
7
AT
input() function: The input() function in Python accepts
input from the user, but only in the form of string values,
which should be converted in int or float values using int()
IC
or float() respectively.
Ex. num=int(input(“Enter number”))
will prompt user to enter a number with the given
BL
message.
>>>Enter number__
Value entered by user will convert into int type because of
int() function used with input().
PU
Computer-7
3. Write some features of Python.
Ans. The important features of Python:
i. Python is easy to understand and to learn for beginners.
ii. Python interpreters are available for many operating
systems.
iii. Python is a multi-paradigm programming language.
(Procedural and Object Oriented)
S
iv. Its formatting is visually uncluttered, and it often uses
English keywords.
N
v. The simple and easy to learn syntax of Python
emphasises readability.
IO
vi. It supports modules and packages, which encourages
program modularity and code reuse.
vii. It can be easily integrated with languages like C, C++,
Java etc.
4.
Ans.
AT
Describe different types of data type used in Python.
The basic data types used in Python:
Int (integer): The Int data type represents integer numbers
(numbers without any fractional part). There are two types of
IC
integers in python:
i. Integers- It stores values in the range of -2147483648 to
2147483647.
BL
Computer-7
2. What is a character set?
Ans. Character represents any letters, digits or symbol. It is a
set of valid characters that Python recognises. Python
uses the traditional ASCII character set. Python consists
of the following:
i. Letters: A to Z (Upper case) and a to z (Lower case)
S
ii. Digits: 0 to 9
iii. Special symbols: _ , (, ), [, ], {, }, +, -, *, /, ~, ^, $, <, %, >, #
N
iv. White spaces'\t\n\x0c\r'): Space, tab ( ), new line( )
IO
3. What are operators? Write the names of the different types of
operators.
Ans. An operator in a programming language is a symbol that
AT
tells the compiler or interpreter to perform specific
mathematical, relational or logical operation and
produces final result.
Types of operators used in Python are-
IC
i. Arithmetic operators
ii. Relational Operators
BL
Computer-7