Python Programming: An Introduction to Computer Science, 3rd Ed.
Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
bartleby

Videos

Question
Book Icon
Chapter 6, Problem 11PE
Program Plan Intro

Program to display the square of the numbers

Program plan:

  • The function named “squareEach()” is defined and inside the “squareEach()”,
    • Initialize the for loop that ranges till the length of the array
      • The required variable is declared and stores the array of numbers that have been squared.
      • Return the value stored in the variable “nums”
  • In the “test()” function,
    • Declare an array variable and initialize it with an array.
    • Call the method named “squareEach()” to square the numbers in the given array.
    • Print the output value stored in the array variable “y”.
  • Call the function “test()”.

Blurred answer
Students have asked these similar questions
Multiples of ten in a list (python) Write a program that reads a list of integers, and outputs whether the list contains all multiples of 10, no multiples of 10, or mixed values. Define a function named is_list_mult10 that takes a list as a parameter, and returns a boolean that represents whether the list contains all multiples of ten. Define a function named is_list_no_mult10 that takes a list as a parameter and returns a boolean that represents whether the list contains no multiples of ten. Then, write a main program that takes an integer, representing the size of the list, followed by the list values. The first integer is not in the list. Ex: If the input is: 5 20 40 60 80 100 the output is: all multiples of 10 Ex: If the input is: 5 11 -32 53 -74 95 the output is: no multiples of 10 Ex: If the input is: 5 10 25 30 40 55 the output is: mixed values The program must define and call the following two functions. is_list_mult10() returns true if all integers in the list are multiples…
C++ Coding: ArraysTrue and False Code function definitions for eoNum() and output(): Both eoNum() and output() are recursive functions. output() stores the even/odd value in an array. Store 0 if the element in the data array is even and store 1 if the element in the data array is odd. eoNum() displays all the values in an array to the console.
Question > Not complete Marked out of 1.50 Flag question Previous page Write a recursive function named get_palindromes (words) that takes a list of words as a parameter. The function should return a list of all the palindromes in the list. The function returns an empty list if there are no palindromes in the list or if the list is empty. For example, if the list is ["racecar", "hello", "noon", "goodbye"], the function should return ["racecar", "noon"]. A palindrome is a word that is spelled the same forwards and backwards. Note: The get_palindromes() function has to be recursive; you are not allowed to use loops to solve this problem. For example: Test words = ["racecar", "hello", "noon", "goodbye", "test", 'aibohphobia'] ['racecar', 'noon', 'aibohphobia'] print (get_palindromes (words)) print (get_palindromes ([])) print (get_palindromes (['this', 'is', 'test'])) Answer: (penalty regime: 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 %) Result Precheck Check [] [] Next page
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
What Are Data Types?; Author: Jabrils;https://www.youtube.com/watch?v=A37-3lflh8I;License: Standard YouTube License, CC-BY
Data Types; Author: CS50;https://www.youtube.com/watch?v=Fc9htmvVZ9U;License: Standard Youtube License