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

Class 7 CH 7

it lecture notes

Uploaded by

digitechrise
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)
146 views

Class 7 CH 7

it lecture notes

Uploaded by

digitechrise
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

7 Introduction to Python

TUK Activity (Page No. 123)


Fill in the blanks.
general purpose high level programming

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
_________________________________.

TUK Activity (Page No. 130)


Try some programming codes.
AT
IC
1. Write a program to accept two numbers. Now swap the
numbers and display them after swapping.
a = int (input ( "Enter first number" ))
BL

b= int (input ( "Enter second number" ))


c= a
a= b
PU

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

a = int (input ( "Enter a number"))


TU

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

False. != operator check whether the values of two operands


___________________________________________________________________
IC
are not equal to each other.
___________________________________________________________________
3. 5.486 is an example of int literal.
False. 5.486 is an example of floating point literals.
___________________________________________________________________
BL

4. Script mode executes command and gives output immediately.


False. Interactive mode executes command and gives
___________________________________________________________________
output immediately.
___________________________________________________________________
PU

(C) Tick (✔) the correct answer.


1. ______________ menu consists of options like cut, copy and paste.
a) file b) ✔ edit c) help
K

2. What do you call the predefined words of a programming


language?
TU

a) delimiter b) variable c) ✔ keywords


3. Which operators are used to work on numeric values?
a) ✔ arithmetic b) relational c) logical
4. Which data type represents decimal numbers?
a) int b) ✔ float c) str

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

2. What do you understand by interactive mode in Python?


Ans. In the interactive mode of Python, the instructions are
executed line by line to give the output. The Python
interactive interpreter makes it easy to check Python
commands in this mode. Follow the process given below,
K

to work in the interactive mode:


i. Click on the Start button All programs
TU

Python 3.7 IDLE (Python 3.7).


ii. It will open the python shell window where the python
prompt can be seen(>>>).
iii. Type the following commands next to the python
prompt and the Python will immediately give the output.

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

ii. Boolean (bool)- It represents logical values in the form


of true and false. In Boolean, 0 represents false and 1
represents true.
Float: It represents floating point values, which means
PU

numbers with fractional parts. The fractional part of a floating


point number may be 0 as well. Examples of floating point
numbers are 3.14, -48.6,18.0, etc.
Str(String): A string datatype represents strings of
characters enclosed within quotation marks (“Or”).
K

Example of strings are, “Welcome”, 'hi', '312','India', etc.


TU

(E) Answer in short.


1. Write a short note on Python.
Ans. Python is a general-purpose high-level programming
language. It allows programming in procedural and
Object Oriented programming paradigm. Python
programs are generally smaller than other programming
languages.

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

iii. Logical Operators


4. What do you understand by installing Python?
Ans. Installing Python means downloading Python Executable
PU

Installer and running it, so that Python IDE is ready to


execute the Python code.

(F) Application based questions


K

1. Raman is writing a program to enter and display the names and


weights of the students. Suggest him which data type he should
TU

use for weight.


Float
___________________________________________________________________
2. Savita wants to write a program to check whether a number is
even or odd. Which operator will help her to find the remainder?
% modulas operator
___________________________________________________________________

Computer-7

You might also like