Skip to content

Instantly share code, notes, and snippets.

@i2x
Created July 19, 2023 03:25
Show Gist options
  • Save i2x/f5f1acb929f64dd24c0c56ae494d14e8 to your computer and use it in GitHub Desktop.
Save i2x/f5f1acb929f64dd24c0c56ae494d14e8 to your computer and use it in GitHub Desktop.
week3
import math
a = int(input("Enter the first number:\n"))
b = int(input("Enter the second number:\n"))
print(math.gcd(a, b))
import random
for seed_value in range(1, 11):
random.seed(seed_value)
random_number = random.randint(1, 100)
print(f"Seed: {seed_value}, Random Number: {random_number}")
import math
side1 = float(input())
side2 = float(input())
hypotenuse = math.hypot(side1,side2)
print(hypotenuse)
from math import radians, sin, cos, acos
print("Input coordinates of two points:")
slat = radians(float(input("Starting latitude: \n")))
slon = radians(float(input("Starting longitude: \n")))
elat = radians(float(input("Ending latitude: \n")))
elon = radians(float(input("Ending longitude: \n")))
dist = 6371.01 * acos(sin(slat)*sin(elat) + cos(slat)*cos(elat)*cos(elon - slon))
print("The distance is %.2fkm." % dist)
n = int(input())
for i in range(1,n+1):
if n % i == 0: print(i)
n = int(input())
a = int(input())
mn = mx = a
c = 0
if a < 0 : c = 1
for k in range(n-1):
a = int(input())
if a > mx : mx = a
if a < mn : mn = a
if a < 0 : c += 1
print( (mx - mn), c )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment