subject

Reading input from file, instead of hard-coding values in your code or getting them from user input, can speed up your workflow and allow you to write modular code. In this lab, you will write a function read_configuration(), which will take a filename as its input and return a list, where every line from the file is a list, which contains each whitespace-separated value as its element.
For example, below are the contents of a file is called board1.txt:
X O .
X O .
X . .
After processing this file, the function should produce the following:
>>> read_configuration("board1.txt")
[['X', 'O', '.'], ['X', 'O', '.'], ['X', '.', '.']]
Note that you can visualize the returned list as follows to see how it maps to the input file
[['x', 'o', '.'],
['x', 'o', '],
['x', '.', ']]
Hint: Remember that split() is a really helpful function. Also, you can get a sense of how to approach file processing by following along.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 06:30
This technology is used to produce high-quality documents that look good on the computer screen and in print.
Answers: 1
question
Computers and Technology, 23.06.2019 01:20
Me with this program in c++ ! computers represent color by combining sub-colors red, green, and blue (rgb). each sub-color's value can range from 0 to 255. thus (255, 0, 0) is bright red. (130, 0, 130) is a medium purple. (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (in other word, equal amounts of red, green, blue yield gray).given values for red, green, and blue, remove the gray part. ex: if the input is 130 50 130, the output is: 80 0 80. thus, find the smallest value, and then subtract it from all three values, thus removing the gray.
Answers: 3
question
Computers and Technology, 23.06.2019 20:30
If an appliance consumes 500 w of power and is left on for 5 hours, how much energy is used over this time period? a. 2.5 kwh b. 25 kwh c. 250 kwh d. 2500 kwh
Answers: 1
question
Computers and Technology, 23.06.2019 21:30
Write a fragment of code that reads in strings from standard input, until end-of-file and prints to standard output the largest value. you may assume there is at least one value. (cascading/streaming logic, basic string processing)
Answers: 3
You know the right answer?
Reading input from file, instead of hard-coding values in your code or getting them from user input,...
Questions
question
Mathematics, 17.02.2021 22:10
question
Mathematics, 17.02.2021 22:10
question
Law, 17.02.2021 22:10
question
Mathematics, 17.02.2021 22:10
question
Health, 17.02.2021 22:10
question
Physics, 17.02.2021 22:10
question
Biology, 17.02.2021 22:10
Questions on the website: 13722363