blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
7a672ece6c9328dc9a942d152d6c0073f47be8bf
karensiglaa/aprendoPython2
/compara.py
524
4.0625
4
numero1=input("numero 1:") numero2=input("numero 2:") salida="numeros proporcionados {} y {}. {}." #solo si los números capturados entran if (numero1==numero2): print(salida.format(numero1, numero2, "los numeros son iguales")) #si los numeros no son iguales else: if numero1>numero2: #cual n...
bb9d69ac509e2b672033de4f887872c044b804c6
esosn/euler
/17.py
923
3.546875
4
import time import math times = [] times.append(time.clock()) limit = 1000 words = {0:'', 1:'one', 2:'two', 3:'three', 4:'four', 5:'five', 6:'six', \ 7:'seven', 8:'eight', 9:'nine', 10:'ten', 11:'eleven', 12:'twelve', 13:'thirteen', \ 14:'fourteen', 15:'fifteen', 16:'sixteen', 17:'seventeen', 18:'eighteen', \ 19:'n...
87516cec830b15e45e878b3b5a90fedfd270afc2
ronicson/ronicson
/ex010.py
113
3.65625
4
s = float(input('Digite a seu capital em espécie:')) print('Você pode comprar {:.2f} dólares'.format(s/5.12))
8cc48ac3e60be5a441ee72dc4f12f51b245af440
AvanthaDS/PyLearn_v_1_0
/Math.py
648
3.625
4
__author__ = 'Avantha' import math sqr = math.sqrt print(sqr(4)) value = input('Please enter the Vale:') diff = abs(17-int(value)) if int(value)>17: diff2 =diff*2 print('Since the value >17 the new difference is : %i'%diff2) else: print('The difference between the entered value and 17 is: %i'%diff) def n...
c9f25469c99aa924670879835462ef321d44b1a2
ajhurst95/personal_archive
/Pydoodles/automatetheboringstuff/commacode.py
532
4.21875
4
## combines a list into a string of the form ## item1, item2, and item3 ## Args: ## items (list): List of strings ## ## Returns: ## string: list items combined into string def stringit(items): item_len = len(items) if item_len == 0: return '' elif item_len == 1: ...
ebecb2e8a3aa4639684017300f155048d80683ae
lovehoneyginger/LearnPython
/quadratic equation.py
310
3.953125
4
import cmath print("Enter the a, b, c in the equation ax^2 + bx + c = 0") a = float(input('Enter a: ')) b = float(input('Enter b: ')) c = float(input('Enter c: ')) print("solution x1 : " + str(((-b) + cmath.sqrt(b**2 - 4*a*c))/(2*a))) print("solution x2 : " + str(((-b) - cmath.sqrt((b**2) - (4*a*c)))/(2*a)))
c6eadd54edbfc7013c701bec2b47359783a92c2b
Anshum4512501/dsa
/trees/bt/btest.py
443
3.609375
4
# class Node: # def __init__(self,val): # self.data = val # self.left = None # self.right = None # class Solution: # def height(self, root): # if root is None: # return 0 # return max(self.height(root.left),self.height(root.right))+1 # root ...
0a6d483d73e577db03418619f1e2d0f1c9780a5f
hakami1024/femicide
/check_dup.py
742
3.515625
4
# -*- coding: utf-8 -*- import config import pandas as pd def check_existance(target: str) -> bool: print(F'Searching for {target}') for f_name in config.SOURCES: df = pd.read_csv(f_name) raw_urls = df['ссылки и дополнения'].tolist() for url_str in raw_urls: if type(url_s...
c573db3750ea74fc94fe4fbe35bd94820cc05bcf
jsqihui/lintcode
/Valid_Sudoku.py
1,288
3.578125
4
class Solution: # @param board, a 9x9 2D array # @return a boolean def isValidSudoku(self, board): ret = True for i in [0, 3, 6]: for j in [0, 3, 6]: ret = ret and self.validCell(board, i, j) return ret and self.validRow(board) and self.validCol(b...
79a49b7768beb82f75b6cb77abf74f9cd50be6ed
qmnguyenw/python_py4e
/geeksforgeeks/python/basic/16_12.py
3,479
4.25
4
Python program to swap two elements in a list Given a list in Python and provided the positions of the elements, write a program to swap the two elements in the list. **Examples:** **Input :** List = [23, 65, 19, 90], pos1 = 1, pos2 = 3 **Output :** [19, 65, 23, 90] **...
4502a3bc184dd772a1c65ae2cbc2ff61783db9b4
gopupanavila/ABCnDofAI
/lesson3/pd_exercise.py
1,762
3.96875
4
import pandas as pd # Pandas dataframe exercises # simple dataframe # data = { # 'apples': [3, 2, 0, 1], # 'oranges': [0, 3, 7, 2] # } # purchases = pd.DataFrame(data) # print(purchases) # load data from csv file # df = pd.read_csv('appliances_rating.csv') #, index_col=0) # print(df) # print(df.loc[2]) # prin...
998f2cb573f1742119fb3222a224c7a2d6e5e4f8
q1003722295/WeonLeetcode
/_32-LongestValidParentheses/LongestValidParentheses3.py
1,335
3.75
4
''' 给定一个只包含 '(' 和 ')' 的字符串,找出最长的包含有效括号的子串的长度。 示例 1: 输入: "(()" 输出: 2 解释: 最长有效括号子串为 "()" 示例 2: 输入: ")()())" 输出: 4 解释: 最长有效括号子串为 "()()" ''' ''' 见题解2、3.png ''' # 栈+排序 class Solution1: def longestValidParentheses(self, s): res=[] stack=[] for i in range(len(s)): if(stack and s...
ec387c8991940d82edec4b8979c03086aea3d299
KarlPearson15/Chapter_5
/Chapter5-2.py
2,054
4.0625
4
#Chapter5-2.py #Karl Pearson #11/11/14 party=[] person=() strength=0 health=0 wisdom=0 dexterity=0 add=input('Would you like to add a party member? Y/N: ') while not add == "Y" and "N": print('You may only choose [Y]es or [N]o') add=input('Would you like to add a party member? Y/N: ') while add == "Y": nam...
6b7c0b12bae7353f189152b8ec527efb1f53dbf9
GHMan2021/python-project-lvl1
/brain_games/games/games_prime.py
723
3.9375
4
from random import randint from ..check_answer import f_check_answer def is_prime(): print('Answer "yes" if given number is prime. Otherwise answer "no".') counter = 1 result = True while result is True and counter <= 3: number = randint(0, 500) print('Question:', number) right...
d61dd616dc32c188c10e115b81d37a37786f4781
susmitpy/Interview_Practice
/bal_brackets.py
510
3.65625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Oct 29 09:03:07 2019 @author: susmitvengurlekar """ from collections import deque def isBalanced(s): stack = deque() opening = ["(", "[", "{"] closing = [")", "]", "}"] for i in s: if i in opening: stack.append(i)...
6eedd857d44549f59f21102f0b645d3d00cad0bf
Viveckh/Duell_Py
/Game.py
12,041
3.90625
4
# coding: utf-8 # Game Class # Implements the necessary details to run a game like conducting initial toss, getting user input for moves, displaying updated game board and turn notifications. # """ ************************************************************ * Name: Vivek Pandey * * Project: Duell Python ...
cae615385524e32d95c204ee874965f2941723dd
cowaar/advent2019
/Day6/second_.py
491
3.828125
4
import networkx as nx import matplotlib.pyplot as plt list = open("input.txt").read().split() print(list) G = nx.Graph() for item in list: inner,outer = item.split(")") print('inner = ' +inner +" outer = " + outer) G.add_edge(outer, inner) for neighbour in nx.neighbors(G,"SAN"): santas_planet = neigh...
760b19149c6f59d84cfc6569c88b08bba0fed5ea
daniel-reich/ubiquitous-fiesta
/aj7JPnAuW8dy4ggdp_17.py
127
3.75
4
def parity(n): remainder = bool(n % 2) if remainder == False: return "even" if remainder == True: return "odd"
6af0f346e07eeedf48d949d801b4577e0afec858
chengchaos/watchlist
/mytrain/alien.py
774
3.78125
4
# -*- coding:utf-8 -*- import print as print alien_0 = {"color": "green", "points": 5} print(alien_0["color"]) print(alien_0['points']) alien_0['x_position'] = 0 alien_0['y_position'] = 25 print(alien_0) del alien_0['points'] print(alien_0) favorite_languages = { "jen": "python", "sarah": "c", "edward":...
d0f4cced62680d432e13ee6b283d6b0a0aa52ce1
pnayab/dsp
/python/advanced_python_csv.py
372
3.65625
4
import csv f = open("faculty.csv") txt = f.read()[1:] header = txt.splitlines()[:1] lines = txt.splitlines()[1:] csv_f = csv.reader(lines) degree_list = [] for row in csv_f: degree_list.append(row[3]) f.close() with open('emails.csv', 'wb') as testfile: csv_writer = csv.writer(testfile, delimiter='\n') ...
d38f5fc63715e647c0538a77b42f141e29322502
jackyko1991/ConvNet-pytorch
/convnet.py
869
3.546875
4
from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F import torch class ConvNet(nn.Module): # neural net in pytorch inherits pytorch nn module class def __init__(self): super(ConvNet, self).__init__() # convnet # class initation defines convolution, pooling and cross produc...
e5867cbec367df050953c3506e5e1f139fb9f70b
JuanMPerezM/AlgoritmosyProgramacion_Talleres
/taller de estructuras de control de repeticion/ejercicio7.py
214
3.53125
4
""" Entradas Dato 1-->int-->x Dato 2-->int-->m Salidas """ while True: inp=input().split() x,m=inp x=int(x) m=int(m) if (x==0 and m==0): break else: n=x*m print(n)
0e4617ecbba8d6579b53c98087b96364e5dc6e83
neulab/tranx-study
/analysis/submissions/0ed2dff1d23b0de1cfcf9edb0ba35b1c_task1-1_1591986411/task1-1/main.py
463
3.640625
4
# Example code, write your program here import random import string from collections import defaultdict def main(): letters = [random.choice(string.ascii_lowercase) for _ in range(100)] numbers = [random.randint(1, 20) for _ in range(100)] d = defaultdict(list) for c, x in zip(letters, numbers): ...
b83a96edb849205eb16e489fc71097cee4956c60
Fe-Ordan/GitUp
/Quadratic Formula (ax^2+bx+c) Solver.py
1,127
4.0625
4
print(" Type a Quadratic Formula (ax^2+bx+c)") print(" =====================================") print(" But first we Have to do it the hard way") print(" " + "Do you Agree?") ans = "yes" answer = input() if answer == ans : print("Ok ,cool") else : print("alas!!") ...
bff28c27cf07ca5a0afd7c5608896440ba834d56
dmolony3/bland-altman
/bland_altman.py
3,253
3.5625
4
# -*- coding: utf-8 -*- """ Created on Tue Jan 30 10:07:00 2018 # Code for creating Bland Altman plot and Concordance Correlation Coefficient plots @author: David """ import pandas as pd import matplotlib.pyplot as plt import argparse from numpy import polyfit example_text = r'Example Usage: python bland_altman.py --...
2c4d25bbd91e1abf4cee55efae40626c87d6b750
xiaoxin12/pythonlearn
/learnign/12.素数判断.py
814
3.828125
4
# !/usr/bon/python # _*_ coding: UTF-8 _*_ # 题目:判断101-200之间有多少个素数,并输出所有素数。 # 程序分析:判断素数的方法:用一个数分别去除2到sqrt(这个数),如果能被整除,则表明此数不是素数,反之是素数。 count =0 for x in range(101, 200): # 首先先把这个输放出来 # 如果这个输字能被人一一个2 到自己的数字整除,则不是素数 issu = 0 for i in range(2, x): if x % i == 0: issu = 1 if issu ==...
1456da1bdf2b674ed5a4ca382a83536c3e0cb45a
angelosuporte/PythonLearning
/app_pyLearning/Exercise1.py
539
3.8125
4
a = int(input('Primeiro bimestre: ')) if a > 10: int(input('Você digitou um número errado. Digite novamente: ')) b = int(input('Segundo bimestre: ')) if b > 10: int(input('Você digitou um número errado. Digite novamente: ')) c = int(input('Terceiro bimestre: ')) if c > 10: int(input('Você digitou um número ...
f4f79ee8e93556baa1758073bc1b76fc93656102
TrisDing/algorithm010
/01/rotate-array.py
2,226
3.921875
4
""" 189. Rotate Array <Easy> https://leetcode.com/problems/rotate-array/ """ from typing import List class Solution: def rotate1(self, nums: List[int], k: int) -> None: """ Solution #1: Brute Force, rotate k times Time: O(n*k) Space: O(1) """ for i in range(k): ...
33103a5b720d88c34696887740d4a886a8778d61
AbdulAhadSiddiqui11/PyHub
/File Handling/Append.py
517
4.40625
4
# Append mode is used to attach new data to the exisiting text file rather than overwriting it. # Write Mode : path = "assets/Random.txt" file = open(path, "w") file.write("Hey! This is the second message and it repalced the previous one!") file.close() # Everytime you run the program, the lines are removed and th...
5e84a164bd423af5ede5ec4cbc572fedbea42e5e
laippmiles/Leetcode
/66_加一.py
1,143
3.828125
4
''' 给定一个非负整数组成的非空数组,在该数的基础上加一,返回一个新的数组。 最高位数字存放在数组的首位, 数组中每个元素只存储一个数字。 你可以假设除了整数 0 之外,这个整数不会以零开头。 示例 1: 输入: [1,2,3] 输出: [1,2,4] 解释: 输入数组表示数字 123。 示例 2: 输入: [4,3,2,1] 输出: [4,3,2,2] 解释: 输入数组表示数字 4321。''' class Solution(object):#36ms def plusOne(self, digits): """ :type digits: List[int] :rt...
bb02b6f7c4f95c6d65b2a8189d1a348891c7980f
caitanojunior/python
/Coursera/semana2/dezenas.py
1,293
3.921875
4
entrada = int(input('Digite um número inteiro: ')) numeroStr = str(entrada) if(entrada < 100): dezena = entrada // 10 print('O dígito das dezenas é', dezena) elif(entrada < 1000): dezena = numeroStr[1:2] print('O dígito das dezenas é', dezena) elif(entrada < 10000): dezena = numeroStr[2:3] pr...
604a6bf4069b75ac2d42b95c3dd2161b6740d2af
BridgetWright/B8IT105_Program_10354568
/bw_ca5b.py
3,833
3.9375
4
# Bridget Wright # Student No: 10354568 # B8IT105 Programming for Big Data # CA5b - Calculator, Python, Lambda, Map, Filter, Reduce # A calculator that can handle lists of data # Lambda, Map, Reduce, Filter, List Comprehension, Generator # Code from tutorial in class add = lambda x,y : x+y print add(1,1) ...
de4860107641e4c39f0f121d5898ef2d21a993e7
karrui/taskrr
/test/read_file.py
704
3.734375
4
from os import getcwd import csv # Convert any item in the row, from string to float def parse_csv_row(row): new_arr = [] for item in row: try: new_arr.append(float(item)) except: new_arr.append(item) return new_arr ## Read a csv file, return the data as list of tup...
e3ae49d8e381779796efb35dafe16fd8d76b56b5
rakshith4able/python-password-generator
/main.py
3,175
3.8125
4
from tkinter import * from tkinter import messagebox from random import choice, randint, shuffle import pyperclip # ---------------------------- PASSWORD GENERATOR ------------------------------- # def generate_password(): letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',...
85a60d251b7f5a4a8baf95c86b04520d695676d1
kbuczek/computerScienceStudies
/Python/Zadania9/9.6.py
3,086
3.75
4
class Node: def __init__(self, data=None, left=None, right=None): self.data = data self.left = left self.right = right def __str__(self): return str(self.data) def insert(self, node): if node.data < self.data: # mniejsze na lewo if self.left...
09053100811651fbeffa44915434353bea2d28f3
p234a137/caltech_ml
/hw1/Perceptron_hw1.py
2,307
3.640625
4
# coding: utf-8 # # Perceptron exercise from homework 1, April 8, 2013 # In[15]: #get_ipython().magic(u'pylab inline') import random import numpy as np # In[31]: number_runs=20 number_iterations=1000 number_training=10 iterations_to_convergence=[]; for run in range(0,number_runs): # target function x1=r...
eb0f205c4d2ae04a43eaa29350f6b5870a588a1b
malayandi/bCoursesGB
/sectionComp.py
3,036
3.96875
4
""" Given a CSV file containing the gradebook data from bCourses, prints a data frame containing the section averages and standard deviations for the specified assignment. Command line input should be as follows: python sectionComp.py path_to_data assignment Parameters: path_to_data: path to CSV file containing grade...
dbf103fbf156e8f3d06326de2c10dd46c4f494dc
yuwen37/algorithm021
/Week_02/429.n-叉树的层序遍历.py
1,152
3.515625
4
# # @lc app=leetcode.cn id=429 lang=python # # [429] N 叉树的层序遍历 # # @lc code=start """ # Definition for a Node. class Node(object): def __init__(self, val=None, children=None): self.val = val self.children = children """ class Solution(object): def levelOrder(self, root): """ :t...
6976a00c9db0fe5a06e735be6a7c6e11c28b291d
yang-0115/shiyanlou-code
/jump7.py
121
3.640625
4
a=0 while a <=99: a = a+1 if (a%7 ==0) or (a%10 ==7) or (a//10 ==7): continue else: print(a)
0e79fbea8d4474433ad6c3649be303cfedef0eea
yasmineElnadi/python-introductory-course
/Assignment 4/4.7.py
1,141
3.84375
4
import math class QuadraticEquations: def __init__(self, a, b, c): self.__a = a self.__b = b self.__c = c def geta(self): return self.__a def getb(self): return self.__b def getc(self): return self.__c #def checkDiscriminant(self): # if (sel...
e998645c3bea51297bb6dc94bd9b2e1c6da11614
shuforov/CheckiO
/Roman_numerals/roman_numerals.py
1,968
3.703125
4
"""translater from latin number to roman""" def roman_numerals(number_lat): """translate number""" roman_num = {1: 'I', 2: 'II', 3: 'III', 4: 'IV', 5: 'V', 6: 'VI', 7: 'VII', 8: 'VIII', ...
e2d1dd8ecc09e2261b8bf0008669cff2fda3954a
dylan7rdgz/AI
/Training Models/linear_regression.py
4,049
4.5
4
# linear regression is just a machine learning model import numpy as np # set of equations random_values = np.random.rand(100, 1) print(random_values) # random values is our input to our dataset and X is the output, the form of the foll: equation is y = mx X = 2 * random_values print(X) # what is numpy.random? ...
97b84dd0bb1ffd7889331d60e7244717b6d51791
ankitaapg17/Basic-Python-Codes
/new.py
311
3.75
4
#to generate exception of your type #custom exception class salnotinRange(Exception): salary=None def __init__(self,salary): self.salary = salary salary=int(input("Enter salary")) if not 5000 < salary < 15000: raise salnotinRange(salary) else: print("Thanks")
7afa691066ee1071a8ba4e36c034f9bd50753608
Alexis-Lopez-coder/ProgramacionLogiaAlexisLopez
/ejercicio1.py
1,838
4.0625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Apr 24 16:13:07 2020 @author: alexis """ """ # Programación Lógica # Modus ponendo ponens "el modo que, al afirmar, afirma" P → Q. P ∴ Q Se puede encadenar usando algunas variables P → Q. Q → S. S → T. P ∴ T Ejercicio Defina una funcion qu...
62c7d446a3772b74d7cd81a5c40a19b94f8f228a
bongster/leetcode
/solutions/1282-number-of-valid-words-for-each-puzzle/number-of-valid-words-for-each-puzzle.py
2,621
4.03125
4
# With respect to a given puzzle string, a word is valid if both the following conditions are satisfied: # # word contains the first letter of puzzle. # For each letter in word, that letter is in puzzle. # # For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage", while # i...
c2a9dc318e975e92e5ebd4244292f9229007d6a9
potomatoo/TIL
/Programmers/kakao_문자열 내림차순으로 배치하기.py
179
3.65625
4
def solution(s): answer = '' sort_ls = sorted(s, reverse=True) for i in range(len(sort_ls)): answer += sort_ls[i] return answer print(solution('Zbcdefg'))
cb33348cf40a968db5105373aa4f64d36bd83821
stacecadet17/python
/filter_by_type.py
992
3.953125
4
# If the integer is greater than or equal to 100, print "That's a big number!" If the integer is less than 100, print "That's a small number" def integer(num): if num >= 100: print ("That's a big number!") else: print ("that's a small number") # ************************************************************...
eb6069c8e804f5db3bdbc9bb52d8ba267c5114b4
deer95/Prog_Sparrow
/Term_2/Syms Palindrome_4.py
336
3.78125
4
import re def comparer(s): i = 0 while i <= len(s) / 2: if s[i] != s[-i - 1]: return False else: i += 1 return True s = 'Я не стар, брат Сеня'.lower() s = re.sub('\W', '', s) if comparer(s): print('It\'s a palindrome') else: print('It\'s not a palindrome')...
a30ab81661b4ac04d1d61dfe38d04c957fbc5627
wldusdhso/sw-project-class5-2-2
/assignment10_20171685_Guess.py
1,327
3.65625
4
class Guess: def __init__(self, word): self.secretWord = word self.numTries = 0 self.guessedChars = [] self.currentStatus = '_'*len(self.secretWord) self.currentword = '_'*len(self.secretWord) self.indexnumL =[] def display(self): return 'Current: '+ se...
a48171620ef64890d6e72cf1aa68f2de52923b3f
Dev-cSharpe/Algos
/insertion_sort.py
608
3.953125
4
from sort_tester import array_sort_test def insertion_sort(arr): ''' insertion sort : complexity ---> o(n^2) ''' for i in range(1,len(arr)): key=arr[i] j=i-1 while j>=0 and key < arr[j]: arr[j+1]=arr[j] j-=1 arr[j+1]=key return arr ...
692a7320eb41898b3f4d3ddc5c613c09dcf4726a
Aasthaengg/IBMdataset
/Python_codes/p02744/s573177405.py
440
3.5
4
#!/usr/bin/env python3 import sys input = sys.stdin.readline sys.setrecursionlimit(10**5) n = int(input()) ans = [] def dfs(arr, max_val): if len(arr) == n: ans.append(arr) return for i in range(max_val + 2): next_arr = arr[:] next_arr.append(i) dfs(next_arr, max(max_va...
2f89a9baa411fbb92a724ed23e3df374daf1c518
anujkumar163/pythonfiles
/pythonStack/makeArray.py
910
4.3125
4
# Second method to create a 1 D array N = 5 arr = [0 for i in range(N)] print(arr) # Using above second method to create a # 2D array rows, cols = (5, 5) arr = [[0 for i in range(cols)] for j in range(rows)] print(arr) # Python 3 program to demonstrate working # of method 1 and method 2. rows, cols = (5, 5) # metho...
0b0f487979d10051a6c52dd8b2cff4e5562270b1
chunche95/ProgramacionModernaPython
/Proyectos/ProgramacionVintage/OperadoresMatemáticos/modulo.py
963
4.125
4
# Operadores logicos # la tupla toma los valores: # Clave ==> Valor # A 1 # B 2 # ... ... # Creo la lista tupla = ('A','B','C','D','E','F','G','H','I') # Inicio un contador indice = 0 # Genero un bucle while para eliminar las letras con valores 3,6,9 # Leo la lista # while indice < le...
7098b399e7ae88903f96a79513289158bc458a77
minalspatil/coding_repo
/csvreader.py
203
3.59375
4
import csv reader = csv.DictReader(open('salaries.csv', 'rb')) #rows = sorted(Reader) for row in reader: print row reader = csv.reader(open('salaries.csv', 'rb')) for row1 in reader: print row1
acdccfdc659e69248b0e8962e7dfee87da63cae0
nrinn/guessing-game
/guess.py
650
4.0625
4
import random random_number = random.randrange(1, 101) print "Hello player, what is your name?", name = raw_input() print "%r, I'm thinking of a number between 1 and 100" % (name) guess = int(input("Try to guess my number.")) while True: #while guess != random_number: if guess > random_number: print "Yo...
c3ab763db4d75db29557e031cd9c08650732809d
andye456/OXO
/CreateGameModel.py
1,055
3.859375
4
from RunGame import run_game from model import TicTacToeModel print("--- Summary ---") history,x,o,d=run_game(player1="random", player2="random", loaded_model=None, iterations=10000) print("X Wins = "+str(x)) print("O Wins = "+str(o)) print("Draws = "+str(d)) # Train the network using the results from the random game...
33f91cf09df6ec773f19bf3afecbcbebc2ce06e1
xpert-uv/data_structure
/binary_search_tree.py
5,641
4.21875
4
""" binary search tree """ class Node: """ node for binary search tree """ def __init__(self, val, left=None, right=None): self.val = val self.right = right self.left = left # these two functions created based on video, not tested # def find(self, sought): # cur...
04ab63a7c588ef0ee8cd4e22be005e55ecf4b22e
Pooja-DataScientist/Hackerrank_Programs
/grades.py
568
4
4
n = int(input("Enter numbers of students:")) score = [] names=[] for i in range(n): name = input("Enter name: ") grade = float(input("Enter grade: ")) j = name,grade j=list(j) score.append(j) score.sort(key=lambda x: x[1]) lowest = score[0].__getitem__(1) second_lowest = 0 for l in score...
1fadf2e0267eaa079536c0f93d8b8ec00e62ecd9
asabnis7/python-basics
/ex48/lexicon.py
1,365
3.703125
4
def convert_num(s): try: return int(s) except ValueError: return None def scan(raw): lexicon = [('direction','north'), ('direction','south'), ('direction','east'), ('direction','west'), ('direction','down'), ('direction','up'), ('direction','left'), ('direction'...
0afe4b99b3c224ddc6e32159f478265941c2fae8
bocoup/stereotropes-analysis
/src/film/posters.py
5,820
3.515625
4
# A module to download film posters from rotten tomatoes # You can: # - Scrape rotten tomatoes for metadata and get movie posters # - Download poster images # # You don't have to do both. For example, this will scrape the data: # python -m src.film.posters --src=data/results/films_full.json # --dest=data/results/ft...
6487ea78d12ecdb604ce3ca8bfdd333ed4bab9da
fkunneman/ADNEXT_predict
/datahandler.py
8,774
3.765625
4
import csv import sys import re import random import utils class Datahandler: """ Datahandler ====== Container of datasets to be passed on to a featurizer. Can convert .csv files into a dataset Parameters ------ max_n : int, optional, default False Maximum number of data inst...
35e37f1b8ab3012af69e4eaa2eb82ba7e09f3f84
wjonesrhys/python
/learning_python/sqlite.py
3,951
3.75
4
import csv import sqlite3 import os import calendar def create_database(db_file): db = sqlite3.connect(db_file) cursor = db.cursor() c_1 = "transaction_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE NOT NULL" c_2 = "Organisation_Name TEXT NOT NULL" c_3 = "Purchase_Order_Number INTEGER NOT NULL" c...
0aa84e964945cf84bf0060b703587cae9e7a3403
PANNER-BAYARAVAN/Python-Codes
/basic/bubble_sort.py
291
3.65625
4
num1=0 temp=0 arrnum = [7, 4, 1, 3, 8, 6] for num1 in range(5): for num1 in range(4): if arrnum[num1]>arrnum[num1+1]: temp=arrnum[num1] arrnum[num1]=arrnum[num1+1] arrnum[num1+1]=temp for num1 in range(5): print(arrnum[num1])
db86788c34cd11c579106eb4814b885b0aee2d81
raymondhfeng/raymondhfeng.github.io
/data_structures_and_algorithms/cold_interview_practice/caching.py
3,059
3.8125
4
The task: Write a program that implements a cache policy. 1. LRU - Cache manager, has access to the cache and does all accesses. - Keep track of number of elements in cache - getter and setter method for all disk accesses. - Use a dictionary to represent the cache. When inserting an element into the cache * Fi...
433b976ebc79de9ed16e5c537a6fa2e0a3d5be01
akshaya-b/python
/corey.py
719
3.703125
4
class Tree: #class variable nooftrees=0 noofbrances=1.05 def __init__(self,name,age,region): self.name=name self.age=age self.region=region self.biology= name +"-"+ region Tree.nooftrees +=1 def morphology(self): return (str(self.age) + ...
ee0a6cd3c7e71fe252c7a2942316bdf69aee700d
inJAJA/Study
/homework/데이터 과학/p032_sort.py
775
4.1875
4
""" # Sort : list를 자동으로 정렬해줌 이미 만든 list를 망치고 싶지 않다면 sorted를 함수로 사용해서 새롭게 정렬된 list생성 가능 '오름 차순'으로 정렬 """ x = [4, 1, 2, 3] y = sorted(x) # y = [1, 2, 3, 4] / x = [4, 1, 2, 3] x.sort() # x = [1, 2, 3, 4] """ 내림 차순 : reverse = True """ a = sorted([-4, 1, -2, 3], reverse= True) print(a) ...
37301adf61c21f18df52a37023f5c18b763c8d40
Empythy/Algorithms-and-data-structures
/剑指Offer/把二叉树打印成多行.py
1,287
3.578125
4
""" 从上到下按层打印二叉树,同一层结点从左至右输出。每一层输出一行。 """ # -*- coding:utf-8 -*- class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: # 返回二维列表[[1,2],[4,5]] def Print(self, pRoot): # write code here if pRoot is None: return...
de0ef9e7b023d5ee739ade229e415b2a2692b39c
macjohn96/SI_python
/activitie9.py
174
4.21875
4
myNumber = int(input('Enter an integer: ')) print("Number: {0:0=3d}".format(myNumber)) print("Pow2: {0:0=3d}".format(myNumber**2)) print("Pow3: {0:0=3d}".format(myNumber**3))
91b76bbcecbbf331063c03f08300c860899479d7
Harmandhindsa19/python
/class4/2assignment.py
139
3.703125
4
t=(20,50,30,60,78,19,49) print("tuple is:" , t) print("maximun number in tuple is:" , max(t)) print("minimum number in tuple is:" , min(t))
f2dff083ba2780be98cd6d7d72e5ccf231e4b665
fclm1316/mypy
/oop/chapter07/an_error.py
1,034
4.0625
4
#!/usr/bin/python3 #coding:utf-8 def add(a,b): #就地修改a[list] a += b return a class Company: def __init__(self,name,staffs=[]): self.name = name self.staffs = staffs def add(self,staffs_name): self.staffs.append(staffs_name) def remove(self,staffs_name): self.staf...
cfab71901c8e5ae2e22dd895ad57827c8ecf97ea
melany202/programaci-n-2020
/talleres/taller2.py
1,432
4
4
#Ejercicios while print("---Ejercicio1---") preguntaNumero="Ingrese porfavor un numero entero o 0 para terminar : " NumeroIngresado =int(input(preguntaNumero)) suma = 0 while(NumeroIngresado != 0) : suma += NumeroIngresado NumeroIngresado =int(input(preguntaNumero)) print(suma) #Ejercicio while 2 print("---...
3f4b28f1f0a73e386fa1ffd853343a01c62255eb
Wojtbart/Python_2020
/Zestaw2/kopiowanie.py
598
3.765625
4
import sys def kopiowanie(inner_file,outer_file ): text="" with open(inner_file,"r") as fileRead, open(outer_file,"w") as outFile: try: for line in fileRead: if not line.startswith('#'): text+=line outFile.write(text) finally: ...
6dab387392fcc7dbf918196a084c88bb1e25169b
XixinSir/PythonKnowledgePoints
/正则表达式/1、判断是否是手机号码.py
1,506
3.8125
4
import re def checkPhone(str): if len(str) != 11: return False elif str[0] != "1": # 注意str[0]字符形式 判断的时候要注意这一点 return False elif str[1:3]!= "38" and str[1:3]!="39": return False for i in range(3,11): if str[i]>"9" or str[i]<"0": return False ret...
62191c4a3c439bd5d2d887801cdebf2020d34c5e
bryanlimsin/blood_calculator
/for_usage.py
315
3.640625
4
foods = ["apples", "bananas", "cherries", "donuts"] amounts = [11, 22, 33, 44] for i, x in enumerate(foods): print("{} - {}".format(amounts[i], x)) ######### # With zip() do_I_like_it = [True, False, False, True] for y, x, z in zip(amounts, foods, do_I_like_it): print("{} - {} - {}".format(y,x,z))
b9a4267c8f47230ace3ed7a5b8d53e3e37410ff4
jessychen1984/MiniProj
/src/misc/calculator/calculator.py
1,930
3.953125
4
''' A simple python calculation question generator usg: python calculator.py -d "+,-" -c 3 -l 200 -t 30 usg: python calculator.py --op_type="+,-" --op_count=3 --limit=20 --total=30 ''' import sys, getopt, random def auto_cal_generator(limit=100, op_count=1, op_type=["+"], total=100): print("Here are today's %d wor...
94148ce82196e1c63a78c9ca75907da40b352205
DuttaH/TicTacToe
/GamePlay.py
2,646
3.53125
4
from GameCourt import * msg = ['Player ', 'Game Draw', 'Winner : ', 'Press any key to continue...', 'ERROR# Cell already occupied', 'ERROR# Invalid input', 'Do you want to save the game? (Y/N) ', 'Your Game has been saved. Press any key to quit...' ] def save_g...
f62363bf4ffcdaee67c8e6d34a278ef59a0c6b8e
dtliao/Starting-Out-With-Python
/chap.5/08 p.229 ex.4 practice.py
755
3.890625
4
def allCost(l,i,g,o,t,m,totalAnnual): print('Loan payment is $ ',format(l, ',.2f')) print('Insurance expenses is $ ', format(i, ',.2f')) print('Gas expenses is $ ', format(g, ',.2f')) print('Oil expenses is $ ', format(o, ',.2f')) print('Tires expenses is $ ', format(t, ',.2f')) print('Maintenac...
ee55fc8d29595d66d91dc6cc6ca850d0e36cceb1
lucasoliveiraprofissional/Cursos-Python
/Curso em Video/desafio027.py
2,484
4.15625
4
'''Fazer um programa que leia o nome completo de uma pessoa mostrando em seguida o primeiro e o último nome separadamente''' '''De acordo com a aula 09 o len pode ser usado O len pode ser usado para medir a quantidade de qualquer coisa Por exemplo, saber a quantidade de sobrenomes que uma pessoa tem: quant= nome.spli...
fcdf5acf6285185cda8436cb3082ba2c33cb3acb
SimeonTsvetanov/Coding-Lessons
/SoftUni Lessons/Python Development/Python Fundamentals September 2019/Problems And Files/19 EXERCISE OBJECTS AND CLASSES - Дата 25-ти октомври, 1430 - 1730/07. Articles.py
1,507
4.125
4
""" Objects and Classes - Exericse Check your code: https://judge.softuni.bg/Contests/Practice/Index/1734#6 SUPyF2 Objects/Classes-Exericse - 07. Articles Problem: Create a class Article. The __init__ method should accept 3 arguments: title, content, author. The class should also have 4 methods: • edit(new_c...
83b9b2550ab5846af1d641163e2c27a1d5d455ea
luizmariz/cripto
/AL12.1/AL12.1.py
2,504
3.875
4
#Atividade de laboratorio 12.1 from math import sqrt n = input() for x in range(n): numero = input()#calculo da ordem do grupo do numero primo p = numero fi = 1 for y in range(2,int(sqrt(numero)+1)):#existe algum fator em 2<= y <= raizdonumero expoente = 0 while numero%y ...
091ce2f726bcbeb52615bd5a34f4e96cf76b8f18
seunghee63/study_web_python
/web_study_python/syntax/python_study_class.py
2,732
3.65625
4
# coding: utf-8 # In[1]: #self object만의 값 # In[3]: class Person: # class Person의 멤버변수 name = "홍길동" number = "01077499954" age = "20" # class Person의 메소드 def info(self): print("제 이름은 " + self.name + "입니다.") print("제 번호는 " + self.number + "입니다.") print("제 나이는 " + se...
1efaf82d805d4d6e9ce6be477ce50b58a6140bdf
SagarNagarajan/MLproject
/PredictingStudentMarks.py
1,874
4.09375
4
import pandas as pd import matplotlib as plt import sklearn import numpy as np import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split df = pd.read_csv("C:\\Users\\Sagar\\Desktop\\Think42Labs\\student-performance.csv") # ...
d453bd9a2bf15433e5eeed2abdf488e90e216633
davidfv7/TicTacToe
/main.py
3,926
3.5
4
import numpy as np play = True board=[i for i in range(0,9)] print(board) #Funcion para evaluar si el tablero esta lleno def is_board_full(positions): full = True plainPositions = [i for pos in positions for i in pos] for i in plainPositions: if(i ==''): full = False break ...
09a951d4b85fe2c6f2a084ca1101e52d47a797c9
rafaelperazzo/programacao-web
/moodledata/vpl_data/50/usersdata/142/17645/submittedfiles/contido.py
491
3.671875
4
# -*- coding: utf-8 -*- from __future__ import division #função def elementoscomuns (a,b): cont=0 for x in range(0,len(b),1): for i in range(0,len(a),1): if a[i]==b[x]: cont=cont+1 return cont #entradas e programa principal n=input('Digite um valor n:') m=input('...
fc4052524b4a0e98eb77cb3a347af2633211df81
JoaolSoares/CursoEmVideo_python
/Exercicios/ex002.py
305
4.25
4
nome = input('Qual è o seu nome?') print('Estou lisongeado em te conhecer,', nome + '!') print('-> A proxima é uma maneira com o .format que serve para formatar a variavel para encaixar no testo') nome1 = input('qual é o seu nome?') print('Estou lisongeado em te conhecer, {}!' .format(nome))
4b5e38b53111da11c1acbe377e0367f4380c206d
mohamedimmu/100_days_of_python
/day_005/challenge/challennge_5.1.py
350
4.15625
4
# 5.1 Average Height student_heights = input("Input a list of student heights : ").split() student_heights = [int(student_height) for student_height in student_heights] sum_of_height = 0 for student_height in student_heights: sum_of_height += student_height average_height = round(sum_of_height/len(student_heigh...
4600dba0ab1754ad3f7817df8ce71191033edd8d
Nabilabilalla/python_maison
/maison.py
3,822
3.90625
4
from turtle import * # Pour nommer la fenêtre de jeu title("Le jeu du Nabila !") def house(): begin_fill() color('black', 'pink') forward(141) left(90) forward(100) left(45) forward(100) left(90) forward(100) left(45) forward(100) left(90) goto(140, 100,) f...
a5935a432fdc0751637a2ca524982d56688a385b
Skellbags/Previous-Programs
/CS 414/lab09/nim_list.py
1,757
3.9375
4
# 7: Do this last: # Instead of 3 piles with 5 stones each, # ask the user for the number of piles, # and the number of stones per pile. pile_sizes = [] count = 1 num_of_Piles = int(input("How many piles would you like")) while True: num_of_Stones = int(input("Enter the number of stones for Pile")) pile_sizes....
ed936f5f49f560d90192d6abdde0b389aa6e786e
adwardlee/leetcode_solutions
/bfs/0444_graph_valid_treeII.py
2,193
3.84375
4
''' Description Please design a data structure which can do the following operations: void addEdge(int a, int b):add an edge between node aa and node bb. It is guaranteed that there isn't self-loop or multi-edge. bool isValidTree(): Check whether these edges make up a valid tree. Example Example 1 Input: addEdge(1,...
fed1f14b564e5203d2e47a7bddaacad3580076e8
ripingit/python_crawler
/crawler.py
1,675
3.53125
4
#代码来源:https://www.cnblogs.com/xuehaiwuya0000/p/10734004.html # -*- coding: UTF-8 - # 爬取豆瓣网站关于python的书籍,爬虫完一页后,点击后页菜单循环爬虫 # 缺点:逐页点击并获得数据较费时 import time from selenium import webdriver class url_surf(object): def surf_web(self, url): num = 1 driver = webdriver.Chrome("/Users/xjq/Downloads/chromedriv...
a7c40fc28768b463c1e2e8ab5c395a476f5d11e5
majard/prog1-uff-2016.1
/Dice Values.py
305
3.859375
4
import random dice = [] for index in range(10): dice.append(random.randint(1, 6)) numbers = [] for i in range(6): numbers.append(0) for value in dice: numbers[value - 1] += 1 print('Dice outcomes: {}'.format(dice)) print('Times each number was rolled: {}'.format(numbers))
a0371cdc58bf1f651d5e920023d7e66ee4be905b
Mihail-sev/guess-the-number-start
/main.py
1,240
4
4
from random import randint from art import logo print (logo) level = input ("Welcome to GuessHame.\nTry to guess number from 1 to 100.\n Choose your dificult level: 'hard' or 'easy'.\n") rand_number = randint (1, 100) if level == "easy": attempts = 10 else: attempts = 5 user_number = int(input(f"You have {att...
d272d06fe24c55eb16adcb702dfa63bfcb3431d6
mrklyndndcst/100-Days-of-Code-The-Complete-Python-Pro-Bootcamp-for-2022
/Beginner/D002_Understanding_Data_Types_and_How_to_Manipulate_Strings/2.2.BMI_Calculator.py
271
4.0625
4
# 🚨 Don't change the code below 👇 height = input("enter your height in m: ") weight = input("enter your weight in kg: ") # 🚨 Don't change the code above 👆 # Write your code below this line 👇 a = float(height) b = int(weight) print(round(b/a**2))
83c6694ca3eefa4767dbad59c7754681c4306167
spirit1234/location
/python_work/基础/第七章 用户输入和while循环/while处理列表字典.py
1,074
3.828125
4
# -*- coding-utf-8 -*- unconfirmed_users = ['alice', 'brian', 'candace'] confirmed_users = [] while unconfirmed_users: confirmed_user = unconfirmed_users.pop() print('Verifying user: ' + confirmed_user.title()) confirmed_users.append(confirmed_user) print("\nThe following users have been confirmed:") for co...
6320e4d63cf1607045fd7ab8765204153456a7d6
pedrograngeiro/Exercicios-Python
/exercicios cap 3/exercicio 3.6.py
1,154
4.21875
4
# Escreva uma expressão que será utilizada para decidir se um aluno foi ou não aprovado. # Para ser aprovado, todas as médias do aluno devem ser maiores que 7. # Considere que o aluno cursa apenas três matérias, e que a nota de cada uma está armazenada nas seguintes # variáveis: matéria1, matéria2 e matéria3. materia1...
635b1c314f1bd733334a209236f275e55d13d678
fancyQB/utils
/test.py
4,813
3.546875
4
import random import numpy as np from collections import Counter #一行代码实现1-100之间的和 def thesum(): print(sum(range(1,101))) #如何在一个函数内部修改全局变量 a = 100 def fun(): global a a= 10 print(a) #列出5个python标准库 # os sys re math datetime #字典如何删除键和合并两个字典 def de(): A = dict(a=1, b=2) del A['a'] print(A) B = {'name':"zuo...
dd5193c9924d64962533b36a7b7a690004d8206a
marathohoho/leetcode-progress
/200.NumberofIslands/num_of_islands.py
3,088
3.921875
4
""" Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water. Example 1: Input: 11110 11010 11000 00000 Output: 1 Exam...
af633fa5df9a1324ac6b56fd49f03992188740d7
AndriyKhymera/PythonStudy
/Exploration/StringExploration.py
869
4.09375
4
string_1 = "Can use apostrophe easily" string_2 = 'Can\'t use apostrophe by alone' # print(""" # Some multiply words # text # notice that tabs are still here # that means all symbols are included # """) # print("Singe line example") string_1 = "Python" # print("some" "thing") # # print (len("Some ")) # # # F...
8af857612aa1e678d6bfcbdbc285aaaf3b950b38
lmorales17/cs61a
/hw/hw6.py
4,704
4
4
# Name: Luis Morales # Login: cs61a-3w # TA: Sharad Vikram # Section: 120 # Q1. def divide_by_fact(dividend, n): """Recursively divide dividend by the factorial of n. >>> divide_by_fact(120, 4) 5.0 """ if n == 1: return dividend/n return divide_by_fact(dividend / n, n - 1) # Q2. def ...
d1da3baf9053e7c5139df8322daf31fef54cc37f
dhruvarora93/Algorithm-Questions
/Array Problems/prefix to postfix.py
401
3.84375
4
def prefix_to_postfix(string): stack = [] operators = ['+','-','/','*'] for i in string[::-1]: if i not in operators: stack.append(i) else: operand1 = stack.pop() operand2 = stack.pop() temp = str(operand1) + str(operand2) + i stac...