Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help! This is creating a module with the function for Python 3.0-3.5. Thank u ! 1. Write a function called print_duplicates that takes a

Please help! This is creating a module with the function for Python 3.0-3.5. Thank u !

1. Write a function called print_duplicates that takes a string called my_str as a parameter and prints all the characters that occurred more than once along with the number of their occurrences. For Example: - if my_str is ABACAD the output should be: A, count=3 - If my_str is Hello World, the output should be: L, count=3 O, count=2 - You are not allowed to use the string method count You may assume that my_str consists only of letters. Save the function in a PyDev library module named a8_functions.py

Write a main program named q1.py that tests the function.

2. Write a function string_sum that takes a string that has single-digit numbers called my_str as a parameter and returns a number that represents the sum of all the single digit numbers in that string as in the provided docstring below. Save the functions in a PyDev library module named a8_functions.py

def string_ sum (my_str):

""" ------------------------------------------------------- sums all the single digit numbers in my_str use: total = string_ sum (my_str) -------------------------------------------------------

pre-condition: my_str: string that has single-digit numbers (str) post-conditions: returns total: sum of all the single digit number (integer >= 0) ------------------------------------------------------- Sample run >>>total = string_total('2514') >>>print(total) 12 """

Write a program q2.py that asks the user to enter a series of single-digit numbers with nothing

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions