diff --git a/.github/config.yml b/.github/config.yml new file mode 100644 index 0000000..e4ddf94 --- /dev/null +++ b/.github/config.yml @@ -0,0 +1,39 @@ +# Configuration for welcome - https://github.com/behaviorbot/welcome + +# Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome + +# Comment to be posted to on first time issues +newIssueWelcomeComment: > + Thanks for opening your first Issue and showing your interest in @Novice-Paradigm! :bowtie: + + Feel free to join us over [Slack](https://join.slack.com/t/noviceparadigm/shared_invite/enQtNDIyMjczMzA1MzgyLWNlYmY2NjE2MGM3OTZkY2ZkNWI0ZDY2MjE0YTk2NDhjNzRmOTMyYjM0YjYwYmMxN2QxZjRiMTYzNmMyM2JlNTk) or on [Facebook](https://www.facebook.com/noviceparadigm/) for communicate with other contributors. :v: + + Please apply for [Hacktoberfest](https://hacktoberfest.digitalocean.com/). It's a fest celebrating open source where you get to win a free hacktoberfest t-shirt! :tshirt: only in October. Hurry! + + If you like this repository, don't forget to star it using `Star` button available at top right :blush: + +# Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome + +# Comment to be posted to on PRs from first time contributors in your repository +newPRWelcomeComment: > + Thanks for showing your interest in @Novice-Paradigm! :bowtie: + + Feel free to join us over [Slack](https://join.slack.com/t/noviceparadigm/shared_invite/enQtNDIyMjczMzA1MzgyLWNlYmY2NjE2MGM3OTZkY2ZkNWI0ZDY2MjE0YTk2NDhjNzRmOTMyYjM0YjYwYmMxN2QxZjRiMTYzNmMyM2JlNTk) or on [Facebook](https://www.facebook.com/noviceparadigm/) for communicate with other contributors. :v: + + Please apply for [Hacktoberfest](https://hacktoberfest.digitalocean.com/). It's a fest celebrating open source where you get to win a free hacktoberfest t-shirt! :tshirt: only in October. Hurry! + + If you like this repository, don't forget to star it using `Star` button available at top right :blush: + +# Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge + +# Comment to be posted to on pull requests merged by a first time user +firstPRMergeComment: > + Congrats on merging your first Pull Request! We here at @Novice-Paradigm are proud of you! + + Feel free to join us over [Slack](https://join.slack.com/t/noviceparadigm/shared_invite/enQtNDIyMjczMzA1MzgyLWNlYmY2NjE2MGM3OTZkY2ZkNWI0ZDY2MjE0YTk2NDhjNzRmOTMyYjM0YjYwYmMxN2QxZjRiMTYzNmMyM2JlNTk) or on [Facebook](https://www.facebook.com/noviceparadigm/) for communicate with other contributors. :v: + + Please apply for [Hacktoberfest](https://hacktoberfest.digitalocean.com/). It's a fest celebrating open source where you get to win a free hacktoberfest t-shirt! :tshirt: only in October. Hurry! + + If you like this repository, don't forget to star it using `Star` button available at top right :blush: + +# It is recommended to include as many gifs and emojis as possible! diff --git a/Books/Automate the Boring Stuff with Python (2015).pdf b/Books/Automate the Boring Stuff with Python (2015).pdf new file mode 100644 index 0000000..796bf9c Binary files /dev/null and b/Books/Automate the Boring Stuff with Python (2015).pdf differ diff --git a/Books/Python - Learning 4th Edition.pdf b/Books/Python - Learning 4th Edition.pdf new file mode 100644 index 0000000..a9e6998 Binary files /dev/null and b/Books/Python - Learning 4th Edition.pdf differ diff --git a/README.md b/README.md index 253ff5f..5fdf3d2 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ If you are new to git and github, to make your first contributions, visit this: ## Diving Into Python ### Book +- [Python For You and me by Kushal Das](https://pymbook.readthedocs.io/en/latest/) - [Learn Python the Hard Way by Zed Shaw](Books/LPTHW.pdf) ### Online Courses @@ -16,4 +17,8 @@ If you are new to git and github, to make your first contributions, visit this: - [Python Docs](https://docs.python.org/3/tutorial/) - [TutorialsPoint](https://www.tutorialspoint.com/python/index.htm) +### Youtube Channels +- [thenewboston](https://www.youtube.com/watch?v=HBxCHonP6Ro&list=PL6gx4Cwl9DGAcbMi1sH6oAMk4JHw91mC_) +- [Python Docs](https://www.youtube.com/watch?v=oVp1vrfL_w4&list=PLQVvvaa0QuDe8XSftW-RAxdo6OmaeL85M) + For some Sample Problems and to get started [click here](Src) diff --git a/Src/ASCII value/ascii_value.py b/Src/ASCII value/ascii_value.py new file mode 100644 index 0000000..7589f61 --- /dev/null +++ b/Src/ASCII value/ascii_value.py @@ -0,0 +1,2 @@ +k = 'H' +print "The ASCII value of '" + k + "' is",ord(k) \ No newline at end of file diff --git a/Src/Largefactorial.py b/Src/Largefactorial.py new file mode 100644 index 0000000..3b8276a --- /dev/null +++ b/Src/Largefactorial.py @@ -0,0 +1,15 @@ +#Input the number whose factorial is to be calculated +def range_prod(lo,hi): + if lo+1 < hi: + mid = (hi+lo)//2 + return range_prod(lo,mid) * range_prod(mid+1,hi) + if lo == hi: + return lo + return lo*hi +# The above function will reduce the multiplicaion of higher no. and could give 10X better performance than the previous one. +def fact(n): + if n < 2: + return 1 + return range_prod(1,n) +n = int(input("Enter number whose factorial is wanted ")) +print " %d! = %d " %(n,fact(n)) diff --git a/Src/Palindrome.py b/Src/Palindrome.py new file mode 100644 index 0000000..9b60c62 --- /dev/null +++ b/Src/Palindrome.py @@ -0,0 +1,27 @@ +# An example for checking whether the string is palindrome or not +# 1st of all what the palidrome string is. +# A palindrome is a word, number, or other sequence of characters which reads the same backward as forward, such as madam or racecar. +# Some well-known English palindromes are, "Able was I ere I saw Elba",[2] "A man, a plan, a canal – Panama",[3] "Madam, I'm Adam" and "Never odd or even". + +# so here is a code + +# by using for loop +x=str(input()) +y=x +a=len(x) +for i in range(0,a): + if(x[i]!=y[a-i-1]): + print("Not Palindrome") + break +if(i==a-1): + print("Palindrome") + + +# it is by list method + +x=(input()) +x=list(x) # this converts x str into list +if(x==x[::-1]): # x[::-1] implies it reverse the x list + print("Palindrome") +else: + print("Not Palindrome") diff --git a/Src/PrimeNumbers/PrimeRange_EffectiveApproach.py b/Src/PrimeNumbers/PrimeRange_EffectiveApproach.py new file mode 100644 index 0000000..16b9b4d --- /dev/null +++ b/Src/PrimeNumbers/PrimeRange_EffectiveApproach.py @@ -0,0 +1,16 @@ +# Python program to display all the prime numbers within an interval +import math +lower = int(input("Enter lower range: ")) +upper = int(input("Enter upper range: ")) +print("Prime numbers between",lower,"and",upper,"are:") +for num in range(lower,upper + 1): + # prime numbers are greater than 1 + if num > 1: + test=int(math.sqrt(num)) +#here we will iterate upto sqrt of a number not to the number itself, the reason is : any composite number N must have atleast one factor in the range 2 to sqrt(N), which is enough to find out whether N is prime or not. + #iterating upto sqrt(num) + for i in range(2,test+1): + if (num % i) == 0: + break + else: + print(num) \ No newline at end of file diff --git a/Src/PrimeNumbers/PrimeRange_NaiveApproach.py b/Src/PrimeNumbers/PrimeRange_NaiveApproach.py new file mode 100644 index 0000000..a145c15 --- /dev/null +++ b/Src/PrimeNumbers/PrimeRange_NaiveApproach.py @@ -0,0 +1,15 @@ +# Python program to display all the prime numbers within an interval +lower = int(input("Enter lower range: ")) +upper = int(input("Enter upper range: ")) + +print("Prime numbers between",lower,"and",upper,"are:") + +for num in range(lower,upper + 1): + # prime numbers are greater than 1 + if num > 1: + for i in range(2,num): + #iterating upto num + if (num % i) == 0: + break + else: + print(num) diff --git a/Src/factorial/Largefactorial.py b/Src/factorial/Largefactorial.py new file mode 100644 index 0000000..7999617 --- /dev/null +++ b/Src/factorial/Largefactorial.py @@ -0,0 +1,17 @@ +#Input the number whose factorial is to be calculated +def range_prod(lo,hi): + if lo+1 < hi: + mid = (hi+lo)//2 + return range_prod(lo,mid) * range_prod(mid+1,hi) + if lo == hi: + return lo + return lo*hi +# The above function will reduce the multiplicaion of higher no. and +#could give 10X better performance than the conventional one. +def fact(n): + if n < 2: + return 1 + return range_prod(1,n) +n = int(input("Enter number whose factorial is wanted ")) +print " %d! = %d " %(n,fact(n)) +#this code could calculate factorial of large numbers like 10^5. diff --git a/Src/factorial/factorial.py b/Src/factorial/factorial.py new file mode 100644 index 0000000..3643107 --- /dev/null +++ b/Src/factorial/factorial.py @@ -0,0 +1,12 @@ +#Input the number whose factorial is to be calculated +def fact(n): + if(n>0): + return (n*fact(n-1)) + else: + return (1) + +n = int(input("Enter number whose factorial is wanted ")) +print " %d! = %d " %(n,fact(n)) +#this code works appropriately only for smaller values of N, more specifically +#it works only upto 973, afterforth maximum recursion depth for function fact +#exceedes and it ends up being collapsed. diff --git a/Src/leapyearornot.py b/Src/leapyearornot.py new file mode 100644 index 0000000..e99dd54 --- /dev/null +++ b/Src/leapyearornot.py @@ -0,0 +1,15 @@ + +#code for checking if a given year by the user is leap year or not. + +# User enters the year +year = int(input("Enter Year: ")) + +# Checking for leap year +if year % 4 == 0 and year % 100 != 0: + print(year, "is a Leap Year") +elif year % 100 == 0: + print(year, "is not a Leap Year") +elif year % 400 ==0: + print(year, "is a Leap Year") +else: + print(year, "is not a Leap Year") diff --git a/Src/matrixadd.py b/Src/matrixadd.py new file mode 100644 index 0000000..7002b44 --- /dev/null +++ b/Src/matrixadd.py @@ -0,0 +1,20 @@ +import numpy as np +n = int(input("Dimensions of matrix")) +a = [[0] * n for i in range(n)] +b = [[0] * n for i in range(n)] +c = [[0] * n for i in range(n)] + + +for i in range(n): + for j in range(n): + a[i][j] = int(input()) + +for i in range(n): + for j in range(n): + b[i][j] = int(input()) + +for i in range(n): + for j in range(n): + c[i][j] = a[i][j]+b[i][j] + +print(np.matrix(c)) diff --git a/Src/positive_negative_or_zero.py b/Src/positive_negative_or_zero.py new file mode 100644 index 0000000..674c317 --- /dev/null +++ b/Src/positive_negative_or_zero.py @@ -0,0 +1,12 @@ +#the program takes a number from the user and checks for the sign of that number also for zero. +#Using Nested if + + +num = float(input("Enter a number: ")) +if num >= 0: + if num == 0: + print("Zero") + else: + print("Positive number") +else: + print("Negative number") diff --git a/Src/quadratic.py b/Src/quadratic.py new file mode 100644 index 0000000..44bf693 --- /dev/null +++ b/Src/quadratic.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 +import math + + +def solveQuadratic(a, b, c): + discriminant = (b**2) - (4*a*c) + return int((-b-math.sqrt(discriminant))/(2*a)), int((-b+math.sqrt(discriminant))/(2*a)) + + +# optional, when running standalone or without input values +a, b, c = float(input('a value: ')), float( + input('b value: ')), float(input('c value: ')) +print(solveQuadratic(a, b, c)) diff --git a/Src/tempFahToCel.py b/Src/tempFahToCel.py new file mode 100644 index 0000000..fc62dd4 --- /dev/null +++ b/Src/tempFahToCel.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python + +fah = input("Enter Temperature in Fahrenheit: "); +fahrenheit = float(fah); +celsius = (fahrenheit-32)/1.8; +print "Temperature in Celsius =",celsius diff --git a/Src/temp_conversion.py b/Src/temp_conversion.py new file mode 100644 index 0000000..029fb77 --- /dev/null +++ b/Src/temp_conversion.py @@ -0,0 +1,5 @@ +temp = input("Enter temperature: ") + +temp_in_celsius = (0.62)*(temp-32) + +print temp_in_celsius \ No newline at end of file diff --git a/Src/triangle.py b/Src/triangle.py new file mode 100644 index 0000000..d6ad561 --- /dev/null +++ b/Src/triangle.py @@ -0,0 +1,47 @@ +import math + + +def basic_formula(b, h): + return b*h/2 + + +def herons_formula(a, b, c): + s = (a+b+c)/2 + return math.sqrt(s*(s-a)*(s-b)*(s-c)) + + +def trigonometry(a, b, angle): + theta = angle * math.pi / 180 + return a*b*math.sin(theta)/2 + + +print("""Triangle Area Calculator +Which formula do you want to use? +1] Basic Formula (given base and height) +2] Heron's Formula (given all sides) +3] With Trigonometry (given two adjacent sides and the angle between them)""") +selection = int(input("(Type 1 / 2 / 3 to select): ")) + +if selection == 1: + print("Basic Formula:") + base = float(input("Give me the base of the triangle: ")) + height = float(input("Give me the height of the triangle: ")) + + res = basic_formula(base, height) + print("The area of the triangle with a base of {} and a height of {} is {}".format(base, height, res)) +elif selection == 2: + print("Heron's Formula:") + a = float(input("Give me the first side of the triangle: ")) + b = float(input("Give me the second side of the triangle: ")) + c = float(input("Give me the third side of the triangle: ")) + + res = herons_formula(a, b, c) + print("The area of the triangle with sides ({}, {}, {}) is {}".format(a, b, c, res)) +elif selection == 3: + print("Using Trigonometry:") + a = float(input("Give me the first of the two adjacent sides: ")) + b = float(input("Give me the second of the two adjacent sides: ")) + angle = float(input("Give me the angle between them (in degrees): ")) + + res = trigonometry(a, b, angle) + print("The are of the triangle with two adjacent sides ({}, {}) and an angle of {} degrees between them is {}".format(a, b, angle, res)) diff --git a/Thoughts/Pip.md b/Thoughts/Pip.md new file mode 100644 index 0000000..141dce1 --- /dev/null +++ b/Thoughts/Pip.md @@ -0,0 +1,11 @@ +**Pip** + +Pip is a rather simple concept of Python, but it's one that makes Python so amazing. +Pip is the Python package manager, and it helps you install everything you need to make +your program run. Unlike other languages, pip makes dependencies extremely easy. + +You can use pip in the cmd by simply running the command 'pip' +Look through all of the options you might want to use, but many people just use +'pip install ', and it works like magic! tada! + +Example: pip install tensorflow diff --git a/swapTwoNumbers/swap.py b/swapTwoNumbers/swap.py new file mode 100644 index 0000000..de14371 --- /dev/null +++ b/swapTwoNumbers/swap.py @@ -0,0 +1,8 @@ + +a=5 +b=9 +print(a,b) +temp=a +a=b +b=temp +print(a,b)