Skip to content

Commit 7c8f184

Browse files
Merge branch 'geekcomputers:master' into testing
2 parents 5744c00 + 7f2e0db commit 7c8f184

File tree

5 files changed

+107
-10
lines changed

5 files changed

+107
-10
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
numpy==1.25.2
22
opencv_python==4.8.0.76
3-
mediapipe==0.10.3
3+
mediapipe==0.10.5

PDF/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Pillow==10.0.0
1+
Pillow==10.0.1
22
fpdf==1.7.2

Sum of digits of a number.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
1-
q=0 # Initially we assigned 0 to "q", to use this variable for the summation purpose below.
2-
# The "q" value should be declared before using it(mandatory). And this value can be changed later.
1+
# Python code to calculate the sum of digits of a number, by taking number input from user.
32

4-
n=int(input("Enter Number: ")) # asking user for input
5-
while n>0: # Until "n" is greater than 0, execute the loop. This means that until all the digits of "n" got extracted.
3+
import sys
64

7-
r=n%10 # Here, we are extracting each digit from "n" starting from one's place to ten's and hundred's... so on.
5+
def get_integer():
6+
for i in range(3,0,-1): # executes the loop 3 times. Giving 3 chances to the user.
7+
num = input("enter a number:")
8+
if num.isnumeric(): # checks if entered input is an integer string or not.
9+
num = int(num) # converting integer string to integer. And returns it to where function is called.
10+
return num
11+
else:
12+
print("enter integer only")
13+
print(f'{i-1} chances are left' if (i-1)>1 else f'{i-1} chance is left') # prints if user entered wrong input and chances left.
14+
continue
15+
816

9-
q=q+r # Each extracted number is being added to "q".
17+
def addition(num):
18+
Sum=0
19+
if type(num) is type(None): # Checks if number type is none or not. If type is none program exits.
20+
print("Try again!")
21+
sys.exit()
22+
while num > 0: # Addition- adding the digits in the number.
23+
digit = int(num % 10)
24+
Sum += digit
25+
num /= 10
26+
return Sum # Returns sum to where the function is called.
1027

11-
n=n//10 # "n" value is being changed in every iteration. Dividing with 10 gives exact digits in that number, reducing one digit in every iteration from one's place.
1228

13-
print("Sum of digits is: "+str(q))
29+
30+
if __name__ == '__main__': # this is used to overcome the problems while importing this file.
31+
number = get_integer()
32+
Sum = addition(number)
33+
print(f'Sum of digits of {number} is {Sum}') # Prints the sum

bodymass.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
kilo = float (input("kilonuzu giriniz(örnek: 84.9): "))
2+
boy = float (input("Boyunuzu m cinsinden giriniz: "))
3+
4+
vki = (kilo / (boy**2))
5+
6+
if vki < 18.5:
7+
print(f"vucut kitle indeksiniz: {vki} zayıfsınız.")
8+
elif vki < 25:
9+
print (f"vucut kitle indeksiniz: {vki} normalsiniz.")
10+
elif vki < 30:
11+
print (f"vucut kitle indeksiniz: {vki} fazla kilolusunuz.")
12+
elif vki < 35:
13+
print (f"vucut kitle indeksiniz: {vki} 1. derece obezsiniz")
14+
elif vki < 40:
15+
print (f"vucut kitle indeksiniz: {vki} 2.derece obezsiniz.")
16+
elif vki >40:
17+
print (f"vucut kitle indeksiniz: {vki} 3.derece obezsiniz.")
18+
else:
19+
print("Yanlış değer girdiniz.")

power_of_n.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Assign values to author and version.
2+
__author__ = "Himanshu Gupta"
3+
__version__ = "1.0.0"
4+
__date__ = "2023-09-03"
5+
6+
def binaryExponentiation(x: float, n: int) -> float:
7+
"""
8+
Function to calculate x raised to the power n (i.e., x^n) where x is a float number and n is an integer and it will return float value
9+
10+
Example 1:
11+
12+
Input: x = 2.00000, n = 10
13+
Output: 1024.0
14+
Example 2:
15+
16+
Input: x = 2.10000, n = 3
17+
Output: 9.261000000000001
18+
19+
Example 3:
20+
21+
Input: x = 2.00000, n = -2
22+
Output: 0.25
23+
Explanation: 2^-2 = 1/(2^2) = 1/4 = 0.25
24+
"""
25+
26+
if n == 0:
27+
return 1
28+
29+
# Handle case where, n < 0.
30+
if n < 0:
31+
n = -1 * n
32+
x = 1.0 / x
33+
34+
# Perform Binary Exponentiation.
35+
result = 1
36+
while n != 0:
37+
# If 'n' is odd we multiply result with 'x' and reduce 'n' by '1'.
38+
if n % 2 == 1:
39+
result *= x
40+
n -= 1
41+
# We square 'x' and reduce 'n' by half, x^n => (x^2)^(n/2).
42+
x *= x
43+
n //= 2
44+
return result
45+
46+
47+
if __name__ == "__main__":
48+
print(f"Author: {__author__}")
49+
print(f"Version: {__version__}")
50+
print(f"Function Documentation: {binaryExponentiation.__doc__}")
51+
print(f"Date: {__date__}")
52+
53+
print() # Blank Line
54+
55+
print(binaryExponentiation(2.00000, 10))
56+
print(binaryExponentiation(2.10000, 3))
57+
print(binaryExponentiation(2.00000, -2))
58+

0 commit comments

Comments
 (0)