Skip to content

joespi/quiz-itp-w1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intro to Python - Week 1 - Quiz

This small quiz is just for validating the concepts covered during the first week of our course. It's not something you can pass or fail. We use the results of this quiz to evaluate if we need to add more support sessions or improve any aspect of the course.

PLEASE, don't cheat. Make it honest. We'll never share the data with the rest of the class.

To complete this quiz, fork the repo, work on main.py and submit a Pull Request

Question 1

What's the correct data type of the following values: True, False

Options:
a) Integer
b) Boolean
c) String
d) Collection

Question 2

What's the final result of the following operation:

result = True or ("" and False and []) or (1 and "hello world")
Options:
a) []
b) 1
c) True
d) False
e) "hello world"

Question 3

Write a function remove_Es that receives a string and removes all the characters 'e' or 'E'. Example:

remove_Es('remoter')  # 'rmotr'
remove_Es('eEe')      # ''
remove_Es('abc')      # 'abc'

Question 4

Given the following two collections:

a_tuple = (19, 33, 12)
a_list = range(0, 10)

What's the final value of result?

result = a_list[3**2 - 8] + a_list[-1] + a_tuple[2]

Question 5

Write a function calculate_tax that receives a number (income) and calculates how much of Federal taxes is due, according to the following table:

Income Tax Percentage
<= $50,000 15%
<= $75,000 25%
<= $100,000 30%
> $100,000 35%

Example:

income = 30000  # $30,000 is less than $50,000
calculate_tax(income)  # $30,000 * 0.15  = 4500 = $4,500

income = 80000  # $80,000 is more than $75,000 but less than $80,000
calculate_tax(income)  # $80,000 * 0.25 = 20000 = $20,000

income = 210000  # $210,000 is more than $100,000
calculate_tax(income)  # $210,000 * 0.35 = 73500 = $73,500

Question 6

Write a function matrix_sum that sums all the values in a square matrix.

Example:

m1 = [
    [2, 9, 1],
    [3, 1, 18],
    [22, 8, 16]
]
m2 = [
    [81, 29],
    [31, 57]
]

matrix_sum(m1)  #  80
matrix_sum(m2)  # 198

About

Intro to Python Programming - Quiz Week 1

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 97.2%
  • Makefile 2.8%