• High School
  • You don't have any recent items yet.
  • You don't have any courses yet.
  • You don't have any books yet.
  • You don't have any Studylists yet.
  • Information

Programming Assignment UNIT 7 CS 1101

Programming 1 (cs 1102), university of the people, recommended for you, students also viewed.

  • CS 1102 Learning Journal UNIT 3
  • CS 1102 Programming Assignment Unit 3 Text File Only
  • CS 1102 Unit 3 Programming Assignment Solution
  • CS 1102 Discussion Assignment 1
  • Programming 1 CS 1102 unit 8 learning journal
  • CS1102 - Java - Learning Journal Unit 2

Related documents

  • Discussion Unit 1 (Programming I)
  • Learning Journal Unit 8
  • Unit 4 Prog Assignment solutions. 2020/2021
  • Unit 4 Programming Assignment Solution
  • Learning Journal Unit 5 1
  • Unit 3 Programming Assignment Solution(CS 1102)

Related Studylists

Preview text, programming assignment unit 7, fundamentals of programming (cs 1101), university of the people, instructor: farhad malek asghar, date submitted: 21/10/.

Start with the following Python code.

alphabet = "abcdefghijklmnopqrstuvwxyz"

test_dups = ["zzz","dog","bookkeeper","subdermatoglyphic","subdermatoglyphics"]

test_miss = ["zzz","subdermatoglyphic","the quick brown fox jumps over the lazy dog"]

Massachusetts: Green Tree Press.

def histogram(s): d = dict() for c in s: if c not in d: d[c] = 1 else: d[c] += 1 return d

Copy the code above into your program but write all the other code for this assignment yourself. Do not copy any code from another source.

Write a function called has duplicates that takes a string parameter and returns True if the string has any repeated characters. Otherwise, it should return False.

Implement has duplicates by creating a histogram using the histogram function above. Do not use any of the implementations of has_duplicates that are given in your textbook. Instead, your implementation should use the counts in the histogram to decide if there are any duplicates.

Write a loop over the strings in the provided test_dups list. Print each string in the list and whether or not it has any duplicates based on the return value of has_duplicates for that string. For example, the output for "aaa" and "abc" would be the following.

aaa has duplicates abc has no duplicates

Print a line like one of the above for each of the strings in test_dups.

Write a function called missing_letters that takes a string parameter and returns a new string with all the letters of the alphabet that are not in the argument string. The letters in the returned string should be in alphabetical order.

Your implementation should use a histogram from the histogram function. It should also use the global variable alphabet. It should use this global variable directly, not through an argument or a local copy. It should loop over the letters in alphabet to determine which are missing from the input parameter.

The function missing_letters should combine the list of missing letters into a string and return that string.

Write a loop over the strings in list test_miss and call missing_letters with each string. Print a line for each string listing the missing letters. For example, for the string "aaa", the output should be the following.

aaa is missing letters bcdefghijklmnopqrstuvwxyz

If the string has all the letters in alphabet, the output should say it uses all the letters. For example, the output for the string alphabet itself would be the following.

abcdefghijklmnopqrstuvwxyz uses all the letters

Print a line like one of the above for each of the strings in test_miss.

Submit your Python program. It should include the following.

 The provided code for alphabet, test_dups, test_miss, and histogram.  Your implementation of the has_duplicates function.  A loop that outputs duplicate information for each string in test_dups.  Your implementation of the missing_letters function.  A loop that outputs missing letters for each string in test_miss.

Also submit the output from running your program.

ANSWER: Input: print ("Part 1:")

res = has_duplicates(item) if res: print (item,'has no duplicates') else: print (item,'has duplicates')

print () #prints blank line print () #prints blank line

print ("Part 2:")

alphabet = "abcdefghijklmnopqrstuvwxyz" test_miss = ["zzz", "subdermatoglyphic", "the quick brown fox jumps over the lazy dog"]

def histogram(s): d = dict () for c in s: if c not in d: d[c] = 1 else: d[c]+= return d def missing_letters(s): my_dict = histogram(s) missing_list = [] for ch in alphabet: if ch not in my_dict. keys (): missing_list. append(ch) missing = '‘. join(missing_list) return missing

for string in test_miss: missing = missing_letters(string) if missing =='': print (string, 'uses all the letters') else: print (string,'is missing letters', missing)

Output = RESTART: C:/Users/admin/AppData/Local/Programs/Python/Python39/Programming Assignment Unit 7 Part 1: zzz has duplicates dog has no duplicates bookkeeper has duplicates subdermatoglyphic has no duplicates subdermatoglyphics has duplicates

Part 2: zzz is missing letters abcdefghijklmnopqrstuvwxy subdermatoglyphic is missing letters fjknqvwxz the quick brown fox jumps over the lazy dog uses all the letters >>> WORD COUNT: 794 REFERENCES: Downey, A. (2015). Think Python: How to think like a computer scientist. Needham, Massachusetts: Green Tree Press.

  • Multiple Choice

Course : Programming 1 (CS 1102)

University : university of the people.

programming assignment unit 7 cs1101

  • More from: Programming 1 CS 1102 University of the People 926   Documents Go to course
  • More from: Needed by Tanjina Akter 7 7 documents Go to Studylist

IMAGES

  1. Unit 7 Programing Assignment

    programming assignment unit 7 cs1101

  2. CS1101: Programming Fundamentals

    programming assignment unit 7 cs1101

  3. Solutions for Assignment Unit 7

    programming assignment unit 7 cs1101

  4. Cs1101 unit 7 assignment

    programming assignment unit 7 cs1101

  5. CS 1101-01 Programming Fundementals

    programming assignment unit 7 cs1101

  6. Programming Assignment Unit 7

    programming assignment unit 7 cs1101

VIDEO

  1. | An English assignment UNIT 5 to review a street food called 'tahu bulat'

  2. CS1102 unit 3 programming assignment

  3. Dashboard Assignment Unit 2-Key insights from the 2020 Presidential Election

  4. Week 12 Nptel Programming Assignment 1 Programming in java #nptelsolution #nptel

  5. Code.org Lesson 17.2 CSS Classes

  6. CS 1101

COMMENTS

  1. UoPeople/cs1101/Unit 7/Programming Assignment Unit 7.docx at ...

    Programming Assignment Unit 7.docx. Contribute to reedtsutton/UoPeople development by creating an account on GitHub.

  2. CS1101 Programming Assignment Unit 7 - Studocu

    takes a string parameter and Returns a new string with all the letters of the alphabet that are not in the argument string. The letters in the returned string are in alphabetical order. The implementation uses a histogram from the histogram function and also uses the global variable alphabet directly, not through an argument or a local copy.

  3. CS 1101-01 - AY2024-T3 - Programming Assignment Unit 7 - Studocu

    Programming Assignment Unit 7 University of the People CS 1101: Programming Fundamentals - AY2024-T Rupali Memane March 21, 2024. First, we will start with the original dictionary, with the students as the keys and the courses each student is taking as the values. org_dict = { 'Stud1': ['CS1101', 'CS2402', 'CS2001'], 'Stud2': ['CS2402&#039 ...

  4. Cs1101 unit 7 assignment - Welcome to Unit 7 Programming ...

    Welcome to Unit 7 Programming Assignment! This will be your last programming assignment for this course. Start with the following Python code. From Section 11 of:Downey, A. (2015). Think Python: How to think like a computer scientist. Needham, Massachusetts: Green Tree Press.

  5. Programming Assignment Unit 7 | PDF - Scribd

    Programming Assignment Unit 7 - Free download as Word Doc (.doc / .docx), PDF File (.pdf), Text File (.txt) or read online for free. CS 1101-01 Programming Fundamentals Assignment Unit 7.

  6. CS1101 Unit 7 Assignment | PDF - Scribd

    CS1101 Unit 7 Assignment - Free download as Word Doc (.doc / .docx), PDF File (.pdf), Text File (.txt) or read online for free.

  7. Programming Assignment CS 1101 Unit 7.docx - Course Hero

    View Programming Assignment CS 1101 Unit 7.docx from COMP 1101 at University of the People. Programming Assignment CS 1101 Unit 7 Python Code Copied from the assignment alphabet = AI Chat with PDF

  8. UoPeople CS1101 Unit 7 Python Programming Assignment Tutorial

    Programming Assignment tutorial for University of the People CS1101 Programming Fundamentals Unit 7 .

  9. Programming Assignment UNIT 7 CS 1101 - PROGRAMMING ... - Studocu

    Start with the following Python code. From Section 11 of:Downey, A. (2015). Think Python: How to think like a computer scientist. Needham, Massachusetts: Green Tree Press. Copy the code above into your program but write all the other code for this assignment yourself. Do not copy any code from another source.

  10. Programming Assignment Unit 7 (CS1101) | PDF | Parameter ...

    Programming Assignment Unit 7 (CS1101) - Free download as Word Doc (.doc / .docx), PDF File (.pdf), Text File (.txt) or read online for free. The document provides code for a histogram function that counts the frequency of each character in a string.