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]
2 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]2 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
List five ways in which the type declaration system of a language such as Java or C differs from the data definition language us
zhannawk [14.2K]

Answer:

Hi Sevanah! Below are the five main differences between a type declarative language and a data definition language:

A data definition language:

1. define data structure

2. define the column attributes of a table

3. no further classifications

4. The basic commands in a Data Definition language are CREATE, DROP, RENAME, ALTER

5. Scope of variables in data definition languages is limited  

A type declarative language:

1. manipulate the data itself

2. uses functions to add and update the rows of a table

3. further classified into procedural and non-procedural languages

4. The basic commands are INSERT, UPDATE and MERGE

5. Scope of variables in type declarative languages is varied

Explanation:

A data definition language is used to define data structures. It makes use of statements such as create table, alter table to create and alter the database schema to allow it to hold rows of information. A type declarative language such as Java or C is used to manipulate the data itself. For example, insert, update and deletion of rows to the database. Whereas data definition languages define the column attributes of a table, a type declaration language uses functions to add and update the rows of a table. A data definition language does not have any further classification, however a type declarative language can be further classified into procedural and non-procedural languages. The basic commands in a Data Definition language are CREATE, DROP, RENAME, ALTER, whereas the basic commands in a type declarative language are INSERT, UPDATE and MERGE. There is little of no scope of variables in a data definition language, whereas the scope of variables in type declarative languages is varied

8 0
3 years ago
What is meant by algorithm?​
ExtremeBDS [4]

Answer:

a process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer.

Explanation:

7 0
3 years ago
If a data label, title, or legend in a chart is difficult to read, you can format them as bold, but you cannot change the font s
Daniel [21]

If a data label, title, or legend in a chart is difficult to read, you can format them as bold, but you cannot change the font size: False.

<h3>What is a chart?</h3>

A chart can be defined as an effective medium that is used to graphically display data in a pictorial form. Thus, a chart comprises the following elements:

  • Data label
  • Title
  • Legend

If the aforementioned elements in a chart is difficult to read for the end users, they can easily format them as bold and equally change the font size.

In conclusion, the elements in a chart can be formatted as bold and their font size can also be changed.

Read more on chart here: brainly.com/question/24741444

8 0
2 years ago
Statement: There are two files. One file, "badIP_list.txt" has a listing of known bad IP addresses. These addresses were extract
lapo4ka [179]

Answer:

See explaination

Explanation:

SOURCE CODE IN PYTHON:

inp=open('badIP_list.txt', 'r') #opening file for input

badIPs=[i.rstrip('\n') for i in inp.readlines()] #reading bad IPs

inp.close() #closing file

inp=open('server_logs.txt', 'r') #opening file for input

IPs=[i.rstrip('\n') for i in inp.readlines()] #reading all IPs from log

inp.close() #closing file

uniqueBadIPs=[] #to store unique bad IPs

countBadIPs=0 #to store count of bad IPs

countIPs=0 #to store count of all IPs

for IP in IPs: #iterating through the log of IPs

if IP in badIPs: #checking if IP is bad

countBadIPs+=1

if IP not in uniqueBadIPs: #checking if bad IP is unique

uniqueBadIPs.append(IP)

countIPs+=1

out=open('filter_list.txt', 'w') #opening file for output

out.write('_________________________________________________________\n')

out.write('Date : 26/07/2018\nName : Last, First\nMajor: CS\n\n')

out.write('Server logs contained these known bad IP addresses:\n')

for IP in uniqueBadIPs: #output the unique bad IPs

out.write(IP+'\n')

out.write('\n')

out.write('Total unique known bad IP\'s detected:\n'+str(len(uniqueBadIPs))+'\n\n')

out.write('Percentage of bad IP addresses in server logs:\n{:.2f}%\n'.format(countBadIPs*100/countIPs))

out.write('_________________________________________________________')

out.close() #closing file

5 0
4 years ago
__________________________would be involved in projects such as implementing security measures and software to protect systems a
defon

<u>Network Administrator</u><u>/Network Engineer</u> would be involved in projects such as implementing security measures and software to protect systems and information infrastructure, including firewalls and data-encryption programs.

<h3>What does an administrator of a network do?</h3>

The  network administrator is known to be a person who is involved in the day-to-day management of these networks is the responsibility of network and computer system administrators.

They function by helping to plan, set up, and provide maintenance for a company's computer systems, etc., for data communication.

Therefore, <u>Network Administrator</u><u>/Network Engineer</u> would be involved in projects such as implementing security measures and software to protect systems and information infrastructure, including firewalls and data-encryption programs.

Hence, option D is correct.

Learn more about Network Administrator from

brainly.com/question/5860806
#SPJ1

3 0
1 year ago
Other questions:
  • When purchasing a(n) ________ computer, having cellular as well as wifi can be important?
    9·1 answer
  • When you see ##### in a cell, you should A. increase the cell width. B. increase the cell height. C. decrease the cell width. D.
    14·1 answer
  • 20. Which of the following describes an acceptable print resolution?
    10·2 answers
  • Manipulate the SQL statement to pull ALL fields and rows from Customers table that have a PostalCode of 44000. TIP: Since Postal
    13·1 answer
  • 15. The text of a desktop publishing document is often created using
    6·2 answers
  • Fax machines, voice mail, electronic mail, and electronic conferencing are all examples of _________.
    15·2 answers
  • Missy loves her old Windows games. When she upgrades her Windows system, the games run fine, but the output looks fuzzy since th
    15·1 answer
  • 1.) Florida has ____________ roads that are designated as part of the National Highway System.
    12·1 answer
  • Write a method that computes the sum of the digits in an integer. Use the following method header: public static int sumDigits(l
    5·1 answer
  • ______________________ can run on a workstation or server and is at the heart of all business applications.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!