-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathpython_intro.py
More file actions
99 lines (77 loc) · 2.37 KB
/
Copy pathpython_intro.py
File metadata and controls
99 lines (77 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# python_intro.py
"""Python Essentials: Introduction to Python.
<Name>
<Class>
<Date>
"""
# Problem 1 (write code below)
# Problem 2
def sphere_volume(r):
"""Return the volume of the sphere of radius 'r'.
Use 3.14159 for pi in your computation.
"""
raise NotImplementedError("Problem 2 Incomplete")
# Problem 3
def isolate(a, b, c, d, e):
"""Print the arguments separated by spaces, but print 5 spaces on either
side of b.
"""
raise NotImplementedError("Problem 3 Incomplete")
# Problem 4
def first_half(my_string):
"""Return the first half of the string 'my_string'. Exclude the
middle character if there are an odd number of characters.
Examples:
>>> first_half("python")
'pyt'
>>> first_half("ipython")
'ipy'
"""
raise NotImplementedError("Problem 4 Incomplete")
def backward(my_string):
"""Return the reverse of the string 'my_string'.
Examples:
>>> backward("python")
'nohtyp'
>>> backward("ipython")
'nohtypi'
"""
raise NotImplementedError("Problem 4 Incomplete")
# Problem 5
def list_ops():
"""Define a list with the entries "bear", "ant", "cat", and "dog".
Perform the following operations on the list:
- Append "eagle".
- Replace the entry at index 2 with "fox".
- Remove (or pop) the entry at index 1.
- Sort the list in reverse alphabetical order.
- Replace "eagle" with "hawk".
- Add the string "hunter" to the last entry in the list.
Return the resulting list.
Examples:
>>> list_ops()
['fox', 'hawk', 'dog', 'bearhunter']
"""
raise NotImplementedError("Problem 5 Incomplete")
# Problem 6
def pig_latin(word):
"""Translate the string 'word' into Pig Latin, and return the new word.
Examples:
>>> pig_latin("apple")
'applehay'
>>> pig_latin("banana")
'ananabay'
"""
raise NotImplementedError("Problem 6 Incomplete")
# Problem 7
def palindrome():
"""Find and retun the largest panindromic number made from the product
of two 3-digit numbers.
"""
raise NotImplementedError("Problem 7 Incomplete")
# Problem 8
def alt_harmonic(n):
"""Return the partial sum of the first n terms of the alternating
harmonic series, which approximates ln(2).
"""
raise NotImplementedError("Problem 8 Incomplete")