|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 1, |
| 6 | + "id": "0b7793de-48cf-49f0-a34e-fe3df1fb711e", |
| 7 | + "metadata": {}, |
| 8 | + "outputs": [ |
| 9 | + { |
| 10 | + "name": "stdin", |
| 11 | + "output_type": "stream", |
| 12 | + "text": [ |
| 13 | + "Enter your name: Abiodun Iyanda\n", |
| 14 | + "Enter your weight in pounds: 162\n", |
| 15 | + "Enter your height in inches: 60\n" |
| 16 | + ] |
| 17 | + }, |
| 18 | + { |
| 19 | + "ename": "TypeError", |
| 20 | + "evalue": "can't multiply sequence by non-int of type 'str'", |
| 21 | + "output_type": "error", |
| 22 | + "traceback": [ |
| 23 | + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", |
| 24 | + "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", |
| 25 | + "Cell \u001b[1;32mIn[1], line 4\u001b[0m\n\u001b[0;32m 2\u001b[0m weight\u001b[38;5;241m=\u001b[39m\u001b[38;5;28minput\u001b[39m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mEnter your weight in pounds:\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m 3\u001b[0m height\u001b[38;5;241m=\u001b[39m\u001b[38;5;28minput\u001b[39m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mEnter your height in inches:\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m----> 4\u001b[0m BMI \u001b[38;5;241m=\u001b[39m(weight \u001b[38;5;241m*\u001b[39m \u001b[38;5;241m703\u001b[39m) \u001b[38;5;241m/\u001b[39m(height \u001b[38;5;241m*\u001b[39mheight)\n", |
| 26 | + "\u001b[1;31mTypeError\u001b[0m: can't multiply sequence by non-int of type 'str'" |
| 27 | + ] |
| 28 | + } |
| 29 | + ], |
| 30 | + "source": [ |
| 31 | + "\n" |
| 32 | + ] |
| 33 | + }, |
| 34 | + { |
| 35 | + "cell_type": "code", |
| 36 | + "execution_count": 40, |
| 37 | + "id": "252f3e67-ddc4-4f97-bf94-d302e355bcae", |
| 38 | + "metadata": {}, |
| 39 | + "outputs": [ |
| 40 | + { |
| 41 | + "name": "stdin", |
| 42 | + "output_type": "stream", |
| 43 | + "text": [ |
| 44 | + "Enter your name: Abbie\n", |
| 45 | + "Enter your weight in pounds: 170\n", |
| 46 | + "Enter your height in inches: 67\n" |
| 47 | + ] |
| 48 | + }, |
| 49 | + { |
| 50 | + "name": "stdout", |
| 51 | + "output_type": "stream", |
| 52 | + "text": [ |
| 53 | + "26.62285586990421\n", |
| 54 | + "Abbie You're overweight.\n" |
| 55 | + ] |
| 56 | + } |
| 57 | + ], |
| 58 | + "source": [ |
| 59 | + " # to avert the error, convert the weight and height input into integers\n", |
| 60 | + "name = input('Enter your name:')\n", |
| 61 | + "weight=int(input('Enter your weight in pounds:'))\n", |
| 62 | + "height=int(input('Enter your height in inches:'))\n", |
| 63 | + "BMI = (weight * 703) / (height * height)\n", |
| 64 | + "print(BMI)\n", |
| 65 | + "if BMI>0:\n", |
| 66 | + " if BMI<18.5:\n", |
| 67 | + " print(name +\" You're underweight.\")\n", |
| 68 | + " elif BMI < 24.9 :\n", |
| 69 | + " print(name +\" You're normal weight.\")\n", |
| 70 | + " elif BMI < 29.9 :\n", |
| 71 | + " print(name +\" You're overweight.\") \n", |
| 72 | + " elif BMI < 34.9:\n", |
| 73 | + " print(name+\" You're obese.\")\n", |
| 74 | + " elif BMI < 39.9:\n", |
| 75 | + " print(name +\" You're severly obese.\")\n", |
| 76 | + " else:\n", |
| 77 | + " print(name +\" You're morbidity obese.\")\n", |
| 78 | + "else:\n", |
| 79 | + " print(\"Invalid inputs\")\n", |
| 80 | + " " |
| 81 | + ] |
| 82 | + }, |
| 83 | + { |
| 84 | + "cell_type": "code", |
| 85 | + "execution_count": 24, |
| 86 | + "id": "3f819c8c-d85f-414b-872d-6356c58a13d2", |
| 87 | + "metadata": {}, |
| 88 | + "outputs": [ |
| 89 | + { |
| 90 | + "data": { |
| 91 | + "text/plain": [ |
| 92 | + "int" |
| 93 | + ] |
| 94 | + }, |
| 95 | + "execution_count": 24, |
| 96 | + "metadata": {}, |
| 97 | + "output_type": "execute_result" |
| 98 | + } |
| 99 | + ], |
| 100 | + "source": [] |
| 101 | + }, |
| 102 | + { |
| 103 | + "cell_type": "code", |
| 104 | + "execution_count": null, |
| 105 | + "id": "3c552dc9-e81e-40e9-be37-07ae11e3c92f", |
| 106 | + "metadata": {}, |
| 107 | + "outputs": [], |
| 108 | + "source": [] |
| 109 | + }, |
| 110 | + { |
| 111 | + "cell_type": "code", |
| 112 | + "execution_count": null, |
| 113 | + "id": "cd9bc777-6a4a-4c8e-9fa5-da87d9d48f30", |
| 114 | + "metadata": {}, |
| 115 | + "outputs": [], |
| 116 | + "source": [] |
| 117 | + }, |
| 118 | + { |
| 119 | + "cell_type": "code", |
| 120 | + "execution_count": null, |
| 121 | + "id": "d272d169-7bc9-40a1-bcb5-3c57d010ab50", |
| 122 | + "metadata": {}, |
| 123 | + "outputs": [], |
| 124 | + "source": [] |
| 125 | + }, |
| 126 | + { |
| 127 | + "cell_type": "code", |
| 128 | + "execution_count": 36, |
| 129 | + "id": "3634d197-aec7-4d5b-a3c3-683ecb71163d", |
| 130 | + "metadata": {}, |
| 131 | + "outputs": [ |
| 132 | + { |
| 133 | + "name": "stdout", |
| 134 | + "output_type": "stream", |
| 135 | + "text": [ |
| 136 | + "name You're obese.\n" |
| 137 | + ] |
| 138 | + } |
| 139 | + ], |
| 140 | + "source": [ |
| 141 | + "if BMI>0:\n", |
| 142 | + " if BMI<18.5:\n", |
| 143 | + " print(\"name\" +\" You're underweight.\")\n", |
| 144 | + " elif BMI < 24.9 :\n", |
| 145 | + " print(\"name\" +\" You're normal weight.\")\n", |
| 146 | + " elif BMI < 29.9 :\n", |
| 147 | + " print(\"name\" +\" You're overweight.\") \n", |
| 148 | + " elif BMI < 34.9:\n", |
| 149 | + " print(\"name\"+\" You're obese.\")\n", |
| 150 | + " elif BMI < 39.9:\n", |
| 151 | + " print(\"name\" +\" You're severly obese.\")\n", |
| 152 | + " else:\n", |
| 153 | + " print(\"name\" +\" You're morbidity obese.\")\n", |
| 154 | + "else:\n", |
| 155 | + " print(\"Invalid inputs\")\n", |
| 156 | + " " |
| 157 | + ] |
| 158 | + }, |
| 159 | + { |
| 160 | + "cell_type": "code", |
| 161 | + "execution_count": null, |
| 162 | + "id": "442d0830-49f8-4411-bf76-0c127995dd89", |
| 163 | + "metadata": {}, |
| 164 | + "outputs": [], |
| 165 | + "source": [] |
| 166 | + } |
| 167 | + ], |
| 168 | + "metadata": { |
| 169 | + "kernelspec": { |
| 170 | + "display_name": "Python 3 (ipykernel)", |
| 171 | + "language": "python", |
| 172 | + "name": "python3" |
| 173 | + }, |
| 174 | + "language_info": { |
| 175 | + "codemirror_mode": { |
| 176 | + "name": "ipython", |
| 177 | + "version": 3 |
| 178 | + }, |
| 179 | + "file_extension": ".py", |
| 180 | + "mimetype": "text/x-python", |
| 181 | + "name": "python", |
| 182 | + "nbconvert_exporter": "python", |
| 183 | + "pygments_lexer": "ipython3", |
| 184 | + "version": "3.12.4" |
| 185 | + } |
| 186 | + }, |
| 187 | + "nbformat": 4, |
| 188 | + "nbformat_minor": 5 |
| 189 | +} |
0 commit comments