From 7b65bd19ed48d6c42710bf0f1cc27f2570385185 Mon Sep 17 00:00:00 2001 From: Subhendu_singh Date: Wed, 5 Oct 2022 12:20:50 +0530 Subject: [PATCH 1/6] hacktoberfest-fix --- project guess the number game/main.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 project guess the number game/main.py diff --git a/project guess the number game/main.py b/project guess the number game/main.py new file mode 100644 index 0000000..4bee4d4 --- /dev/null +++ b/project guess the number game/main.py @@ -0,0 +1,11 @@ +#Guess the Number Game +import random +for i in range(0,3): + number = random.randint(1,10) + user = int(input("Guess the number ")) + if user == number: + print("Hurray!!") + print(f"you guessed the number right it's {number}") + break + if user != number: + print(f"Your guess is incorrect the number is {number}") \ No newline at end of file From 856cf1f82a8367d3bbeb131ba5d61fad9f4b45a4 Mon Sep 17 00:00:00 2001 From: Ujjwal Kumar Date: Wed, 5 Oct 2022 13:22:11 +0530 Subject: [PATCH 2/6] img2pdf --- README.md | 1 + image to pdf converter/main.py | 15 +++++++++++++++ image to pdf converter/requirements.txt | 1 + 3 files changed, 17 insertions(+) create mode 100644 image to pdf converter/main.py create mode 100644 image to pdf converter/requirements.txt diff --git a/README.md b/README.md index 74422a9..31f1941 100644 --- a/README.md +++ b/README.md @@ -31,3 +31,4 @@ Reference Links:- - Project 3 - Quiz - Project 4 - Clock - Project 5 - QR Code +- Project 6 - Image to PDF Converter \ No newline at end of file diff --git a/image to pdf converter/main.py b/image to pdf converter/main.py new file mode 100644 index 0000000..db1b3d1 --- /dev/null +++ b/image to pdf converter/main.py @@ -0,0 +1,15 @@ +from PIL import Image + +def img2pdf(img_path, pdf_path): + images = [] + + for file in img_path: + img = Image.open(file) + img = img.convert('RGB') + images.append(img) + + images[0].save(pdf_path, save_all=True, append_images=images[1:]) + + print('Done') + +# img2pdf(['1.jpg', '2.jpg', '3.jpg'], 'test.pdf') diff --git a/image to pdf converter/requirements.txt b/image to pdf converter/requirements.txt new file mode 100644 index 0000000..1e8732e --- /dev/null +++ b/image to pdf converter/requirements.txt @@ -0,0 +1 @@ +Pillow==9.2.0 \ No newline at end of file From caea0599a68e91a844ddca51d4381bfa722f9958 Mon Sep 17 00:00:00 2001 From: Ujjwal Kumar Date: Wed, 5 Oct 2022 13:24:04 +0530 Subject: [PATCH 3/6] img2pdf --- .../main.py | 0 .../requirements.txt | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {image to pdf converter => project image to pdf converter}/main.py (100%) rename {image to pdf converter => project image to pdf converter}/requirements.txt (100%) diff --git a/image to pdf converter/main.py b/project image to pdf converter/main.py similarity index 100% rename from image to pdf converter/main.py rename to project image to pdf converter/main.py diff --git a/image to pdf converter/requirements.txt b/project image to pdf converter/requirements.txt similarity index 100% rename from image to pdf converter/requirements.txt rename to project image to pdf converter/requirements.txt From 0c699f656bacae83d72cb0378972d6aa91ed767a Mon Sep 17 00:00:00 2001 From: CuriousCoder321 <66026995+CuriousCoder321@users.noreply.github.com> Date: Wed, 5 Oct 2022 18:15:09 +0530 Subject: [PATCH 4/6] Create binary.py The binary search algorithm is a very important one, and requires you to create a list of numbers between 0 and an upper limit, with every succeeding number having a difference of 2 between them. When the user inputs a random number to be searched the program begins its search by dividing the list into two halves. First, the first half is searched for the required number and if found, the other half is rejected and vice versa. The search continues until the number is found or the subarray size becomes zero. --- project binary/binary.py | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 project binary/binary.py diff --git a/project binary/binary.py b/project binary/binary.py new file mode 100644 index 0000000..4c6ee7b --- /dev/null +++ b/project binary/binary.py @@ -0,0 +1,43 @@ +# Recursive Binary Search algorithm in Python + +def binarySearch(array, x, low, high): + +if high >= low: + +mid = low + (high - low)//2 + +# If found at mid, return the value + +if array[mid] == x: + +return mid + +# Search the first half + +elif array[mid] > x: + +return binarySearch(array, x, low, mid-1) + +# Search the second half + +else: + +return binarySearch(array, x, mid + 1, high) + +else: + +return -1 + +array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + +x = int(input("Enter a number between 1 and 10:")) + +result = binarySearch(array, x, 0, len(array)-1) + +if result != -1: + +print("Element is present at position" + str(result)) + +else: + +print("Element not found") From d7103f9328142beeee02555faccb6f4a649e3170 Mon Sep 17 00:00:00 2001 From: SaloniSahay <86877846+SaloniSahay@users.noreply.github.com> Date: Wed, 5 Oct 2022 20:39:50 +0530 Subject: [PATCH 5/6] Add some programs --- README.md | 6 ++++++ binary_to_decimal/binary-decimal.py | 12 ++++++++++++ display_calender/display_calender.py | 10 ++++++++++ perfect_number/perfect_number.py | 10 ++++++++++ pronic_number/pronic_number.py | 17 +++++++++++++++++ reverse_number/reverse_number.py | 10 ++++++++++ 6 files changed, 65 insertions(+) create mode 100644 binary_to_decimal/binary-decimal.py create mode 100644 display_calender/display_calender.py create mode 100644 perfect_number/perfect_number.py create mode 100644 pronic_number/pronic_number.py create mode 100644 reverse_number/reverse_number.py diff --git a/README.md b/README.md index 74422a9..f8f4e86 100644 --- a/README.md +++ b/README.md @@ -31,3 +31,9 @@ Reference Links:- - Project 3 - Quiz - Project 4 - Clock - Project 5 - QR Code +- Project 6 - Pronic Number +- Project 7 - Reverse a Number +- Project 8 - Perfect Number +- Project 9 - Display Calender +- Project 10 - Binary to Decimal Converter +- Project 11 - BMI Calculator diff --git a/binary_to_decimal/binary-decimal.py b/binary_to_decimal/binary-decimal.py new file mode 100644 index 0000000..03ade00 --- /dev/null +++ b/binary_to_decimal/binary-decimal.py @@ -0,0 +1,12 @@ +print("Enter the Binary Number: ") +bnum = int(input()) + +dnum = 0 +i = 1 +while bnum!=0: + rem = bnum%10 + dnum = dnum + (rem*i) + i = i*2 + bnum = int(bnum/10) + +print("\nEquivalent Decimal Value = ", dnum) \ No newline at end of file diff --git a/display_calender/display_calender.py b/display_calender/display_calender.py new file mode 100644 index 0000000..2721fbf --- /dev/null +++ b/display_calender/display_calender.py @@ -0,0 +1,10 @@ +import calendar + +print("Enter Year: ") +yy = input() +print("\nEnter Month Number (1-12): ") +mm = input() + +y = int(yy) +m = int(mm) +print("\n", calendar.month(y, m)) \ No newline at end of file diff --git a/perfect_number/perfect_number.py b/perfect_number/perfect_number.py new file mode 100644 index 0000000..d07fd2e --- /dev/null +++ b/perfect_number/perfect_number.py @@ -0,0 +1,10 @@ +print("Enter the Number:") +num = int(input()) +sum = 0 +for i in range(1, num): + if num%i==0: + sum = sum+i +if num==sum: + print("It is a Perfect Number") +else: + print("It is not a Perfect Number") \ No newline at end of file diff --git a/pronic_number/pronic_number.py b/pronic_number/pronic_number.py new file mode 100644 index 0000000..0d48ab1 --- /dev/null +++ b/pronic_number/pronic_number.py @@ -0,0 +1,17 @@ +#isPronicNumber() will determine whether a given number is a pronic number or not +def isPronicNumber(num): + flag = False; + + for j in range(1, num+1): + #Checks for pronic number by multiplying consecutive numbers + if((j*(j+1)) == num): + flag = True; + break; + return flag; + +#Displays pronic numbers between 1 and 100 +print("Pronic numbers between 1 and 100: "); +for i in range(1, 101): + if(isPronicNumber(i)): + print(i), + print(" "), \ No newline at end of file diff --git a/reverse_number/reverse_number.py b/reverse_number/reverse_number.py new file mode 100644 index 0000000..21b719a --- /dev/null +++ b/reverse_number/reverse_number.py @@ -0,0 +1,10 @@ +print("Enter a Number: ") +num = int(input()) + +rev = 0 +while num!=0: + rem = num%10 + rev = rem + (rev*10) + num = int(num/10) + +print("\nReverse =", rev) \ No newline at end of file From 265d90a46771010b4e4dd2d18bb1a7a0ad762eeb Mon Sep 17 00:00:00 2001 From: Aaisha Perveen <112773769+aaisha26@users.noreply.github.com> Date: Wed, 5 Oct 2022 21:23:03 +0530 Subject: [PATCH 6/6] added age project --- project_age_calculate/calculate.py | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 project_age_calculate/calculate.py diff --git a/project_age_calculate/calculate.py b/project_age_calculate/calculate.py new file mode 100644 index 0000000..ea29886 --- /dev/null +++ b/project_age_calculate/calculate.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +import time +from calendar import isleap + +# judge the leap year +def judge_leap_year(year): + if isleap(year): + return True + else: + return False + + +# returns the number of days in each month +def month_days(month, leap_year): + if month in [1, 3, 5, 7, 8, 10, 12]: + return 31 + elif month in [4, 6, 9, 11]: + return 30 + elif month == 2 and leap_year: + return 29 + elif month == 2 and (not leap_year): + return 28 + + +name = input("input your name: ") +age = input("input your age: ") +localtime = time.localtime(time.time()) + +year = int(age) +month = year * 12 + localtime.tm_mon +day = 0 + +begin_year = int(localtime.tm_year) - year +end_year = begin_year + year + +# calculate the days +for y in range(begin_year, end_year): + if (judge_leap_year(y)): + day = day + 366 + else: + day = day + 365 + +leap_year = judge_leap_year(localtime.tm_year) +for m in range(1, localtime.tm_mon): + day = day + month_days(m, leap_year) + +day = day + localtime.tm_mday +print("%s's age is %d years or " % (name, year), end="") +print("%d months or %d days" % (month, day)) \ No newline at end of file