You are on page 1of 21

DELHI PUBLIC SCHOOL

NORTH KOLKATA

COMPUTER SCIENCE
REPORT FILE

OWAIS AHMED KHAN


XI-A
20
1. write a python program to read three numbers in three variables and
swap first two variables with the sums of first and second, second and
third respectively.

Ans.
INPUT:-

OUTPUT:-
2. write a python program to input a single digit(n) and print a 3 digit
number created as <n(n+1)(n+2)> e.g. if you input 7, then it should
print 789. Assume that the input digit is in range 1-7.

Ans.
INPUT:-

OUTPUT:-
3. write a python program to compute simple interest and compound
interest.

Ans.
INPUT:-

OUTPUT:-
4. write a python program that reads a number of seconds and prints it in
form : mins and seconds, e.g., 200 seconds are printed as 3 mins 20
seconds.

Ans.
INPUT:-

OUTPUT:-
5. write a python program to take a 3-digit number and then print the
reversed number.

Ans.
INPUT:-

OUTPUT:-
6. write a python program to take two inputs for a day, month and then
calculate which day of the year, the given date is.

Ans.
INPUT:-

OUTPUT:-
7. Write a program to print diamond shaped star pattern.

Ans.
INPUT:-

OUTPUT:-
8. Write a pyhton program to print every integer between 1 and n divisible
by m also report whether the no. that is divisible by m is even or odd.

Ans.
INPUT:-

OUTPUT:-
9. Write a python program to print the sum of the given sequences:
12+32+52+…+n2 (input n).
Ans.
INPUT:-

OUTPUT:-
10. Write a program that prompts for a phone number of 10 digits and two
dashes, with dashes after the area code and the next three numbers. For
example, 017-555-1212 is a legal input.
Display if the phone number entered is valid format or not and display
if the phone number is valid or not (i.e., contain just the digits and dash
at specific places.)
Ans.
INPUT:-

OUTPUT:-
11. Write a python program that:
- Prompt the user for a string
- Extract all digits from a string
- If there are digits:
 Sum the collected digits together
 Print out :
 The original string
 The digits
 The sum of the digits
- If there are no digits:
 Print the original string and a message “has no digits”

Ans.
INPUT:-

OUTPUT:-
12. Write a program that should prompt the user to type some sentence(s)
followed by “enter”. It should then print the original sentence(s) and the
following statistics relating to the sentence(s):
- Number of words
- Number of characters (including white-space and punctuation)
- Percentage of characters that are alpha numeric

Ans.
INPUT:-

OUTPUT:-
13. Write a program that reverses an array of integers (in place).

Ans.
INPUT:-

OUTPUT:-
14. Write a program that rotates the elements of a list so that the element at
the first index moves to the second index, the element in the second
index moves to third index, etc., and the element in the last index
moves to the first index.

Ans.
INPUT:-

OUTPUT:-
15. Write a program that reads the n to display nth term of Fibonacci series.
Ans.
INPUT:-

OUTPUT:-
16. Create a tuple containing the squares of the integers 1 through 50 using
a for loop.

Ans.
INPUT:-

OUTPUT:-
17. Given a nested tuple tup1=((1,2),(3,4.15,5.15),(7,8,12,15)). Write a
program that displays the means of the individual elements of tuple
tup1 and then displays the mean of these computed means.
Ans.
INPUT:-

OUTPUT:-
18. Given the dictionary x={'k1':'v1','k2':'v2','k3':'v3'}, create a dictionary
with the opposite mapping.

Ans.
INPUT:-

OUTPUT:-
19. Given two dictionaries say D1 and D2. Write a program that lists the
overlapping keys of the two dictionaries, i.e., if a key of D1 is also a
key of D2, then list it.

Ans.
INPUT:-

OUTPUT:-
20. Write a program that checks if two same values in a dictionary have
different keys.
Ans.
INPUT:-

OUTPUT:-

You might also like