Quiz 1

By entering in your initials:

  1. You agree not to use outside resources including notes, LLMs, the internet, etc.
  2. You agree to remain in full screen while you complete the exam.





Time Remaining: 30:00

Question 1

Consider the following line of code:


        print( 6**2 == 72/2 )
    
What will the output be?

Question 2

Consider the following line of code:


        (10**2 - 10) % 9
    
What will the output be?

Question 3

Consider the following line of code:


        (1, 2, 3, 4, 5, 6)[4]
    
What will the output be?

Question 4

Consider the following line of code:


        (1, 2, 3, 4, 5, 6)[1:5:2]
    
What will the output be?

Question 5

Consider the following block of code:


        container = []
        for i in range(6):
            container.append(6 - i)
        print(container)
    
What type of object is container? Write out the output of print(container).

Question 6

Give an example of a string.

Question 7

What is the difference between a float and an integer?

Question 8

I want to define a function that takes a number as an input and outputs the sum of squared numbers less than the input number. For example, if I input the value 5, I want the function to output 30 (since 30 = 12+22+32+42). What I made was the following block of code.


            def squares(maximum):
                container = []
                for i in range( maximum ):
                    container.append(i)

                container2 = []
                for j in container:
                    container2.append( j**2 )
                
                container3 = 0
                for k in container2:
                    container3 += k
                
                return container3
        
In words, describe how to make this function shorter (that is, less lines of code).