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

Python Test

The document is a Python test consisting of three sections: Section A includes 12 short answer questions, Section B contains 6 programming tasks, and Section C has 4 more complex programming problems. The test covers various Python concepts, including data types, control flow, and functions, as well as programming tasks in Python and Java. The total marks for the test are 80, and the time allotted is 3 hours.

Uploaded by

ishmitsinghania
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Python Test

The document is a Python test consisting of three sections: Section A includes 12 short answer questions, Section B contains 6 programming tasks, and Section C has 4 more complex programming problems. The test covers various Python concepts, including data types, control flow, and functions, as well as programming tasks in Python and Java. The total marks for the test are 80, and the time allotted is 3 hours.

Uploaded by

ishmitsinghania
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Python Test

(Attempt All the questions)

Full Marks:80 Time: 3Hrs

Sec-A
(10 x 1 =10)
1. Does the program below have an error? If so why?
t= ‘hello’
t[0]=”H”

2. What are lists and tuples? What is the key difference between the
two?
3. How is del D and D[<key>] different from one another if D is a
Dictionary?
4. How are dictionaries different from list?
5. What are break, continue and pass in Python?
6. What is the difference between / and // in Python?
7. What is the difference between .py and .pyc files?
8. Consider the code:

string=raw_input(“enter a string”)

count=3

while True:

if string[0]==’a’ :

string[0]=string[2:1]

elif string[-1]==’b’:

string=string[: 2]

else

count+=1

break

print string

print count

[email protected]
Python Test

what will be the output if; i)aabbcc ii)aaccbb iii) abcc

9. What is type conversion in Python? What is the function of ord() ?


10. How do you write comments in python?
11. How will you convert a string to all lowercase?
12. What is the difference between a Mutable datatype and an Immutable
data type?

Sec-B

(6 x 5 =30)

1. WAP to input a range and print all the prime numbers in that range.
2. WAP a menu driven program to input a number and as per user’s
choice check smith number or not, Armstrong number or not.
3. Write a program that reads a date as a positive integer N. The
program prints out the date in the format

<Month name> <day><year>

Enter date: 12252022

December 25 ,2022

4. Find the sum of the series: 1-4+9-16….till 10th term.


5. A computer salesman gets commission on the following basis:
Sales Commission Rate
Rs. 0 - 20,000 3%
Rs. 20,000 - 50,000 12%
Rs. 50,001 and more 31%
After accepting the sales as input, calculate and print his
commission amount and rate of commission.

(WAP=> Write a program)

6. WAP that reads marks of 3 students in 4 subjects .It then displays


the total marks obtained each student

[email protected]
Python Test

Sec-C

( 10 x 4 =40)

1. Write a program in Java to accept a string and display the new string
after reversing the characters of each word.

Sample Input:
Computer Science

Sample output:
retupmoC ecneicS

2. Input a paragraph containing 'n' number of sentences where (1 < = n <


4). The words are to be separated with a single blank space and are in
UPPERCASE. A sentence may be terminated either with a full stop '.'
Or a question mark '?' only. Any other character may be ignored.
Perform the following operations:

1. Accept the number of sentences. If the number of sentences


exceeds the limit, an appropriate error message must be
displayed.
2. Find the number of words in the whole paragraph.
3. Display the words in ascending order of their frequency. Words
with same frequency may appear in any order.

Input:
Enter number of sentences.
1
Enter sentences.
TO BE OR NOT TO BE.

Output:
Total number of words: 6

Word Frequency

OR 1

NOT 1

TO 2

[email protected]
Python Test

BE 2

3. Create a dictionary whose keys are month names and whose values
are the number of days in the corresponding months.

a)Ask the user to enter a month name and use the dictionary
to tell them how many days are in the .month

b) Print all the keys in alphabetical order.

c) Print all the months with 31 days.

4. WAP to input any 10 numbers in a list and find the frequency of each
number.

Example:

Input numbers:

4425625 558

Output:

Number Frequency

2 2

4 2

5 3

6 1

8 1

[email protected]

You might also like