Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Microsoft Word - CS521_hm_1 3 Weekly Homework each week’s consist of 10 small programs. 1 Term Project to reflect all concepts learnt in previous 6 weeks. Week 4 Homework: Assignment Directions –...

1 answer below »
Microsoft Word - CS521_hm_1
3 Weekly Homework each week’s consist of 10 small programs.
1 Term Project to reflect all concepts learnt in previous 6 weeks.
Week 4 Homework:
Assignment Directions – Apply the concepts taught in each chapter whenever necessary. No Need to include all the concepts from that chapter in one problem but apply any concepts (1 concept or 2 or 3) whenever necessary. Also, can apply previous week’s concept appended at the end of homework instruction page 3.
No fancy coding bcoz this is an introductory Python course. Use Python 3.6 or 3.7. I will be using Spyder 4 or PyCharm Community 2020/JetBrain.
Solutions provided must be runnable in a .py file so that I can upload and see if it runs or not.
Textbook: The Practice of Computing Using Python, 3rd Edition by William Punch and & Richard Enbody.
Assignment Directions – Due Sunday June 7 @ 9 PM EST
Chapter 7 Exercises (List & Tuples) – LIST: indexing/slicing, operators (+, *) with list, function working with collection, Mutability, non-Modifying (index(x), count(x), Modifying (append(x), pop(), extend(C), insert (i, x), remove(x), sort(), reverse(), List to String and back to List, Sorted Function for List, Anagrams, refactoring, Unique Words, mutable objects & references, shallow vs deep copy.
TUPLES: tuples from list, function (len), methods(split), operators(+), List Comprehesion, comprehension/expressions/ternary operators, (Pylab) A
ays vs Range,
22. Given a list of integers, write Python code to create a new list with same number of elements as the original list such that each integer in the new list is the sum of its neighbors and itself in the original list. For example, if listA = [10, 20, 30, 40, 50], listB = [30, 60, 90, 120, 90].
24. Make a list of the words in a sentence. No punctuation should be attached to a “word” in your list, for example, “end.” is not a co
ect word, but “end” is.
a. Use a while loop.
. Use a for loop.
39. Given a list of integers L, use list comprehension to:
a. find the sum of the even integers in list L.
. find the sum of the odd integers in list L.
Hint: Do not prompt. Just List the integer.
52. Create a program that uses the Gettysburg Address as input and outputs a list of tuples for every two words. For example: [('Four', 'score'),('and', 'seven'), ...].
63. Using only list comprehensions (no loops) how would you change a list of positive integers such as [2, 3, 4, 5] and [9, 9, 1, 9] into their actual numbers 2345 and 9919?
Chapter 9 Exercises - Dictionary (Mutability, contains Keys, Values, Items), dictionary indexing & assignment, ordered dictionary, count words in a string, add_word, pretty_print, zip(), multiple lists with zip(), comprehension to construct dictionary y_dict from x_dict containing a value, working with CSV files, read_table(file_object), parse_element(element_string)
Sets: len(), in (test memberships & returns a Boolean (True/False), Set (Intersection, Union, Difference, Symmetric Difference), Global/Local Assignment Rule, Global Statement, built-in,
Iteration of sets, lists & set, double linked list, list traversal (forward
everse), finding/inserting
emoving (at head or tail) an element, queue (enqueue/dequeue) with python Lists, FIFO, queue (append/popleft, deque) with collections,
6. If you had 2 lists, one of first names and one of last names [‘Jane’, ‘John’, ‘Jack’] and [‘Doe’, ‘Deer’, ‘Black’], use zip to create a dictionary with the keys as the first names and the values as the last names.
8. If my_dict = {a':15, 'c':35, 'b':20}, write Python code
a. to print all the keys.
. to print all the values.
c. to print all the keys and values pairs.
d. to print all the keys and values pairs in order of key.
e. to print all the keys and values pairs in order of value.
14. Letter Counts Using Dictionaries
Remember to consider spaces as a special case – exclude anything not a Lette
a. Write a function that takes as input a string and returns the most common letter in the string.
. Write a function that takes as input a string and returns a dictionary of letter counts.
c. Write a function that takes as input a string and prints a histogram of letter counts. A histogram can be done with matplotlib or using different length strings of characters.
Hint: only letters
19. Create a dictionary for the months in the calendar. Keys are the names of the months and the values are the number of days in the month.
26. Use a dictionary to create a program that prompts for a positive integer and prints out the integer using words. For example: 138 will print “one three eight.”
Hint: Prompt for +integer then check for only +intege
Previous Week’s Concepts – can also be applied to the above homework problems.
Chapter 1 - Fundamentals such as module, import math, comply with PEP 8 Style Guide, statements/expression, Tokens (keywords, symbols, characters, operators, punctuation & delimiters, literals), variables & assignments, objects (identity, some attributes, zero/more names) & types (attributes, operations), numbers (integers, float, fractions), built-in (Boolean, string, list, dictionary, intege
floating point operators ( + - * /
% ** ), order of operators, parentheses { (), **, + x, -x, * / %
, + - , }, shortcuts (+= , -= , /= , *=,)
Chapter 2 – Boolean, ==, is, indentation & suite, If-else, If-elif-else, while-else, else-
eak, For-If-Break-Continue, Checking User Input, Use Range to generate number sequence,
while and for, Iterations (for, enumerate), relational operators, ==, is, multiple assignment, swap, loop control & initialization, continue statement, nesting (if, while, for)
Chapter 4 - Working with Strings such as String as a Sequence, Indexing & Slicing, Extended Slicing, Copy Slice. String Iteration, String Operations such as Concatenation & Repetition, when + Indicates addition or concatenation, Comparing Strings with Single Character & with more than one Character, String Collection are Immutable, Formatted Output for Strings, Width & Alignment Descriptors, Floating Point Precision Descriptor, Controls & Strings, String Formatting, Iteration (for & enumerate), \n , \t , the ‘in’ operator, hello_str[ :5], hello_str[0:5], hello_str[3:-2], Range-For,
Chapter 6 – Files: accessing files, writing txt files, reading & writing txt files, file creation/overwriting.
Chapter 14 – More about files: readline (read single line), readlines (read all lines and store as a list of lines), \n, \r ,write (appends to the end of file’s content, newline= None, moving around in a file (tell, seek(0), seek(n), closing a file, with statement, txt file encoding (ascii, utf-8, utf-16, latin_1, windows-1252, csv module (read, write), module function os (os.getcwd, os.chdir, os.listdir),os.path.join.
TERM PROJECT DUE – Sunday 21 JUNE @ 9 PM EST
Quick glance of requirements – Will provide topic week of June 8.
Co
ection to below 1st point – Must USE 5 container types List, Str, Tuple, Set & Dictionary
2 | Page
Answered Same Day Jun 05, 2021

Solution

Neha answered on Jun 07 2021
130 Votes
"""
Class: XXX
Date: June 8 2020
63.    Using only LIST COMPREHENSION (no loops) how would you change a
list of positive integers such as [2, 3, 4, 5] and [9, 9, 1, 9] into
their actual numbers 2345 and 9919?
line 15 using List Comprehension but I cannot make it work. Help
"""
# assignment...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here