FAQs

FAQs

General

I can’t access documents and code stored on Google Drive or Google Colab!

Please use your @tilburguniversity.edu address to log on to Google to view/edit documents posted to Google Drive or Google Colab. Your private @gmail addresses won’t work.


Team Project

How should I store API keys and personal credentials in my notebook without disclosing them (e.g., on GitHub, or to other students)?

With environment variables, you can access variables without literally writing them down in a notebook or script (e.g., password = "..."). Follow the steps here.


My scraper collects a whole lot of string (i.e., text) data, but I’d like to filter down on specific elements and exclude everything else. The replace() function does not suffice. What would you recommend?

Regular expressions are specifically designed to find patterns in string data. Have a look here](https://tilburgsciencehub.com/learn/regex) to get started with regex.


How can I run my web scraper repetitively (e.g., every day)

You can use task scheduling to automate the execution of scripts at specified intervals. Follow the steps in this building block to set-up schedling for your scraper!


Are there (code) examples from previous years?

Yes, some code examples are available here.


How can I get additional support?

A good starting point are recorded coaching sessions from previous years, which are available on this YouTube playlist.

Also, Hannes collects useful code snippets on GitHub, see gist.github.com.

Python Bootcamp

What’s the difference between if and elif?

It’s simply a matter of the order. if refers to the first condition and elif to the condition(s) that follow. There can be 0, 1 or many elif statements.


What is []?
It’s an empty list. More often than not, it’s defined at the top of a function after which items are appended to it.


How should I interpret discount_rate += 0.10?
It means take the current value of discount_rate and add 0.10 to it. So, say that discount_rate = 0.10 and you run discount_rate += 0.10 its value becomes 0.20.


Why is indenting code especially important in for-loops?
It tells the computer when to break out of a loop. The function below already returns its value after 1 iteration because the return statement is part of the loop.

sum = 0
for counter in range(10):
   sum += counter
   return sum

Actually, in this case it makes more sense to first finish the for loop and only then return the value of sum. Like this (i.e., return is unindented here!):

sum = 0
for counter in range(10):
   sum += counter
return sum