Calculating Correlation

Follow the link to calculate correlation between two stocks

https://www.tradingview.com/wiki/Correlation_Coefficient_(CC)

Set 7 Exercises

1) Create a for loop from 30 to 300, printing every other number 2) Create a for loop from 500 to 30, printing every number. 3) Create a for loop from 1000 to 1 printing every 3rd number. (I.E. - 1000, 997, 994...) 4) Create a for loop from 1 to 15 printing only multiples of 3. 5) Ask the user to input 5 decimal values. Add them to a list called values. Loop through the list and print a total count of how many items are within 10 of 100. 6) Ask the user to input 5 decimal values. Add them to a list called vals. Loop through the list and print the total sum of all the elements in the list. 7) Ask the user to input 5 decimal values. Add them to a list called vals. Loop through the list and print the result of multiplying all the numbers in the list. 8) Ask the user to input 5 decimal values. Add them to a list called vals. Loop through the list and if one of the numbers in the list is 10 AND the sum of the numbers in the list are equal to 10, print("10 is present in the list") Otherwise, print("10 is not present in the list") 9) Ask the user to input 5 decimal values. Add them to a list called vals. Loop through the list and if one of the numbers in the list is 10 OR the sum of the numbers in the list are equal to 10, print("10 is present in the list") Otherwise, print("10 is not present in the list") 10) Ask the user to input 5 decimal values. Add them to a list called vals. If the first number and the last element in the list are equal, print("The first and last items are equal to each other") otherwise, print("The first and last items are not equal") 11) Ask the user to input 5 decimal values. Add them to a list called values. Loop through the list and print a total count of how many items are within 10 of 100 or 200. 12) Ask the user to input 5 decimal values. Add them to a list called values. Loop through this list and add each item to a new list called reversed. The new list will have all the same items from the original list except reversed. I.E. - values = [1, 2, 3, 4, 5] reversed = [5, 4, 3, 2, 1] 13) Ask the user to input 5 decimal values. Add them to a list called values. If the values in the list added together is less than 50, print("The total sum is less than 50") otherwise, print("The total sum is greater than 50") 14) Create a program which will ask for your recent exam score out of 80 and tell you what grade you got and how many more points you would have needed to get the next grade up. A - 90% and above B- 80% to 89.9% C- 70% to 79.99%

Finding the sum of the values in a list/average value

This post will show more list operations. Specifically how to find the sum and average values of a list of numbers.

Adding total value to an existing variable

When we have an existing variable for an integer or float, we can add value to it by taking the existing value and increasing it. Example below: x = 5 x = x + 5 print(x) y = 10 y = y * 10 print(y) When running this code, we would see that x equals 10 and y = 100.

Appending (Adding an item) to a List

This code will show you how you can add an item to a list. If we wrote the following code below: numbers = [] numbers.append(10) print(numbers) ---Output: [10] values = ["hello"] values.append("Hi") print(values) ---Output: ["hello", "Hi"]

Looping through a List

This shows how to loop through a list

Length of a List Python - Important for loops

How to use the len() function and how to reference the last item of a list

Set 6 Exercise: Rock-Paper-Scissors

Implement this game of rock-paper-scissors where the user plays against the computer. Think about how to store all the possible choices for the computer in a list and randomly assign the computers choice every round. The user should input their choice of rock, paper or scissors.


Printing Specific Values from a List

This will show how to print out specific items in a list

items = ["clothes", "bags", "shoes"] x = items[1] print(x)

List Positons (Indeces)

This video introduces the concept of list indeces which will be very important going forward.

Creating Lists With Predefined Variables

This shows how to create lists with predefined variables. Example: x = 10 y = 20 z = 30 numbers = [x, y, z] print(numbers)

Lists With Integers

This shows how to create lists with integers. list1 = [1, 2, 3, 4] For floats: list2 = [2.0, 3.5, 4.8]