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
Jlenok [28]
3 years ago
10

# q7 - create function readFileFirstLast() to meet the conditions below

Computers and Technology
1 answer:
MAVERICK [17]3 years ago
3 0

Answer:

See explaination

Explanation:

def readFileFirstLast(filename):

# doc string

''' Function accept the filename and opens the fle

and reads all lines and strips new line character and

stores first and last in a string and return that string'''

#eception handle if file not found

try:

#opening the file

f = open(filename)

#reading the first line and striping the ne line

string = f.readline().strip()

#iterating until last line

for line in f:

pass

#concate the last line after strip the new line character to the string

string = string + " " + line.strip()

#return the string

return string

except:

#if file not found

return "File not found"

#taking the file name from user

filename = input("Enter a file name: ")

#printing the doc string in function

print("\ndoc_sting: \n"+ readFileFirstLast.__doc__+"\n")

#printing the returned string by calling the readFileFirstLast()

print("output string :")

print(readFileFirstLast(filename))

You might be interested in
In addition to the decimal number system, the number systems used most often in PLC operationand programming are ________.
otez555 [7]

Answer: PLC uses:

1. Decimal Number system

2. Binary Number system.

3. Octal Number system.

4. Hexadecimal Number system.

5. Binary Coded Decimal Number system.

6. Negative Number system.

7. Number Conversations.

Explanation: The other numbers the Programmable Logic Controller(PLC) uses aside the decimal number system are:

1. Binary Number system.

2. Octal Number system.

3. Hexadecimal Number system.

4. Binary Coded Decimal Number system.

5. Negative Number system.

6. Number Conversations.

7 0
3 years ago
The data _____ component of a database management system (DBMS) is used to create and maintain the data dictionary. manipulation
Ira Lisetskai [31]

Answer:

definition

Explanation:

A database management system (DBMS) can be defined as a collection of software applications that typically enables computer users to create, store, modify, retrieve and manage data or informations in a database. Generally, it allows computer users to efficiently retrieve and manage their data with an appropriate level of security.

A data dictionary can be defined as a centralized collection of information on a specific data such as attributes, names, fields and definitions that are being used in a computer database system.

In a data dictionary, data elements are combined into records, which are meaningful combinations of data elements that are included in data flows or retained in data stores.

This ultimately implies that, a data dictionary found in a computer database system typically contains the records about all the data elements (objects) such as data relationships with other elements, ownership, type, size, primary keys etc. This records are stored and communicated to other data when required or needed.

Basically, when a database management system (DBMS) receives data update requests from application programs, it simply instructs the operating system installed on a server to provide the requested data or informations.

Hence, the data definition component of a database management system (DBMS) is used to create and maintain the data dictionary.

6 0
3 years ago
4.7 code practice question 2 edhesive i cant figure out the code for this problem csn anyone help me?
rodikova [14]

Answer:

See Explanation

Explanation:

<em>See attachment for complete question</em>

The programming language is not stated; I'll answer using Python and Java

Python:

low = 56

high = 70

for i in range(low,high+1):

    print(i)

Java:

public class PrintOut{

public static void main(String [] args)

{

int low = 56; int high = 70;

for(int i = low; i<=high;i++)

System.out.print(i+" ");

}

}

For both codes, the explanation is:

The code starts by initializing the range of the print out to 56 and 70

Next, the code segment used an iteration that loops through 56 and 70 and print each digit in this range (both numbers, inclusive).

8 0
3 years ago
Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay the hourly rate for the hou
Nuetrik [128]

Answer:

Following is the program in the python language

hr = input("input hours:") #Read input by user

h1 = float(hr)

rate =input("Input Rate:") #Read RATE BY USER

r1 = float(rate) #CONVERT INTO FLOAT

if h1 <= 40: #check condition

   t=h1 * r1

   print (t) #DISPLAY

else :#else block

   t1=(40 * r1) + (h1 -40) * r1 * 1.5

   print('The pay is :')

   print(t1)#DISPLAY

Output:

input hours:45

Input Rate:10.50

The pay is :

498.75

Explanation:

Following are the description of program

  • Read the value of hour in the "hr" variable and convert into the float value in the "h1" variable .
  • Read the value of rate in the " rate" variable and convert into the float value in the "r1" variable .
  • After that check the condition of hour if block if the hour is less then or equal to 40 then it multiplied h1 *t1 otherwise else block will be executed and print the value of pay .

5 0
4 years ago
What is going to be the shortest, most concise restatement of information?
iVinArrow [24]
Not sure i need this too
4 0
3 years ago
Read 2 more answers
Other questions:
  • An engineer is assigned the task of reducing the air pollutants being released from a power plant that generates electricity by
    9·1 answer
  • What is deshtop in desktop publishing
    11·1 answer
  • ______ engineers build prototype cars and troubleshoot them.
    8·2 answers
  • Which course must first-time drivers in Florida take to be eligible for their Learner License?
    11·1 answer
  • As an ICT student teacher using convincing and cogent reasons explain why you think operating system is pivotal in teaching and
    7·1 answer
  • Your mother is sure that you were driving too fast because she knows
    10·2 answers
  • What does t'challa actions reveal about his character( black panther movie)​
    6·1 answer
  • The temperature in toronto canada was-4°c and tje temperature in brixton,england was 6°c warmer. what was the difference in temp
    11·1 answer
  • Raw materials have two basic types what are the 2?
    11·2 answers
  • If a person's mobile phone was designed to work with 4G technology, what will happen when a 5G network is rolled out in their ar
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!