diff --git a/6/6 b/6/6 new file mode 100644 index 00000000..1e8b3149 --- /dev/null +++ b/6/6 @@ -0,0 +1 @@ +6 diff --git a/6/task1.py b/6/task1.py new file mode 100644 index 00000000..819ab32d --- /dev/null +++ b/6/task1.py @@ -0,0 +1,8 @@ +def distance(x1, y1, x2, y2): + res = ((x1-x2)**2 + (y1-y2)**2)**0.5 + return res +x1 = float(input('Enter x1: ')) +y1 = float(input('Enter y1: ')) +x2 = float(input('Enter x2: ')) +y2 = float(input('Enter y2: ')) +print(distance(x1, y1, x2, y2)) diff --git a/6/task2.py b/6/task2.py new file mode 100644 index 00000000..369c7e92 --- /dev/null +++ b/6/task2.py @@ -0,0 +1,12 @@ +a = float(input('Enter number: ')) +n = int(input('Enter degree of number: ')) +def power(a,n): + if n < 0: + a = 1.0/a + n = -n + res = 1 + while n > 0: + res = res * a + n = n-1 + return res +print(power(a,n)) diff --git a/6/task3.py b/6/task3.py new file mode 100644 index 00000000..b1483bb6 --- /dev/null +++ b/6/task3.py @@ -0,0 +1,8 @@ +a = float(input('Enter number: ')) +n = int(input('Enter degree of number: ')) +def power(a, n): + if n == 0: + return 1 + else: + return a * power(a, n - 1) +print(power(a, n))