Questions
in Python 3, I need to search a dictionary for the matching key while ignoring case...

in Python 3, I need to search a dictionary for the matching key while ignoring case of the string and the key. then print the dictionary item in it's original case.

here is the code I have so far but the compiler isn't liking that the name string is lowercase

```
dictionary = {"Dan Smith": {"street":"285 Andover Lane", "city":"Pompano Beach", "state":"FL", "zip":"33060"},"Parker Brady": {"street":"7416 Monroe Ave.", "city":"Windsor", "state":"CT", "zip":"07302"}}

name ="dan smith"

line= dict(filter(lambda item: name.lower() in item[0], dictionary.items()))

print("Street:%5s "% line[name]['street'])
print("City:%5s" % line[name]['city'])
print("State:%5s "% line[name]['state'])
print("Zip Code:%5s "% line[name]['zip'])
```

output should be

Street: 285 Andover Lane

City: Pompano Beach

State: FL

Zip Code: 33060

In: Computer Science

Suppose you are given a file containing a list of names and phone numbers in the...

Suppose you are given a file containing a list of names and phone numbers in the form "First_Last_Phone."

Write a program in C language to extract the phone numbers and store them in the output file.

Example input/output:

Enter the file name: input_names.txt

Output file name: phone_input_names.txt

1) Name your program phone_numbers.c

2) The output file name should be the same name but an added phone_ at the beginning. Assume the input file name is no more than 100 characters. Assume the length of each line in the input file is no more than 10000 characters.

3) The program should include the following function: void extract_phone(char *input, char *phone); The function expects input to point to a string containing a line in the “First_Last_Phone” form. In the function, you will find and store the phone number in string phone.

Please also comment on your code to help to understand, thank you.

In: Computer Science

R language create file Ass2.txt "("Macauley, Culkin" "Antoine, Doinel" "Ace, Ventura" "Tommy, DeVito" "Oda Mae, Brown"...

R language

create file Ass2.txt

"("Macauley, Culkin" "Antoine, Doinel" "Ace, Ventura" "Tommy, DeVito" "Oda Mae, Brown" "John, Malkovich" "Sandy, Olsson" "Raymond, Babbitt" "Jack, Sparrow" "Melanie, Daniels" "Stanley, Kowalski" "Darth, Vader" "Jack, Torrance" "Aurora, Greenway" "Sam, Spade" "Hans, Beckert" "Max, Rockatansky" "Tony, Manero")".

a. Import the data into a vector named name and create an email address for each student as follows. The general format of an email address is username (at) domain. For each student, username is the name of the student in lowercase, with a period separating the first name and the last name if a last name is provided; and domain is IloveR.edu. Name the vector that contains the email addresses as email.

b. Export the data in email to a plain-text file named email.txt in the following format: • Use the column names as the header line.

• There should be no quotes or row names. • Use the comma as a separator.

In: Computer Science

Design and develop a class named Person in Python that contains two data attributes that stores...

Design and develop a class named Person in Python that contains two data attributes that stores the first name and last name of a person and appropriate accessor and mutator methods. Implement a method named __repr__ that outputs the details of a person.


Then Design and develop a class named Student that is derived from Person, the __init__ for which should receive first name and last name from the class Person and also assigns values to student id, course, and teacher name. This class needs to redefine the __repr__ method to person details as well as details of a student. Include appropriate __init__.

Design and develop a class named Teacher that is derived from Person. This class should contain data attributes for the course name and salary. Include appropriate __init__. Finally, redefine the __repr__ method to include all teacher information in the printout.


Implement an application/driver that creates at least two student objects and two teacher objects with different values and calls __repr__ for each.

In: Computer Science

6.13 Lab: Patient Class - process an array of Patient objects This program will create an...

6.13 Lab: Patient Class - process an array of Patient objects

This program will create an array of 100 Patient objects and it will read data from an input file (patient.txt) into this array. Then it will display on the screen the following:

  • 1. The names of the underweight patients.
  • 2. The names of the overweight patients.
  • 3. The names of the obese patients.

Finally, it writes to another file (patientReport.txt) a table as shown below:

Weight Status Report
==================== === ====== ====== =============
Name                 Age Height Weight Status
==================== === ====== ====== =============
Jane North            25   66     120   Normal
Tim South             64   72     251   Obese
.
.
.
==================== === ====== ====== =============
Number of patients: 5

Assume that a name has at most 20 characters (for formatting). Write several small functions (stand-alone functions). Each function should solve a specific part of the problem.

On each line in the input file there are four items: age, height, weight, and name, as shown below:

25 66 120 Jane North    
64 72 251 Tim South

Prompt the user to enter the name of the input file. Generate the name of the output file by adding the word "Report" to the input file's name.

  • If the input file name is patient.txt, the output file name will be patientReport.txt
  • If the input file name is newPatients.txt, the output file name will be newPatientsReport.txt

Display the output file's name as shown below:

Report saved in:  patientReport.txt

If the user enters the incorrect name for the input file, display the following message and terminate the program:

Input file: patients.txt not found!

Here is a sample output:

Showing patients with the "Underweight" status:
Tim South
Linda East
Paul West
Victor Smith
Tom Baker

Showing patients with the "Overweight" status:
none
Showing patients with the "Obese" status:
none
Report saved in:  patient1Report.txt

Main.cpp:

#include "Patient.h"
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;

const int MAX_SIZE = 100;

/* Write your code here:
declare the function you are going to call in this program
*/

int main()
{
Patient patArr[MAX_SIZE];
int size = 0;

string fileName;
cout << "Please enter the input file's name: ";
cin >> fileName;
cout << endl;
/* Write your code here:
function calls
*/
return 0;   
}

/* Write your code here:
function definitions
*/

/*
OUTPUT:

*/

Patient.h:

/*
Specification file for the Patient class
*/

#ifndef PATIENT_H
#define PATIENT_H
#include <string>

using std:: string;


class Patient
{
private:

string name;
double height;
int age;
int weight;

public:
// constructors
Patient();

Patient(string name, int age, double height, int weight);
// setters
void setName(string name);

void setHeight(double height);

void setAge(int age);

void setWeight(int weight);

//getters
string getName() const;

double getHeight() const;

int getAge() const;

int getWeight() const;

// other functions: declare display and weightStatus

void display() const;

string weightStatus() const;
};

#endif

Patient.cpp:

/*
Implementation file for the Patient class.
*/

#include "Patient.h"
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

/*******
This is the default constructor; it sets everything to 0 or "".
*/
Patient::Patient()
{

name = "";
height = 0;
age = 0;
weight = 0;
}

/*******
This is an overloaded constructor.
It sets the variables according to the parameters.
*/
Patient::Patient(string name, int age, double height, int weight)
{

this->name = name;
this->height = height;
this->age = age;
this->weight = weight;

}

void Patient::setName(string name)
{
this->name = name;
}

void Patient::setHeight(double height)
{
this->height = height;
}

void Patient::setAge(int age)
{
this->age = age;
}

void Patient::setWeight(int weight)
{
this->weight = weight;
}

string Patient::getName() const
{
return this->name;
}

double Patient::getHeight() const
{
return this->height;
}

int Patient::getAge() const
{
return this->age;
}

int Patient::getWeight() const
{
return this->weight;
}

/*******
This function displays the member variables
in a neat format.
*/
void Patient::display() const
{
cout << fixed;
cout << " Name: " << getName() << endl;
cout << " Age: " << getAge() << endl;
cout << " Height: " << setprecision(0) << getHeight() << " inches" << endl;
cout << " Weight: " << getWeight() << " pounds" << endl;
cout << "Weight Status: " << weightStatus() << endl;
}

/*******
This function calculates the BMI using the following formula:
BMI = (weight in pounds * 703) / (height in inches)^2
Then, it returns a string reflecting the weight status according to the BMI:
<18.5 = underweight
18.5 - 24.9 = normal
25 - 29.9 = overweight
>=30 = obese
*/
string Patient::weightStatus() const
{
double bmi;
string stat = "";

if (height > 0)
{
bmi = (getWeight() * 703) / (getHeight() * getHeight());

if (bmi < 18.5)
{
stat = "Underweight";
}
else if (bmi >= 18.5 && bmi <= 24.9)
{
stat = "Normal";
}
else if (bmi >= 25 && bmi <= 29.9)
{
stat = "Overweight";
}
else
{
stat = "Obese";
}
}


return stat;
}

In: Computer Science

Diels-Alder Reaction of cis-Butadiene with Maleic Anhydride Experiment: Give the reaction conditions, ie. what apparatus, solvent,...

Diels-Alder Reaction of cis-Butadiene with Maleic Anhydride Experiment:

Give the reaction conditions, ie. what apparatus, solvent, temperature and time will be used. How will the product be isolated from the reaction mixture and how will it be characterized?

In: Chemistry

What role does the trans-1,2,-diaminocyclohexane-N,N,N’,N’-tetraacetic acid play in an experiment testing Fluorine ion concentration in local...

What role does the trans-1,2,-diaminocyclohexane-N,N,N’,N’-tetraacetic acid play in an experiment testing Fluorine ion concentration in local tap water? Does the composition of the TISAB play a role?

In: Chemistry

How do banks create money and how does that compares to the Federal Reserves Quantitative Easing...

How do banks create money and how does that compares to the Federal Reserves Quantitative Easing experiment that saved the U.S. and European economies from a deeper recession and/or depression at the end of the great recession of 2008 - 2009.

In: Economics

Suppose a beginning physics student asks you if it’s possible for a particle to be at...

Suppose a beginning physics student asks you if it’s possible for a particle to be at two different places at the same instant in time. Use the Double-Slit
Experiment to answer the student’s question.

Details would be really helpful

In: Physics

How did the valve influence the experimental results? Is possible, indicate the difference in water displaced(...

How did the valve influence the experimental results? Is possible, indicate the difference in water displaced( in ml) with the valve versus without the valve. does the valve enhance water flow? Why?

Heart valves and pumps experiment

In: Anatomy and Physiology