logo

Crowdly

Browser

Add to Chrome

Programming for Engineers -Summer25

Looking for Programming for Engineers -Summer25 test answers and solutions? Browse our comprehensive collection of verified answers for Programming for Engineers -Summer25 at elearn.squ.edu.om.

Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!

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,

View this question

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.

View this question

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

0%
0%
0%
0%
View this question
View this question

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%
View this question

What does this code do?

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

data = f.write("text")

f.close()

View this question

What is the result of '5' * 5?

View this question

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)
View this question

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%
View this question

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

View this question

Want instant access to all verified answers on elearn.squ.edu.om?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome