blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
0423a1f2927e6d4ea4a16578801e4f237d0cda6d
20040116/Learning-experience-of-python
/Day02(2021.07.07)_Class.py
2,588
4.40625
4
###类的基础学习 ###书上的例子 ###属性:类中的形参和实参 方法:类中的具体函数 ###将一个类作为另一个类的属性 class Wheel(): def __init__(self, maker, size): self.maker = maker self.size = size def wheel_description(self): print("This wheel is " + str(self.size) + " maked by " + self.maker) class Car(): '''模拟汽车的...
5424c43a517edba09323db69e71cb470a8f0e555
Lokhead/Python_les_4
/dz4_6.py
201
3.515625
4
from itertools import count, cycle for el in count(10): if el > 20: break else: print(el) n = 0 for el in cycle('Hello'): if n > 9: break print(el) n += 1
98245ddd60d27d0651d060d0e2658dcac9e803db
ellispax/Binus_Workspace
/Assignment_07_10_19/family_feud.py
2,381
3.90625
4
# -*- coding: utf-8 -*- """ Created on Tue Oct 8 03:36:08 2019 @author: Ellis_Pax """ question = { '1':"What is your favourite snack?", '2':"What is your favourite 2019 movie?", '3':"What is your fvourite holiday resort?", ...
470d90a27f626ad900f689843c07d003e0852ca3
ausmarton/simple-notes
/notes_test.py
987
4.0625
4
""" Test cases """ # !coding: utf-8 from unittest import TestCase from Calculator import add from Calculator import multiply from notes import get def add_note(strings,string): strings.append(string) return strings class NotesTestCase(TestCase): """ Notes Test""" def test_get_note_from_list(self): ...
4df55036ec4dd5ee2a2bf6b4594a5ef63a3b9292
allenjstewart/SU_Programming_19
/Individual Folders/helliwed/factor3.py
1,152
4
4
# My second attempt at a factoring program now in Python 3 #seems to work, except some numbers are presented with a decimal... num = int(input("Enter an integer greater than 1. ")) factorlist = [] print() while (num > 1): i=2 while (i <= num**(.5)): #only need to check up to if num%i != 0: #and including the s...
8c8ec1b011a85861ad88cd5b003a69e0c54139bb
Kami32l/pong-game
/screen.py
869
3.65625
4
from turtle import Screen, Turtle class ScreenGenerator: def __init__(self): self.generate_screen() self.generate_line() def generate_screen(self): screen = Screen() screen.setup(width=1000, height=600) screen.bgcolor("black") screen.title("My Pong Game") ...
8a66ddada41f0d9c67dc46330e93771c0186a6d5
shishir2812/HockeyFantasyOptimizer
/Baseline.py
2,037
3.5
4
import pandas as pd df=pd.read_csv("DataTable.csv") pos_dict={"C":[],"W":[],"D":[],"G":[]} for index, item in df.iterrows(): # item=dict(item) # print(type(item)) # print( item["DKPos"]) if item["DKPos"] in pos_dict: pos_dict[item["DKPos"]].append({"DKSalary":item["DKSalary"],"FDFP":item["FDFP"...
7f1751848f21d7a90c259c773c324b39bcd370b3
AlexSR2590/curso-python
/07-ejercicios/ejercicio2.py
175
3.6875
4
""" Crear un script que muestre los numero pares del 1 al 120 """ for i in range(1,121): if i % 2 == 0 : print(f"Número par: {i}") else: print(f"Número impar: {i}")
f0fb1d24bbeffbc40fbfed97db945a69ffd9a6a1
AlexSR2590/curso-python
/07-ejercicios/ejercicio1.py
433
4.3125
4
""" Ejercicio 1 -Crear dos variables "pais" y "continente" -Mostrar el valor por pantalla (imprimir) -imprimir el tipo de dato de las dos variables """ pais = input("Introduce un país: ") continente = input("Introduce un continente: ") print("Pais: ", pais) print("Tipo de dato de la variable pais: ") print(type(pa...
1a9900260ede8d1f9fa50622b31f2244ff70d858
AlexSR2590/curso-python
/11-ejercicios/ejercicio1.py
1,774
4.28125
4
""" Hcaer un programa que tenga una lista de 8 numeros enteros y hacer lo siguiente: - Recorrer la lista y mostrarla - Ordenar la lista y mostrarla - Mostrar su longitud - Bucar algun elemento que el usuario pida por teclado """ numeros = [1, 9, 4, 2, 30, 7, 28, 18] #Recorrer la lista y mostrarla (función) print("Rec...
f8de2e157b5a6a3360dbfc695f71220e4080c1de
AlexSR2590/curso-python
/07-ejercicios/ejercicio7.py
531
4.03125
4
""" Hacer un programa que nos muestre todos los números impares entre dos numero que de el usuario """ numero1 = int(input("Dame el primer número: ")) numero2 = int(input("Dame el segundo número: ")) if numero1 < numero2 and numero1 >=0 and numero2 >=0: # mostrar numeros impares entre los numero dados for i in range...
08af65139899c28b6e118af7f9c15ecfda947611
AlexSR2590/curso-python
/03-operadores/aritmeticos.py
446
4.125
4
#Operadores aritmeticos numero1 =77 numero2 = 44 #Operador asignación = resta = numero1 - numero2 multiplicacion = numero1 * numero2 division = numero1 / numero2 resto = numero1 % numero2 print("***********Calculadora*************") print(f"La resta es: {resta}" ) print(f"La suma es: {numero1 + numero2} ") print("La...
f7b0abb69961b66369b6039acb9d614aba30a4b5
AlexSR2590/curso-python
/07-ejercicios/ejercicio3.py
444
4
4
""" Escribir un programa los cuadrados de los 60 primeros numero naturales, usar bucle while y for """ print("*****Bucle While*****") i = 0 while i <= 60: print(f"EL cuadrado de {i} es: {i * i}") i += 1 else: print("Programa terminado con bucle while!!") print("______________________________") print("*****Bucle ...
e04f6d80c5333bb085fe5d5c15c217338ba94e6f
cbelden/markovchain
/markovchain/tests/markov_chain_test.py
3,795
3.5
4
import unittest from markovchain import MarkovChain class TestMarkovChain(unittest.TestCase): """Tests the public methods for the MarkovChain class.""" def setUp(self): self._corpus = "This is a, sample' corpus.\n How neat is that.\n" self._expected_chain = {'this': {'is': 1}, ...
38cf064d18af9ebb2a2586ae187b3226835cd946
savadev/30-Days-of-Leetcode
/twoUnique.py
254
3.703125
4
def two_unique(num): arr = [] for i in range(len(num)): temp = num[i] num.pop(i) if temp not in num: arr.append(temp) num.append(temp) return arr print(two_unique([5, 5, 2, 4, 4, 4, 9, 9, 9, 1]))
f02f75dfc5af0a67166c15428440de8245474710
jaredfreytapingo/calculator_obj
/utils.py
756
3.734375
4
import inspect from types import * def symbolChecker(symbol_input): if not stringChecker(symbol_input): print 'The Symbol {} must be a string'.format(symbol_input) return False elif symbol_input.isdigit(): print "The Symbol you typed {} must not be a digit".format(symbol_input) ...
6f72c6c369a23e1a3410271a2ef85d7b35597651
khiljaekang/git-study
/keras/pratice_split.py
1,523
3.6875
4
#1. 데이터 import numpy as np x = np.array(range(1, 101)) y = np.array(range(101, 201)) from sklearn.model_selection import train_test_split x_train, x_test, y_train, y_test = train_test_split( x, y, shuffle = False, train_size =0.7 ) print(x_train) print(x_test) from keras.models import S...
d58fb5dc170496f46cdd9268795e4d40cbc44844
khiljaekang/git-study
/keras/keras59_cifal10_imshow.py
560
3.765625
4
# cifar10 색상이 들어가 있다. from keras.datasets import cifar10 from keras.utils.np_utils import to_categorical from keras.models import Sequential, Model from keras.layers import Dense, LSTM, Conv2D from keras.layers import Flatten, MaxPooling2D, Dropout import matplotlib.pyplot as plt #1. data (x_train, y_train),(...
9e51ffbb2aeb0846e753a7749ffdf0176880cd85
khiljaekang/git-study
/keras/practice_keras04.py
776
3.546875
4
import numpy as np from keras.models import Sequential from keras.layers import Dense x = np.array([1000,1001,1002,1003,1004,1005,1006,1007,1008,1009,1010]) y = np.array([2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010]) model = Sequential() model.add(Dense(2, input_dim=1)) model.add(Dense(400)) model.add(Den...
69b104c84a60cdaf332de46fcbbaee440427b060
khiljaekang/git-study
/keras/keras04_acc_test.py
889
3.546875
4
#1.데이터 import numpy as np x = np.array([1,2,3,4,5,6,7,8,9,10]) y = np.array([1,2,3,4,5,6,7,8,9,10]) x_pred = np.array([11,12,13]) #2.모델구성 from keras.models import Sequential from keras.layers import Dense model = Sequential() model.add(Dense(5, input_dim= 1)) model.add(Dense(3)) # model.add(Dense(1000...
2f446566d8589aa4141ad746d8a04e836093c969
dancojocaru2000/TruthTableLCS
/main.py
1,044
3.8125
4
#!/usr/bin/env python3 from logical_prop import LogicProposition, gen_table, get_max_width, print_table from sys import stdout, stdin p = None if stdout.isatty() and stdin.isatty(): print(" ! is the symbol for not\n","| is the symbol for or\n","& is the symbol for and\n","> is the symbol for implies\n","= is the sym...
9ea156cae87f883f1f3a9e7efa7593a26eeb2e1e
OnlineReview/FlockIdentification
/src/GridFormation/Point.py
723
3.734375
4
from math import sqrt, degrees,atan class Point(object): ''' classdocs ''' def __init__(self, x,y): ''' Constructor ''' self.id=0 self.x=x+0.0 self.y=y+0.0 self.isOnVertex=False def getAngle(self,vertex): a...
54b1926cfdea43184ac12a7762faa6bc7cadef20
sharvaniadiga/squirrel-game
/src/game/TreeNode.py
412
3.703125
4
''' Created on Feb 5, 2016 @author: sharvani ''' import SquarePosition class TreeNode(object): def setPosition(self, x, y): self.position = SquarePosition.SquarePosition() self.position.setPosition(x, y) def getPosition(self): return self.position def setValue(self, v...
b6faa8956a6bb83be2729eda9dec08a31a81cae0
enderweb/smallStuff
/minutesToSeconds/minutesToSeconds.py
148
3.984375
4
print "How many minutes would you like to convert into seconds?" def convert(minutes): print minutes * 60 userChoice = input() convert(userChoice)
01f42ded2480038227e1d492193c9a1dbb3395bf
Chih-YunW/Leap-Year
/leapYear_y.py
410
4.1875
4
while True: try: year = int(input("Enter a year: ")) except ValueError: print("Input is invalid. Please enter an integer input(year)") continue break if (year%4) != 0: print(str(year) + " is not a leap year.") else: if(year%100) != 0: print(str(year) + " is a leap year.") else: if(year%400) == 0: pr...
999579d8777c53f7ab91ebdcc13b5c76689f7411
ayushmohanty24/python
/asign7.2.py
682
4.1875
4
""" Write a program that prompts for a file name, then opens that file and reads through the file, looking for lines of the form: X-DSPAM-Confidence: 0.8475 Count these lines and extract the floating point values from each of the lines and compute the average of those values """ fname = input("Enter file name: ") ...
8e4a66d317f3be15980c606a8f45281ac6b5dea3
eswaribala/pythontraining
/tupledemo.py
206
3.53125
4
''' Created on 02-Jun-2016 @author: BALASUBRAMANIAM ''' data=(5,"Coimbatore",78.5,True) print(data) #data.append(67) print(data[1:]) listdata=list(data) listdata.append(56) print(listdata)
6bc7c7dbb046089646a85d79b22b59593efbe190
eswaribala/pythontraining
/tupleex.py
383
3.765625
4
''' Created on 03-Nov-2016 @author: BALASUBRAMANIAM ''' data=(4,'keeranatham',True) #print(data) #data.append(4359) nestedTuple=(('Ashok',567569756),('Aruna',356995345 ),('Karthik',46704765467)) for tuple in nestedTuple: for data in tuple: print(data,"\t", end=...
ad8c141cf0078dd636bff155cbfcf777d8c952ef
eswaribala/pythontraining
/Coercing.py
318
3.578125
4
''' Created on 01-Jun-2016 @author: BALASUBRAMANIAM ''' from _decimal import Decimal import fractions n = 15 print(bin(n)) print(oct(n)) print(hex(n)) print(float(n)) binarydata=bin(n) print(int(binarydata,2)) print(int(hex(n),16)) import fractions x = fractions.Fraction(1, 3) print(x)
8ea8ce121ad1266f432af418e833a47e02d71732
Abdelrahman-Mohamed-1/Epsilon-Data-Science-Assignments
/Assignment 3/MyAssignment/mypackage/Transformers/stringTransformer.py
85
3.59375
4
def reverse(s): s=s[::-1] print(s) def cee(n): n=n.capitalize() print(n)
2dd7e5f50727ef2fd7531715d87d974d2c5ed588
dephiros/random_python_script
/unique_char_in_string.py
1,782
3.578125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import unittest def is_string_unique_char_array(s): """ only support ASCII, use extra array of 128 chars for this version""" char_counts = [0] * 128 if s is None: return False for i in s: i_ord = ord(i) if i_ord > 127: raise ValueError("char %s out of...
f6de4676af1625e12369026507cfcf70c927e6a0
czchapma/college-diversity-data
/validateFiles.py
546
3.625
4
#Run python validateFiles.py before checking in! def validate(filename): f = open(filename, 'r') header_cols = f.readline().count(",") data = f.readlines() count = 2 error = False for line in data: if line.count(",") != header_cols: error = True print "Error in "...
51b86194f9598763abd275668fd4554fcd174daf
vasilisal/cs102
/homework2/sudoku.py
6,721
3.921875
4
def read_sudoku(filename: str) -> List[List[str]]: """ Прочитать Судоку из указанного файла """ with open(filename) as f: content = f.read() digits = [c for c in content if c in '123456789.'] grid = group(digits, 9) return grid def display(grid: List[List[str]]) -> None: """Вывод Судоку...
7f50b347102b88416d153a8cd199f0e523e7d8c7
Aang1993/python_mathesis_course
/code/week3/13_scope/_13_test_allign.py
655
3.640625
4
# mathesis.cup.gr # Ν. Αβούρης: Εισαγωγή στην Python # Μάθημα 13: Εμβέλεια μεταβλητών # Άσκηση 13_test_allign st = 'Αιγαίο, με βελτίωση του' def allign_text(line, width): sp = ' ' extra_spaces = width- len(line) print(line, extra_spaces) if sp in line: while extra_spaces > 0...
da4e49fa3fb25559bc845d28b7fd75d5196cc7b5
Aang1993/python_mathesis_course
/code/week2/09_while/9_0.py
392
3.71875
4
# mathesis.cup.gr # N. Αβούρης: Εισαγωγή στην Python # Μάθημα 9. Δομή while # βρες τους 10 μικρότερους πρώτους αριθμούς primes = [] num = 2 while len(primes) < 10 : x = num // 2 while x > 1 : if num % x == 0: break x -= 1 else: primes.append(num) num += 1 print(prime...
9a7c385c6a60b598e819543b2b1a6bd00c25a901
Aang1993/python_mathesis_course
/code/week6/19_re/_19_1.py
772
3.59375
4
# mathesis.cup.gr # Ν. Αβούρης: Εισαγωγή στην Python # Μάθημα 19: Regular Expressions # Άσκηση 19_1 import re tonoi = ('αά', 'εέ', 'ηή', 'ιί', 'οό', 'ύυ', 'ωώ') tw = 'trivizas_works.txt' try: with open(tw, 'r', encoding = 'utf-8') as f: works = f.read() for line in works.split('\n'): print(line)...
587182397e95f57d30df6dde183cae386c74f717
Aang1993/python_mathesis_course
/code/week3/12_functions/12_4.py
601
3.640625
4
# mathesis.cup.gr # N. Αβούρης: Εισαγωγή στην Python # Μάθημα 12. Functions '''12.4 Να κατασκευάσετε συνάρτηση που παίρνει στην είσοδο μια λίστα και επιστρέφει τη λίστα με μοναδικά στοιχεία. ''' def list_set(li): # επιστρέφει τη λίστα χωρίς διπλά στοιχεία if not type(li) is list : return [] li_new ...
8d2fc43a94c2e5fe4e52e41d18543d10bd9052d1
Aang1993/python_mathesis_course
/code/week6/19_re/_19_3.py
965
3.609375
4
# mathesis.cup.gr # Ν. Αβούρης: Εισαγωγή στην Python # Μάθημα 19: Regular Expressions # Άσκηση 19_3 import re with open('vouna.txt', 'r', encoding = 'utf-8') as f: text = f.read() for line in text.split("\n"): #print(line.rstrip()) line = line.split("\t") oros =line[0] height = i...
9950df95b026a80b9f184b534400a1b2d1d7d763
Aang1993/python_mathesis_course
/code/week4/14_modules/_14_3.py
607
3.765625
4
# mathesis.cup.gr # Ν. Αβούρης: Εισαγωγή στην Python # Μάθημα 14: Βιβλιοθήκες # Άσκηση 14_3 import math def ypot(a,b) : ''' INPUT : a, b οι κάθετες πλευρές ενός ορθογωνίου τριγώνου OUTPUT: η υποτείνουσα, ή False αν κάποιο από τα a,b δεν είναι αριθμός ''' if ((type(a) is int or type(a) is float) and...
755377403ca0f4ac0380deb69f2c3607bf20206b
Arnkrishn/ProjectEuler
/Problem15/problem15.py
427
3.9375
4
def factorial(num): if num < 0: print "Please provide positive input" elif num in (0, 1): return 1 else: return num * factorial(num - 1) def lattice_path_count(num): if num < 0: print "Please provide positive input" elif num == 1: return 1 else: r...
90ed430e058508cf21e8e49fcc18738154cb79df
Arnkrishn/ProjectEuler
/Problem3/problem3.py
781
4.03125
4
import math def is_prime(num): if num <= 1: print "Please enter a number greater than 1" elif num in (2, 3): return True else: for i in range(2, int(math.sqrt(num)) + 1): if num % i == 0: return False return True def largest_prime_factor(num): ...
d2bd67c580f11a4e07be0778095eebd806c926e0
sergii-yatsuk/projecteuler
/problem0014.py
891
3.875
4
#The following iterative sequence is defined for the set of positive integers: #n n/2 (n is even) #n 3n + 1 (n is odd) #Using the rule above and starting with 13, we generate the following sequence: #13 40 20 10 5 16 8 4 2 1 #It can be seen that this sequence (starting at 13 and finishing at 1) contains...
adfa2df9495c4631f0d660714a2d130bfedd9072
jni/interactive-prog-python
/guess-the-number.py
2,010
4.15625
4
# template for "Guess the number" mini-project # input will come from buttons and an input field # all output for the game will be printed in the console import simplegui import random def initialize_game(): global secret_number, rangemax, guesses_remaining, guesses_label rangemax = 100 guesses_remaining =...
f3e112fc6cda9426823e439c95c79fed1b07b12e
alanveloso/ppgcc-ufpa-ics-2021
/extended_euclidean_algorithm.py
941
3.703125
4
''' Extended Euclidean Algorithm ---------------------------- This algorithm determined the greatest common divisor (GCD) of two integers (​numbers). Also, It returns two integers such that GCD(a, b) = xa + by. @author: @alanveloso ''' def gcd(a, b): ''' Run extended euclidean algorithm. Parameters ---...
45c49bf02c95b6762003d8019e9f687a5f5c0c76
esteev/Eko
/utils/myThread.py
677
3.5
4
import threading import time class myThread(threading.Thread): exitFlag=0 threadId = name = counter = None def __init__(self, threadId, name, counter): threading.Thread.__init__(self) self.threadId = threadId self.name = name self.counter = counter def run(self): print...
e5738c78692248985beba2738ce237546d429779
kuseinova/task4
/task4.py
606
3.53125
4
# import math # import os # import random # import re # import sys # Complete the twoStrings function below. # def twoStrings(s1, s2): # flag=False # for c in s1: # if c in s2: # flag=True # break # if flag: # return ('YES') # else: # return ('NO') ...
29488acb724a4418b491dd098c58c0eab4de0839
raghav1674/graph-Algos-In-Python
/Recursion/01/NthFibonacci.py
488
3.8125
4
def nthFibonacii(n): if n == 1: return 0 if n == 1 or n == 2: return 1 return nthFibonacii(n-1) + nthFibonacii(n-2) dp = {} def memFibonacci(n): if n == 1 or n == 2: return n-1 if n not in dp: dp[n] = memFibonacci(n-1) + memFibonacci(n-2) return dp[n] def ...
5fd5b964582057ac930249378e9b944ac1b31bc0
raghav1674/graph-Algos-In-Python
/Recursion/05/StairCaseTraversal.py
393
4.15625
4
def max_ways_to_reach_staircase_end(staircase_height, max_step, current_step=1): if staircase_height == 0 or current_step == 0: return 1 elif staircase_height >= current_step: return max_ways_to_reach_staircase_end( staircase_height-current_step, max_step, current_step-1) + stairc...
17807197961c90ef347ae2d10fb881f8dd2b70af
CGVanWyk/CS50
/Pset 6/Sentimental-mario-less/mario.py
478
4.03125
4
from cs50 import get_int def main(): hashCount = 2 while True: height = get_int("Height: ") if height >= 0 and height <= 23: break spaceCount = height - 1 for i in range(height): for j in reversed(range(spaceCount)): print(" ", end="") for j in re...
a25bca880b3d7f34c2bd11a1a615f7897c66c484
keegan8912/tweet_prediction
/remove_extra_lines.py
738
3.734375
4
import re text_1 = "This is some text, that can be used. I am not sure! How many characters? This is an extra line " text_2 = "What the hell ?" text_3 = "whoopwhoop." text_4 = "This is crazyyyyy " text_5 = "This is some kind of a test. Yeaah." def remove_extra_lines(text): list_of_suffix = [".", ",", "!", "?"] ...
c4f19c2737304045a2b67a296862818258db96a8
deovaliandro/uri
/1020.py
285
3.53125
4
# 1020 - Age in Days day, month, year = 0, 0, 0 myday = int(input()) year = myday/365 myday = myday % 365 month = myday/30 myday = myday % 30 day = myday if month >= 12: aa = month/12 year+=aa month %= 12 print("%d ano(s)\n%d mes(es)\n%d dia(s)\n" % (year, month, day))
9b35d89bb63cda01e8f774ea545cfe4370fec989
deovaliandro/uri
/1041.py
344
3.90625
4
# 1041 - Coordinates of a Point x = float(input()) y = float(input()) if x == 0 and y == 0 : print("Origem\n") elif x > 0 and y > 0: print("Q1") elif x < 0 and y > 0: print("Q2") elif x < 0 and y < 0: print("Q3") elif x > 0 and y < 0: print("Q4") elif x == 0: print("Eixo X") elif y == 0: pr...
2b412f66b6e1b94d2e92fcbe2be0ac240890ee20
EdsonLMarques/URI
/resolvidos/1051.py
536
3.84375
4
salario = float(input()) imposto_1 = 0 imposto_2 = 0 imposto_3 = 0 if salario <= 2000: print("Isento") else: if 4500 < salario: imposto_3 = (salario - 4500) * 0.28 salario = salario - (salario - 4500) if 3000 < salario: imposto_2 = (salario - 3000) * 0.18 salario = salario - ...
5d3e6144ee08719ed3faee2879a041081ac282ac
EdsonLMarques/URI
/main.py
2,203
3.53125
4
N, M, P = map(int, input().split()) palavras = [] for i in range(0, N): palavras.append(input()) linha = [] matriz = [] for i in range(0, M): linhas = input() for char in linhas: linha.append(char) matriz.append(linha[:]) linha.clear() PRINCIPAL = [] ACIMA = [] ABAIXO = [] DIAGONAL = [] CO...
fff6349aa9a27b61921f6408fa06bcd1aec159d8
EdsonLMarques/URI
/resolvidos/1071.py
122
3.53125
4
x = int(input()) y = int(input()) soma = 0 for n in range(y+1, x): if n % 2 != 0: soma = soma + n print(soma)
a4a7c7db2d8fbfb5649f831e832190e719c499c6
phos-tou-kosmou/python_portfolio
/euler_project/multiples_of_three_and_five.py
1,459
4.34375
4
def what_are_n(): storage = [] container = 0 while container != -1: container = int(input("Enter a number in which you would like to find multiples of: ")) if container == -1: break if type(container) is int and container not in storage: storage.append(container) ...
eec09d1b8c6506de84400410771fcdeb6fe73f73
StephenTanksley/hackerrank-grind-list
/problem-solving/extra_long_factorials.py
950
4.5625
5
""" The factorial of the integer n, written n!, is defined as: n! = n * (n-1) * (n-2) * ... * 3 * 2 * 1 Calculate and print the factorial of a given integer. Complete the extraLongFactorials function in the editor below. It should print the result and return. extraLongFactorials has ...
706fe7a6d67d4df85a66c25d952ef7cc2d6ba6d3
jamiepg1/GameDevelopment
/examples/python/basics/fibonacci.py
277
4.1875
4
def fibonacci (n): """ Returns the Fibonacci number for given integer n """ if n == 0: return 0 elif n == 1: return 1 else: return fibonacci(n-2) + fibonacci(n-1) n = 25 for i in range(n): result = fibonacci(i) print "The fibonacci number for ", i, " is ", result
cd59185b740c3ef165e6163c22bddd1dfa34623a
TheGrumpyCAT/Algorithms
/Divide and Conquer/BinarySearch/program_recursive.py
448
3.84375
4
def binary_search(arr, search_el): if len(arr) > 0: mid = len(arr) // 2 mid_el = arr[mid] if mid_el == search_el: return mid elif search_el > mid_el: return binary_search(arr[:mid], search_el) elif search_el < mid_el: return binary_search(a...
34c6867e4dc393cdcf455a09701e906b48cf5f5e
solitary-s/python-learn
/list/tuple.py
329
4.15625
4
# 元组 不可以修改 类似字符串 tuple1 = tuple(range(1, 10)) print(tuple1) # ,逗号才是元组的标识 temp1 = (1) print(type(temp1)) # <class 'int'> temp2 = (1,) print(type(temp2)) # <class 'tuple'> # 元组的更新和删除,通过切片拼接 temp = (1, 2, 4) temp = temp[:2] + (3,) + temp[2:] print(temp)
cf8e0b2ce24068f60f4c4cb056e2baa57cae3f8f
solitary-s/python-learn
/dict/dict.py
479
4.125
4
# 字典 dict1 = {'1': 'a', '2': 'b', '3': 'c'} print(dict1) print(dict1['2']) # 空字典 empty = {} print(type(empty)) # 创建 dict((('F', 70), ('i', 105))) dict(one=1, two=2, three=3) # 内置方法 # 用来创建并返回一个新的字典 dict2 = {} dict2 = dict2.fromkeys((1, 2, 3), ('one', 'two', 'three')) print(dict2) # keys(), values() 和 items() dict3 =...
1a24f59123824b0a90d3149ea8ccfdd8cc1a224e
solitary-s/python-learn
/class/salary.py
1,451
3.8125
4
from abc import ABCMeta, abstractmethod class Employee(object, metaclass=ABCMeta): def __init__(self, name): self._name = name @property def name(self): return self._name @abstractmethod def get_salary(self): pass class Manager(Employee): def get_salary(self): return 15000.0 class Pr...
1a106be5577902e27ef98f60a6e94a374cdcb55d
josineidess/Daily-Coding-Problem
/Problem1.py
294
3.609375
4
qa = int(input("Quantidade de elementos: ")) k = int(input("valor da soma: ")) lista = [] for r in range(qa): a = int(input("elemento:")) lista.append(a) i = len(lista) - 1 for e in lista: if(lista[i] + e == k): print("sim") break else: print("nao") break i-=1
121f9c3fdbe5cdfa6d7a39b8617b5b29bd5a9abc
jsbaidwan/PythonTutorial
/ConditionalStatement.py
617
4.09375
4
# If condition age = 22 if age >= 18: print("Adult") elif age >= 13: print("Teenager") else: print("Child") print("done") # Statement block if age > 1: pass # for empty block use pass else: pass # Not Operators name = "baidwan" if not name: print("Not a name") # And Operators age = 22 if...
dea21a1897bc30bb33b9f170bae9c281f36b4ff7
gereniz/PG1926Repo
/SifiriTasi.py
293
3.8125
4
liste = [] yeniliste = [] for i in range(0,7): sayi = int(input("Sayı giriniz : ")) liste.append(sayi) for i in range(0,len(liste)): if liste[i] == 0 : yeniliste.append(liste[i]) for i in range (0,len(liste)) : if liste[i] != 0 : yeniliste.append(liste[i]) print(yeniliste)
624f3f7ae285e9a6cfbe1b3a3941c9140833d8d8
michael1016/The-chat-room
/re/regex.py
420
3.53125
4
import re s = 'Alex:1994,Sunny:1993' pattern = r"(\w+):(\d+)" # 通过re模块调用findall l = re.findall(pattern, s) print(l) # 使用compile对象调用 regex = re.compile(pattern) l = regex.findall(s) print(l) # 按照匹配内容切割字符串 re.split(r':|,', s) print(l) # 替换匹配到的内容 s = re.subn(r'\s+','#','This is a test',2) print(s) s = re.sub(r'\...
585bd470c5450d29aab458c79ec8b0c3468fe6aa
Bristy1411/Python-Codes
/First work.py
469
3.578125
4
import matplotlib.pyplot as plt m = 50 g = 9.81 c = 10 V_current = 0 T_current = 0 T_list = list() V_list = list() for i in range(1,10): T_new = i T_list.append(T_new) print(T_new) V_new = V_current + (g-(c*V_current/m))*(T_new - T_current) V_list.append(V_new) print(V_new) T_current = T_new V_current = V...
06cd3f9c93f63aca5e7ca2ee4f282b25d4985ff0
Arpita-Mahapatra/Python_class
/PROJECT1.py
4,245
4.34375
4
#Ds/Dt Calculator #Algebra Functions Functions={1:"Numbers",2:"List",3:"Sets",4:"Strings",5:"Tuples",6:"Dictionaries"} for values,keys in Functions.items(): print(values,keys) #to print all the keys with their values. Func_input=int(input("Enter the function to be performed from above options:")) ...
cfa8ff6a920cfbf24b950c8f47e8e109b52d2fde
Arpita-Mahapatra/Python_class
/List_task.py
1,074
4.15625
4
'''a=[2,5,4,8,9,3] #reversing list a.reverse() print(a)''' #[3, 9, 8, 4, 5, 2] '''a=[1,3,5,7,9] #deleting element from list del a[1] print(a)''' #[1, 5, 7, 9] '''a=[6,0,4,1] #clearing all elements from list a.clear() print(a)''' #o/p : [] '''n = [1, 2, 3, 4, 5] #mean l = len(n) nsum = sum(n) mean = ...
4435a66bd1a8ac1ea63bff7d57e218a6d1b27f6c
andcsantos/mlexercises
/multiplelinearregression.py
1,808
3.515625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Mar 22 13:32:37 2018 @author: lasiand """ import numpy as np import matplotlib.pyplot as plt import pandas as pd dataset = pd.read_csv('50_Startups.csv') X = dataset.iloc[:, :-1].values y = dataset.iloc[:, 4].values ##dummy variables #independentes f...
ac2b45ef810b82758d5ee147ee31f897566ad230
shellyb19-meet/meet2017y1lab4
/caugh_speeding.py
357
4.03125
4
speed = 61 is_birthday = False if not is_birthday: if speed < 31: print("no ticket") elif speed > 30 and speed < 51: print("small ticket") else: print("big ticket") else: if speed < 36: print("no ticket") elif speed > 35 and speed < 56: print("small ticket") ...
557724847397c80b198f7e6afebbfedc503f96b1
taingocbui/Coursera
/AlgorithmicToolbox/week3/Python/moneychange.py
250
3.53125
4
# Uses python3 import sys def get_change(m): answer = m//10 answer = answer + (m%10)//5 answer = answer + (m%10)%5 return answer if __name__ == '__main__': m = int(sys.stdin.read()) #m = int(input()) print(get_change(m))
5cf0f38f2c0e5eb93d51a45537867604104435e5
taingocbui/Coursera
/AlgorithmicToolbox/week5/change.py
763
3.53125
4
import sys def DPchange(money, coins): MinNumCoins = [0] * (money+1) for m in range(1, money+1): MinNumCoins[m] = sys.maxsize for coin in coins: if m >= coin: change = MinNumCoins[m-coin] + 1 if change < MinNumCoins[m]: MinNumCoins...
e1fa97c33df716401b0873340666f7b1fda19020
ygohil2350/infytq-Python_Fandamentals-
/validate_credit_card_number.py
866
3.625
4
#lex_auth_01269445968039936095 def validate_credit_card_number(card_number): #start writing your code here card=str(card_number) l=[] if len(card)==16: for i in card[-2::-2]: n=int(i)*2 if n>9: n1=n%10+n//10 l.append(n1) else: ...
bbf1edc06f3ea8e92fa9b2916bae24933eeef938
ygohil2350/infytq-Python_Fandamentals-
/sms_encoding.py
851
3.703125
4
#lex_auth_01269444961482342489 def sms_encoding(data): #start writing your code here vowel = "aeiouAEIOU" list1 = data.split() list2 = [] for i in list1: length=len(i) if length == 1: list2.append(i) list2.append(" ")#to add spaces between the words ...
ed6993edb8dda10d5bd7d30188773f6269c208b3
smsali97/bioinformatics-work
/pollutantmean.py
1,572
3.5
4
''' Created on Apr 17, 2018 @author: Sualeh Ali ''' import csv def main(): directory = "F:/Drive/Books/Bioinformatics/assignments" pollutant = "sulfate" id = range(1,11) pollutantmean(directory, pollutant, id) """ Calculates the mean of a pollutant (sulfate or nitrate) across a speci...
7b72f3093deaf07fe7dc3694f0c6462db14b72ab
Abstrys/abstrys-toolkit
/scripts/srep
1,759
3.65625
4
#!/usr/bin/env python import sys import glob import re file_list = None search_term = None replace_term = None # takes 3 args (see usage string for details). if len(sys.argv) < 4: print(""" Usage: srep <searchterm> <replaceterm> <filespec> ... Notes: * All arguments are required. * searchterm and/or replacet...
c1dfa57cd7bbe5492f8617a867d280e5e7cd91fc
C0nn0rNash/Neural-Network-classifier-and-optimization
/application L-layered.py
1,630
3.875
4
def L_layer_model(X, Y, layers_dims, learning_rate = 0.0075, num_iterations = 3000, print_cost=False):#lr was 0.009 np.random.seed(1) costs = [] # keep track of cost # Parameters initialization. (≈ 1 line of code) ### START CODE HERE ### parameters = initialize_paramete...
3e2b74991e778c965022834d02d2662a369c1666
subhaminion/Pylearn
/matchparenthesis.py
290
3.828125
4
def matched(str): count = 0 for i in str: print i if i == "(": count += 1 elif i == ")": count -= 1 if count < 0 or count == 0: print 'all matched' else: print 'Something fishy' string = '(abc)' matched(string)
96e43fad4ca2c0ed89fdce56ede8d6e9f260a062
subhaminion/Pylearn
/recur.py
217
3.84375
4
# def calc_factorial(x): # if x == 1: # return 1 # else: # return (x * calc_factorial(x-1)) # print(calc_factorial(4)) def fac(x): if x==1: return 1 else: return (x * fac(x-1)) num = 4 print (fac(num))
1fb9c5027803f73d2c15dac285bd1a9064a0f386
subhaminion/Pylearn
/regextut.py
118
3.671875
4
import re pattern = re.compile(r"\w+") string = "regex is awesome" result = pattern.match(string) print result.group()
00ace827d268e376f6344ddc8fe79857a661fd0f
subhaminion/Pylearn
/second.py
388
3.71875
4
__author__ = 'subham' me = 'Subham' print('Hello subham') #this is a comment line # Another Comment line just to @#$@#% str = 'the price of a good laptop is ' price = 30000 # print 'Hello ' + str + price #throwing an error in first attempt price2 = 40000 print '{0} is thirty thousand. And {1} is fourty'.format(price,...
44462bf98aa69155790a70f2a9ae5cf71607e393
KingOfRaccoon/python
/main.py
484
3.515625
4
def countOnNumber(data=[], number=0): summary = 0 counter = 0 for i in data: if summary + i <= number: counter += 1 summary += i return summary, counter with open("27888.txt") as file: data = file.read().split() for i in range(len(data)): data[i] = int(d...
0f09dd205b9184aa5faab057156b8f0242d17878
MOHAMMADHOSSEIN-JAFARI/Mini-Project-Gussing-the-numeber
/gussing.py
429
3.53125
4
import random f= 1 g= 99 a = random.randint(f,g) print(a) b= input("please inter: ") while b != 'd': if b == 'k': g= a-1 a = random.randint(f,a-1) print(a) b= input("please inter: ") continue elif b == 'b': f= a+1 a= random.randint(f,g) ...
197a59eb37208a39290d4f5ef87ae6c1989d1bd0
iiison/python_experiments
/dictionary.py
757
3.71875
4
def v(): print('Yep, this shit works.') dic = { 'a' : 'val', 'test' : v, 23 : '23 as strting', 'b' : 'some value here too' } print(dic.get('a')) result = dic.get('b', 'Not available!') print(result) print ('---------------------------------------') # Iteration using for loop: for key in dic : ...
d94010fb59fae9ea75e2a20ab7b02e20dab5f625
iiison/python_experiments
/helloWorld.py
2,097
3.9375
4
from math import pi # import math.pi as pie # import math import input_method string_var = "20" print("Yo YO! " + string_var) print(type(string_var)) # string_var = str(90) string_var = 90 print type(string_var) # print "Say man! this is the number value " + str(string_var) str_ = "honey singh mera bhai hai!" # pr...
aad85067c090c60b6095d335c6b9a0863dd76311
dpolevodin/Euler-s-project
/task#4.py
820
4.15625
4
#A palindromic number reads the same both ways. #The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. #Find the largest palindrome made from the product of two 3-digit numbers. num_list = [] result = [] # Create a list with elements multiplied by each other for i in range(100,1000...
70f2ebd8a2757660de025817d99eb4e1a6ec6555
aswathysoman97/LuminarPython
/pythondjangojuneclass/lamda/employee.py
1,180
3.8125
4
class Employee(): def __init__(self,id,name,desgn,salary,exp): self.id=id self.name=name self.desgn=desgn self.sal=salary self.exp=exp def printval(self): print("\n id:",self.id,"\n","name:",self.name,"\n","desgn:",self.desgn,"\n","salary:",self.sal,"\n","exp:",se...
3d82537c0f7694667d9df5dd6f63e969872543b1
aswathysoman97/LuminarPython
/pythondjangojuneclass/lamda/patternmtchng.py
362
3.546875
4
import re # x='[a-z][369][a-z]*' # vname=input("variable name= ") # match=re.fullmatch(x,vname) # if(match!=None): # print("valid") # else: # print("invalid") # validate vehicle registration number x='[klKL]\d{2}[a-zA-Z]{2}\d{4}' vname=input("variable name= ") match=re.fullmatch(x,vname) if(match!=None): ...
7d3fa79cb95f79e6a8795d1a5415b9d3bc504b04
aswathysoman97/LuminarPython
/pythondjangojuneclass/dob.py
124
3.65625
4
dob=input("birth year dd-mm-yy: ") byr=dob.split("-") today=int(input("recent year:")) age=(today-int (byr[2])) print(age)
dab6c268e95af478d5c41c58002fb1bed956392f
aswathysoman97/LuminarPython
/pythondjangojuneclass/exception/handling.py
330
3.75
4
n1=int(input("n1=")) n2=int(input("n2=")) try: res=n1/n2 print(res) # except: # print("<zero division error>") except Exception as f: print(f.args) n2 = int(input("another n2=")) res = n1 / n2 print(res) finally: print("exception is abnormal situation") print("program terminate the e...
3abffd00b7b8830997dd40cedb7c204385c00c1c
aswathysoman97/LuminarPython
/pythondjangojuneclass/class/student.py
812
3.671875
4
class Student: def __init__(self,rollno,name,course,tmark): self.rollno=rollno self.name=name self.course=course self.tmark=tmark def printval(self): print("rollno:",self.rollno,"\n","name:",self.name,"\n","course:",self.course,"\n","total mark:",self.tmark) f=open("studd...
b2a12ab4f0f3701606abc2447f61ec8488e9d327
Mewwaa/Basics-of-Python
/Game_Mewwaa/important_Mewwaa.py
3,269
3.59375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Author: Ewa Zalewska # Concept: Simple terminal game # Github: https://github.com/Mewwaa import random class Spell: def __init__(self, name, cost, dmg, magic_type): self.name = name self.cost = cost self.dmg = dmg self.magic_type =...
526a90a5eaa144a562bc22133f96e563e753cf64
AvadhootRaikar/PracticePythonPrograms
/count vowels.py
300
4
4
# Code to count the No. of vowels in a Text file file = open("textfile.txt","r") line =file.read() c=0 for i in line: word=i.split(" ") if i=="A" or i=="a" or i=="E" or i=="e" or i=="I" or i=="i"or i=="O"or i=="o"or i=="U"or i=="u": c+=1 print ("count of vowels is ",c) file.close()
f7569057859b1753d6f47293519212bb18f347af
AvadhootRaikar/PracticePythonPrograms
/Simple ATM system.py
4,039
4.03125
4
print('Welcome to Dharavi Bank ATM') restart=('Y') chances = 3 balance = 100.00 while chances >= 0: pin = int(input('Please Enter You 4 Digit Pin: ')) if pin == (1234): print('You entered you pin Correctly\n') while restart not in ('n','NO','no','N'): print('Please Press 1 For Your ...
8b89f2d6afb68ebffa4453f3fddb46c5de544aae
cty123/Leetcode
/1. Two Sum.py
463
3.5
4
class Solution: def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ for i_index, i_val in enumerate(nums): for j_index, j_val in enumerate(nums): if i_index != j_index: if i_...
036285387d4b42972cdb6d57dab29d4f485da633
cty123/Leetcode
/19.py
746
3.734375
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode: window = [] temp = head # Preload window for i in range(n+1)...
41b6ee22ddfb9f6ad0d6dc18d0ec4e5bf1e0bb43
anagharumade/Back-to-Basics
/BinarySearch.py
827
4.125
4
def BinarySearch(arr, search): high = len(arr) low = 0 index = ((high - low)//2) for i in range(len(arr)): if search > arr[index]: low = index index = index + ((high - low)//2) if i == (len(arr)-1): print("Number is not present in the input arr...
90dd382141f1aa05d85f5f3831beadb31f2497bd
cheetah100/ecosim
/ecosim.py
5,273
3.6875
4
import model import random import matplotlib.pyplot as plt; plt.rcdefaults() import numpy as np def get_best_price(industry, min_price): chosen_company = None best_price = 1000000 industry_companies = industries[industry] for company in industry_companies: if company.price < best_price and company.price > min_p...
cf1f0d657e3e744eb6a3793c020a553a0faed8cf
mootfowl/dp_pdxcodeguild
/python assignments/lab16_Pick6_v2.py
2,899
3.875
4
''' LAB16v2: Another approach to the Pick 6 problem that utilizes a function that calls another function. Also, instead of comparing if each of the ticket numbers is in the list of winning numbers, regardless of position, this new version requires ticket and winning numbers match the same index. This mirrors the actual...