Шукаєте відповіді та рішення тестів для Programming for Engineers -Summer25 ? Перегляньте нашу велику колекцію перевірених відповідей для Programming for Engineers -Summer25 в elearn.squ.edu.om.
Отримайте миттєвий доступ до точних відповідей та детальних пояснень для питань вашого курсу. Наша платформа, створена спільнотою, допомагає студентам досягати успіху!
Write a Python program that reads a file containing numbers (possibly across multiple lines). The program should:
Convert the values to floats.
Store them in a list.
Compute and print the average (mean) of all numbers in the file.
10 20 30
25 35
15 5 10
A sample code execution is:
Enter the filename: text3.txt
The average is 18.75
Write a Python program that reads a text file. The program should:
Convert all words to lowercase.
Store the words in a list.
Use a dictionary to count how many times each word appears.
Find and print the word(s) with the minimum frequency (i.e., words that occur least often).
Example of the text file words:
Apple banana apple ORANGE Banana orange.
ORANGE apple BANANA apple.
Example of code execution:
Enter the filename: text1.txt
Words with the minimum frequency:
orange.
apple.
What is the result of '5' * 5?
The following program is supposed to continue reading values from the user until a value between 25 and 75 is entered. What line of code must be inserted in the blank so that the program will achieve this goal?
value = int(input("Enter a value: "))____________________ value = int(input("Enter a value: "))Which statement checks whether a value is not equal to 5?
The following program is supposed to print a message any time the user enters two consecutive values that are the same. What line of code must be inserted in the blank so that the program will achieve this goal?
value = int(input("Enter a value: ")inputStr = input("Enter a value: ")while inputStr != "" : previous = value value = int(inputStr) ____________________ print("Found consecutive values that are the same") inputStr = input("Enter a value: ")What does this code do?
f= open('file.txt', 'w')
data = f.write("text")
f.close()
Assuming a user enters 30, 20, and 10 as the input values, what is the output of the following code snippet?
num1 = int(input("Enter a number: "))num2 = int(input("Enter a number: "))num3 = int(input("Enter a number: "))if num1 > num2 : if num1 > num3 : print(num1) else : print(num3)else : if num2 > num3 : print(num2) else : print(num3)Which of these opens a file for both reading and writing at the same time?