Commit 8a2de322 authored by Espen Haabeth's avatar Espen Haabeth
Browse files

Update set.py

parent a1bcd0a0
Pipeline #89245 failed with stages
in 46 seconds
import random
# 100 tilfeldige tall 0 - 100 inn i en liste:
tall = [random.randint(0,100) for i in range(100)]
print("Antall tall:",len(tall))
tall.sort()
print("Sorterte tall:", tall)
# Kjører du dette mange ganger, ser du at ulike tall trekkes.
# Og noen flere ganger. Men det finnes en måte å bare få unike
# verdier.
print("Set:", set(tall))
print("Antall elementer:", len(set(tall)))
import random
# 100 tilfeldige tall 0 - 100 inn i en liste:
tall = [random.randint(0,100) for i in range(100)]
print("Antall tall:",len(tall))
tall.sort()
print("Sorterte tall:", tall)
# Kjører du dette mange ganger, ser du at ulike tall trekkes.
# Og noen flere ganger. Men det finnes en måte å bare få unike
# verdier.
print("Set:", set(tall))
print("Antall elementer:", len(set(tall)))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment