PYTHON How do u make a list for a txt file like this:
[4, 2, 1, 2, 4, 2, 4, 4, 5, 2, 2, 1, 5, 2, 4, 3, 1, 1, 3, 3, 5]
My txt file looks like this :
AAAAA 4 2 1 2 4 2 4 4 5 2 2 1 5 2 4 3 1 1 3 3 5
BBB 5 2 1 2 4 5 4 4 1 2 2 2 4 4 4 3 1 2 3 3 2
K 4 1 2 1 2 1 2 5 1 1 1 1 4 2 2 1 5 1 3 4 1
filename = input("Enter file name: ")
try:
f = open(filename, 'r')
for line in f:
data = line.strip().split()
numbers = []
for num in data[1:]:
numbers.append(int(num))
print(numbers)
f.close()
except FileNotFoundError:
print(filename + " does not exists!")

Python Assignment Tasks 1. Place the two provided plaintext files (file_1.txt, file_2.txt) on your desktop. 2. Write a Python program named fun_with_files.py. Save this file to your desktop as well. 3. Have your program write the Current Working Directory to the screen. 4. Have your program open file_1.txt and file_2.txt, read their contents and write their contents into a third file that you will name final.txt . Note: Ponder the open‐read/write‐close file operation sequence carefully. 5. Ensure your final.txt contains...
txt file iuput in C. If there is a txt file which only contain one row like 1 2 3 How can I read these three integers individually as a special value to pass to a integer i and the size of a two dimensional array like: int i = 1; array a[ 2 ][ 3 ] = {}; Thanks
How do I write a one-line (excluding function definition) python function make_filter(limit), which takes in an integer limit, and returns a function that takes in a list of strings, and returns a copy of the list with all strings shorter than limit characters removed. make_filter must be exactly one line of Python code, not including the function signature line ( def make_filter(limit): ) example: >>> filter5 = make_filter(5) >>> filter5(['', 'a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa']) ['aaaaa', 'aaaaaa'] >>> filter2...
(IN PYTHON) You are to develop a Python program that will read the file Grades-1.txt that you have been provided on Canvas. That file has a name and 3 grades on each line. You are to ask the user for the name of the file and how many grades there are per line. In this case, it is 3 but your program should work if the files was changed to have more or fewer grades per line. The name and...
Assignment: USING PYTHON Expected submission: TWO (2) Python files, main.py and HelperClasses.py Make a file called HelperClasses and create a class inside it called Helpers Inside Helpers, create 8 static methods as follows: 1.) Max, Min, Standard_Deviation, Mean a.) Each of these should take a list as a parameter and return the calculated value 2.) Bubble a.) This should take a list as a parameter and return the sorted list 3.) Median a.) This should take a list as a...
PYTHON language
Write a program that finds the most used word in scarlet3.txt. Run Original - 1 of 1 Show CodeLens 1 2 f open('scarlet3.txt', 'r') 3 file=f.readlines() 4 words={} 5 # Your code here 6 Activity: 1 - ActiveCode (JC_11_1)
Python programming question Using an adjacency matrix: Take a txt file and have the program read it and output the contents into an adjacency matrix. - The txt file would have the size of the matrix and a list of names. - Print the filled matrix of the names - After each iteration, the program will ask, 'continue'? - Show how to swap names for the next iteration(Program would take an input of two names and swap them) Example: input:...
In python, how to sort the 10 highest word
length from a txt file
displayed in an ascending order?
Word list:
pizza
toy
phone
computer
chair
desk
shelf
cup
bed
window
clock
house
roof
pen
example:
Enter name of files on at a time. when ready to compile, enter 'done': done longest words! responsibilities: 16 letters interdependence: 15 letters disillusionment: 15 letters administrations: 15 letters transportation: 14 letters restrictionism: 14 letters neocolonialism: 14 letters multiplication: 14 letters industrialized: 14 letters...
Using C, Write a program to alphabetically merge the three word list files (american0.txt, american1.txt, and american2.txt). Each file will have words in random order. The output must be a file called words.txt. Note that you cannot cheat by using Linux commands to do this. It must be done entirely in your C code. File format: apple banana pear . . . Hint: Program will need to utilize double pointers. More Hints: 1. Assume no word is bigger that 50...
Python Given a list like myList = [1, 2, 3, 4]. Your task is to find sum of each number with another number. For example, 1+2+1+3+1+4,2+3,2+4,3+4. Use for loop to accomplish this task. Return Output: 1 + 2 1 + 3 1 + 4 2 + 3 2 + 4 3 + 4 The sum value: 30