USE PYTHON !!

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: 899603
Joined: Mon Aug 02, 2021 8:13 am

USE PYTHON !!

Post by answerhappygod »

USE PYTHON !!
Use Python 1
Use Python 1 (99.95 KiB) Viewed 29 times
1. Write a function print_squares (values) that takes as a parameter a list of numbers called values, and uses an element-based loop to compute and print out the square of each value. Here are some examples: >>> print_squares([6,7,8]) 36 49 64 >>> print_squares([1.2, 2.5]) 1.44 6.25 2. Write a function print_multiples(n, m) that will print out the first m multiples of the integer n, one per line. Here are some examples: >>> print_multiples(2, 10) # print the first 10 multiples of 2 0 2 4 6 8 10 12 14 16 18

>>> print_multiples (12, 5) # print the first 5 multiples of 12 0 12 24 36 48 Your function must use the definite loop with the built-in range function to control the number of repetitions. Inside the loop, use the multiplication operator to calculate the multiple and print it out. 3. Write the function num_vowels (s), which will process a string s and return the number of vowels (letters that are in the string aeiou) in that string. For example: >>> num_vowels('chocolate') 4 >>> num_vowels('chocolate therapy ice cream') 10 Your function must use a definite loop to process the string, and the accumulator pattern to build the count of vowels. Hints: ▪ You may choose whether to solve this problem using an element-based loop or an index-based loop. It can be solved it each way, but be careful not to mix-and- match!
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply