def power(a,b):
# ** What is 7 to the power of 4?**
return a**b
def split_str(s):
# ** Split this string:**
return s.split()
def format(planet,diameter): print('The diameter of {} is {} kilometers.'.format(planet,diameter))
return None
def indexing(lst):
#lst = [1,2,[3,4],[5,[100,200,['hello']],23,11],1,7]
return lst[3][1][2][0]
#indexing(lst)
def dictionary(d):
return d['k1'][3]['tricky'][3]['target'][3]
def subjective():
return immutable
def domainGet(email):
# ** Create a function that grabs the email website domain from a string in the form: **
So for example, passing "user@domain.com" would return: domain.com
return email.split('@')[1]
def findDog(st): st=st.lower() if (st.find('dog')==-1): val ='False' else: val='True'
** Create a basic function that returns True if the word 'dog' is contained in the input string. Don't worry about edge cases like a punctuation being attached to the word dog, but do account for capitalization. **
return val
def countDog(st): st=st.lower()
** Create a function that counts the number of times the word "dog" occurs in a string. Again ignore edge cases. **
return st.count('dog')
def lambdafunc(seq):
# ** Use lambda expressions and the filter() function to filter out words from a list that don't start with the letter 's'. For example:**
return list(filter( lambda item:item[0]=='s',seq))
def caught_speeding(speed, is_birthday): if(is_birthday==True): speed=speed-5
if(speed<=60):
valu="No ticket"
elif(speed<=80):
valu="Small ticket"
else:
valu="Big Ticket"
and 80 inclusive, the result is "Small Ticket". If speed is 81 or more, the result is "Big Ticket". Unless it is your birthday (encoded as a boolean value in the parameters of the function) -- on your birthday, your speed can be 5 higher in all
return valu
import numpy as np
def create_arr_of_fives(): arr=np.ones(5); arr=arr*5;
return list(arr)
def even_num(): arr=np.linspace(0,50,26)
return list(arr)
def create_matrix(): arr=np.arange(9) arr=list(arr.reshape(3,3))
return arr
def linear_space(): l=np.linspace(0,1,20)
return list(l)
def decimal_mat(): li=np.linspace(1,100,100).reshape(10,10) li=li/100
return list(li)
def slices_1():
arr = np.arange(1,26).reshape(5,5)
arr=arr[2:,1:]
return list(arr)
def slices_2():
arr = np.arange(1,26).reshape(5,5)
arr=arr[:3,1]
return list(arr)
def slices_3():
arr = np.arange(1,26).reshape(5,5)
arr=arr[3:,:]
return list(arr)