Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ name = "pypi"
[packages]

[dev-packages]
pylint = "<2.0.0"
autopep8 = "*"

[requires]
python_version = "3"
87 changes: 85 additions & 2 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/00_hello.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# Print "Hello, world!" to your terminal
# Print "Hello, world!" to your terminal
msg= "Hello, World!"
print(msg)
4 changes: 3 additions & 1 deletion src/01_bignum.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Print out 2 to the 65536 power
# (try doing the same thing in the JS console and see what it outputs)

# YOUR CODE HERE
# YOUR CODE HERE
power=2**65536
print(power)
5 changes: 4 additions & 1 deletion src/02_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
# Write a print statement that combines x + y into the integer value 12

# YOUR CODE HERE
print(x+int(y))


# Write a print statement that combines x + y into the string value 57

# YOUR CODE HERE
# YOUR CODE HERE

print (str(x)+y)
21 changes: 17 additions & 4 deletions src/03_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,39 @@
"""

import sys
import os
# See docs for the sys module: https://docs.python.org/3.7/library/sys.html

# Print out the command line arguments in sys.argv, one per line:
# YOUR CODE HERE

print('')
print(sys.argv[0])
print('')
# print(sys.executable)
# Print out the OS platform you're using:
# YOUR CODE HERE
print(sys.platform)
print('')

# Print out the version of Python you're using:
# YOUR CODE HERE
print(sys.version)
print('')


import os
# See the docs for the OS module: https://docs.python.org/3.7/library/os.html

# Print the current process ID
# YOUR CODE HERE

print(os.environ["TERM_SESSION_ID"])
print('')
# Print the current working directory (cwd):
# YOUR CODE HERE

# print(os.getcwd())
# print('')
print(os.environ["PWD"])
print('')
# Print out your machine's login name
# YOUR CODE HERE
print(os.environ["USER"])
print('')
6 changes: 4 additions & 2 deletions src/04_printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
# Using the printf operator (%), print the following feeding in the values of x,
# y, and z:
# x is 10, y is 2.25, z is "I like turtles!"

print('x is %s, y is %s, z is %s' % (x, y, z))
# Use the 'format' string method to print the same thing
print('x is {}, y is {}, z is {}'.format(x, y, z))

# Finally, print the same thing using an f-string
# Finally, print the same thing using an f-string
print(f'x is {x}, y is {y}, z is {z}')
21 changes: 15 additions & 6 deletions src/05_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,32 @@
# For the following, DO NOT USE AN ASSIGNMENT (=).

# Change x so that it is [1, 2, 3, 4]
# YOUR CODE HERE
# YOUR CODE HERE
x.append(4)
print(x)

# Using y, change x so that it is [1, 2, 3, 4, 8, 9, 10]
# YOUR CODE HERE
# YOUR CODE HERE
x.extend(y)
print(x)

# Change x so that it is [1, 2, 3, 4, 9, 10]
# YOUR CODE HERE
# YOUR CODE HERE
x.pop(4)
print(x)

# Change x so that it is [1, 2, 3, 4, 9, 99, 10]
# YOUR CODE HERE
# YOUR CODE HERE
x.insert(5, 99)
print(x)

# Print the length of list x
# YOUR CODE HERE
# YOUR CODE HERE
print(len(x))

# Print all the values in x multiplied by 1000
# YOUR CODE HERE
# YOUR CODE HERE
z = []
for i in x:
z.append(i*10)
print(z)
12 changes: 9 additions & 3 deletions src/06_tuples.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,34 @@

import math


def dist(a, b):
"""Compute the distance between two x,y points."""
x0, y0 = a # Destructuring assignment
x1, y1 = b

return math.sqrt((x1 - x0)**2 + (y1 - y0)**2)


a = (2, 7) # <-- x,y coordinates stored in tuples
b = (-14, 72)

# Prints "Distance is 66.94"
print("Distance is: {:.2f}".format(dist(a, b)))



# Write a function `print_tuple` that prints all the values in a tuple

# YOUR CODE HERE
def print_tuple(c):
for i in c:
print(i)
return


t = (1, 2, 5, 7, 99)
print_tuple(t) # Prints 1 2 5 7 99, one per line

# Declare a tuple of 1 element then print it
u = (1) # What needs to be added to make this work?
u = (1,) # What needs to be added to make this work?
print_tuple(u)
16 changes: 9 additions & 7 deletions src/07_slices.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,28 @@
a = [2, 4, 1, 7, 9, 6]

# Output the second element: 4:
print()
print(a[1])

# Output the second-to-last element: 9
print()
print(a[-2:-1][0])

# Output the last three elements in the array: [7, 9, 6]
print()
print(a[-3])

# Output the two middle elements in the array: [1, 7]
print()
# l = len(a)
h = int(len(a)/2)
print(a[h-1:h+1])

# Output every element except the first one: [4, 1, 7, 9, 6]
print()
print(a[1:])

# Output every element except the last one: [2, 4, 1, 7, 9]
print()
print(a[:-1])

# For string s...

s = "Hello, world!"

# Output just the 8th-12th characters: "world"
print()
print(s[7:12])