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
Reptile [31]
4 years ago
6

python Write a program that asks a user to type in two strings and that prints •the characters that occur in both strings. •the

characters that occur in one string but not the other. •the letters that don’t occur in either string. Use the set function to turn a string into a set of characters.
Engineering
1 answer:
Yuliya22 [10]4 years ago
8 0

Answer:

see explanation

Explanation:

#we first get the elements as inputs

x = input("enter string A :")

y = input("enter string B :")

#then we make independent sets with each

x = set(x)

y = set(y)

#then the intersection of the two sets

intersection = set.intersection(x,y)

#another set for the alphabet

#we use set.difference to get the elements present in x and not in y, and

#viceversa, finally we get the difference between the alphabet and the #intersection of the elements in our strings

z = set('abcdefghijklmnopqrstuvwxyz')

print('\nrepeated :\n',intersection)

print('differences :\n',' Items in A and not B\n',

set.difference(x,y),'\nItems in B and not A\n',

set.difference(y,x))

print('\nItems in neither :\n',set.difference(z,intersection))

You might be interested in
What is capillary action?
BARSIC [14]
Capillary action occurs When the adhesion to the walls stronger than dirt cohesive forces between a liquid molecules. the head towards Capillery action will take water in a uniform circular is limited by surface tension and, of course, gravity.
4 0
2 years ago
Oil enters a counterflow heat exchanger at 600 K with a mass flow rate of 10 kg/s and exits at 200 K. A separate stream of liqui
Elis [28]

Answer:

The minimum mass flow rate for the water is 14.39kg/s

Explanation:

In this question, we are asked to calculate the minimum mass flow rate for the water in kg/s.

Please check attachment for complete solution and step by step explanation

7 0
3 years ago
1 // Lab 2 tryIt2A 2 #include 3 using namespace std; 4 5 int main() 6 { int x = 1, y = 3; 7 int X = 2, Y = 4; 8 9 cout <<
padilas [110]

Answer:

Here is the complete program:

#include <iostream>

 using namespace std;    

 int main()

 {  int x = 1, y = 3;  

 int X = 2, Y = 4;  

 cout << "tryIt 2A" <<endl;

   cout << x << y << endl;  

   cout << "x" << "y" << endl;  

   cout << X << " " << Y << endl;

   cout << 2 * x + y << endl;  

   cout << 2 * X + Y << endl;  

   //cout << x + 2*y << endl;  

   cout << "x = ";  

   cout << x;  

   cout << " y = ";  

   cout << y;        

   return 0;

   }

Explanation:

I will explain the code line by line in the comment with each line of code and the output of each cout statement.

  • int x = 1, y = 3;  

This statement assigns value 1 to integer variable x and 3 to int variable y

  • int X = 2, Y = 4;  

This statement assigns value 2 to integer variable X and 4 to int variable Y As C++ is a case sensitive language so variable x and y are different from variables X and Y.

  • cout << "tryIt 2A" <<endl;

This statement has cout which is used to display output on the screen. So the output displayed by this cout statement is:

tryIt2A

  • cout << x << y << endl;  

This statement will print the values stored in x and y variables. So output displayed by cout statement here is 1 and 3. As there is not space or next line specified in the statement so output displayed will look like this:

13

  • cout << "x" << "y" << endl;  

This statement will display x and y but these are not the variable x and y. They are enclosed in double quotation marks so they are treated as strings not variables so the output displayed is:

xy

  • cout << X << " " << Y << endl;

This statement will print the values stored in X and Y variables. So output displayed by cout statement here is 2 and 4. As there is  space " " specified in the statement so 2 and 4 are displayed with a space between them so the output displayed will look like this:

2 4

  • cout << 2 * x + y << endl;  

This statement has an arithmetic operation in which 2 is multiplied by the values stored in variable x and then the result is added by value of y. So  2*1 = 2 and 2 + 3 = 5. So the result produced by this cout statement is:

5

  • cout << 2 * X + Y << endl;  

This will work same as above cout statement but the only difference is that the values of capital X and Y variables are calculated here. So 2 * 2 = 4 and then 4 + 4 = 8. The result produced by this cout statement is:

8

  • //cout << x + 2*y << endl;  

This is a comment because before this statement // is written which is used for single line comment. So compiler ignores comments and will not compile this statement.

  •    cout << "x = ";  

This will display "x = " as it is not variable but it is treated as a line to be displayed on the screen. So cout statement displays:

x =

  • cout << x;

This will print the value stored in x variable as there are no double quotes around x so it is a variable which contains value 1. In the above statement there is no endl so the output of this cout statement is displayed with the output of previous cout statement. So the following line is displayed on screen:

x = 1

  • cout << " y = ";

This will display "y = " as it is not variable but it is treated as a line to be displayed on the screen. In the above statement there is no endl so the output of this cout statement is displayed with the output of previous cout statement. So the following line is displayed on screen

x = 1 y =

  • cout << y;    

This will print the value stored in y variable as there are no double quotes around y so it is a variable which contains value 3. In the above statement there is no endl so the output of this cout statement is displayed with the output of previous cout statement. So the following line is displayed on screen:

x = 1 y = 3

So the output of the entire program along with the program is attached as screenshot.

6 0
4 years ago
A journeyman electrician with 16 years experience on-the-job was removing metal fish tape from a hole at the base of a metal lig
Romashka-Z-Leto [24]

Answer: He should have ensured the following before beginning work;

1) All circuits must be de-energized before beginning work

2) All controls must be deactivated during work. LOTO(Log out tag out) must be practiced irrespective of the experience of the electrian or worker.

3) Technicians and Electrical workers must be instructed to know the unsafe conditions associated with their work.

Explanation:

We cannot assume that because he is experienced he cannot be prone to all this wrong practices. Humans tend to think that with experience people become less prone to errors and study has shown that this is not true. Safety must be a priority.

5 0
3 years ago
What part of the plane makes it go up and down
Sunny_sXe [5.5K]
Elevators makes it go up and down
4 0
3 years ago
Read 2 more answers
Other questions:
  • Unlike in previous questions where we wanted you to complete a function we had started, here we want you to write a Python funct
    5·1 answer
  • If the resistance reading on a DMM'S meter face is to 22.5 ohms in the range selector switch is set to R X 100 range, what is th
    5·1 answer
  • A guy named Kirby Had touched only a gear on the projector. Yet there was a out of the blue rip. Kirby did not mind at all and s
    6·1 answer
  • Who want to 1v1 lol unblocked games 76 with me
    5·2 answers
  • Technician A says a limited slip differential can redirect power from a drive wheel that is slipping to the wheel that has tract
    15·1 answer
  • A police officer in a patrol car parked in a 70 km/h speed zone observes a passing automobile traveling at a slow, constant spee
    6·1 answer
  • Which is an alloy made up of iron and carbon and has high compressive and tensile strength?
    6·1 answer
  • How much does the transportation sector contribute to current greenhouse gas emissions? Where do most of these emissions come fr
    14·1 answer
  • Who ever is here first get brainliest
    13·1 answer
  • Technician A says that one function of oil is to clean. Technician B says that one function of oil is to cushion. Who is correct
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!