CISC504A Vatsal Patel Assignment2 O.ipynb

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

{

"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2\n",
"Hello, World!\n",
"('money grown after 3 years is', 1157.6250000000002)\n",
"Enter the Weight(KG) : 72\n",
"Enter the Height(Inch) : 74\n",
"('The BMI is : ', 20.379880058518335)\n",
"Healthy\n"
]
}
],
"source": [
"# Youtube link for Assignment 2 = https://youtu.be/moW_RFnPTvU\n",
"\n",
"#Assignment 2\n",
"\n",
"#Vatsal Patel (186383)\n",
"\n",
"#CISC 504-90- O-2020/Late Summer - Principles of Programming Langu\n",
"\n",
"#Instructor: Muazzam Ali\n",
"#Write a Python program that stores the result of the computation 1+1 in a
variable and then\n",
"#prints the value of this variable.\n",
"\n",
"#Execrise 1.1 \n",
"\n",
"#Code: \n",
"#we need to do 1+1 and we can do it different way\n",
"A = 1 #Assigning Vlaue 1 to A\n",
"B = 1 #Assigning Vlaue 1 to B\n",
"Sum = A + B #now conduction simple formula for addition\n",
"print Sum #Prinitig valuew of Y which will be claulated from above
formula\n",
"\n",
"#another methond \n",
" \n",
"#Exercise 1.2. Write a “Hello, World!” program.\n",
"\n",
"#Code:\n",
"\n",
"print(\"Hello, World!\") #Simple command to Print Hello ,World\n",
"\n",
"\n",
"#Exercise 1.6. Compute the growth of money in a bank.\n",
"#Let p be a bank’s interest rate in percent per year. An initial amount A has
then grown to\n",
"#A(1+P/100)^n\n",
"#after n years. Make a program for computing how much money 1000 euros have
grown to after three years with 5% interest rate.\n",
"\n",
"#Code: \n",
"A = 1000 # initial amount\n",
"P = 5.0 # interest rate in percent\n",
"n = 3 # years\n",
"final_amount = A * (1 + P / 100) ** n # Formula for Calculating FInal ammount
with interns after particular years\n",
"print(\"money grown after 3 years is\", final_amount) # Printing the Result of
Final AMount\n",
"\n",
"#New Excercise\n",
"# Code\n",
"\n",
"W = float(input(\"Enter the Weight(KG) : \")) #take weight in kg as input from
user\n",
"\n",
"H = float(input(\"Enter the Height(Inch) : \"))#take height in inch as input
from user\n",
"\n",
"height_in_meters = H * 0.0254 #converting inch to metre ; 1 inch = 0.0254
metre\n",
"\n",
"BMI = W / height_in_meters**2 #calculating BMI by using given formula\n",
"\n",
"print(\"The BMI is : \",BMI) # Printing Calculated BMI from Above Formula\n",
"\n",
"# When BMI levels are below 16 it will print Below Statement\n",
"if (BMI < 16):\n",
" print(\"severely underweight\")\n",
"\n",
"\n",
"# When BMI levels are below 16 it will print Below Statement\n",
" \n",
"elif (BMI >= 16 and BMI < 18.5):\n",
" print(\"underweight\")\n",
"\n",
"# When BMI levels are 18.5 to 25 it will print Below Statement\n",
"\n",
"elif (BMI >= 18.5 and BMI < 25):\n",
" print(\"Healthy\")\n",
"\n",
"# When BMI levels are between 25 to 30 it will print Below Statement\n",
"\n",
"elif (BMI >= 25 and BMI < 30):\n",
" print(\"overweight\")\n",
"\n",
"# When BMI levels are above 30 it will print Below Statement\n",
"\n",
"elif (BMI >=30):\n",
" print(\"severely overweight\")\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.16"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

You might also like