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 efc0ce7

Browse files
Add files via upload
1 parent de50282 commit efc0ce7

File tree

4 files changed

+94
-47
lines changed

4 files changed

+94
-47
lines changed

‎Section_02/assignment_01.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Assignment 1:
22
"""
3-
We would like to get the remainder of 15 divided by 4.
4-
The calculation below does not seem to give us this result.
5-
How would you change the code to meet the requirement?
3+
Print Bill's salary from the my_list object shown below.
64
7-
"""
5+
my_list = [{'Tom': 20000, 'Bill': 12000}, ['car', 'laptop', 'TV']]
86
7+
"""
98

109

10+
# your code below:
1111

1212

1313

@@ -44,8 +44,7 @@
4444

4545

4646

47-
# Solution:
4847

49-
# remainder = 15 % 4
50-
# print(remainder)
5148

49+
# Solution
50+
# print(my_list[0].get('Bill'))

‎Section_02/assignment_02.py

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,55 @@
11
# Assignment 2:
22
"""
3-
Use of the below format() method is incorrect for what we are trying to do.
4-
We actually have 10 small, 12 large, and 12 medium boxes.
5-
Write code to correct this:
3+
Using some of the collection data types we learned about
4+
in the course so such as a list and dictionary, create a
5+
data structure that best represents the following scenario:
6+
7+
Tom has a salary of 20000 and is 22 years old. He owns a few items such as
8+
a jacket, a car, and TV. Mike is another person who makes 24000 and is 27 years old
9+
who owns a bike, a laptop and boat.
10+
"""
11+
12+
# your code below:
13+
14+
15+
16+
17+
18+
19+
20+
21+
22+
23+
24+
25+
26+
27+
28+
29+
30+
31+
32+
33+
34+
35+
36+
37+
38+
39+
40+
41+
42+
43+
44+
45+
46+
47+
48+
49+
650

751

8-
print("We have {2} small boxes, {2} large boxes, {2} medium boxes".format(10,12,12))
952

10-
"""
1153

1254

1355

@@ -21,4 +63,7 @@
2163

2264

2365

66+
# Solution
2467

68+
# my_list = [{'Tom': {'salary': 20000, 'age': 22, 'owns': ['jacket', 'car', 'TV']}},
69+
# {'Mike': {'salary': 24000, 'age': 27, 'owns': ['bike', 'laptop', 'boat']}}]

‎Section_02/assignment_03.py

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
# Assignment 3:
22
"""
3-
Given 2 variables chars and word, write code to move
4-
the data contained in the variable word in the exact middle of
5-
the characters contained in the variable chars and save this
6-
in a new variable called result and print it.
3+
There is a list shown below titled original_list.
74
8-
NOTE: chars variable will contain only 4 characters
9-
10-
Example:
11-
---------------
12-
chars = "<<>>"
13-
word = "hello"
14-
result - should contain the following string: <<hello>>
5+
Using only what you've learned so far in the course,
6+
write code to create a new list that contains the tuple sorted.
157
8+
IMPORTANT: you must do this programmatically! Don't just
9+
hard code a new list with the values rearranged.
1610
"""
1711

18-
chars = "[[]]"
19-
word = "Cool"
12+
original_list = ['cup', 'cereal', 'milk', (8, 4, 3)]
13+
14+
# your code below:
15+
16+
17+
18+
19+
20+
21+
22+
23+
24+
2025

21-
# Expected Result Printed: [[Cool]]
2226

23-
# Your code below:
2427

2528

2629

@@ -53,7 +56,15 @@
5356

5457

5558

56-
# Solution Below:
57-
# print(chars[:2] + word + chars[2:])
5859

5960

61+
# Solution
62+
# num1 = original_list[3][0]
63+
# num2 = original_list[3][1]
64+
# num3 = original_list[3][2]
65+
# new_list = [num1, num2, num3]
66+
# new_list.sort()
67+
# new_tuple = (new_list[0], new_list[1], new_list[2])
68+
# new_list = [original_list[0], original_list[1], original_list[2], new_tuple]
69+
#
70+
# print(new_list)

‎Section_02/assignment_04.py

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
11
# Assignment 4:
22
"""
3-
Given 2 variables word1 and word2, write code to
4-
print the concatenation of the 2 words omitting the
5-
first_folder letter of the string saved in word1 and the second_folder
6-
letter of the string saved in word2.
7-
8-
Example:
9-
---------------
10-
word1 = "Vehicle"
11-
word2 = "Robot"
12-
result - ehicleRbot
13-
3+
In the list shown below, replace the letter m with the letter x
4+
and replace the word TV with the word television. Then print my_list.
145
"""
156

16-
word1 = "Computer"
17-
word2="Truck"
7+
my_list = [(1, 2), (3, 4), (['c', 'd', 'a', 'm'], [3, 9, 4, 12], 4), 'TV', 42]
8+
189

19-
# Expected Result Printed: omputerTuck
10+
# Your Code Below:
2011

21-
# Your code below:
2212

2313

2414

2515

2616

2717

18+
print(my_list)
2819

2920

3021

@@ -56,8 +47,9 @@
5647

5748

5849

59-
# Solution Below:
60-
# result = word1[1:] + word2[0:1] + word2[2:]
61-
# print(result)
6250

6351

52+
# Solution:
53+
# my_list[2][0][3] = 'x'
54+
# my_list[3] = 'Television'
55+
# print(my_list)

0 commit comments

Comments
(0)

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