blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
ba934740e3a009ec713f7c3630b71ec56d9bb699
killo21/poker-starting-hand
/cards.py
2,285
4.125
4
# -*- coding: utf-8 -*- """ Created on Wed Nov 25 17:30:27 2020 @author: dshlyapnikov """ import random class Card: def __init__(self, suit, val): """Create card of suit suit [str] and value val [int] 1-13 1 - Ace, 2 - 2, 3 - 3,..., 11 - Jack, 12 - Queen, 13 - King suit can be "clu...
true
141b6d72a3890b96f51838d1b4806763f0c60684
sivaneshl/python_ps
/tuple.py
801
4.25
4
t = ('Norway', 4.953, 4) # similar to list, but use ( ) print(t[1]) # access the elements of a tuple using [] print(len(t)) # length of a tuple for item in t: # items in a tuple can be accessed using a for print(item) print(t + (747, 'Bench')) # can be concatenated using + operator print(t) # imm...
true
a29a778e801e3ca3e9a5904fafca8310de0b0b43
sivaneshl/python_ps
/range.py
541
4.28125
4
# range is a collection # arithmetic progression of integers print(range(5)) # supply the stop value for i in range(5): print(i) range(5, 10) # starting value 5; stop value 10 print(list(range(5, 10))) # wrapping this call to the list print(list(range(0, 10, 2))) # 2 is the step argument # enumerate -...
true
149e32d2ea991a06c3d6a7dd1c18c4cc85c3d378
CcccFz/practice
/python/design_pattern/bigtalk/Behavioral/11_visitor.py
1,326
4.15625
4
# -*- coding: utf-8 -*- # 模式特点:表示一个作用于某对象结构中的各元素的操作。它使你可以在不改变各元素的类的前提下定义作用于这些元素的新操作。 # 程序实例:对于男人和女人(接受访问者的元素,ObjectStructure用于穷举这些元素),不同的遭遇(具体的访问者)引发两种对象的不同行为。 class Action(object): def get_man_conclusion(self): pass def get_woman_conclusion(self): pass class Success(Action): def get_m...
false
9f467500632ad90051263cb2282edacfe1258b1b
git-ysz/python
/day5-字符串/05-字符串的查找方法.py
934
4.46875
4
""" 1、字符串序列.find(子串, 查找开始位置下标, 查找结束位置下标) 返回子串出现的初始下标 1.1、rfind()函数查找方向和find()相反 2、字符串序列.index(子串, 查找开始位置下标, 查找结束位置下标) 返回子串出现的初始下标 2.1、rindex()函数查找方向和find()相反 3、字符串序列.count(子串, 查找开始位置下标, 查找结束位置下标) 返回子串出现的次数 ...... """ myStr = 'hello world and itcast and itheima and Python' # find() 函数 print(myStr...
false
5c8e53bc40566dfe596ecf26e8425f65dae57a6a
git-ysz/python
/day15-继承/04-子类调用父类的同名方法和属性.py
1,549
4.3125
4
""" 故事演变: 很多顾客都希望既能够吃到古法又能吃到学校技术的煎饼果子 """ # 师傅类 class Master(object): def __init__(self): self.kongfu = '古法煎饼果子配方' def make_cake(self): print(f'运用{self.kongfu}制作煎饼果子 -- 师父') # 学校类 class School(object): def __init__(self): self.kongfu = '学校煎饼果子配方' def make_cake(self): ...
false
eadb9454aeedd0dff94404ac92f9e6e43f4089c8
git-ysz/python
/day7-字典/04-字典的循环遍历.py
335
4.25
4
dict1 = { 'name': 'Tom', 'age': 20, 'gender': '男' } # 遍历keys for key in dict1.keys(): print(key) # 遍历values for val in dict1.values(): print(val) # 遍历键值对 for item in dict1.items(): print(item, item[0], item[1]) # 键值对拆包 for key, value in dict1.items(): print(f'{key}:{value}')
false
b5bdd6a7b80e23823c3a97def9717da822c0b3b7
git-ysz/python
/day18-模块包/00-导入模块的方法.py
565
4.1875
4
""" 模块: Python模块(module),是一个python文件,以.py结尾,包含了python对象定义和python语句。 模块能定义函数,类和变量,模块里面也能包含可执行的代码 """ import math # 导入指定模块 # from math import sqrt # 导入指定模块内的指定功能 from math import * # 导入指定模块内的所有功能 print(math.sqrt(9)) # 开平方 -- 3.0 print(sqrt(9)) # 开平方 -- 3.0 导入指定模块内的所有功能 print(pi, e) # 3.141592653589793... ...
false
511f5e71a988213812fe04a44b1d08bc2fb10ecf
git-ysz/python
/day17-异常处理/01-捕获异常.py
1,261
4.25
4
""" 语法: try: 可能发生错误的代码 except 异常类型: 如果捕获到该异常类型执行的代码 注意: 1、如果尝试执行的代码的异常类型和要捕获的类型不一致,则无法捕获异常 2、一般try下发只放一行尝试执行的代码 """ # 捕获指定异常类型 try: # 找不到num变量 print(num) except NameError: print('NameError:', NameError.__dict__) try: print(1 / 0) except ZeroDivisionError: print('0不能做被除数') # 捕获多个指...
false
9605013db14a55234a8f79a0f50833ce6f9af675
giselemanuel/programa-Ifood-backend
/modulo-1/exercicios/animal.py
1,227
4.34375
4
""" Programa VamoAI: Aluna: Gisele Rodrigues Manuel Desafio : Animal Descrição do Exercício 3: Criar um programa que: 1. Pergunte ao usuário qual aninal ele gostaria de ser e armazene em uma variável. 2. Exiba na tela o texto: "Num primeiro momento , eu gostaria de ser o <animal> 3. Pergunte ao usuário qual animal ele ...
false
fdc4109862d6acdaaf3b28b259407310172e9973
giselemanuel/programa-Ifood-backend
/qualified/sem7_qualified_3.py
2,466
4.21875
4
""" Descrição Utilizando as mesmas 4 funções da atividade Pilha - Funções Básicas: cria_pilha() tamanho(pilha) adiciona(pilha, valor) remove(pilha): Implemente a função insere_par_remove_impar(lista) que recebe uma lista de números inteiros como parâmetro e retorna uma pilha de acordo com a seguinte regra: para cada e...
false
3b831b55e3fc2796d52d1a3298b690cfbe41fdf7
giselemanuel/programa-Ifood-backend
/qualified/sem5_qualified_2.py
1,078
4.4375
4
# função para somar as duas listas """ Descrição Eu sou novo na programação e gostaria da sua ajuda para somar 2 arrays. Na verdade, eu queria somar todos os elementos desses arrays. P.S. Cada array tem somente numeros inteiros e a saída da função é um numero também. Crie uma função chamada array_plus_array que receb...
false
e07cd5a1719c796c980b06b003c83df9d57457f3
giselemanuel/programa-Ifood-backend
/qualified/sem7_qualified_1.py
1,757
4.65625
5
""" Descrição Crie quatro funções básicas para simular uma Pilha: cria_pilha(): Retorna uma pilha vazia. tamanho(pilha): Recebe uma pilha como parâmetro e retorna o seu tamanho. adiciona(pilha, valor): Recebe uma pilha e um valor como parâmetro, adiciona esse valor na pilha e a retorna. remove(pilha): Recebe uma pilh...
false
003112e87a05bb6da91942b2c5b3db98d082193a
joshua-hampton/my-isc-work
/python_work/functions.py
370
4.1875
4
#!/usr/bin/python def double_it(number): return 2*number def calc_hypo(a,b): if (type(a)==float or type(a)==int) and (type(b)==float or type(b)==int): hypo=((a**2)+(b**2))**0.5 else: print 'Error, wrong value type' hypo=False return hypo if __name__ == '__main__': print double_it(3) print double_it(3....
true
a15f72482720e16f831f6e44bece611910eec4d5
Katakhan/TrabalhosPython2
/Aula 5/aula5.2.py
505
4.125
4
#2- Mercado tech... #Solicitar Nome do funcionario #solicitar idade #informar se o funcionario pode adquirir produtos alcoolicos #3- #cadastrar produtos mercado tech #solicitar nome do produto #Solicitar a categoria do produto(alcoolicos e não alcoolicos) #exibir o produto cadastrado nomef = input('informe o nome d...
false
34fb94928b4521a02ee32683fcc1369b36a03697
Katakhan/TrabalhosPython2
/Aula59/A59C1.py
1,478
4.3125
4
# ---- Rev Classe # ---- Métodos de Classe # ---- Método __init__ # ---- Variáveis de classe # ---- Variáveis privadas # ---- Metodos Getters e Setters class Calc: def __init__(self, numero1, numero2): # Variável de classe self.__n1 = numero1 self.__n2 = numero2 self.__resultado = 0...
false
bbadb83a9436c4fb543e3a703638449549af44e6
Katakhan/TrabalhosPython2
/Aula59/Classe.py
501
4.15625
4
#---- Métodos #---- Argumentos Ordenados #---- Argumentos Nomeados def soma(n1,n2): resultado = n1+n2 return resultado res = soma(10,20) print(res) def multiplicacao(n1,n2,n3): resultado = n1 * n2 * n3 return resultado res = multiplicacao(10,20,30) print(res) def subtracao(n1,n2,n3): resultad...
false
27989368586ffa54f5ac5a9599a95b0b3c726709
Raylend/PythonCourse
/hw_G1.py
681
4.15625
4
""" Написать декоратор, сохраняющий последний результат функции в .txt файл с названием функции в имени """ def logger(func): def wrapped(*args, **kwargs): # print(f'[LOG] Вызвана функция {func.__name__} c аргументами: {args}, {kwargs}') f_name = func.__name__ + '.txt' f = open(f_name, "w") ...
false
d2822cfa674d1c3701c46e6fd305bf665f26ace4
nkpydev/Algorithms
/Sorting Algorithms/Selection Sort/selection_sort.py
1,030
4.34375
4
#-------------------------------------------------------------------------# #! Python3 # Author : NK # Desc : Insertion Sort Implementation # Info : Find largest value and move it to the last position. #-------------------------------------------------------------------------...
true
9197d3d60ded6acd8d76c581de16cc68dc495b5a
ezhk/algo_and_structures_python
/Lesson_2/5.py
691
4.375
4
""" 5. Вывести на экран коды и символы таблицы ASCII, начиная с символа под номером 32 и заканчивая 127-м включительно. Вывод выполнить в табличной форме: по десять пар "код-символ" в каждой строке. """ def print_symbols(pairs_per_line=10): results_in_line = 0 for i in range(32, 127 + 1): print(f"{i}....
false
332dd6971f3b52129b320f93d189f02a688376fd
ezhk/algo_and_structures_python
/Lesson_3/7.py
1,384
4.34375
4
""" 7. В одномерном массиве целых чисел определить два наименьших элемента. Они могут быть как равны между собой (оба являться минимальными), так и различаться. """ def search_two_min(arr): absolute_min = second_min = None for el in arr: if absolute_min is None: absolute_min = el ...
false
076d47563c9a8852ea3ca389e3abca680676bb52
melvinkoopmans/high-performance-python
/fibonnaci.py
416
4.125
4
def fibonacci_list(num_items): numbers = [] a, b = 0, 1 while len(numbers) < num_items: numbers.append(a) a, b = b, a+b return numbers def fibonacci_gen(num_items): a, b = 0, 1 while num_items: yield a a, b = b, a+b num_items -= 1 if __name__ == '__ma...
false
4cb75a34e0f6806c8990bc06079272effbc2451c
patrickdeyoreo/holbertonschool-interview
/0x19-making_change/0-making_change.py
1,161
4.15625
4
#!/usr/bin/python3 """ Given a list of coin denominations, determine the fewest number of coins needed to make a given amount. """ def makeChange(coins, total): """ Determine the fewest number of coins needed to make a given amount. Arguments: coins: list of coin denominations total: total...
true
31d07fd3332e0b6ca050f4ee3df184451287d710
gauborg/code_snippets_python
/14_power_of_two.py
1,220
4.625
5
''' Description: The aim of this code is to identify if a given numer is a power of 2. The program requires user input. The method keeps bisecting the number by 2 until no further division by 2 is possible. ''' def check_power_of_two(a, val): # first check if a is odd or equal to zero or an integer ...
true
f65d53c042bebae591090aebbf16b3b155e0eee2
gauborg/code_snippets_python
/7_random_num_generation.py
1,416
4.5
4
''' This is an example for showing different types of random number generation for quick reference. ''' # code snippet for different random options import os import random # generates a floating point number between 0 and 1 random1 = random.random() print(f"\nRandom floating value value between using random.random(...
true
2c17e2b6ed89bebf30bbf9a2f25bb8f0793c0019
jkamby/portfolio
/docs/trivia/modulesAndClients/realcalc.py
1,358
4.15625
4
import sys import stdio def add(x, y): """ Returns the addition of two floats """ return float(x) + float(y) def sub(x, y): """ Returns the subtraction of two floats """ return float(x) - float(y) def mul(x, y): """ Returns the multiplication of two floa...
true
a743debf018b5322b6a681783aa0a009fbfd3b61
karingram0s/karanproject-solutions
/fibonacci.py
722
4.34375
4
#####---- checks if input is numerical. loop will break when an integer is entered def checkInput(myinput) : while (myinput.isnumeric() == False) : print('Invalid input, must be a number greater than 0') myinput = input('Enter number: ') return int(myinput) #####---- main print('This will print the Fib...
true
35fb678edb2369ca09c40eecfb4b8856b5ded353
jlocamuz/Mi_repo
/clase12-08-20/main.py
711
4.15625
4
class Clase(): def __init__(self, atributo=0): # Que yo ponga atributo=0 significa que si yo no le doy valor # A ese atributo por defecto me pone 0 self.atributo = atributo def get_atributo(self): # setter and getter: darle un valor a un atributo y obtener # el valor del...
false
b97a94399afac9b9f793d680ffb01892f041ff25
arononeill/Python
/Variable_Practice/Dictionary_Methods.py
1,290
4.3125
4
import operator # Decalring a Dictionary Variable dictExample = { "student0" : "Bob", "student1" : "Lewis", "student2" : "Paddy", "student3" : "Steve", "student4" : "Pete" } print "\n\nDictionary method get() Returns the value of the searched key\n" find = dictExample.get("student0") print find print "\n\nDict...
true
e54903690eceffc1bd7b49faa2db0f79d111f974
TheManyHatsClub/EveBot
/src/helpers/fileHelpers.py
711
4.125
4
# Take a file and read it into an array splitting on a given delimiter def parse_file_as_array(file, delimiter=None): # Open the file and get all lines that are not comments or blank with open(file, 'r') as fileHandler: read_data = [(line) for line in fileHandler.readlines() if is_blank_or_comment(line...
true
97c80a0bc24deb72d908c283df28b314454bcfc5
KHilse/Python-Stacks-Queues
/Queue.py
2,139
4.15625
4
class Node: def __init__(self, data): self.data = data self.next = None class Queue: def __init__(self): self.head = None def isEmpty(self): """Returns True if Queue is empty, False otherwise""" if self.head: return False return True def enq...
true
485458ce7505e832f81aab7520d9fa16db630e89
kalstoykov/Python-Coding
/isPalindrome.py
1,094
4.375
4
import string def isPalindrome(aString): ''' aString: a string Returns True if aString is a Palindrome String strips punctuation Returns False otherwise. ''' alphabetStr = "abcdefghijklmnopqrstuvwxyz" newStr = "" # converting string to lower case and stripped of extra non alphabet c...
true
13776998dc9b97cf329928fa2a5632f4be87d37a
Crowiant/learn-homework-1
/2_if2.py
1,196
4.3125
4
""" Домашнее задание №1 Условный оператор: Сравнение строк * Написать функцию, которая принимает на вход две строки * Проверить, является ли то, что передано функции, строками. Если нет - вернуть 0 * Если строки одинаковые, вернуть 1 * Если строки разные и первая длиннее, вернуть 2 * Если строки разные и вторая с...
false
f3d2913606a2b0536ceb12a9b469762cd9d86fc3
giant-xf/python
/untitled/4.0-数据结构/4.02-栈和队列/4.2.2-队列的实现.py
945
4.4375
4
class Queue(object): #创建一个空的队列 def __init__(self): #存储列表的容器 self.__list = [] def enqueue(self,item): #往队列中添加一个item元素 self.__list.append(item) #头插入,头出来,时间复杂度 O(n) #self.__list.insert(0,item) def dequeue(self): #从队列尾部删除一个元素 #r...
false
1b0dbc67c509a73b2482d2424987e284c5dbd063
kevinliu2019/CP1404practicals
/prac_05/hex_colours.py
758
4.4375
4
CODE_TO_COlOUR = {"AliceBlue": "#f0f8ff", "AntiqueWhite": "#faebd7", "AntiqueWhite1": "#ffefdb", "AntiqueWhite2": "#eedfcc", "DodgerBlue3": "#1874cd", "gray": "#bebebe", "aquamarine1": "#7fffd4", "OldLace": "#fdf5e6", "aquamarine4": "#458b74", "azure1": "#...
false
69c90196bf5f5b97440c574eef6df4d6c70bf04c
Danielacvd/Py3
/Errores_y_excepciones/excepciones.py
2,764
4.1875
4
""" Errores y Excepciones en Python Excepciones Son bloques de codigo que nos permiten seguir con la ejecucion del codigo a pesar de que tengamos un error. Bloque Try-Except Para prevenir fallos/errores tenemos que poner el bloque propenso a errores en un bloque TRY, y luego encadenar un bloque except para tratar la s...
false
db1eedd2b2ea011786f6b26d58a1f72e5349fceb
mirarifhasan/PythonLearn
/function.py
440
4.15625
4
#Function # Printing the round value print(round(3.024)) print(round(-3.024)) print(min(1, 2, 3)) #If we call the function without parameter, it uses the default value def my_function(country = "Norway"): print("I am from " + country) my_function("Sweden") my_function("India") my_function() #Array passing in fu...
true
4235ddfb49c4281b0ecbb62fa93c9098ca025273
davisrao/ds-structures-practice
/06_single_letter_count.py
638
4.28125
4
def single_letter_count(word, letter): """How many times does letter appear in word (case-insensitively)? >>> single_letter_count('Hello World', 'h') 1 >>> single_letter_count('Hello World', 'z') 0 >>> single_letter_count("Hello World", 'l') 3 ...
true
99db5d93dd6673b1afa97701b1fb8d09294223c0
timseymore/py-scripts
/Scripts/set.py
485
4.125
4
# -*- coding: utf-8 -*- """ Sets numerical sets and operations on them Created on Tue May 19 20:08:17 2020 @author: Tim """ test_set = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} # returns a set of numbers in given range (inclusive) # that are divisible by either 2 or 3 def set_mod_2_3(size): temp = {} index = 0 f...
true
4bdf487e4600dfd927e4419f0c25391cfbfb721c
timseymore/py-scripts
/Scripts/counting.py
2,285
4.5
4
# -*- coding: utf-8 -*- """ Counting examples of counting and recursive counting used in cominatorics We will be implementing a graph consisting of nodes and then use recursive counting to find the number of possible paths from the start node to any given node in the graph. The number of possible paths to any give...
true
c75a1774b3d16f850f66a24a24ee1b206adbb9e9
bashmastr/CS101-Introduction-to-Computing-
/Assignments/05/a05.py
1,458
4.125
4
## IMPORTS GO HERE ## END OF IMPORTS #### YOUR CODE FOR is_prime() FUNCTION GOES HERE #### def is_prime(y): if y > 1: x = int(y) if x==y: if x == 1: return False if x == 0: return False if x == 2: return True ...
false
6832a42539daa56e2f4c04a1238236a2cfc31e98
mmuratardag/DS_SpA_all_weeks
/DS_SpA_W10_Recommender_System/03_19/TeachMat/flask-recommender/recommender.py
1,270
4.1875
4
#!/usr/bin/env python import random MOVIES = ["The Green Book", "Django", "Hors de prix"] # def get_recommendation(): # return random.choice(MOVIES) def get_recommendation(user_input: dict): m1 = user_input["movie1"] r1 = user_input["rating1"] m2 = user_input["movie2"] r2 = user_input["rating...
true
e47781a543e7ab3ccca376d773ebdcd13e6cc77b
yveslox/Genesisras
/practice-code-orange/programme-python/while-loop.py
245
4.125
4
#!/usr/bin/python3 #while loop num=1 while(num<=5): print ("num : ",num) num=num+1 print ("") # else statement with while loop num=1 while(num<=5): print("num : ",num) num=num+1 else : print("second loop finished.")
false
26fded563d3655f5f06e2cdf582d0cdc564ab9dc
yveslox/Genesisras
/practice-code-blue/programme-python/lists.py
672
4.34375
4
#!/usr/bin/python list=[1,2,3,4,5,6,7,8]; print("list[0] :",list[0]) print("list[1] :",list[1]) print("list[2:5] :",list[2:5]) #updating list list[3] = 44 print("list(after update):",list) #delete element del list[3] print("list(after delete) :",list) #length of list print("length of list : ",len(list)) #appendi...
true
7851912c02fd2481ace43d7727b3ceb42153a088
amtfbky/hfpy191008
/base/0005_input.py
2,249
4.125
4
# -*- coding:utf-8 -*- # import urllib # 关于互联网的类 # print "Enter your name: ", # 逗号用来把多个print语句合并到同一行上,且增加一个空格 # someone = raw_input() # raw_input的简便方法 # someone = raw_input("Enter your name: ") # print "Hi, " + someone + ", nice to meet you!" # temp_string = raw_input() # fahrenheit = float(temp_string) # 以上两句可简写 ...
false
cbfb4516032f507a384496265b2140ed2d9c5cdd
amtfbky/hfpy191008
/base/0004_data.py
651
4.1875
4
# -*- coding:utf-8 -*- print float(23) print int(23.0) a = 5.99 b = int(a) print a print b a = '3.9' b = float(a) print a print b a = '3.7' b = 3.7 print type(a) print type(b) # cel = 5.0 / 9 * (fahr - 32) # cel float(5) / 9 * (fahr - 32) # cel 5 / float(9) * (fahr - 32) # excise # int()将小数转换为整数,结果是下取整 # cel = fl...
false
9bac38cd3bc1014cc19216e4cbcda36f138dfef1
Ri8thik/Python-Practice-
/creat wedge using loop/loop.py
2,269
4.40625
4
import tkinter as tk from tkinter import ttk root=tk.Tk() # A) labels #here we create a labels using loop method # first we amke a list in which all the labels are present labels=["user name :-","user email :-","age:-","gender:-",'state:-',"city:-"] #start a for loop so that it print all the labels which are given in a...
true
fca8a93a245b027c0cfee51200e9e603c737f5df
rchu6120/python_workshops
/comparison_operators.py
234
4.21875
4
x = [1, 2, 3] y = list(x) # create a NEW list based on the value of x print(x, y) if x is y: print("equal value and identity") elif x == y: print("equal value but unqual identity") else: print("unequal")
true
1ef7c763b40ab15b9bb07313edc9be70f9efd5d6
rchu6120/python_workshops
/logic_hw.py
852
4.375
4
############# Ask the user for an integer ### If it is an even number, print "even" ### If it is an odd number, print "odd" ### If it is not an integer (e.g. character or decimal #), continue asking the user for an input ### THIS PROGRAM SHOULND'T CRASH UNDER THESE CIRCUMSTANCES: # The user enters an alphabet #...
true
5f5f657ef5fad9d08ad0a1657a97cbe83535cb09
HeyChriss/BYUI-Projects-Spring-2021
/Maclib.py
1,453
4.25
4
print ("Please enter the following: ") adjective = input("adjective: ") animal = input("animal: ") verb1 = input("verb: ") exclamation = input("exclamation: ") verb2 = input("verb : ") verb3 = input("verb: ") print () print ("Your story is: ") print () print (f"The other day, I was really in trouble. It all s...
true
7e46e20703c0a192343772c52686b4846904537d
UnimaidElectrical/PythonForBeginners
/Algorithms/Sorting_Algorithms/Quick_Sort.py
2,603
4.375
4
#Quick Sort Implementation ************************** def quicksort(arr): """ Input: Unsorted list of intergers Returns sorted list of integers using Quicksort Note: This is not an in-place implementation. The In-place implementation with follow shortly after. """ if len(arr) < 2: ret...
true
1ab91009e990c5f8858a019968d8a1616a9e4c09
UnimaidElectrical/PythonForBeginners
/Algorithms/Sorting_Algorithms/selection_sort.py
2,740
4.46875
4
# Selection Sort # Selection sort is also quite simple but frequently outperforms bubble sort. # With Selection sort, we divide our input list / array into two parts: the sublist # of items already sorted and the sublist of items remaining to be sorted that make up # the rest of the list. # We first find the smalles...
true
38baa3eb890530cac3a056140908e23015070428
UnimaidElectrical/PythonForBeginners
/Random_code_store/If_Else_Statement/If_Else_statement.py
2,375
4.375
4
"""This mimicks the children games where we are asked to choose our own adventure """ print("""You enter a dark room with two doors. Do you go through door #1 or door #2?""") door = input ("> ") if door == "1": print("There's a giant bear here eating a cheese cake.") print("What do you want to do?") prin...
true
0f509b10fd23df81cd306ea05a6ae07e6b9c13b3
UnimaidElectrical/PythonForBeginners
/Random_code_store/Lists/In_Operators.py
453
4.34375
4
#The In operator in python can be used to determine weather or not a string is a substring of another string. #what is the optcome of these code: nums=[10,9,8,7,6,5] nums[0]=nums[1]-5 if 4 in nums: print(nums[3]) else: print(nums[4]) #To check if an item is not in the list you can use the NOT operator #In th...
true
ff97e60837bf32c1dc1f65ef8afda4f658a7116b
lchristopher99/CSE-Python
/CSElab6/turtle lab.py
2,207
4.5625
5
#Name: Jason Hwang, Travis Taliancich, Logan Christopher, Rees Hogue Date Assigned: 10/19/2018 # #Course: CSE 1284 Section 14 Date Due: 10/20/2018 # #File name: Geometry # #Program Description: Make a geometric shape #This is the function for making the circle us...
true
5e447702f51cd3318fd5595a131da34c2bc498d5
endreujhelyi/endreujhelyi
/week-04/day-3/04.py
528
4.3125
4
# create a 300x300 canvas. # create a line drawing function that takes 2 parameters: # the x and y coordinates of the line's starting point # and draws a line from that point to the center of the canvas. # draw 3 lines with that function. from tkinter import * top = Tk() size = 300 canvas = Canvas(top, bg="#222", he...
true
0c2563d42a29e81071c4a2667ace0495477ac241
endreujhelyi/endreujhelyi
/week-04/day-3/08.py
534
4.1875
4
# create a 300x300 canvas. # create a square drawing function that takes 2 parameters: # the x and y coordinates of the square's top left corner # and draws a 50x50 square from that point. # draw 3 squares with that function. from tkinter import * top = Tk() size = 300 lines = 3 canvas = Canvas(top, bg="#222", heigh...
true
506d0bbf89cbbeeb0a5343c43d955b853a526556
endreujhelyi/endreujhelyi
/week-04/day-4/02.py
212
4.1875
4
# 2. write a recursive function # that takes one parameter: n # and adds numbers from 1 to n def recursive(n): if n == 1: return (n) else: return n + recursive(n-1) print (recursive(5))
false
dc27b4d07c81d4faed52867851a4b623ac3a7ca3
jonathan-potter/MathStuff
/primes/SieveOfAtkin.py
1,824
4.21875
4
########################################################################## # # Programmer: Jonathan Potter # ########################################################################## import numpy as np ########################################################################## # Determine the sum of all prime numbers l...
true
6733b7b848e1e271f7f3d313284348f9e9fab0a8
gyhou/DS-Unit-3-Sprint-2-SQL-and-Databases
/SC/northwind.py
2,546
4.5625
5
import sqlite3 # Connect to sqlite3 file conn = sqlite3.connect('northwind_small.sqlite3') curs = conn.cursor() # Get names of table in database print(curs.execute("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;").fetchall()) # What are the ten most expensive items (per unit price) in the database...
true
75ee01282c6ac7032782e7c7c5e41918976ea2f4
mattwu4/Python-Easy-Questions
/Check Primality Functions/Solution.py
638
4.15625
4
while True: number = input("Choose any number you want! ") number = int(number) if number == 2: print("PRIME!") elif number == 3: print("PRIME!") elif number == 5: print("PRIME!") elif number == 7: print("PRIME!") elif number == 11: print("PRIME!") ...
false
c653a1e85345ac2bd9dabf58da510c86a43afdac
jrabin/GenCyber-2016
/Base_Day.py
309
4.21875
4
# -*- coding: utf-8 -* """ Created on Wed Jul 6 10:24:01 2016 @author: student """ #Create your own command for binary conversion #// gives quotient and % gives remainder ''' hex_digit=input("Hex input:") print(chr(int("0x"+hex_digit,16))) ''' letter=input("Enter letter:") print(hex(int(ord(letter))))
true
8de2a3d8d21d1ccc75b71500424728f5ec707a5f
yestodorrow/py
/init.py
486
4.15625
4
print("hello, Python"); if True: print("true") else: print("flase") # 需要连字符的情况 item_one=1 item_two=2 item_three=3 total = item_one+\ item_two+\ item_three print(total) item_one="hello" item_two="," item_three="python" total = item_one+\ item_two+\ item_three print(total) # ...
false
f7c954329701b44dd381aa844cf6f7a11ba1461e
KritiBhardwaj/PythonExercises
/loops.py
1,940
4.28125
4
# # Q1) Continuously ask the user to enter a number until they provide a blank input. Output the sum of all the # # numbers # # number = 0 # # sum = 0 # # while number != '': # # number = input("Enter a number: ") # # if number: # # sum = sum + int(number) # # print(sum) # # sum = 0 # # number...
true
dbe0e4b02b87fc67dd2e4de9cbaa7c0226f9e58e
geekidharsh/elements-of-programming
/primitive-types/bits.py
1,870
4.5
4
# The Operators: # x << y # Returns x with the bits shifted to the left by y places (and new bits on the right-hand-side are zeros). # This is the same as multiplying x by 2**y. # ex: 2 or 0010, so 2<<2 = 8 or 1000. # x >> y # Returns x with the bits shifted to the right by y places. This is the same as //'ing x by ...
true
3a60bae93f01f1e9205430277f924390825c598f
geekidharsh/elements-of-programming
/binary-trees/binary-search-tree.py
1,229
4.15625
4
"""a binary search tree, in which for every node x and it's left and right nodes y and z, respectively. y <= x >= z""" class BinaryTreeNode: """docstring for BT Node""" def __init__(self, data=None, left=None, right=None): self.data = data self.left = left self.right = right # TRAVERSING OPERATION def preor...
true
4c05bf6d559bd0275323dbdb217edc1a2208f59c
geekidharsh/elements-of-programming
/arrays/generate_primes.py
613
4.1875
4
# Take an integer argument 'n' and generate all primes between 1 and that integer n # example: n = 18 # return: 2,3,5,7,11,13,17 def generate_primes(n): # run i, 2 to n # any val between i to n is prime, store integer # remove any multiples of i from computation primes = [] #generate a flag array for all elem...
true
51a3ae2e607f52ab2c79c59344699e52030e1c15
justindarcy/CodefightsProjects
/isCryptSolution.py
2,657
4.46875
4
#A cryptarithm is a mathematical puzzle for which the goal is to find the correspondence between letters and digits, #such that the given arithmetic equation consisting of letters holds true when the letters are converted to digits. #You have an array of strings crypt, the cryptarithm, and an an array containing the ma...
true
9c01fc72c243846886a7e1f44e5a0ebcce008f7b
sgirimont/projecteuler
/euler1.py
1,153
4.15625
4
################################### # Each new term in the Fibonacci sequence is generated by adding the previous two terms. # By starting with 1 and 2, the first 10 terms will be: # # 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... # # By considering the terms in the Fibonacci sequence whose values do not exceed four million, ...
true
e9acdbfd9ab5a29c06f1e27abcd1d384611c5cf0
chizhangucb/Python_Material
/cs61a/lectures/Week2/Lec_Week2_3.py
2,095
4.21875
4
## Functional arguments def apply_twice(f, x): """Return f(f(x)) >>> apply_twice(square, 2) 16 >>> from math import sqrt >>> apply_twice(sqrt, 16) 2.0 """ return f(f(x)) def square(x): return x * x result = apply_twice(square, 2) ## Nested Defintions # 1. Every user-defined func...
true
fbd7afe059c5eb0b6d99122e46b1ddbcaac18de0
hammer-spring/PyCharmProject
/pythion3 实例/30_list常用操作.py
1,680
4.1875
4
print("1.list 定义") li = ["a", "b", "mpilgrim", "z", "example"] print(li[1]) print("2.list 负数索引") print(li[-1]) print(li[-3]) print(li[1:3]) print(li[1:-1]) print(li[0:3]) print("3.list 增加元素") li.append("new") print(li) li.insert(2,"new") print(li) li.extend(["two","elements"]) print(li) print("4.list 搜索") a = li.ind...
false
99a4589ac6adbe80b7efc1a04fd9761892d09deb
hammer-spring/PyCharmProject
/18-Spider/v23.py
986
4.125
4
''' python中正则模块是re 使用大致步骤: 1. compile函数讲正则表达式的字符串便以为一个Pattern对象 2. 通过Pattern对象的一些列方法对文本进行匹配,匹配结果是一个Match对象 3. 用Match对象的方法,对结果进行操纵 ''' import re # \d表示以数字 # 后面+号表示这个数字可以出现一次或者多次 s = r"\d+" # r表示后面是原生字符串,后面不需要转义 # 返回Pattern对象 pattern = re.compile(s) # 返回一个Match对象 # 默认找到一个匹配就返回 m = pattern.match("one12two2three3") ...
false
16021ebd861f8d23781064101d52eba228a6f800
mldeveloper01/Coding-1
/Strings/0_Reverse_Words.py
387
4.125
4
""" Given a String of length S, reverse the whole string without reversing the individual words in it. Words are separated by dots. """ def reverseWords(s): l = list(s.split('.')) l = reversed(l) return '.'.join(l) if __name__ == "__main__": t = int(input()) for i in range(t): string = str(i...
true
0053bde8153d3559f824aed6a017c528410538ea
JaredD-SWENG/beginnerpythonprojects
/3. QuadraticSolver.py
1,447
4.1875
4
#12.18.2017 #Quadratic Solver 2.4.6 '''Pseudocode: The program is designed to solve qudratics. It finds it's zeros and vertex. It does this by asking the user for the 'a', 'b', and 'c' of the quadratic. With these pieces of information, the program plugs in the variables into the quadratic formula and the formula...
true
bf217099c4cd2547f792e271d60cefcb696187ad
wellqin/USTC
/DataStructure/字符串/数字.py
1,974
4.1875
4
# -*- coding: utf-8 -*- """ ------------------------------------------------- File Name: 数字 Description : Author : wellqin date: 2019/8/1 Change Activity: 2019/8/1 ------------------------------------------------- """ import math # // 得到的并不一定是整数类型的数,它与分母分子的数据类型有关系。 print(7.5//2) # 3.0 p...
false
c1b024fe6518776cbeaabb614ca1fa63813b02b7
wellqin/USTC
/PythonBasic/base_pkg/python-06-stdlib-review/chapter-01-Text/1.1-string/py_02_stringTemplate.py
1,422
4.1875
4
### string.Template is an alternative of str object's interpolation (format(), %, +) import string def str_tmp(s, insert_val): t = string.Template(s) return t.substitute(insert_val) def str_interplote(s, insert_val): return s % insert_val def str_format(s, insert_val): return s.format(**insert_val) ...
true
988ab3ba48c2d279c3706a2f12224f3793182a14
wellqin/USTC
/DesignPatterns/behavioral/Adapter.py
1,627
4.21875
4
# -*- coding:utf-8 -*- class Computer: def __init__(self, name): self.name = name def __str__(self): return 'the {} computer'.format(self.name) def execute(self): return self.name + 'executes a program' class Synthesizer: def __init__(self, name): self.name = name ...
true
a47e31222de348822fbde57861341ea68a4fa5fb
Ph0tonic/TP2_IA
/connection.py
927
4.15625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- class Connection: """ Class connection which allow to link two cities, contains the length of this connection """ def __init__(self, city1, city2, distance): """ Constructor :param city1: City n°1 :param city2: City n°2...
true
92e296b5132802978932b62ddab03030d636785d
elsandkls/SNHU_IT140_itty_bitties
/example_1_list.py
1,593
4.34375
4
# Get our lists from the command line # It's okay if you don't understand this right now import sys list1 = sys.argv[1].split(',') list2 = sys.argv[2].split(',') # # Print the lists. # # Python puts '[]' around the list and seperates the items # by commas. print(list1) print(list2) # # Note that this list has thre...
true
7add89c47bb6e5b3a49504244acc952a91040d31
MasudHaider/Think-Python-2e
/Exer-5-3(1).py
555
4.21875
4
def is_triangle(length1, length2, length3): case1 = length1 + length2 case2 = length1 + length3 case3 = length2 + length3 if length1 > case3 or length2 > case2 or length3 > case1: print("No") elif length1 == case3 or length2 == case2 or length3 == case1: print("Degenerate triangle") ...
true
afc0ab954176bdcbbb49b4415431c49278c9628c
kchow95/MIS-304
/CreditCardValidaiton.py
2,340
4.15625
4
# Charlene Shu, Omar Olivarez, Kenneth Chow #Program to check card validation #Define main function def main(): input_user = input("Please input a valid credit card number: ") #Checks if the card is valid and prints accordingly if isValid(input_user): print(getTypeCard(input_user[0])) print("The number is valid"...
true
dd7b7315ee7d3cfd75af1a924c0fa5f2d0ab731d
syeutyu/Day_Python
/01_Type/String.py
1,380
4.125
4
# 문자열 문자, 단어 등으로 구성된 문자들의 집합을 나타냅니다. # 파이썬에는 4개의 문자열 표현 방법이 존재합니다. a = "Hello Wolrd" #1 a = 'Hello Python' #2 a = """Python Hello""" #3 a = '''Python String''' #4 # 1. 문자열에 작은 따옴표를 포함시킬경우를 위해 제작 # Python's very good 을문자열로 하기위해서는? a = "Python's very good" # 2. 위와 같이 문자열에 큰 따옴표를 표함하기위해서 제작되었다 # I want Study "Python" =...
false
7ba0531979d8aed9f9af85d74a83cd2b5120426f
PythonTriCities/file_parse
/four.py
637
4.3125
4
#!/usr/bin/env python3 ''' Open a file, count the number of words in that file using a space as a delimeter between character groups. ''' file_name = 'input-files/one.txt' num_lines = 0 num_words = 0 words = [] with open(file_name, 'r') as f: for line in f: print(f'A line looks like this: \n{line}') ...
true
d2fd477b8c9df119bccb17f80aceda00c61cd82d
Sai-Sumanth-D/MyProjects
/GuessNumber.py
877
4.15625
4
# first importing random from lib import random as r # to set a random number range num = r.randrange(100) # no of chances for the player to guess the number guess_attempts = 5 # setting the conditions while guess_attempts >= 0: player_guess = int(input('Enter your guess : ')) # for checking ...
true
dbef91a7ddfd4100180f9208c3880d9311e2c94c
Arlisha2019/HelloPython
/hello.py
1,319
4.34375
4
#snake case = first_number #camel case =firstNumber print("Hello") #input function ALWAYS returns a String data type #a = 10 # integer #b = "hello" # String #c = 10.45 # float #d = True # boolean #convert the input from string to int #first_number = float(input("Enter first number: ")) #second_number = float(input("En...
true
ac42e69bac982862edcbed8567653688ee07f186
GaganDureja/Algorithm-practice
/Vending Machine.py
1,686
4.25
4
# Link: https://edabit.com/challenge/dKLJ4uvssAJwRDtCo # Your task is to create a function that simulates a vending machine. # Given an amount of money (in cents ¢ to make it simpler) and a product_number, #the vending machine should output the correct product name and give back the correct amount of change. # The...
true
47f8c6b8f6c8b01f0bc66d998fdd4c039bf91572
Tallequalle/Code_wars
/Task15.py
728
4.125
4
#A pangram is a sentence that contains every single letter of the alphabet at least once. For example, the sentence "The quick brown fox jumps over the lazy dog" is a pangram, because it uses the letters A-Z at least once (case is irrelevant). #Given a string, detect whether or not it is a pangram. Return True if it i...
true
091718f2cf95ce96ff8d3aa2704068d25e650121
wsargeant/aoc2020
/day_1.py
1,383
4.34375
4
def read_integers(filename): """ Returns list of numbers from file containing list of numbers separated by new lines """ infile = open(filename, "r") number_list = [] while True: num = infile.readline() if len(num) == 0: break if "\n" in num: num = num...
true
08e800c3cdcbfaa6f37a0aa98863a39d8260242c
AsiakN/flexi-Learn
/sets.py
1,880
4.34375
4
# A set is an unordered collection with no duplicates # Basic use of sets include membership testing and eliminating duplicates in lists # Sets can also implement mathematical operations like union, intersection etc # You can create a set using set() or curly braces. You can only create an empty set using the set(...
true
fe14c4912950ed8ca6bbb77eabc57ce776a1a095
Barleyfield/Language_Practice
/Python/Others/Pr181121/HW09_Substring.py
1,089
4.15625
4
# -*- coding: utf-8 -*- """ 142694 윤이삭 Substring 함수 만들기 <실행예> Enter the first string: asdf Enter the second string: vfrtgasdfnhy asdf is a substring of vfrtgasdfnhy Enter the first string: 깊은바다 Enter the second string: 파란하늘은 깊은바다와 같다 깊은바다 is a substring of 파란하늘은 깊은바다와 같다 """ def Substring(subst,st) : if(st.find...
false
330e62b9b6ff037ff06d0e9a1dc6aa3a930095f0
Alfred-Mountfield/CodingChallenges
/scripts/buy_and_sell_stocks.py
881
4.15625
4
""" Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm to find the maximum profit. Note that you cannot sell a stock before you buy one. """ def ma...
true
dc2da5e06755ee1ef83d933b77b4ed1ffa1c6d71
SaikumarS2611/Python-3.9.0
/Packages/Patterns_Packages/Symbols/Equilateral_Triangle.py
479
4.125
4
def for_equilateral_triangle(): """Shape of 'Equilateral Triangle' using Python for loop""" for row in range(12): if row%2!=0: print(' '*(12-row), '* '*row) def while_equilateral_triangle(): """Shape of 'Equilateral Triangle' using Python while l...
false
97179eb2d9dcaf051c37211d40937166869a0c83
SaikumarS2611/Python-3.9.0
/Packages/Patterns_Packages/Alphabets/Upper_Case_alphabets/D.py
970
4.21875
4
# using for loop def for_D(): """ Upper case Alphabet letter 'D' pattern using Python for loop""" for row in range(6): for col in range(5): if col==0 or row in (0,5) and col<4 or col==4 and row>0 and row<5: print('*', end ...
false
ae17927ae7d2911b505dca233df10577c39efd6e
SaikumarS2611/Python-3.9.0
/Packages/Patterns_Packages/Alphabets/Lower_Case_alphabets/z.py
869
4.125
4
def for_z(): """ Lower case Alphabet letter 'z' pattern using Python for loop""" for row in range(4): for col in range(4): if row==0 or row==3 or row+col==3: print('*', end = ' ') else: ...
false
e77e9c67faf6319143afd737cee920a98496cce0
SaikumarS2611/Python-3.9.0
/Packages/Patterns_Packages/Symbols/Reverse_triangle.py
444
4.375
4
def for_reverse_triange(): """Shape of 'Reverse Triangle' using Python for loop """ for row in range(6,0,-1): print(' '*(6-row), '* '*row) def while_reverse_triange(): """Shape of 'Reverse Triangle' using Python while loop """ row = 6 ...
false
35e9d5de6afa12398a59af95f454097f3231d4ad
SaikumarS2611/Python-3.9.0
/Packages/Patterns_Packages/Symbols/Rectangle.py
926
4.34375
4
def for_rectangle(): """Shape of 'Rectangle' using Python for loop """ for row in range(6): for col in range(8): if row==0 or col==0 or row==5 or col==7: print('*', end = ' ') else: ...
true
b7cf0ad56f664cab16423ec3baeaea62603d29bb
claraqqqq/l_e_e_t
/102_binary_tree_level_order_traversal.py
1,178
4.21875
4
# Binary Tree Level Order Traversal # Given a binary tree, return the level order traversal of its # nodes' values. (ie, from left to right, level by level). # For example: # Given binary tree {3,9,20,#,#,15,7}, # 3 # / \ # 9 20 # / \ # 15 7 # return its level order traversal as: # [ # [3], # [...
true
cdd09dafb35bc0077d004e332ab48436810224a7
claraqqqq/l_e_e_t
/150_evaluate_reverse_polish_notation.py
1,079
4.28125
4
# Evaluate Reverse Polish Notation # Evaluate the value of an arithmetic expression in Reverse Polish Notation. # Valid operators are +, -, *, /. Each operand may be an integer or another expression. # Some examples: # # ["2", "1", "+", "3", "*"] -> ((2 + 1) * 3) -> 9 # ["4", "13", "5", "/", "+"] -> (4 + (13 / 5))...
true
045ad42fadd7542f7932345050395615896b6543
StevenHowlett/pracs
/prac5/hex_colours.py
468
4.375
4
COLOUR_TO_HEX = {'aliceblue': '#fof8ff', 'antiquewhite': '#faebd7', 'aquamarine': '#7fffd4', 'azure': '#f0ffff', 'beige': '#f5f5dc', 'bisque': 'ffe4c4', 'black': '#000000', 'blue': '#0000ff', 'blueviolet': '8a2be2'} colour = input("Enter colour: ").lower() while colour != "": if colour in COLOUR_T...
false
ec541b14059808cf538ba11ffa9645488d70f4f4
BuseMelekOLGAC/GlobalAIHubPythonHomework
/HANGMAN.py
1,602
4.1875
4
print("Please enter your name:") x=input() print("Hello,"+x) import random words = ["corona","lung","pain","hospital","medicine","doctor","ambulance","nurse","intubation"] word = random.choice(words) NumberOfPrediction = 10 harfler = [] x = len(word) z = list('_' * x) print(' '.join(z), end='\n') while Num...
true