blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
92c098d28f7222c334d0e50fd87074be42ea8c99
Kawser-nerd/CLCDSA
/Source Codes/AtCoder/abc071/B/4910754.py
181
3.578125
4
S = input() flag = False for i in range(97,97 + 26): c = chr(i) if c not in S: print(c) flag = True break if not flag: print("None")
c9c193909200445684e852ae933a390e3cf5ed4f
luisandre69/python-programming-course
/string.py
552
4.09375
4
# %% x='My name is Luis' y="My brother's name is Vitor" z='My last name is "Abreu"' print(x) print(y) print(z) # %% string indexing 'Portugal'[0] # %% string slicing "Portugal"[1:3] # %% string concatenation 'ab'+ 'cd' # %% string repetition 'ab'*2 # %% length len("Portugal") # %% z="Portugal" z.capitalize() # ...
1cdbc663b550284fdd0962aae7ae90f744750c2e
arjunv/code
/python/PygLatin.py
698
4.3125
4
""" Pig Latin is a language game, where you move the first letter of the word to the end and add "ay." So "Python" becomes "ythonpay." To write a Pig Latin translator in Python, here are the steps we'll need to take: * Ask the user to input a word in English. * Make sure the user entered a valid word. * Con...
b4a9e45d7a28e6d8967192dc1160a0b4d58ceaea
Kurdupov/Colocvium
/col23.py
1,408
3.671875
4
#23. Знайти суму всіх елементів масиву цілих чисел, які менше середнього #арифметичного елементів масиву. Розмірність масиву - 20. Заповнення масиву #здійснити випадковими числами від 150 до 300. #Курдупов Олексій 122Г import numpy as np #імпортуємо Бібліотеку numpy . import random #імпортуємо random while True: Z=...
5680a1cc140493d70c604702e1057fdca5643a37
Mishalovoper/ML-Course
/PythonCrashCourse/Part2.py
1,279
4.4375
4
# Dictionary # Is a key value par d = {'key1':'value1','key2': 123} print(d['key1']) #print an element in the key (key1) print(d['key2']) # You could have the value as a list d['key3'] = [1,2,3,] print(d['key3']) #Dictionary inside a dictionary is also possible d['key4'] = {'keyX':[1,2,3]} #Acessing nested dictionar...
7a0a7d24365bc94965f2b85ff7d862f993ea3d6f
jedzej/tietopythontraining-basic
/students/swietczak_monika/lesson_06_dicts_tuples_sets_args_kwargs/guess_the_number.py
374
3.78125
4
n = int(input()) possible_numbers = set(range(1, n + 1)) while True: val = input() if val not in ("YES", "NO", "HELP"): a = set(int(s) for s in val.split()) if val == "YES": possible_numbers &= a if val == "NO": possible_numbers -= a elif val == "HELP": break for el...
a083974250dd94172ae31532af3419aa7800d411
yestemir/web
/week8/informatics/6.py
87
3.515625
4
a0 = input() b0 = input() a = int(a0) b = int(b0) if a > b: print(a) else: print(b)
ea636a2ab0bd2dd6a49fcb07cef5cbd6bc61bd1e
tnohren/Card-Games
/CardandDeck/CardandDeck.py
2,535
4.03125
4
# CardandDeck.py import random import itertools # Card class --- handles the suit and value of the card # as well as the names associated with each # There is a method used to print out the card class Card: snames = ['Clubs', 'Spades', 'Diamonds', 'Hearts'] vnames = ['Ace', '2', '3', '4', '5', '6', '7...
352b3dde010dc17d0ddbd655c70670d98b38bab7
CamiloJose/Intro.Progra
/Semestre 2/Revisar si un numero tiene un digito que sea 2, con auxiliar.py
429
3.609375
4
#Ejemplo de recursividad SIMPLE #E:numero #S:booleano que indique si tiene un 2 #R:Tiene que ser un numero entero def tiene2(num): #Funcion principal if isinstance(num,int): return tiene2_aux(abs(num)) else: return "Error" def tiene2_aux(num): if num ==0: #caso base 1 ...
fec6fbdef05705ab0a394e45c1f5162efe620f13
Kehvarl/AdventOfCode2019
/dijkstra_map.py
3,400
3.953125
4
class DijkstraMap: """ Python implementation of Dijkstra Maps Source: http://www.roguebasin.com/index.php?title=The_Incredible_Power_of_Dijkstra_Maps http://www.roguebasin.com/index.php?title=Dijkstra """ # X, Y Transitions to the 4 neighboring cells neighbors = [(0, -1), ...
f3d90c0b93542d5b73273c161a43838144d248ea
domene96/Nmod
/Structures.py
4,862
4.125
4
#!/usr/bin/env python # LIFO Stack implementantion # Used for: OPERANDS, OPERATORS, TYPES, and JUMPS class Stack: # Initialize stack def __init__(self): self.stack = [] # Insert value into stack def push(self, value): self.stack.append(value) #self.print() # Remove from st...
b286fdbfff82d65361fb9f94f570e6bc04d7a7ea
BrendanSimms8898/Python
/Second-Year/CA268-Labs/PhoneNumbers.py
409
3.765625
4
def main(): print("Enter a name and number, or a name and ? to query (!! to exit)") inp = input() d = {} while inp != "!!": inp = inp.strip().split() if inp[1] == "?": if inp[0] in d: print(str(inp[0]) + " has number " + str(d[inp[0]])) else: print("Sorry, there is no " + str(inp[0])) else: d...
fc6e73cf843aa31d95f416bcfd71cb6b0e487031
Dismissall/function_task-home_task
/array_class.py
3,558
3.765625
4
class Array: def __init__(self, data): self.data = data def __add__(self, other): # Находим максимальное количество столбцов и строк max_col = max(len(self.data), len(other.data)) max_row = max(len(self.data[0]), len(other.data[0])) # Создаем нулевую матрицу ра...
e2d8abcd21cdcb79e2253c9d3b2a8b646111d180
fabriciolelis/python_studying
/coursera/Michigan/chapter_9/maximum.py
500
3.609375
4
fname = input('Enter the file name: ') try: fhand = open(fname) except: print('File cannot be opened:', fname) exit() dic = dict() bigEmail = None bigValue = None for line in fhand: words = line.split() if len(words) == 0: continue if words[0] != 'From': continue dic[words[1...
c76b3ddcea9161ac22a6f947886fc8348eafef46
preet01/cnn_projects
/Conv_operations_numpy/forward_backward_conv.py
4,309
3.5625
4
import numpy as np def affine_forward(x, weight, bias): """ Computes the foward pass for an affine layer. x:input x weight:weight for affine_forward layer bias:bias out:output of weight,x,bias cache:data stored for backward pass """ out = np.zeros((x.shape[0],weight.shape[1])) ...
a5f51bcba80f68eedc2845798975ee5a936b3d47
sibarras/PythonExamples
/solver.py
2,624
3.59375
4
import numpy as np class Ecuation: def __init__(self, xList:list, constant=0, etype='main'): """Define una ecuacion como una matriz de numpy, recibiendo las variables en una lista. Args: xList (list): Se introducen los valores que multiplican a cada variable en la ecuacion ...
b3c9dae68e4eb92eca3239d4f8810fa8e5765fac
IvanM1987/Algorithm
/Lesson_2/2.3.py
545
4.34375
4
# 3. Сформировать из введенного числа обратное по порядку входящих в него цифр и вывести на экран. Например, # если введено число 3486, то надо вывести число 6843. # def endstart(newnumber, number): newnumber = newnumber * 10 + number % 10 number = number // 10 if number == 0: return print(newnumber...
ad430a3bbd6b278cf22bdced455d9d24361a2d78
PriyankaKhire/ProgrammingPracticePython
/Find Duplicate Subtrees.py
4,016
4.09375
4
# Find Duplicate Subtrees #Given a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the root node of any one of them. # #Two trees are duplicate if they have the same structure with same node values. # #Example 1: # # 1 # / \ # 2 3 # ...
9f69ded316f31dd470dfe171abd228b06660b5c0
wdhg/project-euler
/python/question_026.py
681
3.71875
4
def is_prime(x): for i in range(2, int(x ** 0.5) + 1): if x % i == 0: return False return True def get_recurring_len(x): # Basically just bus stop / short hand division to get the length length = 0 carried = [10] while True: length += 1 carry = (carried[-1] %...
17e0e79c1aa81ea4bb6647e19f94c3b9879cbb72
Juan-Tena/Codigo_VBA
/Video_8_Tuplas.py
1,483
4.40625
4
#Creación de una tupla mitupla=("Juan", 13 , 1, 1995, "Juan") #Acceder a un elemento de la tupla print(mitupla[2]) #Hay dos métodos que permiten convertir tuplas en listas y al revés milista=list(mitupla) #Convierte una tupla en una lista print(milista) #Sabemos que es una lista porque imprme los datos entre corchete...
37a0955ef27ab861a303dd519c91b2a7bd5332c6
siddharthchd/Python-Basics
/files.py
474
4.03125
4
# Open a file myFile = open('myfile.txt', 'w') # Get some info on file print('Name : ', myFile.name) print('Is Closed : ', myFile.closed) print('Opening Mode : ', myFile.mode) # Write to file myFile.write('I am doing this from python') myFile.write(' and this is fun') myFile.close() # Append to file myFile = open('m...
27123c90a292fa1ae24714bfb38a84712c38d438
fotavio16/PycharmProjects
/GameDevPython&Pygame/gameobjects.py
1,460
3.59375
4
import math class Vector2(object): def __init__(self, x=0.0, y=0.0): self.x = x self.y = y if hasattr(x, "__getitem__"): x, y = x self._v = [float(x), float(y)] else: self._v = [float(x), float(y)] def __str__(self): return "(%s, %s)...
03148be62375b94f91df8eb031f503cde00c7fc0
nickyfoto/lc
/python/69.sqrtx.py
1,220
3.921875
4
# # @lc app=leetcode id=69 lang=python3 # # [69] Sqrt(x) # # https://leetcode.com/problems/sqrtx/description/ # # algorithms # Easy (31.11%) # Total Accepted: 363.8K # Total Submissions: 1.2M # Testcase Example: '4' # # Implement int sqrt(int x). # # Compute and return the square root of x, where x is guaranteed t...
f956a6791151f7647012841eecc204dfd20739d9
dale-wahl/materials_pipeline
/collect_labs.py
1,974
3.65625
4
import sys import lab_to_db_updater import csv_creater """ This program creates a master csv to combine lab results with procurement and material processing data. From the SQL database, it relies on the material_procurement, ball_milling, and hot_press tables. It handles ICP and Hall lab results files, recording meas...
06e380325f094c6c4ad5d67aea1a56bf71d71283
toggame/Python_learn
/第二章/assign_operator_test.py
1,018
3.8125
4
# 为变量st赋值为Python st = 'Python' # 为变量pi赋值为3.14 pi = 3.14 # 为变量visited赋值为True visited = True # 将变量st的值赋值给st2 st2 = st print(st2) a = b = c = 20 print('a:%d b:%d c:%d' % (a, b, c)) # 使用()将多个格式转换说明符提交 d1 = 12.34 d2 = d1 + 5 print('d2:%g' % d2) f = 0x41 print("%c" % f) # d,i 转换为带符号的十进制形式的整数 # o 转换为带符号的八进制形式的整数 # x ...
99446f4f23d86c9f526119f62891bf50711bf0e2
chriskwon96/Algorithm_codes
/백준/2606_바이러스/2606_바이러스.py
462
3.5625
4
def bfs(start): global ans q = [start] while q : head = q.pop(0) for i in range(N+1): if matrix[i][head] and v[i] == 0: v[i] = 1 ans += 1 q.append(i) N = int(input()) V = int(input()) matrix = [[0]*(N+1) for _ in range(N+1)] for ...
116f30da56603d77ce3ec6e601db1e7d9217c51b
dom-0/python
/OOPS/oop.py
645
3.71875
4
class Kettle(object): power_source = "electricity" \ "" def __init__(self, make, price): self.make = make self.price = price self.on = False def switch_on(self): self.on = True kenwood = Kettle("kenwood", 13.55) hamilton = Kettle("hamilton", 19.99) print...
d7483fee3f38bcff15ab34d1f5768479f22605c6
iGoWithYou/Laboratories
/lab1.1.py
269
3.828125
4
# -*- coding: utf-8 -*- """ Created on Wed Mar 20 16:01:09 2019 @author: Mati """ from math import* x = 56 z = 0 while x <= 100: y = 2*(x**2) + 2*x + 2 print('for x = ',x,'function value y = ',y) x = x+1; z = z + y; print('function y total value = ',z)
0f2637e48a465145b7aaedd032287a493d250998
pawwahn/python_practice
/dateutil/no_of_days_since_a_date.py
382
4.46875
4
# Python3 program to find number of days # between two given dates from datetime import date def numOfDays(date1, date2): return (date2 - date1).days cur_date = date.today() #print(cur_date) yy,mm,dd = cur_date.year, cur_date.month, cur_date.day #print(yy,mm,dd) # Driver program date1 = date(1947, 12, 13) date...
14b5cd9ce3446fbe105ad90117c45029bb70347a
arapujo/exercicios_python
/pyhton_para_zumbis/lista1/1somaDoisNumeros.py
303
4.03125
4
''' Faça um programa que peça dois números inteiros e imprima a soma desses dois números ''' print(' === SOMA DE DOIS NÚMEROS === ') numero_1 = int(input('Insira o 1º número: ')) numero_2 = int(input('Insira o 2º número: ')) soma = numero_1 + numero_2 print(f'O resultado da soma é: {soma}')
5a5c0eb934355ad6e72bd01826c52afaf418ff27
DevanLawal/Nim
/main.py
347
3.921875
4
#This function will repeat for each person Score = 0 #while function that will be true running = True while running: Choice = int(input("1 or 2?: ")) if Choice > 20: running == True #adding our inputted number to the score Score += Choice print(Score) else: running = False #Make the funct...
8ee693a423fb016ce0470b0381bac84b437630d6
khromov-heaven/pyBursaGit
/L1/dz1_3.py
100
3.890625
4
s = str(raw_input('Enter a string: ')) s1 = ('wow') print '''Counter of wow's is:''',s.count('wow')
54bf7fab78b959a5cf19fcf5a56ea8809a5311e0
rajshree8217/c7_audit_text_repo
/wsgi.py
9,878
4.03125
4
#!/usr/bin/env python # coding: utf-8 # #### Week 3 - Functions # In[1]: # Import Library default with python installation import os import sys # In[3]: def my_main(input_filename): print('***Start of my_main function***') # Get the current working directory curr_dir = os.getcwd() print(cu...
9362f5bfe923dbbc695b0cbee116e7cd7ff6a908
mahimoksha/Games
/tic_tac_toe.py
21,337
3.5625
4
import random def print_curr(total_table): p = 0 for i in range(3): print(" ___",end="") print() for i in range(3): for j in range(3): if j == 0 : print("| ",end = "") print(total_table[i][j] , end = " | ") ...
bf4917de3c7b89ca971f41ef2cc070d7e5212f25
DhruvDange/Python-games
/tic-tac-toe.py
3,956
3.890625
4
import time player_no = 1 played_pos = [] available_pos = [1,2,3,4,5,6,7,8,9] grid = {'7':' ','8':' ','9':' ','4':' ','5':' ','6':' ','1':' ', '2':' ','3':' '} def rules(): print("Welcome to tic-tac-toe!!") time.sleep(2) print("Decide your position by typing on your numpad!") print("The grid is numbe...
d23f970f82d5cf0b3ebccdde733bec17201a980c
dmonyei/Python-Blackjack
/Blackjack(Beta).py
6,424
3.875
4
import random deck = {"Ace of Diamonds": 11, "Two of Diamonds" : 2, "Three of Diamonds": 3 , "Four of Diamonds": 4 , "Five of Diamonds" : 5, "Six of Diamonds": 6, "Seven of Diamonds": 7, "Eight of Diamonds": 8, "Nine of Diamonds": 9, "Ten of Diamonds": 10, "Jack of Diamonds" :10,"Queen of Diamonds"...
d0ed5222503d7605d655c3ef896a7fdd5ee74280
Algomaster0628/BinarySearchAlgorithm
/binary_search.py
727
4.03125
4
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] def binary_search(mylist: list, item: int) -> bool: """ checks if an item is inside a sorted list :param mylist: a sorted list of integers :param item: an integer """ ...
92a4e2dd9e1a14c4b2370eeea8517f4017a0034f
krishnanandSrivastava/Hackerrank_question
/Python/Set .symmetric_difference() Operation.py
174
3.640625
4
# Enter your code here. Read input from STDIN. Print output to STDOUT _=input() e=set(input().split()) _=input() f=set(input().split()) print(len(e.symmetric_difference(f)))
dbff8c631afeade4109d3a3cd3db06d8e961b423
bobby20180331/Algorithms
/LeetCode/python/_442.FindAllDuplicatesinanArray.py
1,025
3.546875
4
# 一看题目很简单,瞬间写好一个,测试通过,然后提交,超时了... class Solution(object): def findDuplicates(self, nums): """ :type nums: List[int] :rtype: List[int] """ t = [] ans=[] for x in nums: if x not in t: t.append(x) else: ans....
25b429e1b42bd0bd815011b5f41131a40ff0721c
chiragbohet/MCA
/MCA-101-oops/merge_two_lists.py
742
4.21875
4
def mergeTwoLists(lst1, lst2, lst3 = [], i=0, j=0): ''' Objective : Merge two lists Input Parameters : lst1 : The list 1 lst2 : The list 2 Return : The Merged list ''' #Approach : Using Recursion a=len(lst1) b=len(lst2) if (i==a and j==b): return lst3 ...
f78e8d2838f91ca31446e7ad8e51671dda9714b0
Clempops/algorithms
/permutationString.py
624
3.859375
4
A = 'hello' B = 'hello' def compareString(A, B): if abs(len(A) - len(B)) != 0: return False else: hashTable = [0] * len(A) for i in range(len(A) - 1): hashed_pos = hashValue(A[i], len(A)) add(hashed_pos, hashTable, 1) hashed_pos = hashValue(B[i], len(A)) add(hashed_pos, hashTab...
53090d12abc44d4679272d78db01acb8ad6541d7
Maria-Lasiuta/geegs_girls-Lab2
/ex.8(2).py
269
3.796875
4
list1=['d', 'cccc', 'bb', 'aaa'] def mysort(mylist = [],numflag = False): if numflag == False: mylist.sort(key = lambda x: x[0]) else: mylist.sort(key = len) return print(mylist) mysort(list1) mysort(list1, True) print('DONE')
ed6b13d9e089ebab87aaae7dbb0eed0884f9a65a
Albertojuanse/miso_beacon
/miso_beacon_analysis/calculate_statistics.py
9,376
3.640625
4
"""This functions calculate some statistics from real data obtained from real devices""" import json import sys import os from math import pow, sqrt, pi from matplotlib import pyplot from numpy import linspace, arange, reshape, dot, asarray, exp # ##### GET DATA ##### def readjson(path): with open(path, 'r') as ...
12be7257e2843d403a0b684e77262997ffbb8daf
zywh/waterlooccc
/2015/Senior/S5.py
9,053
3.9375
4
# CCC 2015 Senior 5: Greedy for Pies # # by Daniel Whitney, Newmarket High School # # NOTE: This is in python 3, tho I believe it would take very little # to convert it to python 2 (switch range to xrange, print() to # print). # NOTE: This is way over 5 seconds for the 5 M = 100 if the default # pytho...
b26f5421e94532c2a69c13d3de932d08c8979982
SachinMurkute/python
/generator_example.py
1,304
4.15625
4
import time def follow(thefile): thefile.seek(0, 2) # Go to the end of file while True: next_line = thefile.readline() # type: object if not next_line: time.sleep(0.1) # Sleep briefly continue yield next_line """ one of the most powerful application ...
65381b538439df31dcccef38b213fff707aa0f87
benxiao/python-dynamic-programming
/napsack/napsack.py
1,033
3.703125
4
from typing import * values = [60, 100, 120] weights = [10, 20, 30] def knapsack(values, weights, i, weight_limit): if i == -1: return 0 if weights[i] > weight_limit: return knapsack(values, weights, i - 1, weight_limit) return max(knapsack(values, weights, i - 1, weight_limit), ...
7d03343e2517d7fe4340b6a512a41790fe77a5be
Rozhin-sharifi/Assignment2
/7.py
75
3.5
4
li=[] for i in range(0,20): li.append(int(input())**2) print(li)
1f56974898059ae21757a031baa9739f6f995f3e
nwthomas/code-challenges
/src/daily-coding-problem/medium/coin-collector/coin_collector.py
1,419
4.28125
4
""" Good morning! Here's your coding interview problem for today. This question was asked by Zillow. You are given a 2-d matrix where each cell represents number of coins in that cell. Assuming we start at matrix[0][0], and can only move right or down, find the maximum number of coins you can collect by the bottom ri...
7f316283a116bbdb728454ed87421985334186d6
hansolJu/PythonTutorial
/pythonForBegineer/0430/nonreturn/5.py
689
3.9375
4
def AskBiman(height,weight): biman = weight/pow((height/100),2) if(biman < 18.5): print("저체중입니다.") elif(biman>=18.5 and biman<23): print("정상체중입니다.") elif(biman>=23 and biman<25): print("과체중입니다.") elif (biman >= 25 and biman < 30): print("경도비만입니다.") elif (biman >=...
a34d2f4f752a02a1dc8c3039b98d10622c063469
CihatAcar/Python-Learning-Projects
/filesAnddirectories.py
568
3.578125
4
from pathlib import Path # Absolute path # c:\Program Files\Microsoft # /usr/local/bin # Relative path # path = Path("ecommerce") # print(path.exists()) # Check if the directory exists # # path = Path("emails") # print(path.mkdir()) # Create the directory # # path = Path("ecommerce") # print(path.rmdir()) # Remove ...
4b94bb7d64222f735790680a04c430e664194116
jedzej/tietopythontraining-basic
/students/piechowski_michal/lesson_02_flow_control/chocolate_bar.py
262
4.0625
4
#!/usr/bin/env python3 width = int(input()) height = int(input()) number_of_squares = int(input()) if ((number_of_squares % width == 0 or number_of_squares % height == 0) and width * height >= number_of_squares): print('YES') else: print('NO')
357e2893ccbde0f92b78f0f059c48577caa5df24
Inazuma110/atcoder
/cpp/asakatsu/0923/e/gen.py
203
3.671875
4
#!/home/inazuma/.pyenv/shims/python3 import random n = random.randint(1, 10 ** 5) k = random.randint(1, 10 ** 12) print(n, k) for i in range(n): print(random.randint(1, 10 ** 12), end=' ') print()
e16b815acec22193d525af8a1636d37bcd890b6e
brunocorbetta/exerciciocursoemvideo
/ex005.py
147
3.953125
4
n = int(input('Digite um Numero:')) ant = n - 1 suc = n + 1 print('Analisando o {}, seu antecessor é {} e seu sucessor é {}'.format(n, ant, suc))
49e683e024d5088aa2eb25441e2a5f3b70c43e50
nonnikb/verkefni
/Lokapróf/Kattis/Bolir.py
266
3.6875
4
import string a = int(input("Hversu mörg: ")) l = [] f = [] count = 0 while count < a: n = input("Nafn: ") s = input("Staðsetning: ") #if s not in l and s != ' ': l.append(s) count += 1 print() for x in l: print(x) print(set(len(f)))
2125bde9994af2326272262033159079cd6f8457
cris711/100daychallenge
/interest yearly calc.py
299
3.953125
4
p = float(input("Please enter Principal amount")) r = float(input("Please enter rate of interest in decimal form(ex:3% == .03)")) t = float(input("Please enter number of years")) a = p*(1+(r*t)) print("Initial Amount: ",p," with interest rate: ",r," over the span of: ",t," years results in:", a)
edea86d59a226eb53321d479c5a3ef6c0912b2bd
pandusudo/HACKERRANK
/Python/ListComprehensions.py
665
4.3125
4
# Let's learn about list comprehensions! You are given three integers X,Y and Z representing the dimensions of a cuboid along with an integer N. # You have to print a list of all possible coordinates given by (i,j,k) on a 3D grid where the sum of i + j + k is not equal to N. Here, 0 <= i <= X;0 <= j <= Y;0 <= k <= Z ...
f9dca01b670df9c5ae091cb0205057ae4bf7044e
guimmp92/python
/selection_sort.py
573
4.0625
4
#!/usr/bin/python """ Selection sort: Repeatedly identify the smallest remaining unsorted element and put it at the end of the sorted portion of the array. """ from random_array import randlist arr = randlist(50, 100) def swap(arr, i, j): arr[i], arr[j] = arr[j], arr[i] def selection_sort(arr): cur = 0 ...
275d81b277aa877ec12de2c158db300ecdd97c6a
renatomarquesteles/estudos-python
/Exercicios Curso em Video/ex027.py
210
4.0625
4
nome = input('Digite seu nome completo: ').strip().split() print('Muito prazer em te conhecer!') print('Seu primeiro nome é', nome[0].capitalize()) print('Seu último nome é', nome[len(nome)-1].capitalize())
bb985d9c3abcdf88d59a8e1a5c9f5d16749d5fbe
zwh42/ThinkComplexity
/Graph.py
4,934
3.640625
4
# -*- coding: utf-8 -*- """ Created on Thu Jun 30 16:15:12 2016 @author: wzhao """ class Graph(dict): def __init__(self, vs = [], es = []): """ create a new graph, vs: list of vertices; es: list of edges. """ for v in vs: self.add_vertex(v) for e in es...
801da1ce59cb5d60cf3ba786b874e14d491a10aa
FB-5/Aulas_Python
/aula2.py
1,730
4.5
4
# aula 2 (variáveis, manipulação de variáveis, conversão, poradores aritiméticos,strings, interação com usuário). # str - string # int - inteiro # % - quisermos exibir só o resto da divisão # \n - espaço com um ENTER; para quebra de linhas. # type() - Para saber o tipo de um objeto ou variável. #.format - o ...
2539f6930b3b411dbc235d4d2ede63168b03989b
1joeyfish/PyLab
/Tkinter/4.Dialog.py
4,880
4
4
# https://tkdocs.com/tutorial/index.html # https://www.python-course.eu/python_tkinter.php # https://www.tutorialspoint.com/python3/python_gui_programming.htm # https://www.python-course.eu/ # http://effbot.org/tkinterbook/ # import Libs from tkinter import * from tkinter import ttk from tkinter import mess...
c4205b2089e3cda2232e2789842881bdd2e268f0
Oowalkman23/Python-3.8
/Lexicograph_Bitmask.py
746
3.890625
4
def permutations(): # call variables global running global characters global bitmask if len(running) == len(characters): print(''.join(running), end=' ') else: for i in range(len(characters)): # basically telling if there is a string hasn't been added to the ...
1876249ae4d79122a6a461d0bb2a0c97e6e7218f
wangrui0/python-base
/com/day11/Demo06_except_catch.py
1,105
4.03125
4
# try: # try 和catch中存放怀疑会出现异常的代码(如果当发生异常时,程序没有捕获该异常,程序将会终止,当捕获住异常时,程序会调到异常代码,然后执行异常捕获后的代码) # num = 2 / 0 # print(num) # print("aaa") # except NameError: # 捕获的异常的类型 # print("已经捕获到异常") # 异常捕获后,的处理; # print("程序执行结束") """ Traceback (most recent call last): File "C:/File/2-workspace/python/python-base/c...
9ac7223dba34ae60866a55e0bbb0770dcb30e5dc
suryaroman/roman
/fact.py
118
3.59375
4
jag=int(input()) if(jag<20): import math print(math.factorial(jag)) else: print('num is greater than 20')
8b8c35846b7e8f7ffd64677cf2be375c31e87055
daviuezono/mc920
/02-enhancement-linear-effects/enhancement-linear-effects.py
1,563
3.671875
4
#!/usr/bin/python # -*- coding: utf-8 -*- name = raw_input("Please select one of these images: coins, columns or dragon.\n") while name not in ["coins", "columns", "dragon"]: name = raw_input("ERROR! Please select one of these images: coins, columns or dragon.\n") effect = raw_input("Please select one of these line...
abc1a956c566148fd4ea5d70a3bf0516e4070a44
KojoAning/PYHTON_PRACTICE
/bubble_sort.py
209
3.6875
4
a=[88,81,44,22,42,51,21,42,11,21,93] def bubblesort(): for j in range (0,len(a)-1): for i in range(j): if a[i]>a[i+1]: a[i],a[i+1]=a[i+1],a[i] bubblesort() print(a)
348d8d0dbfde6bfd152353c902a2b37551f464e8
js986/CS485Project1
/RecursiveBST.py
2,713
3.515625
4
class Node: def __init__(self,data,parent): self.data = data self.leftChild = None self.rightChild = None self.parent = parent class RecBST: def __init__(self,root): self.root = root def insertRec(self,root,data): if root == None: root = Node(dat...
45aa8875d1da441d82c155d27d1e6c85f9ada533
ryan-yang-2049/oldboy_python_study
/first_module/homework/question10.py
436
3.78125
4
li = ['手机','电脑','鼠标垫','游艇'] choice_li = [] while True: for k,v in enumerate(li): print(k,v) choice = input("请选择商品编号,退出 q:").strip() if choice.isdigit(): choice_li.append(li[int(choice)]) print(choice_li) elif choice == 'q': print("退出购物!") break else: ...
7d9995cfcbae5da5a5c562072748dae69f72aa13
walliuswilliam/graph
/src/tree.py
1,651
3.625
4
class Node: def __init__(self, index, value): self.index = index self.value = value self.children = None class Tree: def __init__(self, edges, node_values): self.edges = edges self.node_values = node_values self.root = self.get_roots(edges) def build_from_edges(self): node_array =...
06ed22b4f608ef4a062700f28aceab6945e485a7
brianfurrer/CSE015
/Lab_03/Lab_3.py
1,183
4.1875
4
from logic import TruthTable checkList = [] userInput = input("Enter your expression: ") myTable = TruthTable([userInput]) print("") myTable.display() a = myTable.table for x in a: checkList.append(x[1][0]) tableLength = len(checkList) def contingency(tableLength, checkList): check = False for i in ra...
bf4b9da6528a164c03aee8415f9ce601cdcca22f
obalderes/project2-pd7
/GROUP_0/api.py
1,699
3.796875
4
import json import urllib2 apikey="nxs4nu8b9u3ekhuv5gfynr7s" #3 different charts: album, track, artist, but i just used the chart for track track_url="http://api.emusic.com/track/charts?apiKey=nxs4nu8b9u3ekhuv5gfynr7s&format=json" album_url="http://api.emusic.com/album/charts?apiKey=nxs4nu8b9u3ekhuv5gfynr7s&format=js...
bf56db2c486e7da93ac0b937a209f38df517696a
theonemule/ce2c
/011 -- Classes/list.py
437
4.15625
4
class person: def __init__ (self, name, job, age): self.name = name self.job = job self.age = age def greet(self): return "Hello. My name is " + self.name + ". I am a " + self.job + ". My age is " + self.age + "." people = [person("AG", "student", "6"),person("EE", "tod...
d524363f56f93f5dbd673a6143320a4145f7f42c
scMidnight/python_demo
/FileOperation/cvs_test.py
519
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import csv #csv中文文档:https://yiyibooks.cn/xx/python_352/library/csv.html#module-csv csv_file = open('demo.csv', 'w', newline='', encoding='utf-8-sig') writer = csv.writer(csv_file) writer.writerow(['电影', '豆瓣评分']) writer.writerow(['银河护卫队','8.0']) writer.writerow(['复仇者联盟','...
f6f837f9ce493c1d19459fc37b253b8c7dfc09b5
xxkason/formula
/pi/sensor_test.py
793
3.515625
4
import RPi.GPIO as GPIO import time sensor_input = 36 led = 40 ledstate = False #set numbering mode for the program # GPIO.setmode(GPIO.BOARD) # GPIO.setup(sensor_input, GPIO.IN,initial=0) # GPIO.setup(led, GPIO.OUT,initial=0) #this method will be invoked when the event occurs def switchledstate(channel): global...
992d3626fe8544d400ac0edab570dfb217eba801
abikg71/python37
/CS1030/HWHelpMercy2.py
3,142
4.21875
4
def menu (): #Display program header #print("Student Test Score Entry Program") print("-----------------------------") choose_menu = "" while choose_menu != "n": print('Choose an option:') print("a - Add item to cart \n" "r - Remove item from cart\n" "c - change item q...
43466d3b34aac8cabd2e43126b192dfa67aaf099
Banashree81/97-NumberGuessingGame
/GuessTheNumber_C97.py
491
4.28125
4
import random print("Number Guessing Game!") print("Guess a number between 1 and 9 ") num = random.randint(1,9) chances = 0 while chances < 3: choice = int(input("Enter your guess : ")) if(choice == num): print("Yay! you won!") break elif(choice < num): print("Too ...
eb7c0ca956bc07420081601744091f0757454ce3
Shadaez/euler
/euler20.py
409
4.125
4
"""n! means n (n 1) ... 3 2 1 For example, 10! = 10 9 ... 3 2 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. Find the sum of the digits in the number 100!""" import math x = 1 n = 1 def fart(y): h = '' h = str(y) z = 0 for i in range(len(h)): ...
a2571bbbd4e8278feef7a20358a399893523c392
DevanshiGupta007/Image-Classifier
/Image Classifier.py
4,262
4.0625
4
# -*- coding: utf-8 -*- # DESCRIPTION : PROGRAM TO CLASSIFY IMAGES . #LOADING THE DATASET . from keras.datasets import cifar10 (x_train,y_train),(x_test,y_test) = cifar10.load_data() #PRINT THE DATATYPE print(type(x_train)) print(type(y_train)) print(type(x_test)) print(type(y_test)) #GET THE SHAPES OF THE DATA pri...
2ea8bfe257725ff535ebe3d988ddd3dbf1e3d087
ash/amazing_python3
/396-random.py
232
3.546875
4
# Let's print 10 different(!) # random integer numbers # below 20 import random used = set() while 1: n = random.randrange(20) if not(n in used): used.add(n) print(n) if len(used) == 10: break
de78d8491e73756ba58137bf28444e87fdd791e7
keila2k/dsps-2-python
/c0/mapper.py
666
3.6875
4
# !/usr/bin/env python """A more advanced Mapper, using Python iterators and generators.""" import sys def read_input(__file__): for line in __file__: # split the line into words yield line.strip().split() def main(): count = 0 # input comes from STDIN (standard input) data = read_i...
61c290137b3c1430a6d38d9818263121f458ae99
quantum-pie/python-learn
/algo_exam_1/exam_6.py
556
3.625
4
from array import array def sift_up(child_idx): parent_idx = child_idx // 2 while parent_idx != child_idx and heap[parent_idx - 1] > heap[child_idx - 1]: tmp = heap[parent_idx - 1] heap[parent_idx - 1] = heap[child_idx - 1] heap[child_idx - 1] = tmp child_idx = parent_idx ...
6aed2c570713f9ee99ebbc96972e47d6645318fa
DemondLove/Python-Programming
/CodeFights/24. Minesweeper.py
1,512
4.3125
4
''' In the popular Minesweeper game you have a board with some mines and those cells that don't contain a mine have a number in it that indicates the total number of mines in the neighboring cells. Starting off with some arrangement of mines we want to create a Minesweeper game setup. Example For matrix = [[true, fa...
bf90ee4a93780ed29e1cd119473746e275cb90d7
953250587/leetcode-python
/LargestRectangleInHistogram_HARD_84.py
3,376
3.96875
4
""" Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. Above is a histogram where width of each bar is 1, given height = [2,1,5,6,2,3]. The largest rectangle is shown in the shaded area, which has area = 10 un...
c1e7331f146a07c27dcd07140064e9e86cf091e2
lubiedak/adventOfCode
/13/OptimalTablePlaces.py
820
3.515625
4
from itertools import permutations def readLines(): with open('input.txt') as f: return f.readlines() allNames = set() def parseData(data): sittingPreferences = {} for line in data: words = line.split(' ') name1 = words[0] allNames.add(name1) name2 = words[-1][:-2] pref = int(words[3]) * (-1 if (words...
bdcf99d7c75649a371209a2964f48efc66d94984
IvanaOlvera/Mision_08
/vocales.py
926
3.890625
4
#Autor: Ivana Olvera Mérida #Escribe la función contieneLasVocales, que recibe como parámetro una cadena #y regresa True si la cadena contiene TODAS las vocales, False en otro caso. def contieneLasVocales(cadena): copiaVocal = cadena.upper() #Utilizar una copia para identificar si se recibió una vocal en mayú...
ff994d7cf86f240d7825a5ab484a6ed0244f84c5
Zamio77/School-Projects
/LamarDougM05_Ch5Ex21.py
1,634
4.40625
4
""" A paper, rock, scissors game Computer's choice is determined by random number. User will choose and then the choose's are compared. Input validation for when a user continues to enter the incorrect answer. """ import random #valid choices for user VALID_CHOICES = ('ROCK','PAPER','SCISSORS') #the g...
b9e8765a8f81df834697fbda23bdce349c051621
LRBeaver/Eduonix
/tkinter_calc.py
2,396
3.609375
4
__author__ = 'lyndsay.beaver' from tkinter import * root = Tk() equa = "" equation = StringVar() calculation = Label(root, textvariable=equation) equation.set("Enter...") calculation.grid(columnspan=4) def btnPress(num): global equa equa = equa + str(num) equation.set(equa) def...
6ed1cb774fc905d1bfe1f2335b5bbefaf2adace7
najeebuddinm98/count_characters
/count_characters_clip.py
542
3.75
4
#count number of each character in the text stored in clipboard #make sure pyperclip in installed before running import pyperclip def alphabetCount(recmes): #recmes=received message count={} for character in recmes.lower(): count.setdefault(character,0) #create key for character not present already in...
d282269442835bcd3c294f80fc7fffd5d9652d7f
NEHAISRANI/K.B.C-game
/K.B.C.py
1,500
3.921875
4
question_list = ["(1)How many continents are there?", "(2)What is the capital of India", "(3)NG mei kaun se course padhaya jaata hai?"] options=[["(1)Four","(2)Nine","(3)Seven", "(4)Eight"], ["(1)Chandigarh","(2)Bhopal", "(3)Chennai", "(4)Delhi"], ["(1)Software Engineering", "(2)Counse...
2eb0f782ad84b833abb3cf1055651455bce7ac56
jinn2u/basic-Scraping
/assign1.py
1,145
3.578125
4
from bs4 import BeautifulSoup import urllib.request as req import sqlite3 url = "https://ko.wikisource.org/wiki/%EC%A0%80%EC%9E%90:%EC%9C%A4%EB%8F%99%EC%A3%BC" res = req.urlopen(url) soup = BeautifulSoup(res, 'html.parser') # 데이터베이스 연결하기 filepath = "test.sqlite" conn = sqlite3.connect(filepath) # 테이블 생성하기 cur = con...
1700ec9f29742afef74209b45bb98303a47198e4
dpattayath/algo
/dandc.py
509
3.671875
4
def find_sum(lst): if len(lst) == 0: return 0 return lst[0] + find_sum(lst[1:]) def find_count(lst): if len(lst) == 1: return 1 return 1 + find_count(lst[1:]) def find_max(lst): if len(lst) == 2: return lst[0] if lst[0] > lst[1] else lst[1] sub_max = find_max(lst[1:]) ...
f12d31af0f7ea9cb883505e3c87de82d60a0ae2e
deepakvashist/python-search-methods
/search_methods/backends/width.py
1,814
3.90625
4
from collections import deque from search_methods.base import SearchAbstract class Search(SearchAbstract): """ A busca em largura é um algoritmo utilizado para percorrer ou buscar itens dentro das estruturas de dados grafos ou árvores. Como característica temos que a busca sempre ocorre nos filhos ou...
0f6137ed3fa0eca1ca877dc713e8526aced5d098
jack7hammer/Heap
/lexic.py
1,087
3.703125
4
import sys def heapify(A, n, r_index): least = r_index left_child_index=2*r_index+1 right_child_index=2*r_index+2 if left_child_index < n and A[r_index].lower() > A[left_child_index].lower(): least = left_child_index if right_child_index < n and A[leas...
e43aa20e8999ca7e9b27b1a4eea027b3d8cd8f8f
doandanhtu/pythonbasic
/Function/functionHW.py
682
3.5625
4
def quadEquaSolver(a: float, b: float, c: float) -> float: if a != 0: delta = b ** 2 - 4 * a * c if delta < 0: return None else: return (-b + delta ** (1/2)) / 2 * a, (-b - delta ** (1/2)) / 2 * a else: if b != 0: return -c / b else: ...
10ec07a37cf069b3148994e8d1bd7492c1d83ce2
joaoelvas/PythonTraining
/Databases/students.py
1,590
4
4
from peewee import * db = SqliteDatabase('students.db') # SqliteDatabase - The class from Peewee that lets us connect to an SQLite database class Student(Model): """docstring for Student""" username = CharField(max_length=255, unique=True) points = IntegerField(default=0) class Meta: database = db students = ...
210b72b9b403091079be911b6f47632fb0e40e34
wildmask01/algorithms
/binary_search.py
909
3.75
4
def search1(plist, needle): """ :param plist: :param needle: :return: """ if not plist: return -1 middle = len(plist)/2 if needle == plist[middle]: return middle return search(plist[0:middle], needle) if plist[middle] > needle else middle + search(plist[middle:], need...
f1f5fbad0b2c522c8f7aef42ffe5f072d193af0e
SanjeevkMishra/Generic_Training_Python_INFY
/Fundamental Programming Part 1/Assignment_Set-4/find_correct.py
1,602
4
4
''' Problem Statement: Write a python function, find_correct() which accepts a dictionary and returns a list as per the rules mentioned below. The input dictionary will contain correct spelling of a word as key and the spelling provided by a contestant as the value. The function should identify the degree of correctne...
722cec74f8c9e755fbe6b0a54499408efe67f2ab
sservett/python
/PDEV/EXAMPLES/ex002.py
217
3.546875
4
for i in range(1,int(input())): print(((10**i)//9) * i) def servet(ali): def arzu(): print("Ben Arzu") ali() return arzu @servet def ince(): print("INCEEE") ince() """ test011 """
2e69c848ed53bb620e5c459c6838ac3906a5bea8
jspw/Basic_Python
/problems/Codeforces/A. Hulk.py
373
3.734375
4
import sys n=int(input()) fast = "I " last=" it" mid=" hate " i=int(2); if n==1 : print("I hate it") sys.exit(0) else : while 1<i<=n : # print("1") if (i%2)==0 : mid = mid + " that I love " # print("2") else : mid = mid + " that I hate " ...
9948c6423dfef800a2b3aaed0e87b9cc2a6e8772
nralex/Python
/2-EstruturaDeDecisao/exercício23.py
391
4.125
4
# Faça um Programa que peça um número e informe se o número é inteiro ou decimal. Dica: utilize uma função de arredondamento. número = str(input('Digite um número: ')).replace(',', '.') n = float(número) if n == int(n): # Preferi usar o int, que ignora os calores das casas decimais. print(f'{n} é um número inteiro'...