# Week 3: Exercise Solutions

## Exercise 3.1

• Using `2**100` we find that there are 31 digits in 2100.
• Using `3**11 % 11` we find the answer 3.

## Exercise 3.2

• A float has a decimal point in it: `3.0` represents a float and `3` represents an integer.
• It forgets the fractional part, so `int(-7.8)` is `-7`.

## Exercise 3.3

```# To calculate body mass index
height = float(input("What is your height in metres? "))
weight = float(input("What is your weight in kilos? "))
print("Your BMI is", weight / height**2)
```

## Exercise 3.4

```# To decide if a number is non-zero
number = int(input("Enter an integer: "))
print("It is", number != 0, "that your number is non-zero")
```

## Exercise 3.5

In the first case, the condition is always true so the program will just print

```Spam
Spam and eggs
```

over and over again forever and will never print `Lobster thermidor`.

In the second case the condition is never true, so will not print anything about spam but will only print `Lobster thermidor`.