0% found this document useful (0 votes)
6 views2 pages

TP 3

The document outlines a practical exercise aimed at enhancing Python programming skills, focusing on various operators and data types. It includes tasks for manual evaluation of Python instructions and executing them in interactive mode. Additionally, it instructs the reader to write a program to calculate and display their age based on their name and birth year.

Uploaded by

belhadi.ttl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

TP 3

The document outlines a practical exercise aimed at enhancing Python programming skills, focusing on various operators and data types. It includes tasks for manual evaluation of Python instructions and executing them in interactive mode. Additionally, it instructs the reader to write a program to calculate and display their age based on their name and birth year.

Uploaded by

belhadi.ttl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Centre Universitaire MAGHNIA

Third practical working

But:
The goal of this work is to improve in using various operators (assignment, arithmetic,
alphanumeric, and comparison) in Python syntax. Additionally, it aims to a deeper
understanding of the Python environment, including interactive mode and programming.
Practice one:
First part: Try to manually evaluate the instructions provided in the table below.
Instructions Expected result Type of data
a=16-7 a =……………. type(a)=…………….
b=a**2 b =…………… type (b)=……………
a=b%3
c=125 c =…………….. type(c)=…………….
c=c+3 b =……………. type (b)=……………
b=c//2
a=20 d =…………….. type(d) =…………….
b=42 f =……………... type (f) =……………
c=15 g =…………….. type(g) =…………….
d= (b-c) * a
f=a + b**2
g=d/f
a = ”evening” c =…………….. type(d) =…………….
b =5 d =……………. type (c) =……………
c = a+ str(b)
d=a*b

a=4 d =…………….. type(d) =…………….


b= 8 f =……………... type (f) =……………
c= 2 g =…………….. type(g) =…………….
d= a**c % b m =…………….. type(m) =…………….
f=a + b - c
g= a*b//c
m= a/c + b

1
Second part: try executing the instructions in Python using interactive mode.

a=3 b=2 c= ”hello”


Instructions Obtained result
d= a**b
print(d , type(d))
d/0
m= c * b
print(m, type(m))
m+c
m+a
c + str(d)
b + int(c)
d>=a
m != c**3

Practice two:
Write a program that assigns your name to the variable "name_user" and your birth year to the
variable "year_birth". The program should then calculate your age and display a message in the
following format: "YourName is X years old."

You might also like