Print Practice

Let’s try some simple practice problems. These problems are not graded - they are just for you to practice before doing the real exercises in the lab itself. You can find the answers below each question by clicking the button below each question.

1.1 Reading Code

What is the output that is displayed to the user after running the following Python code:

print("Kansas State University")
print("Manhattan ", end="")
print("KS", end=" ")
print("66506")
print("KSU!\nGo Cats!")
1.1 Answer

The correct output:

Kansas State University
Manhattan KS 66506
KSU!
Go Cats!

1.2 Constructing Code

We want to write a program that produces the following output:

*
* *
* * *

Rearrange the following Python statements to create a program that produces that output. You may not use all of these statements in your answer.

print("*")
print("*")
print("*")
print("*", end=" ")
print("*", end=" ")
print("*", end=" ")
1.2 Answer

One solution:

print("*")
print("*", end=" ")
print("*")
print("*", end=" ")
print("*", end=" ")
print("*")

1.3 Writing Code

Write a Python program that will display the last five letters of the alphabet, one per line.

1.3 Answer

One possible answer is shown below:

print("v")
print("w")
print("x")
print("y")
print("z")

Many others are possible!