An introduction to curl using GitHub's API
Makes a basic GET request to the specifed URI
curl https://api.github.com/users/cibofdevs
#Provided is a list of tuples. Create another list called t_check that contains the third element of every tuple. | |
lst_tups = [('Articuno', 'Moltres', 'Zaptos'), ('Beedrill', 'Metapod', 'Charizard', 'Venasaur', 'Squirtle'), ('Oddish', 'Poliwag', 'Diglett', 'Bellsprout'), ('Ponyta', "Farfetch'd", "Tauros", 'Dragonite'), ('Hoothoot', 'Chikorita', 'Lanturn', 'Flaaffy', 'Unown', 'Teddiursa', 'Phanpy'), ('Loudred', 'Volbeat', 'Wailord', 'Seviper', 'Sealeo')] | |
t_check = [] | |
for x in lst_tups: | |
t_check.append(x[2]) | |
print (t_check) | |
#Below, we have provided a list of tuples. |
##To start, define a function called strip_punctuation which takes one parameter, a string which represents a word, and removes characters considered punctuation from everywhere in the word. (Hint: remember the .replace() method for strings.) | |
punctuation_chars = ["'", '"', ",", ".", "!", ":", ";", '#', '@'] | |
def strip_punctuation(word): | |
New_word="" | |
print("Word is: ",word) | |
for w in word: | |
if w not in punctuation_chars: |
## The .items() method produces a sequence of key-value pair tuples. With this in mind, write code to create a list of keys from the dictionary track_medal_counts and assign the list to the variable name track_events. Do NOT use the .keys() method. | |
track_medal_counts = {'shot put': 1, 'long jump': 3, '100 meters': 2, '400 meters': 2, '100 meter hurdles': 3, 'triple jump': 3, 'steeplechase': 2, '1500 meters': 1, '5K': 0, '10K': 0, 'marathon': 0, '200 meters': 0, '400 meter hurdles': 0, 'high jump': 1} | |
track_keys=[] | |
for i in track_medal_counts.items(): | |
track_keys.append(i[0]) | |
track_events=track_keys |
## Write two functions, one called addit and one called mult. addit takes one number as an input and adds 5. mult takes one number as an input, and multiplies that input by whatever is returned by addit, and then returns the result. | |
def addit(a): | |
add = a+5 | |
return add | |
def mult(a): | |
return a*addit(a) | |
addit(5) | |
Create a dictionary that keeps track of the USA’s Olympic medal count. Each key of the dictionary should be the type of medal (gold, silver, or bronze) and each key’s value should be the number of that type of medal the USA’s won. Currently, the USA has 33 gold medals, 17 silver, and 12 bronze. Create a dictionary saved in the variable medals that reflects this information. | |
medals={} | |
medals['gold']=33 | |
medals['silver']=17 | |
medals['bronze']=12 | |
print (medals) |
## Write code to take ‘London’ out of the list trav_dest. | |
trav_dest = ['Beirut', 'Milan', 'Pittsburgh', 'Buenos Aires', 'Nairobi', 'Kathmandu', 'Osaka', 'London', 'Melbourne'] | |
trav_dest.remove('London') |
str1 = "I love python" | |
chars = [] | |
for i in str1: | |
chars.append(i) |
words = ["adopt", "bake", "beam", "confide", "grill", "plant", "time", "wave", "wish"] | |
past_tense = [] | |
for i in words: | |
if(i[len(i)-1] == 'e'): | |
i += 'd' | |
else: | |
i += 'ed' | |
past_tense.append(i) |
words = ["water", "chair", "pen", "basket", "hi", "car"] | |
num_words = 0 | |
for i in words: | |
if len(i) > 3: | |
num_words += 1 |