Introduction and Running Python

1 minute read

Course website and Syllabus

Hopefully you’ve had a chance to look through the course web site and followed instructions from last time

  • read syllabus
  • install some tools

Let’s go check it out and discuss in a little more detail

Installing Python and Visual Studio Code

  • How did this go?
  • Let’s stop and get everyone up and running

In-Class Activities

Make a group of 3-4 students.

Have a discussion about each of these problems.

Group Activity Problem 1

Run the following code examples. In the note section below, describe what this code does.

my_list = [35,66,70,5,42,10,12]
print(42 in my_list)
my_list = [35,66,70,5,42,10,12]
print(0 in my_list)

Group Activity Problem 2

If you run this code by itself, it doesn’t do anything. How can you get it to work like it is meant to?

def search_for(item, list_to_search_in):
    
    result = item in list_to_search_in

    return result

Group Activity Problem 3

Rewrite the search_for function above so that it uses a loop and if statement rather than the list-contains operator (i.e., in). Note that you can still use the in operator if setting up a for loop, just don’t directly use it to check if the item is in the list.

def search_for(item, list_to_search_in):
    
    return False #you'll need to change this line after you get your loop and if statement working