Online course

PYTHON

TRAINING 1

What will be displayed after running the next codes ?

a) x=10 b) x="10"

print(2*x) print(2*x)

TRAINING 2

1. Write a program that uses a variable named age and assign it with your age. Let the program write “Your age is" and then your age .

2. Let the program calculate your age in ten years.

TRAINING 3

1/ What does this program returns when x=2 ?

2/ What does this program returns in terms of x ?

Training 1 - solution

a) 20

b) 1010 (Here 10 is a string)

Training 2 - solution

1. age=int(input("How old are you?"))

print("Your age is", age, "years old.")

2. age=int(input("How old are you?"))

print("In ten years your age will be", (age+10), "years old.")

Training 3 - solution

1/ When x=2, program returns 4

2/ The program returns x²-x+2

RESOURCES

INVOLVED LESSONS