blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
324e4ca6292ef63cd68fb5708144e7f33454af3d
VaibhavRangare/python_basics_part1
/List1.py
790
4.0625
4
list1 = [1, 2, 3, 4, 5, 6, 7, 8, 8] print(len(list1)) print(list1[0]) print(list1) # start index:end index:step print(list1[::2]) print(list1[:]) list1.append(9) print(list1) print(list1.count(8)) # how many times an item is there in the list print(list1.index(4)) # index position of...
f16366640ba48446b1afeaac2bc1f976e42e75ec
TechKrowd/sesion2python_10062020
/alternativas/01.py
174
3.8125
4
""" Pedir un número por teclado y comprobar si está comprendido entre 1 y 10. """ n = int(input("Introduce un número: ")) print("Si") if n>=1 and n<=10 else print("No")
3d78654f3592bc041d7322d41be9f1f0ebd30fb9
daniiarkhodzhaev-at/lab1
/2.py
300
3.53125
4
#!/usr/bin/python3 import matplotlib.pyplot as plt import numpy as np def y(x: np.ndarray) -> np.ndarray: return x ** 2 - x - 6 def main() -> int: _x = np.array(range(-300,400)) / 100 _y = y(_x) plt.plot(_x, _y) plt.show() return 0 if (__name__ == "__main__"): main()
85ecf178f301c7dec9407eb66554058bd9dafd64
Danilo-mr/Python-Exercicios
/Exercícios/ex005.py
106
3.96875
4
n = int(input('Digite um número: ')) print('Antecessor é {} e o sucessor é {}'.format(n-1, n+1))
cbb1f87b88123c1286fb127dd8e76bfed156663e
Sranciato/holbertonschool-interview
/0x13-count_it/0-count.py
1,141
3.5625
4
#!/usr/bin/python3 """Queries Reddit API and finds keywords from all hot posts""" import requests from sys import argv def count_words(subreddit, word_list, after="", counter={}, check=0): """Queries Reddit API and finds keywords from all hot posts" """ if check == 0: for word in word_list: ...
ed8c3082a7b09917a031102ffa1b96752a637726
Elmlea/pythonLearn
/ex23.py
1,103
3.921875
4
import sys # this is command line argument handling script, encoding, error = sys.argv def main(language_file, encoding, errors): line = language_file.readline() #reads a line from language_file if line: #if statement; the indented lines below run if true print_line(line, encoding, errors) #lines 9/1...
4cd89955a81924314ebea33ad83f2b07c5d59a12
peltierchip/the_python_workbook_exercises
/chapter_5/exercise_122.py
990
4.03125
4
## #Translating the string entered by the user into Pig Latin language #Read the string from the user s_e=input("Enter a string:\n") w="" #Create a list to store the words of the string entered l_s_e=s_e.split() #Create a list to store the words stored in l_s_e in Pig Latin language l_s_p_l=[] #Translate each stored wo...
37deb9eabf9cbf639c7c4d9a7f387e546577fd5e
westyyyy/What-am-i
/What am I.py
924
4.125
4
def valid(question): answer = input(question + "\n> ") while not(answer == "y" or answer == "n"): answer = input(question + "\n> ") if answer == "y": return True return False print ("Welcome to what am I\nRespond with y/n\n") if valid("Does it have legs?"): if valid(...
4cdb7e1693b8e5d73aeab0b115a38a36d4d2df58
himanshu2801/hackerrank_code
/filling jars.py
703
3.578125
4
""" Link of the question... https://www.hackerrank.com/challenges/filling-jars/problem Solution... """ #!/bin/python3 import os import sys # Complete the solve function below. def solve(n, operations): sum=0 for i in range(len(operations)): sum=sum + (operations[i][1] - operations[i][0] + 1)*operation...
bed0e874f9a755ecd5d04e3c0c5ed6f8ef2a8eb0
DavidGavaghan/pints
/pints/_util.py
2,366
3.5
4
# # Utility classes for Pints # # This file is part of PINTS. # Copyright (c) 2017, University of Oxford. # For licensing information, see the LICENSE file distributed with the PINTS # software package. # from __future__ import absolute_import, division from __future__ import print_function, unicode_literals import ...
c277727f39f20dc1baa477f5c6183affdc81a2cb
wolfgang-stefani/computer-vision_canny_edge_detection
/canny-edge-detection.py
1,264
3.65625
4
# Do all the relevant imports import matplotlib.pyplot as plt import matplotlib.image as mpimg import numpy as np import cv2 # Read in the image and convert to grayscale # Note: in the previous example we were reading a .jpg # Here we read a .png and convert to 0,255 bytescale image = mpimg.imread('exit-ramp.jpg') gr...
e13854d98c9ff420c1a7d1c2cf59866fe23efa39
kristophbee/general
/guessurnum.py
1,238
3.890625
4
import random validVal=False guessed=False maxVal=100#max zakres minVal=0#min zakres tries=0 while validVal == False: print("Enter a number") resp = input() try: val=int(resp)#zrzut do inta if int(resp) < minVal or int(resp) > maxVal: print...
04b841123a22899f60724a23e7154f46b6e3106c
slmnptl11/Simple-Expense-Tracker
/Expense_tracker_.py
4,062
4.375
4
import sqlite3 import datetime class Mymain: # Defining the main function to operate other function in the body def main(self): while (True): print("=====================================================") print(" -=-=-| Welcome to the Expense Tracker system |-=-=- ") ...
2b3c55daa8a1ab27a0bcb5c7e794557fbf87f731
ehoversten/flask_fundamentals
/assignment_routing.py
876
4.34375
4
# ------------------------------------------------------------------------------/ # Assignment: Understanding Routing # Objectives: # Practice building a server with Flask from scratch # Get comfortable with routes and passing information to the routes # # -----------------------------------...
8e4e199418dd4e581bd5cacc6694be07f2e67598
wahab14131211/Bell_pey_challenge_Wahab
/Files for Testing/pred_war_testing.py
1,915
3.71875
4
from random import * #This script is a simple version of the predwar game described in the challenge statement. #This is used to test 2 strategies, to determine which one is better def player2(x,y,z,b,r,k): #where k is the desired betrayal rate for player2 if randint(0,100) < k: return "cooperate" ...
ffa8014c4526962ceb18bf32e2452300ac8baa5e
AlekhyaMupparaju/pyothon
/79.py
120
3.53125
4
import math s,m=map(int,raw_input().split()) a=s * m if math.sqrt(a).is_integer(): print "yes" else: print "no"
9efb509eee250a0d29f3d76076da55f22f051002
mmfrenkel/brain-teasers
/python_problems/problem7/main.py
1,257
3.765625
4
#!/bin/python3 import math import os import random import re import sys # Complete the hourglassSum function below. def hourglassSum(arr): largest_sum = 0 if not arr or len(arr) < 3 or len(arr[0]) < 3: return largest_sum rows_of_hour_glasses = len(arr) - 2 for row in range(0, rows_of_hour_g...
1f3041f20e0e7e00802a75e2411ecc21c3338e63
RALF34/McGyver_Game
/classes.py
9,391
3.59375
4
"""classes for McGyver game""" import pygame import random from pygame.locals import * from constants import * class Labyrinth: def __init__(self, code_file): """File coding the structure of the labyrinth """ self.code_file = code_file """Dictionnary containing the three objects as keys ...
061277ad4e1e23eedbb5572746c03bed5973720d
Chiranjit-Mukherjee/code-20210227-cmukherjee
/bmi_index.py
2,028
3.75
4
import argparse import pandas as pd from pandas import ExcelWriter import sys def process_bmi(input, output): try: df = pd.read_json(input) except Exception as e: print("Error: Specified file could not be found. Please check the file name and path") sys.exit() # calculating and storing BMI df['BMI'] = (df...
2a041e301a6aa0d8dcbb6ec69393e5cda869155a
sandhiyasajiv/python
/positive or negative.py
167
4.28125
4
num=float (input(Input a number:")) if num>0: print("it is positive number") elif num==0: print("it is zero") else: print("it is a negative number")
2ec29932c1277baad3568b37839de1dfc81e6eab
peterpanGreg/Snake-in-blender-python
/Function.py
4,675
3.578125
4
from random import choice class Table(): def __init__(self,x,y): self.cord={} for i in range(y): for k in range(x): self.cord[(k,i)]=True self._keys=[] for i in self.cord.keys(): self._keys.append(i) self._values=[] for i in s...
abd44b923998a7121f4a1ab426f44aa32ec6cefd
Jaswantsinghh/Python-Codes
/conversion to list and tuple.py
120
3.796875
4
a=input("Input comma seperated numbers :") list=a.split(",") tuple=tuple(list) print('list:',list) print('tuple:',tuple)
1d47f8f4d3e911cb2ae264088dac920ee3e45b0e
larafonse/cti-ips-2020
/math_m2/excel_column.py
239
3.96875
4
def excel_column_to_number(column): sum, count = 0,0 for i in range(len(column)-1,-1,-1): sum += (26**count) * (ord(column[i]) - 64) count+=1 return sum if __name__ == "__main__": print(excel_column_to_number(input()))
e87ebaf99af3550abea7494250b3da1d9aaced58
flashfinisher7/ML_Fellowship
/Week1/Program35.py
516
4.125
4
while True: try: ele1 = input("Enter the element1:") ele2 = input("Enter the element2:") ele3 = input("Enter the element3:") ele1 = int(ele1) ele2 = int(ele2) ele3 = int(ele3) List = [ele1, ele2, ele3] print('Your List is: ' + str(List)) new_...
c022575d283077e5d609f82142e566286f2ddf67
bssrdf/pyleet
/S/SubstringXORQueries.py
3,589
3.78125
4
''' -Medium- *Robin Karp* *Rolling Hash* *Hash Table* You are given a binary string s, and a 2D integer array queries where queries[i] = [firsti, secondi]. For the ith query, find the shortest substring of s whose decimal value, val, yields secondi when bitwise XORed with firsti. In other words, val ^ firsti == seco...
a920c30a15a1c137cfbe6ccfc63cad331342fb3f
Anshikaverma24/meraki-function-questions
/meraki functions ques/debug last part/q2.py
168
3.75
4
# function multi(a,b): # multiply=a*b # return multiply # print(multi(3,4)) # ANSWER def multi(a,b): multiply=a*b return multiply print(multi(3,4))
a1e86e90766f33f078b4a59b89ae01ab26479377
radomirbrkovic/algorithms
/hackerrank/other/manasa-and-stones.py
317
3.765625
4
# Manasa and Stones https://www.hackerrank.com/challenges/manasa-and-stones/problem def stones(n, a, b): result = set() if a > b: a, b = b,a for i in range(n): result.add(i * a + (n-1 - i) * b) return sorted(list(result)) print stones(3, 1, 2) print stones(4, 10, 100)
7f1188a91a4d8502f042568b541d070b794687c7
xfree86/Python
/code/ex00007.py
1,320
3.953125
4
# -*- coding: utf-8 -*- # 字符串、变量、格式化符号、运算符练习 # 打印字符串 print "Mary had a little lamb." # 打印字符串,%s格式化字符调用后面的snow字符串 print "Its fleece was white as %s." % 'snow' # 打印字符串 print "And everywhere that Mary went." # 打印字符串,10个点 print "." * 10 # what'd that do? # 给变量end1赋值字符串C end1 = "C" # 给变量end2赋值字符串h end2 = "h" # 给变量en...
5e36bdfc807bb3aac84c558f18433c53dd399b74
RitwickRoy/Annova
/Anova_analysis.py
3,113
3.703125
4
# -*- coding: utf-8 -*- """ Created on Fri Oct 2 07:04:41 2020 @author: Ritwick """ # # ANOVA analysis # import pandas as pd # # read sample data and perform Anova analysis. # # Read input Excel file # Each sample/group is a column with first row containing # the sample name. The data is assumed...
b63dee02f8fc3c33c3d89774ff44b7c27e983e62
ruoilegends/NGUYENTANLOC_43807_CA18A1A
/NguyenTanLoc_43807_CH03/exercise/Page92_Exercise_01.py
487
4.09375
4
""" Author: Nguyen Tan Loc Date: 10/09/2021 Problem: Translate the following for loops to equivalent while loops: a. for count in range(100): print(count) b. for count in range(1, 101): print(count) c. for count in range(100, 0, –1): print(count) Solution: a. count = 0 while count < 100: print(co...
372f073cf48acd32f48a979cc3c141e4c4e0e7bd
IshratEpsi16/Book-Library
/bookbd.py
2,532
3.546875
4
from tkinter import * import backend #select the row def get_selected_row(event): global selected_tuple #global variable index=l1.curselection()[0] selected_tuple=l1.get(index) e1.delete(0,END) # 0 to end e1.insert(END,selected_tuple[1]) e2.delete(0,END) e2.insert(END,selected_tupl...
3bc304f5fec8a3f16efd4077a3538a205459f545
RafalProkopowicz/Grafy
/graf2.py
1,977
3.625
4
size = int(raw_input("rozmiar tablicy: ")) tab = [[None] * size for i in range(size)] # pomocnicza macierz sasiedztwa, jak jej nie bedzie to poprosi o uzupelnienie danych tab = [[0, 1, 0, 0, 0], [1, 0, 0, 1, 0], [0, 0, 0, 0, 0], [0, 1, 0, 0, 1], [0, 0, 0, 1, 0]] #jak cos puste to uzupelnic...
d3c945f4ff3f03c5da6c64830b30c3284acc4dd1
chavp/MyPython
/ThinkPython/fruitfull_function.py
466
3.875
4
import math def area(radies): return 2 * math.pi * radies def factorial (n): if not isinstance(n, int): print('Factorial is only defined for integers.') return None elif n < 0: print('Factorial is not defined for negative integers.') return None elif n == 0: return 1 else: return n * factorial(n-1) ...
85365ea40f822190ef1853e996fe0e508e622dd7
dudu9999/Exercicio_Aula_01
/ExercicioPiramide.py
559
3.921875
4
# Autor: Eduardo Caetano ''' Faça um algoritmo para imprimir a imagem abaixo. # ### ##### ####### ######### ########### ############# ############### ################# ...
c764b453c3153fe46cb2cff7b246af70efae3dbf
henriquekfmaia/curso-python
/601_c_arquivo_r.py
468
3.984375
4
filename = "zen.txt" file_in = open(filename, "r") # O parâmetro "r" significa "read", indicando que o arquivo somente será lido ## O comando read() retorna todo o texto do arquivo text = file_in.read() # file_in = open(filename, "r") ## O comando readlines() retorna uma lista com cada linha do texto que está dentro do...
fd1fa0e12990bd0598b90d218c672b36ce694ee7
HduiOSClub/HduiOSClub
/projects/沈孙峰/Python/裴波纳契数列.py
172
3.90625
4
def F(n): if (n == 0 or n == 1) : return n else : return F(n-1)+F(n-2) n = int(input("请输入一个数")) for i in range(0,n) : print(F(i))
bc01f4688dd6baf7a7f7d76981c9f34f08a620b3
tbro28/intermediatepython
/python-interm-class files/EXAMPLES/testrandom.py
1,223
3.640625
4
#!/usr/bin/env python # Test three functions from the random module: import random import unittest class TestSequenceFunctions(unittest.TestCase): # <1> @classmethod def setUpClass(cls): # <2> print("Starting all tests") def setUp(self): # <3> self.seq = list(range(10)) print("...
25eb31986557393c5c87020b0c238b09e3ccad2f
Gabrielatb/Interview-Prep
/hackbright/word_break.py
2,480
3.71875
4
# Build a function that is given a phrase and a vocab set. # It should return a set of the possible legal phrases that can be made # from that vocabulary. # >>> vocab = {'i', 'a', 'ten', 'oodles', 'ford', 'inner', 'to', # ... 'night', 'ate', 'noodles', 'for', 'dinner', 'tonight'} # >>> sentences = parse('iateno...
fb98eae4bf16eb4c620f6e11b3bb0d60761acf7e
12315jack/j1st-python
/python-basic/game_code_files/game1.py
719
4.03125
4
#!/usr/bin/env python # -*- coding:utf-8 -*- import random print('---------------------happy study python------------------') guess = random.randint(1, 10) while guess != 8: temp = input("猜猜用户输入的数字是多少?:") guess = int(temp) if guess == 8: print("哈哈,你真牛逼,这都能猜得到") print("不过猜中了也没用,哈哈哈,洗洗睡吧") ...
d2d48c6100c4b514b0c879eb2409390b62f1df96
sy0837/Assistant
/venv/AudioCommand/AudioCmd.py
3,453
3.53125
4
import speech_recognition as sr import webbrowser as wb def Youtube(): print("Do you want to search a video") with sr.Microphone() as source: audio = r2.listen(source) try: output = r2.recognize_google(audio) print("You said {}".format(output)) except: ...
58d0b347e000f5d327793229a775d29f673afd93
grigor-stoyanov/PythonAdvanced
/functions/min_max_sim.py
270
3.546875
4
line = list(map(int, input().split())) minimum_number = min(line) maximum_number = max(line) sum_of_all_numbers = sum(line) print(f"The minimum number is {minimum_number}") print(f"The maximum number is {maximum_number}") print(f"The sum number is {sum_of_all_numbers}")
616df6d2012fd745ef7adfd11c8af4fb77209aba
jagandecapri/XAI4ESN
/OldCode/GenerateVideoDataset.py
6,150
3.5625
4
''' This code generates a simplified video dataset for action recognition video Each video will be 60 frames of 28x28 grayscale with representation of 10 basic movements. - Bouncing - 0 - Vertical Upward - 1 - Vertical Downward - 2 - Horizontal Rightward - 3 - Horizon...
7c9c7416756db65e091e1f2758f3f452f6863b30
FedeMatt/Algorithms-for-bioinformatics
/problems_week6/Problem_31.py
271
3.546875
4
def SuffixArray(Text): l = [(Text[j:],j) for j in range(len(Text))[::-1]] new_l = [index[1] for index in sorted(l)] for number in new_l: if number == new_l[-1]: print(number, end = "") else: print(number, end=", ")
abd47c8c1474d3ca264ebf50adff30cb61c70838
Vesihiisi/WLE_import
/importer/WikidataItem.py
9,081
3.671875
4
# -*- coding: utf-8 -*- """ An object that represent a Wikidata item. This is a basic object used to construct a Wikidata item. It contains the basic functions to create statements, qualifiers and sources, as well as labels and descriptions with specified languages. The purpose of it is to serve as a base for a data-...
55a725253cbe65c9bf386b43b052007cce786791
luvhalvorson/Leetcode-Python-Solutions
/problems/remove_palindromic_subsequences/solution.py
455
3.578125
4
class Solution: def ispalindrome(self, s): #if len(set(s)) == 1: # return True for i in range(len(s)//2): if s[i] == s[-(i+1)]: continue else: return False return True def removePalindromeSub(self, s: str) -> int...
1e500274af2ddc2d34173b4557747ce00d06f24a
jeong123456789/MyPython
/Ch01/Ex08.py
154
3.5
4
import turtle t = turtle.Turtle() t.shape("turtle"); t.goto(100) t.forward(100) t.up t.forward(100) t.down t.goto(200) t.forward(100) t.down
5a1909fb09026e9c42bd16dd1255223b973030ba
Fincap/dicomfuse
/dicomfuse/transform.py
3,157
3.515625
4
from typing import List, Tuple import numpy as np def __validate_points(fixed_points: List[Tuple[float, ...]], moving_points: List[Tuple[float, ...]]): """ Validates that the two list of points given are of equal length and dimensionality (i.e. they correspond). """ # Check neither list is empty: if len(mo...
276b21c33dee10074484a0fcf85860deb7e9c857
THEKINGSTAR/udacity_data_analysis_pro-nano-dgree
/2. Introduction to Python/Lesson 5 Functions/readable_timedelta.py
1,768
4.21875
4
""" Quiz: readable_timedelta Write a function named readable_timedelta. The function should take one argument, an integer days, and return a string that says how many weeks and days that is. For example, calling the function and printing the result like this: print(readable_timedelta(10)) #should output the followi...
3d9ad81d3a63522a848be02e0fceaf721894021d
TrentBrunson/Neural_Networks
/working/RandomForest_DeepLearning.py
3,501
3.515625
4
#%% """ Build a classifier that can predict if a loan will be provided. Random forest models will only handle tabular data Deep learning will handle images, NLP, etc. """ #%% # Import dependencies from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler from sklearn.ensemb...
b70d2733a400dac2179a4c4ff6ad179448048d59
thijsBoet/small-python-projects
/create-random-password.py
305
3.578125
4
import random import string def createRandomPassword(amountOfCharacters): chars = list(string.ascii_letters + string.digits) password = '' for letter in range(amountOfCharacters): password += chars[random.randrange(0, len(chars))] return password print(createRandomPassword(32))
813039c6417ed384b6c346a1d30a2683af9d1f28
bunnybryna/Coursera_MIT_Intro_To_CS
/Code/wk3ps3_hangman.py
5,580
4.25
4
# 6.00 Problem Set 3 # # Hangman game # # ----------------------------------- # Helper code # You don't need to understand this helper code, # but you will have to know how to use the functions # (so be sure to read the docstrings!) import random import string WORDLIST_FILENAME = "words.txt" def loadWords(): "...
a89809fc93c49bd1776f02482003981fb229b24d
homawccc/class-example
/tk/newfolder_git/lists.py
238
3.890625
4
fruit = ["apple", "blueberries", "cranberries", "cranberries"] print(set(fruit)) veges = ["onion", "tomato", "kale"] print(set(veges)) newlist = fruit.extend(veges) length = len(fruit) print(fruit[0:length]) for f in fruit: print(f)
d2f1cea3fe908ec8a9d42138d7497f0987d5138f
xaca/fundamentos_python
/reto1.py
290
3.890625
4
usuario = input("Ingrese usuario ") # print(type(usuario)) # usuario = int(usuario) # print(type(usuario)) if usuario == "51619": clave = input("Ingresar clave ") if clave == "91615": print("Bienvenido usuario") else: print("Error") else: print("Error")
3e40352eba2ce73d106a7dee3517f41d4f60052b
automoto/python-code-golf
/graph/detect-a-cycle-medium-bad-attempt.py
1,072
4.0625
4
""" You are given an array of integers. Each integer represents a jump of its value in the array. For instance, the integer 2 represents a jump of 2 indices forward in the array; the integer -3 represents a jump of 3 indices backward in the array. If a jump spills past the array's bounds, it wraps over to the other si...
faf82ccb7295ad495eb36037e21233f4781c5b72
jzhangfob/jzhangfob.csfiles
/Intervals.py
1,967
4.21875
4
# File: Intervals.py # Description: Create a program that will output merged intervals so that there are no longer any overlapping intervals # Student Name: Jonathan Zhang # Student UT EID: jz5246 # Course Name: CS 303E # Unique Number: 50860 # Date Created: 4/19/2016 # Date Last Modifie...
efc8214779d0511a6565cc3b9306415132e2f2cc
Alexsan3005/Learn-Python
/Calk.py
809
4.1875
4
x,oper,y=float(input("Введите первое число ")),input("Введите операцию "),float(input("Введите второе число ")) if oper == "+": print(x+y) elif oper == "-": print(x-y) elif oper == "*": print(x*y) elif oper == "pow": print(x**y) elif oper == "/" and y == 0: print("Деление на 0!") y=float(input...
1985004962625ad160ab0ed10b949f4108e26fb4
zhaolixiang/python_cookbook
/7-1.py
421
3.9375
4
prices={ 'ACME':45.23, 'AAPL':612.78, 'IBM':205.55, 'HPQ':37.20, 'FB':10.75 } #找出价格最低放入股票 min_price=min(zip(prices.values(),prices.keys())) print(min_price) #找出价格最高放入股票 max_price=max(zip(prices.values(),prices.keys())) print(max_price) #同样,要对数据排序只要使用zip()再配合sorted() prices_sorted=sorted(zip(prices.values(),prices....
9c081aff52a3657796626aa1c918d7e51f0b0003
functorial/DataScienceFromScratch--Notes
/DecisionTrees.py
10,991
4.0625
4
# # Decision Trees # # A decision tree is a model that forms a tree-like structure # like the game 'Twenty Questions' # Pros: # (*) Can handle data of various types, e.g. numeric and categorical # (*) Easy to understand # (*) Easy to interpret # # Cons: # (*) Computationally very hard to find an optimal de...
1ea45e4f7a3db371b1ee4da03618b86aa30d2330
Lumpsum/heuristieken
/assets/solver.py
8,519
3.53125
4
import Queue class Solver(object): def __init__(self, grid, car_list): self.grid = grid self.car_list = car_list def a_star(self, grid, car_list): # Initialize variables queue, pre_grid = init_var_queue(grid, car_list, True) # Main loop while queue: # Take first grid from queue get_grid, grid...
b52b170c64b22041c7f938a8705a757e12f0d318
JMW0503/CSCI_4
/conditionals.py
637
4.125
4
import sys def main(): myInput = int(input("Enter a number, please. ")) myVariable = 4 #myVariable == 4 if (myVariable < 10 and myVariable > -10): print("number between -10 and 10") #same thing^ if (myVariable < 10): if (myVariable > -10): print("...
294b259296e7c76916e75bba77bd89a7b4531b4a
luanlelis12/Avaliacao1-Luan-Alves
/Avalicao1-Luan Alves/Questão07.py
724
4.125
4
salario = float(input("Insira o salário do colaborador:")) if salario <= 280: perAumento = 0.20 aumento = salario*perAumento nSalario = salario+aumento elif salario > 280 and salario < 700: perAumento = 0.15 aumento = salario*perAumento nSalario = salario+aumento elif salario > 700 an...
39b34f94ccbbb99c30b13b4bc0dd3bcbfce9eeaf
Alex19-91/Python
/Lesson_2/2.2.py
271
3.765625
4
my_list = input ("Введите значения элементов списка через пробел:") my_list = my_list.split() i = 1 a = my_list[i] while i< len(my_list): a= my_list[i-1] my_list[i-1] = my_list[i] my_list[i] = a i+=2 print (my_list)
f3d3fc9ee9c633aa7d012f1fa91ba259b43cacd6
huhudaya/leetcode-
/程序员面试金典/面试题 16.19. 水域大小.py
1,555
3.578125
4
''' 你有一个用于表示一片土地的整数矩阵land,该矩阵中每个点的值代表对应地点的海拔高度。若值为0则表示水域。由垂直、水平或对角连接的水域为池塘。池塘的大小是指相连接的水域的个数。编写一个方法来计算矩阵中所有池塘的大小,返回值需要从小到大排序。 示例: 输入: [ [0,2,1,0], [0,1,0,1], [1,1,0,1], [0,1,0,1] ] 输出: [1,2,4] 提示: 0 < len(land) <= 1000 0 < len(land[i]) <= 1000 ''' from typing import List # DFS class Solution: def pondSi...
49cfefbfe97f7a593023e3a215ab2b251836af3c
makozi/Sal-s-Shipping
/script.py
1,218
3.796875
4
# Premium Ground Shipping Flat charge: $125.00 cost_premium_ground= 125.00 def cost_ground_shipping(weight): if weight <=2: price_per_pound=1.50 elif weight <=6: price_per_pound=3.00 elif weight <=10: price_per_pound=4.00 else: price_per_pound= 4.75 return 20 + (price_per_pound * weight) # T...
07109e0211e7c00b1f20ecb9404bd4390f92a051
yutoo89/python_programing
/basic_grammar/list_copy.py
519
3.765625
4
# 参照渡し i = [1, 2, 3, 4, 5] j = i j[0] = 100 print('i =', i) print('j =', j) # i = [100, 2, 3, 4, 5] # j = [100, 2, 3, 4, 5] print('i.id =', id(i)) print('j.id =', id(j)) # 同じIDが出力される # i.id = 140443418909888 # j.id = 140443418909888 # 値渡し x = [1, 2, 3, 4, 5] y = x.copy() y[0] = 100 print('x =', x) print('y =', y) # x ...
79d246215be7494004a6a36b29a1ad933124e5ad
betty29/code-1
/recipes/Python/438810_First_last_item_access_predicates_increase/recipe-438810.py
1,055
4.03125
4
def first(seq, pred=None): """Return the first item in seq for which the predicate is true. If the predicate is None, return the first item regardless of value. If no items satisfy the predicate, return None. """ if pred is None: pred = lambda x: True for item in seq: if pr...
556ce9fc798886174ea4bb8fded3abe0b175e958
vladkudiurov89/Test_book
/function.py
496
3.984375
4
# x = math.sqrt(x + 3) - x + 1 # f(0); f(1); f(sqrt(2)); f(sqrt(2)-1 import math def f(x): return math.sqrt(x + 3) - x + 1 # # List of values to plug in for x in [0,1,math.sqrt(2), math.sqrt(2)-1]: print("f({:.3f}) = {:.3}f".format(x, f(x))) # y = math.sqrt(y + 1) - y + 5 # fn(5); fn(sqrt(7)); fn(0); fn...
a80dc4288cbb6c6686fd86b7540179fd5ec93be0
crobird/aoc2020
/day5/part1.py
1,959
3.5625
4
#!/usr/bin/env python """ Advent of Code 2020 """ import os import re import math import collections from enum import Enum from dataclasses import dataclass me = os.path.basename(__file__) DEFAULT_INPUT_FILE = "input/" + me.replace(".py", ".txt") LOW_HIGH_MAP = dict( F = 0, L = 0, B = 1, R = 1 ) c...
ab8c05899374825ca7b207f741b3a2c7da3153fb
destinyadams/calculator
/functions.py
657
4
4
def addition(num1,num2,num3,num4): result = num1 + num2 + num3 + num4 print ("{0} + {1} = {2}".format(num1,num2,num3,num4,result)) def subtraction(num1,num2,num3,num4): result = num1 - num2 - num3 - num4 print ("{0} - {1} = {2}".format(num1,num2,num3,num4,result)) def multiplication(nu...
f2446bb1bf79ca45becd4cec523b69f51a246a65
NirmalVatsyayan/python-revision
/language_programs/43_super.py
662
3.9375
4
''' question asked by linga ''' class Student(object): c = "1111" def __init__(self): self.name = "linga" self.roll_number = "1" class Programmer(Student): '''this is a programmer class''' def __init__(self): self.language = "python" super(Programmer, self).__init__(...
201780a280471160c78a71299e3a236d748b433d
wandererzzx/GloVe
/CPU_co_occur.py
3,169
3.515625
4
import numpy as np import os import csv import time # read csv file and return a list with each row in the csv file as an element def read_csv(csv_path,delimiter=' '): ''' csv_path: preprocessed csv file path ''' with open(csv_path) as csvfile: reader = csv.reader(csvfile,delimiter=delimiter) data = list(reader...
bf7c6b06e7d510bcbdb674a051efb608b49439ac
chenzhixun/Learning-Python3
/002-Control Structures/01_if_statements.py
471
4.25
4
if 10 > 5: print("10 greater than 5") print("Program ended") spam = 7 if spam > 5: print("five") if spam > 8: print("eight") num = 12 if num > 5: print("Bigger than 5") if num <= 47: print("Between 5 and 47") x = 4 if x == 5: print("Yes") else: print("No") num = 7 if num == 5: ...
db1863f4e73a74bcd132111792109c1e6ce95cc6
Seonaid/MyExercismCode
/python/isbn-verifier/isbn_verifier.py
660
3.6875
4
def filterNumbers(character): return character.isdigit() def makeNumbers(character): if character == 'X': return 10 else: return int(character) def is_valid(isbn): # check length and format raw_isbn = list(filter(filterNumbers, isbn[0:-1])) if (len(raw_isbn) != 9): ret...
32b559f9d19db243b78afa1267436ad893b4a205
yvlee/Univeristy-Project
/FIT1008-Algorithms and Data structure/Prac2/Task6_AssPrac.py
5,911
3.9375
4
from Task4_AssPrac import ArrayBasedList class TextEditor: def __init__(self): self.newArray = ArrayBasedList(10) def insertNum(self,num, item): ''' This function inserts a new item at the position before the index selected complexity: bests and worst case O(1) :param ...
29245d44544f01199e03edabd5e54aae6e513643
namhee33/selection_sort
/timed_selection_sort2.py
1,042
3.640625
4
import random import datetime x=[] def create_list(): for i in range(0,100): random_num = random.randint(0,10000) x.append(random_num) def print_pretty(): for i in range(0,10): for j in range(0,10): print '{0:5d}'.format(x[j+i*10]), print def selection_sort(): print 'half size: ' + str(len(x)//2) for ...
bdd6e5c93acd57ee7928702f750e4e4ad9ad6ded
Lincoln12w/OJs
/PAT/Basic Level/1013.py
382
3.71875
4
def isPrime(num): for i in range(2, int(num ** 0.5) + 1): if num % i == 0: return False return True edge = raw_input().split() beg = int(edge[0]) end = int(edge[1]) if beg <= 2: print 2, n = 3 primecnt = 1 while primecnt < end: if isPrime(n): primecnt += 1 if primecnt >= beg: if (primecnt - beg + 1) ...
e84c1ab8d381c53061f6934d4a1d6b57606b5310
ZakBibi/PracticePython
/CodingPractice/OOPPractice/tests/test_MaxSizeList.py
753
3.703125
4
import unittest from CodingPractice.OOPPractice.assignments.MaxSizeList import MaxSizeList class TestMaxListClass(unittest.TestCase): def test_list_three_elements(self): a = MaxSizeList(3) a.push('Hey') a.push('hi') a.push('you') a.push('guys') self.assertEqual(['h...
2eec7b387b09eef6060ed005a89124ed26785427
924070845/TanzhouPythonVipSecondClass
/数据库01/datetime标准库.py
691
3.765625
4
import datetime # 必须自然规范,不然报错 # 指定时间 time = datetime.time(20, 30, 59) print(time) # 日期 date = datetime.date(2018, 9, 7) print(date) # 年月日不能少,时分秒可以少 date_time = datetime.datetime(2018, 9, 6, 20, 30 ,59) print(date_time) # 获取当前时间 now = date_time.now() print(now) # 将指定时间对象转换为时间戳 time_stamp = date_...
6992e8064e8031e1b0023071471f937152b69263
Dakarai/war-card-game
/main.py
3,338
3.53125
4
import random suits = ('Clubs', 'Diamonds', 'Hearts', 'Spades') ranks = ('2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A') values = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'T': 10, 'J': 11, 'Q': 12, 'K': 13, 'A': 14} war_cards_count = 3 class Card: def __init__(self, suit...
258a0abde9684ef44adb9c2ad4423f01b9037bb4
RomanPutsilouski/M-PT1-37-21
/Tasks/Lappo_Tasks/Class_Task8/phone_book.py
336
3.765625
4
book = {} def get_book(): def AddPhone(d): fn=input("Введите имя:") ln=input("Введите фамилия:") ph=input("Введите телефон:") if d.get((fn,ln)): d[(fn,ln)].append(ph) else: d[(fn,ln)]=[ph] def DeletePhone(dict): del dict["A1"] #def FindPhone:
9c7e0f3f122882fdb3da7818b01d6a18b2db2fae
Toubat/Stanford-Algorithm
/Assignment2.py
1,268
3.65625
4
# assignment 2 def countSplitInv(arr_left, arr_right, n): # arrA is a sorted array arrA, inv = [], 0 i, j = 0, 0 while i < len(arr_left) and j < len(arr_right): if arr_left[i] <= arr_right[j]: arrA.append(arr_left[i]) i += 1 else: arrA.append(arr_rig...
6bb8dd2d88ccc6e2d5bb1bf9d0d19c023a24efb6
kenjimouriml/kyopro
/kenchon/ch03/test_get_min_value.py
648
3.71875
4
import unittest from main import get_min_value class SearchTest(unittest.TestCase): def test_get_min_value_ok(self): num_list = [1, 2.8, 3, 4, 5, 6, 0.2] returns = get_min_value(num_list) self.assertEqual(returns, (0.2, 6)) def test_get_min_value_typeerror(self...
356b5f89360d1de462315688ff1a953e91b84adc
pmrowla/aoc2018
/day1.py
928
3.53125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """Advent of Code 2018 day 1 module.""" from __future__ import division, print_function from itertools import cycle def part_two(digits): seen = set([0]) current = 0 for x in cycle(digits): current += x if current in seen: return c...
d80538cff3b01893a142cd0112aa336ecb69a216
LucasWong02/Py_Uni_Prjcts
/Hackerrank_1.py
207
3.875
4
n = int(input("Pon un numero: ")) if n == (2,4): print("Not weird") elif (n % 2) == 0 and (5 < n < 21): print("Weird") elif (n % 2) == 0 and (n > 19): print("Not Weird") else: print("Weird")
e1b9c7c64322be53043374686fbc395a301b0a18
kuzovkov/python_labs
/4/task4.2.py
406
4
4
# def is_simple(n): # for x in range(2,n): if n%x ==0: return False return True def simple(n): n=int(n) ls=range(1,n+1) return filter(lambda x:is_simple(x),ls) n=input(' :') print " ",n,": ",simple(n)
2a58b5f4360e963cf11e59a980b3dc93599cb247
arthur11678/Desafio-1-STI-UFF
/Main.py
1,080
3.6875
4
from Consulta import Consulta #Importa a classe Consulta da biblioteca Consulta from Cadastro import Cadastro #Importa a classe Cadastro da biblioteca Cadastro matricula_aluno = input("\nDigite sua matricula\n") #Pergunta ao usuário sua mat...
7d43bcdcc6890c363d9267554509d8b43e6b53be
crainte/ap-assignment
/addtime.py
2,085
4.0625
4
#!/usr/bin/env python -B import re def add_time(current_time, additional_time): # current_time can be "[H]H:MM {AM|PM}" # additional_time is number of minutes to add to the time of day # return should be same format if not isinstance(additional_time, int): raise ValueError("Expected Integer a...
15535557d5d3af33dffbf6f75ad2bde9377530d9
r50206v/Leetcode-Practice
/2022/*Medium-75-SortColors.py
1,251
3.734375
4
''' dual-pivot partitioning time: O(N) space: O(1) ''' class Solution: def sortColors(self, nums: List[int]) -> None: """ Dutch National Flag problem solution. """ # for all idx < p0 : nums[idx < p0] = 0 # curr is an index of element under consideration p0 = curr = ...
2fe267c86c7ce2bf90f554ed58e17cd5550871a0
hermanschaaf/advent-of-code-2017
/day1.py
408
3.6875
4
#!/bin/python from __future__ import print_function, unicode_literals from collections import defaultdict def special_sum(i): n = i while n > 0: f = n % 10 n //= 10 s = 0 n = f while i > 0: c = i % 10 i //= 10 if c == n: s += c n = c ...
a451fba49167c5eeab3a6d9b7432b9a47b3d53fa
Abdulkadir78/Python-basics
/q13.py
439
4.09375
4
''' Write a program that accepts a sentence and calculate the number of letters and digits. Suppose the following input is supplied to the program: hello world! 123 Then, the output should be: LETTERS 10 DIGITS 3 ''' sentence = input('Enter a string: ') letters = 0 digits = 0 for i in sentence: if i.isalpha():...
d380d12c851a225d2b4825a0ae47b33eac21ac66
pkmm91/competitive-programming-solutions
/Hackerearth/comapnies_based_questions/p17.py
417
3.671875
4
from math import factorial def fib(n): return factorial(n) for i in range(input()): num = int(raw_input()) if num in [1,2,3]: print "0000" + str(fib(num)) elif num in [4]: print "000" + str(fib(num)) elif num in [5,6]: print "00" + str(fib(num)) elif num in [7]: p...
cf67608998af9f7b7d9994a2267ba48975b8cc82
saad-abu-sami/Learn-Python-Programming
/basic learning py/function_social media.py
469
3.796875
4
class User: name = '' email = '' password = '' login = False def login(self): email = input('enter email') password = input('enter password') if email == self.email and password == self.password: login = True print('login successful!') ...
1a4a7a1520a55d15321d55425d575f7aefe962e5
seo1511kr/TIL
/pycharm/python/hw/hw26.py
4,730
3.53125
4
# 1. 유클리드 호제법으로 구현(뺄셈, 나눗셈) # 나눗셈 # num1,num2=list(map(int,input().split())) # import copy # def getc_mm(small,big): # if small>big:small,big=big,small # while big%small!=0: # res = big % small # big=copy.copy(small) # small=res # return small # print(getc_mm(num1,num2)) # # # # nu...
a12af68cf63e8e5ede06cf0ec9c71c157ea931ea
tutorialcreation/mlbib
/len_strings.py
723
4.03125
4
# Author: Martin Luther Bironga # Date: 27/1/2021 # problem statement """ Make a program that filters a list of strings and returns a list with only your friends name in it. If a name has exactly 4 letters in it, you can be sure that it has to be a friend of yours! Otherwise, you can be sure he's not... Ex: Input = ...
a854da4cc9f404a550c08303dab0e679bd93621f
evanqianyue/Python
/day12/property/property.py
868
4.125
4
# !/usr/bin/env python # -*- coding:utf-8 -*- """ @ Author :Evan @ Date :2018/10/31 18:37 @ Version : 1.0 @ Description: @ Modified By: """ class Person(object): def __init__(self, age): # 属性直接对外暴露 # self.age = age # 限制访问 self.__age = age ''' def getAge(...
a439375fb90a5dc295855cc9ee05de0689cb8be1
ramyasutraye/python--programming
/beginner level 1/set6-52.py
292
3.890625
4
s=raw_input() if (s=="1"): print "One" elif (s=="2"): print "Two" elif (s=="3"): print "Three" elif (s=="4"): print "Four" elif (s=="5"): print "Five" elif (s=="6"): print "Six" elif (s=="7"): print "Seven" elif (s=="8"): print "Eight" elif (s=="9"): print "Nine" else: print "Ten"
7161564f3595d4b9f885dbf3c47e2bbb16e7b368
snehashish090/Book_archive_CLI
/app.py
4,734
4.1875
4
# Made by Snehashish Laskar # Made on 15-03-2021 # Developer Contact: snehashish.laskar@gmail.com # This is a simple book archive manager that stores info about books import json # Opening the data.json file to extract data with open("data.json", "r") as file: data = json.load(file) read = [] readin...
b1df2c7e972242de2af45266600d9c7a4d928689
frances-zhao/ICS207
/homework/lesson 18/lesson18_6.py
1,792
4.28125
4
# ***************************************************** # # Program Author: Frances Zhao # Completion Date: May 20 2021 # Program Name: lesson18_6.py # Description: Write a function that models linear equations. The function should take three numbers as input m, x and b # Then it should use the relationship y = mx + b ...
7fe4c3c481a89fb9fdef226823ce1d293eb84f5c
fieldsfarmer/coding_problems
/decorator1.py
1,599
4.0625
4
import functools ### a decorator to count how many times a function is called def counter(func): @functools.wraps(func) def wrapper(*args,**kwargs): wrapper.count += 1 print('%s is called %d times' %(func.__name__, wrapper.count)) return func(*args, **kwargs) wrapper.count = 0 return wrapper # @counter def ...
7299979b219396e5e1318a8210a71728c2a6233c
sallyklpoon/data-structures-and-algorithms
/linked_lists/sll_node.py
1,629
4.09375
4
""" Implementation of a single linked list node. """ class SllNode: def __init__(self, data): """ Instantiate a Node class. Done in constant time. :param data: any data type :postcondition: instantiate a Node object """ self.data = data self.next ...