A file named numbers.txt contains a unknown number of line, each consisting of single integer. Write some code that opens the file, computes the sum of all integers it contains, and stores the sum in a variable name sum Below is a code that does not work: sum=open("numbers.txt", "r") number=sum.readline() while line !=" ": sum+=int(line) number+=sum.readline() sum.close()
Q: Create a question with the topic Functions (Continuity and inverse of a function),
A: Continuity and inverse of a function
Q: In what format does the Scroll Lock Virtual Key Symbol appear on the screen?
A: Scroll lock is a key which is located on the keyboard and it is nearer to the pause key. This key wa...
Q: Floyd distinguished two required properties to verify a program. The two properties are called corre...
A: The answer is
Q: 3 a
A: Answer is given below.
Q: Write a program that reads a list of integers into a list as long as the integers are greater than z...
A: Start input number untill user input number less than 0 append all number in list then sort list pr...
Q: Given a directed graph G=(V, E), design an algorithm to find out whether there is a route between tw...
A: DFS Pseudo code DFS (V,E) for each vertex u in V[G] do color[v] ← GRAY π[v] ← NIL // predecessor o...
Q: Compare between the Two Tier Client-Server DBMS Architecture and Three Tier Client-Server DBMS Archi...
A: Compared between the Two-Tier Client-Server DBMS Architecture and Three-Tier Client-Server DBMS Arch...
Q: Write a C program named bal.c that checks if the curly braces (ie "{" and "}") are balanced. It does...
A:
Q: It's important to know what a heuristic is and how it's different from an algorithm, so we're going ...
A: Check further steps for the answer :
Q: Simplify these Boolean expressions as much as possible: a) ((A+D)(C'+B')'+C) b) A'B+CA'D+B'+D' c) (A...
A: Part(a) Given the expression is: ((A+D)'(C'+B')+C)' Now simplifying the given expression: ((A+D)')...
Q: Four criteria were defined for comparing search strategies: completeness, optimality, time complexit...
A: Four criteria were defined for comparing search strategies: completeness, optimality, time complexit...
Q: PART I: Functions – Math Test Write the Flowchart and Python code for the following programming pro...
A: import random #function to read student NAMEdef inputNames(): name = input("Enter Student Name: "...
Q: QUESTION 12 When using buffer, the producer sends the message after the previous one is received by ...
A: The answer for all the questions are Given below.
Q: HW6_4: Write code to solve the following system of equations using the Newton-Raphson method. Let x ...
A: function [x0,iter]=newton_Nonlinear_System(f,df,x0,tol,Max_iter)% INPUTS %f = vector of function ...
Q: Identify and briefly discuss four reasons why computer incidents have become more prevalent. Use you...
A: A computer is an electronic device which takes data from user , processes it and produces output. Co...
Q: Provide a brief description of the AllocConsole function.
A:
Q: Design 4 networks each with 6 hosts for network 16. 10.10.0 then write for each network:- 1-Network ...
A: Introduction: Design 4 networks each with 6 hosts for network10 . 10. 10.0 then write for each netwo...
Q: You do not have to write the whole program. Write the definition for function tally() that counts th...
A: I am writing the function tally but for better understanding of yours I am attaching output screensh...
Q: if we would like to represent merge sort in terms of occurence relation T(n)=aT(n/b)+f(n), what woul...
A: Given: Represent merge sort in terms of occurence relation T(n)=aT(n/b)+f(n), We have to discuss Wh...
Q: Hi, please answer this correctky and completely. Thanks! The subject is Data Structure and Algorithm...
A: SUMMARY: - Hence, we discussed all the points.
Q: The result is negative when the dividend and divisor have not same sign. * O False True
A: Binary Coded Decimal, or BCD, is a telephone system or code that uses binary numbers or digits to re...
Q: Write a program that prompts the user to enter the weight of a person in kilograms and outputs the e...
A: Given The answer is given below.
Q: r friends has invented a new game called Pillar Jumpers. In this ga ghts are placed next to each oth...
A:
Q: Make a flowchart where a program dispenses cash at an ATM machine that has been upgraded to dispense...
A: Since you needed the output screenshot I am attaching for both conditions thatis when amount is divi...
Q: NOTE: (what your answer will contain) 1. Use C PROGRAMMING LANGUAGE ONLY 2. Use RECURSION type of pr...
A: Given The answer is given below. To write a C program to find quotient of two numbers.
Q: Say what holds for S: a) It has more test cases than a minimal test suite requires. b) There is a ...
A: So we are given Input -14 <= x <= 28, x ∈ Z; -10 <= y <= 32, y∈ Z Output the integer x...
Q: Discuss Big Data and how corporations are using it these days, as well as why they are doing so.
A: The answer of this question is as follows:
Q: (True or False) The result of convolving an image by a filter, x, and then by a filter, y,
A: Convolution is a mathematical way of combining two signals to form a third signal. It is the single ...
Q: Over the first few Long Weekly Homework assignments for this quarter, we have been building a Sudok...
A:
Q: Cloud computing has the potential to have a wide range of societal ramifications. Can computers and ...
A: Introduction: Cloud computing uses the internet to access resources such as programs, servers (both ...
Q: Regular or Not? Use the pumping lemma, and/or closure arguments to prove your answer a. The set of a...
A: Pumping Lemma for Regular languages states that if we consider any language L then take any string w...
Q: A robot's "arm" is also known as its: (A) End effector (B) Actuator (C) Manipulator (D) Servomechan...
A: Correct Answer is (C) Manipulator. A robot manipulator is a multi-segmented, electronically contro...
Q: How does a compiler deal with an inline member function of a class?
A: Introduction: When you write code in one programming language (the source language), you can use com...
Q: Write down the cardinal polynomials in the Lagrange interpolation polynomial for the points x ...
A: According to the information given:= We have to write down the cardinal polynomials in the Lagrange ...
Q: What does SCROLLLOCK ON mean?
A: Given: What exactly does SCROLLLOCK ON imply?
Q: A (blank) is a usable representation of a solution.
A: Answer: Design
Q: There are several types of linear-programming models that exhibit a special structure which can be e...
A: There are several types of linear-programming models that exhibit a special structure which can be e...
Q: Explain any five assembler directives of 8086 microprocessor
A: 8085 microprocessor or the eighty eighty five microprocessor are the 8 bit microprocessor which are ...
Q: Fully justify your choice of network devices with reference to their intended function and where the...
A: A LAN connects computers over a relatively short distance, allowing them to share data, files, and r...
Q: Compare between the Two Tier Client-Server DBMS Architecture and Three Tier Client-Server DBMS Archi...
A: Your answer is here. Introduction :- Two Tier Client-Server DBMS Architecture :- Two-tier client-ser...
Q: Write a java program. Enter a string includes letters and numbers,print out the numbers with sorted ...
A: Please find the answer below
Q: How many comparsions would be needed for insertion sort algorithm for these 3 types of arrays and al...
A: Actually insertion sort requires 1/4(N2 - N) comparisons, and thus should require about 1/2 the comp...
Q: Justifying network devices used in my LAN design. Fully justify your choice of network devices with ...
A: the answer is given below:-
Q: Translate source code into intermediate language that directly executes line by line. java-virtual m...
A: correct option is D (interpreter)
Q: Your employer has charged you with implementing a risk management program. The CEO has requested you...
A: Security is prevention of unauthorised access into system. Exposure of holes in source code is respo...
Q: 1 Description of the Program In this assignment, you will write four java files, Message.java, Messa...
A: I have added the required 4 classes as per the requirements. comments are added to better understand...
Q: What is the expression for f (x) for a (5, 4, 3, 2, 1) neural network?
A: Normally f(x) =5,4,3,2,1 5+4+3+2+1 = 15 In Neural network by Linear regression y = mx...
Q: Write a pthread program using c/c++ or java code to print the sum of 100 numbers of the first 1000...
A:
Q: What is the virtual key symbol for the Right Ctrl function key?
A: Answer:
Q: Write a program to read a string and reverse it
A: GIVENBuild NASM programs for the following questions 2. Write a program to read a string and reverse...
A file named numbers.txt contains a unknown number of line, each consisting of single integer. Write some code that opens the file, computes the sum of all integers it contains, and stores the sum in a variable name sum
Below is a code that does not work:
sum=open("numbers.txt", "r")
number=sum.readline()
while line !=" ":
sum+=int(line)
number+=sum.readline()
sum.close()
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
- JAVA PPROGRAM Write a program that prompts the user to enter a file name, then opens the file in text mode and reads names. The file contains one name on each line. The program then compares each name with the name that is at the end of the file in a symmetrical position. For example if the file contains 10 names, the name #1 is compared with name #10, name #2 is compared with name #9, and so on. If you find matches you should print the name and the line numbers where the match was found. While entering the file name, the program should allow the user to type quit to exit the program. If the file with a given name does not exist, then display a message and allow the user to re-enter the file name. The file may contain up to 100 names. You can use an array or ArrayList object of your choosing, however you can only have one array or ArrayList. Input validation: a) If the file does not exist, then you should display a message "File 'somefile.txt' is not found." and allow the…OWrite a program that reads data from a file containing integers that ends with -999. Output the numbers that are divisible by 7 Output the numbers that are divisible by 11 Output the numbers that are not divisible by 7 or 11.please code in python count_word: This function takes a filename and a keyword. Return the number of times the keywordoccurs in the file. Initialize a variable to keep track of the number of times the keyword appears.Traverse the file by line. Use the count method on each line to find the number of times the keywordappears in it and add that amount to the variable
- wordSort.py: Write a program that reads words from a file (filename given as a command-line argument) and prints them in (case insensitive) sorted order. For example, if the input file contains:If there's a problem yo I'll solve itCheck out the hook while my DJ revolves itIce ice baby The program should print (one word per line, compressed here for brevity):a baby Check DJ hook I'll Ice ice If it it my outproblem revolves solve the there's while yoCENT 110 Homework 6 This assignment involves writing a program that takes reads from a text file containing multiple lines of floating numbers separated by commas. The program will ask for the user to enter file name of the text file. The program will read each line of numbers, use the split() function to put the numbers in lists. For each line of numbers, the program will calculate the total of the numbers, the average value, the smallest number, and the largest number. For each line of numbers, it will then display each number, the total, average, smallest number, and the largest number. The numbers are in a text file named numbers.txt and contains the following: 1.0, 2.0, 3.0 4.0, 3.0, 2.0, 1.0 5.0, 5.0, 5.0, 5.0, 5.0Python A Personal Fitness Tracker is a wearable device that tracks your physical activity, calories burned, heart rate, sleeping patterns, and so on. One common physical activity that most ofthese devices track is the number of steps you take each day The steps.txt file contains the number of steps a person has taken each day for a year. There are 365 lines in the file, and each line contains the number of steps taken during a day. Write a program that reads the file, then displays the average number of steps taken for each month Your program should use a function to calculatethe averagenumber of steps. You will need to pass more than one argument to the function.
- File Operations:Write a complete program that reads integers from a file called numbers.txt, and displays their sum on the screen. Example: If the content of numbers.txt is: 10 20 30 100 The program should print: 160Body Mass Index Write a program that reads names, weights, and heights from bmi.dat (provided with starter code; do not change the file name). Use the information to calculate and displays a person’s body mass index (BMI). The BMI is often used to determine whether a person with a sedentary lifestyle is overweight or underweight for his or her height. A person’s BMI is calculated with the following formula: BMI = weight × 703 / height2 where weight is measured in pounds and height is measured in inches. The file is in the format name weightInKG heightInCM You will read the name, weight and height for 4 people from the file, and you will need to convert the weights in the file to pounds (note that 1 kilogram = 2.2 pounds) and the heights to inches (2.54 cm = 1 inch). The program should display the person's name along with the calculated BMI and a message indicating whether the person has optimal weight, is underweight, or is overweight. Your output should look like A person’s weight…In Java Oleae nust read a file A photographer is organizing a photo collection about the national parks in the US and would like to annotate the information about each of the photos into a separate set of files. Write a program that reads the name of a text file containing a list of photo file names. The program then reads the photo file names from the text file, replaces the "_photo.jpg" portion of the file names with "_info.txt", and outputs the modified file names. Assume the unchanged portion of the photo file names contains only letters and numbers, and the text file stores one photo file name per line. If the text file is empty, the program produces no output. Ex: If the input of the program is: ParkPhotos.txt and the contents of ParkPhotos.txt are: Acadia2003_photo.jpg AmericanSamoa1989_photo.jpg BlackCanyonoftheGunnison1983_photo.jpg CarlsbadCaverns2010_photo.jpg CraterLake1996_photo.jpg GrandCanyon1996_photo.jpg IndianaDunes1987_photo.jpg LakeClark2009_photo.jpg…
- scores.txt : Jan,86 Drew,92 Blake,85 Alex,81 Taylor,88 Jordan ,72Cam,89 Note: code is written in python please The file scores.txt (attached) contains a list of names and test scores. Create a program that reads each line of the file and determines the highest score and who obtained it. This is an exercise in strings. You are required to use at least one string method to determine the names and the scores. Your output should resemble the following: Highest Score: 100Achieved by: Jay Note; i could not send an attachment of the actual file but i have copied its contents.A Personal Fitness Tracker is a wearable device that tracks your physical activity, calories burned, heart rate, sleeping patterns, and so on. One common physical activity that most of these devices track is the number of steps you take each day. The steps.txt file contains the number of steps a person has taken each day for a year. There are 365 lines in the file, and each line contains the number of steps taken during a day. (The first line is the number of steps taken on January 1st, the second line is the number of steps taken on January 2nd, and so forth.) Write a program that reads the file, then displays the average number of steps taken for each month. (The data is from a year that was not a leap year, so February has 28 days.) You don't need to see the file , Just write a code using the "file" like this def main(): with open("steps.txt", "r") as file:The function file_first_chars in python takes one parameter, fname, the name of a text file, and returns a string made up of the first character from each line in the file. You may assume there are no blank lines in the file. Hint: Use a for loop to iterate over the lines of the file and accumulate the string of first characters. NOTE: Return the function, don't print For example: Test Result print(file_first_chars("wordlist1.txt")) hsaem