Python Programming: An Introduction to Computer Science
Python Programming: An Introduction to Computer Science
3rd Edition
ISBN: 9781590282779
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
Of the five primary components of an information system (hardware, software, data, people, process), which do you think is the most important to the success of a business organization? Part A - Define each primary component of the information system. Part B - Include your perspective on why your selection is most important. Part C - Provide an example from your personal experience to support your answer.
Management Information Systems
Q2/find the transfer function C/R for the system shown in the figure Re ད
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