blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
4b4a7eaa84dd60ccabcf39665d4321a9f7f261ca | burnettaw/python-challenge | /PyPoll/main.py | 3,459 | 3.890625 | 4 | # The total number of votes cast
# A complete list of candidates who received votes
# The percentage of votes each candidate won
# The total number of votes each candidate won
# The winner of the election based on popular vote.
import os
import csv
voter_id = []
county = []
candidate = []
unique_candidates = []
uniq... |
a8a73a85775b28bb51c09172e95620676558f238 | BruceHi/leetcode | /DiningPhilosophers/DiningPhilosophers-leetcode.py | 1,852 | 3.703125 | 4 | # 哲学家进餐
import threading
from threading import Condition, Semaphore
from collections import defaultdict
# 方法一:一个吃完一个来
# class DiningPhilosophers:
# def __init__(self):
# self.lock = threading.Lock()
#
# # call the functions directly to execute, for example, eat()
# def wantsToEat(self,
# ... |
64814ea84e91bef82a2cdff6749caf5645dbdae5 | hanrick2000/algorithm-6 | /01 - Defeat the Algorithm Interview/E627.LongestPalindrome.py | 1,409 | 3.828125 | 4 | class Solution:
"""
@param s: a string which consists of lowercase or uppercase letters
@return: the length of the longest palindromes that can be built
"""
def longestPalindrome(self, s):
# write your code here
# method 1
hash = {}
for char in s:
if cha... |
dc9a9acd0b60d9c169869091fde6cdf813a77ad3 | CongoCash/Rocket | /Updated/oop-python/py/fundamentals/blog/main.py | 2,189 | 4.03125 | 4 | """
To run this program, make sure you are on the blog/ level (where main.py is) in your command line
(in Pycharm you can get to your terminal by click on the box at the bottom left of your window). Then run
python main.py YOUR NAME HERE
If you get an index out of range error it's because you haven't supplied your na... |
17924cd94cd30330de83a7a24af01f2d977c96fd | venkyp1/Misc | /python_bits/thread1.py | 885 | 3.734375 | 4 |
######################################################
# Venky, Mon Aug 21 16:39:22 2017 #
######################################################
from threading import Thread
import time
import logging
logging.basicConfig(level=logging.DEBUG, format='(%(threadName)-10s) %(message)s',)
def fun(num... |
635958882f410b257bb3fb41049cdf031d67a145 | BryceKrispie/TextAdventure | /Practice.py | 1,676 | 3.65625 | 4 | import random
class Character():
def __init__(self, HP=10, ATK=2, name=""):
self.HP = HP
self.ATK = ATK
self.name = name
def Travel(self):
print "You travel, and bump into a line of code."
def Status(self):
print "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\nHere's your health " + str(self.HP)... |
da6e0e597538625640deef01fcfe1d9a39b42b97 | JakubKazimierski/PythonPortfolio | /AlgoExpert_algorithms/Medium/BST_Traversal/BST_Traversal.py | 2,717 | 4.15625 | 4 | '''
BST Traverslal from AlgoExoert.io
January 2021 Jakub Kazimierski
'''
class BST:
'''
Class of binary search tree.
Task description:
Write three functions that take in
a Binary Search Tree (BST) and an empty
array, traverse the BST, add its nodes'
values to the inp... |
72cdd27a578360badb22689dec53cb53942d0ff2 | julugale/testamento | /P2.py | 529 | 4.3125 | 4 | def factorialR(num):
if num==1:
return 1
else:
return num*factorialR(num-1)
print ("Factorial Recursivo")
num=int(input("Ingresa un numero: "))
print(factorialR(num))
print ("----------------------------------------------------------------------")
def factorialI(num):
factor... |
6e7b690264f2185676e9e09c7ca293ca1c7c1cad | Callmich/Data-Structures | /doubly_linked_list/doubly_linked_list.py | 7,580 | 3.71875 | 4 | """
Each ListNode holds a reference to its previous node
as well as its next node in the List.
"""
class ListNode:
def __init__(self, value, prev=None, next=None):
self.prev = prev
self.value = value
self.next = next
def __del__(self):
self.value = None
# if both se... |
9850316011df243f3aef62428868ba70208e4ccc | arknave/project-euler | /python/pe038.py | 581 | 3.640625 | 4 | def pandigital(x):
prod_string = str(x)
i = 2
while len(prod_string) < 9:
prod_string += str(i * x)
i += 1
if ''.join(sorted(prod_string)) == "123456789":
return prod_string
else:
return None
def main():
best_prod = "918273645"
ranges = (x for y in (range(91,... |
bca72840b409b1facd2e8f5c280ec9b64b381df8 | KineOdegardHanssen/PhD-subprojects | /P3_NEURON/efel_findCm_somaonly_hh.py | 7,194 | 3.625 | 4 | import efel
import numpy
import math
import matplotlib.pyplot as plt
## Mainly Sverre's stuff.
## Needed to modify to fit my simulations, though
## Setting I is a bit hacky.
def main(filename,idelay,idur,iamp):
"""Main"""
# Use numpy to read the trace data from the txt file
data = numpy.load... |
77be58a9d7e5f5b21d21cf99f533154b76a0182d | theshevon/A1-COMP30024 | /Astar3Commented/board.py | 2,630 | 3.578125 | 4 | from node import *
class Board:
combination_data = {}
def __init__(self, data):
self.pieces_colour = data["colour"]
self.exit_locations= self.returnExits(self.pieces_colour)
self.blockSet = [tuple(l) for l in data["blocks"]]
#return items from combination_data
def getNode(self... |
e54eed627b80bd4dc307ba16192078c3733d57bb | Subhan-khaliq/Data-Structures-Python | /DFS.py | 1,898 | 3.734375 | 4 | class Node:
def __init__(self, val):
self.value = val
self.leftChild = None
self.rightChild = None
def insert(self, data):
if self.value == data:
return False
elif self.value > data:
if self.leftChild:
return self.leftChild.insert(... |
b6a092bbbf72bd126e602583cb51fa557dab8f39 | pasha-bolokhov-cs/comp112 | /handin/lab4/lab4.py | 3,653 | 4.1875 | 4 | #!/usr/bin/env python
#encoding: utf-8
import math, sys
#
# xrange() is replaced by range() in Python 3
#
if (sys.hexversion >= 0x300000):
def xrange(stop):
return range(stop)
def timediff(t1, t2):
"""
Time difference
"""
#
# First time is always before the second time,
... |
b395a414fabb68c6ef02d9c4dd394a2b47f77d65 | gschen/sctu-ds-2020 | /1906101095-王凯/作业3.py | 3,226 | 3.84375 | 4 | import datetime
class student:
def __init__(self,Sno,Sname,Sbarthday,Sfaction):
self.Sage = 0
self.Sname = Sname
self.Sno = Sno
self.Sbarthday = datetime.datetime.strptime(Sbarthday,"%Y-%m-%d")
self.Sfaction = Sfaction
self.Setage(Sbarthday)
self.SetGarde(Sfaction)
def Setage(self,Sbarthday):
if (datetime.date.today().... |
44f7ad53df6cf045538b7a9c42e0c65a45b05730 | HduiOSClub/HduiOSClub | /projects/吕昊临/python/03.py | 134 | 3.5 | 4 | # 输出前20项裴波纳契数列
if __name__=="__main__":
x,y=1,1
for _ in range(20):
print(x)
x,y=y,x+y
|
e75370dd9f9f70511722bbcdf1eb71883b075b26 | my-hub30/PythonExer-Leetcode | /Bubble sort.py | 282 | 3.625 | 4 | '''
Bubble sort
Date: 2020-9-20
'''
lis = [int(i) for i in input().strip().split()]
n = len(lis)
for i in range(n):
for j in range(n-1):
if lis[j]>lis[j+1]:
trans = lis[j+1]
lis[j+1] = lis[j]
lis[j] = trans
print(lis)
|
b8b237668c90ea3e1e9d5e5e94c24b612c231834 | benamoreira/LivroPensePython2Ed | /capitulo8.py | 534 | 4.125 | 4 | def rotate_word(palavra1, valor):
CARACTERES = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
decifrada = ''
for letra in palavra1:
if letra in CARACTERES:
num = CARACTERES.find(letra)
num = num + valor
decifrada = decifrada + CARACTERES[num]
print('palavra decifrada: ', decifr... |
6752d483b8cc5c7d78941a6c5525570c57f76890 | daniel-reich/ubiquitous-fiesta | /ZaEFRDBZ7ZMTiSEce_11.py | 159 | 4 | 4 |
def find_nemo(sentence):
return "I found Nemo at " + str(sentence.split().index("Nemo")+1) + "!" if "Nemo" in sentence.split() else "I can't find Nemo :("
|
82b5f015cd49b7e16cde0b40fee8485195dd6afc | AdamZhouSE/pythonHomework | /Code/CodeRecords/2468/60846/272454.py | 455 | 3.75 | 4 | def printList(lst):
#firstFlag=False
#for num in lst:
# if not firstFlag:
# firstFlag=True
# print(num,end='')
for num in lst:
print(num,'',end='')
print()
t=int(input())
while t:
n=int(input())
nums=[int(x) for x in input().split()]
ret=[]
product=1
... |
750745ddaf87c7c12ab6e9d620e5b3c1e53ac863 | Nickolaim/refresh_linear_algebra | /tests_vector.py | 1,812 | 3.578125 | 4 | #!/usr/bin/env python
import math
import unittest
from vector import Vector
class VectorTestCase(unittest.TestCase):
def test_addition(self):
v1 = Vector([0, 0, 0])
v2 = Vector([1, 1, 1])
self.assertEqual(v2, v1 + v2)
def test_subtraction(self):
self.assertEqual(Vector([-1, ... |
f1f4cc1ca2094dd81b393104cbea833ae1457887 | rgayatri23/Python_prac | /test1.py | 4,081 | 4.4375 | 4 | from __future__ import print_function
import random
import sys
import os
print("Hello World")
#comment
''' A test Program to learn python '''
#name = "Rahul"
#print(name)
#
#number = 5+2
#print("number = ", number)
#
#number = 5-2
#print("number = ", number)
#
#number = 5/2
#print("number = ", number)
#
#number = 5... |
64705d060eead954ddd719e929b84daa088ec178 | dersonf/aulaemvideo | /exercicios/ex070.py | 764 | 3.65625 | 4 | #!/usr/bin/python36
total = prod1000 = valorprodbarato = 0
prodbarato = ' '
while True:
prod = str(input('Nome do Produto: '))
valor = int(input('Preço: R$'))
total += valor
if valor > 1000:
prod1000 += 1
if valorprodbarato == 0 and prodbarato == ' ':
prodbarato = prod
valorp... |
ad032aaeb32840aa35b6f250549807c86dfa462e | YannTorres/Python-mundo1e2 | /Desafios/58JogoAdvinhaçãoV2.py | 565 | 3.859375 | 4 | from random import randint
n = randint(0, 10)
print('Pensei em um número de 0 a 10')
p = 11
tentativa = 1
while p != n:
p = int(input('Qual número eu pensei: '))
if p == n:
print('Parabéns você acertou!')
elif p != n:
if p < n:
print('Você errou tente novamente! (shiii... |
70709e22ca71b9b627ba2436a048146da9ce1c38 | zqs01/ASR_chinese_e2e | /Predictor/Utils/score.py | 341 | 3.671875 | 4 | import Levenshtein as Lev
def calculate_cer(s1, s2):
"""
Computes the Character Error Rate, defined as the edit distance.
Arguments:
s1 (string): space-separated sentence (hyp)
s2 (string): space-separated sentence (gold)
"""
word_num = len(s2.split(' '))
return Lev.distance(s... |
9087570ed1716ba7bbb6e8c4e4661c2d0b5a07f6 | vishalsingh8989/karumanchi_algo_solutions_python | /Chapter 2 recursion/palindrome.py | 598 | 3.84375 | 4 | #!/usr/bin/python
__author__ = "Vishal Jasrotia. Stony Brook University"
__copyright__ = ""
__license__ = "GPL"
__version__ = "1.0"
__maintainer__ = "Vishal Jasrotia"
__email__ = "jasrotia.vishal@stonybrook.edu"
__status__ = ""
__problem__ = 'NA'
import sys
def ispalindrome(string = ""):
if len(string) == 1 or ... |
3a8e57c146af0c3d80cafb8c0c1bcf5eb4e8e1d2 | arunkumardurgadevi/a | /swap.py | 103 | 3.625 | 4 | num1,num2=input().split()
num1=int(num1)
num2=int(num2)
temp=num1
num1=num2
num2=temp
print(num1,num2)
|
6c115c1c714b05276fb9be144256ed536c11dded | JaquesZanon/skedm | /build/lib/skedm/skedm.py | 21,288 | 3.90625 | 4 | """
Scikit learn implementation of nonlinear forecasting.
By Nick Cortale
"""
from . import utilities
from scipy import stats as stats
from sklearn import neighbors
import numpy as np
from sklearn import metrics as skmetrics
class Regression:
"""
Nonlinear regression
"""
def __init__(self,weights='u... |
b6b98a186eee60b0565f588e4e54449795eb5ec0 | PawelDabala/Python-programming-exercises | /Question11_2.py | 516 | 3.953125 | 4 | """
Question:
Write a program which accepts a sequence of comma separated 4 digit binary numbers as
its input and then check whether they are divisible by 5 or not.
The numbers that are divisible by 5 are to be printed in a comma separated sequence.
Example:
0100,0011,1010,1001
Then the output should be:
1010
Notes: As... |
b2a9fc1c31434976516416c124be9134946a4d03 | CQU-AI/ML-Algorithm | /cquai_ml/KNeighborsClassifier.py | 3,213 | 3.734375 | 4 | import scipy
from sklearn.neighbors import BallTree, KDTree
class KNeighborsClassifier:
""" A KNN implementation imitating scikit-learn interface.
Dependency
----------
`scipy` : For performance reasons, use scipy to perform the underlying operations
- `scipy.unique`
- `scipy.spatial.d... |
e2f69a189d1334f325fa86884bc86a4af7ddb0ac | crato-thaissa/crato-thaissa.github.io | /python/aleao.py | 1,038 | 4.0625 | 4 | #Classificação de palavras em alemão
#------------------------------
#A função de ordenação embutida do Python ordena strings pelo unicode.
#Isso é inconveniente para palavras em alemão porque coloca palavras com umlauts no final enquanto elas devem ser classificadas junto com suas vogais correspondentes.
#Essa funç... |
dd3db1f0233dfd8ab84b527f5bcfffa90d543ab4 | niharika210400/practice.python | /Zero-sum-triplet.py | 2,066 | 3.65625 | 4 | # Ques: https://practice.geeksforgeeks.org/problems/find-triplets-with-zero-sum/1
# Soln:
''' Your task is to returns 1 if there is triplet with sum equal
to 0 present in arr[], else return 0'''
def findTriplets(arr, n):
sum = 0
for i in range(0, n-1):
# Find pair in subarray A[i + 1..n-1]
... |
908dc2185b0f968038c1fad06e281b2ce0b9a7a3 | wulalakuaipao/api_auto | /week_5/class_0215/boy_firend_new.py | 1,024 | 3.859375 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/2/15 20:42
# @Author : lemon_huahua
# @Email : 204893985@qq.com
# @File : boy_firend.py
#男朋友类 身高 喜欢运动 技术性 有钱 帅 会Python 优秀 赚钱 有责任 会家务
#做饭
#初始化函数--魔方函数 魔法函数
class BoyFriend:
def __init__(self,age,height,name):#类的属性参数化
self.age=age
self.height=height
... |
f3fc0af0271ca7a8b7bc367706435639676e7f84 | masci/playground | /cstutoring/026.py | 403 | 3.875 | 4 | """
Given the first few Fibonacci numbers:
1 1 2 3 5 8 13 21 ...
How many odd digits (1, 3, 5, 7 or 9) are contained in the 1000th Fibonacci
number?
"""
def fiborange(limit):
n, f = 0, 1
while (f <= limit):
yield f
n, f = f, f+n
f = fiborange(10**500)
num = 0
for x in xrange(1000):
num =... |
91b0270a2a88ed640d112449b60911a7356ee4b5 | jiikrish/Delhivery---PJM-Project | /varibale.py | 1,109 | 4.25 | 4 | """
Variable Names
A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume). Rules for Python variables:
A variable name must start with a letter or the underscore character
A variable name cannot start with a number
A variable name can only contain alpha-numeric char... |
df405e4eee6cbfeb6d9cfbcec578391f0502540c | victorbertoldo/aprendendo_python | /TesteInterface/IMC.py | 729 | 3.578125 | 4 | from tkinter import *
def calcular():
peso1 = float(peso.get())
altura1 = float(altura.get())
imc = peso1/altura1**2
resposta['text'] = imc
janela = Tk()
janela.title('Calcule seu IMC!')
janela.geometry('800x400')
janela.resizable(False,False)
Label(janela, text='Insira seus dados:').grid(row=0, co... |
554071fc71f96e89127446e7086b5b48c7851e1e | fitigf15/PYTHON-VICTOR | /Algorismica avançada - UB/Pau/(ALGA)Algorismica avançada/(ALGA)Algorismica avançada/ejercicios varios/apunts 2n parcial/apunts 2n parcial/progDin/floyd_warshal.py | 840 | 4.15625 | 4 | #Shortest path!!
'''
Example of Floyd-Warshall Algorithm for http://csalgorithm.wordpress.com/
@language: Python 3.1
@author: Wonjohn Choi
'''
hugeNumber = 999999999; #a really huge number for disconnected cities
#distance map
dist = (
[0, 50, 200, 300, hugeNumber],
[50, 0, 300, hugeNumber, 10... |
469e7178b60c8bd0ff5a1fd5d187851079bc70be | jgroc-de/mixed_projects | /algorithm/linear_regression/src/ft_math.py | 426 | 3.734375 | 4 | def linear(x: float, theta: list) -> float:
return float(theta[0]) + float(theta[1]) * x
def ft_pow(number: float, power: int) -> float:
powered_number = 1
while power > 0:
power -= 1
powered_number *= number
while power < 0:
power += 1
powered_number /= number
ret... |
342e76d19c7cabfb461a9196a25683fa0bca8b0e | Juanma1909/ADA | /5ta tarea/lcm.py | 635 | 3.5625 | 4 | from sys import stdin
from math import sqrt
def gcd(a,b):
if b == 0:ans = a
else:ans = gcd(b,a%b)
return ans
def lcm(a,b):
return (a//gcd(a,b))*b
def solve(n):
root = int(sqrt(n))
divisor = []
count = 0
for i in range(1,root+1):
if n%i == 0:
divisor.append(i)
if i*i != n:divisor.append(n... |
84f9ccd3fa561d31b95f15506fd2394469f7bdb6 | AgentRatz/VITAP-FRESHERS-CSE1002-AS1 | /#To check sum of two numbers using a while loop.py | 580 | 3.90625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Oct 16 22:42:27 2021
@author: 91798
"""
#VITAP assignment-1
#School: SCOPE
#Semester: Fall Sem 2021-22
#Subject: Problem Solving using Python
#Subject Code: CSE1012
# This code is to Calculate the Sum of Natural Numbers Using While Loop
num1 = int(input("Enter... |
ac03ff35e9c395250c55f4fda1ce3040eb6a1a24 | meghaljambhale/Python | /QR Generator.py | 628 | 3.828125 | 4 | #This code generates a QR code for any text or link and also auto saves it in your desktop.
import os
import pyqrcode
from PIL import Image
class QrGenerator(object):
def __init__(self, text):
self.qr_image = self.qr_gen(text)
@staticmethod
def qr_gen(text):
qr_code = pyqrcode.create(text)
file_name = "QR C... |
97a3b966efa16a336cc65cc0969aa2913c49e833 | ravi4all/MachineLearning_WE_Morning | /04-Modules/module_caller.py | 341 | 3.75 | 4 | from modules import main_module
num_1 = int(input("Enter first number : "))
num_2 = int(input("Enter second number : "))
print("Addition is",main_module.add(num_1,num_2))
print("Subtraction is",main_module.sub(num_1,num_2))
print("Division is",main_module.div(num_1,num_2))
print("Multiplication is",main_mod... |
044330a1ecc92126eba95d88aece0f70cc6da156 | edgy9/voice-assistant | /pepper.py | 2,467 | 3.5625 | 4 | from spotipy import Spotify
class InvalidSearchError(Exception):
pass
def get_album_uri(spotify: Spotify, name: str) -> str:
"""
:param spotify: Spotify object to make the search from
:param name: album name
:return: Spotify uri of the desired album
"""
# Replace all spaces in name with... |
89670f6c0d5a7d5739c5a8d4a7ec7e9ba224af20 | IceMIce/LeetCode | /Array/169_Majority Element.py | 363 | 3.5625 | 4 | class Solution(object):
def majorityElement(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
digits = {}
for num in nums:
digits[num] = digits.get(num, 0) + 1
if digits[num] > len(nums) / 2:
return num
solution = Solutio... |
62307127b8c1a69723ab389411d92958ead2ca93 | Bruin-Spacecraft-Group/Reach-Sentinel-Lite | /reachSentinelLite/junk.py | 3,399 | 3.546875 | 4 |
#had problems with only reading in a few data
print('-------------------------- * * * -------------------------- BEFORE')
if (len(data) < 6):
print("not enough data")
continue
print('-------------------------- * * * -------------------------- AFTER')
#convert from string type
for i in range(len(data... |
f47c284e590a760c3340fd0b9ed76fd7c19892c3 | mxhit-j/Molecular-Modeling-and-Simulations-BIM-303- | /Steepest_Descent_Method_BIM-2019-18.py | 325 | 3.890625 | 4 | #Steepest descent method
x1 = int(input('Enter the initial guess: '))
def f(x):
p = 1 - (2*x)
return p
fx1 = f(x1)
x2 = x1 + 0.1*f(x1)
while(True):
if x2-x1 < 0.0001 and x2-x1 > -0.0001:
break
else:
x1 = x2
x2 = x1 + 0.1*f(x1)
print('The root is', x2)
... |
f47bbb8c120dabd02f0c02de1dd3332067623e97 | nirajandata/Old-Archives | /test.py | 267 | 3.6875 | 4 | import turtle
def _draw():
window=turtle.Screen()
window.bgcolor("grey")
a=turtle.Turtle()
i=0
j=0
x=['grey','black','blue','green','red','white','yellow','white']
while(i<7):
a.circle(20+j)
j=j+40
i=i+1
# a.fill(x[i])
a.color(x[i])
_draw()
input()
|
0207950f5eb425a6dcdf8b5f612b0418d9a52c93 | omanwasid/SeleniumWithPython | /PycharmProjects/test/if.py | 3,085 | 3.8125 | 4 | """
aa=['apple','Banana','Orange','Coconut']
for fruit in aa:
print ('The current fruit: %s' % fruit)
"""
"""
for num in range(1,10):
print('I am at:%d' % num)
if num > 5:
print('I am Below 5')
else:
print('I am above 5')
"""
"""
my_nums =[100,200,300,400]
for ak in my_nums:
result=ak/2
... |
ebac6c142f93dda1f120c1d7a8894fb22bc43143 | harrifeng/leet-in-python | /076_minimum_window_substring.py | 1,657 | 4 | 4 | """
Given a string S and a string T, find the minimum window in S which will
contain all the characters in T in complexity O(n).
For example,
S = "ADOBECODEBANC"
T = "ABC"
Minimum window is "BANC".
Note:
If there is no such window in S that covers all characters in T, return the
empty string "".
If there are multiple s... |
c62d01133a7f27fc7f84cb771b3bee2421ce4da7 | cgavinh/SCMP401 | /Development Programs/push_button.py | 559 | 4.40625 | 4 | # Program to test functionality of a push button
# Source: https://raspberrypihq.com/use-a-push-button-with-raspberry-pi-gpio/
import RPi.GPIO as GPIO
GPIO.setwarnings(False) #ignore warnings for now
GPIO.setmode(GPIO.BOARD) # use physical pin numbering
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) #set pin 10 ... |
402fc06443e5bdfdf8b602843d97244933fe0ba4 | jerryzhang2019/Udacity_DSA_Project1 | /Project1_DataStructure_Algorithm.py | 7,364 | 3.796875 | 4 |
# coding: utf-8
# In[37]:
#Task0 任务0
""""
What is the first record of texts and what is the last record of calls?
Print messages:
"First record of texts, <incoming number> texts <answering number> at time <time>"
"Last record of calls, <incoming number> calls <answering number> at time <time>, lasting <during> seco... |
848b4b035f32a7e0939ca3a02b58cf8e0f558db7 | juanPabloCesarini/cursoPYTHON2021 | /Seccion 12/paquete/operaciones2.py | 146 | 3.5 | 4 | def dividir(n1,n2):
print("El resultado de la division es: ", n1/n2)
def multiplicar(n1,n2):
print("El resultado de la suma es: ", n1*n2) |
5c26467041f393411bbf7fdc93ba2ba7ebd16df2 | kellerja/AoC2019 | /day4/part2/solution.py | 1,238 | 3.984375 | 4 | def is_ascending_with_exactly_double_digit(num):
double_digit = False
previous_digit = 0
same_digit_count = 1
for str_digit in str(num):
digit = int(str_digit)
if previous_digit > digit:
return False
elif previous_digit == digit:
same_digit_count += 1
... |
3ce078e18bdddd9f79c40f6502ba09057fcef945 | arshadumrethi/Hacker_rank | /Python_Challenges/hrnk5.py | 687 | 3.90625 | 4 | #Attempt number 1 which did not work
# n = int(raw_input())
# for n in range(1, 21):
# i = int()
# i = i > 0
# if i < n:
# print i^2
# else:
# break
#Attempt number 2 which worked
n = int(raw_input())
i = 0 #setting i as zero
numbers = [] #setting an empty list where the numbers will be... |
55825572ae97f81318adc01bd23b160e93dc3bea | IanCBrown/practice_questions | /cd.py | 384 | 3.5 | 4 |
while True:
case = input().split()
n = int(case[0])
m = int(case[1])
if n == 0 and m == 0:
break
jack_list = []
jill_list = []
for i in range(n):
jack_list.append(int(input()))
for i in range(m):
jill_list.append(int(input()))
combined = jack_list + ji... |
7ffb3c8f211624687e38de8b65920afa78be3755 | OrigenesZhang/-1s | /UVaOJ/Maths/Probability/UVa11971.py | 270 | 3.59375 | 4 | def gcd(a, b):
if not b:
return a
return gcd(b, a%b)
T=int(input())
for t in range(1, T+1):
s=input()
N, K=s.split()
K=int(K)
if K==1:
print("Case #"+str(t)+": 0/1")
continue
b=1<<K
a=b-K-1
g=gcd(a, b)
print("Case #"+str(t)+": "+str(a//g)+"/"+str(b//g))
|
5397b227ee16ca8746a618e02e41e28030a5257c | row-yanbing/LeetCode | /[206]反转链表.py | 1,241 | 3.96875 | 4 | # 给你单链表的头节点 head ,请你反转链表,并返回反转后的链表。
#
#
#
#
# 示例 1:
#
#
# 输入:head = [1,2,3,4,5]
# 输出:[5,4,3,2,1]
#
#
# 示例 2:
#
#
# 输入:head = [1,2]
# 输出:[2,1]
#
#
# 示例 3:
#
#
# 输入:head = []
# 输出:[]
#
#
#
#
# 提示:
#
#
# 链表中节点的数目范围是 [0, 5000]
# -5000 <= Node.val <= 5000
#
#
#
#
# 进阶:链表可以选用迭代或递归方... |
7ba8dac05d56c801096aa8911f7c5d3bd2735e5e | FarhoodHS/Connect-4 | /Connect-4.py | 5,090 | 3.765625 | 4 | import random as rn
class Board:
def __init__(self):
self.game = [[' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' '... |
3c30dc82bbc56080764e8feebf3315f73395d0dc | lynnpepin/socket-examples | /test_server.py | 1,585 | 3.578125 | 4 | """
test_server.py
Instantiates a SimplestServer, sends 100 pieces of data over it, and repeats the procedure 100 times.
The data is generated deterministically using random.seed, so the client can verify that the server sends the correct data.
"""
from simplest import SimplestServer
import random
if __name__ == ... |
c9b09cff1cd7dd62be942f65b16582ba1fb1fe34 | DYEkanayake/CO324 | /Lab01/ex3.py | 1,081 | 3.828125 | 4 | from ex1 import *
def load_course_registrations_dict(filename: str) -> List[Student]:
#Dictionary of Student Objects
studentDetails=dict()
#To keep the read data of the line being read
details=[]
with open(filename) as f:
for line in f:
details= line.st... |
c8992dae4fc373905361dc4ba6bed6a27cbf22fb | NoorKhan/cracking-the-coding-interview | /Chapter 2/2.2.py | 432 | 3.859375 | 4 | from linked_list import LinkedList
def kth_to_last(linked_list, k):
nodes = []
current_head = linked_list.head
while current_head is not None:
nodes.append(current_head)
current_head = current_head.next
print(nodes[len(nodes) - k - 1].data)
linked_list = LinkedList()
linked_list.... |
bed318ab8e498c7997d4ece6f1eecde407a000cc | cugxin/All-Projects-in-CUG | /GIS-and-Big-Data/Urban Perception Assessment/2.Training set Construction/1.四通道变三通道.py | 1,160 | 3.515625 | 4 | '''
功能:读取图片文件,得到对每张图片的数据矩阵
'''
# 读取图片的库
from PIL import Image
import os
import numpy as np
# 所有图片转换成RGB格式
def Photo2RGB(filpath):
if os.path.exists('RGB/RGB_'+filpath[:-1]) == False:
os.mkdir('RGB/RGB_'+filpath[:-1])
manyfiles = os.listdir("img/"+filpath)
for file in manyfiles:
... |
986f18f3f62102a0ba080d634165c1ea46842b64 | jayhebe/Python_100ex | /ex018.py | 198 | 4.1875 | 4 | number = input("Please enter a number: ")
repeat = int(input("Please enter how many times it will repeat: "))
result = 0
for i in range(1, repeat + 1):
result += int(number * i)
print(result)
|
10f485ca958a94d995b3a8f146abcb2f6c6cbdd8 | NeilWangziyu/Leetcode_py | /MagicDictionary.py | 1,364 | 3.96875 | 4 | from typing import List
class MagicDictionary:
def __init__(self):
"""
Initialize your data structure here.
"""
def buildDict(self, dict: List[str]) -> None:
"""
Build a dictionary through a list of words
"""
self.dict = {}
check_list = set("ab... |
fbe17d388fe07924df536025702a36f9786599b6 | hzcodec/instruments | /rotate_images/rotate_image3.py | 10,660 | 3.71875 | 4 | # Auther : Heinz Samuelsson
# Date : 2015-08-02
# File : rotate_image3.py
# Reference : -
# Description : Rotate the loaded image at an offset position.
# The position is set by offsetX and offsetY.
# Same as rotation_image2 but now rotating without mouse control.
# ... |
1476e0f9e53448afc3d9e1a9529f07d6e88cf143 | Kunal352000/python_program | /8.py | 142 | 3.96875 | 4 | x=eval(input("Enter your nested list object: "))
num=int(input("Enter the numbers: "))
for i in range(1,num+1):
x.append(i)
print(x)
|
41f0542f545f132539e608104d0b9b391b585833 | noiclas/TicTacToe | /ai.py | 909 | 3.671875 | 4 | from math import inf
from board import Board
def minimax(board, player, max_depth, current_depth):
if board.is_game_over() or current_depth == max_depth:
return board.evaluate(player), None
best_move = None
best_score = -inf if board.current_player == player else inf
for move in board.get_mov... |
32bbb8a3ef1cde3cc213bd76b65ac4d7a1bd5ba9 | Vineasouza/study-python | /curso1/maniparchives.py | 689 | 3.703125 | 4 | """
Manipulando arquivos de arquivos
"""
with open("arquivo.txt", encoding="utf8") as ARQUIVO_1:
#readline le uma linha
#readlines le o arquivo e armazena em uma lista
LINHAS = ARQUIVO_1.readlines()
print(LINHAS)
for LINHAS in LINHAS:
print(LINHAS)
#read le o arquivo inteiro
TEXTO... |
d343a94b96322f147d3f96012fc2241ed4a5fe04 | shocklee/python-code | /kochCurve.py | 478 | 3.625 | 4 | from swampy.TurtleWorld import *
import math
def draw(t, length, n):
"""Givena turtle, length, and number, draw a shell-like Koch curve.
"""
if n == 0:
return
angle = 50
fd(t, length*n)
lt(t, angle)
draw(t, length, n-1)
rt(t, 2*angle)
draw(t, length, n-1)
lt(t, angle)
... |
68f872232759fe7f5e40b74c615a0ecabb4949a3 | client2233/Python | /s1e17/sw.py | 139 | 3.625 | 4 | i = 1
j = 1
while i<=9:
j = 1
while j<=i:
print (i, 'x', j, '=', i*j, end=" ")
j += 1
print ('\n')
i += 1 |
40205bfd6888e595f23822b2ea21c95d90778b5f | johebuck/Algorithms-Analysis | /Algorithms & Analysis/sort/Program1/insertion/insertion_sort_ordered.py | 511 | 4.1875 | 4 | #NAME: John Buckley
#DATE: 9/17/17
#PROGRAM: Programming assignment 1: ordered input
#PURPOSE: Uses insertion sort to take a list of integers and sort them in increasing order
def insertionSort(alist):
for i in range(1,len(alist)):
k = alist[i]
j = i
while j>0 and alist[j-1]>k:
... |
1aa8118a0df1a4529c50de0a236e903493ef706e | Jansonboss/LeetCoding_Practice | /DepthFirstSearch/LeetCode17_LetterCombination.py | 1,704 | 3.578125 | 4 | # https://leetcode.com/problems/letter-combinations-of-a-phone-number/
# Using depth first search 但这题有点不同但是虽然我们每个depth要从头开始, 我们用的
# 是idex来控制深度 控制是digits eg. 2 -> 3 -> 4
# This kind of queston is suitable for DFS since the lenghth of english word
# is somehow limited which means the depth of the recursion is limited as ... |
ac6114af8ab62ad5e5f583d4a24bda46252efb8c | ansj11/DeepLearning | /code/python/ansj_class.py | 326 | 3.578125 | 4 | class Ansj():
name = ''
age = 0
sex = 'male'
def setName(self,name):
self.name = name
def getName(self):
print self.name
def setAge(self,age):
self.age = age
def getAge(self):
print self.age
ansj=Ansj()
print(ansj.name,ansj.age,ansj.sex)
ansj.setAge(25)
ansj.setName('anshijie')
ansj.getAge()
ansj.get... |
22c500d839b7a94bca62e190c0768fbc08d996ef | pawellogin7/Python-matplotlib | /WNO_labirynt/maze.py | 4,560 | 4.25 | 4 | import numpy
from numpy.random import randint as rand
import matplotlib.pyplot as pyplot
def generate_maze(width=81, height=51, complexity=.75, density=.75):
"""Generate a maze using a maze generation algorithm."""
# Only odd shapes
shape = (((height // 2) * 2 + 1, (width // 2) * 2 + 1))
# Adju... |
828be5ff5eccf051aae9892a92d0389cb3affc75 | mzw4/Pokemoji | /pokemoji/post_processor.py | 901 | 3.515625 | 4 | #
# Rename, resize, and convert image to PNG
#
import os
from PIL import Image
image_dir = 'images/'
result_dir = 'final/'
size = 50, 50
# load name map
image_map = {}
with open(image_dir + 'image_map.txt') as map_file:
for line in map_file:
(img_name, sha1) = line.strip().split(',')
image_map[s... |
16e8d980ebf2268b38e2e58a0220fd13bdf73e42 | jinsa564/Software-Engineering | /programming lab/big.py | 168 | 3.984375 | 4 | a=int(input("enter the first num :"))
b=int(input("enter the second num :"))
c=int(input("enter the third num :"))
big=max(a,b,c)
print("biggest of",a,b,c,"is",big) |
18c7a659f8c40dced677c23f90849d19768dfaf8 | xiaoxing666/myPython | /多线程/02.py | 962 | 4.0625 | 4 | '''
利用 time 函数,生成两个函数
顺序调用
计算总的运行时间
'''
import time
# _thread 是老的多线程包,建议用 threading
import _thread as thread
def loop():
print('loop 开始时间:',time.ctime())
time.sleep(4)
print('loop 结束时间:',time.ctime())
def loop2():
print('loop2 开始时间:',time.ctime())
time.sleep(2)
print('loop2 结束时间:',time.ctime())... |
080d71c3bccad5b75ac364236bd86ceea5cda584 | Li-congying/algorithm_python | /LC/Design/all_O1.py | 8,845 | 3.890625 | 4 | '''
Implement a data structure supporting the following operations:
Inc(Key) - Inserts a new key with value 1. Or increments an existing key by 1. Key is guaranteed to be a non-empty string.
Dec(Key) - If Key's value is 1, remove it from the data structure. Otherwise decrements an existing key by 1. If the key does no... |
6671e1bbeea1e00b91242578f6ffa624850f65e2 | JosephLevinthal/Research-projects | /5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/223/users/4501/codes/1594_2043.py | 195 | 3.78125 | 4 | a=float(input("Digite a nota a: "))
b=float(input("Digite a nota b: "))
c=float(input("Digite a nota c: "))
d=float(input("Digite a nota d: "))
m=((a*1+b*2+c*3+d*4)/(1+2+3+4))
print(round(m, 2))
|
b07bd5d624ac156c1e66bcd76dc5c1bb6b25978a | xiaoqianbaobao/Pygames | /resources/code/chap03/TestCode.py | 395 | 3.84375 | 4 | # Test Code
something = 123
print(something)
something = "ABC"
print(something)
A = 123
B = "ABC"
C = 456
D = "DEF"
print(A,B,C,D)
name = "John Carpenter"
birth = "11/11/2011"
print(name,birth)
print("String","Theory", sep='-', end=':')
print()
import sys
print(sys.copyright)
print(sys.platform)
print(sys.versio... |
35a41935069d1a84cb72cfa34a17f5beb73e5745 | Zaela24/pathfinder | /pf_diagonal_shot_calc.py | 914 | 3.921875 | 4 | # Zaela
#
# Range increment calculator for shooting diagonally in Pathfinder.
# Takes two arguments, length and height, then returns the distance of the shot.
# Rounds down if remainder when divided by 5 is less than 1, otherwise rounds
# up to the nearest 5 foot increment
def diagonal_shot(length, height):
... |
731552d972c4d4c035cab08c6c93f24770969542 | arpolek/Learning-Python | /006-metody_string.py | 799 | 4.15625 | 4 | firstname = input('What is your name?')
lastname = input('What is your name?')
number = input('What is your number?')
print('Czy imie sklada sie tylko z liter?', firstname.isalpha())
print('Czy nazwisko sklada sie tylko z liter?', lastname.isalpha())
print('Czy numer tel. sklada sie tylko z liczb?',number.isdigi... |
dfd021f89d656d84c17570a41a805abee01e1b06 | rtotheroh/class-work | /8.1.2.py | 132 | 3.703125 | 4 |
handt = ['a', 'b', 'c', 'd', 'e']
def middle(x):
return(x[1:len(handt)-1])
handt2 = middle(handt)
print(handt)
print(handt2)
|
3b67b764d1fc81530b345c75b5018502caee68b5 | OJRR-91/Random_programs | /clases.py | 566 | 3.75 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jan 2 11:55:49 2020
@author: oscarjex
"""
class Promedio():
n1=0
n2=0
n3=0
h=3
pro=0
def __init__(self):
print("Se acaba de crear un objeto")
def promedio(self):
self.n1=int(input("Ingresa la calificacion del prime... |
9edfac2e16f5d692d450651acb5332712b152330 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2533/60761/233761.py | 200 | 3.703125 | 4 | A=input("")
A=A.replace('[',"")
A=A.replace(']',"")
A=list(map(int,A.split(",")))
result=[]
for a in A:
if(int(a)%2==0):
result.insert(0,a)
else:
result.append(a)
print(result) |
338d189bdeabe5d9ab6ca753acd0bb747cf76719 | wvenderbush/matrix_wvenderbush | /main.py | 1,379 | 3.609375 | 4 | from display import *
from draw import *
import random
screen = new_screen()
color = [ 0, 255, 0 ]
matrix = new_matrix()
#print_matrix(matrix)
#Identity Matrix
print "\nID Matrix\n"
idmatrix = new_matrix()
ident(idmatrix)
print_matrix(idmatrix)
#Scalar Multiplication
print "\nScalar Multiplication by 2\n"
print_ma... |
c498fe012fb18fed76f5a9524f4f8d280f2154e1 | redcrabs/pyrandwalk | /pyrandwalk/pyrandwalk_util.py | 1,326 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""Utility module."""
import numpy as np
def make_prob_dist(freq, precision=10**(-10)):
"""
Return a fine probability distribution based on given frequencies of states.
:param freq: inputted array showing rate of occurrence
:type freq: list or np.array
:param precision: sh... |
5f30b6fe56c3a6b2d07ccf59c3c49c6633595b84 | Lokamp/Learning_python | /Functions/decorator_example/func_count_write_file.py | 436 | 3.515625 | 4 | from datetime import datetime
def function_call_count(func):
def wrapper(*args):
func(*args)
func_name = wrapper.__name__ = func.__name__
with open('file.txt', 'a') as file:
file.write(f'{datetime.now()};{func_name};\n')
return wrapper
@function_call_count
def custom_sum(... |
b6f04002bbf840c744249ad06a9584f8ad2901e3 | KhoptiukVitalii/PythonCourse | /1015-lesson.py | 494 | 3.734375 | 4 | # import string
letters = input("Text to code> ")
key = 10 # secret code
for i in range(len(letters)):
letter = letters[i]
# print(letter)
code = ord(letter)
newCode = ord(letter) + key
if 97 <= code <= 122:
if newCode > 122:
newCode = newCode - 26
elif 65 <= code <= 90:... |
b9935d5d53ca2ae32c3350b818a78b5f6e54b0a5 | sidv/Assignments | /Bijith/Aug31/8.remove_duplicates_list.py | 247 | 4.09375 | 4 | #8.Write a program (function!) that takes a list and returns a new list that contains all the elements of the first list minus all the duplicates.
lst = [1,2,3,4,5,1,6,5,4,3,2]
def lst_rem_elm():
print(list(set(lst)))
lst_rem_elm()
|
0c58e78927a2a47240f52fcb5f0b16e15733dc79 | briancaffey/hackerrank | /cd.py | 796 | 4.09375 | 4 | # implementing cd in python
class Path:
def __init__(self, path):
self.path = path
def cd(self, p):
if p[0] == '/' or p == '':
self.path = p
return self.path
changes = p.split('/')
for i in changes:
if i == '':
next
... |
36bcd4c3517dd5678b26d694f171ccb35b604ec9 | WHJR-G12-Github/Solution_C1_TA2 | /shooting_spaceship_c1_ta2.py | 879 | 3.828125 | 4 | # Importing 'pygame'
import pygame
# Initialising 'pygame'
pygame.init()
# Creating game window of width 400 and height 600
screen = pygame.display.set_mode((400,600))
# Setting the title of the game
pygame.display.set_caption("Shooting Spaceship")
# Loading the background image
background_image = pygame.image.lo... |
995ceac36d8af01f17ad4072877a51d52d9bd670 | elad123456/EladProject | /first_package/printDATE.py | 243 | 4.09375 | 4 | d = int(input("enter your day:"))
m = int(input("enter your mounth:"))
y = int(input("enter your year:"))
print(str(d)+"/"+str(m)+"/"+str(y))
# ההבדל בין זה לפייל הקודם שזה מציג בלי רווח בין סלש לסלש |
647f71bb93c5eeb9540d7e91fa6db9635bfd2d98 | waikhit/pandas_tutorial | /harvard_tutorial.py | 215 | 3.515625 | 4 | import pandas as pd
import numpy as np
pd.Series(np.random.randn(5), index = ['a','b','c','d','e'])
s = pd.Series(np.random.randn(5))
print(s)
#Creating a dataframe
df = pd.Dataframe(s, columns = ['Column 1'])
df |
ab5c2a50339dbc56c250a7606faf4d7926e07e1e | NjengaSaruni/LeetCode-Python-Solutions | /IrfanBaqui/cycle_in_array.py | 808 | 3.953125 | 4 | """
Problem Definition:
Given an array in which the value stored as an index is the value of the next index
to go to in the array, write an algorithm to detect if there is loop in this array
Example:
:args [1, 2, 8, 1, 2, 3, 1, 3, 2]
:returns: 2
:description
Indexes 2 and 8 cause a loop
"""
from t... |
bddd0f92bdd9e8af354016ee5d9f38fe8febd644 | tedkim97/fibonacci-fd-comparisons | /python/fibonacci.py | 2,066 | 3.859375 | 4 | import math
# from functools import lru_cache
# Simple Recursion - O(2^n)
def fib_naive(n: int):
if(n <= 1):
return n
return fib_naive(n-1) + fib_naive(n-2)
# Simple Iteration - O(n)
def fib_iter(n: int):
n0, n1 = 0, 1
while(n > 0):
n0, n1 = n1, n0 + n1
n = n - 1
return n0
... |
bc98f1623406d0bb2570a9dc96e5739cc877eaf4 | Park-SeungWoo/python_algorithm_study | /baekjoon_algorithm/2839.py | 619 | 3.65625 | 4 | # def leastPb(n):
# count = 0
# while n:
# if n % 5 != 0 and n % 3 == 0:
# n -= 3
# count += 1
# elif n >= 5:
# n -= 5
# count += 1
# else:
# print(-1)
# return
# print(count)
#
#
# amount = int(input())
# leastP... |
528c937b9ed93b26635eb4b8c4dcd71e528cccb1 | Gokul-raaj-5999/TCS_CPA_python_programing | /NUMBER OF NONVOWEL WORDS IN THE LIST.py | 585 | 3.84375 | 4 | def NonvowelWords(str_list):
res=[]
for i in str_list:
z=0
for j in i:
if(j=='a'or j=='e' or j=='i' or j=='o' or j=='u'):
z+=1
if(z==0):
res.append(i)
else:
z=0
return res
if __name__ == '__main__':
count=... |
9d0a158fd0c6689ceb41d1b820f2424a9b287540 | MrHamdulay/csc3-capstone | /examples/data/Assignment_7/ynxyis001/util.py | 2,922 | 3.6875 | 4 | #2048 functions
#Jennifer Yuan (YNXYIS001)
#2 May 2014
def create_grid(grid): #creates an empty 4x4 grid
for i in range(4): #rows
temp =[] #empty dtring
for j in range(4): #columns
temp.append(0) #inputs 0 as value in list (temp)
... |
6eddd7f19a0c11ed6d054f5d970b0d8bae12f7bc | akshitgupta29/Competitive_Programming | /LeetCode & GFG & IB/Duplicate Zero.py | 576 | 3.859375 | 4 | '''https://leetcode.com/explore/learn/card/fun-with-arrays/525/inserting-items-into-an-array/3245/'''
from typing import List
class Solution:
def duplicateZeros(self, arr: List[int]) -> None:
"""
Do not return anything, modify arr in-place instead.
"""
i=0
N = len (arr)
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.