A. Write a function named count target that has two string parameters, the first parameter is a longer string and the se

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

A. Write a function named count target that has two string parameters, the first parameter is a longer string and the se

Post by answerhappygod »

A Write A Function Named Count Target That Has Two String Parameters The First Parameter Is A Longer String And The Se 1
A Write A Function Named Count Target That Has Two String Parameters The First Parameter Is A Longer String And The Se 1 (24.65 KiB) Viewed 61 times
A Write A Function Named Count Target That Has Two String Parameters The First Parameter Is A Longer String And The Se 2
A Write A Function Named Count Target That Has Two String Parameters The First Parameter Is A Longer String And The Se 2 (45.75 KiB) Viewed 61 times
A Write A Function Named Count Target That Has Two String Parameters The First Parameter Is A Longer String And The Se 3
A Write A Function Named Count Target That Has Two String Parameters The First Parameter Is A Longer String And The Se 3 (38.07 KiB) Viewed 61 times
help solve please
A. Write a function named count target that has two string parameters, the first parameter is a longer string and the second parameter is the target string you want to count the occurrences in the first parameter. count the occurrences of the second parameter in the first one and return it. the function is NOT case-sensitive, so Python and python will be the same. Hint Initialize a counter Convert both parameters to lowercase, then split the source and o iterate over the words of the source if any word is equal to the target then increment the counter o return the counter after the iterations. Sample count target function calls and outputs: Sample function call 1: source Python is simple and python is fun' target Python' count python in Python is simple and python in fun print (count_target (source, target))) Output 1: 2 Sample function call 2 source Python is simple and python is fun! target java Foount java in Python is simple and python is fun print (count_targot (source, target)) Output 2: 0

B. Write a function named read data that reads from a file given as a parameter. . it has a string parameter for the file name, and • it filters the numbers that are divisible by 3 into a list and returns this list. • one number per line exists in the file and you do not know the number of lines in it. Sample read data function calls and outputs: Sample function call 1: test_file = 'numbers2.txt' *** File content 2 3 8 print (read_data (test_file)) Output 1: [3, 6] Sample function call 2 test_file = "numbers3.txt' Filo content 3 6 9 print (read_data (test_file)) Output 2: [3, 3, 6, 9]

C. Write a function named write_data • to write the numbers and their squares in a given range into another file. This function has 3 parameters, output file name, range start, and range end. • You will write the numbers and the squares of those numbers in the given range where start and end are inclusive to the output file. Sample write data function calls and outputs: Sample function call 1: output_file = 'rangel-3.txt' write_data (output_file, 1, 3) Contents of the output file after function call 11 24 39 *** Sample function call 2 output_file = 'range5-9.txt' write_data (output_file, 5, 9) Contents of the output file after function call 5:25 6:36 7.49 8 64 9 81 ***
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply