PS Week 4
PS Week 4
Q1. Create a function, which counts and prints down from given number (as an input) to
0. Then it counts and prints from zero to given number.
Q2. The function below finds the summation of all numbers between 0 and 10. Try to
figure out the errors.
def summation():
for i in range(9):
sum=0
sum +=1
print sum
Q3. Write a function print_even() that takes two even numbers as input and prints the all
even numbers between these numbers. (write it with for and while loop) For example:
print_even(12,18)
14
16
Q4. What is the output of the following operations?
a=4
b=6
c=4
print(a = 2)
print(b > 2)
print(a >= c)
print(a > b)
print(b < a)
print(a = b)
print(a <= c)
print(a != b)
print(a =< c)
Q5. Write a function that takes a negative number and prints all the negative numbers
from 0 until that number. For example:
negatives(-10)
0
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
Q6. Write a function that prints the following when called.
10
20
30
40
50
60
70
80
90
100
Q7. Write a function that takes 2 numbers and prints from the smaller number till the
bigger one. You may use max(), min() built in functions. Hint: use for loop. For example: if
the input is func(1,6), the output should be:
1
2
3
4
5
6
for I in range(-1,-10,1):
print(i)
Q13. Create a function which draws the figure below several times.