Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
160 views

Python Assignment

This document contains the solved assignments for Class 11 Computer Science subject. It includes questions on Python features, data types, operators, expressions, programs to calculate compound interest. For example, question 1(d) asks to write a program that takes two names as input and prints a greeting message. Question 3(c) provides a program to take principle, rate and time as input and calculate compound interest.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
160 views

Python Assignment

This document contains the solved assignments for Class 11 Computer Science subject. It includes questions on Python features, data types, operators, expressions, programs to calculate compound interest. For example, question 1(d) asks to write a program that takes two names as input and prints a greeting message. Question 3(c) provides a program to take principle, rate and time as input and calculate compound interest.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

KENDRIYA VIDYALAYA SANGATHAN

SOLVED ASSIGNMENT

CLASS – XI

SUBJECT - COMPUTER SCIENCE (Answer Key)

Q1. (a) Write any four features of Python.

Ans: 1. It is platform independent

2. Used as both scientific and non-scientific programming language

3. It is open source language.

4. It is extensible language.

5. It has very vast library of add-on modules.

(b) What are the two ways to use Python interpreter?

Ans : 1. Interactive mode

2. Script mode

(c) Write any four basic numeric data types used in Python.

Ans: 1. Int 2. float 3. Complex number 4. Boolen

(d) Write a program that asks two people for their names; stores the names in variables called

Name1 and Name2; says hello to both of them

Name1 = raw_input(“Enter First Name : ”)

Name2 = raw_input(“Enter Second Name : “)

print “Hello “, Name1, “ and “, Name2

Q2 (a) What are the rules for naming an identifier.

Ans: 1. Identifiers may have letters A-Z, a-z, numbers 0-9 and _ (underscore).

2. Must begin with a letter or underscore but not with digit.

3. keyword can not be used as identifier.

4. it is case sensitive i.e. upper case letters and lower case letters are different

(b) Write any two-assignment statement to assign float and string value.

Pi = 3.14

School = “KV Dongargarh”


(c) What are different arithmetic operators used in Python?

Ans: Arithmetic Operators

1. + - Addition

- - subtraction

* - multiplication

/ - division

** - Exponentiation

% - Modulus

// - integer division (floor value)

(d) Write the precedence of operators used in Python. 4

Precedence of operator - Listed from high precedence to low precedence .

Operator Description
** Exponentiation (raise to the power)
+,- unary plus and minus

* , /, %, // Multiply, divide, modulo and floor division


+,- Addition and subtraction

<, <=, >, >= Comparison operators


==, != Equality operators

% =, / =, // = , -
Assignment operators
=, + =, * =
not and or Logical operators
Q3 (a) Write
the following expressions using operators used in Python:

a+ b
(i) c= (ii) x = a 3 + b3 + c3
2a

−b ± √ b2−4 ac
(iii) A=π r ( r+ h)2 (iv) x=
2a
Answer: 1. c = (a + b) / (2 *a)

2. x = a**3 + b**3 + c**3

3. A = math.pi * r (r + h) ** 2 or A = 3.14*r (r +h) ** 2

4. x = (-b + math.sqrt(b*b – 4 * a * c)/ (2 *a )

(b) Evaluate the following expression with precedence of operator:

X = 2* 3/ 5 + 10 //3 - 1
Ans: 3

(c) Write a program to input values for Principle, rate and Time and calculate compound interest.

Ans: p = input(“Enter Principle : “)

r = input(“Enter rate : “)

t = input(“Enter time : “)

A = p * (1 + r/100.0) ** t

CI = A – p

print “Compound interest = “, CI

(d) What will be the output of the following code:

A = 3 – 4 + 10

B=5*6

C = 7.0/2.0

D = “Hello” * 3

print “Values are :“, A. B, C, D

Ans: Values are : 9 30 3.5 HelloHelloHello

You might also like