GoConqr has a new look! Let us know what you think.

Module 4 of 11 · Text

Using variables

David Khieu

Using variables

You're allowed to use as many variable declarations as you need to achieve your goa;, like this:

 

var = 1

account_balance = 1000.0

client_name = 'John Doe'

print(var, account_balance, client_name)

print(var)

You're not allowed to use a variable which doesn't exist (in other words, a variable that was not assigned a value).

This example will cause an error:

var = 1 print(Var)

We've tried to use a variable named Var, which doesn't have any value (note: var and Var are different entities, and have nothing in common as far as Python's concerned).

REMEMBER

You can use the print() function and combine text and variables using the + operator to output strings and variables, e.g.:

var = "3.8.5"

print("Python version: " + var)

Can you guess the output of the snippet above? 

Python version: 3.8.5

 

Instructions

You must submit an attempt for this quiz to progress. You can submit it after the last question.

Go to the chosen module

Feedback

What is it about?

What do you think of the new look?

How do you like it?