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

Program to display the sum of the numbers

Program plan:

  • 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 “test()” function,
    • Declare an array variable and initialize it with an 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 “test()”.

Blurred answer
Students have asked these similar questions
Review the code snippet. func printwelcomeMessage() { } print("Welcome to My ToDo List") Which keyword is used to declare a function? Answer the question by entering the answer in the box.
Python please!   Generalized image blender function   Create a function blend images() which takes multiple RGB images as an input, and outputs a blended image.   The function should accept following parameters 1. image list- A Python list of 3D arrays where each 3D array corresponds to an RGB image 2. weight list-A Python list of float values between (0, 1) corresponding to the pixel weight to be given to each image-e.g. [0.2, 0.3, 0.1, 0.4] for 4 images. The sum of the weights should be equal to 1.   Test your function against a provided list of 5 images with following weight lists (i.e. 2 blended images) [0.2, 0.2, 0.2, 0.2, 0.2]- blend all 5 images [0.2, 0.3, 0.5]- blend first 3 images NOTE: DO NOT USE pre-existing image blending functions.
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…
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++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
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