Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 729463f

Browse files
Add files via upload
1 parent c53fba8 commit 729463f

File tree

1 file changed

+167
-0
lines changed

1 file changed

+167
-0
lines changed

‎Assignment-6.ipynb

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 3,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"name": "stdout",
10+
"output_type": "stream",
11+
"text": [
12+
"Fibonacci sequence:\n",
13+
"0\n",
14+
"1\n",
15+
"1\n",
16+
"2\n",
17+
"3\n",
18+
"5\n",
19+
"8\n",
20+
"13\n",
21+
"21\n",
22+
"34\n",
23+
"55\n",
24+
"89\n"
25+
]
26+
}
27+
],
28+
"source": [
29+
"def recursion_fiboseries(n):\n",
30+
" if n <= 1:\n",
31+
" return n\n",
32+
" else:\n",
33+
" return(recursion_fiboseries(n-1) + recursion_fiboseries(n-2))\n",
34+
"\n",
35+
"n = 12\n",
36+
"\n",
37+
"# check if the number of terms is valid\n",
38+
"if n <= 0:\n",
39+
" print(\"Plese enter a positive integer\")\n",
40+
"else:\n",
41+
" print(\"Fibonacci sequence:\")\n",
42+
" for i in range(n):\n",
43+
" print(recursion_fiboseries(i))"
44+
]
45+
},
46+
{
47+
"cell_type": "code",
48+
"execution_count": 8,
49+
"metadata": {},
50+
"outputs": [
51+
{
52+
"name": "stdout",
53+
"output_type": "stream",
54+
"text": [
55+
"Factorial of 7 is : 5040\n"
56+
]
57+
}
58+
],
59+
"source": [
60+
"def recursion_factorial(n):\n",
61+
" if (n==1 or n==0):\n",
62+
" return 1\n",
63+
" else:\n",
64+
" return (n * recursion_factorial(n - 1))\n",
65+
"\n",
66+
"print(\"Factorial of 7 is : \",recursion_factorial(7))\n"
67+
]
68+
},
69+
{
70+
"cell_type": "code",
71+
"execution_count": 10,
72+
"metadata": {},
73+
"outputs": [
74+
{
75+
"name": "stdout",
76+
"output_type": "stream",
77+
"text": [
78+
"Enter your height in cm: 6.3\n",
79+
"Enter your weight in kg: 52\n",
80+
"You BMI is 13101.536911060719\n",
81+
"You are severely obese.\n"
82+
]
83+
}
84+
],
85+
"source": [
86+
"height = float(input(\"Enter your height in cm: \"))\n",
87+
"weight = float(input(\"Enter your weight in kg: \"))\n",
88+
"BMI = weight / (height/100) **2\n",
89+
"print(\"You BMI is \",BMI)\n",
90+
"if BMI <= 18.4:\n",
91+
" print(\"You are underweight.\")\n",
92+
"elif BMI <= 24.9:\n",
93+
" print(\"You are healthy.\")\n",
94+
"elif BMI <= 29.9:\n",
95+
" print(\"You are over weight.\")\n",
96+
"elif BMI <= 34.9:\n",
97+
" print(\"You are severely over weight.\")\n",
98+
"elif BMI <= 39.9:\n",
99+
" print(\"You are obese.\")\n",
100+
"else:\n",
101+
" print(\"You are severely obese.\")"
102+
]
103+
},
104+
{
105+
"cell_type": "code",
106+
"execution_count": 11,
107+
"metadata": {},
108+
"outputs": [
109+
{
110+
"name": "stdout",
111+
"output_type": "stream",
112+
"text": [
113+
"math.log(200.50) : 5.300814246746624\n"
114+
]
115+
}
116+
],
117+
"source": [
118+
"import math\n",
119+
"print (\"math.log(200.50) : \", math.log(200.50))"
120+
]
121+
},
122+
{
123+
"cell_type": "code",
124+
"execution_count": 26,
125+
"metadata": {},
126+
"outputs": [
127+
{
128+
"name": "stdout",
129+
"output_type": "stream",
130+
"text": [
131+
"Enter any number: 6\n",
132+
"cube sum of 6 is 441\n"
133+
]
134+
}
135+
],
136+
"source": [
137+
"numb = int(input(\"Enter any number: \"))\n",
138+
"sum=0\n",
139+
"for i in range(numb+1):\n",
140+
" cube=i**3\n",
141+
" sum = sum+cube\n",
142+
"print(\"cube sum of\",numb,\"is\",sum)"
143+
]
144+
}
145+
],
146+
"metadata": {
147+
"kernelspec": {
148+
"display_name": "Python 3",
149+
"language": "python",
150+
"name": "python3"
151+
},
152+
"language_info": {
153+
"codemirror_mode": {
154+
"name": "ipython",
155+
"version": 3
156+
},
157+
"file_extension": ".py",
158+
"mimetype": "text/x-python",
159+
"name": "python",
160+
"nbconvert_exporter": "python",
161+
"pygments_lexer": "ipython3",
162+
"version": "3.8.5"
163+
}
164+
},
165+
"nbformat": 4,
166+
"nbformat_minor": 4
167+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /