Skip to content

Instantly share code, notes, and snippets.

View chicagowebmanagement's full-sized avatar

Patrick Elward chicagowebmanagement

View GitHub Profile
"""
Author: Patrick Elward
Date: 04/01/2019
convert string to list using "?" as delimiter
"""
x="Where now? Who now? When now?"
@chicagowebmanagement
chicagowebmanagement / replace-screaming.py
Created April 2, 2019 03:54
Replace every instance of "s" in "A screaming comes across the sky." with a dollar sign.
"""
Author: Patrick Elward
Date: 04/01/2019
Replace every instance of "s" in "A screaming comes across the sky." with a dollar sign.
"""
x="A screaming comes across the sky."
y= x.replace("s","$")
print(y)
@chicagowebmanagement
chicagowebmanagement / hemingway.py
Created April 2, 2019 04:06
6. Use a method to find the first index of the character "m" in the string "Hemingway".
"""
Author: Patrick Elward
Date: 04/01/2019
6. Use a method to find the first index of the character "m" in the string "Hemingway".
"""
x=list("Hemingway")
print("Convert to List results: ",x) # this proves string is now a list (think 'training wheels' for this new coder!)
@chicagowebmanagement
chicagowebmanagement / six-gist-results-STRING.txt
Created April 2, 2019 04:08
List of six exercises and their gist results
1. Print every character in the string "Camus".
https://gist.github.com/chicagowebmanagement/b0db1a567e84c0326f15110ea532320e
2. Write a program that collects two strings from a user, inserts them into the string "Yesterday I wrote a [response_one]. I sent it to [response_ two]!" and prints a new string.
https://gist.github.com/chicagowebmanagement/d31f529d8281f917b9b40f357a0b04a0
3. Use a method to make the string "aldous Huxley was born in 1894." grammatically correct by capitalizing the first letter in the sentence.
https://gist.github.com/chicagowebmanagement/e785b42e4e39657d6d67a6f4da739d18
@chicagowebmanagement
chicagowebmanagement / functions-list.py
Created April 3, 2019 21:14
learning how to append items in a list
def func(a,L=[]):
L.append(a)
return L
print(func(1),func(3))
@chicagowebmanagement
chicagowebmanagement / turn-string-to-quote.py
Created April 3, 2019 21:22
Find dialogue in your favorite book (containing quotes) and turn it into a string.
x='"I think the big mistake in schools is trying to teach children anything, and by using fear as the basic motivation. Fear of getting failing grades, fear of not staying with your class, etc. Interest can produce learning on a scale compared to fear as a nuclear explosion to a firecracker.” - Stanley Kubrick'
print(x)
@chicagowebmanagement
chicagowebmanagement / string-remove-replace.py
Created April 4, 2019 23:08
string replace one character and remove latter part of string
"""
Author: Patrick Elward
Date: 04/04/2019
Slice the string "It was a bright cold day in April, and the clocks were striking thirteen."
to only include the characters BEFORE the comma
Since I don't know the 'character count' of the comma, I can't use slice, but if I split them into a list, then I can simply print the first item in list.
"""
@chicagowebmanagement
chicagowebmanagement / for-loop-list.py
Created April 11, 2019 02:28
print each item in a list using for loop
"""
Author: Patrick Elward
Date: 04/10/2019
Print each item in this list: ["The Walking Dead", "Entourage", "The Sopranos", "The Vampire Diaries"].
"""
shows = ["The Walking Dead", "Entourage", "The Sopranos", "The Vampire Diaries"]
for show in shows:
print(show)
@chicagowebmanagement
chicagowebmanagement / print-range.py
Created April 11, 2019 02:31
print range of numbers
"""
Author: Patrick Elward
Date: 04/10/2019
An Example of XXX
Print all the numbers from 25 to 50
"""
home_on_range=range(25,51)
for home in home_on_range:
"""
Author: Patrick Elward
Date: 04/10/2019
Print each item in the list from the first challenge and their indexes
["The Walking Dead", "Entourage", "The Sopranos", "The Vampire Diaries"]
"""
shows= ["The Walking Dead", "Entourage", "The Sopranos", "The Vampire Diaries"]
i=0
for show in shows: