# 3.9. ExercisesΒΆ

## 3.9.1. Contributed ExercisesΒΆ

Write a function to add together its two arguments
Write a function to add together its two arguments

Q-1: After completing the reading, what concepts are still unclear to you? If nothing is unclear, what did you find most interesting?

Q-1: Suppose Python gives you this error: TypeError: cannot concatenate 'str' and 'int' objects on line 1

What does this error mean? How would you fix it?

Consider the code below that takes two numbers and calculates the average. Before running it try to do it on a paper and use a calculator. What is the average of two numbers like: 7 and 9? Now, run the program below with these numbers. Do you get the result you expected? Obviously, your result is wrong, but Python is not complaining at all! This is because a logical or semantic mistake has been made. There is nothing wrong with the syntax, but your calculation is wrong. Fix the code below to give you the expected result every time, with any pair of numbers the user specifies.

Consider the code below. We want the user to enter the age of their dog and we want to write the program that will output the age of the dog in human years. The rule you want your program to follow is that 1 dog year is 7 human years. We wrote some code for you below, but it has a number of syntax errors. What is a syntax error (review Ch3 if needed)? Fix it to work as you would expect. For example, if my dog is 7 years old, I expect to see the following output: Your dog’s age is equivalent to 49 human years.

Consider the code below. We want the user to enter the age of their dog and we want to write the program that will output the age of the dog in human years. The rule you want your program to follow is that 1 dog year is 7 human years. We wrote some code for you below, but it has a number of syntax errors. What is a syntax error (review Ch3 if needed)? Fix it to work as you would expect. For example, if my dog is 7 years old, I expect to see the following output: Your dog’s age is equivalent to 49 human years.