blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
de294c2e235272455548d2b723ca38eba5c5cdc6
2005-smart-programmer/Tic-Tac-Toe
/game.py
5,061
4.53125
5
# We are gonna make a tic-tac-toe app using Python # So let's do this # First we need to make a board board = ['-', '-', '-', '-', '-', '-', '-', '-', '-'] global player player = 'X' global winner winner = 'X' # Now we have to display this board def display_board(): print(board[0] + ' | ' +...
d70c86867376ccb77491b6d1e20c3f1a0b98bfe2
concon121/project-euler
/problem4/answer.py
688
4.3125
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. ZERO = 0 MIN = 100 MAX = 999 def isPalindrome(number): reverse = str(number)[::-1] if (str(numbe...
0311dd559bd1ede8770b0830d55eaee973f35c80
liangsongyou/python-small-games
/tictactoe.py
6,103
4.0625
4
# coding: utf-8 import random def draw_board(board): """ Print out the board that it was passed. "board" is a list of 10 strings representing the board(ignore index 0). """ print(' | |') print(' {0} | {1} | {2}'.format(board[7], board[8], board[9])) print(' | |') print(' 7 8 ...
7af9a74b13af5cc1c52a70970744b0a837bc52ca
cepGH1/dfesw3cep
/convTemps.py
413
4.21875
4
#°F = (°C × 9/5) + 32. #C =(F -32)*(5/9) myInput = input("please enter the temperature using either 'F' or 'C' at the end to show the scale: ") theNumber = int(myInput[:-1]) theScale = myInput[-1] print(theNumber) print(theScale) if theScale == "C": fahrenheit = (theNumber*(9/5)) + 32 print(fahrenheit, "F") if ...
0f86166c773101b04d03a2780b02ac5a5740d630
cepGH1/dfesw3cep
/pyTry.py
1,791
4.0625
4
#print("hello python") #print("I can python") #print("this is another string") #myVar1 = "My first variable" #print(myVar1) #myInput1 = float(input("please enter a number : ")) #myInput2 = float(input("please enter another number: ")) #answer = myInput1 + myInput2 #print(myInput1, "+", myInput2, "=", str(answer) ) ...
246f78f0af85130065705c522666746301e4fb92
balvantghanekar11/python-lern
/c6.py
536
3.59375
4
#tut44 enumerate function list=["bhindi","Aloo","chopsticks","chowmein"] i=1 for item in list: if i%2 is not 0: print(f"Jarvis please buy{item}") i+=1 for index,item in enumerate(list): if i%2==0: print(f"Jarvis please buy{item}") #tut45 import work import sklearn as sk print(sk.__vers...
c1c778ddcb3e5d00461279d382a46f4cb904fd98
balvantghanekar11/python-lern
/c8.py
686
3.84375
4
dromes = ("demigod", "rewire", "madam", "freer", "anutforajaroftuna", "kiosk") palindromes = list(filter(lambda word: word == word[::-1], dromes)) print(palindromes) #exe1 map numbers=["3","44","5"] print(map(int,numbers)) number= list(map(int,numbers)) number[2]=number[2]+1 print(number[2]) #exe2 map num=[1,2,3...
58fc7ca3ba0bf94d524e460a51c58f4fc6a6ccc7
balvantghanekar11/python-lern
/log.py
3,083
3.859375
4
#tut37 def getdate(): import datetime return datetime.datetime.now() def take(k): if k==1: c=int(input("Enter 1 for excersise and 2 for food")) if(c==1): value=input("type here\n") with open("harry-excersise.txt","a") as op: op.write(str([str(getdate...
cdb5dff43e44f80ce8cc79bdc4424b24e06f1094
balvantghanekar11/python-lern
/cal1.py
686
4.21875
4
def operation(op,n1,n2): if op == "+": return n1+n2 elif op == "-": return n1-n2 elif op == "*": return n1-n2 elif op == "/": return n1-n2 elif op == "%": return n1-n2 elif op == "**": return n1**n2 else: print("Wrong Choice") ...
53c19d8f69814b39d4f037e3af00fbcae89c62b3
mateogolf/pythonOOP
/callcenter.py
2,151
3.765625
4
class Call(object): def __init__(self, UID=1, caller="Matt", callerNum="123-4567",callTime=60, callReason="This is a test"): self.UID = UID self.caller = caller self.callerNum = callerNum self.callTime = callTime self.callReason = callReason def display(self): pri...
a7f78ea7ce7d5bfdaf46e2213df3b060963e63d4
MapleLove2014/DataStructureAndAlgorithmAnalysisInCTest
/chapter3_list_stack_queue/reverse_polish.py
1,875
3.53125
4
import re from stack import MyStack num_pat = re.compile(r'\d') operator_priority = { '+' : 1, '-' : 1, '*' : 2, '(' : -1 } def pop_all_not_lower(bit, operators, postfix): while operators.get_size() > 0: ope = operators.pop() if operator_priority[ope] < operator_priority[bit]: ...
9cb08a7918edb7beec42fccfdd38e14936eef2dc
MapleLove2014/DataStructureAndAlgorithmAnalysisInCTest
/chapter3_list_stack_queue/arbitrary_precision.py
2,831
3.8125
4
from linked_list import LinkedList from matplotlib import pyplot as plt from collections import OrderedDict # UNIT = (1 << 10) - 1 # MASK = UNIT BITS = 3 UNIT = 1000 def exponent(base, exponents): if exponents == 0: one = LinkedList() one.add_to_last(1) return one if exponents == 1: ...
2e2f3dabdf84ca1424b1a0295027f2bf89560b69
MapleLove2014/DataStructureAndAlgorithmAnalysisInCTest
/chapter2_algorithm_analysis/prime.py
942
3.59375
4
def is_prime(num): """ trial division """ if num <= 1: return False if num == 2: return True half_root = int(num ** 0.5) for i in range(2, half_root+1): if num % i == 0: return False return True def sieve_erastothenes(N): nums = { n:n for n in ra...
9d11aab5395d89674d09d9138364fc2c78fbf4d5
ziplokk1/BusinessDatetime
/businessdatetime/__init__.py
12,377
4.15625
4
from datetime import datetime, timedelta class BusinessDatetime(object): """ Datetime wrapper used for calculating the number of working datetimes between two datetimes ex: >>> import datetime >>> from businessdatetime import BusinessDatetime >>> dt = datetime.datetime(2016, 6, 6, 8, 30) >...
f505a0fff46edd244a7c3472acf385440b76ae01
salcosser/learningPython
/FizzBuzz.py
542
4.21875
4
# Write a program that prints the numbers from 1 to 100. # But for multiples of three print “Fizz” instead of the number # and for the multiples of five print “Buzz”. For numbers which # are multiples of both three and five print “FizzBuzz”. def fb(): for i in range(100): if i % 3...
b7f91e8de1632763eef919422ee23de27ac7a42c
fiskirton/Artezio-Academy
/Lesson VI/exception.py
293
3.640625
4
""" Simple module for catching exceptions """ N = int(input()) for _ in range(N): try: a, b = map(int, input().split()) print(a / b) except ZeroDivisionError as ex: print(f'Error Code: {ex}') except ValueError as ex: print(f'Error Code: {ex}')
e851d1683ab8051e550f422a53ac4d53e30ec995
fiskirton/Artezio-Academy
/Lesson I/task1.py
120
4.15625
4
input_str = input().split() capitalized_str = " ".join([word.capitalize() for word in input_str]) print(capitalized_str)
06a3e4883fcc9e6927cc23c31869aad8b53f932c
fiskirton/Artezio-Academy
/Lesson I/task6.py
81
3.671875
4
n = int(input()) sqr_dict = {x: x * x for x in range(1, n + 1)} print(sqr_dict)
d32b8b57cb7affc2596b5b336ab0ff5a6be8e4c0
AdePessoa/Intermediate-Python
/Sorteio.py
1,084
3.78125
4
# Importação de bibliotecas from random import randint from time import sleep # Função de Sorteio com Sleep def sorteia(lista): print('Sorteando lista de números aleatórios: ', end='') for cont in range(0,10): # Escolhe 10 numeros no total n= randint(1,100) # Escolhe os numeros de 0 - 100 ...
eb95d7a83615536c9b6821f7167f6bee9e9331cd
elani0/leetcode-python-solutions
/118. Pascals Triangle.py
1,047
3.796875
4
# -*- coding: utf-8 -*- """ Created on Sat Apr 01 15:47:41 2017 @author: Elani """ #118. Pascal's Triangle class Solution(object): def generate(self, numRows): #:type numRows: int #:rtype: List[List[int]] if numRows == 0: return [] elif numRows == 1: ...
40e2873d6bd4790c83e27e356943c3d46b9dd27e
elani0/leetcode-python-solutions
/198. House Robber.py
1,238
3.671875
4
# -*- coding: utf-8 -*- """ Created on Sun Apr 02 16:31:21 2017 @author: Elani """ #198. House Robber """ You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have secur...
dde715521b584b2583296e5603715ffc51f57505
elani0/leetcode-python-solutions
/22. Best Time to Buy and Sell Stock II.py
1,514
3.765625
4
# -*- coding: utf-8 -*- """ Created on Sat Apr 01 15:23:45 2017 @author: Elani Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multipl...
248fd64d55210d11e86fdee6e0e2fc42a2b7a4dc
elani0/leetcode-python-solutions
/2.py
1,141
3.5625
4
# -*- coding: utf-8 -*- """ Created on Sat Mar 04 21:37:45 2017 @author: Elani """ # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def addTwoNumbers(self, l1, l2): """ :type l1: L...
aa31c75c2661571a1c0f77eb2d7c44db640dee38
jasper98/advent-of-code
/day7/solution.py
2,495
3.625
4
# coding: utf8 import re PATTERN = re.compile(r'(?P<program>[a-z]+) \((?P<weight>\d+)\)( -> )?(?P<children>[a-z, ]+)?') def recursive_circus_v1(circuits): """Recursive Circus.""" programs = {} for name in circuits.keys(): programs[name] = 0 for circuit in circuits.values(): if 'child...
e3f921727b144a84ab0927a907554afe773b032a
MayaLu/Learn-Python-The-Hard-Way
/ex21.py
670
4.09375
4
def add(a, b): print "adding %d + %d" % (a, b) return a + b def subtract (a, b): print "subtracting %d - %d" % (a, b) return a - b def multiply(a, b): print "multiplying %d * %d" %(a,b) return a * b def divide (a, b): print "dividing %d/%d" %(a, b) return a / b age = add(int(raw_input()),...
1cb7a726b1074a78252ba83a4b358821fd6f6385
LeoBaz20/Netflix-Style-Recommender
/netflix-style-recommender-master/PythonNumpyWarmUp.py
1,770
4.28125
4
# coding: utf-8 # In[25]: # Handy for matrix manipulations, likE dot product and tranpose from numpy import * # In[26]: # Declare and initialize a 2d numpy array (just call it a matrix, for simplicity) # This how we will be organizing our data. very simple, and easy to manipulate. data = array([[1, 2, 3], [1, 2...
226c41731cf03fa02ce2ba320bdfa089a0c5e6d3
jPoland33/CSS-225
/Problem4Unique.py
313
3.734375
4
#Jaden #11/11/2021 # This code takes a list of numbers and returns it to the user. def uniquel(alist): unique_list = [] for i in alist: if i not in unique_list: unique_list.append(i) return unique_list y = [1, 3, 3, 3, 6, 2, 3, 5, 500, 500,] print(uniquel(y))
9f6cadc84ed5b9b05f9a97919f29e5a3080cde98
brclarkson/cmdb-bootcamp-homework
/day2_HW/Q3.py
471
3.53125
4
#!/usr/bin/env python import pandas as pd import matplotlib.pyplot as plt # I have no headers in my csv file, so I need to specify that so pandas doesn't call the first row a header sxl_df = pd.read_table("/Users/cmdb/cmdb-bootcamp-homework/day2_HW/female_sxl.csv", header = None) plt.figure() # FPKM data is contain...
a2fa1efcd916bb897bd9cee8e9d0357fc77da0cb
brclarkson/cmdb-bootcamp-homework
/day3_HW/day3_HW_transcripts.py
851
3.796875
4
#!/usr/bin/env python import sys from fasta import FASTAReader """ Take out the 100 longest sequences in a FASTA file """ reader = FASTAReader( sys.stdin ) seq_list = [] for sid, sequences in reader: # take the first 30 characters of the gene ids so we know which genes we're looking at. Ta...
d9c90efe77769796e8e71856cda8177c0ae7b9ad
jgarrow/Data-Structures
/binary_search_tree/binary_search_tree.py
7,008
4.21875
4
""" Binary search trees are a data structure that enforce an ordering over the data they store. That ordering in turn makes it a lot more efficient at searching for a particular piece of data in the tree. This part of the project comprises two days: 1. Implement the methods `insert`, `contains`, `get_max`, and `for...
616a17eb50e73be631a73b7ef1ace3f3ea1cbfd1
alexpfernandes/adventofcode2020
/advent-day-06.py
1,460
3.71875
4
# This will open a text file, split it into a list of each line file = open('aoc6.txt',newline='') questions = file.read().splitlines() file.close() # This will parse the list of individual question responses into a parent list of parties, with child lists of individuals def questionparser(questions): group = [] ...
467dbe695b066c1b17caff99d0112ab215fd1559
matthijsvk/codewars
/python_IQTest.py
748
4.03125
4
# CODEWARS PROBLEM 1: IQ TEST #PROBLEM 1 : find the odd number in the even sequence or vice versa def iq_test(numbers): numbers= numbers.split(" ") logging.debug(numbers) nb_odd = int(numbers[0]) % 2 + int(numbers[1]) % 2 + int(numbers[2]) % 2 logging.debug(nb_odd) if nb_odd >=2: #sequence ...
3070a54293cfc8331fd0b62f3acbe562cb800eb3
Korfeusz/DESY_photon_pulse_property_predictor
/beam_profile_metadata/tools/tools.py
659
3.546875
4
import numpy as np def get_indices_of_n_lowest_values(array_of_values, number_to_find): best_positions_unsorted = np.argpartition(array_of_values, number_to_find)[:number_to_find] best_values_sorted_indices = np.argsort(array_of_values[best_positions_unsorted]) return best_positions_unsorted[best_values_s...
32f0d6f2d2db502bbfe897d3e74c11563c639a6f
Annu86/learn_Python
/anu_ex1.py
420
3.796875
4
print("Hi, I am new to python") print("hello again") print("What else can I learn here") print("i like typing this.") print("yay! I can print 'anything'") #trying single quotes outside and double inside print('anything "specific"') #worked a = 10 b = 6 c = 'philly ' d = ' * New York * ' print(c) print(c* a) print(d* 6)...
a0c0f8f6df218174460ece178e34a090775f0ccc
Annu86/learn_Python
/anu_ex8.py
824
4.125
4
# Membership and Bitwise Operators #Membership in and not in a = 14 b=10 list = [11, 12, 14, 15, 16, 17] print('a is present in the list:', a in list) print('b is present in the list:', b in list) if(a in list): print('a is present in the list') if(b not in list): print('b is not in the list') #Bitwise ...
52b9c167b058db6092d8f6b5dc760a306cc9b608
jdellithorpe/scripts
/percentify.py
1,497
4.15625
4
#!/usr/bin/env python from __future__ import division, print_function from sys import argv,exit import re def read_csv_into_list(filename, fs): """ Read a csv file of floats, concatenate them all into a flat list and return them. """ numbers = [] for line in open(filename, 'r'): parts ...
241e9a101eb282b3ddab3dd565082f4bcddbfe37
Scarletcurve188/Crypto-Encryption-and-Decryption-Tools
/ScytaleCipher/ScytaleCipher.py
2,778
4.09375
4
# Tolga AKKAPULU # /tolgaakkapulu # -*- coding:utf-8 -*- import math print(""" ############################### Scytale Cipher ################################### # In cryptography, a scytale is a tool used to perform a transposition cipher, # # consisting of a cylinder with a strip of parchment wound around it on ...
d2509fe614c199d9ba7352645314d98e2bfbea3c
ThomasKramp/RaspBerryPi_Pong
/Testjes/button.py
578
3.703125
4
import tkinter as tk class Button(object): def __init__(self, canvas, coords, fill, text, command): self.canvas = canvas self.button = tk.Button(canvas, text=text,command=command) self.button.place(x=175, y=100) if __name__ == "__main__": def x(): global xb print(xb...
7dbb32e48337cd258ae8d7ca2bc652d094b4cf30
ThomasKramp/RaspBerryPi_Pong
/PongUpload/ClientSide/Label.py
855
3.6875
4
import tkinter as tk class Label(object): def __init__(self, canvas, coords, text): self.canvas = canvas self.text = tk.StringVar() self.text.set(text) self.label = tk.Label(canvas,textvariable=self.text) self.label.place(x=coords[0], y=coords[1]) def changeText(sel...
a4bd50b4ac26814d745411ca815aa8115c058d0c
bettymakes/python_the_hard_way
/exercise_03/ex3.py
2,343
4.5
4
# Prints the string below to terminal print "I will now count my chickens:" # Prints the string "Hens" followed by the number 30 # 30 = (30/6) + 25 print "Hens", 25 + 30 / 6 # Prints the string "Roosters" followed by the number 97 # 97 = ((25*3) % 4) - 100 # NOTE % is the modulus operator. This returns the remainder ...
a1bf907f6e4ec29dfd1c6f81f1a3831470664681
copyNdpaste/HackerRank
/Practice/Interview Preparation Kit/String/Special String Again.py
1,360
3.90625
4
#!/bin/python3 import os def substr_count(n: int, s: str) -> int: count = n for i in range(0, n): even_before = i even_after = i + 1 odd_before = i - 1 odd_after = i + 1 count = count_palindromes( count=count, even_before=even_before, ...
056edddfead012216e20b012483d92ab177fcf60
kidword/spider
/数据去重/csv去重.py
1,033
3.5
4
import pandas as pd # 将new_flight 数据删除不需要列 # 合并两个list 然后读取csv文件数据,转化成list,在对数据进行去重操作,保存到csv文件 read = pd.read_csv(r'D:/new_flight.csv') def read_csv(file_name): f = open(file_name, 'r',encoding = 'utf-8') content = f.read() final_list = list() rows = content.split('\n') for row in rows: fina...
b0c0f56c46b20e529b8d2b0023fe63bec81d9b12
pr4nshul/CFC-Python-DSA
/Codes/Doubt session 4/search_rot_arr.py
556
3.703125
4
def search_rotated(arr,key): start,end= 0,len(arr)-1 while start<=end: mid = start+ (end-start)//2 if arr[mid] ==key: return mid if arr[start] <= arr[mid] : if key >arr[start] and key < arr[mid]: end = mid-1 else: ...
f0a567bdbc9496bde8fa4f283b47e4d7ffc2ded6
Namooro/tasks
/rats_and_poison/rats_and_poison.py
2,607
3.796875
4
import doctest import math from random import randint class RatsAndPoison: """ This class describes a solution for the rats and poison problem. The default amount of numbers of rats is 3, and the number of bottles where only one is poisoned is 8. The assumption is that the task requires only one day a...
a180130c264deebbe5d7d6f781ff18b65ce5a90f
kwilson7770/Python-HexViewer
/HexViewer.py
2,690
4.03125
4
import argparse # This is my custom function to convert the hexadecimal values into their ASCII characters. # I don't include any control characters or spaces def getASCIIChars(rawHex): toReturn = "" for i in rawHex.split(): exclamationPoint = 33 tilde = 126 if int(i, 16) >= exclamatio...
fb4089bcce2764ddd695f378f9911c1374ee911b
jxq0816/psy_learn_python
/diamond.py
241
4.25
4
#请输入一个奇数,打印出一个行数为奇数行的菱形 n=int(input("number=?")) for i in range(1,n+1,2): string_1="*"*i print(string_1.center(n)) for i in range(n-2,0,-2): string_1="*"*i print(string_1.center(n))
c13914935b43f39ebf3db4f04d335328be75c5f8
jxq0816/psy_learn_python
/data_type.py
270
3.953125
4
a=2 a=str(a) print("a的值是=",a,"a的类型是:",type(a)) a=float(a) print("a的值是=",a,"a的类型是:",type(a)) a=int(a) print("a的值是=",a,"a的类型是:",type(a)) b=3 print("a==b",a==b,type(a==b)) print("a>b",a>b,type(a>b)) print("a<b",a<b,type(a<b))
22ce1f9b4482fe7097f3bd08a2b007e5060d01e9
AmbujaAK/practice
/python/tools/useList.py
519
3.796875
4
import sys # use iter() and next() lst = [int(item) for item in input().split()] print(lst) ''' # print all elements i = iter(lst) while True : try : print(next(i),end=' ') except StopIteration: sys.exit() ''' ############### methods # append() print("Enter the elements in list : ") n = int...
2445d8b96c8dc3af3b4f4fdcd05c3fdcc4d53ea2
AmbujaAK/practice
/ds/file/storeMatrixFromFile.py
222
3.59375
4
def readMatrix() : file = open('textFile/matrix.txt') matrix = [] for line in file : matrix.append(line) for item in matrix : print(item,end='') if __name__ == '__main__': readMatrix()
9d974a2303335e4416411a7b8f145edc5d7b7d21
AmbujaAK/practice
/python/ShortestToChar.py
1,069
3.671875
4
def shortestToChar(S,C): l = [] ci = S.find(C) for i in range(len(S)): print("string now is : " , S[i:]) print("find e : ",S[i:].find(C)) if i > ci and S[i:].find(C) >= ci : ci = S[i:].find(C) print('i :',i) print("ci : ",ci) ele = abs(ci-i...
1ae7293dc3f05b0c526e4fdbd7842cef7d903fa0
AmbujaAK/practice
/python/tools/binary.py
148
3.953125
4
print("Enter any integer : ") num = int(input()) print("Binary of the given integer will be : ") binary = bin(num) print(binary) print(len(binary))
8f8d6e84c1a173348e1062608a17c71aa1b5408d
AmbujaAK/practice
/ai/assgn7/BFS.py
1,128
3.84375
4
from collections import defaultdict class Graph: def __init__(self): self.graph = defaultdict(list) def addEdge(self,u,v): self.graph[u].append(v) def printMatrix(self): for i in self.graph: for j in self.graph[i]: print(self.graph[i][j]) print() def B...
65a31990ab5786e2e7135bbac8649ec64adcb892
AmbujaAK/practice
/python/rotateMatrix.py
460
4
4
def rotate(arr): tup = zip(*arr[::-1]) return [list(item) for item in tup] #matrix = [[1,2,3],[4,5,6],[7,8,9]] #print(matrix[1][1]) print("Enter the n,m,f :") #f = int(input()) n,m,f = map(int,input().split()) mat = [[int(input()) for x in range(n)] for y in range(m)] #mat = [[1,2,3],[4,5,6],[7,8,9]] mat1 = l...
cd542d4491a14d5f3c8c4ae9f840975c6ad04e45
AmbujaAK/practice
/python/nptel-Aug'18/quiz4/ques1.py
142
3.578125
4
def mystery(l): if l == []: return (l) else: return (l[-1:] + mystery(l[:-1])) l = [13,23,17,81,15] print(mystery(l))
29d52543ea68404abe7bef2ff3e0f7a3b9524261
AmbujaAK/practice
/python/filter.py
279
3.640625
4
arr = [int(item) for item in input().split()] print(list(filter((lambda x: x > 0), arr))) a = (1,2,4,6,8,0,10) b = (2,6,4,-4,0,9,7) print(list(filter(lambda x: x in a,b))) ########filter######### # it take two arguments # one is function and other may be list,tuple (iterable)
77ff1d18e2d88269716f2eda2e09270d78d39840
eckoblack/cti110
/M5HW1_TestGrades_EkowYawson.py
1,650
4.25
4
# A program that displays five test scores # 28 June 2017 # CTI-110 M5HW1 - Test Average and Grade # Ekow Yawson # #greeting print('This program will get five test scores, display the letter grade for each,\ \nand the average of all five scores. \n') #get five test scores score1 = float(input('Enter test s...
40867a0b45d2f9f37f5d4bcfe0027bd954c82c36
eckoblack/cti110
/M6T1_FileDisplay_EkowYawson.py
451
4.1875
4
# A program that displays a series of integers in a text file # 5 July 2017 # CTI-110 M6T1 - File Display # Ekow Yawson # #open file numbers.txt def main(): print('This program will open a file named "numbers.txt" and display its contents.') print() readFile = open('numbers.txt', 'r') file...
27072ca954bec86f409d1bece278fdaa67311fa6
eckoblack/cti110
/M5T2_FeetToInches_EkowYawson.py
718
4.0625
4
# A program that converts feet to inches # 26 June 2017 # CTI-110 M5T2_FeetToInches # Ekow Yawson # #define main def main(): print('This program will convert feet values you input into inches.') print() feetToinches() def run_again(): again = input('Would you like to convert ...
d5e2204d1e6cec1f4aeba47d86fd52a5e062b29c
ocean20/Python_Exercises
/fileIO/openClose.py
540
3.59375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Jun 29 14:35:40 2019 @author: cawang """ # open file fo = open("testFile.txt", "w+") print("Name of file:", fo.name) print("Opening mode:", fo.mode) fo.write("This is a line of text") # this rewrote what was in the file # ouptputs the number of charac...
4fdb7741fa84ad336c029825adf0994f174aaa2b
ocean20/Python_Exercises
/functions/globalLocal.py
602
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Jun 23 16:41:56 2019 @author: cawang """ x = 2 def fun1(): x = 1 print("Inside function x =", x) fun1() # Inside function x = 1 print("Outside function x =", x) # Outside function x = 2 def fun2(): print("Inside function x =", x) fun2() ...
c1a9218f3beffdc90acb16c2cf5a5302be80d3fc
ocean20/Python_Exercises
/exceptions/checkNum3.py
464
3.96875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Jun 29 18:52:06 2019 @author: cawang Instead of printing your own message, print the default error message """ x = input("Enter a number: ") num_x = int(x) y = 100 try: z = y * 1.0 / x print("Z is {}".format(z)) except ZeroDivisionError as ...
2e773e2cbfb1e0d5746d2cb1066d6b2e8d0a4c5c
fseimb/moviebot-1
/moviebot/nlu/annotation/semantic_annotation.py
2,476
3.75
4
"""Semantic annotation is annotation that stores certain insight from text. Some text can have many such annotatins. """ from typing import Text, Optional from enum import Enum from moviebot.nlu.text_processing import Span class AnnotationType(Enum): """Types of annotations""" NAMED_ENTITY = 0 TEMPORAL...
9617a580441c6785e837d8edfe9b8331173963eb
plammfish/HackBulgaria-Programming101
/week0/is_int_palindrome/solution.py
232
3.875
4
def is_int_palindrome(n): n = abs(n) return n == reverse(n) def reverse(n): result = 0 n = abs(n) while n != 0: work = n % 10 result = result*10 + work n = n // 10 return result if __name__ == '__main__': main()
7c2216403111634f822f9961402d7c47b4f6a26e
simgesaricayir/Cse-321-Algorithm-Design-And-Analysis
/hw5/part2.py
420
3.859375
4
def OptimalPlan(ListNy,ListSf,M): PlanN,temp,PlanS= ListNy[0],ListNy[0],ListSf[0] for i in range(1,len(ListNy)): PlanN = ListNy[i] + min(temp,M+PlanS) PlanS = ListSf[i] + min(PlanS,M+temp) temp = PlanN return min(PlanN,PlanS) ListNy = [10,5,10,5] ListSf = [5,10,5,10] print(OptimalPl...
ec713f1b19f90d8975d1df10a711ef20bc0e9dfe
NJHu/Python
/Book/数据可视化/highs_lows.py
723
3.546875
4
import csv from matplotlib import pyplot def main(): filename = 'sitka_weather_history_2014.csv' with open(filename) as file: reader = csv.reader(file) header_low = next(reader) highs = [] for row in reader: if len(row) > 0: highs.append(row[...
41d2b9551fd3d429549fae8c3cfe967aa87e9cc0
The-Flash/clui-python
/inquirer.py
895
3.5
4
from PyInquirer import prompt questions = [ { "type": "list", "name": "favorite_language", "message": "What is your favorite programming language?", "choices": ["Python", "Javascript", "Java", "C++"] }, { "type": "checkbox", "name": "top_languages"...
e044c9f60c9081221313fd527521406feba12c84
SAGNIKMJR/autoweb
/wge/cache.py
1,366
3.859375
4
class Cache(object): """Provides a set of APIs for caching.""" def __init__(self): self._cache = dict() def uncached_keys(self, keys): """Returns a list of the keys that are not cached in the same order as keys. Args: keys (list[Hashable]) Returns: ...
28bf46ca0222b8365920e445c6e85d78dd2ae452
Caiovg/Algoritimos-de-Ordenacao-e-Busca
/heap_sort.py
1,049
4.125
4
def heap_sort(data): length = len(data) index = length // 2 parent = 0 child = 0 temp = 0 while True: if index > 0: index -= 1 temp = data[index] else: length -= 1 if length == 0: return temp = data[lengt...
becd9e1a85e5c8774980e8cecf3eafdf65226f31
Caiovg/Algoritimos-de-Ordenacao-e-Busca
/bucket-sort.py
1,171
3.78125
4
def insertion_sort(vetor): for i in range(1, len(vetor)): chave = vetor[i] aux = i - 1 while aux >= 0 and vetor[aux] > chave: vetor[aux + 1] = vetor[aux] aux -= 1 vetor[aux + 1] = chave return vetor def bucketSort(x): arr = [] slot_num = 10 for i in ...
1cf238e00055a462513aa9e60ed029681b2679f5
chencoming/python-demo
/reference.py
279
4.09375
4
#!/usr/bin/python list = ['first','second','third','forth','fifth','sixth'] newlist = list del list[0] print 'list is ', list print 'newlist is ', newlist # make a copy by doing a full slice mylist = list[:] del list[0] print 'list is ', list print 'mylist is ', mylist
4514fdd464588483e356ced32030d9f3dbc881e1
snowdence/hcmus_ai_lab_pl_resolution
/exp.py
1,216
3.625
4
class ExprItem: encode_val = -1 label_variable = "*" op = "+" def __init__(self, variable): variable = str(variable) if variable != None: if variable[0] in ["-", "+"]: # negative self.op = variable[0] self.label_variable = vari...
30f36be3d0fbe3105c4a29a5e770ceab051505c9
henriquelorenzini/EstruturasDeDecisao
/Exercicio24.py
1,184
4.3125
4
# Faça um Programa que leia 2 números e em seguida pergunte ao usuário qual operação ele deseja realizar. O resultado da operação deve ser acompanhado de uma frase que diga se o número é: # par ou ímpar; # positivo ou negativo; # inteiro ou decimal. numero1 = float(input("Digite o número 1: ")) numero2 = float(input("...
a8f0b493d291147afa08f2e699112412f5ccbeb9
henriquelorenzini/EstruturasDeDecisao
/Exercicio15.py
1,180
4.3125
4
# Faça um Programa que peça os 3 lados de um triângulo. O programa deverá informar se os valores podem ser um triângulo. Indique, caso os lados formem um triângulo, se o mesmo é: equilátero, isósceles ou escaleno. # Dicas: # Três lados formam um triângulo quando a soma de quaisquer dois lados for maior que o terceiro; ...
921035af4cf9beef9eea8661aab63cbd26477227
henriquelorenzini/EstruturasDeDecisao
/Exercicio06.py
586
4.125
4
#Faça um Programa que leia três números e mostre o maior deles. print('Veja qual dos três números é maior') num1 = float(input('Digite o primeiro valor: ')) num2 = float(input('Digite o segundo valor: ')) num3 = float(input('Digite o terceiro valor: ')) if num1 > num2 and num1 > num3: print('O número {:.2f} é ma...
54d7e6446e8c7306e11db074207531b9ad875d22
jonesal5/Users-with-accounts
/users_with_bank_accounts.py
1,960
4
4
Class User: def __init__(self, name, email, int_rate, balance): self.name = name self.email = email self.account = BankAccount(int_rate=0.00, balance=0) def make_deposit(self, amount): self.account.deposit(amount) return self def make_withdrawal(self, amount): self.account...
128039caec432553bb36875e92b86d6578175728
AndreasGustafsson88/assignment_1
/assignments/utils/assignment_1.py
1,179
4.46875
4
from functools import lru_cache """ Functions for running the assignments """ def sum_list(numbers: list) -> int: """Sums a list of ints with pythons built in sum() function""" return sum(numbers) def convert_int(n: int) -> str: """Converts an int to a string""" return str(n) def recursive_sum(...
2f09a7410c0aed71f3e43fbcf01069cc1329673a
tapasya234/MasterComputerVision
/Section3/Lecture3.6+-+Cropping.py
641
3.59375
4
# coding: utf-8 # In[3]: import cv2 import numpy as np image = cv2.imread('images/input.jpg') height, width = image.shape[:2] # Let's get the starting pixel coordinates (top left of the cropping rectangle) start_row, start_col = int(height * 0.25), int(width * 0.25) # Let's get the ending pixel coordinates (botto...
d48a7f13d05b9e5c3f955873c5185258b8d05a04
KarlVaello/python-programming-challenges
/SpaceArrange_PPC2.py
1,974
4.15625
4
from random import randint import math from Point import Point # def that sort an array of points (bubble algorithm) def bubbleSort(alist): n = len(alist) for i in range(len(alist)-1): swp = False for j in range(len(alist)-1): if (alist[j][2] > alist[j+1][2]): tempPo...
ef674839cb01af7c8e19c0402d42ab2f890de992
soufal/python_datastructure
/python_datastructure/stack_operation.py
718
3.671875
4
#!/usr/bin/env python3 from stack import Stack def matches(open, end): opens = "([{" ends = ")]}" return opens.index(open) == ends.index(end) def parCheck(symbString): s = Stack() temp = True for i in symbString: if temp == True: if i in "([{": s.p...
fef49248066e919f4b1bf78ac6f7d7ba0919e068
AGCapdeville/Film-Prediction-Machine
/helpful/midterm/COMP478_Midterm_2_Part_2.py
3,671
4.5625
5
# Adam Capdeville # Isaac Garza # ========== Question 1 ========== # ### Part A: ### ''' Briefly explain what this method is. Explanation: Principal Component Analysis (PCA) is a technique for extracting the most important features from a dataset. PCA does this through linear dimensionality reducti...
6c0ff9386eac9d05a4bd3abcdc0d5185acd7ccd9
JonSeijo/project-euler
/problems 80-89/problem_80.py
861
3.828125
4
# Problem 80 # Square root digital expansion """ It is well known that if the square root of a natural number is not an integer, then it is irrational. The decimal expansion of such square roots is infinite without any repeating pattern at all. The square root of two is 1.41421356237309504880..., and the digital sum ...
e7caa4f77e395995056f6020b8e9178f11b8e763
JonSeijo/project-euler
/problems 50-59/problem_52.py
1,172
3.828125
4
# Permuted multiples # Problem 52 """ It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order. Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits. """ def isPermutation(number1, number2): # Not permut...
7d37abd2c0b0befa66dd882874135bea99834ca7
JonSeijo/project-euler
/problems 70-79/problem_73.py
981
3.9375
4
# Problem 73 # Counting fractions in a range """ How many fractions lie between 1/3 and 1/2 in the sorted set of reduced proper fractions for d <= 12,000? """ def main(): """ Recorro todos los posibles valores de d, y recorro todos los valores de n en un rango acotado 1/3 < n/d < 1/2 <---> d/3 <...
fd50491b2f67bc3b76ff3b1b5391952b0bed92eb
JonSeijo/project-euler
/problems 1-9/problem_1.py
825
4.34375
4
#Problem 1 """ If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. """ MAXNUM = 1000 def findMultiples(number): """Return a list with the multiples of the number, betw...
65d1972d9b415a535a78821445c05ceb340e3866
JonSeijo/project-euler
/problems 10-19/problem_16.py
505
3.984375
4
# Power digit sum # Problem 16 """ 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 2^1000? """ def main(): """Very easy in python. In other languages the magnitude of the number would be a big problem. For now, I won't bother in solving the ...
ec2a73d8147e75ab14f1453c16295bb50e52a58e
JonSeijo/project-euler
/problems 50-59/problem_57.py
1,689
4.125
4
# -*- coding: utf-8 -*- # Square root convergents # Problem 57 """ It is possible to show that the square root of two can be expressed as an infinite continued fraction. √ 2 = 1 + 1/(2 + 1/(2 + 1/(2 + ... ))) = 1.414213... By expanding this for the first four iterations, we get: 1 + 1/2 = 3/2 = 1.5 1 + 1/(2 + 1/2)...
7722dc7620f4850a5e4b2d1091b075c1ed7b797e
JonSeijo/project-euler
/problems 10-19/problem_18.py
2,136
3.765625
4
# Problem 18 # Maximum path sum 1 """ By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. 3 7 4 2 4 6 8 5 9 3 That is, 3 + 7 + 4 + 9 = 23. Find the maximum total from top to bottom of the triangle """ # tri will contain the 'tria...
0e7ca8a8f7a8976c31606e4bf4af1535dbaaa124
JonSeijo/project-euler
/problems 10-19/problem_12.py
2,123
4
4
# Highly divisible triangular number # Problem 12 """ The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... Let us list the factors of the first seven tria...
2c05a5eb643ee36b8e1f9138cc739f830a29c969
MdAman02/problem_solving
/search/binary_search/codeforces/F1324D/Solution.py
616
3.546875
4
# problem name: Pair of Topics # problem link: https://codeforces.com/contest/1324/problem/D # contest link: https://codeforces.com/contest/1324 # time: (?) # author: reyad # other_tags: sortings, two pointers, data structures # note: this problem can be solved in various ways, so there are so many tags ...
06da5fa654f7ad20c5c5c7d10058a847bf5fe1bf
AppliedAlpha/BOJ
/Submitted/13xxx/13705.py
1,415
3.8125
4
from decimal import * getcontext().prec = 200 getcontext().rounding = ROUND_HALF_UP pi = Decimal('3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446...
a0833a8d5905c2c787fa787fbf7921c7a723d9a5
lovelinklife/Algoritmi_di_crittografia-2019
/RSA_didattico.py
2,442
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue May 7 12:00:26 2019 @author: mauro """ def extended_euclid(x,y): ''' Implementa l'algoritmo di Euclide esteso ''' if y==0: return x,1,0 d,a,b = extended_euclid(y, x%y) return d,b,a-int(x/y)*b def modexp(x,y,n): '''...
a5e7fef0822f1da9393fcbda4adc5b6599729f9b
kamni/jackson-expert-systems
/chapter_02/moving_blocks.py
9,641
4.21875
4
""" The problem in the book is stated as 'missionaries and cannibals', and the alternate name for the problem is 'jealous husbands'. Both of these framings are problematic, so we're just going to reword it as a blocks game. The rules are as follows: - You're a small child that has a pile of 3 red and 3 blue blocks. - ...
c097c70c4735269c74ec34b7900748a85e0cda83
grant-create/100daysofcode
/day5/pw_gen.py
1,638
3.796875
4
import random chars = [ ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'], ['0', '1', '2', '3', '4', '5', '6'...
ea28fe108231a6238a72551a62b3b287f3cd9597
grant-create/100daysofcode
/day18/main.py
680
3.609375
4
# made in jupyter notebook # doesnt seem to work in vscode import turtle as t from turtle import Screen screen = Screen() screen.screensize(200,150) # Setting the screen color-mode t.colormode(255) import random tim = t.Turtle() tim.shape('turtle') def random_color(): r = random.randint(0,255) g = random...
dda55321f57c7049ab75245018e3368757cb6fa8
RafaelHuang87/Leet-Code-Practice
/95.py
928
3.953125
4
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def generateTrees(self, n: int) -> [TreeNode]: if n == 0: return [] def generateTreesDFS(left, right): if ...
6c47f00dbaf67a8ce437e3276e092e4d4d86f3aa
RafaelHuang87/Leet-Code-Practice
/449.py
1,213
3.6875
4
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Codec: def serialize(self, root: TreeNode) -> str: """Encodes a tree to a single string. """ l = [] def preOrder(root): ...
b20b744ac4fc131dbe7b782144316abb9ecaffe2
RafaelHuang87/Leet-Code-Practice
/79.py
898
3.640625
4
class Solution: def exist(self, board: [[str]], word: str) -> bool: def find(board, word, i, j, m, n): if word == '': return True if i < 0 or i >= m or j < 0 or j >= n: return False elif word[0] == board[i][j]: board[i][j] ...
16edf348b9ae096de3b6e90e1b0dead18d03f5c6
RafaelHuang87/Leet-Code-Practice
/212.py
1,405
3.921875
4
class Trie(object): def __init__(self): self.root = dict() self.isword = False def insert(self, word): """ Inserts a word into the trie. :type word: str :rtype: void """ curNode = self.root for i in word: if i not in curNode.ro...
bd1a9cacd91d987af893b1b9cdd6e4283b0e8ba8
RafaelHuang87/Leet-Code-Practice
/19.py
911
3.796875
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: pre = head length = 0 while pre: pre = pre.next length += 1 ...
1586219fcde4e7ded37c7a50124fe6918058c583
RafaelHuang87/Leet-Code-Practice
/124.py
698
3.8125
4
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def maxPathSum(self, root: TreeNode): self.re = -pow(2, 31) self.recursion(root) return self.re def recursion(self, ...