1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Nat2105 [25]
3 years ago
6

Consider the following code segment: try : inputFile = open("lyrics.txt", "r") line = inputFile.readline() print(line) _________

____________ print("Error") What should be placed in the blank so that the program will print Error instead of crashing if an exception occurs while opening or reading from the file?
Computers and Technology
1 answer:
aleksandrvk [35]3 years ago
6 0

Answer:

The answer is "except IOError:"

Explanation:

It is part of the exception handling, that stands for input/ output operation fails, this exception aeries when we attempting to access an anti-existent file, in the program so, it will give the program related errors.

  • This type of error is handled in the try block, it also allows you to prepare the deal with the exceptional block.  
  • It also helps you to hide the bugs by using code, if you handle an unexpected error.
You might be interested in
Consider the unsigned decimal number 35. What is the value in hexadecimal?<br><br> 3510 = _______ 16
Lena [83]

Answer:

(35_{10}) = (23)_{16}

Explanation:

The Hexa-decimal numbers have base 16 and includes numbers:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F

The given steps are performed to convert a decimal number to hexa-decimal number, here to convert decimal number 35 to hexa-decimal number:

  • Divide 35 by 16
  • Note the remainder, r which is 3 here and quotient which is 2
  • Again divide 2 (quotient) by 16 and note the remainder, r' which is 2 and quotient is 0
  • We will stop here as the quotient is now 0. Usually division by 16 is repeated until we get quotient = 0
  • Now arrange the remainder in reverse order to get the hexa-decimal number as r'r
  • The hexa-decimal number is (23)_{16}
4 0
3 years ago
output device. Vrite very short answer of the following questions. What is computer hardware? Which dovico in lini nwhich device
kirill115 [55]

Computer hardware is the physical components that a computer system requires to function.

Have a gr8 day ahead ✌️

7 0
2 years ago
Assume that the following variables have been properly declared and initialized.
grandymaker [24]

Answer:

       if (option1.equals(option2)){

           rsvp = true;

       }

       System.out.println(rsvp);

A full program is given in the explanation section

Explanation:

import java.util.Scanner;

public class Option {

   public static void main(String[] args) {

       boolean rsvp = false;

       int selection;

       String option1,option2;

       Scanner in = new Scanner(System.in);

       option1 = in.next();

       option2 = in.next();

       if (option1.equals(option2)){

           rsvp = true;

       }

       System.out.println(rsvp);

   }

}

4 0
3 years ago
There is a simple method for constructing a magic square for any odd value of n:
DaniilM [7]

Answer:

See Explaination

Explanation:

class MagicSquare():

def __init__(self,side):

self.side=side

self.two_dimension=[]

for row in range(1,side+1):

row_line=[]

for col in range(1,side+1):

row_line.append(0)

self.two_dimension.append(row_line)

def display(self):

row=0

col=int((self.side-1)/2)

for i in range(1,self.side**2+1):

self.two_dimension[row][col]=i

row-=1

col+=1

if row==-1:

row=self.side-1

if col==self.side:

col=0

if self.two_dimension[row][col]==0:

continue

else:

row+=1

if row==self.side:

row==0

for line in self.two_dimension:

for num in line:

print("{0:>3}".format(num),end=" ")

print()

def main():

for i in range(1,14,2):

square=MagicSquare(i)

square.display()

print("----------------------------------------------------")

if __name__ == '__main__':

main()

3 0
3 years ago
Which of the following is not possible? A class that implements two interfaces. A class that inherits from two classes. A class
ozzi

Answer:

"A class that inherits from two classes"

Explanation:

If we're talking about Java, you can't extend from two classes. The reason for this is Java doesn't allow multiple inheritance.

The reason for this is to avoid the ambiguity caused by it. One of the cases where multiple inheritance can cause ambiguity is the diamond problem.

Diamond problem can occur if two classes (say B and C) inherit from one class (say A). And another class (say D) inherits from both B & C.

If B and C class override the same method from A class. And D class calls that method, which one will be called, class B's or C's??

4 0
3 years ago
Other questions:
  • A level breach of security could be expected to have a severe or catastrophic adverse effect on organizational operations, organ
    12·1 answer
  • When doing a complex presentation, which of the following would be the best tool to begin designing your presentation?
    11·2 answers
  • Knowledge can reside in email, voice mail, graphics, and unstructured documents as well as structured documents.
    9·2 answers
  • What are the two ways to use the help menu
    9·2 answers
  • Which technology is predominately used for contactless payment systems?
    11·1 answer
  • Write a program that calculates the average rainfall for three months. The program should ask the user to enter the name of each
    5·1 answer
  • Interactive sites where users write about personal topic and comment to threaded discussion are called?
    10·2 answers
  • An image that has been saved in Tagged Image File Format (or .TIF) is A. readable only by Windows personal computers. B. a recto
    6·1 answer
  • Using Python I need to Prompt the user to enter in a numerical score for a Math Class. The numerical score should be between 0 a
    7·1 answer
  • BRAINLIEST You have a small company and want to keep your costs low, but it is important your employees share data. Which networ
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!