From 0f3701a3bdc09b0f8d3091f52a312685124f32ee Mon Sep 17 00:00:00 2001 From: Naman Kumar Garg <31842804+Naman-Garg-06@users.noreply.github.com> Date: Sat, 28 Oct 2017 00:47:44 +0530 Subject: [PATCH 1/4] earlier it was not printing the sequence. It was just returning one value. --- Awesome-Scripts/fibonacci.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Awesome-Scripts/fibonacci.py b/Awesome-Scripts/fibonacci.py index e0a6fd0..b9d76ea 100644 --- a/Awesome-Scripts/fibonacci.py +++ b/Awesome-Scripts/fibonacci.py @@ -8,4 +8,6 @@ def fib(n): n = int(input("Enter a number: ")) -print(fib(n)) \ No newline at end of file +print("Fibonacci series:") +for i in range(n): + print fib(n) From 964856c7bf4792a6b8169d9eb2557802656d226d Mon Sep 17 00:00:00 2001 From: Naman Kumar Garg <31842804+Naman-Garg-06@users.noreply.github.com> Date: Sat, 28 Oct 2017 20:11:54 +0530 Subject: [PATCH 2/4] Print using single quotes. A statement can be printed using single quotes too. Also there were some spelling errors. --- Python-Syntax.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Python-Syntax.md b/Python-Syntax.md index 4825c85..97c55cc 100644 --- a/Python-Syntax.md +++ b/Python-Syntax.md @@ -2,20 +2,21 @@ ## Python 2 1. Printing output in python 2 :- - print "argument that you want to print" + print "argument that you want to print" OR + print 'argument that you want to print' 2. mathematical operators :- x = 8 y = 4 - print x+y # it wil give outout of sum of x and y + print x+y # it will give output of sum of x and y print x-y # it will give difference of x and y print x/y # it will give quotient when x is divided by y print x%y # it is modulo function and gives remainder when x is divied by y - print x ** y # it means x^y. it is way to represnt power operator + print x ** y # it means x^y. it is way to represent power operator 3. single line comments can be given by putting # before a line - 4. multi line comments can be given by putting 3 double quotes befire and after the lines. + 4. multi line comments can be given by putting 3 double quotes before and after the lines. example of putting multiline comments is : """ hello From f366ad06e78753209188d4c559f93c25af141bbd Mon Sep 17 00:00:00 2001 From: Naman Kumar Garg <31842804+Naman-Garg-06@users.noreply.github.com> Date: Mon, 30 Oct 2017 16:42:18 +0530 Subject: [PATCH 3/4] Spiral Matrix.py --- Awesome-Scripts/spiralmatrix.py | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Awesome-Scripts/spiralmatrix.py diff --git a/Awesome-Scripts/spiralmatrix.py b/Awesome-Scripts/spiralmatrix.py new file mode 100644 index 0000000..d19891b --- /dev/null +++ b/Awesome-Scripts/spiralmatrix.py @@ -0,0 +1,41 @@ +n=int(input("Enter the size of matrix:")) +t=1 +r=0 # r stands for row +c=0 # c stands for column +matrix=[[0 for x in range(n)]for y in range(n)] # to initialise the matrix +if n%2==0: + k=n/2 +else: + k=(n/2)+1 +for i in range(k): + while c=i: + matrix[r][c]=t + c=c-1 + t=t+1 + c=c+1 + r=r-1 + while r>i: + matrix[r][c]=t + t=t+1 + r=r-1 + r=r+1 + n=n-1 + c=c+1 +for m in matrix: + print m + ln = "" + for i in m: + ln += str(i) + " " + print(ln) \ No newline at end of file From 1bde911c2eb6ff42e52a97694dacf053958ddf57 Mon Sep 17 00:00:00 2001 From: Naman Kumar Garg <31842804+Naman-Garg-06@users.noreply.github.com> Date: Thu, 2 Nov 2017 20:21:05 +0530 Subject: [PATCH 4/4] Update Python-Syntax.md --- Python-Syntax.md | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/Python-Syntax.md b/Python-Syntax.md index 97c55cc..dccc790 100644 --- a/Python-Syntax.md +++ b/Python-Syntax.md @@ -1,30 +1,32 @@ # Basic Python Syntax ## Python 2 -1. Printing output in python 2 :- - print "argument that you want to print" OR - print 'argument that you want to print' +- Printing output in **Python 2** :- + `print "argument that you want to print"` + OR + `print 'argument that you want to print'` -2. mathematical operators :- - x = 8 - y = 4 - print x+y # it will give output of sum of x and y - print x-y # it will give difference of x and y - print x/y # it will give quotient when x is divided by y - print x%y # it is modulo function and gives remainder when x is divied by y - print x ** y # it means x^y. it is way to represent power operator +- Mathematical operators :- + >`x = 8` + >`y = 4` + >`print x + y` # it will give output of sum of x and y + >`print x - y` # it will give difference of x and y + >`print x / y` # it will give quotient when x is divided by y + >`print x % y` # it is modulo function and gives remainder when x is divied by y + >`print x ** y` # it means x^y. it is way to represent power operator - 3. single line comments can be given by putting # before a line + - Single line comments can be given by putting **#** before a line - 4. multi line comments can be given by putting 3 double quotes before and after the lines. + - Multi line comments can be given by putting 3 double quotes before and after the lines. - example of putting multiline comments is : - """ hello - how are you """ + example of putting multiline comments is : + **""" hello + how are you """** - 5. To validate a variable to be an integer or a string, use 'isinstance(, )' - it accepts two parameter - 1. variable name - 2. Type to be validated - example: isinstance(a, dict) , isinstance(num, integer) - It return True if true else false. + - To validate a variable to be an integer or a string, use `isinstance(, )` + it accepts two parameter: + - variable name + - Type to be validated + + example: isinstance(a, dict) , isinstance(num, integer) + It returns True if true else False.