MODULE 1

READING:

  1. thinkcspy Chp 1-2

  2. Data Types

TASKS:

  1. Install Python on your device. Read the #python-installation channel on the Discord server.

  2. Do P-Set 1

P-Set 1

Remember to document your code well. Report all results in a LaTeX-rendered PDF document. Submit your .py file and your .PDF file in a single compressed folder (.7z, .zip, or .rar).

TASK:

John List wishes to better understand South Side crime. To do so, we wish to conduct interviews with South Side residents and understand the demographics of South Side Chicago before conducting a field experiment.

  1. What are potential data that we would wish to collect from each individual? Propose 10 variables that we may want to collect in a survey, including, at the very least, these 5, along with a very short explanation of why it could be of interest.

    1. Age, in months

    2. Name

    3. Income

    4. Whether they have been a victim of violent crime in the past year (assume this is always 365 days).

    5. The number of days since they have last witnessed a violent crime

  2. For each variable in Question 1, state what the data type of variable should be.

  3. Suppose researchers in the field will run a Python script to store survey data when talking to South Side residents. Create all 10 variables in Question 1 based on user input (Chapter 2.8).

  4. We define “witnessing” a violent crime to include events where the resident is a victim of the violent crime in question. After collecting survey data from the resident, the script should tell the researcher whether the resident witnessed a violent crime in the past year and compare it to whether the resident was a victim of violent crime in the past year.

  5. Suppose we conduct an experiment to see whether wealth transfers to residents deter crime. The script should at this point prompt the researcher to input the randomized wealth transfer to the resident (0 means the resident does not receive any transfer). For the purposes of our research, we count this as income. Add this wealth transfer to the income variable. Print the income variable so that the researcher can verify that it is correct.

  6. Create a new variable, age_in_years, based on age in an appropriate manner. Ensure that this is a whole number, with all decimal places truncated. Print this new variable so that the researcher can verify that it is correct.

  7. We now wish to thank the resident for assisting us in our research. Print a string, with their name included, of a farewell greeting that the researcher can repeat to thank the resident.