From ef0943be40bfd99f06e9b259dab4b9be631d540c Mon Sep 17 00:00:00 2001 From: Bishal Kumar Ghosh <81809899+bISHAL-2001@users.noreply.github.com> Date: Wed, 26 May 2021 11:45:22 +0530 Subject: [PATCH 01/11] Create readme.md --- Bishal/readme.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Bishal/readme.md diff --git a/Bishal/readme.md b/Bishal/readme.md new file mode 100644 index 0000000..c26684b --- /dev/null +++ b/Bishal/readme.md @@ -0,0 +1,3 @@ +//Learning C++ and C and Java +#Learning Python + From 12a798a4f8c128ffb321d81ad8f5f7d55da14999 Mon Sep 17 00:00:00 2001 From: Bishal Kumar Ghosh <81809899+bISHAL-2001@users.noreply.github.com> Date: Wed, 26 May 2021 11:47:03 +0530 Subject: [PATCH 02/11] Day_1 --- Bishal/Day1Question1.py | 19 +++++++++++++++++++ Bishal/Day1Question2.py | 13 +++++++++++++ Bishal/Day1Question3.py | 33 +++++++++++++++++++++++++++++++++ Bishal/Day1Question4.py | 11 +++++++++++ Bishal/Day1Question5.py | 12 ++++++++++++ Bishal/Day1Question6.py | 15 +++++++++++++++ Bishal/Day1Question7.py | 28 ++++++++++++++++++++++++++++ Bishal/Day1Question8.py | 19 +++++++++++++++++++ Bishal/readme.md | 4 +--- 9 files changed, 151 insertions(+), 3 deletions(-) create mode 100644 Bishal/Day1Question1.py create mode 100644 Bishal/Day1Question2.py create mode 100644 Bishal/Day1Question3.py create mode 100644 Bishal/Day1Question4.py create mode 100644 Bishal/Day1Question5.py create mode 100644 Bishal/Day1Question6.py create mode 100644 Bishal/Day1Question7.py create mode 100644 Bishal/Day1Question8.py diff --git a/Bishal/Day1Question1.py b/Bishal/Day1Question1.py new file mode 100644 index 0000000..3df13f4 --- /dev/null +++ b/Bishal/Day1Question1.py @@ -0,0 +1,19 @@ +def names(name): + sta = """ + Hello {}! + Welcome to our world of new innovations. + """ + print(sta.format(name)) + + +def altnames(name): + st = f""" + Hello {name}! + Welcome to our new era! + """ + print(st) + + +n = input("What's your name?\n") +names(n) +altnames(n) diff --git a/Bishal/Day1Question2.py b/Bishal/Day1Question2.py new file mode 100644 index 0000000..442f254 --- /dev/null +++ b/Bishal/Day1Question2.py @@ -0,0 +1,13 @@ +def sortnames(name1, name2, name3): + x = [name1, name2,Dname3] + x.sort() + print("Your Names is sorted order: ") + for i in x: + print(i) + + +a = input("Input name1: ") +b = input("Input name2: ") +c = input("Input name3: ") +sortnames(a, b, c) + diff --git a/Bishal/Day1Question3.py b/Bishal/Day1Question3.py new file mode 100644 index 0000000..b95f6c0 --- /dev/null +++ b/Bishal/Day1Question3.py @@ -0,0 +1,33 @@ +def prime(a) -> bool: + c = 0 + for i in range(a + 1): + if a % (i + 1) == 0: + c += 1 + if c == 2: + return True + + +def palin(b) -> bool: + d = b + s = 0 + while b != 0: + div = b % 10 + s = s * 10 + div + b = b // 10 + if d == s: + return True + + +number = int(input("Enter a number: ")) +bo = prime(number) +boo = palin(number) +if bo and boo: + print("Prime Palindrome.") +elif bo: + print("Only Prime.") +elif boo: + print("Only Palindrome.") +else: + print("Neither Prime nor Palindrome.") + + diff --git a/Bishal/Day1Question4.py b/Bishal/Day1Question4.py new file mode 100644 index 0000000..bf6d627 --- /dev/null +++ b/Bishal/Day1Question4.py @@ -0,0 +1,11 @@ +def printing(): + c = """ + Hello World! + I am Bishal Kumar Ghosh. + I've just kick-started learning. + """ + print(c) + + +printing() + diff --git a/Bishal/Day1Question5.py b/Bishal/Day1Question5.py new file mode 100644 index 0000000..97091ac --- /dev/null +++ b/Bishal/Day1Question5.py @@ -0,0 +1,12 @@ +def flickingif(n): + if not(n > 0): + print(f"{n} is positive.") + elif not(n < 0): + print(f"{n} is negative.") + else: + print(f"{n} is Zero.") + + +no = int(input("Enter a number: ")) +flickingif(no) + diff --git a/Bishal/Day1Question6.py b/Bishal/Day1Question6.py new file mode 100644 index 0000000..23fcaf8 --- /dev/null +++ b/Bishal/Day1Question6.py @@ -0,0 +1,15 @@ +def summation(li): + s: int = 0 + for j in li: + s += j + return s + + +n = int(input("Enter for how many numbers you want to compute the sum: ")) +print(f"Enter {n} numbers to get the desired sum: ") +numbers = [] +for i in range(n): + numbers.append(int(input())) +sum1 = summation(numbers) +print(sum1) + diff --git a/Bishal/Day1Question7.py b/Bishal/Day1Question7.py new file mode 100644 index 0000000..7df3801 --- /dev/null +++ b/Bishal/Day1Question7.py @@ -0,0 +1,28 @@ +import math + +import matplotlib.pyplot as plt + + +def pl(li1): + plt.plot(li1) + plt.show() + + +def xcal(li2): + for i in range(len(li2)): + li2[i] = math.sqrt(li2[i]) + return li2 + + +def inp(): + n = int(input("Enter how many numbers you wanna enter: ")) + print(f"Now, enter {n} numbers: ") + li3 = [] + for i in range(n): + li3.append(int(input())) + return li3 + + +lx = inp() +m = xcal(lx) +pl(m) diff --git a/Bishal/Day1Question8.py b/Bishal/Day1Question8.py new file mode 100644 index 0000000..601bc08 --- /dev/null +++ b/Bishal/Day1Question8.py @@ -0,0 +1,19 @@ +def deladdnumb(): + n = int(input("Enter the number of numbers you wanna enter: ")) + li = [] + print(f"Enter {n} numbers:") + for i in range(n): + li.append(int(input())) + temp = [li[0]] + for i in range(1, n): + c = 0 + for j in range(i): + if li[i] == li[j]: + c += 1 + if c != 1: + temp.append(li[i]) + print(f"Before Deletion: {li}") + print(f"After Deletion: {temp}") + + +deladdnumb() diff --git a/Bishal/readme.md b/Bishal/readme.md index c26684b..76e1cb1 100644 --- a/Bishal/readme.md +++ b/Bishal/readme.md @@ -1,3 +1 @@ -//Learning C++ and C and Java -#Learning Python - +##Java and Python and C and C++ and Ruby From 92d0ea11fb4e06b232fa5df0c609b2212411e30a Mon Sep 17 00:00:00 2001 From: BISHAL KUMAR GHOSH Date: Wed, 26 May 2021 11:58:30 +0530 Subject: [PATCH 03/11] Starting with Classes --- .idea/.gitignore | 8 ++++++++ .idea/100DaysOfCode.iml | 8 ++++++++ .../inspectionProfiles/profiles_settings.xml | 6 ++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ Bishal/Day1Question9.py | 20 +++++++++++++++++++ 6 files changed, 56 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/100DaysOfCode.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 Bishal/Day1Question9.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/100DaysOfCode.iml b/.idea/100DaysOfCode.iml new file mode 100644 index 0000000..9b31378 --- /dev/null +++ b/.idea/100DaysOfCode.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..c11033a --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Bishal/Day1Question9.py b/Bishal/Day1Question9.py new file mode 100644 index 0000000..1720f81 --- /dev/null +++ b/Bishal/Day1Question9.py @@ -0,0 +1,20 @@ +class Student: + def __init__(self, age, height, weight, gender): + self.age = age + self.height = height + self.weight = weight + self.gender = gender + + @staticmethod + def intro(first, sur): + print(f"\n\nName: {first} {sur}") + + +b = input("Enter first name: ") +m = input("Enter surname: ") +specifications = Student(input("Enter Age(years): "), input("Enter Height(feet): "), input("Enter Weight(kgs): "), input("Enter Gender: ")) +specifications.intro(b, m) +print(f"Gender: {specifications.gender} ") +print(f"Age: {specifications.age} years") +print(f"Height: {specifications.height} feet") +print(f"Weight: {specifications.weight} kgs") From c09a91b55d3b92f7ba0658c7f1b41b9b0f8c7b05 Mon Sep 17 00:00:00 2001 From: BISHAL KUMAR GHOSH Date: Wed, 26 May 2021 12:01:10 +0530 Subject: [PATCH 04/11] Starting with Classes2 --- Bishal/Day1Question10.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Bishal/Day1Question10.py diff --git a/Bishal/Day1Question10.py b/Bishal/Day1Question10.py new file mode 100644 index 0000000..bbd2cf5 --- /dev/null +++ b/Bishal/Day1Question10.py @@ -0,0 +1,20 @@ +class Student: + def __init__(self, age, height, weight, gender): + self.age = age + self.height = height + self.weight = weight + self.gender = gender + + @staticmethod + def intro(first, sur): + print(f"\n\nName: {first} {sur}") + + def __str__(self) -> str: + return f"Gender: {self.gender}\nAge: {self.age} years\nHeight: {self.height} feet\nWeight: {self.weight} kgs" + + +b = input("Enter first name: ") +m = input("Enter surname: ") +student = Student(float(input("Enter you Age: ")), float(input("Enter you Height: ")), float(input("Enter you Weight: ")), input("Enter you Gender: ")) +Student.intro(b, m) +print(student) From b6c8dad312e00dff52c702548569da9c2920d800 Mon Sep 17 00:00:00 2001 From: BISHAL KUMAR GHOSH Date: Wed, 26 May 2021 12:10:55 +0530 Subject: [PATCH 05/11] Working with Dates and Times --- Bishal/Day1Question11.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Bishal/Day1Question11.py diff --git a/Bishal/Day1Question11.py b/Bishal/Day1Question11.py new file mode 100644 index 0000000..8d4046e --- /dev/null +++ b/Bishal/Day1Question11.py @@ -0,0 +1,5 @@ +import datetime +print(datetime.datetime.now().day) +print(datetime.datetime.now().month) +print(datetime.datetime.now().year) +print(datetime.datetime.now().time()) From e34894094c0b0c5b9002b1de4191dbabf2a60a3f Mon Sep 17 00:00:00 2001 From: BISHAL KUMAR GHOSH Date: Wed, 26 May 2021 12:12:13 +0530 Subject: [PATCH 06/11] Working with Dates and Times 2 --- Bishal/Day1Question12.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Bishal/Day1Question12.py diff --git a/Bishal/Day1Question12.py b/Bishal/Day1Question12.py new file mode 100644 index 0000000..c96d609 --- /dev/null +++ b/Bishal/Day1Question12.py @@ -0,0 +1,13 @@ +from datetime import datetime +from datetime import date + +print("Default Format:") +print(datetime.today()) +print("Changed Format:") +new = datetime.now() +print(new.strftime("Format 1:\n%d.%m.%Y\n%H:%M:%S\n")) +print(new.strftime("Format 2:\n%d %B/%y\n%H:%M:%S\n")) +print(new.strftime("Format 3:\n%d %b/%Y\n%H:%M:%S")) +print(new.strftime("Format 3:\n%m/%d/%Y\n%I:%M %p")) +print("Printing only dates:") +print(date.today().strftime("%d %B/%y")) From dacbc4fc709ed9ef2b55e1dc1cc820cdb54c7464 Mon Sep 17 00:00:00 2001 From: BISHAL KUMAR GHOSH Date: Sat, 29 May 2021 17:12:22 +0530 Subject: [PATCH 07/11] Working with timedelta objects --- Bishal/Day2Question1.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Bishal/Day2Question1.py diff --git a/Bishal/Day2Question1.py b/Bishal/Day2Question1.py new file mode 100644 index 0000000..cd06aac --- /dev/null +++ b/Bishal/Day2Question1.py @@ -0,0 +1,36 @@ +# Working with timedelta objects +from datetime import date +from datetime import datetime +from datetime import timedelta + +print(timedelta(days=60, hours=4, minutes=21, seconds=17)) + +# today's date +now = datetime.now() +print("Today is:\n" + str(now)) + +# after a year +print("After 1 year:\n" + str(now + timedelta(days=365))) + +# after 2 days 3 weeks +print("After 2 days and :\n" + str(now + timedelta(days=2, weeks=3))) + +# 1week ago +t = datetime.now() - timedelta(weeks=1) +s = t.strftime("%A %B %d, %Y") +print("A week ago: " + s) + +# How many days until Jan 01 +today = date.today() +nov = date(today.year, 11, 6) + +# If for this date has already occurred before today +if nov < today: + print("6th Nov has went by %d days ago" % (today - nov).days) + nov = nov.replace(year=today.year + 1) + +# Now calculating for the next year's 6th Nov +time_to_nov = nov - today +print("It's just", time_to_nov.days, "days until next 6th Nov.") + +# \ No newline at end of file From 055a55d9ef0f48f79fc46493f118b9f03c447f6d Mon Sep 17 00:00:00 2001 From: BISHAL KUMAR GHOSH Date: Sat, 29 May 2021 19:03:15 +0530 Subject: [PATCH 08/11] Working with Calenders --- Bishal/Day2Question2.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Bishal/Day2Question2.py diff --git a/Bishal/Day2Question2.py b/Bishal/Day2Question2.py new file mode 100644 index 0000000..b2f19a8 --- /dev/null +++ b/Bishal/Day2Question2.py @@ -0,0 +1,8 @@ +# Working with Calenders +import calendar + +# Plain text calender +c = calendar.TextCalendar(calendar.MONDAY) +st = c.formatmonth(2017, 1, 0, 0) +print(st) + From 15849bc59052c55868042f9ed81cb4cf12837032 Mon Sep 17 00:00:00 2001 From: BISHAL KUMAR GHOSH Date: Sat, 29 May 2021 19:30:15 +0530 Subject: [PATCH 09/11] Working with Files --- Bishal/Day2Question3.py | 16 ++++++++++++++++ Bishal/Day2Question4.py | 0 Bishal/Text.txt | 21 +++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 Bishal/Day2Question3.py create mode 100644 Bishal/Day2Question4.py create mode 100644 Bishal/Text.txt diff --git a/Bishal/Day2Question3.py b/Bishal/Day2Question3.py new file mode 100644 index 0000000..230919a --- /dev/null +++ b/Bishal/Day2Question3.py @@ -0,0 +1,16 @@ +# Opening a New File +file = open("Text.txt", "w+") +for i in range(10): + file.write(str(i+1) + ". Hello World! It's me.\nI'm here to learn something new.\n") +file.close() + +# Appending +f = open("Text.txt", "a") +f.write("Yo!") +f.close() + +# Opening the file back up and read the contents +f = open("Text.txt", "r") +if f.mode == 'r': + contents = f.read() + print(contents) diff --git a/Bishal/Day2Question4.py b/Bishal/Day2Question4.py new file mode 100644 index 0000000..e69de29 diff --git a/Bishal/Text.txt b/Bishal/Text.txt new file mode 100644 index 0000000..e4d9395 --- /dev/null +++ b/Bishal/Text.txt @@ -0,0 +1,21 @@ +1. Hello World! It's me. +I'm here to learn something new. +2. Hello World! It's me. +I'm here to learn something new. +3. Hello World! It's me. +I'm here to learn something new. +4. Hello World! It's me. +I'm here to learn something new. +5. Hello World! It's me. +I'm here to learn something new. +6. Hello World! It's me. +I'm here to learn something new. +7. Hello World! It's me. +I'm here to learn something new. +8. Hello World! It's me. +I'm here to learn something new. +9. Hello World! It's me. +I'm here to learn something new. +10. Hello World! It's me. +I'm here to learn something new. +Yo! \ No newline at end of file From 95d46433fab44c597092b0cbf0125f5afe79b7fa Mon Sep 17 00:00:00 2001 From: BISHAL KUMAR GHOSH Date: Sat, 29 May 2021 20:31:16 +0530 Subject: [PATCH 10/11] Working with Files2 --- Bishal/Day2Question4.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Bishal/Day2Question4.py b/Bishal/Day2Question4.py index e69de29..cb6944c 100644 --- a/Bishal/Day2Question4.py +++ b/Bishal/Day2Question4.py @@ -0,0 +1,29 @@ +# Working with os.path module +import os +from os import path +import datetime +import time + + +def main(): + # Printing the name of the oS + print(os.name) + print(os.path) + + +main() + +# Check for item existence and type +print("Item exists (Text.txt): "+str(path.exists("Text.txt"))) +print("Item is a file (Text.txt): "+str(path.isfile("Text.txt"))) +print("Item is a directory (Text.txt): "+str(path.isdir("Text.txt"))) +print("Item is a directory (My_File): "+str(path.isdir("My_File"))) + +# Work with file paths +print("Item path: " + str(path.realpath("Text.txt"))) +print("Item path and name: " + str(path.split(path.realpath("Text.txt")))) + +# Get the modification time +t = time.ctime(path.getmtime("Text.txt")) +print(t) +print(datetime.datetime.fromtimestamp(path.getctime("Text.txt"))) From 016a47ca2cc38dc77b3e29cee6bdb28d5b48069c Mon Sep 17 00:00:00 2001 From: Bishal Kumar Ghosh <81809899+bISHAL-2001@users.noreply.github.com> Date: Sat, 29 May 2021 20:35:08 +0530 Subject: [PATCH 11/11] Working with os.path module --- Bishal/Day2Question4.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Bishal/Day2Question4.py b/Bishal/Day2Question4.py index cb6944c..b0b66e4 100644 --- a/Bishal/Day2Question4.py +++ b/Bishal/Day2Question4.py @@ -27,3 +27,4 @@ def main(): t = time.ctime(path.getmtime("Text.txt")) print(t) print(datetime.datetime.fromtimestamp(path.getctime("Text.txt"))) +