<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Python Crash Course Exercises
This is an optional exercise to test your understanding of Python Basics. The questions tend to have a financial theme to them, but don't look to deeply into these tasks themselves, many of them don't hold any significance and are meaningless. If you find this extremely challenging, then you probably are not ready for the rest of this course yet and don't have enough programming experience to continue. I would suggest you take another course more geared towards complete beginners, such as Complete Python Bootcamp
Exercises
Answer the questions or complete the tasks outlined in bold below, use the specific method described if applicable.
Task #1
Given price = 300 , use python to figure out the square root of the price.
Step1:  Task #2
Given the string
Step2:  Task #3
 Given the variables
Step3:  Task #4
 Given the variable of a nested dictionary with nested lists
Step4:  Task #5
 Given strings with this form where the last source value is always separated by two dashes -- 
"PRICE
Step5:  Task #5
 Create a function called price_finder that returns True if the word 'price' is in a string. Your function should work even if 'Price' is capitalized or next to punctuation ('price!')
Step6:  Task #6
 Create a function called count_price() that counts the number of times the word "price" occurs in a string. Account for capitalization and if the word price is next to punctuation.
Step7:  Task #7
Create a function called avg_price that takes in a list of stock price numbers and calculates the average (Sum of the numbers divided by the number of elements in the list). It should return a float.
<ASSISTANT_TASK:>
Python Code:
price = 300
import math
math.sqrt( price )
import math
math.sqrt( price )
Explanation: Python Crash Course Exercises
This is an optional exercise to test your understanding of Python Basics. The questions tend to have a financial theme to them, but don't look to deeply into these tasks themselves, many of them don't hold any significance and are meaningless. If you find this extremely challenging, then you probably are not ready for the rest of this course yet and don't have enough programming experience to continue. I would suggest you take another course more geared towards complete beginners, such as Complete Python Bootcamp
Exercises
Answer the questions or complete the tasks outlined in bold below, use the specific method described if applicable.
Task #1
Given price = 300 , use python to figure out the square root of the price.
End of explanation
stock_index = "SP500"
stock_index[2:]
Explanation: Task #2
Given the string:
stock_index = "SP500"
Grab '500' from the string using indexing.
End of explanation
stock_index = "SP500"
price = 300
print('The {quote} is at {price} today'.format(quote=stock_index,price=price))
Explanation: Task #3
 Given the variables:
stock_index = "SP500"
price = 300
 Use .format() to print the following string: 
The SP500 is at 300 today.
End of explanation
stock_info = {'sp500':{'today':300,'yesterday': 250}, 'info':['Time',[24,7,365]]}
stock_info['sp500']['yesterday']
stock_info['info'][1][2]
Explanation: Task #4
 Given the variable of a nested dictionary with nested lists: 
stock_info = {'sp500':{'today':300,'yesterday': 250}, 'info':['Time',[24,7,365]]}
 Use indexing and key calls to grab the following items:
Yesterday's SP500 price (250)
The number 365 nested inside a list nested inside the 'info' key.
End of explanation
def source_finder(str): 
    index = str.find('--')
    return str[index + 2:]
source_finder("PRICE:345.324:SOURCE--QUANDL")
Explanation: Task #5
 Given strings with this form where the last source value is always separated by two dashes -- 
"PRICE:345.324:SOURCE--QUANDL"
Create a function called source_finder() that returns the source. For example, the above string passed into the function would return "QUANDL"
End of explanation
def price_finder(str):
    return str.upper().find('PRICE') != -1
price_finder("What is the price?")
price_finder("DUDE, WHAT IS PRICE!!!")
price_finder("The price is 300")
price_finder("There are no prize is 300")
Explanation: Task #5
 Create a function called price_finder that returns True if the word 'price' is in a string. Your function should work even if 'Price' is capitalized or next to punctuation ('price!')
End of explanation
def count_price(str):
    return str.upper().count('PRICE')
s = 'Wow that is a nice price, very nice Price! I said price 3 times.'
count_price(s)
s = 'ANOTHER pRiCe striNG should reTURN 1'
count_price(s)
Explanation: Task #6
 Create a function called count_price() that counts the number of times the word "price" occurs in a string. Account for capitalization and if the word price is next to punctuation.
End of explanation
def avg_price(prices):
    return sum(prices) / len(prices)
avg_price([3,4,5])
Explanation: Task #7
Create a function called avg_price that takes in a list of stock price numbers and calculates the average (Sum of the numbers divided by the number of elements in the list). It should return a float.
End of explanation
<END_TASK>