Exercise 1

You might also like

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

Morsli Abdellah University Center in Tipaza

Institute of Sciences
Department of science and technology (ST) – 1st Year (LMD)
Course : Computer Science 2
1st Serie of Exercises (Practical Work)
procedures and functions (1)

Exercise 1:
- What is a Procedure?
- What is a Function?
- What are the similarities between procedures and functions?
- What is the main difference between a procedure and a function?
- Why do we use procedures and functions?
Exercise 2:
a. Is the following Python procedure correct? If not, correct it.
Pgm_1 pgm_2 pgm_3

b. Detect the errors in the following Python programs and correct them:
Pgm_4 Pgm_5

Pgm_6 Pgm_7

c. From both 'a' and 'b', what conclusions can be drawn regarding the preceding procedure programs?
Exercise 3: What is the output of the following Python programs?
Pgm_1 Pgm_2

Pgm_3 Pgm_4
Exercise 4:
1. Write a python procedure that takes an integer `n` as input and prints all even numbers from 1 to `n`.
2. Write a procedure that takes two integers `width` and `height` as input and prints the perimeter and the
surface area of a rectangle.
3. Write a procedure that takes a string as input and prints the count of (a, M, , x, .) in the string.
4. Write a procedure that takes a list as input and prints the elements of the list in reverse order. Then, prints
the maximum and the average of those numbers.

 Call each defined procedure, ensuring that the input value is entered by the user.

You might also like