mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-01-30 22:23:42 +00:00
Improved Code and removed warnings (#482)
Improved Code and removed warnings
This commit is contained in:
parent
fedb3e70ab
commit
07451a6ca4
|
@ -37,7 +37,7 @@ def computeAP(l):
|
||||||
|
|
||||||
for x in range(len(isArt)):
|
for x in range(len(isArt)):
|
||||||
if isArt[x] == True:
|
if isArt[x] == True:
|
||||||
print(x, end=" ")
|
print(x)
|
||||||
|
|
||||||
# Adjacency list of graph
|
# Adjacency list of graph
|
||||||
l = {0:[1,2], 1:[0,2], 2:[0,1,3,5], 3:[2,4], 4:[3], 5:[2,6,8], 6:[5,7], 7:[6,8], 8:[5,7]}
|
l = {0:[1,2], 1:[0,2], 2:[0,1,3,5], 3:[2,4], 4:[3], 5:[2,6,8], 6:[5,7], 7:[6,8], 8:[5,7]}
|
||||||
|
|
|
@ -101,8 +101,8 @@ def PrimsAlgorithm(l):
|
||||||
return TreeEdges
|
return TreeEdges
|
||||||
|
|
||||||
# < --------- Prims Algorithm --------- >
|
# < --------- Prims Algorithm --------- >
|
||||||
n = int(input("Enter number of vertices: "))
|
n = int(raw_input("Enter number of vertices: "))
|
||||||
e = int(input("Enter number of edges: "))
|
e = int(raw_input("Enter number of edges: "))
|
||||||
adjlist = defaultdict(list)
|
adjlist = defaultdict(list)
|
||||||
for x in range(e):
|
for x in range(e):
|
||||||
l = [int(x) for x in input().split()]
|
l = [int(x) for x in input().split()]
|
||||||
|
|
|
@ -9,7 +9,7 @@ def isPositiveInteger(limit):
|
||||||
def main():
|
def main():
|
||||||
limit = int(input("How many terms to include in fibonacci series: "))
|
limit = int(input("How many terms to include in fibonacci series: "))
|
||||||
if isPositiveInteger(limit):
|
if isPositiveInteger(limit):
|
||||||
print(f"The first {limit} terms of the fibonacci series are as follows:")
|
print("The first {limit} terms of the fibonacci series are as follows:")
|
||||||
print([recur_fibo(n) for n in range(limit)])
|
print([recur_fibo(n) for n in range(limit)])
|
||||||
else:
|
else:
|
||||||
print("Please enter a positive integer: ")
|
print("Please enter a positive integer: ")
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# encoding=utf8
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
A Framework of Back Propagation Neural Network(BP) model
|
A Framework of Back Propagation Neural Network(BP) model
|
||||||
|
|
|
@ -9,4 +9,4 @@ T = int(input().strip())
|
||||||
ls = []
|
ls = []
|
||||||
for _ in range(T):
|
for _ in range(T):
|
||||||
fib(int(input().strip()))
|
fib(int(input().strip()))
|
||||||
print(*ls, sep = '\n')
|
print(ls, sep = '\n')
|
||||||
|
|
|
@ -3,7 +3,7 @@ Problem:
|
||||||
The prime factors of 13195 are 5,7,13 and 29. What is the largest prime factor of a given number N?
|
The prime factors of 13195 are 5,7,13 and 29. What is the largest prime factor of a given number N?
|
||||||
e.g. for 10, largest prime factor = 5. For 17, largest prime factor = 17.
|
e.g. for 10, largest prime factor = 5. For 17, largest prime factor = 17.
|
||||||
'''
|
'''
|
||||||
from __future__ import print_function
|
from __future__ import print_function, division
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
# Author: OMKAR PATHAK
|
#!/usr/bin/python
|
||||||
|
# encoding=utf8
|
||||||
|
|
||||||
|
""" Author: OMKAR PATHAK """
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
# Author: OMKAR PATHAK
|
#!/usr/bin/python
|
||||||
|
# encoding=utf8
|
||||||
|
|
||||||
|
""" Author: OMKAR PATHAK """
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# encoding=utf8
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
# Author: OMKAR PATHAK
|
# Author: OMKAR PATHAK
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function, division
|
||||||
|
|
||||||
try:
|
try:
|
||||||
raw_input # Python 2
|
raw_input # Python 2
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# encoding=utf8
|
||||||
|
|
||||||
"""
|
"""
|
||||||
This program calculates the nth Fibonacci number in O(log(n)).
|
This program calculates the nth Fibonacci number in O(log(n)).
|
||||||
It's possible to calculate F(1000000) in less than a second.
|
It's possible to calculate F(1000000) in less than a second.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""
|
"""
|
||||||
Implementation of gradient descent algorithm for minimizing cost of a linear hypothesis function.
|
Implementation of gradient descent algorithm for minimizing cost of a linear hypothesis function.
|
||||||
"""
|
"""
|
||||||
from __future__ import print_function
|
from __future__ import print_function, division
|
||||||
import numpy
|
import numpy
|
||||||
|
|
||||||
# List of input, output pairs
|
# List of input, output pairs
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
'''
|
#!/usr/bin/python
|
||||||
|
# encoding=utf8
|
||||||
|
"""
|
||||||
The Fisher–Yates shuffle is an algorithm for generating a random permutation of a finite sequence.
|
The Fisher–Yates shuffle is an algorithm for generating a random permutation of a finite sequence.
|
||||||
For more details visit
|
For more details visit
|
||||||
wikipedia/Fischer-Yates-Shuffle.
|
wikipedia/Fischer-Yates-Shuffle.
|
||||||
'''
|
"""
|
||||||
import random
|
import random
|
||||||
|
|
||||||
def FYshuffle(LIST):
|
def FYshuffle(LIST):
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# encoding=utf8
|
||||||
|
|
||||||
'''Author Anurag Kumar | anuragkumarak95@gmail.com | git/anuragkumarak95
|
'''Author Anurag Kumar | anuragkumarak95@gmail.com | git/anuragkumarak95
|
||||||
|
|
||||||
Simple example of Fractal generation using recursive function.
|
Simple example of Fractal generation using recursive function.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user