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)):
|
||||
if isArt[x] == True:
|
||||
print(x, end=" ")
|
||||
print(x)
|
||||
|
||||
# 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]}
|
||||
|
|
|
@ -101,8 +101,8 @@ def PrimsAlgorithm(l):
|
|||
return TreeEdges
|
||||
|
||||
# < --------- Prims Algorithm --------- >
|
||||
n = int(input("Enter number of vertices: "))
|
||||
e = int(input("Enter number of edges: "))
|
||||
n = int(raw_input("Enter number of vertices: "))
|
||||
e = int(raw_input("Enter number of edges: "))
|
||||
adjlist = defaultdict(list)
|
||||
for x in range(e):
|
||||
l = [int(x) for x in input().split()]
|
||||
|
|
|
@ -9,7 +9,7 @@ def isPositiveInteger(limit):
|
|||
def main():
|
||||
limit = int(input("How many terms to include in fibonacci series: "))
|
||||
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)])
|
||||
else:
|
||||
print("Please enter a positive integer: ")
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
# encoding=utf8
|
||||
|
||||
'''
|
||||
|
||||
A Framework of Back Propagation Neural Network(BP) model
|
||||
|
|
|
@ -9,4 +9,4 @@ T = int(input().strip())
|
|||
ls = []
|
||||
for _ in range(T):
|
||||
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?
|
||||
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
|
||||
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
# Author: OMKAR PATHAK
|
||||
#!/usr/bin/python
|
||||
# encoding=utf8
|
||||
|
||||
""" Author: OMKAR PATHAK """
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
# encoding=utf8
|
||||
|
||||
from __future__ import print_function
|
||||
# Author: OMKAR PATHAK
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
from __future__ import print_function
|
||||
from __future__ import print_function, division
|
||||
|
||||
try:
|
||||
raw_input # Python 2
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
# encoding=utf8
|
||||
|
||||
"""
|
||||
This program calculates the nth Fibonacci number in O(log(n)).
|
||||
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.
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from __future__ import print_function, division
|
||||
import numpy
|
||||
|
||||
# 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.
|
||||
For more details visit
|
||||
wikipedia/Fischer-Yates-Shuffle.
|
||||
'''
|
||||
"""
|
||||
import random
|
||||
|
||||
def FYshuffle(LIST):
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
# encoding=utf8
|
||||
|
||||
'''Author Anurag Kumar | anuragkumarak95@gmail.com | git/anuragkumarak95
|
||||
|
||||
Simple example of Fractal generation using recursive function.
|
||||
|
|
Loading…
Reference in New Issue
Block a user