From 5514bd98cb32c995c2765afd99736718091c977c Mon Sep 17 00:00:00 2001 From: Deepak Raj <54245038+perfect104@users.noreply.github.com> Date: Tue, 28 Jan 2020 16:38:59 +0530 Subject: [PATCH] Documentaion For Some Codes aare Updated Documentaion For Some Codes aare Updated with some comment for better Code-Reading. --- Control Flow/Loop 3.py | 4 ++- Functions/Basic Function Introduction.py | 10 +++--- Functions/Function_extended.py | 9 ++++-- Numpy/Basic Operation_numpy.py | 1 + Numpy/std Deviation.py | 13 ++++++++ Pandas/Create Pandas Dataframe.py | 7 ++-- Pandas/Pandas Indexing and slicing.py | 3 +- ...as dataframe from list using dictionary.py | 5 +++ Python Projects/Compound Interest.py | 0 Python Projects/Find n-th Fiboncci Number.py | 8 ++--- .../Google Image Auto Image Download.py | 2 ++ Python Projects/Grade Calculator.py | 11 ------- Python Projects/Number Guessing Game .py | 26 +++++++++++---- Python Projects/Prime Number.py | 20 ++++++++---- .../Python Program for factorial.py | 10 ++++-- Python Projects/Rock Paper Scissors.py | 14 -------- Python Projects/Text To Speech.py | 1 + ...Text to speech using windows in feature.py | 5 ++- Python Projects/password Generator.py | 23 ++++++++++--- Python Projects/reverse palindrome.py | 32 +++++++++++-------- .../sum of square of n natural number.py | 17 +++------- 21 files changed, 135 insertions(+), 86 deletions(-) create mode 100644 Numpy/std Deviation.py delete mode 100644 Python Projects/Compound Interest.py delete mode 100644 Python Projects/Grade Calculator.py delete mode 100644 Python Projects/Rock Paper Scissors.py diff --git a/Control Flow/Loop 3.py b/Control Flow/Loop 3.py index 345fbb6..6cbe7cb 100644 --- a/Control Flow/Loop 3.py +++ b/Control Flow/Loop 3.py @@ -2,7 +2,9 @@ """ Created on Mon Oct 28 17:17:30 2019 -@author: Looping Example 2 +@author: codePerfectPlus + +Looping Example 2 """ Phone = ['Iphone 10', 'Samsung S10', 'One plus 7 pro', 'Redmi note 7 pro'] diff --git a/Functions/Basic Function Introduction.py b/Functions/Basic Function Introduction.py index 102cc3b..5a8697b 100644 --- a/Functions/Basic Function Introduction.py +++ b/Functions/Basic Function Introduction.py @@ -6,11 +6,11 @@ ''' def check_number(x): - if (x % 2 == 0): - print("Given Number Is Even") + if (x % 2 == 0): # checking Divisibility by 2 + print("Given Number Is Even") # 2,4,6,8.... else: - print("Given Number Is Odd") + print("Given Number Is Odd") #1,3,5,7... check_number(7) check_number(5) @@ -21,4 +21,6 @@ def check_number(x): def student_name(firstname,lastname): print(firstname, lastname) -student_name(firstname = 'Alex', lastname = 'Jean') \ No newline at end of file + +student_name("john","adam") +student_name(lastname = 'Jean',firstname = 'Alex',) \ No newline at end of file diff --git a/Functions/Function_extended.py b/Functions/Function_extended.py index b5f8212..efd55cd 100644 --- a/Functions/Function_extended.py +++ b/Functions/Function_extended.py @@ -1,12 +1,17 @@ +''' +Check you name contain vowel Or Not Using python intersection function. +''' + def names(): - name = str(input("Please! Enter Your Name")) + name = input("Please! Enter Your Name\n") #Enter Your name if set('aeiou').intersection(name.lower()): print("Your Name Contains a vowel") else : print("Your Name doesn't have a vowel") - for letter in names: + for letter in name: # For Loop To Check Letter print(letter) + names() \ No newline at end of file diff --git a/Numpy/Basic Operation_numpy.py b/Numpy/Basic Operation_numpy.py index 1f8134a..50d12a2 100644 --- a/Numpy/Basic Operation_numpy.py +++ b/Numpy/Basic Operation_numpy.py @@ -1,4 +1,5 @@ ''' +@author : CodePerfectplus we can use arithmatic operators to do elementwise operation on array to convert in a new array. Arithmatic Operaqtors diff --git a/Numpy/std Deviation.py b/Numpy/std Deviation.py new file mode 100644 index 0000000..6520d76 --- /dev/null +++ b/Numpy/std Deviation.py @@ -0,0 +1,13 @@ +''' +Standard deviation is a number that describes how spread out the values are. +A low standard deviation means that most of the numbers are close to the mean (average) value. +A high standard deviation means that the values are spread out over a wider range. +Example: This time we have registered the speed of 7 cars: +''' +import numpy + +speed = [86,87,88,86,87,85,86] + +x = numpy.std(speed) + +print(x) \ No newline at end of file diff --git a/Pandas/Create Pandas Dataframe.py b/Pandas/Create Pandas Dataframe.py index 3cb5399..401094f 100644 --- a/Pandas/Create Pandas Dataframe.py +++ b/Pandas/Create Pandas Dataframe.py @@ -1,5 +1,8 @@ -# import pandas Library - +''' + import pandas Library +Pandas is Python Library for dataframe, Like to read write and load data in dataframe. +Pandas is must known library for Data Science. +''' import numpy as np import pandas as pd diff --git a/Pandas/Pandas Indexing and slicing.py b/Pandas/Pandas Indexing and slicing.py index 00cab61..60f1ff7 100644 --- a/Pandas/Pandas Indexing and slicing.py +++ b/Pandas/Pandas Indexing and slicing.py @@ -2,7 +2,8 @@ """ Created on Wed Oct 23 17:42:13 2019 -@author: Indexing and Selecting Data with Pandas +@author: CodePerfectPlus +@Topic : Indexing and Selecting Data with Pandas """ import pandas as pd df = pd.read_csv('nba.csv', index_col = "Name") diff --git a/Pandas/creating pandas dataframe from list using dictionary.py b/Pandas/creating pandas dataframe from list using dictionary.py index 3aea6bf..5fe79c8 100644 --- a/Pandas/creating pandas dataframe from list using dictionary.py +++ b/Pandas/creating pandas dataframe from list using dictionary.py @@ -1,3 +1,8 @@ +''' +Cretae Data Frame Using Dictionary in python. +Dictionary is a (key-value) Pair Data Type in python. +''' + import pandas as pd dict ={ 'Name':['john', 'joe', 'Alex', 'Iris', 'berry'], diff --git a/Python Projects/Compound Interest.py b/Python Projects/Compound Interest.py deleted file mode 100644 index e69de29..0000000 diff --git a/Python Projects/Find n-th Fiboncci Number.py b/Python Projects/Find n-th Fiboncci Number.py index 9df3157..b0cddf7 100644 --- a/Python Projects/Find n-th Fiboncci Number.py +++ b/Python Projects/Find n-th Fiboncci Number.py @@ -1,7 +1,7 @@ -# a = (a-1) + (a-2) - -# recurssion mehthod - +''' +Fibonacci Series start from 1. it makes new number by adding previous 2 Numbers. +1,1,2,3,5 +''' def Fibonacci(n): if n<0: print("Wrong Input ! Please Check Again") diff --git a/Python Projects/Google Image Auto Image Download.py b/Python Projects/Google Image Auto Image Download.py index 9a98813..760fbd5 100644 --- a/Python Projects/Google Image Auto Image Download.py +++ b/Python Projects/Google Image Auto Image Download.py @@ -1,4 +1,6 @@ # importing google_images_download module +''' +Python Module for download google image in one click by User Input''' from google_images_download import google_images_download # creating object diff --git a/Python Projects/Grade Calculator.py b/Python Projects/Grade Calculator.py deleted file mode 100644 index 1dbdb3d..0000000 --- a/Python Projects/Grade Calculator.py +++ /dev/null @@ -1,11 +0,0 @@ -''' -Grade Calculator -10 % of marks scored from Submission of assignment -70 % of marks scored from Test -20 % of marks scored in Lab-work - -90 >= 'A' -80 >= 'B' -70 >= 'C' -60 >= 'D' -''' diff --git a/Python Projects/Number Guessing Game .py b/Python Projects/Number Guessing Game .py index 531a1fa..0035d62 100644 --- a/Python Projects/Number Guessing Game .py +++ b/Python Projects/Number Guessing Game .py @@ -1,16 +1,28 @@ -import random -start = input("First Choose your Range for Number guessing\nlike 1 to 20\nEnter To Start Game For Number Guess ") +''' +Number Guessing Game In Python Without Gui Using Random and User_Input Fucntion in Python 3.8 +''' +import random +input("First Choose your Range for Number guessing\nlike 1 to 20\nEnter To Start Game For Number Guess ") lower_range =int(input("Enter Your Lower Range To Start Guessing Game: \n")) upper_range =int(input("Enter Your Upper Range To Start Guessing Game: \n")) -for i in range(10): - ran_num = random.randint(lower_range,upper_range) + +ran_num = random.randint(lower_range,upper_range) +#print(ran_num) To print Random Number For Debugging Purpose. +''' +Random : import random for generate random number between Lower Range TO Upper Range +Input : input Fucntion for take user input +Lower Range : Lower Range for randomly Generated Number +Upper Range : Upper Range For Randomly Generated Number +ran_num = Random Number Generated In Saved In ran_num Variable for Check With User Input + +''' num = int(input("Please Enter Your Guess Number :\n")) while True: - if num == ran_num: + if num == ran_num: # Checking User Input with Random Generated Number print("You Guess Right Number") break else: - print("Your Guess Was Wrong") + print("Your Guess Was Wrong") # if ran_num was not same as User Input. break -print("The Real Number Was {}".format (ran_num)) \ No newline at end of file +print("The Real Number Was {}".format (ran_num)) # To Print The Random Generated Number . diff --git a/Python Projects/Prime Number.py b/Python Projects/Prime Number.py index 3366c14..92ed54f 100644 --- a/Python Projects/Prime Number.py +++ b/Python Projects/Prime Number.py @@ -1,15 +1,23 @@ '''A Prime Number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The first few prime number are {2,3,5,7,11} ''' - -a = 1 -b = 30 - +input("Enter Your Range For Print Number \nLower Range \n Upper Range\n Like 1 to 20") +a = int(input("Lower Range :\n ")) +b = int(input("Upper Range :\n ")) +solution =[] +''' +a = Lower Range +b = Upper Range +solution = a list to contain prime Number +''' +print("-"*20) for val in range(a, b + 1): if val >1: - for n in range(2, val): + for n in range(2, int(val**0.5)): if ( val % n) == 0: break else: - print(val) + solution.append(val) + +print(solution) diff --git a/Python Projects/Python Program for factorial.py b/Python Projects/Python Program for factorial.py index a70d381..96592be 100644 --- a/Python Projects/Python Program for factorial.py +++ b/Python Projects/Python Program for factorial.py @@ -1,11 +1,15 @@ ''' Python program to find factorial of given number +Factorial of n +n = n*(n-1)*(n-2)*(n-3).......3*2*1 +4 = 4*3*2*1 = 24 + ''' def factorial(n): #Line to Find Factorial return 1 if (n==1 or n==0) else n * factorial(n -1); #Driver Code -num = 5; -print("Factorial of ",num,"is", -factorial(num)) \ No newline at end of file +num = int(input(" Enter Number For Factorial :\n")) +answer = factorial(num) +print(f"Factorial of {num} is {answer}.") diff --git a/Python Projects/Rock Paper Scissors.py b/Python Projects/Rock Paper Scissors.py deleted file mode 100644 index 227c4f5..0000000 --- a/Python Projects/Rock Paper Scissors.py +++ /dev/null @@ -1,14 +0,0 @@ -import random -for i in range(1): - Qu = ["rock", "paper", "scissors"] - ran_word = random.choice(Qu) - print(ran_word) -print("Welcome to The \n Rock Paper Scissors ") -ans = str(input("Choose Your word Below and Enter:\n 1.Rock\n2.Paper\n3.scissors\n")).lower() -while True: - if ans == ran_word: - print( "You won the Game") - break - else: - print("Loosers") - break \ No newline at end of file diff --git a/Python Projects/Text To Speech.py b/Python Projects/Text To Speech.py index ed2573f..77fa385 100644 --- a/Python Projects/Text To Speech.py +++ b/Python Projects/Text To Speech.py @@ -1,5 +1,6 @@ ''' python programfor convert text to speech +gTTS = Google Text to Speech ''' from gtts import gTTS import os diff --git a/Python Projects/Text to speech using windows in feature.py b/Python Projects/Text to speech using windows in feature.py index d829420..919df73 100644 --- a/Python Projects/Text to speech using windows in feature.py +++ b/Python Projects/Text to speech using windows in feature.py @@ -5,4 +5,7 @@ import win32com.client as wincl speak = wincl.Dispatch("SAPI.SpVoice") -speak.Speak("Text To Speech") \ No newline at end of file +speak.Speak("Text To Speech") +''' +This Program is not complete yet +''' \ No newline at end of file diff --git a/Python Projects/password Generator.py b/Python Projects/password Generator.py index c6a1b21..7c4de8a 100644 --- a/Python Projects/password Generator.py +++ b/Python Projects/password Generator.py @@ -1,9 +1,22 @@ +''' +Password Generation Using Random Function in Python. +Random is python module to generate random value or select random vlaue from list, string. +''' import random +list = [] s = "abcdefghijklmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()?" passlen = int(input("Enter Length to Genrate Password:\n")) -if passlen<6: - print("Choose 6 or Greater") -else: - p = "".join(random.sample(s,passlen )) - print (p) \ No newline at end of file +n = int(input("How Many Password Your Want to print :\n")) +''' +passlen = Length of password . Password Length should be greater than 8 +n = Number of password for your project +s = symbol and letter for auto-generation password +''' +for i in range(n): + if passlen<8: + print("Choose 8 or Greater") + else: + p = "".join(random.sample(s,passlen)) + list.append(p) # append Password in list +print(list) diff --git a/Python Projects/reverse palindrome.py b/Python Projects/reverse palindrome.py index 72f1f12..352c8ec 100644 --- a/Python Projects/reverse palindrome.py +++ b/Python Projects/reverse palindrome.py @@ -1,17 +1,23 @@ ''' -python programe to check if a string is palindrome -or not''' +Python Programe To Check if a String is Palindrome or Not +''' -x = "211112" -w = "" +check1 = input("Choose Your Input For Check Palindrome\n For Integer Type --> i \n For Word Type -->s\n").lower() +for i range(1,3): + if check1 == 's': + x = input("Enter Your Word Here :\n").lower() + elif check1 == 'i': + x = input("Enter Your Number Here :\n") + else: + print("Please Enter I or S only") -# save string x to a new new variable and compare them -for i in x: - w = i + w - #print(w) - if (x==w): - print("Yes") - break + w = "" # Empty String to save Reverse value in it. -else: - print("No") \ No newline at end of file +#save string x to a new new variable and compare them + for i in x: + w = i + w # save new value to w + if (x==w): + print("Yes") + break + else: + print("No") \ No newline at end of file diff --git a/Python Projects/sum of square of n natural number.py b/Python Projects/sum of square of n natural number.py index 39b090a..12639f7 100644 --- a/Python Projects/sum of square of n natural number.py +++ b/Python Projects/sum of square of n natural number.py @@ -1,22 +1,15 @@ ''' Given a positive integer N. The task is to find 12 + 22 + 32 + ….. + N2. - if N = 4 -1^2 + 2^2 + 3^2 + 4^2 - - The idea is to run a loop from 1 to n and for each i, 1 <= i <= n, find i2 to sum. - - +1^2 + 2^2 + 3^2 + 4^2 = 30 +The idea is to run a loop from 1 to n and for each i, 1 <= i <= n, find i2 to sum. ''' def squaresum(n): - sum = 0 for i in range(1, n+1): - sum = sum + (i * i) - + sum += (i * i) return sum -n = 4 -print(squaresum(n)) - +n = int(input("Enter Number to Print Sum Of square of N Natural Number :\n")) +print(squaresum(n)) \ No newline at end of file