diff --git a/Awesome-Scripts/List of ideas.md b/Awesome-Scripts/List of ideas.md index 025aaaf..27ff76c 100644 --- a/Awesome-Scripts/List of ideas.md +++ b/Awesome-Scripts/List of ideas.md @@ -36,4 +36,18 @@ It plays morse code (audio) depending on users' entered string. ### 14. The number game that insults you if you get it wrong with entries in a file. ### 15. [Bitcoin price tracker GUI](luno_btc_price.py) A GUI that shows Bitcoin price with a button that can refresh to the current price. -~ +### 16. [Rolling a Dice](Rolling_Dice.py) +A Simple Script that Rolls a dice. +### 17. [Chat Server](chat_serv.py) +Server for Multithreaded Chat application. +### 18. [Exponentiation](exponentiation.py) +To Get Precised exponent of desired Float Number. +### 19. [Fibonacci](fibonacci.py) +A simple fibonacci script. +### 20. [Port Scanner](port_scanner.py) +Simple Port Scanner to check whether port 80 available or not. +### 21. [File Renamer](toRenamer.py) +This program renames a list of tv episodes. Episodes can be nested inside folders. folders will be flattened and episodes renamed to a particular format. +### 22. [Reddit Scrapping.py](reddit_scrapping.py) +Scrapper for Reddit. + 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) diff --git a/Awesome-Scripts/hackernews.py b/Awesome-Scripts/hackernews.py new file mode 100755 index 0000000..5f1c8d9 --- /dev/null +++ b/Awesome-Scripts/hackernews.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +from __future__ import print_function +import requests +from bs4 import BeautifulSoup + +# get the front page from hacker news +response = requests.request("GET", "https://news.ycombinator.com/") + +# convert the response to soup +soup = BeautifulSoup(response.text, "lxml") + +# count the things that get processed +count = 0 + +# process all of the things! :D +for things in soup("tr", { "class" : "athing" }): + # get at the rank of each thing + for rank in things("span", { "class" : "rank" }): + print( rank.text, end=' ' ) + + # get the title of each thing + for title in things("a", { "class" : "storylink" }): + print( title.text ) + print( title['href'] ) + print( " " ) + + count = count + 1 + + if count == 10: break 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 diff --git a/Python-Syntax.md b/Python-Syntax.md index 4825c85..dccc790 100644 --- a/Python-Syntax.md +++ b/Python-Syntax.md @@ -1,29 +1,32 @@ # Basic Python Syntax ## Python 2 -1. Printing output in python 2 :- - 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 wil give outout 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 +- 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 befire 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.