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
Wewaii [24]
2 years ago
13

The Linux tail command prints the last maximum n lines of a file. When writing a function that performs this function, choose th

e correct statements that can go in the ?????.
lines[-n]

lines[-n:]

lines[len(lines)-n:]

lines[-1:-n-1:-1]

lines.pop(n)

Computers and Technology
1 answer:
goldenfox [79]2 years ago
3 0

The Linux tail command prints the last maximum n lines of a file. When writing a function that performs this function, in this case is lines[-n:].

<h3>Writing code in Linux:</h3>

<em>def tail(filename, n=10) :</em>

<em>  with open(filename, "r") as </em>

<em>      lines = f.readlines()</em>

<em>   for line in lines[-n:] : </em>

<em>     print (lines) </em>

See more about linux at brainly.com/question/15122141

#SPJ1

You might be interested in
C++
daser333 [38]

#include<iostream>

#include <fstream>

#include <vector>

#include <string>

#include "StatePair.h"

using namespace std;

int main() {

ifstream inFS;

int zip;

int population;

string abbrev;

string state;

unsigned int i;

vector<StatePair <int, string>> zipCodeState;

vector<StatePair<string, string>> abbrevState;

vector<StatePair<string, int>> statePopulation;

inFS.open("zip_code_state.txt");

if (!inFS.is_open()) {

    cout << "Could not open file zip_code_state.txt." << endl;

    return 1;

}

while (!inFS.eof()) {

    StatePair <int, string> temp;

    inFS >> zip;

    if (!inFS.fail()) {

        temp.SetKey(zip);

    }

    inFS >> abbrev;

    if (!inFS.fail()) {

        temp.SetValue(abbrev);

    }

    zipCodeState.push_back(temp);

}

inFS.close();

inFS.open("abbreviation_state.txt");

if (!inFS.is_open()) {

    cout << "Could not open file abbreviation_state.txt." << endl;

    return 1;

}

while (!inFS.eof()) {

    StatePair <string, string> temp;

    inFS >> abbrev;

    if (!inFS.fail()) {

        temp.SetKey(abbrev);

    }

    getline(inFS, state);

    getline(inFS, state);

    state = state.substr(0, state.size()-1);

    if (!inFS.fail()) {

        temp.SetValue(state);

    }

    abbrevState.push_back(temp);

}

inFS.close();

inFS.open("state_population.txt");

if (!inFS.is_open()) {

    cout << "Could not open file state_population.txt." << endl;

    return 1;

}

while (!inFS.eof()) {

    StatePair <string, int> temp;

    getline(inFS, state);

    state = state.substr(0, state.size()-1);

    if (!inFS.fail()) {

        temp.SetKey(state);

    }

    inFS >> population;

    if (!inFS.fail()) {

        temp.SetValue(population);

    }

    getline(inFS, state);

    statePopulation.push_back(temp);

}

inFS.close();

cin >> zip;

for (i = 0; i < zipCodeState.size(); ++i) {

 }

for (i = 0; i < abbrevState.size(); ++i) {

 }

for (i = 0; i < statePopulation.size(); ++i) {

}

}

Statepair.h

#ifndef STATEPAIR

#define STATEPAIR

#include <iostream>

using namespace std;

template<typename T1, typename T2>

class StatePair {

private:

T1 key;

T2 value;

public:

StatePair()

{}

void SetKey(T1 key)

{

this->key = key;

}

void SetValue(T2 value)

{

this->value = value;

}

T1 GetKey() { return key;}

T2 GetValue() { return value;}

void PrintInfo()

{

cout<<key<<" : "<<value<<endl;

}

};

3 0
1 year ago
Cotización de un software
Mashcka [7]

Answer:

translate it

Explanation:

3 0
3 years ago
2 WAp to input the radius and print<br> the area of circle
daser333 [38]
<h3>Program:-</h3>

\tt r=float(input("Enter\:the\:value\:for\:radius\:of\:circle"))

\tt x=3.14*\:r**2

\tt print("Area\:of\:Circle=\{x\}")

<h3>Sample run:-</h3>

\tt r=3

\tt Area\:of\:the\:circle=28.26

5 0
2 years ago
Write a program using integers userNum and x as input, and output userNum divided by x four times. Ex: If the input is: 2000 2
STatiana [176]

Answer:

// here is code in c++.

// include header

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

// variables to read input

   int userNum,x;

   cout<<"enter the value of userNum and x :";

   // read the input from user

   cin>>userNum>>x;

   // divide the userNum with x 4 times

   for(int a=0;a<4;a++)

   {

       userNum=userNum/x;

       cout<<userNum<<" ";

   }

       cout<<endl;

return 0;

}

Explanation:

Declare two variables "userNum" and "x". Read the value of these. Run a for loop 4 time and divide the "userNum" with "x" and print  the value of "userNum".

<u>Output:</u>

enter the value of userNum and x :2000 2                                                                                  

1000 500 250 125  

3 0
2 years ago
What can multivariable calculus show for a data set.
dalvyx [7]

Answer:

They can help to explain the relationship between the output and input variables.

Hope this Helps!

5 0
2 years ago
Other questions:
  • Ted is a fashion designer. Where is he most likely to work
    9·1 answer
  • Write a program that prints the block letter “B” in a 7x7 grid of stars like this:
    13·1 answer
  • In microsoft windows when a window is minimized what happens to that window
    9·1 answer
  • Preesure is drived quantity? why​
    15·2 answers
  • What was bill gates first operating system he created?
    7·1 answer
  • Could someone please explain to me the an electrical circuit.
    13·2 answers
  • Laptops are used for accessing the internet. Name two advantages and two disadvantages for using a laptop rather than a smartpho
    5·2 answers
  • What are node in a computer network​
    14·1 answer
  • How is scale depicted on a flat video screen?
    13·1 answer
  • Do you guys answer questions about cyber security?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!