Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Class 11 CS & Ip Worksheets

Download as pdf or txt
Download as pdf or txt
You are on page 1of 25

PM SHRI KENDRIYA VIDYALAYA No.

1, ARAKKONAM
WORK SHEET - Class XI
Computer Science 083
GETTING STARTED WITH PYTHON
Very Short answer Type Questions
Q.1 When was Python released?

Q.2 Who developed Python?


Q.3 Which two languages contributed to Python as a Programming Language?
Q.4 Is Python an Object Oriented Language?
Q.5 Python got its name from which show?
Short Answer Type Questions
Q.1 „Python is an interpreted language‟. What does it mean to you?

Q.2 What does a cross-platform language mean?


.
Q.3 Python is a Free and Open-Source language. What do you understand by this feature?
Q.4 In how many ways, can you work in Python?
Q.5 What is the difference between Interactive mode and Script Mode in Python?

Q.6 What are the advantages of Python?


Q.7 What are the limitations of Python?

Skill Based Questions


Q.1 Which of the following are not valid strings in Python?
(a) ‖Hello‖ (b) ‗Hello‘ (c)‖Hello‘ (d) ‗Hello‖ (e) {Hello}
Q.2 Write Instructions in python to get the following result: (Do it in both interactive
mode and script mode)
I am a student of KV Barabanki
I live in Barabanki
And I love Barabanki.
Barabanki is 20 KM away from Lucknow
This Place is famous for Dewa Sharif

PYTHON FUNDAMENTALS
Very Short answer Type Questions
Q.1 What is None literal in Python?
Q.2 What is the error in following code: x, y =7 ?
Q.3 what will the following code do: a=b=18 ?
Q.4 Following code is creating problem X = 0281, find reason.
Q.5 Find the error in the following code:
(a) temp=90 (b) a=12 (c) print(“x=”x)
Print temp b=a+b
print( a And b)
(d) a, b, c=2, 8, 4 (e) x = 23 (f) else = 21-4
print(a, b, c) 4=x
c, b, a = a, b, c
print(a; b; c)
Q.6 Find the error in the following code:
(a) y = x +5 (b) a=input(“Value: “) (c) print(x = y = 5)
print(x,y) b = a/2
print( a, b)
Short Answer Type Questions
Q.1 What is the difference between a keyword and an identifier?
Q.2 What are literals in Python? How many types of Literals allowed in Python?
Q.3 How many types of sequences are supported in Python?

Q.4 What factors guide the choice of identifiers in program?


Q.5 What is the difference between an expression and a statement in Python?
Q.6 What are tokens in Python? How many types of tokens allowed in Python?

Q.7 What are operators? What is their function? Give examples of some
unary and binary operators.
Q.8 What is block/code block/suit in Python?
Q.9 What is the role of indentation in Python?
Q.10 How many types of strings are supported by Python?
Skill Based Questions

Q.1 What will be the sizes of following constants?


(a) „\a‟ (b) “\a” (c) “Kumar\‟s” (d) „\”‟ (e) “it‟s”
Q.2 How can you create multi-line strings in Python?
Q.3 Which of the following are syntactically correct strings? State reason.
(a) ”Python is nice Language”
(b) „He called me “Friend!” when he came‟
(c) “Very Good‟
(d) „This is a good book‟
(e) “Namaste
(f) “I liked „Harry Potter‟ very much”

Q.4 What is the error in following Python program with one statement?
print(“My name is : “, name)
suggest a solution
Q.5 Predict the output of the following:

Q.6 What will be the output of the following code:

Q.7 Write a Program to obtain temperature in Celsius and convert it into Fahrenheit using
formula –
C X 9/5 + 32 = F
Q.8 Predict output:

Q.9 WAP to read todays date (only date Part) from user. Then display how many days are
left in the current month.
Q.10 WAP to print the area of circle when radius of the circle is given by user.

Q.11 WAP to print the volume of a cylinder when radius and height of the cylinder is given
by user.

Q.12 What is the error in following Python program with one statement?
print(“My name is : “, name)
suggest a solution
Q.13 Predict the output of the following:

Q.14 What will be the output of the following code:

Q.15 Write a Program to obtain temperature in Celsius and convert it into Fahrenheit using
formula –
C X 9/5 + 32 = F

Q.16 Predict output:

Q.17 WAP to read todays date (only date Part) from user. Then display how many days are
left in the current month.
Q.18 WAP to print the area of circle when radius of the circle is given by user.
Q.19 WAP to print the volume of a cylinder when radius and height of the cylinder is given
by user.
Q.20 WAP to find area of a triangle.
Q.21 WAP to calculate simple interest.
Q.22 WAP to read a number in n and prints n2, n3, n4

Chapter – 3: DATA HANDLING


Very Short answer Type Questions
Q.1 Identify the data types of the following values given bellow –
3, 3j, 13.0, „12‟,”14”, 2+0j,19, [1,2,3],(3,4,5)
Q.2 What will be the output of the following
(a)12/4 (b)14//14 (c)14%4 (d) 14.0/4 (e) 14.0//4 (f)14.0%4

Q.3 What will be the output of the following ?

Q.4 What are mutable and immutable types in Python? List both of them.
Q.5 What are augmented assignment operators? How are they useful?

Skill Based Questions


Q.1 WAP to calculate compound simple interest after taking the principle, rate and time.
Q.2 WAP to check the given year is leap year or not.

Q.3 WAP to take two numbers and check that the first number is fully divisible by second
number or not.

Q.4 What will be the output of the following?

Q.5 What will be the output of the following?

Q.6 WAP to take value of x,y,z from the user and calculate the equation 4𝗑4 + 3𝑦3 + 9z2 + 6𝜋

Q.7 WAP to take the temperatures of all 7 days of the week and displays the average
temperature of that week.

Chapter – 4: CONDITIONAL AND ITERATIVE STATEMENTS


Short Answer Type Questions
Q.1 What a range() function does? Give an example.

Q.2 What are loops in Python? How many types of loop are there in Python?
Q.3 What is the syntax of if-elif statement in Python?

Q.4 What are jump statements in Python? Name jump statements with example.
.
Q.5 Rewrite the following code fragment using for loop.
Q.6 What is the error in following code. Rewrite the correct code.
Correct
Code:

Q.7 WAP to input a digit and print it in words.


Q.8 WAP to check whether square root of a given number is prime or not.
Q.9 WAP to print first n odd numbers in descending order.
Q.10 WAP to print the following series –
(i) 1 4 7 10 . . . . . . .40
(ii) 1 -4 7 -10 . . . . . . . . -40

Q.11 WAP to find the average of the list of the numbers entered through keyboard.
Q.12 WAP to find the largest number from the list of the numbers entered throughkeyboard.

Q.13 WAP to find the 2nd largest number from the list of the numbers entered
throughkeyboard. (This program is from List Chapter)

Q.14 WAP to find the sum of n natural numbers.

Q.15 WAP to find the sum of first n even numbers.

Q.16 WAP to find the sum of first n odd numbers.

Q.17 WAP to print the following pattern


(a) * (b) * (c) A (d) 0
** ** AB 22
*** *** ABC 444
**** **** ABCD 8888
***** ***** ABCDE

Skill Based Questions


Q.1 Rewrite the following code fragment using while loop.

Q.2 WAP that searches for prime numbers from 15 through 25.

Q.3 WAP to test if given number is prime or not.

Q.4 WAP to compute the result when two numbers and one operator is given by user.
Q.5 WAP to calculate the roots of a given quadratic equation.

STRING MANIPULATION
Very Short answer Type Questions
Q.1 which of the following is not a Python legal string operation?
(a) ‟abc‟+‟abc‟ (b) „abc‟*3 (c)‟abc‟ + 3 (d)‟abc‟.lower()
Q.2 Out of the following operators, which ones can be used with strings?
=, -, *, /, //, %, >, <>, in, not in, <=
Q.3 From the string S = “CARPE DIEM”. Which ranges return “DIE” and “CAR”?

Q.4 Given a string S = “CARPE DIEM”. If n is length/2 then what would following return?
(a) S[:n] (b) S[n:] (c) S[n:n] (d) S[1:n] (e) S[n:length-1]

Q.5 What would following expression return?


(a) ”Hello World”.upper().lower() (b) ”Hello World”.lower().upper()
(c) ”Hello World”.find(“Wor”,1,6) (d) ”Hello World”.find(“Wor”)
(e) ”Hello World”.find(“wor”) (f) ”Hello World”.isalpha()
(g) ”Hello World”.isalnum() (h) ”Hello World”.isdigit()
(i) “123FGH”.isdigit()
Short Answer Type Questions
Q.1 What is a string slice? How is it useful?
Q.2 Write a python script that traverses through an input string and prints its characters
in different lines – two characters per line

Q.3 Which functions would you chose to use to remove leading and trailing white spaces
from a given string?
Q.4 Suggest appropriate functions for the following tasks –
(a) To check whether the string contains digits.
(b) To find the occurrence a string within another string.
(c) To convert the first letter of a string to upper case.
(d) To convert all the letters of a string to upper case.
(f) To check whether all the letters of the string are in capital letters.
(g) to remove all the white spaces from the beginning of a string.

Q.5 Find the errors -


s=”PURA VIDA”
Print(s[9] + s[9:15])

Q.6 Find the output – if we give input as “Hello”


Skill Based Questions
Q.1 WAP to print following pattern without using any nested loop.
#
##
###
## # #
#####
Q.2 WAP to print the number of occurrences of a substring into a line.

Q.3 WAP to check the given string is palindrome or not.

Q.4 WAP that:


o Prompt the user for a string
o Extract all the digits from the string.
o If there are digits
▪ Sum the collected digits together.
▪ Printout:
• The original string
• The digits
• The sum of the digits
o If there are no digits
▪ Print the original string
▪ A message “Has no Digits”

LIST MANIPULATION
Very Short answer Type Questions
Q.1 What do you understand by mutability?
Q.2 Start with the list[8,9,10]. Do the following using list functions
(a) Set the second entry (index 1) to 17
(b) Add 4, 5 and 6 to the end of the list.
(c) Remove the first entry from the list.
(d) Sort the list.
(e) Double the list.
(f) Insert 25 at index 3

Q.3 If a is [1, 2, 3], what is the difference (if any) between a*3 and [a, a, a]?

Q.4 If a is [1, 2, 3], is a *3 equivalent to a + a + a?

Q.5 If a is [1, 2, 3], what is the meaning of a [1:1] = 9?


Q.6 If a is [1, 2, 3], what is the meaning of a [1:2] = 4 and a [1:1] = 4?
Q.7 What are list slices?
Q.8 Does a slice operator always produce a new list?
Short Answer Type Questions

Q.1 How are lists different from strings when both are sequences?
Q.2 What are nested Lists?
Q.3 Discuss the utility and significance of Lists.
Q.4 What is the purpose of the del operator and pop method? Try deleting a slice.
Q.5 What are list slices?
Q.6 What do you understand by true copy of a list? How is it different from shallow copy?

Q.7 Predict the output – Ans:

Q.8 Predict the output – Ans:


Skill Based Questions

Skill Based Questions


Q.1 WAP to find minimum element from a list of elements along with its index in the list.

Q.2 WAP to calculate mean of a given list of numbers.

Q.3 WAP to search for an element in a given list of numbers

Q.4 WAP to count frequency of a given element in a list of numbers

Q.5 WAP to calculate the sum of integers of the list.

Q.6 WAP that reverses an array of integers (in place)


Q.7 WAP that creates a third list after adding two lists.
Q.8 WAP a program to generate a list of elements of Fibonacci Series.

TUPLES
Very Short answer Type Questions
Q.1 What do you understand by immutability?

Q.2 What is the length of the tuple shown below?


T = ((((„a‟, 1), ‟b‟, ‟c‟), ‟d‟, 2), ‟e‟, 3)

Q.3 If a is (1, 2, 3), what is the difference (if any) between a*3 and [a, a, a]?
Q.4 If a is (1, 2, 3), is a *3 equivalent to a + a + a?
Q.5 If a is (1, 2, 3), what is the meaning of a [1:1] = 9?
Q.6 If a is (1, 2, 3), what is the meaning of a [1:2] = 4 and a [1:1] = 4?
Q.7 Does a slice operator always produce a new Tuple?
Q.8 How is an empty Tuple created?
Q.9 How is a tuple containing just one element created?

Q.10 What is the difference between (30) and (30,)?


Short Answer Type Questions

Q.1 How are Tuples different from Lists when both are sequences?
Q.2 Can tuples be nested?
Q.3 Discuss the utility and significance of Tuples.
Q.4 How can you say that a tuple is an ordered list of objects?

Q.5 How can you add an extra element to a tuple?


Q.6 Find out the output generated by following code fragments:
(a) plane = (“Passengers”, ”Luggage”)
plane [1] = “Snakes”
(b) (a, b, c) = (1,2,3) (c) (a, b, c, d) = (1,2,3)
(d) a, b, c, d = (1,2,3) (e) a, b, c, d, e = (p, q, r, s, t) = t1
Predict the output –

Q.7 Predict the output –

Skill Based Questions


Q.1 WAP that creates a tuple storing first 9 items of Fibonacci Series.
Q.2 WAP that creates a third tuple after adding two tuples. Add second after first tuple.

Q.3 WAP to calculate the mean of the numbers of the tuple.

Q.4 WAP to calculate the average of the numbers of the tuple.

Chapter – 9: DICTIONARIES
Very Short answer Type Questions
Q.1 Why can‟t List can be used as keys?
Q.2 What type of objects can be used as keys in dictionary?
Q.3 Can you change the order of the dictionaries contents?
Q.4 Can you modify the keys in a dictionary?
Q.5 Can you modify the value in a dictionary?
Q.6 Is dictionary Mutable? Why?
Short Answer Type Questioemns
Q.1 How are dictionaries different from Lists?
Q.2 When are dictionaries more useful than lists?

Q.3 Discuss the utility and significance of Dictionaries.


Q.4 Why is a dictionary termed as an unordered collection of objects?
Q.5 How is clear() function different from del <dict> Statement?
Q.6 What is the output produced by the following code -

Skill Based Questions


Q.1 WAP that repeatedly asks the user to enter product names and prices. Store all of
them in a dictionary whose keys are product names and values are prices. And also
write a code to search an item from the dictionary.

Q.2 WAP to create a dictionary named year whose keys are month names and values are
their corresponding number of days.

************************************************************************
Q.8
.

You might also like