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

Assignment IP Looping, Funbda

This document is an assignment for Class 11 Computer Science focusing on Python programming and looping fundamentals. It includes exercises on evaluating expressions, displaying information, predicting data types, and understanding iteration through code fragments. Additionally, it contains programming tasks to practice various concepts such as calculating profit-loss, generating Fibonacci series, and determining triangle types.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Assignment IP Looping, Funbda

This document is an assignment for Class 11 Computer Science focusing on Python programming and looping fundamentals. It includes exercises on evaluating expressions, displaying information, predicting data types, and understanding iteration through code fragments. Additionally, it contains programming tasks to practice various concepts such as calculating profit-loss, generating Fibonacci series, and determining triangle types.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

CLASS 11th

Computer Science (083)

ASSIGNMENT Looping / Fundamentals


Introduction To Python Programming
1. Evaluate the following expressions:
(1) 15 + 3 * 5 - 6 / 2
(2) (15 + 3) * 5 – 6 / 2
(3) 15 + 3 * (5 – 6) / 2
(4) 15 + (3 ** 5 – 6)/ 2
(5) 15 * (3 % 5)// 2 + 6
(6) 15 % 3 ** 5//5 + 6

2. Write Python command/instruction/statement to display your name.


3. Write Python command to display your school name, class, and section, separated by “-“.
4. Evaluate the following expressions manually:
(i) (5 + 3) ** 3 - 6 / 2 (ii) (5 + 3) * 5//4+(4 + 6)/ 2 (iii) 16 + (3 * 4 – 6) / 3
(iv) 16 + (3 * *4 – 6)// 2 (v) 16 * 3 % 5 + 2 * 6//4 (vi) 16 % 5 *3 +(2*6)//4
5. Python has a built in type() function to ascertain the data type of a specific value. Predict the data
type of the given Python expressions:
Python Expression
i. m=32 iii.m=12E4
n=float(m) print(type(m))
print(type(n))
ii.a=42.85 iv.a=5; b=2
b=int(a) p=complex(a,b)
print(type(b)) print(type(p))

6. Predict the return type of the following Python statements:


Statement Return data type
i.type(int(‘10’)) iv.type(0.0025))
ii.type(25/5) v. type(0j)
iii.type(float(’55.5’))

7. Convert the following:

d= 18.25 to an integer
p= “89.5” to a float
m= 99
n= 21.85
What will be the datatype of print
(m+n)

8. Predict the output for the following statements:


1
i. print(" Hello'\t' World") iii.print(“Rashmi \n”, “16 years\n”, ”Class: XI”)
ii.print(“ Hello\n World”) iv. print(“Rashmi \t 16 years\n”, ”Class: XI”)

ITERATION :

1. What will be the outputs produced by following code fragments?


a) for i in 10, 12, 14, 16, 18:
print(i)
b) for i in range(5):
print(i)
c) for j in range (0,5):
print(j)
d) for k in range (3,0):
print(k)
e) for c in “Apple”:
print(c)

2 What will be the outputs produced by following code fragments?


a) i=10
while (i>0):
print(“Value of i “,i)
i -=4
else:
print (“Out of loop”)

b) i=10
while (i>0):
print(“Value of i”,i)
else:
print (“Out of loop”)
c) i=10
while (i>0):
print(“Value of i”,i)
i-=3
else:
print (“Out of loop”)
3. Consider following three codes and display the output produced by these codes
a) i=0
while i <10:
i +=1
if i%2==0:
print(i)
b) i=0
while i >10:
i +=1
if i%2==0:
print(i)
c) i=0
while i<1:
i -=1
if i%2==0:
print(i)
4. Consider
i=0
while i <=10:
i +=1

2
if i%2==0:
print(i)

5. Make changes in the code so that it prints values less than 10 but not value 10, WITHOUT changing the
test condition of while loop.
6. Find the errors and correct the code:
a) i =10
While (i < 100) :
Print (a)
Print(“over!”)
b) key = ‘panda’
Correct = false
while not correct :
inp = input(“Enter secret key :”)
if inp == secret :
print (“CORRECT! You got that.”)
else :
print (“Wrong guess. Try again.”)
7. Find the syntactical errors in following codes. Underline the erroneous part and write corrected codes.
a) for iMus range (10)
B = 19 + iMus
Print (b)
b) while k < 10 :
print (k)
k = k+2
c) a = 5
While a < 10 : print (a *2)
Else print (a + 1)
d) For p in range(3)
for q in range(3)
Print (p * q)
else:
Print (“outer loop ends”)
e) for p in range(3)
for q in range(3)
Print (p * q)
elif:
print (“loop ends”)
else :
print (“loop over”)
8. How many times will the given loops iterate?
(a) j=0
while (j < 50):
print (“Hello World”)
(b) j = 25
while (25 <= j <= 30):
Print (“Temp variable =”, j)
J = j+1
(c) j = 25
while (25 <= j < 30):
Print (“Temp variable =”, j)
J = j+1
9. Write down the syntax of break and continue statement used in a ‘for’ loop.

Programming :
1. To print the first “n” multiples of a given no.
2. To calculate profit – loss for given cost and sell price.

3
3. To find sale price of an item with given cost and discount (%).
4. To find the sum of squares of the first 100 natural numbers.
5. Display Fibonacci series up to 10 terms
6. Find the factorial of a given number
7. Display numbers from -10 to -1 using for loop
8. Write a program to print multiplication table of a given number
9. Print First 10 natural numbers using while loop
10. Calculate the cube of all numbers from 1 to a given number
11. Find the sum of the series upto n terms

14 Accept three sides of a triangle and check whether it is an equilateral, isosceles or scalene
triangle?

You might also like