2.1.4.7 LAB: Variables

LAB 

Estimated time

10 minutes

Level of difficulty

Easy

Objectives

  • becoming familiar with the concept of storing and working with different data types in Python;
  • experimenting with Python code.

Scenario

Here is a short story:
Once upon a time in Appleland, John had three apples, Mary had five apples, and Adam had six apples. They were all very happy and lived for a long time. End of story.
Your task is to:
  • create the variables: johnmary, and adam;
  • assign values to the variables. The values must be equal to the numbers of fruit possessed by John, Mary, and Adam respectively;
  • having stored the numbers in the variables, print the variables on one line, and separate each of them with a comma;
  • now create a new variable named totalApples equal to addition of the three former variables.
  • print the value stored in totalApples to the console;
  • experiment with your code: create new variables, assign different values to them, and perform various arithmetic operations on them (e.g., +, -, *, /, //, etc.). Try to print a string and an integer together on one line, e.g., "Total number of apples:" and totalApples.


  • Console 

Comments

Popular Posts