Print Command Quiz

The first instruction you will most likely learn when using Python is the print() instruction. It is used to display/output a message on screen.

print("Hello World")

Using Variables
The print command can be used to output the content of a variable:

username="admin"
print("You are logged as:")
print(username)

Using String Concatenation
You can join multiple strings together (string concatenation using +) to print them on a single line:

username="admin"
print("You are logged as:" + username)

Casting numbers (e.g integers) into string and vice-versa:
You can convert (cast) a number (e.g integer) into a string using the str() function or convert/cast a string into an integer using the int() function:

score=10
print("Your score:" + str(score))

Take the Quiz! (open full screen)


Did you like this challenge?

Click on a star to rate it!

Average rating 3.3 / 5. Vote count: 52

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!