The python code required is for a text file that has names and numbers associated with those names e.g.( GARCIA 0.31817:)
infile = open('last.txt', 'r') - the file must be read only
for line in infile:
the question is this:
Find the longest last name and assign it to “ans14” variable.
infile = open('last.txt', 'r')
ans14 = None
for line in infile:
words = line.strip().split()
name = words[0]
if ans14 is None or len(name) > len(ans14):
ans14 = name
infile.close() # remove this line if closing the file is not required.
# print(ans14) # uncomment this line if you want to print ans14
The python code required is for a text file that has names and numbers associated with...
The python code required is for a text file that has names and numbers associated with those names e.g.( GARCIA 0.31817:) infile = open('last.txt', 'r') - the file must be read only for line in infile: the question is this: Find the name that comes first in the dictionary (alphabetical) order and assign it to “ans13” variable.
QUESTION17 The following Python script aims to read lines from a text file and add them to a list Marlout oft. 00 Example P Flag question If the text file contains the following lines wordt wordz words the list will be ['word, word2, Words' after the execution of the program Question: Rearrange the following statements on the correct (logical) form Note: The-indicates the indentation #--> Program infile=onen/fileName --infile = open(fileName, 'r') . . -try: --for line in infile: --infile =...
Create a python code named LetterCount with a text file named words.txt that contains at least 100 words in any format - some words on the same line, some alone (this program involves no writing so you should not be erasing this file). Then create a program in the main.py that prompts the user for a file name then iterates through all the letters in words.txt, counting the frequency of each letter, and then printing those numbers at the end...
*PYTHON EXPERTS ONLY PLEASE* Please provide the answer coded in Python using comments to explain code function. Good answers will be rated with thumbs up! Please answer both parts. Thank you for your time. Question 3 - Suppose you have a file named numbers.csv which contains a bunch of integers, five per line of text, separated by commas. Write code below that will open the _le, read the numbers from it, and print the sum of all the even numbers...
Python Programming QUESTION 16 Which of the following is an example of a Keyword in Python? elif class for All of the above QUESTION 17 Which of the following is not an acceptable variable name in Python? 2ndVar $amount Rich& ard None of the above are acceptable variable names QUESTION 18 The number 1 rule in creating programs is ___________________- Write the code first Think before you program Let the compiler find you syntax errors There are no rules just...
Please help with this python assignment. Thank you. question 1 Write a Python program to read a file line by line store it into a variable. question 2 Write a Python program to read a file line by line store it into an array. question 3 Write a python program to find the longest words. question 4 Write a Python program to count the number of lines in a text file. question 5 Write a Python program to count the...
(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...
Create a Word doc file (name of the file: numbers) using Python. Write the following numbers to the Word document as shown below and read these numbers from the file and calculate and print the sum and average of these numbers. 9 5 7 6 3 After that, read these values from the file and calculate the sum and average of these numbers. I have wrote this so far, but doesnt work! def numbersfile(): f = open("numbers.docx, "w") for i...
Python Coding The script, `eparser.py`, should: 1. Open the file specified as the first argument to the script (see below) 2. Read the file one line at a time (i.e., for line in file--each line will be a separate email address) 3. Print (to the screen) a line that "interprets" the email address as described below 4. When finished, display the total number of email addresses and a count unique domain names Each email address will either be in the...
Fill in the following code: # Open the file data.csv in read mode data_file = XXXXXX # This is a for loop where line is the variable name # line will automatically be set to each line of the file data.csv # and will be different at each iteration of the loop for XXXX in data_file: # Create a list called columns, that contains the 4 elements of the row columns = line.rstrip(XX).split(XX) # assign the 0th column to the...