This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Geometri, hva kan gjøres med bare firkanter? La oss bygge en by | |
from turtle import * | |
from random import * | |
# Litt oppsett av vindu, farger og størrelser | |
skjerm_bredde = 1700 | |
skjerm_hoyde = 1000 | |
setup(skjerm_bredde, skjerm_hoyde) | |
tracer(2) # sett til 0 for å tegne umiddelbart, da betyr speed() ingenting |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import sleep | |
def finn_tall(n): | |
partall = [] | |
oddetall = [] | |
for siffer in n: | |
if int(siffer) % 2 == 0: | |
partall.append(int(siffer)) | |
else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import sleep | |
print("Vi prøver Kaprekar's rutine på vei mot konstanten 6174 og 495\n") | |
mitt_tall = input("Velg et tre eller firesifret tall, med minst to ulike siffer: ") | |
desc_a = "".join(sorted(mitt_tall, reverse=True)) | |
asc_a = "".join(sorted(mitt_tall)) | |
steg = 0 | |
siffer = len(mitt_tall) | |
print(f"\nVi finner størst {desc_a} og minst tall {asc_a} fra sifrene og begynner rutinen...\n") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
palindromer = [] | |
palindromprimtall = [] | |
for tall in range(00000,99999+1): | |
sjekk = f'{tall:05}' | |
if sjekk == ''.join(list(reversed(sjekk))): | |
palindromer.append(tall) | |
if all(int(sjekk) % i for i in range(2, int(sjekk))): | |
palindromprimtall.append(tall) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
palindromer = [] | |
for tall in range(00000,99999+1): | |
sjekk = f'{tall:05}' | |
if sjekk == ''.join(list(reversed(sjekk))): | |
palindromer.append(tall) | |
print(f'For et femsifret tall, er det {len(palindromer)} palindromer') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Det kan gjøres automatiske oppslag mot JPL for å hente oppdatert informasjon | |
om avstand til planeter på https://ssd-api.jpl.nasa.gov/doc/horizons.html | |
''' | |
# Noen definisjoner først, bruker dictionary | |
reisemål = {'Månen': 384400, 'Mars': 368240000, 'Jupiter':643522000, 'Saturn':1512051000} | |
romfartøy = {'Apollo':39900,'Dragon':28000,'Chang':39900} | |
# Nå skal det velges reisemål |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# coding: utf-8 | |
def main(): | |
# Get date from user | |
birthday = input('Enter birth date on the form DDMMYYYY: ') | |
print(f'You entered {birthday}, {len(birthday)} digits.\n') | |
num = len(birthday) | |
# Read in decimals of Pi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
LOGFILE='logfile' | |
TIMEFORMAT='%Y-%m-%d-%H%M' | |
URL='https://webkamera.atlas.vegvesen.no/kamera?id=' | |
# Declare the locations and their webcam id in an associated array (Thanks BASH 4) | |
declare -A PLACES | |
PLACES=( \ | |
[bleik]=1335902_1 \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from turtle import * | |
from random import * | |
def RandomPosition(): | |
penup() | |
posx = randint(-500, 500) | |
posy = randint(-200, 300) | |
setpos(posx, posy) | |
pendown() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Geometri, hva kan gjøres med bare firkanter? La oss bygge en by | |
from turtle import * | |
from random import * | |
HUS_FARGER = ["#363432", "#196774", "#90A19D", "#F0941F", "#BD2A2E", "#3B3936", "#889C9B", "#486966"] | |
VINDU_FARGER = ["#F2F2F2", "#202022"] | |
# Tegne firkant funksjon | |
def firkant(x, y, h, w, col): |