faith reason justice e eastern 19 25 university dtsc 575 code grade as
Search for question
Question
faith reason justice
E EASTERN
19/25
UNIVERSITY
DTSC 575 Code Grade Assignments
Here you will find the description for the programming assignments. Remember, this is
a learning experience, and you are encouraged to utilize other forms of resources to
complete these assignments (you can look for assistance with errors or to understand
how portions of code work generally, but may not use any solutions that you may come
across).
All assignments below will be accounted towards your final grade.
There are multiple ways to complete some of these assignments. If sys.argv is not used
to test Code Grade cases, points will be deducted at the end of the semester.
General rule for CodeGrade:
• If importing a certain package is not necessary, do NOT import it. If you do so,
Code Grade will throw an error message.
O For example, you do NOT need to packages such as:
■ "import matplotlib.pyplot as plt"
■ "import seaborn as sns"
■ "import sklearn"
■ and etc.
O If you do, even if the rest of your code is correct, Code Grade will mark it
as wrong.
Code Grade is case-sensitive to .py file submissions.
O For example, submitting "Change.py" instead of “change.py" will throw an
error.
For assignments that use csv files, you do NOT need to upload the .csv to
Code Grade because it's pre-loaded.
● • You will NEVER have to use input() for any Code Grade uploads.
General Python
Strings
●
countVowels.py
Create a program called countVowels.py that has a function that takes in a string
then prints the number of unique vowels in the string (regardless of it being upper
or lower case).
For example:
o The argument "swEet" should print 1
O The argument "AaaaeeE" should print 2
capCount.py
Create a program called capCount.py that has a function that takes in a string
and prints the number of capital letters in the first line, then prints the sum of their
indices in the second line.
The string "hEllo, World" would should look like this:
2
8
shortest.py
Create a program, shortest.py, that has a function that takes in a string argument
and prints a sentence indicating the shortest word in that string. If there is more
than one word print only the first. Your print statement should read:
"The shortest word is x"
Where x = the shortest word. The word should be all uppercase.
palindrome.py
Create a program, palindrome.py, that has a function that takes one string
argument and prints a sentence indicating if the text is a palindrome. The
function should consider only the alphanumeric characters in the string, and not
depend on capitalization, punctuation, or whitespace. If your string is a palindrome it should print:
It's a palindrome!
●
If it is not a palindrome, it should print:
It's not a palindrome!
*Note: please copy and paste these versions into your code because the type of
apostrophe can differ between IDEs, command line, etc.
Dictionary
luke.py
Do NOT use elif statement or nested if-else statement for this assignment. You
should only need one single if-else statement at most (points will be deducted if
more than one single if-else statement is used or the dictionary is changed).
• Create a program, luke.py, using the following dictionary:
relations = {'Darth Vader':'father', 'Leia':'sister', 'Han':'brother in law',
'R2D2':'droid', 'Rey':'Padawan', 'Tatooine':'homeworld'}
• The program will take one argument, corresponding to one of the relations' keys.
The program will print out the statement:
"Luke, I am your x"
Where x = the relationship.
● For example:
O If the argument is Leia, it should print “Luke, I am your sister"
O If the key is 'Darth Vader' it should instead print "No, I am your father"
grades.py
Use this exact dictionary to complete this assignment (Do NOT add or delete
anything from this dictionary. This dictionary should remain the same throughout
your codes - points will be deducted if dictionary is changed): ●
●
grades = {'Biology':80, 'Physics':88, 'Chemistry':98, 'Math':89, 'English':79,
'Music':67, 'History':68, 'Art':53, 'Economics':95, 'Psychology':88}
Create a program, grades.py, that takes an argument (subject) and prints the
average score excluding that subject, to two decimals.
For example:
O If the argument is Biology, it should print 80.56
O If the argument is Chemistry, it should print 78.56
gpacalc.py
Use this exact dictionary to complete this assignment (Do NOT add or delete
anything from this dictionary. This dictionary should remain the same throughout
your codes - points will be deducted if dictionary is changed):
gpa_dict = {'A':4.0, 'A-':3.66, 'B+':3.33, 'B':3.0, 'B-':2.66, 'C+':2.33, 'C':2.0,
'C-':1.66, 'D+':1.33, 'D':1.00, 'D-':.66, 'F':0.00}
• Create a program, gpacalc.py, that takes four letter grade arguments and prints
out the corresponding GPA, to two decimals. Your program should work both in
arguments are upper-case and lower-case.
• Your program should print in the form:
"My GPA is x"
Where x = GPA calculation
List & Sets
inrange.py
● Create a program inrange.py that has a function that takes one integer argument.
The function will print a list of all values between 3000 and 5000 that is divisible
by:
1. the integer argument
2. the integer argument + 7
3. the integer argument ^2
For example, if the integer argument is 6, it should print: ●
[3276, 3744, 4212, 4680]
commonset.py
IMPORTANT
a. Your autotest cases will NOT work if you don't load your sys.argv like
below. For this assignment, load in your variables like this:
set_a = sys.argv[1:]
set_b = ['apple', 'banana', 'mango', 'orange']
b.
The above set_a is a list-type variable which contains words.
c. Your order may be different for the examples below because sets are
unordered.
Create a program, commonset.py. Your program should:
a. Find the common words between set_a and set_b.
b. Print the output in a set format.
● Example 1 - If the set_a is ['apple', 'banana', 'pear', 'grape'], the program should
print:
{'banana', 'apple'}
Example 2 - If the set_a is ['mango', 'mango', 'mango', 'pear', 'grape'], the
program should print:
{'mango'}
diffset.py
• IMPORTANT
a. Your autotest cases will NOT work if you don't load your sys.argv like
below. For this assignment, load in your variables like this:
set_a= sys.argv[1:]
set_b = ['apple', 'banana', 'mango', 'orange']
b. The above set_a is a list-type variable which contains words.
c. Your order may be different for the examples below because sets are
unordered.