blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
d8968493d4b89f821c9979e7ed9eefff3e3f76b5
Jerrydperry/cs114
/magic8ballv3.py
766
4.15625
4
print ("what is your name?") name = input() print ("welcome " + str(name) + " I hope you're ready for your fate.") import random r = random.randint(1,3) def getAnswer(r): # if r == 1: # fortune ='your fate is looking grim.' # elif r == 2: # fortune = 'your fate will be of nuetral concern.' ...
1472a1673eded1685a80a9fb87eba58e947fe04d
xpls7/softuni-python-fundamentals
/Exercise_4_Functions/ex.3.py
171
3.78125
4
def all_symbol(ch_1, ch_2): for i in range((ord(char_1))+1, ord(ch_2)): print(chr(i), end=" ") char_1 = input() char_2 = input() all_symbol(char_1, char_2)
f62ba1358cd8d88a67950709c9d24dbfe5388d1b
UWPCE-PythonCert-ClassRepos/SP_Online_Course2_2018
/students/srepking/lesson07/part1/L7_populate_personjob.py
5,987
3.5
4
""" Loads the database that includes Department for assignment 7. You need to delete the database personjob.db before you run this. """ import logging import sqlite3 from L7_create_personjob import * from peewee import * import pprint logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__...
f32040cf8be0569800906ba537a6da197f200a43
kiranKrishna0801/Coursera_IIPP
/week0/week0b/week0b_practice_exercise_6.py
155
4.09375
4
PI = 3.14 radius = 8 area=PI*radius**2 print "A circle with a radius of " + str(radius), print "inches has an area of " + str(area) + " square inches."
34bd52c9dd72807cef5dce83c0850c70e0ced478
evianyuji/the-self-taught-programmer
/3章/3-2.py
88
3.625
4
x = 9 if x < 10: print("xは10未満です") else: print("xは10以上です")
cd7b77c065c0fdbd02e29199fdc6bc8b058d8637
freonzx/cs50stuff
/pset6/credit/credit.py
1,157
4.09375
4
# Function that checks the card def check_card(number): # Holds the sum of numbers soma = 0 # Holds the number of digits count = len(number) # Reverse the number so we can work with it number = number[::-1] # iterates through number string converting digit to integer and working with it ...
c6da7f030d95854ea6c0d4d76ad5f2e0e4a11b58
gabriellaec/desoft-analise-exercicios
/backup/user_265/ch37_2020_09_16_20_53_13_466941.py
202
3.84375
4
senha = True while senha: a = str(input('Palavra ')) if a != 'desisto': a = str(input('Palavra ')) else: senha = False print('Você acertou a senha!')
703b4307b4c717a34fe8a2681f5d73444f3d9036
diaosj/python-data-structure
/english_ruler.py
1,439
4.5625
5
""" Consider how to draw the markings of a typical English ruler. For each inch, we place a tick with a numeric label. Denote the length of the tick designating a whole inch as the major tick length. Between the marks for whole inches, the ruler contains a series of minor ticks, placed at intervals of 1/2 inch, 1/4 inc...
13c396c8d436ebd601fc7b033a105a0960e11eda
LivHackSoc/Workshop
/python/intro.py
628
4.0625
4
print "This is Python programming!" + "\n" # variable in python greenApple = 2 redApple = 3 # data type: integer totalApple = greenApple + redApple # print information to console print ('The total number of apples: ' + str(totalApple) + "\n") # declare a function using the keyword 'def' def totalApplePrice(tota...
a0c76170f7f6ecbef94d0493a403b99cc4932bd8
samuel129/Old-programs-from-2020
/real coin change finder.py
658
3.953125
4
# change calculator money = float(input('How much money did you pay?: $')) cost = float(input('How much money did it cost?: $')) money = money*100 cost = cost*100 quarter = 25 dime = 10 nickel = 5 penny = 1 money2 = money - cost quarter2 = money2 // 25 money3 = money2 % 25 dime2 = money3 // 10 money4 = money3 % 10 n...
fc19dac05d4e08d0c8d7a9f34b3f336f8a079c57
JSBCCA/pythoncode
/early_projects/theater.py
2,721
3.8125
4
import myshop def movie(name): two = round((9.99 * 1.07), 2) print("Here is your Ticket and movie receipt.\n[Ticket for", name, " - $" + str(two) + "]\nEnjoy the film!") def concession(): print(" Refreshments:\n" "Popcorn - $5.05\n" "Coke - $2.19\n" "Cookies -...
e55e5e9953188bba3474f8e7d07f7c8edfc4066a
elsagrasia/UG10_D_71210761
/1_D_71210761.py
579
3.59375
4
a = int(input("Harga makanan sebesar RP ")) b = int(input("Harga snack sebesar Rp ")) c = int(input("Harga minuman sebesar Rp ")) d = int(input("Uang yang anda bawa sebesar Rp ")) e = a+b+c total = d-e if d<e: print("Total yang harus anda bayar sebesar Rp", e) print("Uang anda kurang! Anda memiliki hutang sebes...
29ef3b294a878de6ed699ed80a72750df64fbead
Sean1708/Regetron3.0
/regetron/engine.py
8,098
3.828125
4
import re import sys import os CMD_PATTERN = re.compile("^!([a-z]+)\s*(.*)$") class ArtificialException(Exception): def __init__(self, value): self.value = value def __str__(self): return repr(self.value) class Regetron: def __init__(self): self.infile_name = None sel...
6bf70383383d015f4876c1f7146fb68880270aed
pangyouzhen/data-structure
/other/162 findPeakElement.py
583
3.546875
4
from typing import List class Solution: def findPeakElement(self, nums: List[int]) -> int: if len(nums) == 1: return 0 nums.append(float('-inf')) for i in range(len(nums) + 1): if nums[i + 1] - nums[i] < 0: return i if __name__ == '__m...
9e23381cb448a784a829905a5e2183d21ce4e28d
mcxu/code-sandbox
/PythonSandbox/src/misc/coin_change_min_num_of_coins.py
2,990
3.765625
4
""" Given array of pos ints representing denominations, and a single non-negative int representing a target amount of money, implement function that returns SMALLEST NUMBER OF COINS needed to make change for target amount. Sample input: 7, [1,5,10] Sample output: 3 (2x1 + 1x5) """ class Prob: ''' Dynamic prog...
98f912cc42ac8fc7b579b256911cefec110de1e6
vasjanovak/Vehicle-Manager
/vehicles.py
4,188
4
4
class Vehicle: def __init__(self, make, model, mileage, service): self.make = make self.model = model self.mileage = mileage self.service = service def list_of_vehicles(vehicles): if not vehicles: print('') print("You don't have any vehicles on your list") print('') else: for index, vehicle in enum...
4ed5e33077d6194e4d3b25d831b7600301d47f77
sanjitroy1992/PythonCodingTraining
/coderbyte/binary_wildcard.py
259
3.625
4
# -*- coding: utf-8 -*- """ binary wildcard combinations """ def ans(s): ans = [""] for i in s: if i == "?": ans = [x + "0" for x in ans] + [x + "1" for x in ans] else: ans = [x + i for x in ans] return ans
b0544010531e643f3576a2ec4982b2be42b457fe
wangtao666666/leetcode
/20181002-7-Reverse_Integer.py
579
3.875
4
# encoding='utf-8' class Solution(object): def reverse(self, x): """ :type x: int :rtype: int """ mindata = -pow(2, 31) maxdata = pow(2, 31) - 1 if x < mindata or x > maxdata: return 0 else: if x < 0: result =...
66369f29a7756e00c599c42b52119debb5e0b2d0
eltolis/ZombieAdventure
/zombieadventure/old_building.py
2,992
3.75
4
# -*- coding: utf-8 -*- import prompt import custom_error import score import death def enter(the_player): the_player.location = 'Old Building' the_player.directions = ['March Street','Old Building (first floor)'] print "\nLocation:", the_player.location print "-" * 30 num_of_tries = 4 if the_player.locatio...
bd1ae9bbd1b08e8ce21cafe34ed4abfd7c4ee39e
namyangil/edu
/Python/codeup/codeup_3014.py
150
3.796875
4
for i in range(20): if i==19: print("hello",end=" ") else: print("hello",end="") for j in range(30): print("world",end="")
9887e3b2746475fac540a33f0f6af53140341740
Thiagolino8/Documentos
/main.py
213
3.5625
4
from Documento import Documento while True: documento = (input("Insira seu documento: ")).strip() documento = Documento.cria(documento) if not documento: continue break print(documento)
54b11cc13895b9a8e14645c1fbfb21b003aa9249
sxdegithub/pythonExercise
/pythonExercise/py001/py001_a.py
972
3.953125
4
# coding=utf-8 # https://github.com/Show-Me-the-Code/show-me-the-code # 做为 Apple Store App 独立开发者,你要搞限时促销,为你的应用生成激活码(或者优惠券),使用 Python 如何生成 200 个激活码(或者优惠券)? import random import string # 大小写字母,数字 letter = string.ascii_letters digit = string.digits # 连接后作为取样的population chars = letter + digit # print(chars) # tuple_a ...
d0aecaa08d47e70707d924278fb715db5b8dbcc2
PedroBernini/ipl-2021
/set_0/p0_4.py
485
3.8125
4
# Programa baseado no algoritmo de Zeller, que calcula o dia da semana em que uma determinada data caiu (ou cairá). year = 2017 month = 1 day = 9 def zellerAlgorithm(year, month, day): if month in [1, 2]: y1 = year - 1 m1 = month + 12 else: y1 = year m1 = month y2 = y1 % 10...
89d0c6969bb3083f25af28f7877fcb4e19c32815
SamanehGhafouri/DataStructuresInPython
/list.py
1,687
3.765625
4
# ***************************************** List comprehension *********************** x = list() y = ['a', 25, 'dog', 8.43] tuplel = (10, 2) z = list(tuplel) # List comprehension a = [m for m in range(8)] print(a) b = [i**2 for i in range(10) if i > 4] print(b) # ***************************************** DELETE ***...
78621bcc3b475c835b62d468b6c5df4a9ae53b72
henryji96/LeetCode-Solutions
/Easy/409.longest-palindrome/longest-palindrome.py
455
3.59375
4
from collections import Counter class Solution: def longestPalindrome(self, s): """ :type s: str :rtype: int """ sDict = dict(Counter(s)) ans = 0 existOrder = 0 for num in sDict.values(): ans += num // 2 if num % 2 != 0: ...
7496df61eec6f34b10c6272be8dd699256acc55d
geediegram/parsel_tongue
/gideon/else_statement.py
709
3.640625
4
# year = int(input()) # print("Leap" if year % 400 == 0 or year % 4 == 0 and year % 100 != 0 else "Ordinary") # year = int(input()) # if (year % 4 == 0 and year % 100 != 0) or year % 400 == 0: # print("Leap") # else: # print("Ordinary") # num_1 = int(input()) # num_2 = int(input()) # maximum = num_1 # if nu...
6cdb09fbf24fcf74e244f33f48ea87948ffe9f2e
astikanand/Interview-Preparation
/Algorithms/7. String Algorithms /3_kmp_algo.py
1,169
3.546875
4
def calculate_lps(pat): m = len(pat) lps = [0]*m i = 1; j = 0 while(i < m): if(pat[i] == pat[j]): lps[i] = j+1 i+=1 j+=1 elif(j>0): j = lps[j-1] else: lps[i] = 0 i+=1 return lps # print("LPS Examp...
e7abec69343691d132e2481c8aff7645d30ea235
tarunnagole/bankmanagementsystems
/bank.py
3,437
4.03125
4
import sys import sqlite3 import random as r class customer: bank_name='Welcome To SBI BANK' conn=None def __init__(self): self.conn=sqlite3.connect('customer.db') self.cursor=self.conn.cursor() self.cursor.execute("create table if not exists customer(accno int primary key,name varch...
886e97dd71088eaff7bbcd3f592b05b56bdbbbab
JinXiaozhao/python_learn
/data_structure/LinkList/link_list.py
3,766
4.03125
4
class ListNode(object): def __init__(self,now_data,next_data=None): self.data = now_data self.next = next_data class LinkList(object): def __init__(self): self.head = None def set(self): print('以空格键结束输入!') print('input:') data = input() if data ...
6d46d003abb0565a90362ab87d8c9f1f6e035ffd
vincenzorm117/CCI_6edition
/problems/chapter5/2_binary_to_string/python/solution.py
456
3.578125
4
#!/usr/local/bin/python3 # Number is between 0 and 1 def binary_to_string(x): binary = [0] * 32 mantissaIndex = 0 c = x while c != 1 and mantissaIndex < 32: c *= 2 if 1 < c: binary[mantissaIndex] = 1 c -= 1 mantissaIndex += 1 if c != 1: return "ERROR" else: binary[mantissaIndex] = 1 return '.'...
9969c47cb73f7c4018ad3919d45b0c31c62fade1
LTMenezes/fluid-playlist
/fluidplaylist/spotify_helper.py
7,366
3.625
4
import random import bcolors as colors from spotipy import oauth2, client class Spotify(object): """ Spotify serves as a helper to extend the spotipy library. Args: client_id (str): Spotify client id. client_secret (str): Spotify client secret. callback_url (str): Spotify callback ...
86f0108e27b8183198e174549d7867c1d069a275
YidanLong1229/UVic_Projects
/CSC265_Software_Development_Methods/Online_Analytical_Processing_queries_1stprinciple/OLAP
13,961
3.5
4
#!/usr/bin/env python3 import argparse import os import sys import csv def main(): # deliberately left blank for your implementation - remove this comment and begin arguments = sys.argv groupby_flag = False groupby_field = [] calculation_flag = False calculation_label_field = [] lab...
7de35716a35ed54f1940a5a5571eca1dfc710990
gabriellaec/desoft-analise-exercicios
/backup/user_227/ch26_2020_03_07_19_48_48_200459.py
342
4.0625
4
valor_da_casa = float(input("Qual o valor da casa a comprar? ")) salário = float(input("Qual seu salário? ")) anos = int(input("Qual a quantidade de anos a pagar? ")) valor_da_prestação = (valor_da_casa/(12*anos)) if valor_da_prestação > 0.3*salário : print("Empréstimo não aprovado") else: print("Empréstimo apr...
f21eb9182e50564efb9036f298c5be46f5bec68c
0helloword/pytest
/src/practice/get_phone_num.py
715
3.96875
4
# -*- coding: utf-8 -*- import os import random phone_number_list = [133, 153, 180, 181, 189, 130, 131, 132, 145, 155, 156, 185, 186, 134, 135, 136, 137, 138, 139, 147, 150, 151, 152, 157, 158, 159, 182, 183, 184, 187, 188] def get_phone_number(): phone_number = '' ...
0f88dac5c3e8c6826f4b38f26b9e7f2845bc5715
terrysky18/Python-repo
/My Python Scripts/Python Game Lesson/explode_example.py
1,072
3.5625
4
""" The explosion example in code skulptor """ import simpleguitk as simplegui EXPLOSION_CENTRE = [50, 50] EXPLOSION_SIZE = [100, 100] EXPLOSION_DIM = [9, 9] explosion_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/explosion.hasgraphics.png") # create timer that iterate cur...
cb1485e166e193c3521d8a66ebd45cc5ca3cb8be
rrrituraj/python
/OOPS/multiple_inheritence_example.py
5,499
4.28125
4
# -*- coding: utf-8 -*- """ Created on Sun Aug 21 12:29:14 2016 @author: RITURAJ """ """ The class Clock is used to simulate a clock. """ class Clock(): def __init__(self , hours , minutes , seconds): """ The paramaters hours, minutes and seconds have to be integers and...
8d6045df812f7c68ab116130a02a1db51f5377d1
Ankit-29/competitive_programming
/Strings/increasingDecreasingString.py
1,968
3.84375
4
''' Given a string s. You should re-order the string using the following algorithm: - Pick the smallest character from s and append it to the result. - Pick the smallest character from s which is greater than the last appended character to the result and append it. - Repeat step 2 until you cannot pick more characters....
eb8c729b54d0df553b1a62a91d236bb45a068f66
forrestliao/datastructure-algorithms
/array_stack.py
817
3.859375
4
class ArrayStack: def __init__(self): self.top = 0 self.stack = list() def print_stack(self): if not self.is_empty(): print(self.stack[:self.top]) else: print("it's empty") def is_empty(self): return self.top == 0 def push(self, num): ...
822ab0a4ac361e3c32efe243b3181d6a6e328206
FapCod/Python
/Condicionales/ejercicioCinco.py
764
4.03125
4
saldo=1000 print("\t\t'Menu'") print("1. Ingresar dinero en la cuenta") print("2. Retirar dinero de la cuenta") print("3. Mostrar dinero disponible") print("4. Salir") opc = int (input("digite una opcion del menu:")) print() if opc==1: extra =float (input("cuanto dinero quiere ingresar--->")) saldo += extra ...
eff68ee869c3c9551a1c79f7e7752ec4104583cc
mich7095/curso_de_poo_y_algoritmos_python
/ordenamiento_insercion.py
1,188
3.78125
4
import random def ordenamiento_por_insercion(lista): # el for va guardando cada valor en memoria # del siguiente numero en la lista, porque el # for se inicializo desde 1 for indice in range(1, len(lista)): valor_actual = lista[indice] posicion_actual = indice # este while es...
bf54a23cf162a76eecda59d85ae7f54cc0abedac
ranajoy-dutta/TechGig
/30-Day-Challenge/Day14_Lets_Make_A_Dictionary_Order.py
162
3.765625
4
def main(): n = int(input()) arr = [] for i in range(n): arr.append(input()) arr = sorted(arr) for i in arr: print(i) main()
26d083191f7d9a06da742fcee90b8c338dab7145
challakarthikreddy/project_euler
/10001_prime_number.py
229
3.578125
4
count = 1 for num in range(2,10000000): prime = True for i in range(2,num): if (num%i==0): prime = False if prime: count = count +1 print str(num) + '-----' + str(count) +'st prime'
3f5f69c4e6367e25c885f5fc1217284ac665e4c2
poojataksande9211/python_data
/python_tutorial/excercise_2/func_range.py
227
4.1875
4
#Write a Python function to check whether a number is in a given range def range_with(n): if n in range(3,9): print("%s is in the range"%str(n)) else: print("%s is out of the range"%str(n)) range_with(8)
7cd01c71f45fbf08b2465ddd8ef9b77e241ffc3c
ttessaractt/Programming2_Tessa
/Problems/Plotting Problems/matplotlib_CTA_ridership.py
2,535
4.09375
4
# CTA Ridership (28pts) # Get the csv from the following data set. # https://data.cityofchicago.org/Transportation/CTA-Ridership-Annual-Boarding-Totals/w8km-9pzd # This shows CTA ridership by year going back to the 80s #1 Make a plot of rail usage for the most current 10 year period. (year on x axis, and riders...
0cf020afb34a34f0adec19756624b0e061937413
zhousihan0126/zimpute
/zimpute/Select_r.py
529
3.5625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Oct 31 17:08:15 2019 @author: sihanzhou """ #the method about select r import numpy as np def select_r(Data_matrix_M): u,sigma_list,v_T=np.linalg.svd(Data_matrix_M,full_matrices=False) sigma_sum=0 for i in range(0,len(sigma_list)):...
f44acbfd63bc7949a8bcafa524a0ac0b8d389b9d
rhanmiano/100days-coding-challenge
/py/day5-title-case.py
1,049
4.0625
4
## # 100 Days Coding Challenge # # @author Rhan Miano # @since November 6, 2018 # # Pushing myself to do this 100 Days Coding Challenge. ## # Day 5 Title Case A Sentence # Return the provided string with the first letter of each word capitalized. # Make sure the rest of the word is in lower case. # Initi...
e266979ce618689e922486c756e973f5cee0886a
Bshel419/5303-DB-Shelton
/A09/A09.py
13,184
3.921875
4
#Benjamin Shelton and Garrett Morris #A09 #Simple python program that generates users and has them send messages and times #how long it took, by default it's 1000000 users, but can be paramaterized as well. from random import randint from time import time from time import sleep #startTime is universal startTime = time...
3c83b4ba12d8be6c8826f0f9f59922e2d2faa6ed
akhlaque-ak/pfun
/reference files/Reference Files/Lab 4/Exercise_4_2/Exercise_4_2.pyde
508
4.125
4
'''Exercise 4.2 Look up the pushMatrix() and popMatrix() function and understand their working. Create a program and define a function named rec() which draws a series of 5 rectangles 100 units high and 150 units wide whenever the mouse is pressed. hint: Use loops and transformations. ''' def setup(): size(5...
8180105bf40950d5d62f12e20b20636563760116
python-yc/pycharm_script
/流畅的python/第1~2章节 序幕和数据结构/双向队列.py
1,416
3.734375
4
# -*- coding: utf-8 -*- """ collections.deque类(双向队列)是一个线程安全、可以快速从两端添加或者删除元素的数据类型。 而且如果想要有一种数据类型来存放“最近用到的几个元素”,deque也是一个很好的选择。这是因为在 新建一个双向队列的时候,你可以指定这个队列的大小,如果这个队列满员了,还可以从反向端删除过 期的元素,然后在尾端添加新的元素 """ from collections import deque # maxlen是一个可选参数,代表这个队列可以容纳的元素的数量,一旦设定,这个属性就不能修改 dq = deque(range(10), maxlen=10) print(dq)...
789c7521b3406e5c4e05e2fb902c1e5168166034
Siriapps/hackerrankPython
/strictSuperset.py
377
3.65625
4
# https://www.hackerrank.com/challenges/py-check-strict-superset/problem bools = list() setA = set(map(int, input().split())) for _ in range(int(input())): setN = set(map(int, input().split())) bools.append(setA.issuperset(setN)) # loop for checking superset without using built-in function # for i in s...
5aef115e57520ca9ab2cf4911b8cf8d49efd5b40
csjzhou/py-codes
/lists-stack.py
350
4.125
4
# Tutorial: http://www.idiotinside.com/2015/03/01/python-lists-as-fifo-lifo-queues-using-deque-collections stack = ["a", "b", "c"] # add an element to the end of the list stack.append("e") stack.append("f") print stack # pop operation stack.pop() print stack # pop operation stack.pop() print stack # push operation...
2232a3a688d1f57df8036a304543c16c884d72b6
krl97/cool-compiler-2020
/src/code_generation/variables.py
1,073
3.6875
4
class Variables: def __init__(self): self.stack = {} self.vars = [] def add_var(self, name): self.stack[name] = len(self.stack) + 1 self.vars.append(name) def id(self, name): if not name in self.stack: self.add_var(name) return int(len(self....
b68e6863f0920a84eefa13e0cf8f5ec0b67dc668
LastGunslinger/project_euler
/project_euler/problems/problem_019.py
1,789
3.9375
4
prompt = ''' You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on leap y...
d4b5c9d861caf2e7ce4002093b0ec62c4c34b987
altonelli/interview-cake
/problems/python/second_largest_node.py
576
3.984375
4
from binary_tree_node import BinaryTreeNode def find_second_largest_node(root): if not root.left or not root.right: return root.value current_largest = root second_largest = None while current_largest.right: second_largest = current_largest current_largest = current_largest.righ...
8b8977d8d74a70f272c0139fcec6b08a0deb8692
hebe3456/algorithm010
/Week01/21.合并两个有序链表.py
2,587
3.75
4
# # @lc app=leetcode.cn id=21 lang=python3 # # [21] 合并两个有序链表 # # @lc code=start # Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: # iteratively 迭代 # recursively 递归 # time: O(m+n) 其中 m 和 m 分别为两个链表的长度...
3e55d65181ca9b5f1dfcf8706477d10e5f97fb2a
jaelzela/cracking_code
/running_median.py
527
3.609375
4
#!/bin/python import sys def insertElement(a, e): if len(a) == 0: a.append(e) i = 0 while i < len(a): if e < a[i]: a.insert(i, e) break i += 1 n = int(raw_input().strip()) a = [] a_i = 0 for a_i in xrange(n): a_t = int(raw_input().strip()) #insertEl...
4de10ea6b8cd6c2b471efd95734436a95622862f
mjavorka/adventofcode
/day20/day20.py
2,082
3.609375
4
# !/usr/bin/python3 """ http://adventofcode.com/2017/day/20 author: Martin Javorka """ class Day20: def __init__(self): data = [line.rstrip().split(', ') for line in open("input", 'r')] self.particles = [] for row in data: position = list(map(int, row[0].strip('p=<>').split('...
1888900e9495baae1638fac60d597fdb8ffa1691
instnadia/python-03-20
/Week_1/Day_2/questions.py
1,188
4.375
4
students = [ {'first_name': 'Michael', 'last_name' : 'Jordan'}, {'first_name' : 'John', 'last_name' : 'Rosales'}, {'first_name' : 'Mark', 'last_name' : 'Guillen'}, {'first_name' : 'KB', 'last_name' : 'Tonel'} ] # def iteratedDictionary(some_list): # for i in range(len(some_...
34b5671c27432ad4ec879e7f45708e1646e58f53
Lohit9/python_algorithms
/legacy/linked_list/rerverse_llist.py
343
4
4
# //Reverse a linked list // 2 --> 4 --> 5 --> 6 def revllist(node): if not node: return None elemList = [] while(node.next not None): elemList.append(node) node = node.next node = None for each in elemList.reverse(): node = each node.next = None node = node...
876302556703c060fe3240dd6535f43c97e8da45
fdanmon/times
/countdown.py
731
3.859375
4
#! /usr/bin/env python3 import time from datetime import datetime import helpers print("Time data must be in 24 hrs format!") end = input("Type ending time (hh:mm:ss dd-mm-yyyy) -> ").strip() if helpers.is_datetime(end): try: end_dt = helpers.to_datetime(end) now = datetime.now().strftime('%H:%M...
48c233e978584f023495009d0e271c9117365b60
chetnachauhan12/hacktoberfest2021-2
/Python program/stack.py
718
3.953125
4
st=[] c='y' while c=='y': print("(1) Enter Employee details") print("(2) Delete Employee details") print("(3) Display Employee details") ch=int(input("Enter function choice: ")) if (ch==1): a=int(input("Enter employee_id : ")) b=input("Ener employee_name: ") j=[] ...
fc607fe1de128e6cd8b622d650fb6ca8edd37e2e
mehularora8/Probability-simulators
/hundreds_game.py
976
3.765625
4
""" Problem: Two players play a game. The game starts with S = 0 Player 1 draws random numbers and adds it to S till S > 100, at which point Player 1 notes their last number. Player 2 continues to add numbers to S till S > 200, at which point Player 2 notes their last number. Player 2 wins if lastNum(Player 2) > la...
9c00fc746ac4f768f9dedc2d44a3fe46deafa331
amy58328/python
/pandas/hello pandas.py
795
3.796875
4
import pandas as pd # 準備傳入 DataFrame 的資料 data_1 = { 'name': ['王小郭', '張小華', '廖丁丁', '丁小光'], 'email': ['min@gmail.com', 'hchang@gmail.com', 'laioding@gmail.com', 'hsulight@gmail.com'], 'grades': [60, 77, 92, 43] } data_2 = { 'name': ['王小郭', '張小華', '廖丁丁', '丁小光'], 'age': [19, 20, 32, 43] } # 建立 Data...
9401d384a2d8d88129d3ffcc91590a0679d1081f
RembertoNunez/Parking-Spot-Detector
/mockLight/.~c9_invoke_cZFUyo.py
3,264
3.5
4
#Author: Daniel Ochoa #last Modified: 04-19-17 #Description: This file connects the project together. Its main purpose is to read the scores and deside if the parking spot is open or not. #futher improvements: 1. Connect the results of this file into the notification services. #2. make the system calls into a function ...
717ce73fca2bd28ca5f31309f0f3c2f11c79cdfa
jdiodati20/hangman
/Book/chap4.py
461
3.84375
4
def square (var): """ returns var squared. :parameter var: int. """ return(var ** 2) print(square(5)) def printing (string): print(string) printing("hello") def optional (str0, str1, str2, str3 = 2, str4 = 1): print("nice") print(str3) print(str4) optional(0, 1, 2, 10) def di...
e26b023954e2f6329062d8d36203afb4b0dd7f58
mayurshetty/Python-Assignment-from-HighSchool
/Lab4.01-de_vowel/Lab 4.01-de_vowel.py
571
4.125
4
vowel_list = ["a","e","i","o","u","A","E","I","O","U"] def de_vowel(a_string): global vowel_list de_vowel_string = [] for list_letter in a_string: if list_letter not in vowel_list: de_vowel_string.append(list_letter) return("".join(de_vowel_string)) def count_vowels(a_string): global vowel_list vo...
83d71778cb0ad3383239338bd6bdc9029c9e509e
PrakashChanchal1998/pyathonproject
/gu.py
187
3.859375
4
for n in range(1,3): from random import randint d=randint(1,20) print(d) if d<15: print("try again") elif d==15: print("you score it") break elif d>15: print("try again")
d94b368c1851021f0005ed0e8df3677182b8589f
kriti-ixix/ml-130
/python/reverse star pattern.py
237
4.09375
4
# for row in range(5, 0, -1): # for col in range(1, row+1): # print("* ", end='') # print("") stars = 5 for row in range(1, 6): for col in range(1, stars+1): print("* ", end='') print("") stars -= 1
3fa5566438d0c0649bdc357c225d6bd800d7369e
fortelg/python
/eje38.py
502
3.90625
4
#!/usr/bin/python #!encoding: UTF-8 print "Introduzca el valor para n:" n = int (raw_input()) print "Introduzca el valor para m:" m = int (raw_input()) numeros = [] for i in range(n, m+1): numeros.append(i) print "Los numeros almacenados son:" for i in range(m-n+1): print numeros[i] suma = 0 for i in range(m-n+1):...
c3e92c963e4f5a27b60e66f1e151063590474d1f
Adit-COCO-Garg/rit-cscI141-recitation
/Replace.py
492
3.96875
4
# Tigran Hakobyan # week4 recitation class #strReplace(’test’, ’t’, ’x’) => 'xesx' # replace x with y in st. def strReplace(st, x, y): if len(st) < 1: return st else: if st[0] == x: return y + strReplace(st[1:],x,y) else: return st[0] + strReplace(st[1:],x,y) def strReplaceIter(st, x, y): result ...
19dcd36a4698fc21ff17961ef99a5084b26c2512
signalwolf/Leetcode_by_type
/MS Leetcode喜提/店面准备MS/面经/微软电面2.py
271
3.796875
4
# coding=utf-8 # 给俩没sorted 的array, 每个array和俩array之间都有可能出现重复数字。要求merge这俩array 做到sort 和去重 def merge(A1, A2): return sorted(list(set(A1).union(set(A2)))) print merge([1,23,4423,55,1,2], [1,3,4,6,7,8,12,3,6])
0068f095d2d14896c11bab46707b264ace0f1dd6
srishilesh/Data-Structure-and-Algorithms
/HackerRank/Practice/candies.py
6,921
4.25
4
# https://www.hackerrank.com/challenges/candies/problem ''' Alice is a kindergarten teacher. She wants to give some candies to the children in her class. All the children sit in a line and each of them has a rating score according to his or her performance in the class. Alice wants to give at least 1 candy to each c...
2aa894799300cbffa2081730e2902d5d2e37a80a
shurawz/BasicPython
/Comprehension/listcomp.py
451
4.375
4
numbers = [1, 2, 3, 4, 5, 6] number = int(input("Please enter a number. I'll tell you its square value: ")) squares = [number ** 2 for number in numbers] # Using Comprehension which is list comprehension # cubes = {number ** 3 for number in numbers} # Using Comprehension which is set comprehension # 'number ** 2' ...
d22b68f91776b53c37f232e5c6790e551b3d21f7
J-TKim/Effective_Python_2nd
/Ch3/Better_way20.py
1,902
3.65625
4
# 0으로 수를 나누려는 경우 None을 반환하는 함수 def careful_divide(a, b): try: return a / b except ZeroDivisionError: return None # 이함수를 사용하는 코드는 반환 값을 적절히 해석하면 된다. x, y = 1, 0 result = careful_divide(x, y) if result is None: print('잘못된 입력') # 피제수가 0인 경우 0이 return되어 잘못된 코드가 실행된다. x, y = 0, 5 result = caref...
ad2f2987898e888752369a1f058485c8cf258c64
zofiagrodecka/ASD
/Grafy/malejace_krawedzie_najkrotsza.py
1,966
3.53125
4
def parent(i): return i // 2 def left(i): return i * 2 def right(i): return 2 * i + 1 def empty(k): if k[0] == 0: return True else: return False def heapify(k, i): l = left(i) r = right(i) mini = i size = k[0] if l <= size and k[l][1] < k[mini][1]: ...
6ac853fe84ea0e3c21d877cbd9488262388ea9be
Hairidin-99/quiz
/quiz2.py
2,772
3.609375
4
print "welcome in our game" random import chislo1 = int(input("vyberite chislo ot 0 do 6")) comp = random.randint(1,6) if chislo > 6: print "vyberite chislo ot 1 do 6" elif comp < 0: print "vyberite chislo ot 1 do 6" elif comp == chiclo1: x = kh - chislo1 ball = 6 print "Tvoi kolichetvo ballov:" print ...
d059326bf2e1b55306d08a5513ddde76530cfbf2
geetanjalisawant16/GS_WINE
/Clustering.py
12,684
3.53125
4
# This code is to implement Clustering methods. # Importing all Libraries from sklearn.cluster import KMeans, AgglomerativeClustering, MeanShift, Birch # Our clustering algorithm from sklearn.mixture import GaussianMixture # To implement GaussianMixture model clustering from sklearn.decomposition import PCA # Ne...
100b3472314334813a10184af3347445db3e70d5
lucasguerra91/some-python
/Trabajos_Practicos/TP3/entrega/pluma.py
999
3.8125
4
class Pluma: '''Crea una Pluma para ser utilizada por la clase Tortuga.''' def __init__(self, ancho=1, color="black"): self.ancho = ancho self.color = color self.abajo = True def esta_abajo(self): '''Devuelve la posición de la Pluma: True si está abajo, False si está arriba.''' return self.abajo d...
2b587eb5292af3261309413e7cd9436add8b72ef
dilesh111/Python
/20thApril2018.py
904
4.625
5
''' Python program to find the multiplication table (from 1 to 10)''' num = 12 # To take input from the user # num = int(input("Display multiplication table of? ")) # use for loop to iterate 10 times for i in range(1, 11): print(num,'x',i,'=',num*i) # Python program to find the largest number among the three ...
4836686b3106701382e3b85859b177d09353a308
spaingmzdaeg/MetodosBusqueda_Python
/Busqueda.py
2,179
3.65625
4
import random class Busqueda: def busquedaSecuencial(self,unaLista,datoBuscar): pos=0 encontrado=False while pos < len(unaLista) and not encontrado: if unaLista[pos]==datoBuscar: encontrado=True else: pos=pos+1 return encontrado...
44d92f19f6e734ea3b8eb6de47804fa0bf6d7948
quanee/Note
/Python/Python/Python19.py
778
3.609375
4
from time import ctime, sleep import threading ''' 线程实例 计算密集型 c IO密集型 多线程 ''' def music(func): for i in range(2): print("Begin listening to %s. %s" % (func, ctime())) sleep(1) print("end listening %s" % ctime()) def movie(func): for i in range(2): print("Begin watching at t...
a7a76e60dcac10eb0484d546b767349df6487036
mubaskid/new
/DAY4/List.py
325
4.09375
4
NUMBERS = 6 numbers = [] sum = 0 for i in range(NUMBERS): value = int(input("Enter a number: ")) numbers.append(value) sum += value average = sum / NUMBERS count = 0 for i in range(NUMBERS): if numbers[i] > average: count += 1 print("average is", average) print("number above average is", c...
b9beb71069f47b5003aba3ea400e582f83ca8a7d
bellagrin10/GeekBrains_PythonBasics
/HomeWork3/task_3_4_variant2.py
1,248
3.765625
4
def thesaurus_adv(*args): """ The function takes strings in the format "First Name Last Name" as arguments and returns a dictionary, in which the keys are the first letters of the surnames, and the values are dictionaries, in which the keys are the first letters of the names, and the values are lists,...
3e611d51973056a745287c7fd60781990a791d71
WarrenJames/LPTHWExercises
/exl20.py
2,777
4.40625
4
# Exercise 20: Functions and Files # # from system folder, import argument variable from sys import argv # script, input_file = argv # it will look like in terminal: python exl20.py (file of choice as input_file) script, input_file = argv # define(function) print_all(with f as an expression): <-- consists of # prints ...
9a4094089475fb4786aefd7901241311aeae95ef
mennanov/hackerrank
/warmup/lonely_integer.py
394
3.65625
4
""" There are N integers in an array A. All but one integer occur in pairs. Your task is to find the number that occurs only once. We can use XOR to solve this problem in linear time: x ^ x = 0, so the only number which will remain is a lonely number. """ if __name__ == '__main__': _ = input() ints = map(int, ...
3357aa457d6d82af7d85ffd319884640a99087bc
France-ioi/taskgrader
/examples/taskRunner/tests/gen/sol-bad-py.py
411
3.515625
4
#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # Example bad solution for this task # Defines the function min3nombres which is then used by the runner def min3nombres(a, b, c): # Bad solution: we return the max instead of the min if a < b: if b < c: return c else: re...
42a35149f94ba560b93d86e676ac88560caa8e73
DajuanM/DHPythonDemo
/02_高级用法/04_高级函数补充.py
905
3.625
4
# zip l1 = [1,2,3,4] l2 = [10,20,30,40] z = zip(l1,l2) print([i for i in z]) # enumerate l = [10,20,30,40] em = enumerate(l) l2 = [i for i in em] print(l2) em = enumerate(l, start=100) l2 = [i for i in em] print(l2) # collections模块 # - nametuple # - deque 解决了频繁删除插入的效率问题 import collections Point = collections.namedt...
febfcc3e1daf6945994c6387d2ca881f8ed15c10
eternalseptember/CtCI
/05_bit_manipulation/03_flip_bit_to_win/flip_bit_to_win_sol_1.py
1,713
3.6875
4
# Brute force solution # Integer.BYTES = 32? # O(b) time and O(b) memory, where b is the length of the sequence. def longest_sequence_of_ones(num): if num == -1: # -1 in binary is a string of all ones. # This is already the longest sequence. return "No bits are flipped." sequences = get_alternating_sequences...
6cb6ca4d7eaee6ec5d2930b39e45ac58b6a8b7c0
panchyni/PseudogenePipeline
/_pipeline_scripts/1_3_getUniqesFromCol.py
409
3.625
4
#This script is designed to simply print the number of unique items in a given #column #Created by David E. Hufnagel on June 13, 2012 import sys inp = open(sys.argv[1]) #input file to check for unique items col = int(sys.argv[2]) - 1 #the column to check for unique items theSet = set() for line in inp: line...
cb9926b4eb1ae20e9bac19751a3f55460f0ccf6b
LingChenBill/lc_pandas
/ch03/4_find_max_by_sorted.py
1,118
3.59375
4
#! /usr/bin/python3 # -*- coding:utf-8 -*- # @Time: 2020/6/27 # @Author: Lingchen # @Prescription: 通过排序选取每组中的最大值 import pandas as pd movie = pd.read_csv('../data/movie.csv') movie2 = movie[['movie_title', 'title_year', 'imdb_score']] print('movie2按照title_year降序排列: ') print(movie2.sort_values('title_year', ascending=Fa...
8e1eaca2c534ab590ef058f10c521bcab1b4c678
xiaochenchen-PITT/CC150_Python
/Leetcode/Unique Binary Search Trees.py
866
3.703125
4
# Unique Binary Search Trees class Solution: # @return an integer def numTrees(n): # DP mp = {0: 1, 1: 1} # key: n, value: number of different structures if n in mp: return mp[n] for i in range(2, n+1): # i nodes res = 0 sm = 0 for j in ...
1a2c878c2a7417c4258a3e75e36e1e1f6dad15af
SandboxGTASA/Python-1
/Jogo da forca/jogo_da_forca.py
1,663
3.78125
4
import random import time palavras = ('casa', 'abelha', 'cachueira', 'porta', 'mesa', 'lixeira', 'cadeado', 'guarda') sorteio_palavras = random.choice(palavras) # Pegando palavras aleatorias letras = [] tentantiva = 5 acertou = False print('='*20 + ' JOGO DA FORCA ' + '='*20 + '\n') print('Sorteando um palavra...'...
6de3ec1cfef71a8e50c8f6b69bf6e3a6dccc6b3a
jeysonrgxd/python
/nociones_basicas/operadores_expresiones/operadores_logicos.py
546
4.1875
4
# OPERADOR not # not true = false # dos formas de expresion logicas por conjuncio(AND) y disyuncion(OR) ''' >> True and True True >> not True False >> True or False True >> False or False False >> not True == False True >> False and False False ''' print("CONJUNCION and\n") a=13 b = a > 10 and a < 20 print(b) #sal...
873fad90d0b61790b78434d7786c2a1d9aabc05c
NagiReddyPadala/python_programs
/Python_Scripting/Pycharm_projects/DataStructures/LinkedList/DoublyLinkedList.py
2,866
3.59375
4
class Node: def __init__(self, data): self.data = data self.prev = None self.next = None class DoublyLinkedList: def __init__(self): self.head = None def append(self, data): new_node = Node(data) if not self.head: self.head = new_node el...
9f4a8310cf7402cfb4418db7cf2c3ab2c10aa2a5
seoket1/BootCamp2017
/Homeworks/Math/Week6/Some_Codes_for_Chapter_8.py
1,574
3.5625
4
import numpy as np from matplotlib import pyplot as plt # 8.1 x = np.linspace(-10, 10, 1000) y = np.linspace(-10, 10, 1000) f = 5*x - 4*y y1 = (1/3) * (2*x + 4) y2 = (1/6) * (x-1) y3 = 6 - x plt.plot(x, y1, label = "y1") plt.plot(x, y2, label = "y2") plt.plot(x, y3, label = "y3") plt.plot(x, np.zeros(x.size), label...
3047affa42aa289118bdcf5c8ecfd192ebe6b7c7
highjump000/DNNEXMP
/ReinforcementLearningEXP/ENVIRONMENT.py
1,421
3.5625
4
#created by bohuai jiang # on 2/10/2017 09:47 # create agent environment import numpy as np class ENVIRONMENT: def __init__(self,width,height): self.width = width self.height = height self.I = [0,0] # initial state self.O = [width-1,height-1] # end state self.NUMBER_OF_ACTIO...
7cd01906f57c1bcbcef26ffd2ebdb78aba0080ed
Suganya108/guvi
/looping/swap_first_and_last_digits_of_a_number.py
178
3.875
4
# Write a program to swap first and last digits of a number. def fun(n): c=str(n) c[0],c[-1]=c[-1],c[0] print(c) return 0 n=int(input("Enter no. : ")) fun(n)
416be965774c5c1ef85adc8c576a0948af2289df
JishnuRamesh/Algorithms-and-datastructures
/Hashmap/hashmap.py
2,240
3.546875
4
class map: def __init__(self, size): self.size = size self.keys = [None] * self.size self.value = [None] * self.size def put(self,key,value): probeIndex = 0 hashValue = self.hash_function(key,len(self.keys), probeIndex) if self.keys[hashValue] == None or \ ...
62ab47d114423cb039bc16b2859758d62dde2ca3
CocoaBrew/General
/Python/PokerGame.py
3,825
4.03125
4
# This program will let user play a simple Poker game, # then report user's score and thank him for playing at end # Dan Coleman # 12/04/13 # Program 6 # provides information for Dice class import random class Dice: def __init__(self): # create empty dice, then roll to set them self.dice = [0] *...
91f61ca12407633ddfb7692f61e9e4c6b783c55a
Silvio622/pands-problems-2020
/Lab 03 Variable and State/lab03.03-div.py
327
4.21875
4
# program that reads in two numbers and # outputs the integer answer and remainder x = int(input("Enter first number: ")) y = int(input("Enter the number you want to divide by: ")) answer = int(x/y) remainder = x%y # remainder is percent sign % print("{} divided {} is {} with remainder {}".format(x, y, answer, remai...