# 07 - Simple Calculations

1. The following program seeks to ask the user to enter a number: (no. of pounds) and then give them the equivalent Japanese yen. In the code here, line 2 has an error. 'yen' should be 'pounds'
```def convert_currency():
yen=int(input("Enter No. of Pounds:"))
yen=pounds*150
print("Converted into yen, that would give you:",yen)

convert_currency()```

False

True

2. There is an error in the line below on line 4. Line 4 should be: minutes=60*convert
```def convert_hours():

hours=int(input("Enter no. of hours"))
minutes=60*x
print(minutes)

convert_hours()```

True

False

3. What needs to go on line 6 to calculate the average of the three test scores?
```def find_average():
test1=30
test2=100
test3=99
#find average of the three test scores

average=total/3
print("The average mark is:",average)

find_average()```

total=30+100+9

test1=test2=test2=total

total=test1+test2+test3

4. How would you print the area of the shape on line 6?
```def create_shape():
import turtle
width=int(input("Enter width:"))
height=int(input("Enter height:"))
print("You have created a shape of width:",width,"and height:",height)
#what would you type here to calculate area?
create_shape()```

print("area is equal to:",width*height)

print area which is equal to width and height

area=print(width*height)

print(area=width*height)

5. What would you type on line 5 to check to see if the user's entered guess is equivalent to the computer's guess which is stored in the variable computer_guess (equal to 7)
```def guess():
guess=int(input("Enter a number between 1 and 10:"))
print("You have guessed:",guess)
computer_guess=7
print("Well done!")
else:
print("You came close, but not quite sorry!")

guess()```

if user input ==computer_guess:

if guess=computer_guess:

if guess==computer_guess:

if computer_guess = True

6. The expression int(age) below implies that ...
```age=input("Enter age:")
int(age)
print(age)```

the variable age is converted to integer.

the variable age can no longer be used as an integer

the variable age is converted to a string

the variable age is an integer = 0

7. Trace the logic to predict the output of the following:
```def main():
a=1
b=2
a,b=4,2
print(a+b)

main()```

3

6

2

1

8. The MOD or % operator gives the remainder. So, 10 MOD 2 =0, and 10 MOD 8 = 2. Difficult question for a beginner: Analyse the program below and see if you explain what it is doing? Try to code it and see.
```#This is a python program that tells you if a number is or is not a ....

num = 407

# take input from the user
# num = int(input("Enter a number: "))
if num > 1:
# check for factors
for i in range(2,num):
if (num % i) == 0:
print(num,"is not.....")
print(i,"times",num//i,"is",num)
break
else:
print(num,"is one!")

else:
print(num,"is not")```

a number that is in the range of 2 + num

a number that has a remainder of 0

a number that is divisible by 2

a prime number

9. This is another program that uses MOD (%). Fill in the blanks on line 4 and 6. The program asks for a number and what does it calculate?
```#Code this yourself and see what it does:
num = int(input("Enter a number: "))
if (num % 2) == 0:
print("The number is _________")
else:
print("The number is _________")```

Line 4: Is PRIME Line 6: Is not PRIME

Line 4: Gives a remainder of 2 Line 6: Does not give a remainder of 2

Line 4: EVEN Line 6: ODD

Line 4: Is a multiple of 2 Line 6: Is not a multiple of 2

10. If the number entered was: 7, animal was 'cat' and first name was 'Bob', the username would be?
```def main():