COP 4814 Lab #1 - Coding Questions in Python
Only Python version 3 is allowed. Have fun!
Name(s): PantherID(s):
1. Write a Python program that finds all numbers that are divisible by 7 but not a multiple of 5 between
2000 and 3201 (included).
2. Write a function in Python that generates a dictionary with the format i : i ∗ i given a certain intege
number n. For instance, if the function is called on 3, then the dictionary should have the following
format: 1: 1, 2: 4, 3: 9.
3. Write a function in Python that takes in parameters name and age. The function should return a
message (it can be a print statement) containing the year when that person with that age will turn (o
turned) 100 years old.
4. Write a function in Python that takes in as input a certain number and then prints out a list of all the
divisors of that number.
5. Write a function in Python that takes in a list (example: a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]) as
input and returns a new list that has only the even elements of this list in it.
6. Given 2 lists, a and b, containing integers, not necessarily with the same length, Write a function in
Python that returns a list that contains only the elements that are common between the lists a and
(without duplicates).
7. Write a function in Python that takes in a dictionary and returns the sum of all the values (not keys)
in a dictionary.
8. Given a number n, write a function in Python to determine if n is a prime.
9. Given a string, write a function in Python that takes in a string and: if the length of the string is at
least 3, adds ”ing” to its end. But, if it already ends in ”ing”, adds ”ly” instead. And if the string
length is less than 3, leaves it unchanged. Return the resulting string.
10. Write a function in Python that takes a character and returns its ASCII value.
11. Write a function in Python that takes in an integer n and returns the first n Fibonnaci numbers.
12. Write a Python script that implement a function that takes as input three variables, and returns the
largest of the three. Do this without using the Python max() function! Hint: Use if statements.