logo

Crowdly

Browser

Додати до Chrome

Programming for Engineers -Summer25

Шукаєте відповіді та рішення тестів для Programming for Engineers -Summer25 ? Перегляньте нашу велику колекцію перевірених відповідей для Programming for Engineers -Summer25 в elearn.squ.edu.om.

Отримайте миттєвий доступ до точних відповідей та детальних пояснень для питань вашого курсу. Наша платформа, створена спільнотою, допомагає студентам досягати успіху!

Write a Python program that reads a text file. The program should:

  1. Extract all words and convert them to lowercase.

  2. Store the words in a list.

  3. Use a dictionary to group the words by their length.

  4. Print all words that have the maximum length, in alphabetical order.

Example of a text file:

In the realm of artificial intelligence, machines learn from data.

Extraordinary algorithms power systems that simulate human cognition.

Sometimes, simplicity outperforms complexity.

Example of code execution:

Enter the filename: text2.txt

Words with the maximum length (13):

extraordinary

intelligence,

Переглянути це питання

Write a Python program that reads a text file. The program should:

  1. Convert all words to lowercase.

  2. Store the words in a list.

  3. Use a dictionary to count how many times each word appears.

  4. 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.

Переглянути це питання

Which statement checks whether a value is not equal to 5?

0%
0%
0%
0%
Переглянути це питання
Переглянути це питання

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: ")
0%
0%
0%
0%
Переглянути це питання

What does this code do?

f= open('file.txt', 'w') 

data = f.write("text")

f.close()

Переглянути це питання

What is the result of '5' * 5?

Переглянути це питання

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)
Переглянути це питання

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: "))
0%
0%
0%
0%
Переглянути це питання

Which of these opens a file for both reading and writing at the same time?

Переглянути це питання

Хочете миттєвий доступ до всіх перевірених відповідей на elearn.squ.edu.om?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!

Browser

Додати до Chrome