Python Assignment: Variables and Concatenation
Instructions
Complete the following questions by writing Python code. Test your code to ensure it
runs correctly. Write your solutions in a Python file, with each answer clearly labeled
and commented. This assignment focuses on using variables and string concatenation.
Questions
1. Create a variable name with your name and print it.
2. Create two variables age and year with your age and the current year. Print them
in a sentence using concatenation (e.g., ”I am 12 years old in 2025.”).
3. Assign the value 25 to a variable score and then update it to 30. Print the updated
value.
4. Create a variable city with the value ”New York” and concatenate it with the string
” is awesome!” to print the result.
5. Create two variables first_name and last_name. Concatenate them with a space
in between and print the full name.
6. Assign 10 to a variable x and 5 to a variable y. Create a new variable sum_xy that
stores their sum and print it.
7. Create a variable greeting with the value ”Hello” and concatenate it with a variable
user containing a name of your choice. Print the result.
8. Create a variable price with the value 19.99. Print a sentence using concatenation
to say ”The price is $19.99”.
9. Create two variables a and b with values 15 and 7. Calculate their product and
store it in a variable product. Print the result.
10. Create a variable color with the value ”blue” and a variable item with the value
”car”. Concatenate them to print ”The car is blue.”
11. Assign the string ”Python” to a variable language and the string ” is fun!” to a
variable opinion. Concatenate and print them.
12. Create a variable count with the value 42. Print a sentence using concatenation
like ”I have 42 apples.”
1
Example
Here is an example of how to structure your answer for Question 1:
1 # Q u e s ti o n 1 : C r e a t e a v a r i a b l e ’ name ’ with your name and p r i n t i t .
2 name = ” A l i c e ”
3 p r i n t ( name )
Submission
Write your answers in a single Python file. Include a comment before each question (e.g.,
# Question 1) to indicate which question the code solves. Test your code to ensure it
runs without errors before submitting.