
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Write a program in python that takes a sequence of non-negative numbers and performs
the computation suggested by the examples in the picture sent. A negative number is used to
terminate the input but is not part of the sequence. USE ONLY WHILE LOOPS!
DO NOT USE LANGUAGE OF: "true" or "break" when doing the code.
![Write a program that takes a sequence of non-negative numbers and performs
the computation suggested by these examples. A negative number is used to
terminate the input but is not part of the sequence.
Restrictions: The only list operations you are allowed to use on this exam
are as follows:
Length of a list:
List accessor:
len(list)
list[k]
Create empty list: list = [ ]
list.append(k)
List append:
Examples :
computation
1*5 + 2*4 + 3*3 + 4*2 + 5*1
3*9 + 5*6 + 6*5+ 9*3
3*2 + 8*8 + 2*3
input
output
2 3 4 5 -1
35
3 5 6 9 -1
114
3 8 2 -1
76
7 -1
7*7
49
|| || ||||](https://content.bartleby.com/qna-images/question/601ccad1-4d17-4947-9a80-69495cb62ebb/61833325-975c-46b1-9bea-91aac0cf4fe3/szqh2w_thumbnail.png)
Transcribed Image Text:Write a program that takes a sequence of non-negative numbers and performs
the computation suggested by these examples. A negative number is used to
terminate the input but is not part of the sequence.
Restrictions: The only list operations you are allowed to use on this exam
are as follows:
Length of a list:
List accessor:
len(list)
list[k]
Create empty list: list = [ ]
list.append(k)
List append:
Examples :
computation
1*5 + 2*4 + 3*3 + 4*2 + 5*1
3*9 + 5*6 + 6*5+ 9*3
3*2 + 8*8 + 2*3
input
output
2 3 4 5 -1
35
3 5 6 9 -1
114
3 8 2 -1
76
7 -1
7*7
49
|| || ||||
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 4 images

Knowledge Booster
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
- IN PYTHON: Integer num_guesses is read from input, representing the number of integers remaining in input. Read the remaining integers from input and append each integer to user_guesses in that order.Ex: If the input is:3 9 5 2then the output is:user_guesses: [9, 5, 2]Note: Remember to correctly close all parentheses.arrow_forwardWrite a loop that calculates the total of the following series of numbers: 1/30 + 2/29 + 3/28 + 4/27 + ... + 30/4 Use python language to code.arrow_forwardWrite a c++ program without a nested loop. Only use a single loop.arrow_forward
- write in python there are two variables a and z that hold integer numbers where a <=z. Using loops print the following: all the numbers from a to z inclusive. the sum of the numbers from a to z inclusive. Verify that your program works by changing the values of a and z. a=7 and z=15arrow_forwardIn this lab, you add nested loops to a Python program provided. The program should print the outline of the plin 2 # across and 5 asterisks down. 3 # Input: None letter E. The letter E is printed using asterisks, three 4 # Output: Prints the letter E. across and five down. This program uses the 5 print("*", end=' ') to print an asterisk and ') to print a space. 6 NUM_ACROSS = 3 # Number of asterisks to print across 7 NUM_DOWN = 5 # Number of asterisks to print down print(" ", end=' 8 9 # Write a loop to control the number of rows. Instructions 10 # Write a loop to control the number of columns 11 # Decide when to print an asterisk in every column. 1. Write the nested loops to control the number of rows |12 print("*", end='') 13 # Decide when to print asterisk in column 1. and the number of columns that make up the letter E, 14 print("*", end='') as shown below: 15 # Decide when to print a space instead of an asterisk. 16 print(" ", end='') *** 17 # Figure out where to place this…arrow_forwardWrite in python please Write a nested for-loop to create the pattern below. (Hint: image is 8 x 20).arrow_forward
- Write a do while loop in C++ that validates an input classCode. The valid inputs are ‘F’, ’S’, ’J’, or ’R’. Use a boolean variable invalid to assign the invalid expression. Have it output the input and either “ is an INVALID INPUT – Please try again!” or “ is valid – thank you!”. For Example: G is an INVALID INPUT – Please try again! OR F is valid – thank you! Use the following declarations: char classCode; bool invalid;arrow_forwardComputer Science Write correct Python code to complete the following task. Document all assumptions. Solutions that do not incorporate a loop will receive a grade of 0. Obtain a positive integer greater than 1 but less than 20 from the user. Calculate the product of all numbers starting from the user's number up to, and including 100. If the number is evenly divisible by 7, do not include it in the product. If the product is more than or equal to 5000 stop the loop early and show the message "a big product". When the loop ends, if the product is less than 5000 show the product to the user.arrow_forwardPlease help me with this question in python using psedocode details. I have attached both pictures below:-arrow_forward
- create a C program for this: ask the user to enter a negative value, which is an integer n. If the number is negative, the summation of all numbers between -1 and n is displayed on the screen, your print must show the same format, -1 -2 -3 -... -n =If the number is positive, you must ask the user again for another number, repeat the process until the given number is a negative number use do while loop for this part.arrow_forwardPYTHON PROGRAMMING (practice review for final) (please see attached)arrow_forwardPlease write me an python (We cannot have while true and break)arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education