From a091f23cb6cfa8c566d3f8c2fc4f2aca2efb61cb Mon Sep 17 00:00:00 2001 From: SuhaniP Date: Sun, 20 Oct 2019 11:28:36 +0530 Subject: [PATCH 01/62] add fibonacci --- practice/python/python/fibonacci.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 practice/python/python/fibonacci.py diff --git a/practice/python/python/fibonacci.py b/practice/python/python/fibonacci.py new file mode 100644 index 0000000..c2b6b47 --- /dev/null +++ b/practice/python/python/fibonacci.py @@ -0,0 +1,17 @@ +# Function for nth Fibonacci number + +def Fibonacci(n): + if n<0: + print("Incorrect input") + # First Fibonacci number is 0 + elif n==1: + return 0 + # Second Fibonacci number is 1 + elif n==2: + return 1 + else: + return Fibonacci(n-1)+Fibonacci(n-2) + +# Driver Program + +print(Fibonacci(9)) From 7bb0f823b08b6abb4989a12356b55fac4fa72f48 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Tue, 14 Jul 2020 10:12:43 +0530 Subject: [PATCH 02/62] Write a function (leap year) --- leapyear.py | 10 ++++++++++ runnerup.py | 9 +++++++++ 2 files changed, 19 insertions(+) create mode 100644 leapyear.py create mode 100644 runnerup.py diff --git a/leapyear.py b/leapyear.py new file mode 100644 index 0000000..3af9034 --- /dev/null +++ b/leapyear.py @@ -0,0 +1,10 @@ +def is_leap(year): + if year%400==0: + return True + if year%100==0: + return False + if year%4==0: + return True + return False +year=int(input()) +print(is_leap(year)) diff --git a/runnerup.py b/runnerup.py new file mode 100644 index 0000000..cf54e40 --- /dev/null +++ b/runnerup.py @@ -0,0 +1,9 @@ +n=int(input()) +arr=map(int,input().split()) +arr=list(arr) +arr.sort(reverse=True) +for i in range(1,n): + if(arr[0]==arr[i]): + continue + print(arr[i]) + break From 4003cf146c165a52633f1328a6eebb8aa3298a33 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Tue, 14 Jul 2020 18:22:40 +0530 Subject: [PATCH 03/62] Nested List --- nestedlist.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 nestedlist.py diff --git a/nestedlist.py b/nestedlist.py new file mode 100644 index 0000000..18885cf --- /dev/null +++ b/nestedlist.py @@ -0,0 +1,24 @@ +def secondlow(students): + grades = [] + for student in students: + grades.append(student[1]) + sort_grades = sorted(grades) + seclow_grade = sort_grades[0] + for grade in sort_grades: + if grade != seclow_grade: + seclow_grade = grade + break + seclow_stud = [] + for student in students: + if student[1] == seclow_grade: + seclow_stud.append(student[0]) + for name in sorted(seclow_stud): + print(name) + + + +students = [] +for pupil in range(int(input())): + new_stud = [input(), float(input())] + students.append(new_stud) +secondlow(students) From b804cd93ac62c85a74f3a2434ea2b9e5c1843bf6 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Tue, 14 Jul 2020 19:19:56 +0530 Subject: [PATCH 04/62] Find the Percentage --- percentage.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 percentage.py diff --git a/percentage.py b/percentage.py new file mode 100644 index 0000000..1e49786 --- /dev/null +++ b/percentage.py @@ -0,0 +1,12 @@ +n = int(input()) + student_marks = {} + for _ in range(n): + name, *line = input().split() + scores = list(map(float, line)) + student_marks[name] = scores + query_name = input() + l = list(student_marks[query_name]) + no = len(l) + s = sum(l) + ss = s/no + print("%.2f" % ss) From f19ba5af687abf33c866f3984ba7d8392d76f836 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Wed, 15 Jul 2020 17:28:48 +0530 Subject: [PATCH 05/62] Create README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..3ca790d --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# pythonbeginner +This repository contains programs implemented in python. Questions have been solved by HackerRank Practice. From ae832b1309e2d8f02c1f7b6320ce195ef6fa4610 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Thu, 16 Jul 2020 12:14:52 +0530 Subject: [PATCH 06/62] Lists --- lists.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lists.py diff --git a/lists.py b/lists.py new file mode 100644 index 0000000..6ee17a8 --- /dev/null +++ b/lists.py @@ -0,0 +1,23 @@ +n=int(input()) +list=[] +for i in range(n): + s=input().split() + len_s=len(s) + for i in range(1,len_s): + s[i]=int(s[i]) + if s[0]=="append": + list.append(s[1]) + elif s[0]=="remove": + list.remove(s[1]) + elif s[0]=="insert": + list.insert(s[1],s[2]) + elif s[0]=="pop": + list.pop() + elif s[0]=="count": + print(list.count(s[1])) + elif s[0]=="sort": + list.sort() + elif s[0]=="reverse": + list.reverse() + elif s[0]=="print": + print(list) From c7e953227b3f22f14abc3abf7eea198db9524af7 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Thu, 16 Jul 2020 12:30:33 +0530 Subject: [PATCH 07/62] Tuples --- tuples.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 tuples.py diff --git a/tuples.py b/tuples.py new file mode 100644 index 0000000..0a540f1 --- /dev/null +++ b/tuples.py @@ -0,0 +1,5 @@ +n=int(input()) +integer_list=map(int,input().split()) +t=tuple(integer_list) +x=hash(t) +print(x) From 4932852f1d98e0334462bde6fb8e057e580fad73 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Fri, 17 Jul 2020 21:13:02 +0530 Subject: [PATCH 08/62] sWAP cASE --- string.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 string.py diff --git a/string.py b/string.py new file mode 100644 index 0000000..4f4f678 --- /dev/null +++ b/string.py @@ -0,0 +1,5 @@ +def swap_case(string): + return string.swapcase() +string=input() +result=swap_case(string) +print(result) From 69a026fa7dc5df2238885e3068a80b6f8a8f5a0e Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Thu, 23 Jul 2020 14:05:11 +0530 Subject: [PATCH 09/62] String split and Join --- splitandjoin.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 splitandjoin.py diff --git a/splitandjoin.py b/splitandjoin.py new file mode 100644 index 0000000..3f2c1ed --- /dev/null +++ b/splitandjoin.py @@ -0,0 +1,7 @@ +def split_and_join(line): + x=line.split() + return "-".join(x) + +line = input() +result = split_and_join(line) +print(result) From fdd2c49fb5e96436152c5da9bf0537a13e90bb2e Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Thu, 23 Jul 2020 23:04:48 +0530 Subject: [PATCH 10/62] Mutations --- mutations.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 mutations.py diff --git a/mutations.py b/mutations.py new file mode 100644 index 0000000..2026cb8 --- /dev/null +++ b/mutations.py @@ -0,0 +1,9 @@ +def mutate_string(s, i, c): + l=list(s) + l[i]=c + return ''.join(l) + +s = input() +i, c = input().split() +s_new = mutate_string(s, int(i), c) +print(s_new) \ No newline at end of file From 0fae640205bd792d821a7152aaf2b0bbda26cc43 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Fri, 24 Jul 2020 14:28:54 +0530 Subject: [PATCH 11/62] Find a string --- findstring.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 findstring.py diff --git a/findstring.py b/findstring.py new file mode 100644 index 0000000..70486ef --- /dev/null +++ b/findstring.py @@ -0,0 +1,15 @@ +def count_substring(string, sub_string): + count=0 + for i in range(0, len(string)): + if string[i:i + len(sub_string)] == sub_string: + count += 1 + + return(count) + + + +string = input().strip() +sub_string = input().strip() + +count = count_substring(string, sub_string) +print(count) \ No newline at end of file From 2d91f2a6bd92d431bc0582db2e6a2a37e60a5d50 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Fri, 24 Jul 2020 17:22:26 +0530 Subject: [PATCH 12/62] String Validators --- stringvalidators.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 stringvalidators.py diff --git a/stringvalidators.py b/stringvalidators.py new file mode 100644 index 0000000..ce60232 --- /dev/null +++ b/stringvalidators.py @@ -0,0 +1,10 @@ +s=input() + +print(any(char.isalnum() for char in s)) +print(any(char.isalpha() for char in s)) +print(any(char.isdigit() for char in s)) +print(any(char.islower() for char in s)) +print(any(char.isupper() for char in s)) + + + From 44d2fb624ac43b372909273bde091c8d5369294b Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Fri, 24 Jul 2020 18:04:50 +0530 Subject: [PATCH 13/62] Text Alignment --- textalign.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 textalign.py diff --git a/textalign.py b/textalign.py new file mode 100644 index 0000000..f99f37a --- /dev/null +++ b/textalign.py @@ -0,0 +1,22 @@ +thickness = int(input()) #This must be an odd number +c = 'H' + +#Top Cone +for i in range(thickness): + print((c*i).rjust(thickness-1)+c+(c*i).ljust(thickness-1)) + +#Top Pillars +for i in range(thickness+1): + print((c*thickness).center(thickness*2)+(c*thickness).center(thickness*6)) + +#Middle Belt +for i in range((thickness+1)//2): + print((c*thickness*5).center(thickness*6)) + +#Bottom Pillars +for i in range(thickness+1): + print((c*thickness).center(thickness*2)+(c*thickness).center(thickness*6)) + +#Bottom Cone +for i in range(thickness): + print(((c*(thickness-i-1)).rjust(thickness)+c+(c*(thickness-i-1)).ljust(thickness)).rjust(thickness*6)) \ No newline at end of file From 2cfab66494c0341b81ccb33c46e8c4dabd7fa3a8 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Fri, 24 Jul 2020 18:20:17 +0530 Subject: [PATCH 14/62] Text Wrap --- textwrap.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 textwrap.py diff --git a/textwrap.py b/textwrap.py new file mode 100644 index 0000000..e9c74b0 --- /dev/null +++ b/textwrap.py @@ -0,0 +1,9 @@ +import textwrap + +def wrap(string, max_width): + return textwrap.fill(string,max_width) + +if __name__ == '__main__': + string, max_width = input(), int(input()) + result = wrap(string, max_width) + print(result) \ No newline at end of file From 5c3c19b204535b273c7435d0cda8b083e9f00d3f Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Sat, 25 Jul 2020 20:16:58 +0530 Subject: [PATCH 15/62] Designer Door mat --- doormat.py | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 doormat.py diff --git a/doormat.py b/doormat.py new file mode 100644 index 0000000..1549e10 --- /dev/null +++ b/doormat.py @@ -0,0 +1,3 @@ +n, m = map(int,input().split()) +pattern = [('.|.'*(2*i + 1)).center(m, '-') for i in range(n//2)] +print('\n'.join(pattern + ['WELCOME'.center(m, '-')] + pattern[::-1])) \ No newline at end of file From b9f7d355197bc5c45fe6df90a0dc4c51b907e6e8 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Sat, 25 Jul 2020 20:19:43 +0530 Subject: [PATCH 16/62] Update doormat.py --- doormat.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/doormat.py b/doormat.py index 1549e10..33d5378 100644 --- a/doormat.py +++ b/doormat.py @@ -1,3 +1,19 @@ n, m = map(int,input().split()) pattern = [('.|.'*(2*i + 1)).center(m, '-') for i in range(n//2)] -print('\n'.join(pattern + ['WELCOME'.center(m, '-')] + pattern[::-1])) \ No newline at end of file +print('\n'.join(pattern + ['WELCOME'.center(m, '-')] + pattern[::-1])) + + + + +# Explanation : +#There are a couple things to notice. + +#The first is that each line has a set number of repetitions of '.|.', which are centered, and the rest is filled by '-'. + +#The second is that the flag is symmetrical, so if you have the top, you have the bottom by reversing it. +#You only need to work on n // 2 (n is odd and you need the integer div because the remaining line is the "WELCOME" line). + +#line 2: I generate 2\*i + 1 '.|.', center it, and fill the rest with '-'. That's basically the top part of the output. + +#line 3: put things together. '\n'.join() should be straightforward. Then, the sequence of strings to join is the pattern described above, the middle 'WELCOME' line, +#and the pattern reversed. From e75a77436b2366d1a46ab335c41afe98074f4fb2 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Sat, 25 Jul 2020 21:21:21 +0530 Subject: [PATCH 17/62] String Formatting --- stringformatting.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 stringformatting.py diff --git a/stringformatting.py b/stringformatting.py new file mode 100644 index 0000000..ed6adf4 --- /dev/null +++ b/stringformatting.py @@ -0,0 +1,12 @@ +def print_formatted(number): + w = len(str(bin(number)).replace('0b','')) + for i in range(1,number+1): + d = str(i).rjust(w,' ') + b = bin(i)[2:].rjust(w,' ') ## rjust is used for line alignment + o = oct(i)[2:].rjust(w, ' ') + h = hex(i)[2:].rjust(w, ' ').upper() + print(d, o, h, b) + +if __name__ == '__main__': + n = int(input()) + print_formatted(n) \ No newline at end of file From 326468d859585dc60f9263bf35204636bfb8d25c Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Wed, 29 Jul 2020 20:00:26 +0530 Subject: [PATCH 18/62] Class vs Instance(Day 04) from 30 Days of code --- classvsinstance.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 classvsinstance.py diff --git a/classvsinstance.py b/classvsinstance.py new file mode 100644 index 0000000..8acd5d3 --- /dev/null +++ b/classvsinstance.py @@ -0,0 +1,28 @@ + +class Person: + def __init__(self,initialAge): + if initialAge>=0: + self.age=initialAge + else: + self.age=0 + print("Age is not valid, setting age to 0.") + def checkOld(self): + if self.age<13: + print("You are young.") + elif 13<=self.age<18: + print("You are a teenager.") + else: + print("You are old.") + + def yearPasses(self): + self.age=self.age+1 + +t = int(input()) +for i in range(0, t): + age = int(input()) + x = Person(age) + x.checkOld() + for j in range(0, 3): + x.yearPasses() + x.checkOld() + print("") \ No newline at end of file From f1bf915fed78e2d8cb50b59eeb2914e609b57340 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Sat, 1 Aug 2020 23:34:41 +0530 Subject: [PATCH 19/62] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ca790d..8e564c0 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # pythonbeginner -This repository contains programs implemented in python. Questions have been solved by HackerRank Practice. +This repository contains programs implemented in python. Questions have been solved by HackerRank Practice- +- Contains solutions from HackerRank 30 days of code and Python. From 9a514bd77a635293d512e852a945394ea2dde2e4 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Mon, 10 Aug 2020 15:25:04 +0530 Subject: [PATCH 20/62] Capitalize! --- capitalize.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 capitalize.py diff --git a/capitalize.py b/capitalize.py new file mode 100644 index 0000000..a07701a --- /dev/null +++ b/capitalize.py @@ -0,0 +1,22 @@ +#!/bin/python3 + +import math +import os +import random +import re +import sys + +# Complete the solve function below. +def solve(s): + words = s.split(" ") + capitalized_words = [w.capitalize() for w in words] + print(" ".join(capitalized_words)) + + # return " ".join(capitalized_words) -------------> this would work for standard stdout + + + +s = input() +result = solve(s) + + \ No newline at end of file From 24cf61929175080d1b4e4e06bf6f67b5fcfa1cbf Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Mon, 10 Aug 2020 15:30:42 +0530 Subject: [PATCH 21/62] Lists --- lists.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lists.py b/lists.py index 6ee17a8..ba86ecc 100644 --- a/lists.py +++ b/lists.py @@ -20,4 +20,4 @@ elif s[0]=="reverse": list.reverse() elif s[0]=="print": - print(list) + print(list) \ No newline at end of file From 2ce673e4c8de89a0f28dc45f515cfc6463ee4db0 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Mon, 10 Aug 2020 15:32:29 +0530 Subject: [PATCH 22/62] Nested List --- nestedlist.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nestedlist.py b/nestedlist.py index 18885cf..9923655 100644 --- a/nestedlist.py +++ b/nestedlist.py @@ -1,6 +1,6 @@ def secondlow(students): grades = [] - for student in students: + for student in students: grades.append(student[1]) sort_grades = sorted(grades) seclow_grade = sort_grades[0] @@ -9,10 +9,10 @@ def secondlow(students): seclow_grade = grade break seclow_stud = [] - for student in students: + for student in students: if student[1] == seclow_grade: seclow_stud.append(student[0]) - for name in sorted(seclow_stud): + for name in sorted(seclow_stud): print(name) From 14150ead8d11fcc72e6cdc1e5f1cf4b862efe24f Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Mon, 10 Aug 2020 23:42:36 +0530 Subject: [PATCH 23/62] The Minion Game --- minion_game.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 minion_game.py diff --git a/minion_game.py b/minion_game.py new file mode 100644 index 0000000..e4e0c33 --- /dev/null +++ b/minion_game.py @@ -0,0 +1,19 @@ +def minion_game(s): + Stuart=0 + Kevin=0 + vowel='AEIOU' + for i in range(len(s)): + if s[i] in vowel: + Kevin+=len(s)-i + else: + Stuart+=len(s)-i + if Stuart>Kevin: + print("Stuart "+"%d" %Stuart) + elif Kevin>Stuart: + print("Kevin "+"%d" %Kevin) + else: + print("Draw") + + +s=input() +minion_game(s) \ No newline at end of file From 8f1ade5f2a9b20d7e8e615438bb87c53dfe611bf Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Mon, 10 Aug 2020 23:57:44 +0530 Subject: [PATCH 24/62] Merge The Tools! --- merge_the_tools.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 merge_the_tools.py diff --git a/merge_the_tools.py b/merge_the_tools.py new file mode 100644 index 0000000..5db1933 --- /dev/null +++ b/merge_the_tools.py @@ -0,0 +1,15 @@ +def merge_the_tools(string, k): + for i in range(0,len(string), k): + line = string[i:i+k] + seen = set() + for i in line: + if i not in seen: + print(i,end="") + seen.add(i) + #prints a new line + print() + + +if __name__ == '__main__': + string, k = input(), int(input()) + merge_the_tools(string, k) \ No newline at end of file From c86b81dd3a0e0704bf70ebec0f07e44bcb60ce2a Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Tue, 11 Aug 2020 23:58:25 +0530 Subject: [PATCH 25/62] Symmetric Difference from Python --- symmetric_difference.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 symmetric_difference.py diff --git a/symmetric_difference.py b/symmetric_difference.py new file mode 100644 index 0000000..ee013f2 --- /dev/null +++ b/symmetric_difference.py @@ -0,0 +1,7 @@ +a = int(input()) +M = set(list(map(int, input().split()))) +b= int(input()) +N= set(list(map(int,input().split()))) +s = sorted(list(M.difference(N))+list(N.difference(M))) +for i in s: + print (i) From 3802944ca1b15a39a16007353e837949e0a1b9ee Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Tue, 11 Aug 2020 23:58:54 +0530 Subject: [PATCH 26/62] Set .add() from Python --- set_add.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 set_add.py diff --git a/set_add.py b/set_add.py new file mode 100644 index 0000000..344e39a --- /dev/null +++ b/set_add.py @@ -0,0 +1,5 @@ +a=int(input()) +countries=set() +for i in range(a): + countries.add(input()) +print(len(countries)) \ No newline at end of file From eb0f2f416ba57a67c48fcfa1abf17b682d476ba1 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Thu, 13 Aug 2020 01:21:34 +0530 Subject: [PATCH 27/62] Merge the tools! from Python --- merge_the_tools.py | 1 - 1 file changed, 1 deletion(-) diff --git a/merge_the_tools.py b/merge_the_tools.py index 5db1933..497f35d 100644 --- a/merge_the_tools.py +++ b/merge_the_tools.py @@ -6,7 +6,6 @@ def merge_the_tools(string, k): if i not in seen: print(i,end="") seen.add(i) - #prints a new line print() From 97a03ca5805ba0cc8418bd468a38867d8d46665c Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Thu, 13 Aug 2020 01:23:00 +0530 Subject: [PATCH 28/62] Set .discard(), .pop(), .remove() from Python --- discard_remove_pop.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 discard_remove_pop.py diff --git a/discard_remove_pop.py b/discard_remove_pop.py new file mode 100644 index 0000000..8c02c53 --- /dev/null +++ b/discard_remove_pop.py @@ -0,0 +1,12 @@ +n = int(input()) +s = set(map(int, input().split())) +N = int(input()) +for i in range(N): + command=input().split() + if command[0]=="pop": + s.pop() + elif command[0]=="remove": + s.remove(int(command[1])) + elif command[0]=="discard": + s.discard(int(command[1])) +print(sum(s)) \ No newline at end of file From 0976cfda60422ed7b04a0f8f3420851bef0c7058 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Thu, 13 Aug 2020 01:23:56 +0530 Subject: [PATCH 29/62] Set .union() Operation from Python --- set_union.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 set_union.py diff --git a/set_union.py b/set_union.py new file mode 100644 index 0000000..092e8cb --- /dev/null +++ b/set_union.py @@ -0,0 +1,6 @@ +n=int(input()) +n_val=set(map(int,input().split())) +b=int(input()) +b_val=set(map(int,input().split())) +x=n_val.union(b_val) +print(len(x)) \ No newline at end of file From fb05e884b33107ee079fa71e6e537283519c0a76 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Thu, 13 Aug 2020 01:25:29 +0530 Subject: [PATCH 30/62] Introduction to sets from Python --- introduction_to_sets.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 introduction_to_sets.py diff --git a/introduction_to_sets.py b/introduction_to_sets.py new file mode 100644 index 0000000..c49471f --- /dev/null +++ b/introduction_to_sets.py @@ -0,0 +1,7 @@ +def average(array): + return sum(set(array))/len(set(array)) + +if __name__ == '__main__': + n = int(input()) + arr = list(map(int, input().split())) + average(arr) \ No newline at end of file From 4186c54b9dd37fff20e59e44cdbd457bed1050fe Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Thu, 13 Aug 2020 01:27:31 +0530 Subject: [PATCH 31/62] Alphabet Rangoli from Python --- alphabet_rangoli.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 alphabet_rangoli.py diff --git a/alphabet_rangoli.py b/alphabet_rangoli.py new file mode 100644 index 0000000..7af2d36 --- /dev/null +++ b/alphabet_rangoli.py @@ -0,0 +1,13 @@ +def print_rangoli(size): + + myStr = 'abcdefghijklmnopqrstuvwxyz'[0:size] + + for i in range(size-1, -size, -1): + x = abs(i) + if x >= 0: + line = myStr[size:x:-1]+myStr[x:size] + print ("--"*x+ '-'.join(line)+"--"*x) + + +size = int(input()) +print_rangoli(size) \ No newline at end of file From 90132baf3d98bf3d98e676c064fa006dad4826d9 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Thu, 13 Aug 2020 01:30:36 +0530 Subject: [PATCH 32/62] Rangoli from Python --- rangoli.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 rangoli.py diff --git a/rangoli.py b/rangoli.py new file mode 100644 index 0000000..dd95985 --- /dev/null +++ b/rangoli.py @@ -0,0 +1,9 @@ +import string +def print_rangoli(size): + width = 4 * size - 3 + alpha = string.ascii_lowercase + for i in list(range(size))[::-1] + list(range(1, size)): + print('-'.join(alpha[size-1:i:-1] + alpha[i:size]).center(width, '-')) + +size = int(input()) +print_rangoli(size) \ No newline at end of file From ec552483e78360f603207d206f86832a7d0fa4da Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Tue, 18 Aug 2020 23:05:22 +0530 Subject: [PATCH 33/62] Set .intersection() operation --- set_intersection.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 set_intersection.py diff --git a/set_intersection.py b/set_intersection.py new file mode 100644 index 0000000..36ed2cc --- /dev/null +++ b/set_intersection.py @@ -0,0 +1,9 @@ +n_eng=int(input()) +arr1=set(map(int,input().split())) +n_french=int(input()) +count=0 +arr2=set(map(int,input().split())) +intersection= arr1.intersection(arr2) +for i in intersection: + count+=1 +print(count) From 462c6f5fb692b13904d7948324c3cf7db5d58b6e Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Tue, 18 Aug 2020 23:08:35 +0530 Subject: [PATCH 34/62] Set .intersection() operation from Python --- set_intersection.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/set_intersection.py b/set_intersection.py index 36ed2cc..2d301d1 100644 --- a/set_intersection.py +++ b/set_intersection.py @@ -3,7 +3,9 @@ n_french=int(input()) count=0 arr2=set(map(int,input().split())) + intersection= arr1.intersection(arr2) for i in intersection: count+=1 + print(count) From 6827c0790cfb492cf5560d6e54b2f15d42073a7b Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Tue, 18 Aug 2020 23:15:51 +0530 Subject: [PATCH 35/62] Set .difference() Operation from python --- set_difference.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 set_difference.py diff --git a/set_difference.py b/set_difference.py new file mode 100644 index 0000000..8448529 --- /dev/null +++ b/set_difference.py @@ -0,0 +1,11 @@ +n_eng=int(input()) +arr1=set(map(int,input().split())) +n_french=int(input()) +count=0 +arr2=set(map(int,input().split())) + +intersection= arr1.difference(arr2) +for i in intersection: + count+=1 + +print(count) From 902930a3372c840896a18a46a991ee1fcb298e67 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Tue, 18 Aug 2020 23:21:15 +0530 Subject: [PATCH 36/62] Set .symmetric_difference() Operation from python --- set_symmetric_difference.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 set_symmetric_difference.py diff --git a/set_symmetric_difference.py b/set_symmetric_difference.py new file mode 100644 index 0000000..97fbf71 --- /dev/null +++ b/set_symmetric_difference.py @@ -0,0 +1,11 @@ +n_eng=int(input()) +arr1=set(map(int,input().split())) +n_french=int(input()) +count=0 +arr2=set(map(int,input().split())) + +intersection= arr1.symmetric_difference(arr2) +for i in intersection: + count+=1 + +print(count) From a89e154bb4080c0e006849b0004f9f4ef6ab73c6 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Tue, 18 Aug 2020 23:37:20 +0530 Subject: [PATCH 37/62] Set Mutations from Python --- set_mutations.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 set_mutations.py diff --git a/set_mutations.py b/set_mutations.py new file mode 100644 index 0000000..786930c --- /dev/null +++ b/set_mutations.py @@ -0,0 +1,14 @@ +n = int(input()) +s = set(map(int, input().split())) +N = int(input()) +for i in range(N): + command=input().split() + if command[0]=="intersection_update": + s.intersection_update(list(map(int,input().split()))) + elif command[0]=="update": + s.update(list(map(int,input().split()))) + elif command[0]=="symmetric_difference_update": + s.symmetric_difference_update(list(map(int,input().split()))) + elif command[0]=="difference_update": + s.difference_update(list(map(int,input().split()))) +print(sum(s)) \ No newline at end of file From f94dee88eaade6703612f3058fe8ca4ce6213d48 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Thu, 20 Aug 2020 23:26:17 +0530 Subject: [PATCH 38/62] The Captain's Room from Python --- captains_room.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 captains_room.py diff --git a/captains_room.py b/captains_room.py new file mode 100644 index 0000000..8f9f100 --- /dev/null +++ b/captains_room.py @@ -0,0 +1,10 @@ +k=int(input()) +rooms = input().split() +single=set() +multiple=set() +for room in rooms: + if room not in single: + single.add(room) + else: + multiple.add(room) +print(single.difference(multiple).pop()) \ No newline at end of file From 4efc3e0083984d6fa8f9cf31dc552f4251ab9909 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Thu, 20 Aug 2020 23:58:29 +0530 Subject: [PATCH 39/62] Check Subset from Python --- check_subset.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 check_subset.py diff --git a/check_subset.py b/check_subset.py new file mode 100644 index 0000000..103dcc2 --- /dev/null +++ b/check_subset.py @@ -0,0 +1,7 @@ +T=int(input()) +for cases in range(T): + elem_A=int(input()) + set_A=set(map(int,input().split())) + elem_B=int(input()) + set_B=set(map(int,input().split())) + print(set_A.issubset(set_B)) \ No newline at end of file From eec562e65d56a491c6d3dcf96e3ff42f5a9693c0 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Fri, 21 Aug 2020 12:58:27 +0530 Subject: [PATCH 40/62] Check strict Superset from Python --- check_strict_superset.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 check_strict_superset.py diff --git a/check_strict_superset.py b/check_strict_superset.py new file mode 100644 index 0000000..71402e8 --- /dev/null +++ b/check_strict_superset.py @@ -0,0 +1,11 @@ +set_A=set(map(int,input().split())) +num_other_sets=int(input()) +set_list=[] +for i in range(num_other_sets): + set_other=set(map(int,input().split())) + set_list.append(set_other) +result=True +for i in set_list: + if not set_A.issuperset(i): + result= False +print(result) \ No newline at end of file From 661537f764a121d7fae50d211af9977184111fe5 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Thu, 27 Aug 2020 03:20:24 +0530 Subject: [PATCH 41/62] No idea! from Python --- no_idea.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 no_idea.py diff --git a/no_idea.py b/no_idea.py new file mode 100644 index 0000000..0463a8e --- /dev/null +++ b/no_idea.py @@ -0,0 +1,5 @@ +n, m= input().split() +arr=input().split() +A=set(input().split()) +B=set(input().split()) +print(sum([(i in A) - (i in B) for i in arr])) \ No newline at end of file From c156702d598b9626d4eacbfd7138a82c92317301 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Mon, 14 Sep 2020 22:55:05 +0530 Subject: [PATCH 42/62] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8e564c0..715784d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ # pythonbeginner This repository contains programs implemented in python. Questions have been solved by HackerRank Practice- -- Contains solutions from HackerRank 30 days of code and Python. +- Contains solutions from +# HackerRank 30 days of code and Python. From a22ca8253c43b7dfceb805961ce40059c296511b Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Mon, 14 Sep 2020 23:00:28 +0530 Subject: [PATCH 43/62] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 715784d..4ec5e69 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ # pythonbeginner This repository contains programs implemented in python. Questions have been solved by HackerRank Practice- - Contains solutions from -# HackerRank 30 days of code and Python. +##### HackerRank 30 days of code and Python. From 4dea947f5d19f9ee07829334995f4ad6963b5d93 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Wed, 16 Sep 2020 00:33:23 +0530 Subject: [PATCH 44/62] Polar Coordinates from python --- polar_coordinates.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 polar_coordinates.py diff --git a/polar_coordinates.py b/polar_coordinates.py new file mode 100644 index 0000000..d35e3f8 --- /dev/null +++ b/polar_coordinates.py @@ -0,0 +1,6 @@ +import cmath +z=complex(input()) +a=abs(complex(z)) +b=cmath.phase(z) +print("%.3f"%a) +print("%.3f"%b) From 8b3fcf5a4cf451df2b1d9f4bbfd711710d2d83f1 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Wed, 16 Sep 2020 01:20:03 +0530 Subject: [PATCH 45/62] Mod Divmod from Python --- divmod.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 divmod.py diff --git a/divmod.py b/divmod.py new file mode 100644 index 0000000..a0363ee --- /dev/null +++ b/divmod.py @@ -0,0 +1,5 @@ +a=int(input()) +b=int(input()) +print(int(a/b)) +print(a%b) +print(divmod(a,b)) \ No newline at end of file From 399b659ee4f22520ae4addd6fd70ced3790a27e0 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Wed, 16 Sep 2020 01:25:16 +0530 Subject: [PATCH 46/62] Power- Mod Power from Python --- power_mod_power.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 power_mod_power.py diff --git a/power_mod_power.py b/power_mod_power.py new file mode 100644 index 0000000..09aae4e --- /dev/null +++ b/power_mod_power.py @@ -0,0 +1,5 @@ +a=int(input()) +b=int(input()) +m=int(input()) +print(pow(a,b)) +print(pow(a,b,m)) \ No newline at end of file From 1ab37459ad54869bb868a06551823153bee67cd6 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Wed, 16 Sep 2020 01:47:31 +0530 Subject: [PATCH 47/62] Integers Come In All Sizes --- integers_come_in_all_sizes.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 integers_come_in_all_sizes.py diff --git a/integers_come_in_all_sizes.py b/integers_come_in_all_sizes.py new file mode 100644 index 0000000..7e58076 --- /dev/null +++ b/integers_come_in_all_sizes.py @@ -0,0 +1,6 @@ +a=int(input()) +b=int(input()) +c=int(input()) +d=int(input()) + +print(pow(a,b)+pow(c,d)) \ No newline at end of file From 7c18250598b97193e3340035aa86f8015c952521 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Thu, 17 Sep 2020 22:53:06 +0530 Subject: [PATCH 48/62] Find Angle MBC from Python --- find_angle.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 find_angle.py diff --git a/find_angle.py b/find_angle.py new file mode 100644 index 0000000..d73fc6d --- /dev/null +++ b/find_angle.py @@ -0,0 +1,7 @@ +import math +AB=int(input()) +BC=int(input()) +hype=math.hypot(AB,BC) #to calculate hypotenuse +res=round(math.degrees(math.acos(BC/hype))) #to calculate required angle +degree=chr(176) #for DEGREE symbol +print(res,degree, sep='') \ No newline at end of file From c88b6d18ae775532c5804a7be25697f1597d1194 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Fri, 18 Sep 2020 23:26:17 +0530 Subject: [PATCH 49/62] Triangle Quest 2 from Python --- triangle_quest2.py | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 triangle_quest2.py diff --git a/triangle_quest2.py b/triangle_quest2.py new file mode 100644 index 0000000..f4746ee --- /dev/null +++ b/triangle_quest2.py @@ -0,0 +1,2 @@ +for i in range(1,int(input())+1): + print (int((10**i)/9)**2) \ No newline at end of file From 9b9aad7ca6ec054ddc3611038770a23085b1ed57 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Fri, 18 Sep 2020 23:38:28 +0530 Subject: [PATCH 50/62] Triangle Quest from Python --- triangle_quest.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 triangle_quest.py diff --git a/triangle_quest.py b/triangle_quest.py new file mode 100644 index 0000000..8d542ae --- /dev/null +++ b/triangle_quest.py @@ -0,0 +1,4 @@ +for i in range(1,int(input())): + print (int(10**(i)//9)*i) + + From f947d34f90a5105f3855ee4e199e274b2a25c56b Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Sat, 19 Sep 2020 18:05:54 +0530 Subject: [PATCH 51/62] itertools.product() --- itertools_product.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 itertools_product.py diff --git a/itertools_product.py b/itertools_product.py new file mode 100644 index 0000000..e696071 --- /dev/null +++ b/itertools_product.py @@ -0,0 +1,4 @@ +from itertools import product +a=list(map(int,input().split())) +b=list(map(int,input().split())) +print(*product(a,b)) From 984f808cb3576578f95c6c1afa5dbe312959c0ea Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Sun, 20 Sep 2020 22:58:12 +0530 Subject: [PATCH 52/62] itertoosl.permutations() from Python --- itertools_permutations.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 itertools_permutations.py diff --git a/itertools_permutations.py b/itertools_permutations.py new file mode 100644 index 0000000..bd6f721 --- /dev/null +++ b/itertools_permutations.py @@ -0,0 +1,7 @@ +from itertools import permutations +S, K= map(str,input().split()) +permutations = list(permutations(S, int(K))) +permutations.sort() + +for i in permutations: + print("".join(i)) \ No newline at end of file From 98f21dd3ddaedf9677540534bc9c392728857743 Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Mon, 21 Sep 2020 14:26:48 +0530 Subject: [PATCH 53/62] itertools.combinations() from Python --- itertools_combinations.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 itertools_combinations.py diff --git a/itertools_combinations.py b/itertools_combinations.py new file mode 100644 index 0000000..1632303 --- /dev/null +++ b/itertools_combinations.py @@ -0,0 +1,5 @@ +from itertools import combinations +S, K= map(str,input().split()) +for i in range(1, int(K)+1): + for j in combinations(sorted(S), i): + print ("".join(j)) \ No newline at end of file From 2a146ae62d85f35a942a8d64610be56501346820 Mon Sep 17 00:00:00 2001 From: Manjunatha Sai Uppu Date: Thu, 1 Oct 2020 16:04:07 +0530 Subject: [PATCH 54/62] added a folder of python questions and answers --- python for beginners/answers/1.py | 1 + python for beginners/answers/10.py | 2 + python for beginners/answers/11.py | 4 + python for beginners/answers/12.py | 4 + python for beginners/answers/13.py | 4 + python for beginners/answers/14.py | 5 + python for beginners/answers/15.py | 5 + python for beginners/answers/16.py | 9 ++ python for beginners/answers/17.py | 5 + python for beginners/answers/18.py | 5 + python for beginners/answers/19.py | 5 + python for beginners/answers/2.py | 2 + python for beginners/answers/20.py | 3 + python for beginners/answers/21.py | 5 + python for beginners/answers/22.py | 2 + python for beginners/answers/23.py | 6 + python for beginners/answers/24.py | 5 + python for beginners/answers/25.py | 6 + python for beginners/answers/26.py | 13 ++ python for beginners/answers/27.py | 10 ++ python for beginners/answers/28.py | 10 ++ python for beginners/answers/29.py | 4 + python for beginners/answers/3.py | 2 + python for beginners/answers/30.py | 3 + python for beginners/answers/31.py | 15 +++ python for beginners/answers/32.py | 15 +++ python for beginners/answers/33.py | 5 + python for beginners/answers/34.py | 5 + python for beginners/answers/35.py | 10 ++ python for beginners/answers/36.py | 7 + python for beginners/answers/37.py | 4 + python for beginners/answers/38.py | 2 + python for beginners/answers/39.py | 5 + python for beginners/answers/4.py | 8 ++ python for beginners/answers/40.py | 4 + python for beginners/answers/41.py | 3 + python for beginners/answers/42.py | 2 + python for beginners/answers/43.py | 5 + python for beginners/answers/44.py | 2 + python for beginners/answers/45.py | 2 + python for beginners/answers/46.py | 3 + python for beginners/answers/47.py | 2 + python for beginners/answers/48.py | 3 + python for beginners/answers/49.py | 5 + python for beginners/answers/5.py | 3 + python for beginners/answers/50.py | 3 + python for beginners/answers/6.py | 3 + python for beginners/answers/7.py | 2 + python for beginners/answers/8.py | 2 + python for beginners/answers/9.py | 2 + python for beginners/questions.txt | 207 +++++++++++++++++++++++++++++ 51 files changed, 449 insertions(+) create mode 100644 python for beginners/answers/1.py create mode 100644 python for beginners/answers/10.py create mode 100644 python for beginners/answers/11.py create mode 100644 python for beginners/answers/12.py create mode 100644 python for beginners/answers/13.py create mode 100644 python for beginners/answers/14.py create mode 100644 python for beginners/answers/15.py create mode 100644 python for beginners/answers/16.py create mode 100644 python for beginners/answers/17.py create mode 100644 python for beginners/answers/18.py create mode 100644 python for beginners/answers/19.py create mode 100644 python for beginners/answers/2.py create mode 100644 python for beginners/answers/20.py create mode 100644 python for beginners/answers/21.py create mode 100644 python for beginners/answers/22.py create mode 100644 python for beginners/answers/23.py create mode 100644 python for beginners/answers/24.py create mode 100644 python for beginners/answers/25.py create mode 100644 python for beginners/answers/26.py create mode 100644 python for beginners/answers/27.py create mode 100644 python for beginners/answers/28.py create mode 100644 python for beginners/answers/29.py create mode 100644 python for beginners/answers/3.py create mode 100644 python for beginners/answers/30.py create mode 100644 python for beginners/answers/31.py create mode 100644 python for beginners/answers/32.py create mode 100644 python for beginners/answers/33.py create mode 100644 python for beginners/answers/34.py create mode 100644 python for beginners/answers/35.py create mode 100644 python for beginners/answers/36.py create mode 100644 python for beginners/answers/37.py create mode 100644 python for beginners/answers/38.py create mode 100644 python for beginners/answers/39.py create mode 100644 python for beginners/answers/4.py create mode 100644 python for beginners/answers/40.py create mode 100644 python for beginners/answers/41.py create mode 100644 python for beginners/answers/42.py create mode 100644 python for beginners/answers/43.py create mode 100644 python for beginners/answers/44.py create mode 100644 python for beginners/answers/45.py create mode 100644 python for beginners/answers/46.py create mode 100644 python for beginners/answers/47.py create mode 100644 python for beginners/answers/48.py create mode 100644 python for beginners/answers/49.py create mode 100644 python for beginners/answers/5.py create mode 100644 python for beginners/answers/50.py create mode 100644 python for beginners/answers/6.py create mode 100644 python for beginners/answers/7.py create mode 100644 python for beginners/answers/8.py create mode 100644 python for beginners/answers/9.py create mode 100644 python for beginners/questions.txt diff --git a/python for beginners/answers/1.py b/python for beginners/answers/1.py new file mode 100644 index 0000000..7cf772c --- /dev/null +++ b/python for beginners/answers/1.py @@ -0,0 +1 @@ +print("Twinkle, twinkle, little star, \n\tHow I wonder what you are! \n\t\tUp above the world so high, \n\t\tLike a diamond in the sky. \nTwinkle, twinkle, little star, \n\tHow I wonder what you are") diff --git a/python for beginners/answers/10.py b/python for beginners/answers/10.py new file mode 100644 index 0000000..023ddcf --- /dev/null +++ b/python for beginners/answers/10.py @@ -0,0 +1,2 @@ +n = int(input()) +print(n + (11 *n) + (111 * n)) \ No newline at end of file diff --git a/python for beginners/answers/11.py b/python for beginners/answers/11.py new file mode 100644 index 0000000..3ee542f --- /dev/null +++ b/python for beginners/answers/11.py @@ -0,0 +1,4 @@ +def absolute(x): + return abs(x) + +print(absolute(float(input()))) \ No newline at end of file diff --git a/python for beginners/answers/12.py b/python for beginners/answers/12.py new file mode 100644 index 0000000..10d0b65 --- /dev/null +++ b/python for beginners/answers/12.py @@ -0,0 +1,4 @@ +import calendar +m = int(input()) +y = int(input()) +print(calendar.month(y,m)) diff --git a/python for beginners/answers/13.py b/python for beginners/answers/13.py new file mode 100644 index 0000000..0fbdc5a --- /dev/null +++ b/python for beginners/answers/13.py @@ -0,0 +1,4 @@ +print("""a string that you "don't" have to escape +This +is a ....... multi-line +heredoc string --------> example""") diff --git a/python for beginners/answers/14.py b/python for beginners/answers/14.py new file mode 100644 index 0000000..9c4180c --- /dev/null +++ b/python for beginners/answers/14.py @@ -0,0 +1,5 @@ +from datetime import date +x = date(2014, 7, 2) +y = date(2014, 7, 11) +delta = y-x +print(f'{delta.days} days') diff --git a/python for beginners/answers/15.py b/python for beginners/answers/15.py new file mode 100644 index 0000000..384bc74 --- /dev/null +++ b/python for beginners/answers/15.py @@ -0,0 +1,5 @@ +import math +def volume(r): + return math.pi * r ** 3 + +print(volume(float(input()))) \ No newline at end of file diff --git a/python for beginners/answers/16.py b/python for beginners/answers/16.py new file mode 100644 index 0000000..514f921 --- /dev/null +++ b/python for beginners/answers/16.py @@ -0,0 +1,9 @@ + +def mathprob(x): + if x>17: + return 2 * abs(17-x) + else: + return 17-x + + +print(mathprob(float(input()))) diff --git a/python for beginners/answers/17.py b/python for beginners/answers/17.py new file mode 100644 index 0000000..2e62cb9 --- /dev/null +++ b/python for beginners/answers/17.py @@ -0,0 +1,5 @@ +x = int(input()) +if abs(1000-x) < 100 or abs(2000-x) <100: + print(True) +else: + print(False) \ No newline at end of file diff --git a/python for beginners/answers/18.py b/python for beginners/answers/18.py new file mode 100644 index 0000000..27d066f --- /dev/null +++ b/python for beginners/answers/18.py @@ -0,0 +1,5 @@ +x,y,z = int(input()),int(input()),int(input()) +if x==y==z: + print(3 *(x+y+z)) +else: + print(x+y+z) \ No newline at end of file diff --git a/python for beginners/answers/19.py b/python for beginners/answers/19.py new file mode 100644 index 0000000..9a4df49 --- /dev/null +++ b/python for beginners/answers/19.py @@ -0,0 +1,5 @@ +s = input() +if "is" in s[0:2]: + print(s) +else: + print("is"+s) diff --git a/python for beginners/answers/2.py b/python for beginners/answers/2.py new file mode 100644 index 0000000..d6d94e1 --- /dev/null +++ b/python for beginners/answers/2.py @@ -0,0 +1,2 @@ +import platform +print(platform.python_version()) \ No newline at end of file diff --git a/python for beginners/answers/20.py b/python for beginners/answers/20.py new file mode 100644 index 0000000..c887b5c --- /dev/null +++ b/python for beginners/answers/20.py @@ -0,0 +1,3 @@ +s = input() +n = int(input()) +print(s*n) \ No newline at end of file diff --git a/python for beginners/answers/21.py b/python for beginners/answers/21.py new file mode 100644 index 0000000..2ef7834 --- /dev/null +++ b/python for beginners/answers/21.py @@ -0,0 +1,5 @@ +x = int(input()) +if x% 2 == 0: + print("EVEN") +else: + print("ODD") \ No newline at end of file diff --git a/python for beginners/answers/22.py b/python for beginners/answers/22.py new file mode 100644 index 0000000..a4db0f1 --- /dev/null +++ b/python for beginners/answers/22.py @@ -0,0 +1,2 @@ +li = [n * 4 for n in range(1,100,10)] +print(li.count(4)) \ No newline at end of file diff --git a/python for beginners/answers/23.py b/python for beginners/answers/23.py new file mode 100644 index 0000000..1a26bb2 --- /dev/null +++ b/python for beginners/answers/23.py @@ -0,0 +1,6 @@ +s = input() +n = int(input()) +if len(s) <=2: + print(s*n) +else: + print(s[0:2]*n) \ No newline at end of file diff --git a/python for beginners/answers/24.py b/python for beginners/answers/24.py new file mode 100644 index 0000000..419a80a --- /dev/null +++ b/python for beginners/answers/24.py @@ -0,0 +1,5 @@ +s = input() +if s in ['a','e','i','o','u']: + print("vowel") +else: + print("not a vowel") \ No newline at end of file diff --git a/python for beginners/answers/25.py b/python for beginners/answers/25.py new file mode 100644 index 0000000..3b7fb37 --- /dev/null +++ b/python for beginners/answers/25.py @@ -0,0 +1,6 @@ +li = [1,5,8,3] +x = int(input()) +if x in li: + print(True) +else: + print(False) \ No newline at end of file diff --git a/python for beginners/answers/26.py b/python for beginners/answers/26.py new file mode 100644 index 0000000..e43b0de --- /dev/null +++ b/python for beginners/answers/26.py @@ -0,0 +1,13 @@ +#Write a Python program to create a histogram from a given list of integers + +def histogram(items): + for n in items: + output = '' + times = n + while(times > 0): + output += '@' + times = times - 1 + print(output) + + +histogram([2, 3, 6, 5]) diff --git a/python for beginners/answers/27.py b/python for beginners/answers/27.py new file mode 100644 index 0000000..5903b02 --- /dev/null +++ b/python for beginners/answers/27.py @@ -0,0 +1,10 @@ +numbers = [ + 386, 462, 47, 418, 907, 344, 236, 375, 823, 566, 597, 978, 328, 615, 953, 345, + 399, 162, 758, 219, 918, 237, 412, 566, 826, 248, 866, 950, 626, 949, 687, 217, + 815, 67, 104, 58, 512, 24, 892, 894, 767, 553, 81, 379, 843, 831, 445, 742, 717, + 958, 743, 527 +] + +for i in range(len(numbers)): + numbers[i] = str(numbers[i]) +print("".join(numbers)) \ No newline at end of file diff --git a/python for beginners/answers/28.py b/python for beginners/answers/28.py new file mode 100644 index 0000000..6f10e7b --- /dev/null +++ b/python for beginners/answers/28.py @@ -0,0 +1,10 @@ +numbers = [ + 386, 462, 47, 418, 907, 344, 236, 375, 823, 566, 597, 978, 328, 615, 953, 345, + 399, 162, 758, 219, 918, 237, 412, 566, 826, 248, 866, 950, 626, 949, 687, 217, + 815, 67, 104, 58, 512, 24, 892, 894, 767, 553, 81, 379, 843, 831, 445, 742, 717, + 958, 743, 527 +] + +for i in range(len(numbers)): + if numbers[i] % 2 == 0: + print(numbers[i]) \ No newline at end of file diff --git a/python for beginners/answers/29.py b/python for beginners/answers/29.py new file mode 100644 index 0000000..2cb14d6 --- /dev/null +++ b/python for beginners/answers/29.py @@ -0,0 +1,4 @@ +color_list_1 = set(["White", "Black", "Red"]) +color_list_2 = set(["Red", "Green"]) + +print(set(sorted(color_list_1 - color_list_2))) \ No newline at end of file diff --git a/python for beginners/answers/3.py b/python for beginners/answers/3.py new file mode 100644 index 0000000..74006e1 --- /dev/null +++ b/python for beginners/answers/3.py @@ -0,0 +1,2 @@ +from datetime import datetime +print(datetime.now()) \ No newline at end of file diff --git a/python for beginners/answers/30.py b/python for beginners/answers/30.py new file mode 100644 index 0000000..8605b42 --- /dev/null +++ b/python for beginners/answers/30.py @@ -0,0 +1,3 @@ +base = int(input()) +height = int(input()) +print(0.5 * base * height) \ No newline at end of file diff --git a/python for beginners/answers/31.py b/python for beginners/answers/31.py new file mode 100644 index 0000000..3ab3a2f --- /dev/null +++ b/python for beginners/answers/31.py @@ -0,0 +1,15 @@ +def gcd(a, b): + if a == 0: + return b + return gcd(b % a, a) + +# Function to return LCM of two numbers + + +def lcm(a, b): + return (a*b) / gcd(a, b) + + +a = int(input()) +b = int(input()) +print(gcd(a,b)) \ No newline at end of file diff --git a/python for beginners/answers/32.py b/python for beginners/answers/32.py new file mode 100644 index 0000000..ef93116 --- /dev/null +++ b/python for beginners/answers/32.py @@ -0,0 +1,15 @@ +def gcd(a, b): + if a == 0: + return b + return gcd(b % a, a) + +# Function to return LCM of two numbers + + +def lcm(a, b): + return (a*b) / gcd(a, b) + + +a = int(input()) +b = int(input()) +print(lcm(a,b)) \ No newline at end of file diff --git a/python for beginners/answers/33.py b/python for beginners/answers/33.py new file mode 100644 index 0000000..de6388e --- /dev/null +++ b/python for beginners/answers/33.py @@ -0,0 +1,5 @@ +x,y,z = int(input()),int(input()),int(input()) +if x==y or y==z or x==z: + print(0) +else: + print(x+y+z) \ No newline at end of file diff --git a/python for beginners/answers/34.py b/python for beginners/answers/34.py new file mode 100644 index 0000000..bdd35c3 --- /dev/null +++ b/python for beginners/answers/34.py @@ -0,0 +1,5 @@ +a,b = int(input()),int(input()) +if 15<=(a+b)<=20: + print(20) +else: + print(a+b) \ No newline at end of file diff --git a/python for beginners/answers/35.py b/python for beginners/answers/35.py new file mode 100644 index 0000000..d9795b2 --- /dev/null +++ b/python for beginners/answers/35.py @@ -0,0 +1,10 @@ +def test_number5(x, y): + if x == y or abs(x-y) == 5 or (x+y) == 5: + return True + else: + return False + + +print(test_number5(7, 2)) +print(test_number5(3, 2)) +print(test_number5(2, 2)) diff --git a/python for beginners/answers/36.py b/python for beginners/answers/36.py new file mode 100644 index 0000000..b4f3cc3 --- /dev/null +++ b/python for beginners/answers/36.py @@ -0,0 +1,7 @@ +#Write a Python program to add two objects if both objects are an integer type. +x = input() +y = input() +if isinstance(x,int) and isinstance(y,int): + print(x+y) +else: + print("Error") diff --git a/python for beginners/answers/37.py b/python for beginners/answers/37.py new file mode 100644 index 0000000..1c64645 --- /dev/null +++ b/python for beginners/answers/37.py @@ -0,0 +1,4 @@ +name = input() +age = int(input()) +address = input() +print (f'name is {name} age is {age} address is {address}') \ No newline at end of file diff --git a/python for beginners/answers/38.py b/python for beginners/answers/38.py new file mode 100644 index 0000000..844fce1 --- /dev/null +++ b/python for beginners/answers/38.py @@ -0,0 +1,2 @@ +x,y = int(input()),int(input()) +print((x+y)*(x+y)) \ No newline at end of file diff --git a/python for beginners/answers/39.py b/python for beginners/answers/39.py new file mode 100644 index 0000000..61ee659 --- /dev/null +++ b/python for beginners/answers/39.py @@ -0,0 +1,5 @@ +def siminterest(p,r,t): + return p * ((1 + (r/100))**t) + + +print(siminterest(int(input()), float(input()), int(input()))) diff --git a/python for beginners/answers/4.py b/python for beginners/answers/4.py new file mode 100644 index 0000000..b7c887c --- /dev/null +++ b/python for beginners/answers/4.py @@ -0,0 +1,8 @@ +import math + + +def area(r): + return math.pi * r ** 2 + + +print(area(float(input()))) diff --git a/python for beginners/answers/40.py b/python for beginners/answers/40.py new file mode 100644 index 0000000..dcadd2a --- /dev/null +++ b/python for beginners/answers/40.py @@ -0,0 +1,4 @@ +import math +p1 = [4,0] +p2 = [6,6] +print(math.sqrt((p2[0] - p1[0])**2+(p2[1] - p1[1])**2)) \ No newline at end of file diff --git a/python for beginners/answers/41.py b/python for beginners/answers/41.py new file mode 100644 index 0000000..ec2322c --- /dev/null +++ b/python for beginners/answers/41.py @@ -0,0 +1,3 @@ +import os.path +open('abc.txt', 'w') +print(os.path.isfile('abc.txt')) diff --git a/python for beginners/answers/42.py b/python for beginners/answers/42.py new file mode 100644 index 0000000..6875ec5 --- /dev/null +++ b/python for beginners/answers/42.py @@ -0,0 +1,2 @@ +import struct +print(struct.calcsize("P") * 8) diff --git a/python for beginners/answers/43.py b/python for beginners/answers/43.py new file mode 100644 index 0000000..9d2a734 --- /dev/null +++ b/python for beginners/answers/43.py @@ -0,0 +1,5 @@ +#Write a Python program to get OS name, platform and release information +import os,platform +print(os.name) +print(platform.system()) +print(platform.release()) diff --git a/python for beginners/answers/44.py b/python for beginners/answers/44.py new file mode 100644 index 0000000..878e314 --- /dev/null +++ b/python for beginners/answers/44.py @@ -0,0 +1,2 @@ +import site +print(site.getsitepackages()) \ No newline at end of file diff --git a/python for beginners/answers/45.py b/python for beginners/answers/45.py new file mode 100644 index 0000000..75e88e0 --- /dev/null +++ b/python for beginners/answers/45.py @@ -0,0 +1,2 @@ +from subprocess import call +call(["ls", "-l"]) diff --git a/python for beginners/answers/46.py b/python for beginners/answers/46.py new file mode 100644 index 0000000..10a0f72 --- /dev/null +++ b/python for beginners/answers/46.py @@ -0,0 +1,3 @@ +#Write a python program to get the path and name of the file that is currently executing. +import os +print(os.path.realpath(__file__)) diff --git a/python for beginners/answers/47.py b/python for beginners/answers/47.py new file mode 100644 index 0000000..7b1e6f2 --- /dev/null +++ b/python for beginners/answers/47.py @@ -0,0 +1,2 @@ +import os +print(os.cpu_count()) \ No newline at end of file diff --git a/python for beginners/answers/48.py b/python for beginners/answers/48.py new file mode 100644 index 0000000..702df8d --- /dev/null +++ b/python for beginners/answers/48.py @@ -0,0 +1,3 @@ +n = "246.2458" +print(float(n)) +print(int(float(n))) diff --git a/python for beginners/answers/49.py b/python for beginners/answers/49.py new file mode 100644 index 0000000..f8d0d95 --- /dev/null +++ b/python for beginners/answers/49.py @@ -0,0 +1,5 @@ +from os import listdir +from os.path import isfile, join +files_list = [f for f in listdir( + 'D:\python\742020') if isfile(join('D:\python\742020', f))] +print(files_list) diff --git a/python for beginners/answers/5.py b/python for beginners/answers/5.py new file mode 100644 index 0000000..6ee082b --- /dev/null +++ b/python for beginners/answers/5.py @@ -0,0 +1,3 @@ +firstname = input() +lastname = input() +print(f'{lastname} {firstname}') \ No newline at end of file diff --git a/python for beginners/answers/50.py b/python for beginners/answers/50.py new file mode 100644 index 0000000..41c3d5c --- /dev/null +++ b/python for beginners/answers/50.py @@ -0,0 +1,3 @@ +#Write a Python program to print without newline or space? +for i in range(0,100): + print("*",end = " ") diff --git a/python for beginners/answers/6.py b/python for beginners/answers/6.py new file mode 100644 index 0000000..21c9a5c --- /dev/null +++ b/python for beginners/answers/6.py @@ -0,0 +1,3 @@ +x = input().split(",") +print(list(x)) +print(tuple(x)) \ No newline at end of file diff --git a/python for beginners/answers/7.py b/python for beginners/answers/7.py new file mode 100644 index 0000000..2fa7063 --- /dev/null +++ b/python for beginners/answers/7.py @@ -0,0 +1,2 @@ +s = input() +print(s[s.find('.')+1:]) \ No newline at end of file diff --git a/python for beginners/answers/8.py b/python for beginners/answers/8.py new file mode 100644 index 0000000..e55263c --- /dev/null +++ b/python for beginners/answers/8.py @@ -0,0 +1,2 @@ +colorlist = ['red','green','white','black'] +print(colorlist[0],colorlist[-1]) \ No newline at end of file diff --git a/python for beginners/answers/9.py b/python for beginners/answers/9.py new file mode 100644 index 0000000..b23563c --- /dev/null +++ b/python for beginners/answers/9.py @@ -0,0 +1,2 @@ +exam_st_date = (11, 12, 2014) +print("The examination will start from: %i/%i/%i"%exam_st_date) diff --git a/python for beginners/questions.txt b/python for beginners/questions.txt new file mode 100644 index 0000000..4e45f22 --- /dev/null +++ b/python for beginners/questions.txt @@ -0,0 +1,207 @@ +1. Write a Python program to print the following string in a specific format (see the output). Go to the editor +Sample String : "Twinkle, twinkle, little star, How I wonder what you are! Up above the world so high, Like a diamond in the sky. Twinkle, twinkle, little star, How I wonder what you are" Output : + +Twinkle, twinkle, little star, + How I wonder what you are! + Up above the world so high, + Like a diamond in the sky. +Twinkle, twinkle, little star, + How I wonder what you are + + +2. Write a Python program to get the Python version you are using. Go to the editor + + +3. Write a Python program to display the current date and time. +Sample Output : +Current date and time : +2014-07-05 14:34:14 + + +4. Write a Python program which accepts the radius of a circle from the user and compute the area. Go to the editor +Sample Output : +r = 1.1 +Area = 3.8013271108436504 + + +5. Write a Python program which accepts the user's first and last name and print them in reverse order with a space between them. Go to the editor + + +6. Write a Python program which accepts a sequence of comma-separated numbers from user and generate a list and a tuple with those numbers. Go to the editor +Sample data : 3, 5, 7, 23 +Output : +List : ['3', ' 5', ' 7', ' 23'] +Tuple : ('3', ' 5', ' 7', ' 23') + + +7. Write a Python program to accept a filename from the user and print the extension of that. Go to the editor +Sample filename : abc.java +Output : java + + +8. Write a Python program to display the first and last colors from the following list. Go to the editor +color_list = ["Red","Green","White" ,"Black"] + + +9. Write a Python program to display the examination schedule. (extract the date from exam_st_date). Go to the editor +exam_st_date = (11, 12, 2014) +Sample Output : The examination will start from : 11 / 12 / 2014 + + +10. Write a Python program that accepts an integer (n) and computes the value of n+nn+nnn. Go to the editor +Sample value of n is 5 +Expected Result : 615 + + +11. Write a Python program to print the documents (syntax, description etc.) of Python built-in function(s). +Sample function : abs() +Expected Result : +abs(number) -> number +Return the absolute value of the argument. + + +12. Write a Python program to print the calendar of a given month and year. +Note : Use 'calendar' module. + + +13. Write a Python program to print the following here document. Go to the editor +Sample string : +a string that you "don't" have to escape +This +is a ....... multi-line +heredoc string --------> example + + +14. Write a Python program to calculate number of days between two dates. +Sample dates : (2014, 7, 2), (2014, 7, 11) +Expected output : 9 days + + +15. Write a Python program to get the volume of a sphere with radius 6. + + +16. Write a Python program to get the difference between a given number and 17, if the number is greater than 17 return double the absolute difference. Go to the editor + + +17. Write a Python program to test whether a number is within 100 of 1000 or 2000. Go to the editor + + +18. Write a Python program to calculate the sum of three given numbers, if the values are equal then return three times of their sum. Go to the editor + + +19. Write a Python program to get a new string from a given string where "Is" has been added to the front. If the given string already begins with "Is" then return the string unchanged. Go to the editor + + +20. Write a Python program to get a string which is n (non-negative integer) copies of a given string. Go to the editor + + +21. Write a Python program to find whether a given number (accept from the user) is even or odd, print out an appropriate message to the user. Go to the editor + + +22. Write a Python program to count the number 4 in a given list. Go to the editor + + +23. Write a Python program to get the n (non-negative integer) copies of the first 2 characters of a given string. Return the n copies of the whole string if the length is less than 2. Go to the editor + + +24. Write a Python program to test whether a passed letter is a vowel or not. Go to the editor + + +25. Write a Python program to check whether a specified value is contained in a group of values. Go to the editor +Test Data : +3 -> [1, 5, 8, 3] : True +-1 -> [1, 5, 8, 3] : False + + + +26. Write a Python program to create a histogram from a given list of integers. Go to the editor + + +27. Write a Python program to concatenate all elements in a list into a string and return it. Go to the editor + + +28. Write a Python program to print all even numbers from a given numbers list in the same order and stop the printing if any numbers that come after 237 in the sequence. Go to the editor +Sample numbers list : + +numbers = [ + 386, 462, 47, 418, 907, 344, 236, 375, 823, 566, 597, 978, 328, 615, 953, 345, + 399, 162, 758, 219, 918, 237, 412, 566, 826, 248, 866, 950, 626, 949, 687, 217, + 815, 67, 104, 58, 512, 24, 892, 894, 767, 553, 81, 379, 843, 831, 445, 742, 717, + 958,743, 527 + ] + + +29. Write a Python program to print out a set containing all the colors from color_list_1 which are not present in color_list_2. Go to the editor +Test Data : +color_list_1 = set(["White", "Black", "Red"]) +color_list_2 = set(["Red", "Green"]) +Expected Output : +{'Black', 'White'} + + +30. Write a Python program that will accept the base and height of a triangle and compute the area. Go to the editor + + +31. Write a Python program to compute the greatest common divisor (GCD) of two positive integers. Go to the editor + + +32. Write a Python program to get the least common multiple (LCM) of two positive integers. Go to the editor + + +33. Write a Python program to sum of three given integers. However, if two values are equal sum will be zero. Go to the editor + + +34. Write a Python program to sum of two given integers. However, if the sum is between 15 to 20 it will return 20. Go to the editor + + +35. Write a Python program that will return true if the two given integer values are equal or their sum or difference is 5. Go to the editor + + +36. Write a Python program to add two objects if both objects are an integer type. Go to the editor + + +37. Write a Python program to display your details like name, age, address in three different lines. Go to the editor + + +38. Write a Python program to solve (x + y) * (x + y). Go to the editor +Test Data : x = 4, y = 3 +Expected Output : (4 + 3) ^ 2) = 49 + + +39. Write a Python program to compute the future value of a specified principal amount, rate of interest, and a number of years. Go to the editor +Test Data : amt = 10000, int = 3.5, years = 7 +Expected Output : 12722.79 + + +40. Write a Python program to compute the distance between the points (x1, y1) and (x2, y2). Go to the editor + + +41. Write a Python program to check whether a file exists. Go to the editor + + +42. Write a Python program to determine if a Python shell is executing in 32bit or 64bit mode on OS. Go to the editor + + +43. Write a Python program to get OS name, platform and release information. Go to the editor + + +44. Write a Python program to locate Python site-packages. Go to the editor + + +45. Write a python program to call an external command in Python. Go to the editor + + +46. Write a python program to get the path and name of the file that is currently executing. Go to the editor + + +47. Write a Python program to find out the number of CPUs using. Go to the editor + + +48. Write a Python program to parse a string to Float or Integer. Go to the editor + + +49. Write a Python program to list all files in a directory in Python. Go to the editor + + +50. Write a Python program to print without newline or space. Go to the editor + \ No newline at end of file From 80d4c8cd065b3755451cb9b2ddb2996797f4ab50 Mon Sep 17 00:00:00 2001 From: Nihar Sanda <55532999+koolgax99@users.noreply.github.com> Date: Thu, 1 Oct 2020 19:22:13 +0530 Subject: [PATCH 55/62] added the fundtracker code --- fundtracker.py | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 fundtracker.py diff --git a/fundtracker.py b/fundtracker.py new file mode 100644 index 0000000..3d248ed --- /dev/null +++ b/fundtracker.py @@ -0,0 +1,76 @@ +import sys + +def main(): + fund_donor = [] + recipient = [] + while True: + print("\n\n1. Enter fund donor's data\n2. Enter fund recipient's data\n3. Retrieve Donor specific data\n4. Retrieve Recipient specific data\n5. Exit system\n\n") + ch = int(input("Enter your choice : ")) + if ch==1: + print("\nEnter the following details:") + name = input("Fund donor's name : ") + ind = -1 + for i in range(len(fund_donor)): + if name.lower()==fund_donor[i][0]: + ind = i + if ind > -1: + fund_donor[ind][2] += 1 + else: + amtdon = input("Amount donated : ") + waydon = input("Enter the method of donation : ") + fund_donor.append([name,amtdon,1,waydon]) + print("\nThank you! Fund donor's details successfully updated!") + elif ch==2: + print("Enter the following details:") + name = input("Fund recipient name : ") + ind = -1 + for i in range(len(recipient)): + if name.lower()==recipient[i][0]: + ind = i + amtrec = input("Amount received : ") + wayrec = input("Enter the method of fund transfer : ") + recipient.append([name,amtrec,wayrec]) + print("\nThank you! Recipient details successfully updated!") + elif ch==3: + while True: + print("\n1. Show data of all fund donors\n2. Show data of specific method of fund transfer\n") + opt = int(input("Enter choice : ")) + if opt==1: + print("\n\nNAME\tAMT DONATED\tMETHOD\n") + for i in range(len(fund_donor)): + print(fund_donor[i][0]+"\t"+fund_donor[i][1]+"\t"+str(fund_donor[i][2])) + break + elif opt==2: + hosp = input("Enter fund transfer method : ") + print("\n\nNAME\tAMT DONATED\tMETHOD\n") + for i in range(len(fund_donor)): + if fund_donor[i][2]== waydon.lower(): + print(fund_donor[i][0]+"\t"+fund_donor[i][1]+"\t"+str(fund_donor[i][2])) + break + else: + print("Wrong choice!! Try again!") + elif ch==4: + while True: + print("1. Show dataof all Recipients\n2. Show data of specifc fund transfer\n") + opt = int(input("Enter choice : ")) + if opt==1: + print("\n\nNAME\tAMT RECEIVED\tMETHOD OF FUND TRANSFER\n") + for i in range(len(recipient)): + print(recipient[i][0]+"\t"+recipient[i][1]+"\t"+str(recipient[i][2])) + break + elif opt==2: + hosp = input("Enter method name : ") + print("\n\nNAME\tAMT RECIEVED\tMETHOD\n") + for i in range(len(fund_donor)): + if recipient[i][3].lower()==wayrec.lower(): + print(recipient[i][0]+"\t"+recipient[i][1]+"\t"+str(recipient[i][2])) + break + else: + print("Wrong choice!! Try again!") + elif ch==5: + print("\n\nThank you for using our system!!\nHave a good day!\n") + sys.exit(1) + else: + print("Wrong Choice!! Try again!") + +main() \ No newline at end of file From 5cb30d4acacee08382f5b15c9761fa4c9dd73490 Mon Sep 17 00:00:00 2001 From: Nihar Sanda <55532999+koolgax99@users.noreply.github.com> Date: Thu, 1 Oct 2020 19:25:01 +0530 Subject: [PATCH 56/62] added the fundtracker folder --- fundtracker.py => FundTracker Sysytem/fundtracker.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename fundtracker.py => FundTracker Sysytem/fundtracker.py (100%) diff --git a/fundtracker.py b/FundTracker Sysytem/fundtracker.py similarity index 100% rename from fundtracker.py rename to FundTracker Sysytem/fundtracker.py From 863e2ef2b3bd0f70c21ab8dd5505db2b74955fc1 Mon Sep 17 00:00:00 2001 From: zade1808 <50027662+KAPILJHADE@users.noreply.github.com> Date: Fri, 2 Oct 2020 12:01:39 +0530 Subject: [PATCH 57/62] Add files via upload --- day28-RegX.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 day28-RegX.py diff --git a/day28-RegX.py b/day28-RegX.py new file mode 100644 index 0000000..b947add --- /dev/null +++ b/day28-RegX.py @@ -0,0 +1,23 @@ +#!/bin/python3 + +import math +import os +import random +import re +import sys + + + +if __name__ == '__main__': + N = int(input()) + lst = [] + + for N_itr in range(N): + firstNameEmailID = input().split() + + firstName = firstNameEmailID[0] + + emailID = firstNameEmailID[1] + if re.search('@gmail\.com$',emailID): + lst.append(firstName) + print(*sorted(lst),sep='\n') From 9481036140898d0ed2b3bea4c6f84d868da4e131 Mon Sep 17 00:00:00 2001 From: ANJALIBHAGORIA <48825278+ANJALIBHAGORIA@users.noreply.github.com> Date: Fri, 2 Oct 2020 13:09:15 +0530 Subject: [PATCH 58/62] largest_element_in_the _list Python Program to find Largest Number in a List and also the index position of that largest element. --- largest_element_in_the_list | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 largest_element_in_the_list diff --git a/largest_element_in_the_list b/largest_element_in_the_list new file mode 100644 index 0000000..fa04e9a --- /dev/null +++ b/largest_element_in_the_list @@ -0,0 +1,16 @@ +# Python Program to find Largest Number in a List and also the index position of that largest element + +NumList = [] +Number = int(input("Please enter the Total Number of List Elements: ")) +for i in range(1, Number + 1): + value = int(input("Please enter the Value of %d Element : " %i)) + NumList.append(value) + +largest = NumList[0] +for j in range(1, Number): + if(largest < NumList[j]): + largest = NumList[j] + position = j + +print("The Largest Element in this List is : ", largest) +print("The Index position of the Largest Element is : ", position) From cce2573526d6670ae5a8526b64e19a41873e81d3 Mon Sep 17 00:00:00 2001 From: pravalika <56450276+pravalika2604@users.noreply.github.com> Date: Fri, 2 Oct 2020 14:30:48 +0530 Subject: [PATCH 59/62] Add files via upload --- nth fibonaccinumber.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 nth fibonaccinumber.py diff --git a/nth fibonaccinumber.py b/nth fibonaccinumber.py new file mode 100644 index 0000000..1a20ca9 --- /dev/null +++ b/nth fibonaccinumber.py @@ -0,0 +1,17 @@ +# Function for nth Fibonacci number + +def Fibonacci(n): + if n<=0: + print("Incorrect input") + # First Fibonacci number is 0 + elif n==1: + return 0 + # Second Fibonacci number is 1 + elif n==2: + return 1 + else: + return Fibonacci(n-1)+Fibonacci(n-2) + +# Driver Program + +print(Fibonacci(9)) \ No newline at end of file From 74444a5b594d9418542fd8291253cf96c376e056 Mon Sep 17 00:00:00 2001 From: Aman Osan Date: Sat, 3 Oct 2020 02:57:09 +0530 Subject: [PATCH 60/62] Create prime_number.py --- practice/python/python/prime_number.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 practice/python/python/prime_number.py diff --git a/practice/python/python/prime_number.py b/practice/python/python/prime_number.py new file mode 100644 index 0000000..9590686 --- /dev/null +++ b/practice/python/python/prime_number.py @@ -0,0 +1,9 @@ +def is_prime(num): + for i in range(2, int(num/2)): + if num % i == 0: + return False + return True + + +number = 13 +print(is_prime(number)) From 26aa6eb17e32297813eab0ae37a110248dda7343 Mon Sep 17 00:00:00 2001 From: Aman Osan Date: Sat, 3 Oct 2020 02:58:35 +0530 Subject: [PATCH 61/62] Create leap_year.py --- practice/python/python/leap_year.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 practice/python/python/leap_year.py diff --git a/practice/python/python/leap_year.py b/practice/python/python/leap_year.py new file mode 100644 index 0000000..9129592 --- /dev/null +++ b/practice/python/python/leap_year.py @@ -0,0 +1,13 @@ +def is_leap(year): + if year % 4 == 0: + leap = True + if year % 400 == 0: + leap = True + elif year % 100 == 0: + leap = False + else: + leap = False + return leap + + +print(is_leap(int(input("Enter a year to check for Leap year: ")))) From d589713f7d0430d7085a68946973c07876a6bddb Mon Sep 17 00:00:00 2001 From: Priya Tiru Date: Mon, 5 Oct 2020 22:40:22 +0530 Subject: [PATCH 62/62] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4ec5e69..2247e9c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # pythonbeginner This repository contains programs implemented in python. Questions have been solved by HackerRank Practice- -- Contains solutions from -##### HackerRank 30 days of code and Python. +- Contains solutions from HackerRank 30 days of code and Python. + +#### Added Fundtracker system as a part of Hacktober Fest 2020.