Python Problem Sheet 1
Python Problem Sheet 1
print(len(“\n\n\t\n\n\tHelloIndia”))
b) print(“Hello”,”\t\t\t”,end=”Welcome”)
print(“Good”,”Morning”,sep=”gggg”)
2. Write a python program to print the following in the same format as specified
Welcome to the
department of CSE
Happy day
3. Write a python function which accepts the inputs name and department and prints the
following message –
(If the inputs are Sethuram and CSE), the output must be
I welcome Sethuram to CSE department
(If the inputs are xxx and Mechanical) , the output must be
I welcome xxx to Mechanical department
4. Write a python function which accepts 3 inputs name, city and state and displays the
message like the following
7. Write a python function which accepts 2 numbers (a and b) and returns the remainder
of dividing the first number by the second number.
8. Write a python function which accepts 2 numbers (a and b) and returns the quotient of
dividing the first number by the second number.
9. Write a python function which accepts the diameter of a circular pizza and price per
square inch as inputs and returns the cost of the pizza as output
10.
11.
12.
13. Write a python function which accepts a number as input and prints whether it is even
or odd
14. Write a python function which accepts name and age as input and prints appropriate
string as output
If age<=30 the person is young
If age>30 and age<=60, the person is middle aged
If age>60, the person is old
15. Write a python function which accepts three numbers and returns the largest of the
three numbers.
16. Write a python function which accepts the inputs A,B and C and prints the roots of the
quadratic equation
Ax2+Bx+C=0
17. Simulate a password enabled door-locking system where the door accepts a unique
password
and displays the message “YOU CAN ENTER INSIDE”. If any other password is given, the
message should be “YOU ARE NOT ALLOWED INSIDE”.
18.
19.
21.
22.
23. a) Write a python function which accepts a message and count as inputs and displays
the message, count number of times
For example Suppose the count is 5 and the message is “Hello”, the output should be
Hello
Hello
Hello
Hello
Hello
24. Write a python function which accepts 2 numbers and returns the product of 2 numbers
without using * operator
25. Write a python function which accepts 2 numbers (a and b) and returns ab without using
the ** operator.
26. Write a python function which accepts an n-digit integer and returns the sum of the
digits of the number
27. Write a python function which accepts an n-digit integer and returns the reverse of the
number
28. Write a python program which displays the following pattern given the size n,
If n=4, the program has to display 4 rows
1
1 2
1 2 3
1 2 3 4
29. Write a python program which displays the following pattern given the size n,
If n=5, the program has to display 5 rows
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
30.
31. Write a python function which accepts 2 integers (a and b), returns the average of all
the integers between a and b excluding them (Here a<b)
32. Write a python function which accepts a positive integer and prints whether a number is
prime or composite.
33. Write a python function which accepts 2 positive numbers (a and b), returns the sum of
all odd numbers between a and b (excluding a and b)
34. A) Write a python function which accepts 2 positive numbers (a and b) and displays all
numbers between a and b (including a and b) divisible by n (which is another input)
B) Also display the count of how many such numbers are there.
In the above example the count is 14
35. Write a python function which generates all prime numbers between any 2 given
numbers (a and b) including a and b
36.
37.
38.
39.
40.
41.
42.
sin(x) = x-(x3/3!)+(x5/5!)-(x7/7!)+…..
Where x is in radians
The questions for the test would be similar to the Questions in the above problem sheet
FIRST CODING TEST ON 23rd August 2017 (Wednesday) , Time: 1.5 Hours, Time: 4.30 to 6.00 PM,
Venue: Oracle Lab (E4 Block, Ground Floor)
TOTAL 25 Marks
Complete Execution of the program will fetch you full marks for that question