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]
3 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]3 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
A 0.50 m3 drum was filled with 0.49 m3 of liquid water at 25oC and the remaining volume was water vapor without any air. The dru
timurjin [86]

Answer:

There is not going to be pressure build up in the  system,that is isobaric process.

Explanation:

Assumptions to be made

1.  No mass is gained or lost during the heating process.

2. There are no friction losses,so work is transmitted efficiently.

3. It was started the water in the drum and its surrounding have same temperature.

4. This system is closed,so there is no mass transfer across its boundaries.

5 0
3 years ago
If you are interested only in the temperature range of 20° to 40°C and the ADC has a 0 to 3V input range, design a signal condit
mario62 [17]

Explanation:

Temperature range → 0 to 80'c

respective voltage output → 0.2v to 0.5v

required temperature range 20'c to 40'c

Where T = 20'c respective voltage

\begin{aligned}v_{20} &=0.2+\frac{0.5-0.8}{80} \times 20 \\&=0.2+\frac{0.3}{80} \times 20 \\V_{20} &=0.275 v\end{aligned}

\begin{aligned}\text { when } T=40^{\circ} C & \text { . } \\v_{40} &=0.2+\frac{0.5-0.2}{80} \times 40 \\&=0.35 V\end{aligned}

Therefore, Sensor output changes from 0.275v to 0.35volts for the ADC the required i/p should cover the dynamic range of ADC (ie - 0v to 3v)

so we have to design a circuit which transfers input voltage 0.275volts - 0.35v to 0 - 3v

Therefore, the formula for the circuit will be

\begin{array}{l}v_{0}=\left(v_{i n}-0.275\right) G \\\sigma=\ldots \frac{3-0}{0.35-0.275}=3 / 0.075=40 \\v_{0}=\left(v_{i n}-0.275\right) 40\end{array}

The simplest circuit will be a op-amp

NOTE: Refer the figure attached

Vs is sensor output

Vr is the reference volt, Vr = 0.275v

\begin{aligned}v_{0}=& v_{s}-v_{v}\left(1+\frac{R_{2}}{R_{1}}\right) \\\Rightarrow & \frac{1+\frac{R_{2}}{R_{1}}}{2}=40 \\& \frac{R_{2}}{R_{1}}=39 \quad \Rightarrow\end{aligned}

choose R2, R1 such that it will maintain required  ratio

The output Vo can be connected to voltage buffer if you required better isolation.

3 0
2 years ago
CS3733: Homework/Practice 05 Suppose we would like to write a program called monitor which allows two other programs to communic
valina [46]

Answer:

#include<stdio.h>

#include<stdlib.h>

#include<unistd.h>

#include<sys/types.h>

#include<string.h>

#include<pthread.h>

//#include<sys/wait.h>

int main(int argc, char** argv)

{

int fd1[2];

int fd2[2];

int fd3[2];

int fd4[2];

char message[] = "abcd";

char input_str[100];

pid_t p,q;

if (pipe(fd1)==-1)

{

 fprintf(stderr, "Pipe Failed" );

 return 1;

}

if (pipe(fd2)==-1)

{

 fprintf(stderr, "Pipe Failed" );

 return 1;

}

if (pipe(fd3)==-1)

{

 fprintf(stderr, "Pipe Failed" );

 return 1;

}

if (pipe(fd4)==-1)

{

 fprintf(stderr, "Pipe Failed" );

 return 1;

}

p = fork();

if (p < 0)

{

 fprintf(stderr, "fork Failed" );

return 1;

}

// child process-1

else if (p == 0)

{

 close(fd1[0]);// Close reading end of first pipe

 char concat_str[100];

 printf("\n\tEnter meaaage:"):

 scanf("%s",concat_str);

 write(fd1[1], concat_str, strlen(concat_str)+1);

 // Concatenate a fixed string with it

 int k = strlen(concat_str);

 int i;

 for (i=0; i<strlen(fixed_str); i++)

 {

  concat_str[k++] = fixed_str[i];

 }

 concat_str[k] = '\0';//string ends with '\0'

 // Close both writting ends

 close(fd1[1]);

 wait(NULL);

//.......................................................................

 close(fd2[1]);

 read(fd2[0], concat_str, 100);

 if(strcmp(concat_str,"invalid")==0)

 {

 printf("\n\tmessage not send");

 }

 else

 {

  printf("\n\tmessage send to prog_2(child_2).");

 }

 close(fd2[0]);//close reading end of pipe 2

 exit(0);

}

else

{

 close(fd1[1]);//Close writting end of first pipe

 char concat_str[100];

 read(fd1[0], concal_str, strlen(concat_str)+1);

 close(fd1[0]);

 close(fd2[0]);//Close writing end of second pipe

 if(/*check if msg is valid or not*/)

 {

  //if not then

  write(fd2[1], "invalid",sizeof(concat_str));

  return 0;

 }

 else

 {

  //if yes then

  write(fd2[1], "valid",sizeof(concat_str));

  close(fd2[1]);

  q=fork();//create chile process 2

  if(q>0)

  {

   close(fd3[0]);/*close read head offd3[] */

   write(fd3[1],concat_str,sizeof(concat_str);//write message by monitor(main process) using fd3[1]

   close(fd3[1]);

   wait(NULL);//wait till child_process_2 send ACK

   //...........................................................

   close(fd4[1]);

   read(fd4[0],concat_str,100);

   close(fd4[0]);

   if(sctcmp(concat_str,"ack")==0)

   {

    printf("Messageof child process_1 is received by child process_2");

   }

   else

   {

    printf("Messageof child process_1 is not received by child process_2");

   }

  }

  else

  {

   if(p<0)

   {

    printf("Chiile_Procrss_2 not cheated");

   }

   else

   {

     

    close(fd3[1]);//Close writing end of first pipe

    char concat_str[100];

    read(fd3[0], concal_str, strlen(concat_str)+1);

    close(fd3[0]);

    close(fd4[0]);//Close writing end of second pipe

    write(fd4[1], "ack",sizeof(concat_str));

     

   }

  }

 }

 close(fd2[1]);

}

}

8 0
3 years ago
What major advancement in machine tools occurred in the 1970s and what benefits did it provide? describe in your own words.
mixer [17]

Answer:

I'm just a seventh grader

4 0
3 years ago
Read 2 more answers
Can someone tell me what car year and model this is please
Arlecino [84]

Answer:

i think 1844

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • 9) A construction company employs 2 sales engineers. Engineer 1 does the work in estimating cost for 70% of jobs bid by the comp
    11·1 answer
  • What are the disadvantages of using 3D ink jet printing ??
    8·1 answer
  • Vehicles arrive at a single toll booth beginning at 8:00 A.M. They arrive and depart according to a uniform deterministic distri
    9·1 answer
  • The town of Mustang, TX is concerned that waste heat discharged from a new up- stream power plant will decimate the minnow popul
    10·1 answer
  • Two kilograms of air in a piston-cylinder assembly undergoes an isothermal process from an initial state of 200K, 300kPa to 600k
    8·1 answer
  • Annealing is a process by which steel is reheated and then cooled to make it less brittle. Consider the reheat stage for a 100-m
    14·1 answer
  • A chemistry student accidentally drops a large mercury thermometer and it breaks. The thermometer contained 2 grams of mercury (
    13·1 answer
  • Which of these are factors of 121?
    13·2 answers
  • Question Completion Status:
    6·1 answer
  • Code for XOR with two input logic gate
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!