CS1101-Unit08 programming assignment
.docx
keyboard_arrow_up
School
University of the People *
*We aren’t endorsed by this school
Course
1101
Subject
Computer Science
Date
Jan 9, 2024
Type
docx
Pages
3
Uploaded by BaronEmuPerson965
The input file I will be working with is called “fruits.txt” and contains the following text:
{
'apple': 'red',
'banana': 'yellow',
'cherry': 'red',
'mango': 'yellow',
'grapes': 'purple',
'plum': 'purple',
'lime': 'green',
'lemon': 'yellow'
}
The Python program I have written is as follows:
Running the open()
function along with the with
statement means it will close my file
automatically once the program is finished with it (Chris, 2022.) Writing it this way means I do not need to remember to write any close()
instructions, and my program code will be more concise.
Next, the file is read into a string assigned to the variable contents
. It is evaluated by Python using the eval() function and recognized as a dictionary due to the curly brackets (
{}
) at the beginning and end of the text content.
I began with the inverted dictionary function presented by the text (Downey, 2015, sec. 11.5 Dictionaries and lists) and then modified it to suit this assignment’s requirements. Inverse = {}
creates a new empty dictionary called “inverse.” Next, a for loop iterates over the original dictionary, assigning each key-value pair to the key
and value
variables. If a value
is not already contained within the inverse dictionary, it is added as a new item. That means that otherwise it is already present, in which case the key is appended to the list.
The program concludes by opening a new file called “inverse_fruits.txt” in write mode (which automatically creates the file if it does not already exist) to contain the new, inverted dictionary. File.write(str(inverse))
writes our new inverse dictionary to the file, ensuring that it is formatted as a string in the process. Finally, a confirmation message is printed in the interpreter if everything goes as planned.
When the program is run, the interpreter provides the following output:
The new file that was created, “fruits_inverse.txt,” contains the following text:
{'red': ['apple', 'cherry'], 'yellow': ['banana', 'mango', 'lemon'], 'purple': ['grapes', 'plum'], 'green': ['lime']}
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
By use python language
arrow_forward
Must show it in Python:
Please show step by step with comments.
Please show it in simplest form.
Input and Output must match with the Question
Please go through the Question very carefully.
arrow_forward
Summary
In this lab, you open a file and read input from that file in a prewritten Python program. The program should read and print the names of flowers and whether they are grown in shade or sun. The data is stored in the input file named flowers.dat.
Instructions
Open the source code file named Flowers.py
Write a while loop to read the input until EOF is reached.
In the body of the loop, print the name of each flower and where it can be grown (sun or shade).
Execute the program.
-----------------------------------------------------
flowers.dat (file information, lists flower and temp it needs to grow)
AstilbeShadeMarigoldSunBegoniaSunPrimroseShadeCosmosSunDahliaSunGeraniumSunFoxgloveShadeTrilliumShadePansySunPetuniaSunDaisySunAsterSun
--------------------------------------------
GIVEN CODE:
# Flowers.py - This program reads names of flowers and whether they are grown in shade or sun from an input
# file and prints the information to the user's screen.
# Input: flowers.dat.
#…
arrow_forward
Summary
In this lab, you open a file and read input from that file in a prewritten Python program. The program should read and print the names of flowers and whether they are grown in shade or sun. The data is stored in the input file named flowers.dat.
Instructions
Open the source code file named Flowers.py
Write a while loop to read the input until EOF is reached.
In the body of the loop, print the name of each flower and where it can be grown (sun or shade).
Execute the program.
arrow_forward
Assistance is needed for Python please
The objective is to create a code in Python that can extract the columns highlighted in blue (Column T and AB3) and output them to a .txt file. The code should be able to generate the text file with the columns that are highlighted in blue and store them on a separate folder. Below shows how the Test.xlsm file looks like as well as how the text file should look like when the code extracts and outputs it.
Google drive to access Test.xlsm file: https://drive.google.com/drive/folders/16utzb5_h7yMCN8_13E_JqasfcpykZOYr?usp=sharing
What my code outputs is shown in the picture (O1.png)
What I would like for my code to output is the columns next to each other (Right Example.png)
The current code is able to output Columns T and AB3 but I am not able to output them next to each other as shown above. We would also like for the code to be capable of storing the text file to a separate folder. Below is the code I have been working on.
#package to read xlsm…
arrow_forward
PYTHON CODING
arrow_forward
A python function opens file data.csv, reads the data from the file and spits the data into three columns, x, y and z. The data is then printed out.
Function:
f = open("data.csv ", "r")
print('x\ty\tz'.format())
for row in f:
temp = row.split(',')
for cell in temp:
print(cell,end='\t')
print()
data.csv contains:
1.2,2.1,1.1
2.3,3.2,0.6
0.7,1.9,0.1
1.8,2.5,0.3
4.6,2.7,0.9
arrow_forward
Python Problem Description:
Kevin is a freelance video producer who makes TV commercials for local businesses. When he makes a commercial, he usually films several short videos. Later, he puts these short videos together to make the final commercial. He has asked you to write the following two programs.
A program that allows him to enter the running time (in seconds) of each short video in a project. The running times are saved to a file.
A successful test run for this program would be as shown below:
A program that reads the contents of the file, displays the running times, and then displays the total running time of all the segments. A successful test run for this program would be as shown below:
arrow_forward
12 Digit Barcode
In this homework, you will develop a python program
which reads a series of barcodes from "barcodes.txt"
and creates an output file "output.txt" which contains
the barcodes and their status as seen in the example
output below.
153182953420
5+1+2.5.4-1
7+3+8+4+3+2-3
1
23601057072
6+t-13
Even : 2+6+1 +5+0 = 14
Odd: 1+3+0+ 0 +7+7 = 18
3 x8 = 24
D+3- 10
4 + 4 = 8
10 -8 = 2 (CORRECT)
What to submit:
1) ipynb file which contains checkBarcode function which takes a string varlable as input and returns true or false,
and a driver program which reads in "barcodes.txt" and creates "output.txt". Assume the input file contains one
barcode info per line.
Important: Your input file name MUST BE "barcodes.txt" and the output file name MUST BE "output.txt". Otherwise,
you'l get up to 30 pts penalty
Below a sample output.txt:
123601057072 is a valid 10-digits barcode
lab601057072 is an invalid 10-digits barcode
172601055072 is an invalid 10-digits barcode
12345 is an invalid 10-digits…
arrow_forward
Python programming-basics homework assignment:
Write a program that inputs a text file, should print unique words in file in abc order, uppercase words should take precedence over lower. this is example of output:
example text file:
brown dog fox jumps lazy over quick the
example output:
brown
dog
fox
jumps
lazy
over
quick
the
THis is MY output:
thequickbrownfoxjumpsoverthelazydog
This is my code: QUESTION: why it won't SORT or removing unique text like example output:
# Put your code herefileName = input("Enter the input file name:")word_list = []with open(fileName) as words: for line in words: line.rstrip() for list_of_words in line.split(): print(list_of_words) word_list.sort() for list2_words in word_list: if list2_words not in word_list: word_list.sort() word_list.append(list_of_words) for new_words in line.split(): print(new_words)
arrow_forward
python 3
arrow_forward
Python programming:
Topic: Compresion - using functional function
Write a program that prints the number of palindromes in this file ..../englishWords (tips , open file first then read the content before printing)
arrow_forward
Language: Python
1. The sample input will have to be in Text File (.TXT)
2. By using the first function, this program reads score and name values from a file. The program then determines the grade for each students by using the second function. Finally, the program displays the name, score, and grade information on the console. The two functions are shown in the images attached below:
arrow_forward
In Python
Initially, you will prompt the user for the names of two files: one will contain Customer information, and the other will contain Product information, as described below. Sample files are attached (below) to this project so you can download and review them. Some test cases may use other files, which you will not be able to see, so it is important that your program ask the user for the file names, and be able to open and read any file.
The Customer Information file will be a csv file, with no header row, in which each line has the following fields, which are separated by commas.
Customer_Number
Customer_Name
Customer_Balance
Customer_Password
For example, the sample file named customers.csv has several lines, and the first two are:
24155,"Carey, Drew Allison",838.41,Bo7&J
24426,"Butler, Geoffrey Barbara",722.93,Ep5&
The Product Information file will be a csv file, with no header row, in which each line has the following fields, which are separated by commas:…
arrow_forward
The Directir file contains namés línhe employees and their phone numbers in the following order:
Last name, First name, Phone.
The creator of this file made several mistakes by typing commas and dots inconsistently.
Write a Python program to read this file and produce an output file with the name DirectoryNew.txt. This file should format the phone directory as follows:
Phone
First name
Number 1
First name 1
Number 2
First name 2
The file MUST end with:
End of directory
Edit Metadata
Edit Metadata
Content of the input file
The output should be as follows
Springsteen, Bruce, 2587.
Hassan, Amir, 6958.
Phone
First name
Homes, Rebecca, 5263
Smith, John, 5252
MacDonald, Mirna, 8965!
Pichai, Sundar, 9632.
Jobs, Steve, 1002
2587
Bruce
6958
Amir
5263
Rebecca
5252
John
8965
Mirna
9632
1002
Goldsmith, Micheal, 5478.
Sundar
Yassir, Ammar, 8885
Steve
Nicholas, Jack, 4696
5478
Micheal
8885
Pang, Chee, 9898
Lee, Andrew, 7412.
Jimenez, Dragos, 6547
Ammar
4696
Jack
9898
Chee
7412
Andrew
6547
Dragos…
arrow_forward
1. Random numbers
File: random_numbers.py
(Quick note: NEVER name your files the same as a Python module. If you call this file random.py it won't let you import the real random.)
(Another quick note: Don't let yourself get stuck on something for too long. If one part of one question starts taking you too long, just leave it, move on and come back to it later.)
Write a complete Python program that ask the user for quantity of random numbers and a maximum, then generates and store that many numbers between 0 and the maximum. When you've got this part working, add the following interesting additions:
minimum
maximum
random choice from existing list (Hint: if there are 7 numbers it will be a number at a random index 0-6)
the list reversed*
the list sorted*
Note*: Python's .reverse() and .sort() list methods do NOT return the reversed or sorted list... they modify the list in place.So, if you write something like:
print(numbers.sort())
You will not get what you expect. You'll sort the…
arrow_forward
The function print_last_line in python takes one parameter, fname, the name of a text file. The function should open the file for reading, read the lines of the file until it reaches the end, print out the last line in the file, report the number of lines contained in the file, and close the file.
Hint: Use a for loop to iterate over the lines and accumulate the count.
For example:
Test
Result
print_last_line("wordlist1.txt")
maudlin The file has 5 lines.
arrow_forward
Solve in Python:
Write a program that removes all digits from the given input.
Ex: If the input is:
1244Crescent
the output is:
Crescent
The program must define and call the following function that takes a string as parameter and returns the string without any digits. def remove_digits(user_string)
arrow_forward
with python do whis:
Edit or delete a user profileWhen the user chooses 2, the first thing that it should do is to check whether the user information is loaded in the program (i.e., check if the user information is passed to the function that generates recipe recommendations). If the user information is passed to the function (i.e., the user chose option 1 before choosing option 2), the program should show the user the following menu:Hello (user name)You can perform one of the following operations:1) Delete your profile2) Edit your profilea. If the user chooses 1, perform the following subtasks to delete a user profile:1- Search for the user profile in the file userInformation.txt using the user name in read mode; once you find the user profile (i.e., the line that contains all the user information), pass it to a function that deletes the user information.2- The function should create a temporary file called temp.txt in write mode and search the file userInformation.txt in read mode…
arrow_forward
Help with c program using FILE HANDLING (fopen, fputs, fgets, etc.)
You can also test the program with the following input.txt file
A1, A2
20294 Lorenzana Dr
Woodland Hills, CA
91364
B1, B2
19831 Henshaw St
Culver City, CA
94023
C1, C2
5142 Dumont Pl
Azusa, CA
91112
D1, D2
20636 De Forest St
Woodland Hills, CA
91364
A1, A2
20294 Lorenzana Dr
Woodland Hills, CA
91364
E1, E2
4851 Poe Ave
Woodland Hills, CA
91364
F1, F2
20225 Lorenzana Dr
Los Angeles, CA
91111
G1, G2
20253 Lorenzana Dr
Los Angeles, CA
90005
H1, H2
5241 Del Moreno Dr
Los Angeles, CA
91110
I1, I2
5332 Felice Pl
Stevenson Ranch, CA
94135
J1, J2
5135 Quakertown Ave
Thousand Oaks, CA
91362
K1, K2
720 Eucalyptus Ave 105
Inglewood, CA
89030
L1, L2
5021 Dumont Pl
Woodland Hills, CA
91364
M1, M2
4819 Quedo Pl
Westlake Village, CA
91362
I1, I2
5332 Felice Pl
Stevenson Ranch, CA
94135
I1, I2
5332 Felice Pl
Stevenson Ranch, CA
94135
N1, N2
20044 Wells Dr
Beverly Hills, CA
90210
O1, O2
7659 Mckinley Ave
Los Angeles, CA
90001…
arrow_forward
Code should be in Python.
Given a text file containing the availability of food items, write a program that reads the information from the text file and outputs the available food items. The program first reads the name of the text file from the user. The program then reads the text file, stores the information into four separate lists, and outputs the available food items in the following format: name (category) -- description
Assume the text file contains the category, name, description, and availability of at least one food item, separated by a tab character ('\t').
(Examples in image)
arrow_forward
Using Python:
program6_1.pyWrite a program that uses a text file to store weekly payroll data for the office. The program should enable the user to enter the name, hourly pay rate, and weekly hours for a number of office employees. The pay rate and hours should be type float, and each datum should be written to its own line in the file. Enter data for at least five employees and then close the file.Sample Output See image below
program6_2.pyThis program reads the text file created in the program above and then calculates and prints each employee's weekly pay. Note the currency format with commas for thousands. The program should finish by printing the total payroll for the office.Sample Output see image below
arrow_forward
Make the following modifications for the solution above:
name the output/input file "myRandomNumbers.txt"
use a loop to output 17 random numbers to the file
after creating the file, close it
open the file for input and read the contents and then
total the numbers in the file
determine the average of the numbers in the file
determine the highest and lowest numbers in the file
DO NOT USE PYTHON BUILTIN FUNCTIONS TO CALCULATE THE AVERAGE OR THE HIGHEST AND LOWEST NUMBERS
an expected number of modules/functions would be in the 5-8 range
Display your results:
the numbers generated on a single horizontal line
the calculated total and average
the highest and lowest number in the file
Be sure to use clear prompts/labeling for input and output.
arrow_forward
Language: Java
1. The sample input will have to be in Text File (.TXT)
2. By using the first function, this program reads score and name values from a file. The program then determines the grade for each students by using the second function. Finally, the program displays the name, score, and grade information on the console. The two functions are shown in the images attached below:
arrow_forward
Complete the Python function given below:
def computeExp(x):
#returns the value of x* + 2x - 5x² + 6
arrow_forward
This is a python file
Fix this code and the output is the attachment
#filename: modValidateEmail.py
def isValidMSUMEmail(email):
if email.count('@') != 1: return False
tmp= email.split('@')
if len(tmp) == 0: return False
userName = tmp[0]
if not userName[0].isalpha(): return False
for c in userName:
if not c.isalpha() and c != '.': return False
inst= tmp[1]
if inst != 'mnstate.edu': return False
else: return True
#filename: UnitTestValidEmail.py
from unittest import *
from modValidateEmail import *
class TestValidEmail(TestCase): #create a subclass of unittest.TestCase
def testUserName(self):
self.assertEqual(isValidMSUMEmail('.joe@mnstate.edu'),False)
self.assertEqual(isValidMSUMEmail('joe4@mnstate.edu'),False)
self.assertEqual(isValidMSUMEmail('joe$smith@mnstate.edu'),False)
self.assertEqual(isValidMSUMEmail('joe.smith@mnstate.edu'),True)
def…
arrow_forward
Constraints:
Use Python
Don't use global variables
Don't use external libraries (PIL and os are allowed)
Start the program with a main function (def main():)
Content:
Ask the user to input a .jpeg/.jpg image. Once a jpeg file is uploaded, create a function with the argument img_info and return a tuple with the image's dimensions in pixels (w, h) and the image data in a form of a list of tuples with RGB values.
Print out the values/data collected.
arrow_forward
in python
create function that has a parameter of dict[str, str]
key should be a name
value should be a color
when given a dict of names and color, function should return the color that is most common
no using key, value for loops
no .get, .items, .defaultset no importing builtins
should return a string
arrow_forward
ON PYTHON IDLE
In this assignment you will write a program that shows the valid moves of chess pieces. Your program will draw a board with 64 squares using the traditional layout, next ask the user to choose a move, and then, depending on the user's choice, redraw the board with the selected chess piece and its valid moves. Please see the examples of valid moves of chess pieces and the traditional chess board layout below:
At the beginning, your program should draw an empty chess board and prompt the user to enter a move:
Welcome to the Chess Game! a b c d e f g h +---+---+---+---+---+---+---+---+8| | | | | | | | |8 +---+---+---+---+---+---+---+---+7| | | | | | | | |7 +---+---+---+---+---+---+---+---+6| | | | | | | | |6 +---+---+---+---+---+---+---+---+5| | | | | | | | |5 +---+---+---+---+---+---+---+---+4| | | | | | | | |4 +---+---+---+---+---+---+---+---+3| | | | | | | |…
arrow_forward
Task 2
Write a python program to find the longest word in a file. Then print the word.
Input: [in a file]
I love Python Programming
It is very easy to understand the code
It can code very hard problems easily in python code
Python programming is the best programming language
Output:
Programming
Hint(1):
You can use split function to separate the words into a list.
Hint(2):
Use function readlines()
arrow_forward
OBJECT ORIENTED PROGRAMMING LESSON
LABORATORY EXERCISE-1
Problem: Write a program that takes position and current salary value from the user and
calculate the new salary and shows it on the console according to the following table.
Position
Manager
Salesman
Human Resources
Technician
Headman
Example:
Enter your position: Manager
Enter your current salary: 10000
New salary: 11000
Raise Percentage
%10
%20
%15
%25
%23
Write your program using Java and copy your codes to a text file which has your name and
surname.
Then load it into UZEM under the provided link.
arrow_forward
In C++ (don't copy paste the same answer that is already on this site, post unique code)
Structures
A menu-driven program gives the user the option to find statistics about different baseball players. The program reads from a file and stores the data for ten baseball players, including player’s team, name of player, number of homeruns, batting average, and runs batted in. (You can make up your data, or get it online )
Write a program that declares a struct to store the data for a player. Declare an array of 10 components to store the data for 10 baseball players.
The program prints out a menu (in a loop, so this can be done again and again) giving the user a choice to:
print out all users and statistics
print out the statistics for a specific player
print out all data for a specific team
update the data for a particular player (change one of the statistics)
DO ALL WORK IN FUNCTIONS. USE A FUNCTION TO READ THE DATA, A FUNCTION TO PRINT THE MENU, and FUNCTIONS FOR EACH OF THE MENU…
arrow_forward
Python please:
The provided file "wgucourse.py" is a module that functions as a simple course catalog. The module defines three courses and stores a variety of course details inside each.
Write a program that a) imports the module, b) reads a course from user input, and c) prints the course details in the following format:
[course] Course duration: [duration] Number of Quizzes: [quizzes] Is there a pre exam? [pre_exam]
For example, if the input is:
C859
the output should read:
C859: Professional Programming in Python Course duration: 6 weeks Number of quizzes: 6 Is there a pre exam? True
arrow_forward
I have a python programing question
A junior magician has picked a secret number. He has hidden it in a variable named secret_number. He wants everyone who runs his program to play the "Guess the secret number" game, and guess what number he has picked for them. Those who don't guess the number will be stuck in a loop forever! Unfortunately, he does not know how to complete the code.
arrow_forward
In C language,
3. A text file name.txt - contains this data,
Sam Davis
Kobe S Bryant
Michael K jordan
Li Peng
Raj Mohan Sharma
Can you write a program to read this file and print each name separately in each line ?
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
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
Related Questions
- By use python languagearrow_forwardMust show it in Python: Please show step by step with comments. Please show it in simplest form. Input and Output must match with the Question Please go through the Question very carefully.arrow_forwardSummary In this lab, you open a file and read input from that file in a prewritten Python program. The program should read and print the names of flowers and whether they are grown in shade or sun. The data is stored in the input file named flowers.dat. Instructions Open the source code file named Flowers.py Write a while loop to read the input until EOF is reached. In the body of the loop, print the name of each flower and where it can be grown (sun or shade). Execute the program. ----------------------------------------------------- flowers.dat (file information, lists flower and temp it needs to grow) AstilbeShadeMarigoldSunBegoniaSunPrimroseShadeCosmosSunDahliaSunGeraniumSunFoxgloveShadeTrilliumShadePansySunPetuniaSunDaisySunAsterSun -------------------------------------------- GIVEN CODE: # Flowers.py - This program reads names of flowers and whether they are grown in shade or sun from an input # file and prints the information to the user's screen. # Input: flowers.dat. #…arrow_forward
- Summary In this lab, you open a file and read input from that file in a prewritten Python program. The program should read and print the names of flowers and whether they are grown in shade or sun. The data is stored in the input file named flowers.dat. Instructions Open the source code file named Flowers.py Write a while loop to read the input until EOF is reached. In the body of the loop, print the name of each flower and where it can be grown (sun or shade). Execute the program.arrow_forwardAssistance is needed for Python please The objective is to create a code in Python that can extract the columns highlighted in blue (Column T and AB3) and output them to a .txt file. The code should be able to generate the text file with the columns that are highlighted in blue and store them on a separate folder. Below shows how the Test.xlsm file looks like as well as how the text file should look like when the code extracts and outputs it. Google drive to access Test.xlsm file: https://drive.google.com/drive/folders/16utzb5_h7yMCN8_13E_JqasfcpykZOYr?usp=sharing What my code outputs is shown in the picture (O1.png) What I would like for my code to output is the columns next to each other (Right Example.png) The current code is able to output Columns T and AB3 but I am not able to output them next to each other as shown above. We would also like for the code to be capable of storing the text file to a separate folder. Below is the code I have been working on. #package to read xlsm…arrow_forwardPYTHON CODINGarrow_forward
- A python function opens file data.csv, reads the data from the file and spits the data into three columns, x, y and z. The data is then printed out. Function: f = open("data.csv ", "r") print('x\ty\tz'.format()) for row in f: temp = row.split(',') for cell in temp: print(cell,end='\t') print() data.csv contains: 1.2,2.1,1.1 2.3,3.2,0.6 0.7,1.9,0.1 1.8,2.5,0.3 4.6,2.7,0.9arrow_forwardPython Problem Description: Kevin is a freelance video producer who makes TV commercials for local businesses. When he makes a commercial, he usually films several short videos. Later, he puts these short videos together to make the final commercial. He has asked you to write the following two programs. A program that allows him to enter the running time (in seconds) of each short video in a project. The running times are saved to a file. A successful test run for this program would be as shown below: A program that reads the contents of the file, displays the running times, and then displays the total running time of all the segments. A successful test run for this program would be as shown below:arrow_forward12 Digit Barcode In this homework, you will develop a python program which reads a series of barcodes from "barcodes.txt" and creates an output file "output.txt" which contains the barcodes and their status as seen in the example output below. 153182953420 5+1+2.5.4-1 7+3+8+4+3+2-3 1 23601057072 6+t-13 Even : 2+6+1 +5+0 = 14 Odd: 1+3+0+ 0 +7+7 = 18 3 x8 = 24 D+3- 10 4 + 4 = 8 10 -8 = 2 (CORRECT) What to submit: 1) ipynb file which contains checkBarcode function which takes a string varlable as input and returns true or false, and a driver program which reads in "barcodes.txt" and creates "output.txt". Assume the input file contains one barcode info per line. Important: Your input file name MUST BE "barcodes.txt" and the output file name MUST BE "output.txt". Otherwise, you'l get up to 30 pts penalty Below a sample output.txt: 123601057072 is a valid 10-digits barcode lab601057072 is an invalid 10-digits barcode 172601055072 is an invalid 10-digits barcode 12345 is an invalid 10-digits…arrow_forward
- Python programming-basics homework assignment: Write a program that inputs a text file, should print unique words in file in abc order, uppercase words should take precedence over lower. this is example of output: example text file: brown dog fox jumps lazy over quick the example output: brown dog fox jumps lazy over quick the THis is MY output: thequickbrownfoxjumpsoverthelazydog This is my code: QUESTION: why it won't SORT or removing unique text like example output: # Put your code herefileName = input("Enter the input file name:")word_list = []with open(fileName) as words: for line in words: line.rstrip() for list_of_words in line.split(): print(list_of_words) word_list.sort() for list2_words in word_list: if list2_words not in word_list: word_list.sort() word_list.append(list_of_words) for new_words in line.split(): print(new_words)arrow_forwardpython 3arrow_forwardPython programming: Topic: Compresion - using functional function Write a program that prints the number of palindromes in this file ..../englishWords (tips , open file first then read the content before printing)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