Created
July 19, 2023 03:25
-
-
Save i2x/f5f1acb929f64dd24c0c56ae494d14e8 to your computer and use it in GitHub Desktop.
week3
This file contains 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
import math | |
a = int(input("Enter the first number:\n")) | |
b = int(input("Enter the second number:\n")) | |
print(math.gcd(a, b)) |
This file contains 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
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}") |
This file contains 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
import math | |
side1 = float(input()) | |
side2 = float(input()) | |
hypotenuse = math.hypot(side1,side2) | |
print(hypotenuse) |
This file contains 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 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) |
This file contains 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
n = int(input()) | |
for i in range(1,n+1): | |
if n % i == 0: print(i) |
This file contains 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
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