Skip to content

Commit 3b65e0a

Browse files
committed
u22
1 parent 4483764 commit 3b65e0a

10 files changed

+854
-277
lines changed

.ipynb_checkpoints/Introduction to Jupyter Notebooks-checkpoint.ipynb

Lines changed: 0 additions & 77 deletions
This file was deleted.

.ipynb_checkpoints/Introduction to Notebooks-checkpoint.ipynb

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {
6+
"collapsed": true
7+
},
8+
"source": [
9+
"#Statements Assessment Solutions"
10+
]
11+
},
12+
{
13+
"cell_type": "markdown",
14+
"metadata": {},
15+
"source": [
16+
"_____\n",
17+
"**Use for, split(), and if to create a Statement that will print out letters that start with 's':**"
18+
]
19+
},
20+
{
21+
"cell_type": "code",
22+
"execution_count": 3,
23+
"metadata": {
24+
"collapsed": true
25+
},
26+
"outputs": [],
27+
"source": [
28+
"st = 'Print only the words that start with s in this sentence'"
29+
]
30+
},
31+
{
32+
"cell_type": "code",
33+
"execution_count": 4,
34+
"metadata": {
35+
"collapsed": false
36+
},
37+
"outputs": [
38+
{
39+
"name": "stdout",
40+
"output_type": "stream",
41+
"text": [
42+
"start\n",
43+
"s\n",
44+
"sentence\n"
45+
]
46+
}
47+
],
48+
"source": [
49+
"for word in st.split():\n",
50+
" if word[0] == 's':\n",
51+
" print word"
52+
]
53+
},
54+
{
55+
"cell_type": "markdown",
56+
"metadata": {},
57+
"source": [
58+
"______\n",
59+
"**Use range() to print all the even numbers from 0 to 10.**"
60+
]
61+
},
62+
{
63+
"cell_type": "code",
64+
"execution_count": 1,
65+
"metadata": {
66+
"collapsed": false
67+
},
68+
"outputs": [
69+
{
70+
"data": {
71+
"text/plain": [
72+
"[0, 2, 4, 6, 8, 10]"
73+
]
74+
},
75+
"execution_count": 1,
76+
"metadata": {},
77+
"output_type": "execute_result"
78+
}
79+
],
80+
"source": [
81+
"range(0,11,2)"
82+
]
83+
},
84+
{
85+
"cell_type": "markdown",
86+
"metadata": {},
87+
"source": [
88+
"___\n",
89+
"**Use List comprehension to create a list of all numbers between 1 and 50 that are divisble by 3.**"
90+
]
91+
},
92+
{
93+
"cell_type": "code",
94+
"execution_count": 2,
95+
"metadata": {
96+
"collapsed": false
97+
},
98+
"outputs": [
99+
{
100+
"data": {
101+
"text/plain": [
102+
"[0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48]"
103+
]
104+
},
105+
"execution_count": 2,
106+
"metadata": {},
107+
"output_type": "execute_result"
108+
}
109+
],
110+
"source": [
111+
"[x for x in range(50) if x%3 == 0]"
112+
]
113+
},
114+
{
115+
"cell_type": "markdown",
116+
"metadata": {},
117+
"source": [
118+
"_____\n",
119+
"**Go through the string below and if the length of a word is even print \"even!\"**"
120+
]
121+
},
122+
{
123+
"cell_type": "code",
124+
"execution_count": 6,
125+
"metadata": {
126+
"collapsed": true
127+
},
128+
"outputs": [],
129+
"source": [
130+
"st = 'Print every word in this sentence that has an even number of letters'"
131+
]
132+
},
133+
{
134+
"cell_type": "code",
135+
"execution_count": null,
136+
"metadata": {
137+
"collapsed": true
138+
},
139+
"outputs": [],
140+
"source": []
141+
},
142+
{
143+
"cell_type": "markdown",
144+
"metadata": {},
145+
"source": [
146+
"____\n",
147+
"**Write a program that prints the integers from 1 to 100. But for multiples of three print \"Fizz\" instead of the number, and for the multiples of five print \"Buzz\". For numbers which are multiples of both three and five print \"FizzBuzz\".**"
148+
]
149+
},
150+
{
151+
"cell_type": "code",
152+
"execution_count": null,
153+
"metadata": {
154+
"collapsed": false
155+
},
156+
"outputs": [],
157+
"source": [
158+
"for num in xrange(1,101):\n",
159+
" if num % 5 == 0 and num % 3 == 0:\n",
160+
" print \"FizzBuzz\"\n",
161+
" elif num % 3 == 0:\n",
162+
" print \"Fizz\"\n",
163+
" elif num % 5 == 0:\n",
164+
" print \"Buzz\"\n",
165+
" else:\n",
166+
" print num"
167+
]
168+
},
169+
{
170+
"cell_type": "markdown",
171+
"metadata": {},
172+
"source": [
173+
"____\n",
174+
"**Use List Comprehension to create a list of the first letters of every word in the string below:**"
175+
]
176+
},
177+
{
178+
"cell_type": "code",
179+
"execution_count": 8,
180+
"metadata": {
181+
"collapsed": true
182+
},
183+
"outputs": [],
184+
"source": [
185+
"st = 'Create a list of the first letters of every word in this string'"
186+
]
187+
},
188+
{
189+
"cell_type": "code",
190+
"execution_count": null,
191+
"metadata": {
192+
"collapsed": true
193+
},
194+
"outputs": [],
195+
"source": []
196+
},
197+
{
198+
"cell_type": "markdown",
199+
"metadata": {},
200+
"source": [
201+
"### Great Job!"
202+
]
203+
}
204+
],
205+
"metadata": {
206+
"kernelspec": {
207+
"display_name": "Python 2",
208+
"language": "python",
209+
"name": "python2"
210+
},
211+
"language_info": {
212+
"codemirror_mode": {
213+
"name": "ipython",
214+
"version": 2
215+
},
216+
"file_extension": ".py",
217+
"mimetype": "text/x-python",
218+
"name": "python",
219+
"nbconvert_exporter": "python",
220+
"pygments_lexer": "ipython2",
221+
"version": "2.7.10"
222+
}
223+
},
224+
"nbformat": 4,
225+
"nbformat_minor": 0
226+
}

0 commit comments

Comments
 (0)