blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
c5e6dced5dea09b7de2e950a7a44b4953aef88ac
YuryYefr/PyBase08
/HW_1_3.py
629
3.953125
4
print("Операции + и *") a = int(input("input number: ")) print(int(a), float(a), bool(a), str(a)) b = int(input("input number: ")) print(int(a) + int(b), int(a) + float(b), int(a) + bool(b)) print(float(a) + int(b), float(a) + float(b), float(a) + bool(b)) print(bool(a) + int(b), bool(a) + float(b), bool(a) + boo...
28b84b559b60af828bb71b8adc303e70ae358dcd
pshepshe/practice2
/standard library/std lib.py
2,600
3.5
4
from sys import getsizeof def analise_text(path_to_text): with open(path_to_text, 'r') as text: char_dictionary = {} word_dictionary = {} string_from_text = text.readline().replace('\n', '') while string_from_text != '': # цикл, который прокручивает...
afd00778291b1e814106a60358bb446c1a0e859d
kwentz10/2D-Overland-Flow
/OverlandFlow_2D/test ex.py
2,370
3.53125
4
# -*- coding: utf-8 -*- """ Created on Mon Mar 14 17:21:38 2016 @author: Katherine """ # Creating a simple 2D scarp diffusion model with Landlab # Import the Numpy library, which we'll use for some array calculations import numpy # We will create a grid for our model using Landlab's *RasterModelGrid* class, which w...
b5f7a677760433f78ba5050a757555a43fef051f
patrickTumulty/Python_Jumpstart_Course
/Daily Journal/string_formating.py
327
3.765625
4
def wrap_text(string): line_length = 50 bp = int(len(string) / line_length) if bp == 0: return string else: num_loop = 0 while num_loop < bp: num_loop += 1 string = string[:line_length * num_loop] + "\n" + string[line_length * num_loop:] return s...
74f61f1587cc36dfa9f0f6b90a97ce5e3a3e0202
holynova-SD/MachineLearningCodes
/GD/conjugate_gradient_descent.py
1,499
3.765625
4
# -*- coding: utf-8 -*- from basic_functions import * def cgd(x, y, w, rank): """ use conjugate gradient descent method to calculate the parameter omega :param x: the x coordinate of the training sample, which is a row vector [x1, x2, ..., xn] :param y: the y coordinate of the training sample, which i...
212587006a9e0f5ca4e9103bc2a55591ad68c7f0
SachinMadhukar09/100-Days-Of-Code
/Array/Day 7/TLE20-July_28_Find_Duplicate_number.TLE_15m.py
916
3.734375
4
# Link https://leetcode.com/problems/find-the-duplicate-number/ # 20-July 06:30AM-06:45AM 15 min TLE # 287. Find the Duplicate Number # Medium # 8372 # 882 # Add to List # Share # Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive. # There is only one re...
706fb120fc13c20731ac151813b7eacb9dca1a37
dPezzoli/assignment-plaxis
/tests/overlaps_detection_test.py
11,861
3.671875
4
""" Unit tests for overlaps_detection module """ import math import unittest from src import shapes_2d, overlaps_detection class TestOverlappingShapesDetector(unittest.TestCase): """ Tests for the class OverlappingShapesDetector """ def setUp(self): """ Define a fixture for the tests...
2cc7824de6975d550edba927d46e951c9ea5ae09
AdamZhouSE/pythonHomework
/Code/CodeRecords/2535/60631/256139.py
380
3.765625
4
def maxChunksToSorted(arr): res=0 n=len(arr) tmp=arr.copy() tmp.sort() max_val=0 for i in range(n): if arr[i]>max_val: max_val=arr[i] if tmp[i]==max_val: res+=1 max_val=0 return res a=input().replace('[','').replace(']','').split(',') b=[] ...
e3636a8e36cab6df55aee2f4efefa56efb46fd5b
harshsodi/DSA
/Leetcode/Trees/Medium/1038_binary_search_tree_to_greater_sum_tree.py
882
3.6875
4
# Runtime: 16 ms, faster than 83.76% of Python online submissions for Binary Search Tree to Greater Sum Tree. # Memory Usage: 11.8 MB, less than 100.00% of Python online submissions for Binary Search Tree to Greater Sum Tree. # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): #...
74c27848c2153258f3a5632c9890d5f103096463
RajeshReddyG/3GRM
/Academics/Sem1/Python/mt.py
93
3.953125
4
#Multiplication table using while i=1 while(i<=10): print("5*",i,"=",5*i) i=i+1
de9d99d5e3e4d1ce17d9190eeb4a2c687305b9b9
Raeebikash/python_class1
/python_class/for_loop_practice30.py
338
4.0625
4
#practice for loop # ask user a number like 1235 # calculate sum of digits ---->1+2+3+4 #l#"1256"---->logic #num = "!@56", length = 4 #int (num[0])--->1 #int(num[1])---->2 #int(num[2])---->3 #(num[3])---->6 #i--->o to 3 total = 0 num = input("enter the number:") for i in range(0, len(num)): total += int(num[i]...
e0544e08b8f389067af38881d90fb7b05a64e082
paalso/hse_python_course
/5/5-05.py
1,025
4.375
4
# https://www.coursera.org/learn/python-osnovy-programmirovaniya/programming/jqFOL/flaghi/submission # Флаги # Напишите программу, которая по данному числу n от 1 до 9 выводит на экран n # флагов. Изображение одного флага имеет размер 4×4 символов, между двумя # соседними флагами также имеется пустой (из пробел...
a9b93b86333f645af85e455eee81063db7802dca
Escapist-007/AI_Projects
/Sudoku/code/python/Square.py
325
3.515625
4
class Square: def __init__(self,x,y,val): self.Domain=[] if val!=0: self.pre_assigned = True self.assigned = True self.Assigned_value = val self.Domain.append(val) else: self.pre_assigned = False self.assigned = False for i in range(0,9): self.Domain.append(i+1) self.Assigned_val...
50e0d08dc6cffba03b3035f08cda319d4a8ec20d
linvis/leetcode
/archive/medium/15_3sum/solution.i.py
1,038
3.5625
4
''' Brief: iterate 2 number, and get the third num3 = 0 - num1 - num2, check if the num3 is in nums; Complexity: O(N2), but I got a Time limited Exceed. the worst: the result list is the nums list, then the complexity maybe O(N3) ''' class Solution(object): def threeSum(self, nums): """ ...
501c1350accb3cfe7c2d2330acce58344b8b0763
ccallen001/Playing-w-Python
/gen.py
181
3.703125
4
def yielder(list_nums): for num in list_nums: yield num my_list_nums = [1, 2, 3] # print(yielder(my_list_nums)) for x in yielder(my_list_nums): print x
b16ef6cdda6441e2a3c14a557d3f3a6711de6b48
shumpei-noda/getTips
/tips_count.py
669
3.546875
4
import sys import json def count(paths): n_tips_list = [] for path in paths: with open(path, 'r') as open_json: tips_json = json.load(open_json) n_tips = 0 for tips in tips_json: n_tips += len(tips_json[tips]['tips']) n_tips_list += [n_tip...
fa806f3040644f993a1366ee24114adf3d843987
pylearninggroup/Python
/0324/mjw/作业2.py
253
3.671875
4
#猜数字 import random import sys result=random.randint(1,20) while True: s= int(input("猜测值")) if s<5: print("猜小啦!") elif s>5: print("猜大啦!") elif s==5: sys.exit() # TODO:稍微注意下格式
24ac308b1f86080be86ad0f125da974a0b9a0ecb
juanjosua/codewars
/test_autocomplete.py
696
3.9375
4
""" This file is to learn how to use pytest. """ # https://www.codewars.com/kata/5389864ec72ce03383000484/train/python import pytest import os def autocomplete(input_, dictionary): #your code here result = [] for d in dictionary: if d.find(input_) == 0: result.append(d) ...
d20fdf2d56ba08a88e67ad356a372a45626592b3
Ocango/fluent_python
/Section3/decorator_test.py
2,922
3.515625
4
#!/usr/bin/python # -*- coding:utf-8 -*- #示例 def deco(func): def inner(): print('running inner()') return inner @deco def target(): print('running target()') target() ''' 此方法其实就是 def target(): print('running target()') target = deco(target) 仔细看区别 ''' # 计算移动平均值 ## 使用类定义可调用对象 class Averager(): ...
19b4d58dd205d61ef46450f1f7aecc628de28406
arianacd/unit8
/daily_exercises.py
1,135
4.46875
4
# by ariana daney # last modified november 15, 2019 # unit 8 daily exercises from tkinter import * root = Tk() # ex. 1 # hello_world = Label(root, text="Hello, World") # hello_world.grid(row=1, column=1) # ex. 2 # def say_hi(): # other_name = user_name.get() # your_name.set(other_name) # if other_name...
21cc83f6faf8371a67134bf334f25b90d45316b5
jpike/PythonProgrammingForKids
/BasicConcepts/SyntaxErrors/Volume1_Chapter1_SyntaxErrors_Fixed.py
313
3.75
4
# Print statements with syntax errors (fixed). print('Hello, world!') print('This is a series') print('of print statements.') print('The end!') print("But not really!") print("Here's another print statement!") print("And here's another one!") print("This will be the last one of these initial print statements.")
1fa24c548489fd5e0a6ffa3b3e5b17a973870295
rserafico1/MIS3640
/factor.py
761
4.34375
4
#1 #Factoring of integers. #Write a program that asks the user for an integer and then prints out all its factors. #For example, when the user enters 150, the program should print 2 3 5 5 #Works with 'Terminal', rather than 'Debug Console' # INSTRUCTIONS # 1. Run program on 'Terminal' # 2. Enter integer # 3. Lis...
844878fa3823064172f4a8d1ddc5a689b03695f8
UB-info/algorismica
/exercici9.py
12,341
3.515625
4
#Autor: Rafael Arquero Gimeno import math import random import time import collections #agafa length bits comencant a contar per la dreta # bitsplit(101001, 0, 3) = 001 def bitsplit(n, first, length): return (n >> first) & (2 ** length - 1) def binlen(n):#longitud d'un enter representat en binari if n == 0: ...
5f20dee9c858992ae383022b31f45c2d016b372e
acamilass/learning-python
/parte1/ex-20/ex-20.py
861
3.703125
4
res = "" compras = [] total = 0 valid_valor = False while res != "n": prod = input("Digite o nome do produto: ").capitalize() # qtd = int(input("Quantidade do produto: ")) while valid_valor == False: valor = input("Digite o valor do produto: ") try: valor = float(valor) ...
5a01de33e968ec53822be6fe32741709426c86bc
Abdullah3553/algorithms_visualizer
/bubble_sort.py
3,963
3.53125
4
from tkinter import * from tkinter import messagebox import shared_functions def main(arr, maxm_num): main_window = Tk() lop1 = 0 lop2 = 0 is_sorted = False cur_op = 1 def swap_lbls(element1, element2): # a function to swap 2 labels :) if int(element1['text']) < int(element2['text'])...
0bb00b708b57acbd2355e2a7eaacf69bedcad9ab
Mybik/projecteuler-
/1.py
354
4.375
4
''' 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.''' numbers = range(1000) needed_numbers = [] for i in numbers: if i % 3 == 0 or i % 5 == 0: needed_numbers.appen...
3430c92f003b077cc6912b1b8594240bc8136464
TessFerrandez/AdventOfCode-Python
/2019-2/day13-pygame.py
1,922
3.53125
4
from ComputerV4 import Computer, InputInterrupt, OutputInterrupt import numpy as np import pygame EMPTY = 0 WALL = 1 BLOCK = 2 PADDLE = 3 BALL = 4 WHITE = (255, 255, 255) colors = { EMPTY: (255, 255, 255), WALL: (0, 0, 0), BLOCK: (255, 0, 0), PADDLE: (0, 255, 0), BALL: (0, 0, 255) } TILE_WIDTH ...
03fc8181d950320a014cad7716762348c11db1d9
mattheal/MyPython-Practice
/EulurOne.py
443
4.28125
4
#Find all multiples of 3 or five below 1000 summA = 0 summB = 0 for num in range(1000): if num % 3 == 0: summA += num print (num, num / 3) elif num % 5 == 0: summB += num print (num, num / 5) print ("The sum of all multiples of 3 is %d " %summA) print ("The su...
3c3cc9ff15caa478dc1453fafdd7f09a11faefb2
fridriks98/Forritunarverkefni
/Undirbúningsnámsskeið/for_loops4.py
298
3.859375
4
#Verkefni_4 low = input("Please input a number: ") high = input("Please input a higher number: ") Sum = 0 low_int = int(low) high_int = int(high) for x in range(low_int, high_int+1): if x % 2 == 0: Sum += x print(x) print("The sum of the numbers is: ", Sum)
d4f744844a1e9fda43fe5bd6f663c66cf3dc7744
RichardSrn/Advanced_Algorithmics_Edit_Distance
/algorithms/ed_dp_2_mat.py
2,897
3.6875
4
#! /usr/bin/env python3 import numpy as np def mat_dp_ed(x,y) : """ Parameters : x,y : strings. Return : l[1,:] : the last line of the array created by the dynamic programming approach. """ #add blank space at the beginning of each words. #correspond to row 0 and column 0 of the array. x=' '+x y=' '+y #n and...
278d544fde87b96affd94b8843a6e5d7db6d9e1d
novayo/LeetCode
/2018_Check_if_Word_Can_Be_Placed_In_Crossword/try_3.py
2,134
3.703125
4
class Solution: def placeWordInCrossword(self, board: List[List[str]], word: str) -> bool: height, width = len(board), len(board[0]) n = len(word) for i in range(height): for j in range(width): # check up if (i-n >= -1) an...
229a149dbe481966a2e8f014f72d56c0e78c9569
crucio-009/DARE2FLY
/main.py
8,501
3.53125
4
import random # random number generation import sys # used sys.exit() to exit the program import pygame from pygame.locals import * # basic pygame imports # Global variables for the game FPS = 32 SCREENWIDTH = 289 SCREENHEIGHT = 511 SCREEN = pygame.display.set_mode((SCREENWIDTH, SCREENHEIGHT)) GROUND_Y = ...
68299d793dc2efb75c484933d59703c45f91a41f
bhowmik23/Python-Basic
/pythonBasic/object introspection.py
925
3.625
4
class Employee: def __init__(self, fName, lName): self.fName= fName self.lName= lName # self.email = f"{fName}.{lName}@gmail.com" def explain(self): return f" This emlpoyee is {self.fName} {self.lName}" @property def Email(self): if self.fName==None or ...
d275bf929f932ba3b06c0e04b40b53b159e25891
rpalominosc/python
/Aprendizaje/Decoradores/practica_decoradorI.py
618
3.609375
4
def funcion_decoradora(funcion_parametro): def funcion_interior(*args,**kwars): # Acciones adicionales que decoran print ("Vamos a realizar un cálculo: ") funcion_parametro(*args,**kwars) #Acciones adicionales print("Se ha finalizado el calculo: ") ...
bc3120c420d736a013aab8217a07d22a0a989a63
bangalia/Superhero-Team-Dueler
/dog.py
450
3.625
4
class Animal: def __init__(self,name,sleep_duration): self.name = name self.sleep_duration #print("dog initialized") def sleep(self): print( "{} sleeps for {} hours {}".format( self.name, self.sleep_time)) class Dog(Animal): ...
ea96ca496fa397ac17e32fdef70521029471f3a6
grabania/adventure-game
/adventuregame.py
3,059
3.859375
4
import time import random import sys sys.setrecursionlimit(1500) enemy = ["dragon", "troll", "gorgon", "pirate"] name = random.choice(enemy) def print_pause(message_to_print): print(message_to_print) time.sleep(0.7) def enter_1_or_2(): print_pause("(Please enter 1 or 2)\n") knock_or_peer = input(...
46e90c2882cebb9b51cf6a2a7653f4a88dbc6f41
ai-distill/UsePyToDataAnal
/Chapter 4/4.1/数组转置和轴对换.py
777
3.640625
4
import numpy as np arr = np.arange(15).reshape((3, 5)) # print(arr) # 对数组进行转置 # print(arr.T) # 也是对ndarray进行转置 # print(arr.transpose()) # arr = np.random.randn(6, 3) # 计算矩阵内积 # print(np.dot(arr.T, arr)) # 对于高维数组,tranpose需要得到一个由轴编号组成的元祖才能对这些轴进行转置(比较费脑子) # arr = np.arange(16).reshape((2, 2, 4)) # print(arr) # 对高维矩阵...
7106fdb27c9b050d64d46f765cc2478696b6dc2c
singnet/offernet
/graphs/generators/example_scripts/graphGenerator.py
724
3.5
4
#!/usr/bin/env python import networkx as nx import sys print ('Arguments: numberOfVertexes,outputFileName') print ('Generating cycle graph graph: ') print ('Vertexes: ' + sys.argv[1]) # print ('Edges: ' + sys.argv[2]) print ('To file: ' + sys.argv[2]) G = nx.DiGraph() nx.cycle_graph(int(sys.argv[1]),G) print ('Turns ...
aed98f8a1dbbc2bd364e9713bf864ce25e1d95d7
TobiasPleyer/blog
/code/post58/do_initial.py
3,920
3.78125
4
import unittest def do(s: str) -> str: """The do-function. Takes a string containing the computation written in Haskell style do-notation and returns a string with the computation rewritten using the bind (>>=) and sequence (>>) functions of the monad type class. This function will render the who...
67a9d69ed8cbd14725e2730ad38b19c3f2f2a980
Lucas-Moura-Da-Silva/UNIFESP-aulas-optativas-de-Python
/Exercícios/Exercícios_aula6_08-06_até_14-06/Ex003.py
822
4
4
'''3) Escreva uma função que receba dois números e retorne True se o primeiro número for múltiplo do segundo.''' #cores cores = {'limpa':'\033[m', 1:'\033[1;30m', 2:'\033[1;31m', 3:'\033[1;32m', 4:'\033[1;33m', 5:'\033[1;34m', 6:'\033[1;35m', 7:'\033[1;36m...
7a04606ce16bbc1c7759a946acedacb9d7e6c37c
edo9300/Advent-of-code
/2019/day 01.py
357
3.71875
4
file=open("input1.txt","r",encoding="UTF-8") total=0 for line in file: total+=int(line)//3-2 print("result 1:",total) def GetFuel(input): if input<6: return 0 return (input//3)-2 + GetFuel((input//3)-2) file.seek(0) file=open("input1.txt","r",encoding="UTF-8") total=0 for line in file: total+=GetFuel(int(line)) ...
b1f496ce6d71a98cdeb6f618885ecabc073a8f8e
babdenour/Python
/FacPython/TD3/td3ex7.py
215
3.75
4
#coding: utf-8 #somme des entiers nb1 = int(input("Donner le premier entier: ")); i = 0; somme = 0; n = 0; while (n != 0): print("Donner l'entier suivant"); print("La somme des entiers saisis est de ", somme);
6b07ddadffecc9fc3f95cc2417e9d7f3dc39e4d6
Navesz/python
/Exercícios/ex009.py
289
4.4375
4
num = int(input("Insira um número: ")) print(f" {num} * 1 = {num*1} \n {num} * 2 = {num*2} \n {num} * 3 = {num*3} \n {num} * 4 = {num*4} \n {num} * 5 = {num*5}") print(f" {num} * 6 = {num*6} \n {num} * 7 = {num*7} \n {num} * 8 = {num*8} \n {num} * 9 = {num*9} \n {num} * 10 = {num*10}")
d567fb607a09e23ec51f224d5687931f195788c5
AntonBeletsky/python_learn
/python/learn_python/basics/input.py
262
3.5
4
s1 = input("input data: ") print("you data: " + s1) a = 1; b = 2; print("ab", a, b) c = 5; d = 6; pass # if if (a == 1 and b == 2 and c == 3 and d == 4): # Не забываем про двоеточие print('spam' * 3) else: print('lolka')
7bc50870c6de4c1f209e119e10ed516a86caf8d3
beidou9313/deeptest
/第一期/上海-棒棒糖/第二次任务-每日代码练习/2017-2/2-2/SQlite.py
1,109
3.875
4
# 导入 SQLite 驱动: import sqlite3 # 连接到 SQLite 数据库 # 数据库文件是 test.db # 如果文件不存在,会自动在当前目录创建: conn = sqlite3.connect('test.db') # 创建一个 Cursor: cursor = conn.cursor() # 执行一条 SQL 语句,创建 user 表: cursor.execute('create table user (id varchar(20) primary key, namevarchar(20))') # 继续执行一条 SQL 语句,插入一条记录: cursor.execute('insert into us...
060d0abf3a2c0eec55ff4a5c9cf6dd455b7f98b8
SSShinorina/UVA-Problems
/12578.py
198
3.53125
4
import math t=int(input()) pi=math.acos(-1) for i in range(0,t): l=int(input()) wid=l*0.60 radius=l/5 red=pi*radius*radius green=l*wid-red print("%.2f"%red,"%.2f"%green) exit
fcc28c1028010d73fd0cc03494236be7f7563af9
DanielAShurmer/PythonBootcamp
/Day 2/FindSubStringInString.py
353
3.953125
4
InputString = input("Please enter a Message:") Substring = input("Please enter a Substring to Search:") counter = 0 NumberOfMatches = 0 SubStrLen = len(Substring) while counter < len(InputString): if InputString[counter:counter+SubStrLen] == Substring: NumberOfMatches += 1 counter += 1 print("This substring appe...
03ca47bb83de0e4324cc439cc15b5822a9b7be30
huangxiaofeng10047/fun_acm
/leetcode/Binary Tree Level Order Traversal.py
686
3.78125
4
# Definition for a binary tree node # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: # @param root, a tree node # @return a list of lists of integers def levelOrder(self, root): if root == None: ...
3b1dfb9284f3d7495dfcb732b6ed0be7c669a68a
NBakalov19/SoftUni_Python_Fundamentals
/02.Lists/algorithm_exercise/reverse_list.py
298
3.59375
4
if __name__ == '__main__': nums = list(map(int, input().split(' '))) for index in range(len(nums) // 2): first_element = nums[0 + index] last_element = nums[-1 - index] nums[index] = last_element nums[-1 - index] = first_element print(*nums)
3a48512568f54d7d8d503cdb7536bb5fa16df6f7
saurabh28march/AeroProject
/Chatbot.py
5,196
3.890625
4
import nltk import warnings warnings.filterwarnings("ignore") ​ # nltk.download() # for downloading packages import numpy as np import random import string # to process standard python strings # For our example,we will be using the Wikipedia page for chatbots as our corpus. # Copy the contents from the page and place ...
29b8685630b14616536f023b96f13aeb94cc3442
dengjoe/py_base
/e02_func.py
2,437
3.96875
4
# -*- coding: utf-8 -*- ## import re import collections from functools import reduce #1. lamda 匿名函数 mul = lambda x:x*x add = lambda x:x+x #2. map:接收一个函数和一个序列,返回一个Iterator,惰性序列 iterable = [1,2,3,4,5,6,7,8,9] m0 = map(add, iterable) print(type(m0), m0) print("Iterable:", isinstance(m0, collections.Iterable)) print(...
e5cfc661bd35a7728a1e6940dd7edb9e25108787
alina-17-08/Sort
/test.py
548
3.59375
4
import unittest import QuickSort import MergeSort from random import randint class SortTest(unittest.TestCase): def test_quicksort(self): for i in range(10): l = [randint(-1000000, 100000000) for x in range(100000)] self.assertEqual(QuickSort.quickSort(l), sorted(l)) def test_...
b59e238b36241e66729e385c72396d133b4bf4c6
laserdazed/laserdaze
/main.py
2,335
4.0625
4
# Умножение длинных чисел с использованием строк. Кандаков В.И. def multiply(num1, num2): len_num1 = len(num1) len_num2 = len(num2) if len_num1 == 0 or len_num2 == 0: return "0" # Записываем поразрядно в виде вектора result = [0]* (len_num1 + len_num2) index_num1 = 0 ...
b12c47726ec81e15648d2b2d2dfd33dbf6ac88ba
Kevinp1402/lab-08-for-loops
/party.py
214
4.125
4
num = input("Lets party! How long til' the party?(Give me a number)"); num = int(num); if(num < 1): print("Party now!") for x in range(num,0,-1): print(num); num=num-1; if (num <1): print("It's PARTY TIME!");
d6c75b1bd60fbf02b560c624cd28a41897646d63
iamgilvan/AlienInvasionGame
/Ship/bullet.py
1,111
4.03125
4
import pygame from pygame.sprite import Sprite class Bullet(Sprite): """ this class manage bullets""" def __init__(self, ai_settings, screen, ship): """" Create the bullet object in the spaceship position.""" super(Bullet, self).__init__() self.screen = screen # Create the rec...
da374755e068f00ed9178cd95736201f66bbfebe
danielchk/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/tests/6-max_integer_test.py
1,183
3.796875
4
#!/usr/bin/python3 """ Unittest for max_integer([...]) """ import unittest max_integer = __import__('6-max_integer').max_integer class TestMaxInteger(unittest.TestCase): """define unittest""" def test_int(self): self.assertEqual(max_integer([4, 6, 8, 10]), 10) def test_neg(self): self...
61922c60391ea5feaed91581a5fd64551155be11
ngugikubai/Learning-python
/favourte_languagesdictio.py
329
4.09375
4
favourite_languages { 'william':'python', 'wendy':'javascript', 'jimmy':'java', } friends = ['william','wendy'] for name in favourite_languages.key(): print(name.title()) if name in friends: print(" Hi"+ name.title() + ", I see your favourite language is " + favourite_languages[name].title(...
d5eaa95ac740772f1cac90e0e3e323dda38f8e7d
TonHai1111/DB_Implementation
/Database Implementation/Python/Experiments/Evaluation_1.py
7,777
3.515625
4
#!/usr/bin/python #TODO: # 1. Read data from postgres database # 2. Insert data to IB-Tree/IBPlus-Tree # 3. Print the tree # 4. Do some queries # 5. Obtain the results from IBTree import IBTree from PLITypes.IBEntry import * from PLITypes.dataTypes import * import tools from IBPlusTree import IBPlusTree import re fro...
8fcdea50415baf8a32b827ee4d047688e0ac8467
u-ever/CursoEmVideoPython
/exercises/ex022_Analisador_de_Textos.py
507
4.03125
4
nome =str(input('Digite seu nome completo: ')).strip() print('Analisando seu nome...') print('Seu nome em maiúsculas é {}'.format(nome.upper())) print('Seu nome em minusculas é {}'.format(nome.lower())) print('Seu nome tem ao todo {} letras.'.format(len(nome) - nome.count(' '))) # - nome.count(' '))) tira os espaços pr...
457cdb4b76de9c8f508ea82acc365bebec4a1fea
jinurajan/Datastructures
/LeetCode/bloomberg/discussions/find_all_routes.py
1,674
3.875
4
""" Given one directional airport connections, devise a solution that can provide the route from Airport A to Airport B. Implement 2 functions: one that adds a one-directional airport connection between 2 airports, and second that return out all possible routes between an origin and a destination. This could be done b...
565a36219ec34444a2a0109a8af444a7ac1264ae
griadooss/HowTos
/Tkinter/08_widgets_checkbutton.py
2,632
4.4375
4
#!/usr/bin/python # -*- coding: utf-8 -*- """ ZetCode Tkinter tutorial This program toggles the title of the window with the Checkbutton widget author: Jan Bodnar last modified: December 2010 website: www.zetcode.com """ '''Tkinter widgets''' #In this part of the Tkinter tutorial, we will cover some basic Tkinter...
b8b68d6343fb7770cec782cf2d772d721dee309c
subedibimal/iw-assignments
/assignment/9.py
438
3.84375
4
numbers = [1,2,3,5,6,7,9,13,16] def binarySearch(arr: list[int], l: int, r: int, x: int) -> int: if (r >= l): mid = int(l + (r - l) / 2) if (arr[mid] == x): return mid if (arr[mid] > x): return binarySearch(ar...
80918dcc6b9f83c73ccc255ee09045b4b4793a5e
rerafyaw/ToolBox-Geocoding
/mbta_finder.py
3,241
3.546875
4
""" Geocoding and Web APIs Project Toolbox Anderson Ang Wei Jian - Toolbox #3 Find the MBTA stops closest to a given location. Full instructions are at: https://sites.google.com/site/sd15spring/home/project-toolbox/geocoding-and-web-apis """ import urllib # urlencode function import urllib2 # urlopen function (be...
cd01312aede816ead4546f309c4afc89e7a8b8ac
rafaelperazzo/programacao-web
/moodledata/vpl_data/25/usersdata/116/12019/submittedfiles/av1_3.py
420
3.6875
4
# -*- coding: utf-8 -*- from __future__ import division import math a = input ('insira o valor de a:') b = input ('insira o valor de b:') if a>=b: c=a%b cont=0 while c>0: c=a%b cont = cont +1 a=b b=c print (a) print (cont) if b>a: c=b%a cont=0 while c>0:...
9c50961f67196a00751736eebf0bbb36691032ed
tejanidhi/Python
/RotatingCharacters.py
835
3.546875
4
inputString='abDEg:1789,bcdFw:2679' val=inputString.split(',') def square(x): sum=0 while x>0: rem=x%10 sum=sum+rem*rem x=x//10 return sum first_value=val[0] first_split=first_value.split(':') first_string=first_split[0] first_integer=first_split[1] sum_one=square(int(first_inte...
88e0adcaa22677e95a0eb59c6a34de476d24b18b
Huxhh/LeetCodePy
/1-50/031NextPermutationMedium.py
461
3.5625
4
# coding=utf-8 def nextPermutation(nums): n = len(nums) - 2 while n >= 0 and nums[n] >= nums[n + 1]: n -= 1 if n >= 0: j = len(nums) - 1 while j >= 0 and nums[j] <= nums[n]: j -= 1 temp = nums[j] nums[j] = nums[n] nums[n] = temp end = nums[...
adbf19552e91d0f750ab56e0b59d283af0f78550
Youngfellows/PythonStudy
/study/day01/02_Python字符串.py
7,256
3.953125
4
# 1.字符串的连接 str1 = '加油' str2 = "武汉..." str3 = str1 + str2 print(str3) # 2.字符串的合并 # Join将序列中的多个字符串,合并成一个字符串 # 语法:任意字符串.join(多字符串组成的序列) urlList = ['www', 'google', 'com'] url = '.'.join(urlList) print(url) # 3.字符串相乘 line = "*" * 30 print(line) # 4.字符串切片 # 字符串、列表、元组都支持切片操作,主要是在对象中截取一部分元素的操作 # 序列切片语法:序...
01c2440af3c33a44286ed8c2ff4cf1c3e46bb63d
yugwas/python-functions-worksheet
/projects/min3/min3.py
525
4
4
def min3 (num1, num2, num3): if num1 <= num2: if num1 <= num3: return num1 else: return num3 else: if num2 <= num3: return num2 else: return num3 # Uncomment this code to test your function print(min3(4, 7, 5)) print(mi...
f447e584d565bf547f349a8d2f51c64e7b40b9aa
FahimCC/Python
/Code Testing Technique/FirstTechnique.py
217
3.734375
4
def average(L): if not L: return None return sum(L)/len(L) def test_average(): assert average([1,2,3,4,5]) == 3.0 , "average() produced incorrect result" if __name__ == "__main__": L = [7,3,4,2,9] average(L)
afa38d3458f5f0ef21f106584ad93bf2bc40df30
latika18/interviewbit
/Q033_add_two_linkedlists_values.py
3,052
3.796875
4
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) Output: 7 -> 0 -> 8 342 + 465 = 807 Make sure there are no trailing ...
8f1c24e9ee98e67ce5212751741b2610ff1420d7
williamstern/Simple-Fishing
/Fishing.py
3,317
4.28125
4
# William Stern # 05.02.2017 import time import random class Fishing(object): def __init__(self): self.highscores = {} self.fishinglog = {} def setup(self): ''' This makes for an easy setup''' # A print of a pond print('| 1 | 2 | 3 |') ...
54796c00a5a8c6b433a3939496947fd11a785226
KirthanaRupanagudi/ModulesExample
/main.py
132
3.5625
4
import random #Heads and tails game random_side = random.randint(0,1) if random_side == 1: print("Heads") else: print("Tails")
773dd2ec5372de109a2c1a2d2a0c7ba7a9a2222a
SatpreetMakhija/Sentiment-Analysis-reviews-Booking.com
/top_ten.py
1,516
3.65625
4
''' Script to return the top 10 hotels of all cities in 1 json file ''' import json from pathlib import Path # sorting based on polarity def polaritySort(data_content): temp = sorted(data_content, key=lambda x: x[2]) temp.reverse() return temp def scoreSort(data_content): temp = sorted(data_content, key=l...
cdff0d5595fa0bd724bd680388de42409e8927d5
victornovaiss/python-CeV
/exercicios/ex25.py
132
3.6875
4
nome = input('Digite seu nome: ') testeLogico = 'silva' in nome.lower() print('Tem ´Silva´ no nome: {}'.format(testeLogico))
ab859da47790d3546dc82315410bf62015d8310d
ajhofmann/PyEuler
/Problems 50-59/Problem 50.py
1,543
3.578125
4
## Project Euler Problem 50: ## The longest sum of consecutive primes below one-thousand that adds to ## a prime, contains 21 terms, and is equal to 953. ## Which prime, below one-million, can be written as the sum of the most consecutive primes? max = 21 num = 953 import math def isPrime(n): if n == 2 or n == 3...
9de9ec77a325a9a84a8cb44d5fad532123a2c3a1
onp/ProjectEuler-py
/Problem028.py
611
3.578125
4
# Project Euler Problem #28 # Number Spiral Diagonals ''' Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows: 21 22 23 24 25 20 7 8 9 10 19 6 1 2 11 18 5 4 3 12 17 16 15 14 13 It can be verified that the sum of the numb...
a9d016c90db623aaa19cf2cbcb20b3dfef086360
LennyDuan/AlgorithmPython
/55. Jump Game/answer.py
345
3.6875
4
def canJump(self, nums) -> bool: if not nums: return False i = 0 max_index = nums[i] while i < len(nums) and i <= max_index: new_index = nums[i] + i max_index = max(max_index, new_index) i += 1 return i >= len(nums) nums = [2, 3, 1, 1, 4] nums = [3, 2, 1, 0, 4] pr...
dd8bfbd28b91fcf9edf0b0650c08d61547403f38
gebremedhin85/python-and-data-science-tools
/week2/week2-homework.py
2,469
3.9375
4
# Week-2 homework # 1. Write fizz_buzz function # from pywin.mfc.object import Object def fizz_buzz(number): if number % 3 == 0 and number % 5 == 0: return "FizzBuzz" elif number % 3 == 0: return 'Fizz' elif number % 5 == 0: return 'Buzz' else: return number print(fiz...
c5ca1479d816139c30107887eb9f68b9c8fb0bb9
lechodiman/IIC2233-Learning-Stuff
/Econometrics/linear_regression_example.py
981
3.609375
4
import pandas as pd from sklearn.linear_model import LinearRegression import numpy as np from sklearn import cross_validation, preprocessing import matplotlib.pyplot as plt n_clients = [8, 7, 6, 4, 2, 1] distance = [15, 19, 25, 23, 34, 40] my_dict = {'Number Clients': n_clients, 'Distance': distance} df = pd.DataFra...
849e378bf0d83b2d51928003a9d432cfd02a7bc2
yangzhipenggit/untitled
/test.py
424
3.65625
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- """================================================= @ProjectFile:PyCharm->untitled -> test @Author :yzp @Date :2021/9/5 14:52 ==================================================""" from yzp import Yzp print "这是一个测试" for i in range(1,10): print ("这是第"+str(i)+"次...
7089698932ffcfb212a28b394551ee36169a9f1b
nkansako/NLP_project
/8_phonetic_analysis.py
10,101
3.78125
4
import re import nlp_config as config import nlp_helpers as helpers import preprocessing import fuzzy import csv import matplotlib.pyplot as plt # constants results_path = 'results/8/' # TASK DESCRIPTION # 8. Compare the phonetic of starting word and ending word of each line of the poem. # Use the “Fuzzy” library i...
89aae58a1d0f8aff2a721e94964cfc2696a5db9a
ying-li-python/python-challenge
/PyBank/main.py
3,063
3.984375
4
""" This script is designed to help analyze financial records. Results will return: Total profit for the period Total months Average change Month that showed greatest increase or decrease of profits Example: $ python main.py """ # import dependencies import os import csv # add variable to the CSV file bank...
88063e197f97ce121e57e7b5363b960c27263190
xuziyan001/lc_daily
/71-simplify-path.py
806
3.796875
4
class Solution: def simplifyPath(self, path: str) -> str: stack = [] name = '' path += '/' for each in path: if each == '/': if name == '.': pass elif name == '..': if len(stack) == 0: ...
e59f545155d1ce59c6b7b07264be41a8a4d07cf7
joshua530/dynamic_programming
/can_sum.py
1,734
4.0625
4
from typing import List def can_sum(target: int, nums: List[int]) -> bool: if target == 0: return True if target < 0: return False for num in nums: if can_sum(target - num, nums): return True return False def can_sum_memoization(target: int, nums: List[int], calc...
1a4216c9ab47e05428a2c87763765c00cae876ee
NiallEHunt/AIB-DataHack-2017---TheHuntForGild
/HuntingForBikeNumbers.py
2,039
3.75
4
import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt from sklearn.cross_validation import train_test_split from sklearn.linear_model import LinearRegression verbose = True # Reading in data data = pd.read_csv("data.csv", index_col=0) if verbose: print("Reading data.csv ..."...
0e97d923079b1474225174b1eeb5de2b737e185a
tomohirohiratsuka/MITLearning
/mit3_3.py
1,409
3.84375
4
import sys print(sys.argv) x = int(sys.argv[1]) y = int(sys.argv[2]) z = int(sys.argv[3]) bestSoFar = 0 # variable that keeps track of largest number # of McNuggets that cannot be bought in exact quantity packages = (x, y, z) # variable that contains package sizes ans = {} candidates = list(range(1, 201)) for n in ...
243c28dfcb40276f5cdfc0831daa197f424094eb
felixjchen/learning
/deep-q-learning/minesweeper.py
3,772
3.765625
4
import numpy as np MINE = -1 COVER = -2 class Minesweeper(): def __init__(self, n, m, reward_profile): """ An nxn minesweeper board with m mines n -- length of side m -- number of mines """ self.size = n self.mines = m self.reward_profile = reward...
83e7aaef62d8d9ef6e25ca2f940ae69179202c0b
TechPuppies/leetcode-python
/add_binary.py
1,108
3.796875
4
# coding=utf-8 # AC Rate: 25.9% # SOURCE URL: https://oj.leetcode.com/problems/add-binary/ # # # Given two binary strings, return their sum (also a binary string). # # # For example, # a = "11" # b = "1" # Return "100". # # import unittest class Solution: # @param a, a string # @param b, a string # @retur...
8b96e904c0ca1c57232240939d799eed3cbee1e2
1tianjing/python-
/2017年旧代码/python基础/2018/王者荣耀版.py
3,044
3.828125
4
print('欢迎来到召唤师峡谷!') name = "wangzherongyao" print(name.title())#首字母大写 print(name.upper())#全部字母大写 first_name="郑" last_name="开州" full_name=first_name+" "+last_name print(full_name) print('尊敬的召唤师:'+full_name+',欢迎来到召唤师峡谷!') print("欢迎来到召唤师峡谷!") print("\t欢迎来到召唤师峡谷!")#文本后缩进一个单位 print("\n欢迎来到召唤师峡谷!")#文本换行 msg = " 努力有用的话还要...
504f05d61d5b33d34881fc0352e62c1224c6005e
janet5141li/lesson1
/tk1.py
442
3.90625
4
from tkinter import* def createWindow(window): xf=Frame(window,relief=GROOVE,borderwidth=2); Label(xf,text="這是LED控制區").pack(pady=10,padx=100); Button(xf,text="LED Off").pack(side=LEFT,expand=YES,fill=X); Button(xf,text="LED On").pack(side=LEFT,expand=YES,fill=X); xf.pack(pady=10,padx=10); if ...
0df93d18f8d03a291de89a9795e86c0af37515a9
ChampionJakkrit/204111_FUNDAMENTALS_OF_PROGRAMMING
/Laboratory 3/Lab03_1_600510533.py
962
4.21875
4
#!/usr/bin/env Python3 # จักรกฤษณ์ บุญเนตร # 600510533 # Lab 03 # Problem 1 # 204111 Sec 01A import math def main(): surface_area = float(input("input surface area: ")) # รับค่าจากผู้ใช้งาน radius = find_r_from_surface_area(surface_area) # หารัศมีจากพื้นที่ผิว volume =sphere_volume(radius) # ห...
f40246634d78b20b8da8d80aab203169fa4027b8
jackcht/Hangman
/game.py
6,242
3.578125
4
#!/usr/bin/python import time import collections import re # Game class class HangmanGame: # 0 means LOSE; 1 means WIN WON = 1 LOST = 0 ONGOING = -1 MAXGUESS = 6 UNKNOWN = '_' def __init__(self, real): self.real = real.lower() self.target = list(self.UNKNOWN * len(self.re...
1992ce87deeea0c2f65160c58328e66aa6c205ff
ZAKERR/-16-python-
/软件第六次作业/软件162/2016021112张瑞芳/奥运五环.py
481
3.875
4
#功能:运用turtle奥运五环 #编写人:张瑞芳 #时间2018.10.18 import turtle ipaomi=turtle ipaomi.shape('turtle')#把画笔设置为小乌龟 ipaomi.pensize(width=3)#设置画笔宽度 color = ['blue','black','red','yellow','green'] p_x = [-110,0,110,-55,55] p_y = [-25,-25,-25,-75,-75] for i in range(5): ipaomi.color(color[i]) ipaomi.penup() ...
2c86802bfad450718e1061c91cfd4eccc66eaea3
not-notAlex/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/9-print_last_digit.py
108
3.78125
4
#!/usr/bin/python3 def print_last_digit(number): c = abs(number) % 10 print(c, end="") return c
284c53ba9e951b65086ff312e7a7f5fe3bf37d90
SahithyaVuppala/Assignment4
/4.py
416
3.875
4
# #4. # Question: # Define a class named American which has a static method called printNationality. # # Hints: # # Use @staticmethod decorator to define class static method. # # class American : def __init__(self,nationality): self.nationality = nationality @staticmethod def printNationality(nation...
1e564c74d41177c75de518bc58a3912ae852ab9e
JamesMcPeek/Python-100-Days
/Day 10.py
923
4.25
4
def add (n1, n2): return n1 + n2 def subtract (n1, n2): return n1 - n2 def multiply (n1, n2): return n1 * n2 def divide (n1, n2): return n1 / n2 operations = {"+": add, "-": subtract, "*": multiply, "/": divide} def calculator(): num1 = float(input("Wha...
6aa49279774160e725ce8cda9a7de69cb773ceff
SaudiWebDev2020/Omaima_Abuzaid
/Assignments/Python/Assignments/For_Loops_Basic_I.py
1,101
3.8125
4
## Print all integers from 0 to 150. for i in range (0,151,1): print(i) ## Print all the multiples of 5 from 5 to 1,000 x=5 while x <=1000: print(x) x= x*5 ##Print integers 1 to 100. If divisible by 5, print "Coding" instead. If divisible by 10, print "Coding Dojo". for n in range (1,101): if n%5==0: ...
adae18461008cfe19df7765ee924f3e2cf488d36
666syh/Learn_Algorithm
/36._Valid_Sudoku.py
2,928
3.734375
4
""" https://leetcode.com/problems/valid-sudoku/ """ """ Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: Each row must contain the digits 1-9 without repetition. Each column must contain the digits 1-9 without repetition. Each of the 9 ...
7bf4297a5da97ff6d12eddb92dbc708aa99776e2
amruth0007/repository01
/Function.py
223
3.609375
4
def wish(): print("Hello Good eve") def add(x,y): z=x+y print(z) def sub(a,b): c=a-b print(c) def add_sub(a,b): c=a+b d=a-b return c,d result1,result2=add_sub(25,3) print(result1,result2)
80b25dabf3adfa0b9c93792b92f047955e774af6
Sedrak-Khachatryan/BasicITCenter
/Homework/Homework_02/xndir_135.py
249
3.78125
4
x=int(input()) k=[1,2,3,4] def func_1(x,k): for i in k: y=x**(i-1) print(y) def func_2(x,k): for i in k: y=x*i**3 print(y) if x>1: func_1(x,k) elif x<3: func_2(x,k) else: y=10**(-6) print(y)