blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
e1fbb298f97581213c3ecc422c51f5fd59c97b4e
SarthakSharma660/Python_Practice
/Number_Guess/number.py
1,213
4.09375
4
from art import logo import random print(logo) print("I'm tinking a number between 1 and 100") computer_number=random.randint(0,100) # to test the code print(computer_number) user_level=input("Choose a difficulty. Type 'easy' or 'hard': ") def user_lives(): if user_level=="easy": return 10 elif user_...
ae2fc98d9380fd8cb64a92d138c8d304aa0c5f76
fernando-lucena-gil/Python_Course
/dragon.py
1,062
3.984375
4
import random import time def introduction(): print('Estas en una tierra llena de dragones.') print('Frente a ti hay dos cuevas') print('En una, hay un dragon bueno, en la otra, uno malo') def eligeTuCueva(): teeligoati = '' while teeligoati != '1' and teeligoati != '2': print('A que cueva quieres entra...
24d0bb6601b264162f435b4f37c8c10512a15606
nickMingi/myFirstSSH_1.0
/Test4.py
219
3.8125
4
# _*_ coding: cp949 _*_ print 'ﰢ ׸n' d = float(raw_input(" : ")) for i in range(int(d)+1) : print ('*' * i) area = float((d ** 2) / 2) print (' : %s' %area) raw_input()
bd700a73b9ddb4835474d4d529c877159490c492
daniel1dolan/python
/duplicatesAlgo.py
356
3.875
4
# my_list = ["dog", "cat", "bird"] # for (index, value) in my_list: # print(index, value) the_list = [1, 1, 2, 3, 4, 4] def removeDuplicates(list): cleanedList = [] for num in list: if num not in cleanedList: cleanedList.append(num) print(cleanedList) return len(cleanedList...
181f800598660fddb3bbfdbd471a883cae609a9c
jfm44/TestsPython
/Exercices/exo11_Objet.py
265
3.875
4
#Exemple Objet class Test: val = 0 def increment(self): Test.val += 1 t1 = Test() t2 = Test() print("t1.val : ",t1.val) print("t2.val : ",t2.val) print("Appel t1.increment() ") t1.increment() print("t1.val : ",t1.val) print("t2.val : ",t2.val)
269dd36c267ba42b4394fe162db913559fb7b10c
tangooricha/thrive-prototypes
/tectonics/tectonics_DEC_2015.py
4,247
3.671875
4
#a simple test for collisions of a sphere #the quaternion rotation method is used for the rotation #and pure Euclidean distance is used for collisions. #a quaternion is represented as a 4 vector, [a,b,c,d] import pygame import math import random from pygame.locals import * #pygame setup background_colour = (255,255,2...
17d87a731ba92e2991cb803ff02130f4d5a80b72
PaulSibert/gb-python-basic
/lesson_02_05.py
910
4.34375
4
# Реализовать структуру «Рейтинг», представляющую собой не возрастающий набор натуральных чисел. # У пользователя необходимо запрашивать новый элемент рейтинга. # Если в рейтинге существуют элементы с одинаковыми значениями, # то новый элемент с тем же значением должен разместиться после них. ratings = [100, 98, 95, 8...
49780e9638399e5d5dd79e4f88563d12a4222ffa
JJLewis/12SDD-FinanceHelper
/Final/Task 2/Python/tester.py
529
3.625
4
def calculateTaxable(income): if income <= 18200: return 0 if 18201 <= income <= 37000: return (income - 18200) * 0.19 if 37001 <= income <= 80000: return ((income - 37000) * 0.325) + 3572 if 80001 <= income <= 180000: return ((income - 80000) * 0.37) + 17547 if incom...
dcefa2dd2ca5713e3c3f46874eaaa2000e4a71d9
JihoAlgorithm/BOJ
/src/deque/boj10866/Main.py
1,306
3.578125
4
import sys read = sys.stdin.readline write = sys.stdout.write class Deque: def __init__(self): self.deque = [] def push_front(self, x): self.deque.insert(0, x) def push_back(self, x): self.deque.append(x) def pop_front(self): x = self.deque.pop(0) if self.s...
8bf3fb44d0f9bf8235c6f9eef98ce242b5866d94
choroba/perlweeklychallenge-club
/challenge-218/roger-bell-west/python/ch-1.py
730
3.765625
4
#! /usr/bin/python3 def maximumproduct(lst): l = lst l.sort() b = len(l) t = [] for i in range(4): p = 1 if i > 0: for j in range(i): p *= l[j] if i < 3: for j in range(b - 3 + i, b): p *= l[j] t.append(p) return max(t) import unittest class TestMaximumproduct(...
d9a132c6a427380cb279c3801662157ef8166030
dan8919/python
/sort/checkAlfabet/high_frequencey2.py
484
3.8125
4
#가장 많이 등장하는 문자 체크 word = "testk" def highFrequencyLetterCount(word): map = {} for alphabet in word: if map.get(alphabet) == None: map[alphabet] = 1 else: map[alphabet] += 1 print("2map=>", map) max = -1 for key in map: print("key",key,"value=>"...
bdc63390efd70265576c62502db34f93e32ba127
wu95063/HelloWorld1
/About format.py
813
4.59375
5
#关于format函数的理解:format即是格式化的意思. #而格式化字符串,在动态处理某些东西的情况下尤其有用。例如: name='王大锤' character=2 print(f'{name}{character}')#不管是什么东东,只要放到这个大括号里 #所有的变量类型都会被格式化成为字符串类型。 #大括号里的变量,是一种动态的对象,所以格式化字符串对于动态处理很有用。 #->王大锤2 #Another example: Job=input('what\'s yo...
058e53e2b130a7cfac90b204f11cf06b03261b45
ahmedkrmn/Competitive-Programming
/Codeforces/1104B.py
210
3.578125
4
s = input() stack = [] c = 0 for i in range(len(s)): if len(stack) == 0 or s[i] != stack[-1]: stack.append(s[i]) else: stack.pop() c += 1 print("YES" if c % 2 else "NO")
2827131901a9fd769527414caa55e9b35aa9fbe0
Pedrolane/git-101
/program.py
341
4.15625
4
# -*- coding: utf-8 -*- from weather import get_weather city = input("Which city do you want to know the weather for?\n> ") data = get_weather(city) for day in data["consolidated_weather"]: desc = day["weather_state_name"] date = day["applicable_date"] temp = day["max_temp"] print(f"{date}: {desc} ({r...
60b018a42bb9eecaa9d6a40d3b6400b752c4ada2
WHUZBF/python
/python_works/hellow.py
350
3.859375
4
#difine name first_name = " bufan " last_name = " zheng " name = f"{last_name.strip()}{first_name.rstrip()}" #use 'f' #main codes print(f"hello\t{name.title()}\n'may yuo be happy!'") names=['bufan','wenjun',"haoming"] print(names) #"" will be changed into '' names.append('gaozhu') names.insert(1,'dengfeng') pr...
87d3e9b0be816a46652046b82ec013b44896dc80
jerrison/03-Fall-2019-CIS-521
/00-homework/02-homework-02/homework2.py
4,489
3.859375
4
############################################################ # CIS 521: Homework 2 ############################################################ student_name = "Jerrison Li" ############################################################ # Imports ############################################################ # Include yo...
c546d4616c3dbd8c37e3d364c47b555c6ce2ebe3
iammax/leetcode
/solutions/py/p1859_sorting_the_sentence.py
270
3.515625
4
class Solution: def sortSentence(self, s: str) -> str: splitted = s.split() out = [0]*len(splitted) for word in splitted: #print(word, word[-1], word[:-1]) out[int(word[-1])-1] = word[:-1] return ' '.join(out)
647f91bbde0cb17121ec3a21e33e82acd61a655e
seddon-software/python3
/Python3/src/22 JSON and XML/JSON/01-arrays.py
254
3.609375
4
import json # start with Python list mylist = [1, '2', 3, "4", 5] print(type(mylist), mylist) #convert to JSON string s = json.dumps(mylist) print("JSON", type(s), s) # convert back to Python list newList = json.loads(s) print(type(newList), newList)
4e56f040e15f71067bf725fa1c6368fe9600ef62
piyushPathak309/100-Days-of-Python-Coding
/Check String Contain Numbers or not.py
217
4.21875
4
# Write a Python program that check if a string only contains numbers. # # If it does, print True. Else, print False. text = input("Enter a text: ") if (text.isdigit()): print(True) else: print(False)
4dbc94160802605438692fe6a44ab6b7fa4862d3
theyadev/ile-au-python
/minigames/ceasar.py
5,143
3.765625
4
from random import randint from prints import printAt, printAnimation from Colors import TextColors from settings import * def caesarize_letter(letter, shift): if 'A' <= letter.upper() <= 'Z': start = ord('a') if letter.islower() else ord('A') return chr((ord(letter) - start + shift) % 26 + start) ...
26b9972e91c54aecb6bb30542b95fb7807b86d2a
AlenaSmychkina/PythonCourse_1
/Task_4.py
155
4.0625
4
maxvalue = 0 s = int(input("Enter your number: ")) while s != 0: a = s % 10 if a > maxvalue: maxvalue = a s = s // 10 print(maxvalue)
72991a284b4ce86e8509be633d2480124a264a73
amanshaw4511/algo
/repetetion.py
302
3.546875
4
#count repetetion def rep(arr,MAX): n=len(arr) flags = [0 for x in range(MAX+1)] i=0 for _ in range(n): flags[arr[i]]+=1 i+=1 #array to store count count=list() for x in arr: count.append(flags[x]) return count a=[1,1,1,6,6,8,8,9,9,9,9] cnt=rep(a,9) print(a) print(cnt)
cda546b0392bb44e32e57e1b23a7cd650b6f27d5
geediegram/parsel_tongue
/fash/chat_bot.py
878
3.78125
4
import random my_dictionary = { "love" : ["Yes, I love you!","No, I don't love you", "What is love?", "Love is wicked"], "age": [num for num in range(1, 100)], "eat": ["No, i haven't", "Yes I've heard breakfast", "I never chop"], "relationship": ["wow, even the gods are clueless", "Yes, i am single", "Yes, i am in a ...
c64bda564c64ba3ce82edc8d577ad5e18bb584ba
shiels14/datasciencecoursera
/cars.py
7,747
4.25
4
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 03:13:28) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license()" for more information. >>> thislist = ["apple", "banana", "cherry"] >>> print(thislist) ['apple', 'banana', 'cherry'] >>> thislist = ["apple","banana", "cherry"] >>> print(th...
f6dc6108fb255b22fb182aef5f3902e2091c993d
Aadit017/workspace
/python_code/calculator.py
6,157
3.703125
4
from tkinter import * class Calculator: def __init__(self, title): self.title = title self.first_num = None self.current_operation = None self.in_result = False def clear(self): self.entry.delete(0, END) self.first_num = None self.current...
eaa6a15537abee83ee8facdb6926ff23f6b533ea
banboooo044/AtCoder
/ABC004/C.py
272
3.640625
4
#! usr/bin/env python3 #C:入れ替え import sys def swap(i,j): global num tmp = num[i] num[i] = num[j] num[j] = tmp N = int(input()) N = N % 30 num = list("123456") for l in range(N): i = l % 5 swap(i,i+1) for k in num: sys.stdout.write(k) print("")
fd99bbec99e5b88910a72e269237f221aca4a149
Thiagomrfs/Desafios-Python
/aula21/desafio0104.py
298
3.96875
4
# crie uma função leiaint, tipo o input, mas que só valida se for um valor numérico def leiaInt(): num = input("sla man colloca um numero ae: ") while num.isnumeric() != True: num = input("\033[31mInsira um valor numérico: \033[m") return num aaa = leiaInt() print(aaa)
4b108524f667601ed4efeb90fdb9727dde3af2d0
scorppion/Python-exercises-cev
/exer65.py
550
4
4
print('Maior/Menor/Media') soma = cont = media = 0 resp = 'S' while resp in 'Ss': n = int(input('Digite um número: ')) soma += n cont += 1 if cont == 1: maior = menor = n else: if n > maior: maior = n if n < menor: menor = n resp = str(input('Desej...
e4bd38f8459825b0b9c64672a2033541bb277fe9
krishjadhwani/python
/valleys.py
550
3.84375
4
#!/bin/python3 import math import os import random import re import sys # Complete the countingValleys function below. def countingValleys(s): inValley = False depth = 0 i = 0 valleys = 0 while (i < len(s)): if s[i] == 'D': depth -= 1 if depth < 0: inValley = True else: depth += 1 if depth ==...
5ce50883cc720e47bf22116faef18aa29b3e1524
coldmax88/PyGUI
/Tests/02-window.py
1,459
3.765625
4
# # Python GUI - Test windows # from GUI import Window, run from testing import say class TestWindow(Window): def mouse_down(self, event): say(self.name, "Mouse down:", event) def mouse_drag(self, event): say(self.name, "Mouse drag:", event) def mouse_up(self, event): say(self.name, "Mouse up:", event...
a4647ba17779ebd2c3b38cdea804ca3796c0118f
AssaultKoder95/hackerrank
/hackerrank101/python/introduction/InterchangeTwoNumbers.py
163
3.84375
4
# Enter your code here. Read input from STDIN. Print output to STDOUT a = tuple() n = int(raw_input()) n1 = int(raw_input()) a += (n1,n) print a[0] print a[1]
eb4506aa938f76f4ef335dc40334628a2a80fb65
FavioT/Python
/factorial.py
131
3.875
4
def factorial(x): if x <= 1: return 1 i = 1 f = 1 while i <= x: f *= i i += 1 return f
95591a71fa7f82e329dc4d142f8e30680d8ab533
nagask/Interview-Questions-in-Python
/Arrays/TripletSum.py
403
3.921875
4
''' "Given an array write a function to print all triplets in the array which sum of 0. Input: Array = [-1, -3, 5, 4] Output: -1, -3, 4" ''' arr = [-1, -3, 5, 4] sum_dict = {} for i in xrange(len(arr)-1): sum_dict[(arr[i])] = True for j in xrange(i+1, len(arr)): if -(arr[i]+arr[j]) in sum_dict: ...
927bea5b4451f7fb4d1bbabfa4460fd5507a0fbb
beggerss/algorithms
/Numbers/eratosthenes.py
952
4.28125
4
#!/usr/bin/python # Author: Ben Eggers import math # Finds prime numbers up to a user-generated value using the Sieve of Eratosthenes # algorithm. The algorithm starts with an index i = 2. Then, it iteratively adds # the current index number to the primes set, marks all multiples of it (in a boolean # array) as non-p...
e310246b0de4f7331a8e583bc5afd2845e6a5a21
debramaelee/python-exercises
/Week 1-2 Exercises/guess_the_number4.py
668
3.96875
4
import random my_random_number = random.randint(1, 10) print "I am thinking of a number between 1 and 10" switch = int(raw_input("What's the number? ")) tries = 5 while True: if switch < my_random_number: tries -= 1 print "You have %r tries left!" % tries switch = int(raw_input("%d is too...
a4453c1f226fc2b4a96aa60e7817804b3ef95464
wpisailbot/firstyear
/bbb/py/controls.py
1,437
3.640625
4
from util import * from math import pi def get_rudder_angle(goal_heading, yaw, rel_wind): """ Get the rudder angle given current state and goal information. goal_heading and yaw should be the same frame--ie, for both, positive should be CCW, negative CW, and if yaw == goal_heading, we should be heading i...
42e565fd02f3526f0a7c58eb0cc2ffa51ad71fe6
guo326/Study-Python
/exercise/chapter02/exercise/22_while_e01.py
671
3.5
4
f = open("C:\Python\exercise\chapter02\exercise\while_new.txt", 'w') coffee = 10 while True: money = int(input("돈을 넣어 주세요: ")) if money == 300: f.write(str(money) + " 커피를 줍니다\n") coffee = coffee - 1 elif money > 300: f.write((str(money) + " 거스름돈 %d를 주고 커피를 줍니다\n" % (money - 300))) ...
7fca84a3919f96bb6c08e2e099a24f2e1c678b67
granand/PythonCourse
/tut12UsefulOperators.py
2,955
4.40625
4
#### Generator # range function # prints numbers from 0 through 9 for num in range(10): print(num) # start and end range # starts from 3 and up to 9 but not 10 for num in range(3,10): print(num) # start and end range with step size # prints even numbers # prints 0,2,4,6 and 8 # if you need 10 to be printed t...
93cc15a94d94ce48f9c26ecdab19bad1bc4a7351
EnriqueMC557/POO_Ajedrez
/CLI/main.py
2,969
3.5625
4
""" main para ajedrez I.P.O.O Aguilar C. M. R. & Mena C. E. """ import sys from errores import LenError, TeamError, SinMovimientos, SeleccionVacia from ajedrez import Ajedrez class Menu: """Clase que permite jugar ajedrez desde la consola.""" def __init__(self): #Incialización de jugadores pri...
d0e0bc28a1396c68a30749705dfe64d4bcecc633
Rodrigo-Ruiz1/algorithm_practice
/problem2.py
314
3.859375
4
candies = [2,3,5,1,3] max_candies = max(candies) extra_candies = 3 def extra(self): count = 0 while count < len(candies): candies[count] += extra_candies if candies[count] >= max_candies: print("True") else: print("False") count += 1 extra(candies)
4d5059cd0f6ca082a50644fa90fca383b33f6153
aiiilii/py_code
/time_based_key_value_store.py
1,073
3.859375
4
import collections class TimeMap: def __init__(self): # Usually, a Python dictionary throws a KeyError if you try to get an item with a key that is not currently in the dictionary. # The defaultdict in contrast will simply create any items that you try to access (provided of course they do not ex...
fe030dec9cc3baf76d5a7476cbce0b30c5febb88
fuchami/pytorch_study
/pytorch_tutorials/tensor_tutorial.py
1,627
4.15625
4
# coding:utf-8 ''' What is PyTorch? https://pytorch.org/tutorials/beginner/blitz/tensor_tutorial.html#sphx-glr-beginner-blitz-tensor-tutorial-py ''' #%% import library from __future__ import print_function import torch #%% uninitialized 5x3matrix x = torch.empty(5,3) print(x) #%% randomly initialied 5x3matrix x = tor...
82f56416747d145e397286cdcc70a18966645512
mishrakeshav/Competitive-Programming
/CodeChef/AUG19B/CHEFDIL.py
200
3.75
4
for _ in range(int(input())): string = input() count = 0 for i in string: if i == '1': count+=1 if count%2==0: print("LOSE") else: print("WIN")
5c77a7d28f66b06a91a6281508f375ef67f7219e
JefferySchons/Coms104
/lab05/lab5_checkpoint2.py
338
3.71875
4
def findUserName(name): #given string 'lastname,firstname' user_name=name[name.find(',')+1:].strip()[0]+name[0:name.find(',')] return user_name #index_of_coma= name.find(',') # first_name=name[index_of_coma+1:].strip() # last_name=name[0:index_of_coma] # user_name=first_name[0]+last_name #...
89101ec96540fbd5283da675c7f21d31d62bd32c
jorisvandijk/Python-Crash-Course
/chapter_8/sandwiches.py
328
3.71875
4
def toppings(*toppings): """Storing and displaying what kind of toppings people want""" print("\nYour sandwich contains the following toppings:") for topping in toppings: print(f"- {topping}") toppings('onion', 'tomato', 'ham', 'bacon') toppings('cheese', 'egg') toppings('chicken', 'pineapple', 'le...
7cd0f9067e572b95f15b56ca7607b5aeb877cc41
AnnaPlatek/CreditCalculator
/Problems/Vowels and consonants/task.py
171
4
4
word = input() for char in word: if char in "aeiou": print('vowel') elif char in "bcdfghjklmnqprstvwxz": print('consonant') else: break
38ca918ce628157403baa3f0c49bff6ce98daca3
ajaychinni/Data-structures-and-algorithms
/Arrays/traping_rain_water_optimum.py
380
3.5
4
def precompute(lst): maxs = lst[0] precompute_lst = [] for i in lst: if i > maxs: maxs = i precompute_lst.append(maxs) return precompute_lst def calculate(lst): total = 0 left = precompute(lst[:]) right = precompute(lst[::-1]) for i in range(len(lst)): total += min(left[i],right[i]) - lst[i] retur...
4bb121f9a3aab09b1097002acef05c3f3fb79c93
DmitryVlaznev/leetcode
/1049-last-stone-weight-ii.py
1,617
3.53125
4
# 1049. Last Stone Weight II # We have a collection of rocks, each rock has a positive integer # weight. # Each turn, we choose any two rocks and smash them together. Suppose # the stones have weights x and y with x <= y. The result of this smash # is: # If x == y, both stones are totally destroyed; # If x != y, ...
e3f404c89c08961da2399866a1c4d87986bc1320
satya7289/Compter-Science-Stuffs
/ALGO/DP/FibonacciModified/main.py
244
3.828125
4
def fibonacciModified(t1, t2, n): dp = [0 for i in range(n+1)] dp[0], dp[1] = t1, t2 for i in range(2,n+1): dp[i] = dp[i-2] + (dp[i-1] * dp[i-1]) # return nth value return dp[n-1] print(fibonacciModified(0, 1, 5))
f6c7c595dda03a95156fa9ab47fa36b155b976f5
SuperCat1121/WorkSpace_Python
/Py01_Hello/com/test02/control_star.py
753
4.0625
4
# 1 print('# 1') for i in range(5): for j in range(i+1): print('*',end= ' ') print() # 2 print('# 2') for i in range(5) : for j in range(5-i) : print('*', end=' ') print() # 3 print('# 3') for i in range(5) : for j in range(4-i, 0, -1) : print(' ', end=' '...
878a9fa622c2ea557f390223d48b4c22d2e368dd
pengzhefu/LeetCodePython
/hashtable/easy/q202.py
1,057
3.84375
4
# -*- coding: utf-8 -*- """ Created on Thu Apr 4 16:08:47 2019 @author: pengz """ ''' Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the p...
182fc267f0f12a2167a1af6b2c1a6b63b36cda62
maansidesai/SpeechArrestData
/output_columns_csv.py
3,200
3.546875
4
import os import csv import pandas as pd import glob """ Maansi Desai & Alia Shafi, November 2017 Project: Speech Arrest This script reads in all csv files (one per patient) which contains data on stimulation time (onset and offset), error time (onset and off set), error type, and columns which record the presenc...
2957a6c840881f6f8b598a57100e6159c16d8390
rproque/reference_guide
/programming/python/prime_finder.py
1,321
4.5625
5
#!/usr/local/bin/python3 #MacOSX # Check if a number is a prime number: # A number is prime if it is divisible by exactly 2 distinct positive numbers 1 and the number itself. # https://www.mathsisfun.com/prime-composite-number.html # also: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes # wow: https://leetcode.com/...
e904869ac1f058222c17aec7bad23bf9e82dce86
EC-Yao/ProjectEuler
/Problem7.py
289
3.65625
4
# Literally brute force listPrimes = [2] for a in range(3, 10000000): isPrime = True for b in range(0, len(listPrimes)): if a % listPrimes[b] == 0: isPrime = False if isPrime: listPrimes.append(a) if len(listPrimes) > 10000: break print(listPrimes[10000])
3d106275e6ab802b6857fe50d5cb718dd7c626e5
ZeeshanJ99/Deloitte-Python
/control_flow/while-loops.py
932
3.921875
4
# a for loop iterates through an iterable # a while loop will run forever # as long as a condition is True # x = 1 # while x < 10: # print(f"x is currently {x}") # x += 1 # if x == 4: # break # print(f"x is now {x}") # x += 1 # this will loop forever dont click run, - because x is always l...
b467327ed9f7f4fd2122f0e754fe03b57c9ce454
GraceAKelly/Grace-Kelly-Repository
/collatz.py
433
4.3125
4
#Grace Kelly 11-02-2018 #Week 3 Assesment num = int(input("Please Enter Integer:")) # Enter number to be tested while num!=1: # Number is not equal to 1 if num % 2 == 0: # If the remainder of dividing by 2 is 0 num = num/2 # If it is even divide by 2 print (num) # Print the output else: # Or...
103665c9d2e361736e8a428d14639dca07e0a49d
BibekRai44/Programiz-Python
/Python Program to Display Powers of 2 Using Anonymous Function.py
144
3.875
4
n=8 result=list(map(lambda x:2 **x,range(n))) print("the total terms are:",n) for i in range(n): print("2 raised to power",i,"is",result[i])
2579665a9145de9daf451e595fecd408e028b1cc
Diploma-works/deobfuscator
/obfuscated/examples/ast/middle_source.py
245
4
4
left_op = int(input()) right_op = int(input()) sum_two_things = left_op + right_op other_sum = sum_two_things - 1 if sum_two_things % 2: print("sum_two_things: " + str(sum_two_things)) else: print("other_sum: " + str(other_sum))
bb2f6c8a7ad2e2f1d755fece312aa0580ca0ac84
huojinhui/PycharmProjects
/初级python/venv/24 霍晋辉.py
6,081
3.625
4
import re, random # -------机试题------- # # # 1. 实现一个单例 # class Person: # def __init__(self, name, sex, height): # self.name = name # self.sex = sex # self.height = height # def eat(self): # print('%s吃饭了..'%(self.name)) # def sleep(self): # print('%s正在睡觉'%(self.name)) #...
b4c9a3551c665d07d112d1618173ad1cd82ef042
DenisFuryaev/PythonProjects
/tasks from uneex.org 2018/AndOr.py
119
3.75
4
a = eval(input()) b = eval(input()) if ((a and b) == a) and ((b and a) == b): print('NO') else: print(a or b)
09e4349a663a38896e134286292fa6db76a44581
awlange/project_euler
/python/p100.py
1,800
3.578125
4
import math from p45 import is_perfect_square from p124 import get_prime_factor_list_up_to def is_perfect_square_mod(x): """ Rule: Perfect squares can only end in 0, 1, 4, or 9 in base 16 Helps to avoid the sqrt call 75% of the time! """ d = int(x & 0xF) if d > 9: return False if ...
6eb736f11340b32df35967950dbe00069526666f
madblanche/Practice
/task2_bday.py
380
4.0625
4
from datetime import date, timedelta d = date(1986, 3, 15) print('Friends B-day is on', d.day, 'of', d.strftime("%B")) today = date.today() enddate = today + timedelta(days=7) if today.month <= d.month <= enddate.month \ and today.day <= d.day <= enddate.day: print("B-day is on current week!Don't forget t...
733c36e767c26234eff1dda9fa525f67d18cf2ae
isakura313/24_04_02
/backup/backup.py
330
3.578125
4
import shutil import random print("Запущена программа бекапа") target = input("Введите название папки, которую надо забекапить") string = '' for i in range(len(target)): string += str(random.randint(0, 9)) plan_b = target+string shutil.copytree(target, plan_b)
7dc7854269191e949a3c101743fb8290752e48a5
subhashreddykallam/Competitive-Programming
/Codeforces/Educational Codeforces Round 61 (Rated for Div. 2) - 1132/1132A-Regular Bracket Sequence.py
133
3.65625
4
a = [] for _ in range(4): a.append(int(input())) if a[3] == a[0] and (a[0] > 0 or a[2] == 0): print('1') else: print('0')
f1f38a5a834f80abe8926894bf82be7515152075
XuanC6/Data-Structures-and-Algorithms
/course 1 Algorithmic Toolbox/week 4 Divide-and-Conquer/closest_points_pair.py
1,479
3.515625
4
# -*- coding: utf-8 -*- """ Created on Wed Jan 3 14:25:44 2018 @author: CX """ import math def minimum_distance_1d(x): n = len(x) d = float('inf') if n <=1: return d x.sort() for i in range(n-1): dis = x[i+1]-x[i] if dis<d: d = dis return ...
b502eae9d7ea4e70fa3a528c2646d794c208ac73
augustinkrug/hackinscience
/exercises/210/solution.py
213
3.609375
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 22 13:33:07 2015 @author: A.KRUG """ from is_prime import is_prime somme = 0 for i in range(1, 1000): if is_prime(i): somme = somme + i print(somme)
153d4a8cfca185329d6d340a2bcc4ff2209112cb
rahul120799/rahul
/exno24player.py
126
3.75
4
my_number = input() if(my_number.isdigit()): print("yes") elif(my_number.isalpha()): print("no ") else: print("no")
cd7691bc82d0771629f998746b97d2a9557bb50d
rsthakur83/cloud
/python program/if.py
542
4.125
4
a = 2 b = 6/2 if b % 2 <= 2: print "Number is less than", b else: print "Now fine" if b == 0: result = b % 3 ## % gives the remainder print "The value of result is ", result else: print "Calculation done" now = ["Test", "Value", "List", "Check"] print "Each value of list",...
502483fcb907a57121f4c943c90c02113c9b07d6
aniketshelke123/hello-world.io
/largest_of_4.py
1,769
3.859375
4
#print smallest # a = int(input("enter 4 numbers\n")) # b = int(input()) # c = int(input()) # d = int(input()) # # if a <= b and a <= c and a <= d: # print("a is Smallest ") # elif b <= a and b <= c and b <= d: # print("b is smallest") # elif c <= a and c <= b and c <= d: # print("c is smalles...
60bad422dd3104ca56b3d86e630a94381e244285
cgarrido2412/PythonPublic
/Challenges/Advent Of Code/adventofcode2019/day02_part2.py
3,787
4
4
#! Python 3 ''' --- Part Two --- "Good, the new computer seems to be working correctly! Keep it nearby during this mission - you'll probably use it again. Real Intcode computers support many more features than your new one, but we'll let you know what they are as you need them." "However, your current priority should ...
6b5899828f9b76ce5ee6c7cec46d3d8df100f297
MyloTuT/IntroToPython
/Homework/HW9/filelib.py
1,291
3.734375
4
import os def getlines(filename, newlines=False): try: user_file = os.path.isfile(filename) except IndexError: exit('please input a file name') #fixed terrible logic by initiating an empty list to report back # loop results. Logic similar to 'readlines()' file_lines = [] for li...
d1f446795a0c3a8bcd3864f1c03cf8343b9165f7
mzivi/elgoog
/graph/search.py
7,863
3.640625
4
from collections import namedtuple from collections import deque import heapq from functools import partial def calculate_path_cost(graph, path): cost = 0 if len(path) > 1: for i in range(1, len(path)): cost += graph[path[i - 1]][path[i]] return cost def find_path(graph, source=0, ta...
ee845281dfb6ba7665eca941f56c089f22658cdc
VineetPrasadVerma/GeeksForGeeks
/SudoPlacementCourse/Palindrome.py
217
3.78125
4
test_cases = int(input()) for _ in range(test_cases): size = int(input()) target = input() reverse_string = target[::-1] if target == reverse_string: print('Yes') else: print("No")
96aa74ef23b45b493780eecfd8402d8a03b0929e
mohaoyi98/Monster-s-Grape
/MACD.py
1,005
3.59375
4
#modified from the program in "https://www.linkedin.com/pulse/python-tutorial-macd-moving-average-andrew-hamlet" import pandas as pd def MACD_strat(df, dateindex): #calculate the 30-day and 15-day Exponential Moving Average (EMA) df['30 ema'] = pd.ewma(df['close'], span=30) df['15 ema'] = pd.ewma(df['close...
c0ef0ead9f113ab5b74cd99bfda6062bb49c90dd
MykolaKlishch/OpenDataCampusIF
/make_csv_sample.py
752
3.625
4
"""Produces evenly spaced sample from csv file by leaving only each n-th row. Works well with data_for_each_vehicle.csv but for other datasets randomized sampling may be better choice than this tool """ import csv def main(): with open("data_for_each_vehicle.csv", mode="rt", encoding="utf-8" ) as f...
e7de734cbea526702503626d2190e92e4eca43f4
rahusriv/python_tutorial
/python_batch_2/AssignmentSolutions/List_Solu_13.py
212
3.8125
4
list_x = [] for i in range(0,3): tmp = [] for j in range(0,4): tmp1 = [] for k in range(0,6): tmp1.append("*") tmp.append(tmp1) list_x.append(tmp) print(list_x)
4a2f35826b5e2777bf6b64cf3ffbe3ef1af216ce
yuyihe/snake-game
/snakes/wave.py
11,770
4.3125
4
""" Subcontroller module for Alien Invaders This module contains the subcontroller to manage a single level or wave in the Alien Invaders game. Instances of Wave represent a single wave. Whenever you move to a new level, you are expected to make a new instance of the class. The subcontroller Wave manages the ship, ...
10ce32eebe710ea7887e69c999e904e4bd006851
GentleSkiddie/FileSystem_Regex_Labs
/Labs/1/7/solution.py
408
3.828125
4
import argparse def solve(number): if number == 0: return 0 previous = current = 1 for i in range(number - 2): [current, previous] = [current + previous, current] # Switch values return current if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argu...
7e694adc1a0fa7a3f5c2320f29886bc63310e987
parmalatinter/ai
/math/distribution/multinomialDistribution.py
1,752
3.796875
4
#!/usr/bin/env python # マルチヌーイ分布見方(カテゴリカル分布, 多項分布) # 一回の試行で複数の結果が確率的に発生するときその結果が従う分布 # k=2かつn=1である時、ベルヌーイ分布の確率関数 # 例:サイコロの結果、日本人が好きな髪型、宝くじを引いた結果(それぞれ一回の試行) # 期待値:E(x) = n * p1 # 分散: Var(x) = n * p1 * (1 - p1) # 確率関数(k = 2): f(x1, fx2) = n! / ( x1! * x2! ) * p1 ** x1 * p2 ** x2 # * 確率変数Xがパラメターpのマルチヌーイ分布に従うと...
31f88fcbbb270ea271ce8248b986a8bc926f4038
moabedi/Python-Multithreading-Multiprocessing
/Processes/lock.py
1,279
3.578125
4
import time import multiprocessing def deposit(balance): for i in range(100): time.sleep(0.01) balance.value = balance.value + 1 def withdraw(balance): for i in range(100): time.sleep(0.01) balance.value = balance.value - 1 def problem(): balance = multiprocessing.Value('i', 200) d = multiprocessing.P...
ed8292b9889cc9f0a38da0fef6ec0c48d74a700f
daniel-reich/turbo-robot
/hZ4HzhboCJ5dDiNve_1.py
770
4.53125
5
""" Create a function that takes a string and returns the reversed string. However there's a few rules to follow in order to make the challenge interesting: * The UPPERCASE/lowercase positions must be kept in the same order as the original string (see example #1 and #2). * Spaces must be kept in the same order ...
966395b205b7363d300670f624859640b3f605cf
exer047/homework_6
/ex_9.py
387
4
4
# удалить все повторяющиеся элементы def delete_repeats(element_list): new_list = [] for i in element_list: if i not in new_list: new_list.append(i) return new_list if __name__ == "__main__": element_list = [1, 2, 2, 3, 4, 4, 4, 5, 6, 6, 7, 7, "game", "game"] print...
6f7d20205bd7f423cd9630d77d3839e99d3e86e2
melodyshi/Using_Data_Analytics_To_Understand_Cancer
/Module2_Interactive_Analytics.py
16,771
3.890625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Sep 30 08:28:52 2018 This program supports two functionalities: * Plotting horizontal bar charts * Plotting heatmaps It is user interactive. The user can choose from the engines and a list of cancers to generate visualization based on a preprocessed ...
fab8aefc05252113da203f78094bd1a836774fdd
Enoc-Mena99/FileBulk
/filebulk.py
1,586
3.5625
4
""" Developer: HQSoftware _______________________________________________________________________________________________________ Description: This is a file deletion program that asks you for an extension(.mp3, .pdf, .docx, etc) of a file to delete all of the files in a dir that have that extension. __________________...
8864e2af2560f13d682f20f3f91727b1b1925bee
lskywolfll/comprehensions_list_and_dicts_python
/debugging.py
567
3.84375
4
divisors = lambda num: [i for i in range(1, num + 1) if num % i == 0] def get_input(msg): while True: try: result = int(input(msg)) if result < 0: print("No se admiten numeros negativos 😭\n") raise ValueError() else: retu...
56fed5bee771fc27655db159136ff4b9a4aedbf7
namand010/Project4091998
/Learning_code/learn.py
1,381
3.625
4
print ("Naman is here") string1 = "aieou dubey" a = {} for st in string1: if st not in a: a[st] = None print(a) #Rev b = string1[::-1] print(b) for i in range(len(string1)-1, -1, -1): print(string1[i], end="") #sort d = [10,2,-1,0,11,5,6] for i in range(len(d)): for j in range(len(d)-i-1): ...
b287b40c2ddeef7b70f65a71ae8738cd25342b41
Alexandr-94/overone_ez
/fourth_lesson(for)/task_1.py
118
3.5625
4
#for i in range(4): # print(i) #for i in 'Я учу Python': # print(i) for i in range(15, 0, -1): print(i)
9691d4c7ce84056074da93d9d886a51ff8075e70
anishst/Learn
/Programming/Python/decorators_practice/decorators_using_clock.py
985
3.78125
4
import time def clock(func): def clocked(*args): # t0 = time.perf_counter() result = func(*args) # elapsed = time.perf_counter() - t0 name = func.__name__ arg_str = ', '.join(repr(arg) for arg in args) print('[%0.8fs] %s(%s) -> %r' % (elapsed, name, arg_str, result)) return result return clocked def c...
8efb49467e724dd2a0f06f736c60e9fc4d72df30
Wanpeng66/Python_learning
/面向对象编程/类和实例.py
691
4.0625
4
# python中的类与实例与java中差不多 只不过写法不一样 # 用class关键字声明这是一个类,Student是类名,括号里可以写父类 # python不是静态语言 类的属性不固定 可以随时增删,所以声明类时不用声明属性, # 一个类的不同实例可能也有不同的属性参数 class Student(object): # __init__是构造函数 def __init__(self,name,age): self.name = name self.age = age # 不能有多个重写的构造器 #def ___init__(self): #sel...
c4e7198cc3af47ba7e25c56e88b4021bf2ffed2d
qmnguyenw/python_py4e
/geeksforgeeks/python/python_all/151_1.py
2,629
4.34375
4
Python | Remove duplicates from nested list The task of removing duplicates many times in recent past, but sometimes when we deal with the complex data structure, in those cases we need different techniques to handle this type of problem. Let’s discuss certain ways in which this task can be achieved. **Me...
15b79275bd86b7aac871fe12439495aaeadd6abf
AatreshKulkarni/Learning-Python
/basic_programs/pgm25_factor.py
332
4.375
4
# Find the factors of a Number # Defining a function which calculates factors of a number def factorsOf(num): print("Factors of ",num) # Logic to calculate fact for i in range(1,num+1): if num % i == 0: print(i) # Input a number num = int(input("Enter a number to calculates its factors:")) # Function call fa...
3e142ff230514bcba9466d1cbf8b78d33544f22f
OlyaIvanovs/small_python_projects
/blackjack.py
6,887
3.828125
4
import random, sys # Set up constants HEARTS = chr(9829) DIAMONDS = chr(9830) SPADES = chr(9824) CLUBS = chr(9827) BACKSIDE = "backside" def main(): print( """ Rules: Try to get as close to 21 without going over. Kings, Queens, and Jacks are worth 10 points. Aces are worth 1 o...
3d8f0f9a3ea79dc3e4350f2c7300caef801580ea
ajaymonga20/Projects2016-2017
/problem1.py
235
3.953125
4
def quadrant(x,y): if (x >= 0) and (y >= 0): return 1 elif (x < 0) and (y >= 0): return 2 elif (x < 0) and (y < 0): return 3 else: return 4 x = input() y = input() print quadrant(x,y)
a025927f441e1ad4ed75c062ba084b9461216ee2
PoRiLo/Python-course
/capstone.py
12,720
4.09375
4
""" Fundamentals of Computing - Capstone Exam July 2016 @author: Ruben Dorado """ import math import random ### Question 1 # Enter the value returned by the function def test_01(): print print "Question 1" def f(): return print f() ### Question 2 # What global names are created during...
9029378f680438a34656a98a7d4a16ee3dbcbd3f
marquesarthur/programming_problems
/leetcode/stack/baseball.py
644
3.59375
4
class Solution(object): def calPoints(self, ops): """ :type ops: List[str] :rtype: int """ data = [] for i in ops: if i not in ["C", "D", "+"]: data.append(int(i)) elif i == "C": data.pop() elif i ==...
1b13e8ccafd8e9489695ffd6eba13c13c0113638
Amanymaa/NLP-learning
/main.py
2,927
3.5
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns sns.set_style('white') import sklearn as sk yelp = pd.read_csv('/Users/Magic Systems/Desktop/yelp.csv') print(yelp.head()) print(yelp.info()) print(yelp.describe()) yelp['text length'] = yelp['text'].apply(len) print( yel...
6c0dbd7f2e6fd28efdcdc39cbcab00843f78e760
Nutpapat/Python_Lab
/py/029.py
520
3.765625
4
"""029""" def main(): """Triathlon""" num = int(input()) swim = 0 cycling = 0 run = 0 for _ in range(num): swim2 = float(input()) cycling2 = float(input()) run2 = float(input()) for _ in range(25600): swim += swim2 for _ in range(746): ...
3682fd1eb591c634f3d9cf0d26df40f12267c895
nandehututu/python2
/割线法.py
225
3.5625
4
import math while True: x = input("x = ") y = input("y = ") for i in range(10): z = y-(y*y*y-2*y-5)*(y-x)/(y*y*y-2*y-5-x*x*x+2*x+5) #ʽ print z x = y y = z
07f6ed5aa534b3e1683909c6cb9f3656b865fa69
papunmohanty/build_version_comparison
/build_version.py
2,745
3.84375
4
class InvalidBuild(ValueError): pass class BuildVersion: """ This class is a custom Data type for Build and to compare build for equality and in-equality such as < (less than) > (greater than) == (equals to) parameters: build (str): Build number in str...
0711fc862928da6f334de7d425bb3fcd9018fd3b
cocokaku/SP_Online_Course2_2018
/students/srepking/lesson06/calculator/calculator/calculator.py
1,291
3.953125
4
"""Calculates""" from .exceptions import InsufficientOperands from .exceptions import StackError class Calculator: """Calculator class""" def __init__(self, adder, subtracter, multiplier, divider): self.adder = adder self.subtracter = subtracter self.multiplier = multiplier ...