Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in GDB please as simple as possible What is the output of the following python code? a=set([Apple,4, Mango, 9, Banana, Coca Cola, 5, 11]) b=set([1,9,

image text in transcribed
image text in transcribed
image text in transcribed
in GDB please as simple as possible
What is the output of the following python code? a=set(["Apple",4, "Mango", 9, "Banana", "Coca Cola", 5, 11]) b=set([1,9, "Apple", 2, "Orange", 2, 11, "Coca Cola" ]) print (b) print (a) d=a b print (d) c=a&b print (c) e=ab print (e) f =ab print (f) Solution: Q.29) Explain directories and Exception? What is the output of the following python instruction? \[ \begin{array}{l} \text { set1 }=\text { set }([1,4,2,9,2,7,5,4,5,11]) \\ \text { set2 }=\text { set }([1,9,3,2,5,11,2]) \\ \text { print set2 } \\ \text { print set1 } \\ \text { intersection = set1 \& set2 } \\ \text { print intersection } \\ \text { union = set1 } \mid \text { set2 } \\ \text { print union } \\ \text { difference }=\text { set1 }-\text { set2 } \\ \text { print difference } \\ \text { symm_diff }=\text { set1 } \text { ^ set2 }^{2} \\ \text { print symm_diff } \end{array} \] Q.30) What is the output of the following code? * This function multiplies two numbers def multiply (x,y); return xy \# This function divides two numbers def divide (x,y) : return x/y 2 ithlew hol anole PRINCE SULTAN print("Select operation.") print(").Add") print("2.Subtract") print("3.Multiply") print("4.Divide") while True: \# take input from the user choice = input("Enter choice(1/2/3/4): ") If check if choice is che of the four options if choice in Cl,,2,3:,47 : numl = float(inpat( Enter first number: ")) num2 - float(inpat("Enter second number. ")) if choice =1 ?: print(num1. "+", num2, "=", add(numbl, num2)) elif choice = 2: print(num1, "-", num2, "m", subtract(num1, num2)) clif choice = '3: print(num1, "*", num2, " , mulhiply(num1, num2)) elif choice =4 : 4 print(nam1, " f ", num2, ",", divide(num1, num2)) H check if user wants another calculation \#i break the while loop if answer is no next_calculation - input("Let's do next calculation? (yeso): ") if next_calculation - "no": break else: priat, "Iavalid laput")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions