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
erastovalidia [21]
3 years ago
6

Write a program that asks the user for the name of a text file. The program should display the first 10 lines of the file on the

screen. If the file has fewer than 10 lines, the entire file should be displayed along with a message indicating the entire file has been displayed.
Computers and Technology
1 answer:
tangare [24]3 years ago
5 0

Answer:

Written in Python

filenm = input("File name: ")

myfile = open(filenm+".txt")

for i in range(10):

     line = myfile.readline()

     print(line)

print("End of file")

Explanation:

This line prompts user for file name

filenm = input("File name: ")

This line creates an instance of the file

myfile = open(filenm+".txt")

This line iterates through the 10 lines

for i in range(10):

This line reads the line

     line = myfile.readline()

This line prints each line

     print(line)

This line prints a message indicating that all possible lines have been printed

print("End of file")

You might be interested in
In Word, how can you tell when text is selected?
Anit [1.1K]

Answer:

the text will highlited in gray

Explanation:

5 0
3 years ago
WHERE DO I GO TO DO THIS AND WHAT DO I WRITE?????
faust18 [17]

You can just look up "python ide online" on google and paste this code:

n = -1

count = 0

while n < 0:

   n = int(input("We're checking to see if a number is prime or not! Enter a positive number: "))

if n % 2 == 0:

   if n == 2:

       print("{} is a prime number".format(n))

   else:

       print("{} is not a prime number".format(n))

else:

   for x in range(n, 1, -1):

       if n % x == 0:

           count += 1

   if count > 1 or n == 1:

       print("{} is not a prime number".format(n))

   else:

       print("{} is a prime number".format(n))

I've written some code that checks to see if a number entered by the user is a prime number or not.

Sorry, but I'm not too good with pseudocode plans and all that. I hope this helps.

8 0
3 years ago
Read 2 more answers
Please answer ASAP!!!!!!
Blababa [14]

Answer:

the first constructor invocation will work.

pet temp("mouse", 5.99);

Explanation:

This will create a pet object on the stack, using the constructor.

If you want to create an object on the heap, you would use the new operator:

pet* pTemp = new pet("mouse", 5.99);

3 0
3 years ago
Among the eight unique features of​ e-commerce, which is related to the ability to interact with web technology​ everywhere?
drek231 [11]
#1) ​Among the eight unique features of​ e-commerce, which is related to the ability to interact with web technology​ everywhere?
Answer: The answer is Online shopping web sites for retail sales direct to consumers. Online shopping is a form of electronic commerce which allows consumers to directly buy goods or services from a seller over the Internet using a web browser. Consumers find a product of interest by visiting the website of the retailer directly or by searching among alternative vendors using a shopping search engine, which displays the same product's availability and pricing at different e-retailers.
4 0
3 years ago
What is the output, if userVal is 5? int x; x = 100; if (userVal != 0) { int tmpVal; tmpVal = x / userVal; System.out.print(tmpV
spayn [35]

Answer:

The output is 20

Explanation:

This line divides the value of x by userVal

tmpVal = x / userVal;

i.e.

tmpVal = 100/5

tmpVal = 20

This line then prints the value of tmpVal

System.out.print(tmpVal);

i.e 20

Hence, The output is 20

4 0
3 years ago
Other questions:
  • By using colocated, replicated hardware and software, cloud solution providers reduce many threats to IT resources.
    5·1 answer
  • PLS HELP GIVING 100 POINTS TO THE PERSON WHO WRITES IT
    6·1 answer
  • With iteration-control systems, each team member ________. is given an account with a set of permissions is given their own priv
    6·1 answer
  • A program is a high-level one that has been converted to machine language
    15·1 answer
  • These operating systems were referred to as command-based. A.Android and MS-DOS B.iOS and Windows C.LINUX and UNIX D.MS-DOS and
    12·2 answers
  • What will the following segment of code output?
    7·1 answer
  • Green Field county stadium is planning to conduct a cricket match between two teams A and B. A large crowd is expected in the st
    6·1 answer
  • What is wrong with a MOV BL, CX instruction?
    6·1 answer
  • What kind of files are automatically blocked in outlook?
    7·1 answer
  • Can anyone fix this code for me?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!