3.1. Exercises
Range Questions
numericals = []
for j in range(30,60,5):
numericals.append(j)
numericalsCoding questions
Instructions:
Running a coding exercise for the first time could take a bit of time for everything to load. Be patient, it could take a few minutes.
When you see ____ in a coding exercise, replace it with what you assume to be the correct code. Run it and see if you obtain the desired output. Submit your code to validate if you were correct.
Make sure you remove the hash (#) symbol in the coding portions of this question. We have commented them so that the line won’t execute and you can test your code after each step.
Practice Iterating using Range
Let’s make a loop again but this time let’s practice using the range() verb.
Tasks:
- Iterate over a range from 50 to 10, stepping down 4 integers at a time.
- Append the square of each number for each iteration to
square_list. - Display the value of
square_list.
Applying Range with Dataframes
Let’s read in multiple dataframes together and concatenate them vertically to one large dataframe using a loop and the range() function.
Tasks:
- There are 4 dataframes named
pkm1.csvtopkm4.csv. that we wish to load in and vertically concatenate together. - Fill in the blanks so the code reads in each dataframe according to their differing file name and concatenates them together.
- Display the final dataframe.