Answer:
The Python code is given below for each question.
Explanation:
1:
if __name__ == '__main__':
f = open('golf.txt', 'w')
n = int(input("Enter number of players:"))
for i in range(n):
name = input("Enter name of player number " + str(i + 1) + ":")
score = int(input("Enter score of player number " + str(i + 1) + ":"))
f.write(name + "\n" + str(score) + "\n")
f.close()
2:
try:
with open('golf.txt') as r:
lines = r.readlines()
for i in range(0, len(lines), 2):
print("Name:", lines[i].strip())
print("Score:", lines[i+1].strip())
print()
except FileNotFoundError:
print("golf.txt is not found!")
Answer:
The correct answer for the given question is "Machine languages can be used to write programs that can run on any machine."
Explanation:
The machine language consist of binary digit i. e 0 and 1 .Computer can understand only the machine language .The machine language consist of code that is written in bits so it is used to express algorithms.When any program is compiled the compiler are converted into machine code so the machine language is produced by the compiler .
Machine language cannot used to write a program that run on any machine.
Answer:
A friend asks you for help writing a computer program to calculate the square yards of carpet needed for a dorm room. The statement "the living room floor is rectangular" is an example of a(n) <u>assumption</u> . The length and width of the room are examples of <u>known</u> information, which you can obtain as <u>input</u> from the user.
Explanation:
The given question is a Problem statement.
Problem statement can be defined as the brief description of an issue that needs to be focused in order to reach the require goal.
So the parts that a problem statement may have include:
- facts and figures (assumptions), that are known in the given scenario.
- data required (solution)to be calculated by focusing on present assumptions (given as input by the user).
So the attributes to be filled into blanks of given statement are assumption, known, input.
i hope it will help you!