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
photoshop1234 [79]
3 years ago
9

Ex: If the input is: Pat Silly Doe the output is: Doe, P.S.

Computers and Technology
1 answer:
den301095 [7]3 years ago
7 0

Answer:

Full_name=input("Enter Full Name: ").split()

len1=len(Full_name)

if len1 == 3:

   print(Full_name[2]+", "+Full_name[0][0]+"."+Full_name[1][0]+".")

if len1 == 2:

   print(Full_name[1]+", "+Full_name[0][0]+".")

Explanation:

We first get full names as input from the user. And then split into words, and finally, we store it in the list. Now we calculate the length of that list. The name in general 3 words long, And hence, we can assume here that maximum length is 3, and it can be 2 definitely. Now if the length is 3 we print the third word or last name in full, and the first letter of the middle name and first name. Also, if the maximum length is 2 then we print the middle name in full, and this is the last name in this case. Also, we print the first letter of the first name. And thus, we have our solution.

You might be interested in
The security administrator of ABC needs to permit Internet traffic in the host 10.0.0.2 and UDP traffic in the host 10.0.0.3. Al
koban [17]

Answer:

The correct selection is the letter C. The first ACL is denying all TCP traffic and the other ACLs are being ignored by the router.

Explanation:

In this case, the letter C is the right answer because with the first ACL exactly:

access-list 102 deny tcp any any

We are denying all traffic with the next line deny tcp any any, in this case, the others line are being ignored.

access-list 104 permit udp host 10.0.0.3 any

access-list 110 permit tcp host 10.0.0.2 eq www any

access-list 108 permit tcp any eq ftp any

For that nobody can access to the internet, the security administrator of ABC must change the first ACL.

5 0
3 years ago
In 5-10 sentences, describe the purposes, design considerations, and common elements of most brochures.
lozanna [386]
The primary thing to consider when designing a brochure is the target audience. <span> Brochures are meant to capture attention and deliver information, so it's important that the audience will want to read it in the first place.</span> When planning the design, consider the placement of elements and how they are arranged, or the 'white space'. Also take into consideration whether photos will be used. This ensures readability. <span>Also plan for the brochure's color scheme and fonts. These capture the audience so these are core parts of the design.</span>
4 0
3 years ago
Which of these completes the sentence? People interpret information ___________. Choose one.
evablogger [386]

Explanation:

mannejaondpsbma0jdjdhdj

5 0
3 years ago
Read 2 more answers
What might happen if Python code is not in the correct order? The computer will fix the steps automatically. The computer will f
Vesna [10]

Answer:

The computer will follow the steps, but the program might not work.

Explanation:

4 0
3 years ago
Read 2 more answers
Given a string variable string 's;', implement a tokenizer to identify the unique tokens contained in this string, identify all
Flauer [41]

Answer:

#include <iostream>

#include <string>

#include <vector>

#include <cctype>

#include <algorithm>

using namespace std;

void matrixInit( vector< vector<int> >& matrix, int numRows, int numCols);

struct TokenFreq{

string token;

int freq;

};

string spaces(string& istr, string& newstr);

void printVector(vector<TokenFreq> & tfVec);

void getTokenFreqVec( string& istr, vector<TokenFreq> & tfVecVec);

void selectionSort( vector<TokenFreq> & tokFreqVector );  

void insertionSort( vector<TokenFreq> & tokFreqVector );

//main

int main(int argc, const char * argv[]) {

 

vector<vector<int> > matrix;

matrixInit(matrix, 3, 4);

 

string ostr1 = " I do keep the main points straight in my head most of the time, and I do know where to find the details when I need them. by Bjarne Stroustrup";

string ostr2 = " ";

string ostr3 = "Your time is limited, so don’t waste it living someone else’s life.Stay Hungry. Stay Foolish.";

//string ostr = ostr2;

string istr;

 

cout << "Enter the text: ";

getline(cin, istr);

vector<TokenFreq> tfVec;

getTokenFreqVec(istr, tfVec);

selectionSort(tfVec);

insertionSort(tfVec);

return 0;

}

//-----

void selectionSort( vector<TokenFreq> & tokFreqVector ){

TokenFreq temp;

int min;

 

for( int i = 0; i < int(tokFreqVector.size()-1); i++){

min = i;

for (int j = i+1; j <int(tokFreqVector.size()); j++){

if (tokFreqVector[j].freq < tokFreqVector[min].freq)

min = j;

}

if(min!=i)

{

temp = tokFreqVector[i];

tokFreqVector[i] = tokFreqVector[min];

tokFreqVector[min] = temp;

}

}

cout<<"-----selectionSort------------------"<<endl;

printVector(tokFreqVector);

}

void insertionSort( vector<TokenFreq> & tokFreqVector ){

TokenFreq temp;

int max;

 

for( int i = 0; i < int(tokFreqVector.size()-1); i++){

max = i;

for (int j = i+1; j < int(tokFreqVector.size()); j++){

if (tokFreqVector[j].freq > tokFreqVector[max].freq)

max = j;

}

if(max!=i)

{

temp = tokFreqVector[i];

tokFreqVector[i] = tokFreqVector[max];

tokFreqVector[max] = temp;

}

}

cout<<"-----insertionsort------------------"<<endl;

printVector(tokFreqVector);

}

string spaces(string& istr, string & newstr){

int j;

//Check double space and create new string with lowercase

for (int i = 0; i < int(istr.length()); ++i){

istr[i] = tolower(istr[i]);

if (isspace(istr[i])){

//check double space again

j = i+1;

while(true){

if (istr[j] == '\342') istr[j]=' ';

if (istr[j] == '\200') istr[j]=' ';

if (istr[j] == '\224') istr[j]=' ';

if(isspace(istr[j])) j++;

else break;

}

i=j-1;

newstr = newstr + istr[i];

}else

newstr = newstr + istr[i];

}

return newstr;

}

void getTokenFreqVec( string& istr, vector<TokenFreq> & tfVec){

string newstr;

int curr_beg = 0;

int curr_end = 0;

string word;

bool check = false;

int index=0;

 

//call func spaces to get new string

newstr = spaces(istr, newstr);

//cout << newstr << endl;

//cout << endl;

//cout << newstr << "||" << endl;

string tempstr = newstr;

 

if(newstr != " "){

tfVec.push_back(TokenFreq());

}

for (int i = 0; i < int(newstr.length()); ++i){

if(isspace(newstr[i])){

check = false;

 

curr_end = i;

word = tempstr.substr(curr_beg, curr_end - curr_beg);

curr_beg = i + 1;

 

for (int j = 0; j < int(tfVec.size()); j++){

if (tfVec[j].token == word){

tfVec[j].freq++;

check = true;

 

break;

}

}//end-for;

if (check == false && i!=(int(newstr.length())-1)){

//cout <<"**"<< word <<"**"<<word.length()<< endl;

tfVec[index].token=word;

tfVec[index].freq=1;

index++;

tfVec.push_back(TokenFreq());

}

word = "";

//add last value

}

}//end-for

 

if(!isspace(newstr[int(newstr.length())-1])){

word = tempstr.substr(curr_beg, curr_end - (int(newstr.length())-1));

tfVec[index].token=word;

tfVec[index].freq=1;

//tfVec.push_back(TokenFreq());

}

 

printVector(tfVec);

}

void printVector(vector<TokenFreq> & tfVec){

 

cout << "size= {" << tfVec.size() << endl;

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

cout << " [" << i << "] = (token = \""<< tfVec[i].token <<"\", freq = " << tfVec[i].freq << ")" << endl;

//cout << tfVec[i].token<<endl;;

}

cout << endl;

}

void matrixInit( vector< vector<int> >& matrix, int numRows, int numCols){

int i;

int j;

matrix.resize(numRows, vector<int>(numCols) );

for(i = 0; i< numRows; i++ ){

for(j = 0; j < numCols; j++ )

matrix[i][j] = i*j;

}

 

cout << "size of matrix is: " << numRows << "x" << numCols << endl;

for (i = 0; i < numRows; i++){

for (j = 0; j < numCols; j++){

cout<< "matrix[" << i << "][" << i << "]=" << matrix[i][j] << endl;

}

}

cout << endl;

}

Explanation:

3 0
3 years ago
Other questions:
  • SELECT vendor_name, COUNT(*) AS number_of_invoices, MAX(invoice_total - payment_total - credit_total) AS balance_due FROM vendor
    15·1 answer
  • The expressionvecCont.empty() empties the vector container of allelements.
    13·1 answer
  • Given the function definition below, what is the effect of thecall:
    7·2 answers
  • Object-oriented programs employ a group of techniques for handling errors called ________ handling.
    12·1 answer
  • Implement the function:
    6·1 answer
  • What is a computer briage coures​
    15·1 answer
  • Who has a brainpop acct. can i pls use it !
    12·1 answer
  • Where else can the computer send the results of processing other than to output​
    13·1 answer
  • Help pls<br> cmu cs 0<br> 4.1.2.1 Creating Groups checkpoint 1
    11·2 answers
  • How could the following line of code be shortened?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!