answer.
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
kenny6666 [7]
1 year ago
7

Write a python 3 function named words_in_both that takes two strings as parameters and returns a set of only those words that ap

pear in both strings. You can assume all characters are letters or spaces. Capitalization shouldn't matter: "to", "To", "tO", and "TO" should all count as the same word. The words in the set should be all lower-case. For example, if one string contains "To", and the other string contains "TO", then the set should contain "to".
1.Use python's set intersection operator in your code.
2.Use Python's split() function, which breaks up a string into a list of strings. For example:

sentence = 'Not the comfy chair!'
print(sentence.split())
['Not', 'the', 'comfy', 'chair!']
Here's one simple example of how words_in_both() might be used:

common_words = words_in_both("She is a jack of all trades", 'Jack was tallest of all')
Computers and Technology
2 answers:
mrs_skeptik [129]1 year ago
8 0
I was going to say the same but there is no point in writing it then
s344n2d4d5 [400]1 year ago
5 0

Answer:

def words_in_both(a, b):

 a1 = set(a.lower().split())

 b1 = set(b.lower().split())

 return a1.intersection(b1)

common_words = words_in_both("She is a jack of all trades", 'Jack was tallest of all')

print(common_words)

Explanation:

Output:

{'all', 'of', 'jack'}

You might be interested in
To what extent are the following computer systems instances of artificial intelligence:
ss7ja [257]

Answer: Supermarket bar code scanners and Voice-activated telephone menus are not instances of artificial intelligence

Explanation:

(a)Supermarket bar code scanners are only able to read the code however they are not able to perform any kind of machine learning techniques to be able to learn a sequence from the codes. As machine learning is a important part of artificial intelligence (AI) so they are not instances of AI. Similarly for Voice-activated telephone menus they could only display and cannot perform any intelligent task.

Web search engines and Internet routing algorithms are very dynamic and intelligent in processing and retrieving information to the end user.

So they are instances of AI.

8 0
1 year ago
Write a while loop that prints user_num divided by 2 until user_num is less than 1. The value of user_num changes inside of the
WITCHER [35]

Answer:

The code to this question can be defined as follows:

Code:

#include <stdio.h> //defining header file

int main() //defining main method

{

float user_num; //defining float variable

printf("Enter a value: "); //message

scanf("%f",&user_num); //input value from user end

printf("%f, ",user_num); //print value

while (user_num>1) //loop to calculte value

{

user_num=user_num/2; //diving value

printf("%f, ",user_num); //print value.

}

   return 0;

}

Output:

Enter a value: 20

20.000000, 10.000000, 5.000000, 2.500000, 1.250000, 0.625000,  

Explanation:

Description of the code as follows:

  • First, a float variable "user_num" is declared, in which we take input from the user-end.
  • In the next step, a while loop is declared, that uses the above variable to calculates its value.
  • Inside the loop variable "user_num" divide its value by 2 and holds its calculated value, to print its value the "printf" method is used that prints its value.  
8 0
2 years ago
An IT department submits a purchase order to buy a new computer from a vendor. "Purchase orders" are documents issued by buyers
Umnica [9.8K]

Answer:

Procurement

Explanation:

Characteristics hardware lifecycle:

  • Procurement- Acquiring new IT hardware assets involves evaluating vendors, purchase orders, receiving, and device labeling.
  • Deployment - Hardware configuration and installment, placing hardware and software assets into production environments.
  • Maintenance & Support - Management of assets include scheduling scans and getting audit history.
  • Upgrade - Before you retire your IT hardware assets, you’ll reach a processing plateau that can be restored with hardware upgrades.
3 0
2 years ago
LAB: Miles to track laps. (PLEASE CODE IN PYTHON)
bekas [8.4K]

Answer:

The program in python is as follows:

def miles_to_laps(user_miles):

     return (user_miles/0.25)

mile = float(input("Number of Miles: "))

print("Number of laps: ",end="")

print('{:.2f}'.format(miles_to_laps(mile)))

Explanation:

The first line defines the function miles_to_lap

def miles_to_laps(user_miles):

This line returns the equivalent number of laps

     return (user_miles/0.25)

The main method starts here

This line prompts user for input

mile = float(input("Number of Miles: "))

This line prints the string "Number of laps", without the quotes

print("Number of laps: ",end="")

This prints the equivalent number of laps to two decimal places

print('{:.2f}'.format(miles_to_laps(mile)))

3 0
2 years ago
Read 2 more answers
Extend the functionality of cout by implementing a friend function in Number.cpp that overloads the insertion operator. The over
san4es73 [151]

Answer:

// In the number.cpp file;

#include "Number.h"

#include <iostream>

using namespace std;

Number::Number(int number)

{

   num = number;

}

void Number::SetNum(int number)

{

   num = number;

}

int Number::GetNum()

{

   return num;

}

ostream &operator<<(ostream &out, const Number &n)

{

   out << "The value is " << n.num << endl;

   return out;

}

// in the main.cpp file;

#include "Number.cpp"

#include <iostream>

using namespace std;

int main()

{

   int input;

   cin >> input;

   Number num = Number(input);

   cout << num;  

   return 0;

}

Explanation:

The main function in the main.cpp file prompts the user for the integer value to be displayed. The Number file contains defined functions and methods of the number class to set, get and display the "num" variable.

7 0
1 year ago
Other questions:
  • Which statement best describes how the rapid prototyping model works?a) Developers create prototypes to show stakeholders how va
    11·2 answers
  • Write a program that can convert an integer between 0 and 15 into hex number (including 0 and 15). the user enters an integer fr
    15·1 answer
  • Witch printer covers a large range of colors than any other printer does
    15·2 answers
  • Memory is a _____________ that includes the organization and shaping of information by processing, storage, and retrieval of inf
    15·1 answer
  • Write a algorithm to attend birthday party​
    8·2 answers
  • Which of the following is not true about VOIP?
    9·1 answer
  • In a ____________________ attack, the attacker sends a large number of connection or information requests to disrupt a target fr
    14·1 answer
  • How can a signature be added to an email message? Check all that apply.
    10·2 answers
  • If parties in a contract are not ____, the contract can be canceled.
    12·1 answer
  • 1.1.5 practice: analyzing business culture
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!