0% found this document useful (0 votes)
18 views2 pages

PracticeExercises StringsandVariables

The document contains 3 coding exercises that involve using variables and getting user input in Python. The first exercise assigns values to variables for an animal, vegetable, and mineral and prints them. The second repeats user input. The third displays user input within a speech bubble of a cat.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

PracticeExercises StringsandVariables

The document contains 3 coding exercises that involve using variables and getting user input in Python. The first exercise assigns values to variables for an animal, vegetable, and mineral and prints them. The second repeats user input. The third displays user input within a speech bubble of a cat.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Practice Exercises ­ Strings and Variables

Exercise 1:

Write a Python program that uses three variables. The variables in your program will be animal,
vegetable, and mineral. Assign a string value to each one of the variables. Your program should
display "Here is an animal, a vegetable, and a mineral." Next, display the value for animal,
followed by vegetable, and finally mineral. Each one of the values should be printed on their
own line. Your program will display four lines in total.

Sample Output:

Here is an animal, a vegetable, and a mineral.


cat
broccoli
gold

Exercise 2:

Write a Python program that prompts the user for input and simply repeats what the user
entered.

Sample output:

Please type something and press enter: Hello there!


You entered:
Hello there!

Exercise 3:

Write a Python program that prompts for input and displays a cat "saying" what was provided by
the user. Place the input provided by the user inside a speech bubble. Make the speech bubble
expand or contract to fit around the input provided by the user.

Sample output:

LinuxTrainingAcademy.com
​ _______________________
< Pet me and I will purr. >
­­­­­­­­­­­­­­­­­­­­­­­
/
/\_/\ /
( o.o )
>^<

LinuxTrainingAcademy.com

You might also like