Unit 4 - Lesson 15

48.1.1. Understanding Set Comprehensions

n1 = int(input("n1: "))
n2 = int(input("n2: "))

#fill in the missing code..

my_set = {i*i if i%2==0 else i**3 for i in range(n1,n2)}

print(sorted(my_set))

48.1.2. Understanding Nested Set Comprehension

#fill in the missing code...
n = int(input())
s = { (a,b,c) for a in range(1,n+1) for b in range(1,n+1) for c in range(1,n+1) if a*a == b*b+c*c and c<=b }

print(sorted(s))

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.