blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
cfec03a0908552f93623cbc75b5f7705e6dd0374
aleksanterif/python-blackjack
/blackjack.py
7,736
4.0625
4
#random will offer me a great way to randomly select cards and shuffle deck import random # We should be able to tell if the user is playing userPlaying = True class Bet: def __init__(self): self.betValue = 0 self.amount = 500 #defining of the amount and bet might be better for the u...
e18bc24739e371e5af10c1feac8f6083c4d72508
Aasthaengg/IBMdataset
/Python_codes/p03828/s908609186.py
740
3.5
4
import sys def I(): return int(sys.stdin.readline().rstrip()) N = I() mod = 10**9+7 import math def sieve_of_eratosthenes(n): prime_list = [] # n以下の素数のリスト A = [1]*(n+1) # A[i] = iが素数なら1,その他は0 A[0] = A[1] = 0 for i in range(2,math.floor(math.sqrt(n))+1): if A[i]: prime_list.ap...
6357850112b7df68b556b0268f5ca5d0f722eeec
NarasimhaReddy13/2.python
/gcd-lcm.py
1,172
3.671875
4
# Greatest Common Divisor -- max number which divides the given numbers a = 2 b = 4 if a>b: max_num = a else: max_num = b gcd = max_num for i in range(1, gcd +1): if (a%i == 0 and b%i == 0): gcd = i print("GCD", gcd) #LCM --- 1st or Least common multiple -- which exactly divides the number ...
5b779a6a7661d2a71fcc536d464f3f1bd9c59ed8
Sytx74/LeetCode-Solution-Python
/09-动态规划/0198-打家劫舍(滚动数组).py
502
3.515625
4
# 参考资料:https://blog.csdn.net/Koala_Tree/article/details/80015066 class Solution: def rob(self, nums): """ :type nums: List[int] :rtype: int """ n = len(nums) if n == 0: return 0 if n <= 2: return max(nums) pre = nums[0] ...
fd55fe7bc542f8f30202c247d4cb6e1cd5276ee9
afsana1210/python-learning
/forin.py
53
3.640625
4
mylist=[1,2,3,4,5] for num in mylist: print(num)
d7877a377352d4451cfc66adfa937fccd80c2175
bokukko7/AOJ_AtCoder
/AtCoder/ABC182/C.py
840
3.765625
4
def readinput(): n=int(input()) return n def main(n): list_n = list(str(n)) count1=0 count2=0 sum=0 for c in list_n: if c in ('1', '4', '7'): count1+=1 elif c in ('2', '5', '8'): count2+=2 sum += int(c) if sum < 3: return -1 ...
8ad123d463722bcfc02c7ddb463a65c61aac7710
harshVRastogi/python-examples
/src/exercise5-input/ReadingInputs2.py
677
4.3125
4
# using raw_input(message) you can also show a prompt message seconds = raw_input("How many seconds are there in a minute?") minutes = raw_input("How many minutes are there in an hour?") hours = raw_input("How many hours are there in a day?") print "There are %s hours in a day, " % hours, print "%s minutes in an hour...
8d8f1c005a8e2d1e6d4eab0ec48b0ed79829c6ba
rvillalta/PyClass
/hello.py
680
3.5625
4
for i in range(2): #var = str(i*10) + " Hola Mundo" print("el numeros es {}".format(i)) print("Termine !!") ASD = 1.123456789 class Persona: def __init__(self, _nombre, _edad): self.nombre = _nombre self.edad = _edad def getInfo(self): print("Hola, me llamo {0} y tengo {1} anos".format(self.nombre, s...
8d5e9edf21c062ac91c3f826c81c3c80d2430741
irekizea/machine-learning-learning
/stanford-cnn-course-code/cross_ent_loss.py
3,657
3.84375
4
"""Implementation of the Cross Entropy loss. Source: http://cs231n.github.io/linear-classify/ """ import typing as t import numpy as np import scipy.special def cross_ent_loss(X: np.ndarray, y_inds: np.ndarray, W: np.ndarray, b: t.Optional[np.ndarray] = None,...
05eab2bad5f3c3f63e21afcc0a2ea3fd80d1bc07
ys012313/p2_201611105
/w13Main_2.py
753
3.703125
4
import os import turtle wn=turtle.Screen() t1=turtle.Turtle() aFile=input("Filename") def getCoordsFromFile(aFile): fin=open(aFile,'r') coords=[] for line in fin: line1=line.split(',') aRect=[(line1[0],line1[1]),(line1[2],line1[3].strip())] coords.append(aRect) ...
03ab2cb6fcdd7550e01084b9e870dc5c3e6c5211
TheGoldenKyle/Scrabble
/src/helpers/Managers.py
9,415
3.71875
4
import random import pygame from src.entities.Entities import Tile from src.game.constants import * class WordManager: def __init__(self): file = open('resources/dictionary.txt', 'r') self.words = list(file.read().split()) def check_word(self, word): """ Checks if string is...
c564cffce2c369750a4527ff81e41727ca50a4f2
ALabInTheLab/AutoEssayGrading
/Xinyi/SahilC_AutoEssayGrading/src/Node.py
1,185
3.53125
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 29 22:07:18 2016 @author: Pranav """ class Node: def __init__(self, column = None, split_value = None, left_child = None, right_child = None, result = None): self.column = column self.split_value = split_value self.left_child = left_child ...
694c8b06acaf98dac954b8e5cbc5e4084cb1807b
degtrdg/math-team
/queue.py
876
3.875
4
class node(): def __init__(self, item=None): self.item = item self.next = None self.prev = None class queue(): def __init__(self): self.head = None self.tail = None self.size = 0 def enqueue(self, item): new_node = node(item) if(self.size...
6faff284e08697323b256c8be9bb522c69d7c36e
gauravaror/programming
/isSummetric.py
705
3.828125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def isMirror(self, root1, root2): if (root1 == None and root2 == None): return True ...
486a3cd917ab72bc5dba0c4fd4aa217631765f74
dawidpacia/vistula-selenium-appium
/basics/python_structures.py
663
3.609375
4
class MathOperations: def add_numbers(self, a, b): result = a + b return result def multiply_numbers(self, a, b): result = a * b return result def divide_numbers(self, a, b): result = a / b return result calculator = MathOperations() def test_positive():...
09fca880f1278bbe5b9d0a8cd9c3f50fbb1c0c64
kanhataak/opencv-python
/OpenCV_python/1_opencv_ReadImage.py
345
3.6875
4
# how to read an image... import cv2 # here we fatch image but we do not see a image, we will see matrix format # store the image pixel value im image variable image=cv2.imread("pic.png") cv2.imshow("Output Image",image) # frame name " output image" # waitkey is function that will wait of press any key cv2.waitKey(0)...
dd75c7318584ac48acaa2f65d98e57c10118f7ac
basin87/python08062021
/lesson_3/task_5.py
336
3.8125
4
#Задание №5 import random random_number = random.randrange(1, 10) attempt = 0 amount_of_attempts = 3 while amount_of_attempts > attempt: users_input = int(input("Enter a number in range from 1 till 10: ")) attempt += 1 if users_input == random_number: print("You won!") else: print("You ...
88f56ed72402f162e229dddd7372950ea9fd2433
chris10son/mittprojekt
/bank.py
3,826
3.796875
4
import sys import os import getpass print("Login") def search(username, password, users): #Söker efter användare for user in users: user = user.split(',') if password: #Om användare och lösen stämmer, return true. Om inte, return false. if user[0] == username and user[1] == password: ...
e9ac5b185f16bd854108551c14c2e1fee9f89915
vuminhph/randomCodes
/Techniques/TwoPointers/is_palindrome.py
539
4
4
def is_palindrome(s): s = s.replace(' ', '') if len(s) % 2 == 0: return False if len(s) < 3: return True mid_ptr = len(s) // 2 left_ptr = mid_ptr - 1 right_ptr = mid_ptr + 1 while True: if s[left_ptr].lower() != s[right_ptr].lower(): # print(f'{s[left_pt...
515d2d73d496646deab1b8983bec2f434b163d77
dudulacerdadl/Curso-Python
/Mundo1/Exercícios/ex033.py
458
4.125
4
num1 = int(input('Digite o primeiro número: ')) num2 = int(input('Digite o segundo número: ')) num3 = int(input('Digite o terceiro número: ')) smaller = num1 if num2 < num1 and num2 < num3: smaller = num2 if num3 < num1 and num3 < num2: smaller = num3 larger = num1 if num2 > num1 and num2 > num3: larger =...
b11631c16024a5bc768daf8c0549386207c3f380
cancan233/Coursera_Notes
/Algorithmic Toolbox/week3_greedy_algorithms/largest_number.py
528
3.90625
4
""" Author: Cancan Huang Date: 2020-09-22 22:47:23 """ # Uses python3 import sys import math def largest_number(a): # write your code here res = "" while a: maxdigit = "0" for i in range(len(a)): if int(a[i] + maxdigit) > int(maxdigit + a[i]): maxdigit = a[i] ...
211f9c17e90a1c115aa1e8232af8e0b51a3f6d3e
BohdanKulynych/EPAM_DQE_HW
/HW8/sql.py
3,594
3.578125
4
import argparse import sqlite3 import csv import os # execute by python sql.py -p 'BI' parser = argparse.ArgumentParser(description='Enter name of project after -p') parser.add_argument('-p', '--project', nargs='+', type=str, help='Enter project name', required=True) args = parser.parse_args() def if_...
82b1a3de9abc0efa328865fdafa226c058a71c4c
vbelousPy/py_base
/Lesson_01/1.py
114
3.65625
4
firstName = input("input first name: ") lastName = input("input last name: ") print("Hello,", firstName, lastName)
cdd9cabd17720ec6c09eca1fb7bec596bf75c072
shefali-k/Python-Day1
/Calc.py
583
3.84375
4
# -*- coding: utf-8 -*- """ Created on Mon Nov 19 16:04:00 2018 @author: User """ def add(x,y): return x+y def sub(x,y): return x-y def mul(x,y): return x*y def div(x,y): return x/y x=float(input('Enter the FIRST number:')) y=float(input('Enter the SECOND number:')) c=int(input('Select ...
040128078e17fc7bda105cf84d5bfe22d88bd0ed
eian-lee/coder_five
/Eian/week3/하노이의탑.py
295
3.875
4
#!/usr/bin/env python3 def solution(n): def hanoi(m, s, b, d): if m == 1: yield [s, d] else: yield from hanoi(m-1, s, d, b) yield [s, d] yield from hanoi(m-1, b, s, d) answer = list(hanoi(n, 1, 2, 3)) return answer
033cddce5fa3d1bfedb3210bfc4b62e7aaaf05a5
ananda-wahyu-nur-said/I0320124_Ananda-Wahyu-NUr-Said_Aditya-Mahendra_Tugas6
/I0320124_soal2_tugas6.py
480
3.75
4
daftar_nilai = input('Ketikkan semua nilai yang akan dirata-rata dan pisahkan dengan tanda koma tiap-tiap nilai!>') list_nilai = daftar_nilai.split(',') list_nilai_akhir = [int(x) for x in list_nilai] keseluruhan = 0 for nilai in list_nilai_akhir : keseluruhan = keseluruhan + nilai nilai_rata = keseluruha...
70f8c5d09a14f7f48e465a40c7d71e34270161ca
onionzhou/Note
/OLD_BAK/data_structure/pytree/bstree.py
8,990
4.1875
4
#!/usr/bin/env python3 import queue class Node(object): def __init__(self, data): self.left = None self.right = None self.data = data class BSTree(object): ''' unbalance binary search tree ''' def __init__(self): self.root = None def get_height(self, node): ...
ea68d24a0392ed328b5a2705050a65667b9eadac
acheun1/05.DojoSurvery
/DojoSurvey.py
1,164
3.59375
4
#Dojo Survey + NOTES #2018 09 29 #Cheung Anthony # When you build this, please make sure that your program meets the following criteria: # http://localhost:5000 - have this display a nice looking HTML form. The form should be submitted to '/result' # http://localhost:5000/result - have this display a html with the i...
6bd632abe0953c859971e7e74ef853ee4bb7a910
eduardogomezvidela/Summer-Intro
/10 Lists/Excersises/24.py
470
3.8125
4
#adder up to first even number list = [1, 35, 7, 5, 11, 6, 7, 3, 4, 6, 8, 10, 11] #1 + 35 + 7 + 5 + 11 == 59 adder = 0 new_list = [] for num in list: new_list.append(num%2) up_to = (new_list.index(0)) #Gets up to what number we will add (even number) counter = 0 answer = 0 for num in list: ...
a9089be7d29e0825f2e8ed77d24dd32d584b64d4
summerfang/study
/python/swapnode/swapnode.py
993
3.5625
4
# Definition for singly-linked list. from sqlalchemy import null class ListNode(object): def __init__(self, val=0, next=None): self.val = val self.next = next class Solution(object): def swapPairs(self, head): """ :type head: ListNode :rtype: ListNode """ ...
53674575d3633e1a7555593fc27f02ad1b94b212
jirayu3141/comp1531-software-engineering-fundamentals
/19T3-cs1531-lab03/marks.py
1,213
3.78125
4
import statistics students = [ { "name": "Matt", "homework": [90.0, 97.0, 75.0, 92.0], "quizzes": [88.0, 40.0, 94.0], "tests": [75.0, 90.0], }, { "name": "Mich", "homework": [100.0, 92.0, 98.0, 100.0], "quizzes": [82.0, 83.0, 91.0], ...
ae4c774cfc9d6e621d72768313f3d0139da8f0cf
zmiarzynska/python
/z10/10_4.py
1,360
3.9375
4
class Queue: def __init__(self,size): self.items = [] self.size=size self.amount=0 if self.size<0: raise ValueError("size musi byc wieksze od 0") def __str__(self): # podglądanie kolejki return str(self.items) def is_empty(self):...
35649f6e254ed4f5be3541428e9e22abe2660ff5
DanielRagi/python-tcp-socket
/server.py
1,426
3.515625
4
import socket import sys import os # Definicion de socket con listening en todas las direcciones del servidor sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_address = ('0.0.0.0', 4050) print('Iniciando servidor {} puerto {}'.format(*server_address)) sock.bind(server_address) sock.listen(1) while Tru...
c3f7b9bab5016d9492fb0cc1276d14d4c3d1d627
mateuslunacc/CodeContests
/AA básico/Lista2/The Greater One-digit Number.py
458
3.5625
4
def oneDigitNum(s): n = 0 while True: for c in s: n += int(c) s = str(n) if(n < 10): break else: n = 0 return n num = input().split(" ") while(not(num[0] == "0" and num[1] == "0")): n1=oneDigitNum(num[0]) n2=oneDigitNum(...
d43700b7a1fbff8d71cb91fdc91b29678593193b
Cheney320/LeetCode-
/2020-4-6/53.最大子序和.py
495
3.5
4
# # @lc app=leetcode.cn id=53 lang=python3 # # [53] 最大子序和 # # @lc code=start class Solution: def maxSubArray(self, nums): max_sum = nums[0] for i in range(1, len(nums)): if nums[i-1] > 0: nums[i] += nums[i-1] max_sum = max(max_sum, nums[i]) return max...
d02153b6e98aa1932bdfeac0cd379ebdec33f862
jionchu/Problem-Solving
/BOJ/1001~2000/1330.py
84
3.640625
4
a, b = map(int,input().split()) print('>' if a > b else ('<' if a < b else ('==')))
4920b3b03b6b502297c928d4ba2ced6e4eca21bb
ajaychacko98/HangMan
/file.py
1,108
3.5
4
import random def word(): f=open("list.txt","r") a=[] p=f.readline().strip("\n") while(p!=""): a.append(p) p=f.readline().strip("\n") print(a) l=len(a) print(l) x=random.randint(0,l-1) print(a[x]) return(a[x]) def schan(s, i, a): l = len(s) t = "" if ...
0450c513375e5ac2a386216e251c809d5eabbbff
thiagofb84jp/python-exercises
/pythonCourseUdemu/algoritmosExercicios/estruturaDeDecisao/exercicio08.py
578
4.21875
4
""" 8. Faça um programa que pergunte o preço de três produtos e informe qual produto você deve comprar, sabendo que a decisão é sempre pelo mais barato. """ produtoA = 10.90 produtoB = 8.40 produtoC = 3.99 # Para o produto mais barato if (produtoA < produtoB) and (produtoA < produtoC): print('Produto A é o ma...
781d9f76bd624beac6f0d51552ebf0dd8ed18bbe
MaximeJdDS/VerbCalc
/verbcalc/tests/test_calculating.py
575
3.734375
4
""" Tests calculating. """ import unittest import verbcalc class TestCalculate(unittest.TestCase): def test_calculations(self): self.assertEqual(verbcalc.calculate('2 plus 2'), 4) self.assertEqual(verbcalc.calculate('2 minus 2'), 0) self.assertEqual(verbcalc.calculate('2 times 2'), 4) ...
86a2fb51ffeab9f77bef07f4867c65b62cd70260
dinobobo/Leetcode
/609_find_duplicate_file.py
1,612
3.734375
4
from collections import defaultdict from typing import List class Solution: def findDuplicate(self, paths: List[str]) -> List[List[str]]: # dictonary {content: full path} file_dic = defaultdict(list) for i in paths: res = i.split() root_path = res[0] fil...
31c804ab74b51cadb0259339f53ad2d277ebac98
mackenzielarson/SonomaState
/CS115/Lab08/lab08cFINAL.py
2,308
3.953125
4
__author__ = 'Mackenzie' """ Program: CS 115 Lab 08 (lab08c.py) Author: Mackenzie Larson Description: This program uses the graphics package to animate two circles to rotate around each other. ******* NOTE: My program uses a time.sleep import because I was working off of my personal computer and ...
f38d536f793b4f5b2eee6629b6f44703ceb7e248
mejia127/tallerpd
/catorce.py
246
4.0625
4
#! /usr/bin/env python # -*- coding: utf-8 -*- def tabla(a): for j in range(1,13): n=a*j print (str(a)+"*"+str(j)+" = "+str(n)) multiplicador = int(input("Cual tabla de multiplicar deseas conocer ")) tabla(multiplicador)
efd09e9632905eda769970b6794eef84f2b56d71
fijixfiji/RStanBook
/chap04/lm.py
710
3.625
4
#! -*- coding:utf-8 -*- import numpy as np from sklearn import linear_model # d <- read.csv(file='input/data-salary.txt') # res_lm <- lm(Y ~ X, data=d) # X_new <- data.frame(X=23:60) # conf_95 <- predict(res_lm, X_new, interval='confidence', level=0.95) # pred_95 <- predict(res_lm, X_new, interval='prediction', level=...
fc1c30d499fb1ccccca8a5a7cb8ed7fcfae8dd70
azonmarina/AdventOfCode
/d4p1.py
1,118
4.03125
4
# --- Day 4: The Ideal Stocking Stuffer --- # # Santa needs help mining some AdventCoins (very similar to bitcoins) to use # as gifts for all the economically forward-thinking little girls and boys. # # To do this, he needs to find MD5 hashes which, in hexadecimal, start with at # least five zeroes. The input to the MD...
78e2d8910f9b3bd4458ea86b79e38eaee8fc0730
Jahadul-Rakib/pure-python-playground
/file-read-write.py
619
4.0625
4
# File IO #Reading file = open("files/student.txt", "r+") # r for read, w for write, r+ read and write print(file.readable()) #read all text = file.read() print(text) # or Line By Line text = file.readline() print(text) # or Line By Line All and can accessable by index text = file.readlines() print(text) #Using Loop...
b07041a8ae98cc1b42d93986f089fb3fd32458d0
BIRDDYTTP/elabProgrammingConcept
/python/lab 4 finish/มาตรการเงินโอน แก้จน คนขยัน.py
437
3.640625
4
age = int(input("Enter your age: ")) income = int(input("Enter your net income: ")) if age<15 or age>60: print("Invalid age.") elif income < 0 or income >79999: print("Invalid income.") else: if income<=30000: ic_tax = income*0.2 print("Your negative income tax is %.2f Baht." %(ic_tax)) elif income>30000 and in...
4acc8ac12b01e8e95d6f3b12ec1bdc81013f26af
Tvashta/cp
/Graphs/mulDest.py
1,063
3.6875
4
# Given g and the index of a start vertex s, # find the minimal distances between the start vertex s and each of the vertices of the graph. from heapq import heappop, heappush def minimum(d, v): m = float('inf') mp = -1 for i in range(len(d)): if d[i] < m and not v[i]: m = d[i] ...
37b6e17e6b1c874edc3b2cc275058242f3becc60
ywtail/nowcoder
/38.py
1,208
3.734375
4
# coding:utf-8 # 左旋转字符串 class Solution: def LeftRotateString(self, s, n): if len(s) <= n: return s else: return s[n:] + s[:n] # 运行时间:41ms # 占用内存:5748k solution = Solution() print solution.LeftRotateString('abcXYZdef', 3) # XYZdefabc ''' 题目地址 https://www.nowcoder.com/prac...
6d8ffa5e654cf9795f996e6470cd11e817a70d09
ProPython007/Python_Ouiz_1
/Script/python_quiz.py
5,656
3.875
4
import random print("\n\nWelcome to the PYTHON QUIZ PROGRAM...") ans="y" while ans=="y": print("\n\nSelect a level:\n\neasy\nhard\nvery hard") a=input("\nEnter your choice: ") if a=="easy": s=0 print("\nChoose the field no.:\n\nMultiplication(1)\nAddition(2)\nSubstraction(3)") ...
56fc065a003dc022ea1d844075d95d922fb21554
davidlichacz/simple-banking-system
/main.py
5,956
3.640625
4
from random import randint import sqlite3 conn = sqlite3.connect('card.s3db') create_cards_table = '''CREATE TABLE IF NOT EXISTS card( id INTEGER PRIMARY KEY AUTOINCREMENT, number TEXT, pin TEXT, balance IN...
b7302ddf0a43c4889e67d73a4ffcd1d77bf068b5
Ken-McLoud/machine-server
/app/util_funcs.py
3,941
3.515625
4
def check_cell_info(cell_obj): ''' Function to validate a cell info object before it is allowed into the database Args: cell_obj: an instance of the Cell_info model class Returns: errs: a string describing the error (empty if none) ''' def check_time(time_str,errs):...
185b7bd4678541071b8dffeab8a7a03362762109
ttuygun/competitive-python
/linkedlist/reverseLinkedList.py
1,118
3.8125
4
""" Link: https://leetcode.com/problems/reverse-linked-list/ Category: Linkedlist Tags: Site: Leetcode Solved by: Tarık Taha Uygun """ # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def reverseList(self, head: ListNod...
122ba77ab485b13b52443cf50fc51b10da25307a
Stella2019/study
/1218.最长定差子序列.py
2,947
3.640625
4
# # @lc app=leetcode.cn id=1218 lang=python3 # # [1218] 最长定差子序列 # # https://leetcode-cn.com/problems/longest-arithmetic-subsequence-of-given-difference/description/ # # algorithms # Medium (40.45%) # Likes: 47 # Dislikes: 0 # Total Accepted: 5.9K # Total Submissions: 14.6K # Testcase Example: '[1,2,3,4]\n1' # # ...
3bc61b18155f6c94bbd87c3ac20ff0b234477d18
bkaraosmanoglu/Python-Programming
/adressBook.py
3,924
4.46875
4
PhoneNumber=[] Names=[] Emails=[] option =0 while True: print("---------------------------------------") option = input("Enter the number of the Option you want:"+ "\n----------------------------------------"+ "\n| 1 | To Add Contact"+ "\n| 2 | To search f...
ef258ea9ae4af500136d1784fe35779a09e8fa77
gabeo14/PiDice
/dice_roller_full_set_test.py
1,320
3.734375
4
from random import randint def d2_roller(): roll_d2 = randint(1, 2) return roll_d2 def d4_roller(): roll_d4 = randint(1, 4) return roll_d4 def d6_roller(): roll_d6 = randint(1, 6) return roll_d6 def d8_roller(): roll_d8 = randint(1, 8) return roll_d8 def d10_roller(): roll_d...
71071873a204fb322048138cf0db83f9dab45d8e
ProtulSikder/CodeChef
/2D array 2.py
231
3.890625
4
n = int(input()) a = [[0]*n]*n for i in range(n): for j in range(n): a[i][j] = int(input()) print('value of a[{}][{}]:{}'.format(i,j,a[i][j])) for i in range(n): for j in range(n): print(a[i][j])
9e7e5a66cbbe1819f076657fb484e5493016eeca
HenriFeinaj/Simple_Python_Programs
/Factorial_N.py
323
4.21875
4
#Function body. def factorial(n): if n==0: return 1 elif n < 0: return "The number you have entered should be a positive integer!" break else: return n * (factorial(n-1)) #Main build x = int(input("Please enter only a positive integer: ")) factorial(x) ...
2ae85c0272d9dabb286d09d86bc73acad3b2a08d
bramkuijper/python_course
/day_2/openappend2.py
499
3.9375
4
# first write something to a file with open(file="myfile.txt", mode="w") as file_obj: file_obj.write("I wrote this to a file!") # open file again, now to append and read with open(file="myfile.txt",mode="a+") as file_obj: file_obj.write("\nAnd now I also wrote this!") # move file pointer to 0th by...
ae9797db0833a810c7b69ab2d9e3b66cf1d258ff
mohitgureja/DSA_Nanodegree-Python
/Project_1-Unscramble computer science problems/Task2.py
1,120
3.96875
4
""" Read file into texts and calls. It's ok if you don't understand how to read files """ import csv from collections import defaultdict # with open('texts.csv', 'r') as f: # reader = csv.reader(f) # texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) ...
29255bde08f4ae071fbe990814d5e1ab812d93ed
christopheleroy/oanda-musings
/drafts/teeth.py
4,526
3.828125
4
import pdb from collections import deque ## Teeth is a small module helping to navigate an instrument whose value goes up and down... # keep a queue (FIFO) of size 'size' # to help compute moving-max or moving-min (or moving whatever, with reduce) class MovingQueue(object): def __init__(self, size): sel...
c40d37e5be2aa1a6720d0a3056a53ccab6fd5185
MirkoNardini/tomorrowdevs
/Workbook - cap2/Exercise 44 Faces on Money.py
922
4.125
4
banconota = int(input("Inserire taglio banconota: ")) George_Washington = 1 Thomas_Jefferson = 2 Abraham_Lincoln = 5 Alexander_Hamilton = 10 Andrew_Jackson = 20 Ulysses_S_Grant = 50 Benjamin_Franklin = 100 if banconota == George_Washington: print("La banconota è da 1$ e raffigura George Washington") e...
b6f26ba30c8a50eb6c2ab928f1a27cc391c55526
vsharma-va/Flight-Registery
/src/User.py
6,097
3.9375
4
import main import pandas as pd '''Available Flights is the parent class''' class AvailableFlights: def __init__(self, first, last, email, starting, destination, payment): self.firstName = first self.lastName = last self.email = email self.startingPoint = starting self.de...
d1751d78c337348a6fb8315403359704ff99d301
zdsh/leetcode
/341.py
1,034
3.828125
4
class NestedIterator(object): def __init__(self, nestedList): """ Initialize your data structure here. :type nestedList: List[NestedInteger] """ self.flater_list=[] for n_e in nestedList: if n_e.isInteger(): self.flater_list.append(n_e.ge...
1318db91e925be9e3539ccf554814058fd0f28ef
ewelkaw/advent_of_code
/ad_8.py
2,774
4.03125
4
# --- Day 8: I Heard You Like Registers --- # You receive a signal directly from the CPU. Because of your recent assistance with jump instructions, it would like you to compute the result of a series of unusual register instructions. # Each instruction consists of several parts: the register to modify, whether to inc...
27d9d95680b7f320198733bb38c5cb07d3c076a9
parthokr/family-search-scrape
/service/read_input.py
398
3.515625
4
import csv class ReadInput: def __init__(self, filename, start, end): filename = open(filename, 'r') print("Reading CSV...") self.reader = list(csv.reader(filename))[start:end+1] # for row in self.reader: # print(row) # def get_data(self): # return self.reade...
5b7ac6dd724436ba25022a1ba0a9968c257b9268
borislavstoychev/Soft_Uni
/soft_uni_basic/Conditional Statements/advanced/exercise/07. Hotel Room.py
749
3.984375
4
month = input() nights = int(input()) price_per_studio = 0 price_per_apartment = 0 if month == 'May' or month == 'October': price_per_studio = 50 price_per_apartment = 65 if nights > 7 and nights <= 14: price_per_studio *= 0.95 elif nights > 14: price_per_studio *= 0.7 e...
afd12266d3e49802d238acc4272513a2988213e4
Alexcode100/werken-met-condities
/sollicitatie.py
2,358
3.703125
4
#BEGIN print('----------------------------------------------') print('Welkom bij de:\nCircusdirecteur voor Circus HotelDeBotel Vacature') print('----------------------------------------------') print('Laten we beginnen!') #BEGIN #NAAM EN LEEFTIJD Naam = (input('Wat is uw voor en achternaam? ')) Leeftijd = (input('Wa...
b5623c0d9f19aab8cb1d6388d4bae3ac13c586d0
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/224/users/4352/codes/1692_1107.py
4,758
3.90625
4
x=int(input("escolha o numero: ")) y=int(input("numero de dias apos: ")) z=x+(y%7)-7 if(x>=0) and (x<=6) and (x==6) and (z==6): print("Hoje eh sabado e o dia futuro eh sabado") elif(x==5) and (z==6)and (x>=0) and (x<=6): print("Hoje eh sexta e o dia futuro eh sabado") elif(x==4) and (z==6)and (x>=0) and (x<=6): prin...
bbaa166c9491206f6312fbf9bc922cdf1ef1f1f6
DStheG/ctci
/05_Bit_Manipulation/02_Binary_to_String.py
1,155
3.625
4
#!/usr/bin/python """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 05.02.Binary to String Given a real number between 0 and 1 (e.g., 0.72) that is passed in as a do- uble, print the binary representation. If the number cannot be represented accurately in binary with at most 32 charact...
d405e145adaa41aabffa25464d74dff8c42ca0bf
ivan-yosifov88/python_fundamentals
/list_basic_exercise/survival_of_the_biggest.py
417
3.921875
4
import sys list_of_integer = input().split() number_to_remove = int(input()) new_list = [] for integer in list_of_integer: number = int(integer) new_list.append(number) for iterations in range(number_to_remove): smallest_number = sys.maxsize for numbers in new_list: if numbers < smallest_num...
afebc3f81d0910d240729cdf2c34ad11ea12fa9a
SinCatGit/leetcode
/00636/exclusive_time_of_functions.py
2,724
3.84375
4
from typing import List class Solution: def exclusiveTime(self, n: int, logs: List[str]) -> List[int]: """ #### [636. Exclusive Time of Functions](https://leetcode.com/problems/exclusive-time-of-functions/) On a **single threaded** CPU, we execute some functions. Each function has a uniqu...
7ff87af920c9fbb303257f80f0ce62204d912108
harrisonBirkner/PythonSP20
/Lab4/Lab4/BugCollector.py
186
4.09375
4
BugTotal = 0 for days in range(1,8): BugsToday = int(input('How many bugs did you collect on day ',)) BugTotal += BugsToday print('You collected ', BugTotal, ' bugs today!')
20e181a18ce86f6fc8161d900894a716d33026b2
hundyoung/LeetCode
/leetcode/Q54_Spiral_Matrix.py
2,140
3.5
4
from typing import List class Solution: def spiralOrder(self, matrix: List[List[int]]) -> List[int]: # direction = 'right' result = [] if len(matrix)==0: return result def back_track(init_direction,direction:str,x,y): if init_direction==direction: ...
93aee45e7c1b64b75403ac03469ef0051dfc2b53
ddoplayer2012/leecode
/数组/1删除重复项.py
1,277
3.53125
4
# -*- coding: utf-8 -*- """ 给定 nums = [0,0,1,1,1,2,2,3,3,4], 函数应该返回新的长度 5, 并且原数组 nums 的前五个元素被修改为 0, 1, 2, 3, 4。 你不需要考虑数组中超出新长度后面的元素。 https://leetcode-cn.com/explore/orignial/card/all-about-array/230/define-with-good-care/953/ """ __author__ = 'me' # # # 自己写的,快慢指针。 # def removeDuplicates(nums): # number = 0 # ...
4272f0e4f6798dfdd492ef16224d4d57990d7800
anthonymoon/rbc-statement-parser
/utils.py
3,575
3.53125
4
import json import re with open('config/categories.json') as json_file: data = json.load(json_file) categories = data with open('config/excludes.json') as json_file: data = json.load(json_file) remove_lines = data['lines'] remove_words = data['words'] def cloc(s: str) -> int: ''' Counts the number of l...
05a17389b3b3b8d7eb8e9231c333956e78bc6882
25tunez/TSU-Spring2019-CS456-Grice-Python
/softwareEngProj.py
1,040
4.03125
4
#open file given filename from user filename = input("please type in filename >> ") file = open(filename, 'r') #read in text and print text = file.read() print('\n') print(text) #using split function, create a list of each word (using white space as a delimiter) listOfWords = text.split() print(listOfWords) n...
f54ef11868c0932bc1fed594421e58d5a0b42ff9
Niaev/link_tracking
/indexer.py
4,161
3.765625
4
"""Organizes lists of links""" # Database manipulation imports import sqlite3 # Web crawling imports from urllib.request import urlopen from urllib.error import HTTPError, URLError class Indexer: """Class that receives a list of links to organize and index Instance Variables: links {list} -- Containing ...
786b20301ac0c0ffba9f6cdf26d2f392e9e1e958
tshokair/learning_python
/binary_search.py
2,508
3.890625
4
import math import random def binarySearch(alist, item): n=len(alist) n_sub=n first = 0 last=n-1 found=False index=0 k=0 while n_sub>1: #print("loop #",k,"looking from index",first,"to",last,"n_sub=",n_sub) k+=1 if first==last: return first eli...
71f7cd3c915a5794abc428108101ad37edfbb2d4
hectorRperez/ejercicios-listas-tuplas
/ejercicio9_practica.py
536
3.875
4
""" Ejercicio 9 Escribir un programa que pida al usuario una palabra y muestre por pantalla el número de veces que contiene cada vocal. """ def mostrar_vocales(palabra): lista_vocales = ['a','e','i','o','u'] for i in lista_vocales: contador = 0 for j in palabra: if j == i:...
14c1622a27f18efff4bb97ef482ed30484f97707
ism23867017/M03
/pyhton18/probando.py
300
3.6875
4
#coding: utf-8 x=input("Cuantos numeros vas a introducir?:") salir = False a=0 b=0 import os while salir == False: for aux in range (1,x+1): y=input("Introduzca el numero "+str(aux)+" :") if y%2==0: a=a+1 else: b=b+1 print "Hay ",a," pares, y hay",b," impares." exit()
04e668fa807f194ec3740b98bc91e77a98f5d036
ben-heil/pubmedpy
/pubmedpy/names.py
1,050
4.21875
4
import string import pandas def simplify_fore_name(name, lower=False): """ # Convert period to space # Split on whitespace # Strip punctuation (on termini) # Discard <=1 letter strings # Discard <=3 letter strings that are ALL CAPS # If one string remains, return """ if pandas.isn...
bf21ba941366900f3daf97353325fd4ec6d03c17
AnyiVilaro/TalleresPythonNTD
/ejercicios_basicos/ejercicio8.py
162
3.671875
4
edad1 = int(input("Ingrese la edad 1: ")) edad2 = int(input("Ingrese la edad 2: ")) comparacion = edad1 == edad2 print("Las edades son iguales?: ", comparacion)
d8440e0a8750c139583711939612e134d04aa69b
QikaiYang/DigitalLibrary
/src/Test/TestParser.py
3,786
3.5
4
from Database.Database import Database from Basic.Parser import Parser import unittest class TestParser(unittest.TestCase): my_store = Database("https://cs242-97d35-default-rtdb.firebaseio.com/") def test_simple_smaller(self): """ Test if the simple operator < works as expected """ ...
b507517270360ea2b8f990c909de9063067856ef
bishop527/house_hunt
/src/Commute/CommuteScore.py
3,360
3.8125
4
''' Created on Nov 17, 2015 @author: ad23883 @todo: ''' import pandas as pd from utils import * fileName = 'Master-Commute_Data-2015' priorities = {'Distance': [3], 'Duration': [7]} ''' THis method uses relative frequency to assign a weight to each item in the priorities list. These weights will the...
80db0c746ba700b0c1918ee06d5b10f538fb222d
roncrisostomo/CrackingTheCodingInterview
/strings/stringCompression.py
872
4
4
def stringCompression(s): """ s: a string Returns a compressed version of string using counts of repeated characters """ if len(s) == 0: return '' result = '' # Initialize first run using first character curRunChar = s[0] curRun = 1 # Iterate...
f7bf241c8acea4299153c1796052a0210042705e
andrewEstornell/Project_Euler
/Python_Solutions/26.py
178
3.5625
4
import numpy as np def longest_cycle(value): v = str(value).split('.')[1] length = 0 for i in range(len(v)): for j in range(len(v)/2) print(str(1/7.0))
7e95667034550ea93abd062672bd254302cb9f64
alexnro/Codewars-Katas
/Python/8kyu/dicaprioOscars.py
409
3.65625
4
def leo(oscar): if oscar == 88: return "Leo finally won the oscar! Leo is happy" elif oscar == 86: return "Not even for Wolf of wallstreet?!" elif oscar != 86 and oscar < 88: return "When will you give Leo an Oscar?" elif oscar > 88: return "Leo got one already!" if __...
90793196778ed555e6d16476522fee1d24d8bb64
thenickrj/Data-Structures
/Array/Reversal algorithm for array rotation.py
1,193
4.3125
4
# Python program for reversal algorithm of array rotation # Algorithm: # # rotate(arr[], d, n) # reverse(arr[], 1, d); # reverse(arr[], d + 1, n); # reverse(arr[], 1, n); # arr[] = [1, 2, 3, 4, 5, 6, 7], d = 2 and n = 7 # A = [1, 2] and B = [3, 4, 5, 6, 7] # # Reverse A, we get # ArB = [2, 1, 3, 4, 5, ...
a345322a51a1b42c418b3a612da4fccda91fcf30
KhrulSergey/AI_Robotics_Udacity
/Search/Value Prog.py
1,901
3.8125
4
# ---------- # User Instructions: # # Create a function compute_value which returns # a grid of values. The value of a cell is the minimum # number of moves required to get from the cell to the goal. # # If a cell is a wall or it is impossible to reach the goal from a cell, # assign that cell a value of 99. # ---------...
347ded1cb0f6223bf1763b34023a20bdac4186da
TeeJayYang/Prep
/leet/py/104.py
570
3.71875
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 maxDepth(self, root): """ :type root: TreeNode :rtype: int """ max = 0 def dfs(node,...
5401aeb55dc163aef58322318acc1cff7ed4634b
Kingston802/kattis-solutions
/aboveaverage.py
336
3.734375
4
n = int(input()) inputList = [] for i in range(n): inputList.append(input()) for string in inputList: values = list(map(int,string.split()[1::])) avg = sum(values)/len(values) above = 0 for val in values: if val > avg: above += 1 print("{:.3f}%".format(round(((above/len(values...
d32bdc6fe3571b85583bdc9a035515563c9531ef
eamonbanta/matrix
/run_matrix.py
1,668
3.890625
4
from matrix import Matrix class MatrixProgram(object): commands = set(['q', 'c', 'm', 'a', 'n', 'p']) def __init__(self): self.matrices = {} def loop(self): while True: command = raw_input("(q)uit; (c)reate; (m)ultiply; (a)dd; matrice (n)ames; (p)rint matrix: ") i...
8c53bfc7295b1daa9b647e97f1b9f6506781b3c0
cmd01/my_notes
/python/class.py
1,022
4.0625
4
class Square: def __init__(self, length, width): # инициализация класса с двумя аргментами self.length = length # инициализация первого аргумента self.width = width # инициализация второго аргумента def area(self): # инициализация функции return self.length * self.width # возвраща...
e4194f06729b1a28f311950b290169914b0a511a
maodunzhe/clean_code
/array/missingNumber.py
346
3.765625
4
''' play around the math way and cs way both ''' def missingNumber(nums): result = 0 for i in range(len(nums)): result = result ^ i ^ nums[i] return result ^ (i + 1) def missingNumberI(nums): n = len(nums) return (1 + n) * n / 2 - sum(nums) print missingNumber([0, 1, 2, 4, 5]) print missin...
5b3b88f4543b747d331b57c62ddbb47663679839
phamin2001/Texas-Hold-em-Poker
/tests/test_deck.py
1,258
3.515625
4
import unittest from unittest.mock import patch from poker.card import Card from poker.deck import Deck class DeckTest(unittest.TestCase): def test_has_length_that_is_equal_to_count_of_cards(self): deck = Deck() self.assertEqual(len(deck), 0) def test_stores_no_cards_at_start(self): ...
f337b48391a0d9ab4e3347200d04ea05b788ab9b
ConnorPark/csp_python_2018-2019
/1.3.6/Park_1.3.6.py
1,850
4.25
4
#1 N/A #2 N/A #3 N/A #4 (5,7,12) #5 '''A convention in HTML is the amount of tabs that you put between each line.''' #6 '''a) the value that comes out is 2 because when counting in python, you start at 0 and then progress. b) the output is ('a', 'b') because python is showing the values of 0 and 1, not 2.''' #7 '''Whe...
88cdab6673d0f3377e437fb464983f52abc115f2
ermidebebe/Python
/binary to decimal.py
170
4.25
4
binary=int(input("binary=")) power=0 decimal=0 while binary>0: decimal+=(binary%10)*2**power power=power+1 binary=binary//10 print("decimal\n",decimal)
b97a0635582bd3e4d74c3b465a882270ea4e0bdd
vishalsingh8989/karumanchi_algo_solutions_python
/Chapter 3 linklist/deleteMaxRight.py
1,089
3.703125
4
""" https://www.geeksforgeeks.org/delete-nodes-which-have-a-greater-value-on-right-side/ """ from __future__ import print_function from linklist import SimpleNode as Node from linklist import printlist from random import randint from sys import maxint def deleteMax(head): head = reverse(head) printlist(head) ...
394b3d9772651244240ad673de50071adff78bfe
Python-Programming-Boot-Camp/JonathanKarr
/Week 5/benefits_of_yield.py
289
4.03125
4
def squares (number): squared = [] for i in range(len(number)): squared.append(number[i]**2) return squared def squares_with_yield (number): for i in range(len(number)): yield number[i]**2 print(squares([3,2,5,8])) print(list(squares_with_yield([3,2,5,8])))
4b35215bd1748faeecb659429e0ba9fb6f5d388c
piotrbrendan/Exercises-python
/anagrams.py
707
3.890625
4
#!/opt/anaconda3/bin/python # return True jesli s i t sa anagramami, # return False w przeciwnym wypadku def anagrams(s,t): """(str,str)->bool return True jesli s i t sa anagramami, return False w przeciwnym wypadku zalozylem, ze wielkosc liter nie ma znaczenia """ char_s_list=[] char_t_list=[] ...