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
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ name = "pypi"
[packages]

[dev-packages]
pylint = "*"

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

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

14 changes: 11 additions & 3 deletions src/day-1-toy/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@

# Write a function f1 that takes two integer positional arguments and returns
# the sum. This is what you'd consider to be a regular, normal function.

def f1(a,b):
return a+b
#def f1(...

print(f1(1, 2))

# Write a function f2 that takes any number of iteger arguments and prints the
# sum. Google for "python arbitrary arguments" and look for "*args"

def f2(*args):
#sum something goes here
# def f2(...

print(f2(1)) # Should print 1
Expand All @@ -26,7 +28,8 @@
# Write a function f3 that accepts either one or two arguments. If one argument,
# it returns that value plus 1. If two arguments, it returns the sum of the
# arguments. Google "python default arguments" for a hint.

def f3(a,b=1):
return a+b #?
#def f3(...

print(f3(1, 2)) # Should print 3
Expand All @@ -40,7 +43,12 @@
# key: baz, value: 12
#
# Google "python keyword arguments".
#its like **args from above
#do whatyou did dictionaries.

def f4(**kwargs):
for keys, vals in kwargs.items():
print("")
#def f4(...

# Should print
Expand Down
1 change: 1 addition & 0 deletions src/day-1-toy/bar.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hi my name is...
3 changes: 2 additions & 1 deletion src/day-1-toy/bignum.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# Print out 2 to the 65536 power
# Print out 2 to the 65536 power
print(2**65536)
5 changes: 5 additions & 0 deletions src/day-1-toy/cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@
# docs for the calendar module closely.

import sys
import calendar
import datetime

year = int(input("Enter the year: "))
month = int(input("Enter Month 1 - 12: "))
9 changes: 5 additions & 4 deletions src/day-1-toy/comp.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Write a list comprehension to produce the array [1, 2, 3, 4, 5]
# y = [1,2,3,4,5] as well, but this is a list comprehension

y = []
y = [i for i in range(1,6)]

print (y)

# Write a list comprehension to produce the cubes of the numbers 0-9:
# [0, 1, 8, 27, 64, 125, 216, 343, 512, 729]

y = []
y = [i**3 for i in range(1,10)]

print(y)

Expand All @@ -16,7 +17,7 @@

a = ["foo", "bar", "baz"]

y = []
y = [i.upper() for i in a]

print(y)

Expand All @@ -26,7 +27,7 @@
x = input("Enter comma-separated numbers: ").split(',')

# What do you need between the square brackets to make it work?
y = []
y = [i for i in x if int(i) % 2 == 0]

print(y)

4 changes: 2 additions & 2 deletions src/day-1-toy/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
y = "7"

# Write a print statement that combines x + y into the integer value 12
print(x + y)
print(int(y)+ x)

# Write a print statement that combines x + y into the string value 57
print(x + y)
print(str(x)+ y)
3 changes: 3 additions & 0 deletions src/day-1-toy/dicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@
]

# Write a loop that prints out all the field values for all the waypoints
for vals in waypoints:
print(vals['lat'], vals['lon'], vals['name'])

# Add a new waypoint to the list
waypoints.append({"lat": 100, "lon": -500, "name": "The Unknown"})
14 changes: 8 additions & 6 deletions src/day-1-toy/fileio.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Use open to open file "foo.txt" for reading

openFoo = open("foo.txt", "r")
# Print all the lines in the file

for words in openFoo:
print(words)
# Close the file

openFoo.close()

# Use open to open file "bar.txt" for writing

openBar = open("bar.txt", "w")
# Use the write() method to write three lines to the file

# Close the file
openBar.write("Hi my name is...")
# Close the file
openBar.close()
15 changes: 14 additions & 1 deletion src/day-1-toy/func.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# Write a function is_even that will return true if the passed in number is even.
def even_num(y):
if y % 2 == 0:
return y

# Read a number from the keyboard
num = input("Enter a number: ")

# Print out "Even!" if the number is even. Otherwise print "Odd"
# Print out "Even!" if the number is even. Otherwise print "Odd"

# So it reads it off the keyboard as a string?
# have to convert to num?

num = int(num)

if even_num(num):
print("even")
else:
print("odd")
3 changes: 2 additions & 1 deletion src/day-1-toy/hello.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# Write Hello, world
# Write Hello, world
print("Hello, world")
13 changes: 7 additions & 6 deletions src/day-1-toy/lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@
# For the following, DO NOT USE AN ASSIGNMENT (=).

# Change x so that it is [1, 2, 3, 4]
# [command here]
x.append(4)
print(x)

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

# Change x so that it is [1, 2, 3, 4, 9, 10]
# [command here]
x.remove(8)
print(x)

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

# Print the length of list x
# [command here]
print(len(x))

# Using a for loop, print all the element values multiplied by 1000
# Using a for loop, print all the element values multiplied by 1000
for i in x:
print(i*1000)
13 changes: 6 additions & 7 deletions src/day-1-toy/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
# 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:

print(sys.argv)

# Print out the plaform from sys:
print()
print(sys.platform)

# Print out the Python version from sys:
print()
print(sys.version)



Expand All @@ -21,11 +21,10 @@
# See the docs for the OS module: https://docs.python.org/3.7/library/os.html

# Print the current process ID
print()
print(os.getpid())

# Print the current working directory (cwd):
print()
print(os.getcwd())

# Print your login name
print()

print(os.getlogin())
22 changes: 20 additions & 2 deletions src/day-1-toy/obj.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,39 @@
# Make a class LatLon that can be passed parameters `lat` and `lon` to the
# constructor
class LatLon:
def __init__(self, lat, lon):
self.lat = lat
self.lon = lon

# Make a class Waypoint that can be passed parameters `name`, `lat`, and `lon` to the
# constructor. It should inherit from LatLon.
class Waypoint(LatLon):
def __init__(self, name, lat, lon):
super().__init__(lat, lon)
self.name = name


# Make a class Geocache that can be passed parameters `name`, `difficulty`,
# `size`, `lat`, and `lon` to the constructor. What should it inherit from?
class Geocache(Waypoint):
def __init__(self, name, difficulty, size, lat, lon):
super().__init__(name, lat, lon)
self.difficulty = difficulty
self.size = size

# Make a new waypoint "Catacombs", 41.70505, -121.51521
new_waypoint = Waypoint("Catacombs", 41.70505, -121.51521)

print(new_waypoint)

# Print it
#
# Without changing the following line, how can you make it print into something
# more human-readable?
print(w)
print(new_waypoint.name)

# Make a new geocache "Newberry Views", diff 1.5, size 2, 44.052137, -121.41556
new_geocache = Geocache("Newberry Views", 1.5, 2, 44.052137, -121.41556)

# Print it--also make this print more nicely
print(g)
print(new_geocache.size)
4 changes: 2 additions & 2 deletions src/day-1-toy/printf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
# y, and z:
# x is 10, y is 2.25, z is "I like turtles!"


# Use the 'format' string method to print the same thing
# Use the 'format' string method to print the same thing
print("x is %d, y is %f, z is %s" % (x, y, z))
Loading