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 14PE
Program Plan Intro

Program to display sum of square of the integer value of the string values

Program plan:

  • The function named “toNumbers()” is defined and inside the “toNumbers()”,
    • Initialize the for loop that ranges till the length of the array
      • The variable “strList[]” stores the integer value of the string values in the array.
      • Return the value stored in the variable “strList”
  • 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 “num”
  • The function named “sumList()” is defined and inside the “sumList()”,
    • Declare the required variable
    • Initialize the for loop that ranges till the length of the array
      • The variable “y” stores the sum of the numbers in the array.
      • Return the value stored in the variable “y”
  • In the “main()” function,
    • Generate a prompt to take the user input.
    • Open the text file from which the contents have to be taken as input.
    • Declare the required array variable.
    • Initialize a for loop to read the lines from the file as user input.
    • Call the method named “toNumbers()” to get the integer value of the string.
    • Call the method named “squareEach()” to square the numbers in the given array.
    • Call the method named “sumList()” to square the numbers in the given array.
    • Print the output value stored in the variable “z”.
  • Call the function “main()”.

Blurred answer
Students have asked these similar questions
pattern recognitionPCA algor'thm
Consider the following program: LOAD AC, IMMEDIATE(30)                                                     ADD AC, REGISTER(R1)                                                     STORE AC, MEMORY(20) Given that the value of R1 is 50, determine the value stored at memory address 20 after the program is executed. Provide an explanation to support your answer.
Pattern RecognitonDecision Tree please write the steps not only last answer
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
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C - File I/O; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=cEfuwpbGi1k;License: Standard YouTube License, CC-BY
file handling functions in c | fprintf, fscanf, fread, fwrite |; Author: Education 4u;https://www.youtube.com/watch?v=aqeXS1bJihA;License: Standard Youtube License