Question

can someone please answer this Python code?

Problem 5 and write code that would find the union, intersection, and Read the documentation for sets difference of the sets

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE:

1 #Given sets A and B 2 A={George, Jim, John, Blake, Kevin, Michael} 3 B={George, Katie, Kevin, Michelle,

CODE (for copy):

#Given sets A and B
A={'George','Jim','John','Blake','Kevin','Michael'}
B={'George','Katie','Kevin','Michelle','Ryan'}
#Union of set A and B
print('A union B:'+str(B.union(A))+"\n")
#Intersection of set A and B
print('A intersection B:'+str(B.intersection(A))+"\n")
#Diffrenece of set A and B
print('A diffrence B:'+str(A-B))

OUTPUT:

A union B:set([Michelle, Blake, Jim, Michael, Ryan, John, George, Kevin, Katie]) A intersection B:set([Geo

Add a comment
Know the answer?
Add Answer to:
can someone please answer this Python code? Problem 5 and write code that would find the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The question exercises the union, intersection, and the intersection operations of two set of strings (names)....

    The question exercises the union, intersection, and the intersection operations of two set of strings (names). For this type of problem, you need to preserve the original sets from being modified by some of the set method. You can used the clone( ) method to copy the sets or simply create another set using the same array contents as the original. You can find an example of the clone() for the LinkedHashSet set in   the provided “skeleton” program (assign8_Q3.java) code...

  • Write the code in PYTHON and please provide the full code, thank you! Write a program...

    Write the code in PYTHON and please provide the full code, thank you! Write a program that plots two functions: f(x) = x2 and g(x) = ax. Write it in such a way that the intersection points are marked with an X, for arbitrary a. • You may use your favorite ready-made function to find the intersection points, if not: • One possible way to tackle this problem is to put both function values in arrays and check using a...

  • Can someone please rewrite this code using a while loop? Please write it in python. #The...

    Can someone please rewrite this code using a while loop? Please write it in python. #The winning number my_number = 12 #variable for the input name user_n = input("Hello! What is your name?") #Ask the user print("Well",user_n,": I am thinking of a number between 1 and 20." + "Take a guess.") user_n = float(input("Take a guess.")) #if statements if user_n == my_number: print("Good job" ,user_n, "You guessed my number!") if user_n > my_number: print("Your guess is high. You lose.") if...

  • *PYTHON EXPERTS ONLY PLEASE* Please provide the answer coded in Python using comments to explain code...

    *PYTHON EXPERTS ONLY PLEASE* Please provide the answer coded in Python using comments to explain code function. Good answers will be rated with thumbs up! Please answer both parts. Thank you for your time. Question 3 - Suppose you have a file named numbers.csv which contains a bunch of integers, five per line of text, separated by commas. Write code below that will open the _le, read the numbers from it, and print the sum of all the even numbers...

  • Question 5 5. Write python code for the given for the problem: Ex: Working group has...

    Question 5 5. Write python code for the given for the problem: Ex: Working group has 8 members. Three will be assigned to lead the group (no difference in leadership positions). If there are 3 women and 5 men in the group, what is the probability of exactly 1 woman being assigned to the leadership (if assigned randomly)?

  • Help writing MatLab code Lab Assignment 5-Employees Average Hours CSCI 251 Problem Statement Suppose the weekly...

    Help writing MatLab code Lab Assignment 5-Employees Average Hours CSCI 251 Problem Statement Suppose the weekly hours for all employees are stored in a text file where each line contains the employee name followed by the hours worked for each day of the week. The data is stored as follows (data is continuous in the file but represented in columns below): Kelly Brian Katie Michae Emily Jim John Jane Joe Doe Smith Hart Jones Hu Wright Young Green Hurley Write...

  • This is for programming using Python with the JES software. Please write the code with the...

    This is for programming using Python with the JES software. Please write the code with the proper indentation. Thanks! Problem 1: Write a function that takes 2 arguments (integer or float) and computes the sum, difference, product, and quotient of the arguments. Once you calculate the values you should print out statements telling the user what arguments we used to compute the values and what the result of each calculation (your function should produce 5 lines of output in the...

  • Please help with this python turtle problem using the functions provided. Python Turtle Write a program...

    Please help with this python turtle problem using the functions provided. Python Turtle Write a program using the turtle module to draw the face of a clock that looks like the image below. You will need to use the turtle module for this exercise as well as the bgcolor), shape(), color), penup), right(), forward(), pendown(), and stamp() functions. The code below can be removed or changed as needed. import turtle t turtle.Turtle0 t.forward(75)

  • 1. Please write the following code in Python 3. Also please show all output(s) and share...

    1. Please write the following code in Python 3. Also please show all output(s) and share your code. Below is a for loop that works. Underneath the for loop, rewrite the problem so that it does the same thing, but using a while loop instead of a for loop. Assign the accumulated total in the while loop code to the variable sum2. Once complete, sum2 should equal sum1. sum1 = 0 lst = [65, 78, 21, 33] for x in...

  • Can someone please code this problem in c++? Problem 1 You are to write a C++...

    Can someone please code this problem in c++? Problem 1 You are to write a C++ program to print the following design in the output window. (Note that * is an asterisk, which is commonly found above the 8 on a standard keyboard. On different terminal types, the asterisk may be rendered differently. You need not concern yourself with the appearance of the asterisk. When I run the program, as long as you have used the correct key on the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT