blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
798a56aaea2d995e60715d6de56f382744998967
gioliveirass/atividades-pythonParaZumbis
/Lista de Exercicios I/Ex03.py
400
3.984375
4
# Exercicio 03 print('Exercicio 03: Calculando total em segundos.') dias = int(input('Insira a quantidade de dias: ')) horas = int(input('Insira a quantidade de horas: ')) minutos = int(input('Insira a quantidade de minutos: ')) segundos = int(input('Insira a quantidade de segundos: ')) total = (dias * 24 * 60 * 60) + ...
7eeea30f04674ceb6e21dd1b3566066177f42c9b
hanmochen/LeetCode-Solutions
/17.letter-combinations-of-a-phone-number.py
961
3.59375
4
# # @lc app=leetcode id=17 lang=python3 # # [17] Letter Combinations of a Phone Number # import itertools class Solution: def letterCombinations(self, digits: str) -> List[str]: if(not digits): return [] dicFromDigitsToLetters = {'2':['a','b','c'], '3':['d','e','f']...
e002e126cac9be92447e63ef05353b488f9c5502
choigabin/Certificate_Cospro
/cospro_winter/p28.py
208
3.75
4
li = [1, 2, 3, 4, 5] print(li) li.append(6) print(li) li.append([10, 20, 30]) print(li) li2 = [1, 2, 3, 4, 5] li2.append(6) print(li2[5]) li2.append([10, 20, 30]) print(li2[6]) print(li2[6][0]) print(li2[7])
2e309f7d86334902bda27bf71018ecf8c1ac7db1
Onewincow/Elephe_Signal_Swag
/training/7강/실습 7-5.py
406
3.796875
4
# -*- coding: utf-8 -*- def show_board(board): print() print('S','|','1','2','3','4') print('-','+','-','-','-','-') i = 1 for row in board: for x in range(len(board)): if row[x] == 0: row[x] = '.' print(i, '|', str(row[0]),str(row[1]),str(row[2]),str(row[...
c2a1981448e1622a154f2d12655ea135d7df9ff7
dooking/CodingTest
/BOJ/python/1916(최소비용구하기).py
768
3.75
4
import sys import heapq INF = sys.maxsize input=sys.stdin.readline N= int(input()) M= int(input()) graph=[[] for _ in range(N+1)] queue = [] distances = [INF]*(N+1) def dijkstrat(graph,start): distances[start]=0 heapq.heappush(queue, (distances[start], start)) while queue: current_distance, current...
90fe41030ed34b80c7b30296b4919ee67e5e774a
Adavellisahaja/Python
/Lab1/task2.py
421
4.28125
4
#@title Task 2 dict1 = {'a':21,'b':43,'c':22} dict2 = {'c':43,'d':2,'e':8} #this is simple concatenation of dictionary #last value of same key will be the final concDict = {**dict1,**dict2} print (concDict) #concatenation of dict. by merging values of same key mergeDict = {**dict1,**dict2} for key,value in mergeDict...
1e3be0b9f026b20d9d0f2a29122e88432765d90e
salmanfazal01/210CT
/question 1.py
598
4.125
4
import random def question1(userList): print("\nEntered List: " + str(userList)) #original list newList = [] #empty list to append random numbers for i in range( len(userList) ): random_number = random.choice(userList) #select random original list newList.append(random_...
973208dccc4e82fa573626baa4b94ed61823c45b
HenryBalthier/Python-Learning
/Leetcode_medium/string/43.py
1,404
3.515625
4
class Solution(object): def multiply(self, num1, num2): """ :type num1: str :type num2: str :rtype: str """ if num1 == '0' or num2 == '0': return '0' if num1 == '' or num2 == '': return '' def addstr(n1, n2): if n1 ...
b612e03ae1c83a05d493ab8448b2a75a5dd41275
OMGfox/vk_bot_template
/flights.py
9,261
3.640625
4
""" weekly = (tuple of days_of_week, where days_of_week are numbers from 0 to 6) monthly = (tuple of days_of_month, where days_of_month are numbers from 1 to 31) date = (if weekly and monthly are None then date is using, date type is datetime.date) time = time of flight. The type is datetime.time """ from copy import d...
5fd531de22bc9c7bf6fbd17dbe6aee3e5226137b
ChingisM/python-project-lvl1
/brain_games/games/progression.py
1,063
3.84375
4
import random # Description for the brain-game engine. DESCRIPTION = 'What number is missing in the progression?' def generate_progression(start, diff, length): """Return a generated arithmetic progression.""" progression = [start] new_element = start for i in range(1, length): new_element +=...
814993e2a3f10661ab48bb1e30cd5b36b9fd2b60
dbconfession78/holbertonschool-webstack_basics
/0x01-python_basics/3-no_c.py
324
4.125
4
#!/usr/bin/python3 """ Module 3-no_c """ def no_c(str): """ Description - removes all instances of 'c' and 'C' from a str :param str: the string to remove c's from """ while True: x = str.lower().find('c') if x == -1: break str = str[0:x] + str[x+1:] return ...
618f1311ee04233f679c1160f1d7b8203e36b1ca
johebuck/Algorithms-Analysis
/Algorithms & Analysis/sort/insertion/insertion_sort_ordered.py
628
4.125
4
#NAME: John Buckley #DATE: 9/17/17 #PROJECT: Programming assignment 1: ordered input #PROGRAM: Takes an input, n, and makes a sorted list from 0 to n and outputs the original and sorted lists def insertionSort(alist): for index in range(1,len(alist)): currentvalue = alist[index] position = index...
f4fe1984bb2043d9d7b971d68cb74dad693fe796
fabriciotorquato/pyxavier
/xavier/lib/emokit/util.py
16,357
3.5625
4
# -*- coding: utf-8 -*- import platform import struct import sys system_platform = platform.system() if sys.version_info >= (3, 0): # pragma: no cover unicode = str def is_extra_data(data): if ord(data[1]) == 32: return True return False def bits(bytes): """ Helper function to get a t...
a79c3d0aa902784f7268f89a4e2ff72b118c99ff
BurnySc2/leetcode-solutions
/python_src/073.py
1,618
3.921875
4
""" Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. https://leetcode.com/problems/set-matrix-zeroes/ """ from typing import Set, Tuple, List, Generator, Dict from collections import Counter class Solution: def setZeroes(self, matrix: List[List[int]]) -> None: ...
adf31889265b3fb8e42befabb624b27175c843b8
shemetz/advent_of_code_2017
/day_3.py
1,743
3.75
4
import operator from typing import Tuple, Dict, List input_number = 347991 directions: List[Tuple[int, int]] = [(+1, 0), (0, +1), (-1, 0), (0, -1)] def day_3(): def part_1(): step_size = 1 current = 1 position: Tuple[int, int] = (0, 0) i = 0 while True: direct...
8455a62bf3e6d3e874835b6d47db37142722b03a
TimothyID/speech-recognition
/jarvis.py
3,770
3.53125
4
#1). make calculator from tkinter import * import speech_recognition as sr import time import os import random import datetime import webbrowser import sys import re from pygame import mixer jokes = ["Did you hear about the restaurant on the moon? Great food, no atmosphere.", "What do you call a fake noodle? An Impa...
80d29d53afd743dfa1e7fd293466e4b44926b1bb
ariomer/Python-Basics
/Exercise_110.py
281
3.90625
4
# -*- coding: utf-8 -*- """ Created on Wed Jun 17 15:16:06 2020 @author: ts-omer.ari """ num_list = [45, 55, 60, 37, 100, 105, 220] # use anonymous function to filter result = list(filter(lambda x: (x % 15 == 0), num_list)) print("Numbers divisible by 15 are",result)
740b0850cc1aaa847b14ba7fd1d9ca9c75a1d53c
omar-osario/EulerProject
/Euler034.py
499
3.5
4
import time from sets import Set from math import factorial starttime = time.time() def sumOfDigitFactorial(n): testsum = 0 numberstring = str(n) for x in range(len(numberstring)): testsum += factorial(int(numberstring[x])) if testsum == n : return 1 return -1 upperlimit = 295245 sum = 0 ...
8fec8855829727aeaa9aab429a8eb549abc2ca05
SUBZEROCODE/MODATools
/PrimeHunt.py
961
3.796875
4
import BasicPrime import ComplexPrime import TestSuite mode = 0 def setup(): global mode print("Do you want to use") print("1: Basic") print("2: Complex") choice = raw_input("Do you want to use 1:Basic or 2:Complex:") choice = int(choice) if(choice == 1): mode = 1 elif(choice == 2): mode = 2 else...
2e27555ae493715f36301497be73b1d78cbb986c
Punkrockechidna/PythonCourse
/python_basics/logic/first_gui.py
888
3.890625
4
#Exercise! #Display the image below to the right hand side where the 0 is going to be ' ', and the 1 is going to be '*'. This will reveal an image! picture = [ [0,0,0,1,0,0,0], [0,0,1,1,1,0,0], [0,1,1,1,1,1,0], [1,1,1,1,1,1,1], [0,0,0,1,0,0,0], [0,0,0,1,0,0,0] ] # picture_render =[[]] # print(picture[0]) # ...
5d08928031b36830d898da03c410df836aa412ff
GJHarty/udemy-projects
/product_inventory.py
857
4
4
# Define a Product class. Objects should have 3 variables for price, code, and quantity class Product: def __init__(self, price=0.00, code='aaaa', quantity=0): self.price = price self.code = code self.quantity = quantity def __repr__(self): return f'Product({self.price...
1b559d54967e9ce4868378cfe0f60b0d2413a991
409085596/TallerHC
/Clases/Programas/Tarea07/Ejercicio05.py
1,156
3.828125
4
# -*- coding: utf-8 -*- '''Diseñe y programe un algoritmo recursivo que encuentre la salida de un laberinto, teniendo en cuenta que el laberinto se toma como entrada y que es una matriz de valores True, False, (x,y), (a,b), donde True indica uno bstáculo; False, una celda por la que se pued...
15a0b0c9b2cbf86a5a075c6a987d4b8d5129302f
rishabhsharma015/python_programs
/Prime_Number_in_a_given_range_2.py
327
4.125
4
# Printing Prime numbers in a given range def isPrime(num): for i in range(2, num): if num%i==0: break else: print(num,end=" ") a = int(input("Enter the lower bound: ")) b = int(input("Enter the upper bound: ")) for i in range(a, b+1): if(i!=1): isPrime(i...
7cdc8175f57e76d901f24fb6f4571e8f30acbb79
weezer/fun_scripts
/testPydev/81. Search in Rotated Sorted Array II.py
955
3.703125
4
class Solution(object): def search(self, nums, target): """ :type nums: List[int] :type target: int :rtype: bool """ left = 0 right = len(nums) - 1 while left <= right: mid = (left + right) / 2 if nums[mid] == target: ...
a8065a9461051c8e935cb9b75baf3190e9ac07c0
cliff538/Plotly_Dash_MainProject
/1_numby_pandas_basics.py
2,785
4.34375
4
""" Udemy "Interactive Python Dashboards with Plotly and Dash Course 10/25/2020 """ import numpy as np # NumPy crash course. mylist = [1, 2, 3, 4, 5, 6, 7] print(np.array(mylist)) print(type(mylist)) # makes an array out of a list. arr = np.array(mylist) print(arr) print(type(arr)) a = np.arange(0, 10) print(a) ...
7a6f73020038f2d48eeab9a772cfbc3b8836ac71
hudefeng719/uband-python-s1
/homeworks/A16202/checkin07/day13-homework_02.py
1,342
3.640625
4
#!/usr/bin/python # -*- coding: utf-8 -*- # @author: xxx def buybuybuy(): who = '0000的老妈' good_price = 5 #小贩的价格 good_description = '西双版纳大白菜 ' #小贩的招牌 is_cheap = False #是否便宜 reasonable_price = 5 #老妈能接受的最高价格 buy_amount = 2 #准备买两斤 total_price = 0 #买菜一共花的钱 print ' %s上街看到了%s,卖 %d 元/斤 ' %(who, good_description, g...
be63a4d16282975ebb7a51405c5999c186cad08e
sunx2/codes
/python/sun.py
157
3.953125
4
while True: number = int(input(">> ")) print("\n") for i in range(0,10): print(f"{number} x {i} = {number*i}") print("\n")
1762fa39f1fc2327c436d1fc905503f2c9f104cb
MingkaiMa/Python-Translator
/test00.py
407
4.03125
4
#!/usr/bin/python3 print("hello,world") print("hello, world", 1, 2) y = "hello" print(y) print("hello", 1, 2, end='end') print('y = ') print(1,2,3, sep=';') print("test", "is", "kind", "of", "challenging", sep=";", end="haha") print(1+3) print("this is addition", 1+ 3) print("this is multiplication->:", 8 *9) p...
126e3c3190f15c79eb3419ed9d0246cb0cf8d135
wellington16/BSI-UFRPE
/2016.1/Exércicio LAB DE PROGRAMAÇÃO/Exercício 2016.1/Exercícios/E4/TabuleiroemClasse.py
1,437
3.796875
4
class cavalo: def __init__(self,x,y): self.x = x self.y = y def mov(self,numero): if numero == 1: self.x += 1 self.y += 2 elif numero == 2: self.x += 2 self.y += 1 elif numero == 3: self.x += 2 self....
00527b12b0a50a8fe4d0a1a2f2fdfaa311737c65
kshestakova/homework
/2_3.py
457
3.96875
4
""" Создайте словарь, в котором ключи - разные числа, значения - рандомные числа (любые). Напишите генератор списка из элементов-произведений “ключ” * “значение”. """ from random import randint d = {} for i in range(100): d[i] = randint(0, 1000) l = [key * value for key, value in d.items()] print(d) pri...
515a2dfe1391d63baf39439673644cb262cbb985
ackers93/code-challenge
/python/firstNotRepeatingCharacter.py
1,812
4.15625
4
# Given a string s consisting of small English letters, find and return the first instance of a non-repeating character in it. If there is no such character, return '_'. # Example # For s = "abacabad", the output should be # first_not_repeating_character(s) = 'c'. # There are 2 non-repeating characters in the string...
5893e7cc91f712fda66c84698657ae9635c08332
Lamozaur/SDP
/Program/Krotki.py
77
3.65625
4
# 3.18 t = ('a','b','c','d','e') print t print t[0] print t[-1] print t[1:3]
e2cf2d5ca84bc215378c6e40197123c0b8f4c8e2
tmdgusya/PythonAlgorithmInterview
/src/longest_palindrom/case_one.py
628
3.734375
4
import unittest def get_longest_palindrom(pharse: str): global result # using two pointer def expand(left: int, right: int) -> str: while left >= 0 and right < len(pharse) and pharse[left] == pharse[right]: left -= 1 right += 1 return pharse[(left + 1):right] ...
cb8a3b70f279a35f9bbb75ac235d33e9ac476cbc
alexistenorio/labodega
/gnomeSort.py
282
3.796875
4
def gnomeSort(array): pos = 0 while pos < len(array): if (pos == 0 or array[pos] >= array[pos - 1]): pos += 1 else: #Begin swap aux = array[pos] array[pos] = array[pos - 1] array[pos - 1] = aux #End swap pos -= 1 return array
27db28d422ae0ae841833fd7242b43c9dc43dffb
roopabdr/python-practice
/input_demo.py
738
4.15625
4
# name = input('Enter a name: ') # print('Hello',name) # num = input('Enter a number: ') # num += 2 # print(num) # errors # num = int(input('Enter a number: ')) # num += 2 # print(num) # works # num = int(input('Enter a number: ')) # num += 2 # print(num) # errors if input is a float like 2.5 # num = float(input('E...
26269f8bea9f9148a928530d9f7ca7af196e5e56
Haidram/codeforces_prblm_solutions
/math problem.py
95
3.609375
4
n = int(input()) if n%2 == 0: print("4 " + str(n-4)) else: print("9 " + str(n-9))
f2947be5a9300b43cb9768c5727fe845a9a5c722
fsarachu/python3-essential-training
/01 - Quickstart/2_conditionals.py
226
4.1875
4
a = 0 b = 1 if a < b: print('a ({}) is less than b ({})'.format(a, b)) else: print('b ({}) is less or equal than a ({})'.format(a, b)) print("foo" if a < b else "bar") # Ternary operator-like conditional expression
558c6831acbd9c311d3736a7a9620f4570cb89ce
DavidTaylor96/UnitTesting_pet_shop
/src/pet_shop.py
3,039
3.625
4
# WRITE YOUR FUNCTIONS HERE # Make a function that return the pet shop name. def get_pet_shop_name(pet_shop): return pet_shop['name'] # get the total cash def get_total_cash(pet_shop): return pet_shop['admin']['total_cash'] # Add to the dict def add_or_remove_cash(pet_shop, add): pet_shop['admin']['total_cash'...
eeeea8e40f5900c1becd0cf1738ac49f142f18f0
sshukla31/misc_algos
/quick_sort/quick_sort.py
809
3.921875
4
def quick_sort(table, left, right): i = left j = right pivot = table[(left + right) / 2] while(i <= j): # Case 1: Keep incrementing left index 'i' until i > mid while(table[i] < pivot): i += 1 # Case 2: Keep decrementing right index 'j' until j < mid while(pi...
5edf74efa1f494cdfbf37f98e05cea1c046ad20b
m0hanram/ACADEMICS
/clg/sem4/PYTHONLAB/psbasics_1/ps1basic_9.py
258
3.875
4
n = int(input("enter the number of elements : ")) array = [] for i in range(n): array.append(int(input("Enter the element : "))) array.sort() sumEle = 0 for i in range(1, n-1): sumEle += array[i] centeredAvg = sumEle/(len(array)-2) print(centeredAvg)
f1aa90f5655a4b44fd8a40f7516dd3b66e2840b3
yinhaolin-bot/FCND-Motion-Planning-1
/colinear.py
1,491
3.578125
4
# coding: utf-8 # ## Finding Your Way In The City # # In this notebook you'll combine the work of previous exercises to calculate a minimal series of waypoints in order to get from a start location to a goal location. # # You'll reuse and modify your algorithms from: # # - A* # - Configuration Space # - Collineari...
884c46d225ce705453b8348bf0b7426f014802d8
rehan-bhatia/codeforces_div2_A
/Petya and Strings.py
105
3.84375
4
a = input().lower() b = input().lower() if a<b: print(-1) elif a==b: print(0) else: print(1)
c54d244c995e70ba1fccdaaf81578b2472b58547
git-vish/leetcode-python
/Problems/bin_alternating_bits.py
306
3.53125
4
__author__ = 'Vishwajeet Ghatage' __email__ = 'cloudmail.vishwajeet@gmail.com' __date__ = '05/02/2021' def solution(n: int) -> bool: i = n % 2 n = n // 2 while n: if i == n % 2: return False i = n % 2 n = n // 2 return True if __name__ == '__main__': N = 10 ...
5204e41d70817d3d9e5f9381f4c2ded3a873cce3
EEdwardsA/lambdata
/lambdataeedwardsa/assignment_module.py
949
3.625
4
import pandas as pd import numpy as np df = pd.read_csv('../data/ramen-ratings.csv') target = 'Top Ten' def wrangle_df(df): """ This wrangle function counts null values and creates a train_test split based on your 'target' variable Before running this function, assign a column name to the variable ...
f7a50ab309746190d025b66a4e60372cd2ef0414
hyattden/Programming-Practice
/uva/uva_495.py
1,005
3.8125
4
''' /* UVa problem: 495 * * Topic: Number Theory * * Level: challenging * * Brief problem description: * * Given sequence of numbers of numbers in range 0-5000, output that fibonacci number * * Solution Summary: * * Pre-compute first 5000 fibonacci numbers, store in list, output * * Used Resources: ...
fcd24d4402a642cfece67da56673f83d82991358
afelHipHop/Arboles
/aBinarios.py
1,657
3.59375
4
class Nodo: def _init_(self, numero=None, izq=None, der=None): self.numero = numero self.izq = izq self.der = der def _str_(self): return "%s" %(self.numero) class aBinario: def _init_(self): self.raiz=None def Agregar(self, elemento): if self.raiz == None: self.raiz = elemento e...
564e43d5d349027bcef5a6284c024052da9c9e8c
namansubedi/miniproj
/iterative.py
887
3.53125
4
from time import perf_counter_ns from rich import print def find(L, target): start = 0 end = len(L) - 1 while start <= end: middle = (start + end)// 2 midpoint = L[middle] if midpoint > target: end = middle - 1 elif midpoint < target: start = middle +...
0f80f974342341cc08a441cf1179c7b7db4a4140
valeyandre01/Termodin-micaI
/TareaProgramada_ValeriaB_AndreaDLP.py
5,410
3.5
4
import random import numpy as np from matplotlib import pyplot as plt global s ###matriz original de ceros:### ###a esta se le agregará en el centro la de unos de 10x10### cafenegro = np.zeros((100, 100)) ###matriz para subdividir los pasos guardados### ###(mejor explicación en la función dividir### cafe = n...
25e694dbc86cec56cc4785df19448308cb9f76e7
zyga/arrowhead
/examples/tutorial5.py
2,591
4.03125
4
#!/usr/bin/env python3 """ Tutorial Lesson 5 ================= This is the fith tutorial arrowhead program. This is a dummy program building on the previous lesson. It introduces one more element but is really just more complex than previous examples so that you can play around with the graph viewer. So the new thin...
92e76110da1669ff54aa68e9750cac6467f0cec8
sheauyu/sapy
/src/code_quantlets/generate_events.py
2,471
3.546875
4
""" Generate data for Chapter 6: Exercise 1 Saves the data to 'S6_1_data.npz' These data can be retrieved with the command new_data = np.load('S6_1_data.npz') """ # author: Thomas Haslwanter # date: April-2021 # Import the required packages import numpy as np import matplotlib.pyplot as plt fr...
78ebe748bd92952367ccabaa58bd9a26f574a239
ZhiquanW/Learning-Python-HackerRank
/Basic-Data-Types/Nested-Lists.py
955
3.640625
4
solution = 1 if solution == 1: a = [[input(), float(input())] for i in range(int(input()))] s = sorted(set([x[1] for x in a])) for name in sorted(x[0] for x in a if x[1] == s[1]): print (name) elif solution == 2: import operator if __name__ == '__main__': markSheet = [] nameS...
d75fbbd2040fd70a7301b42bc405a56553eaab1f
jinurajan/Datastructures
/LeetCode/mock_interviews/x_of_a_kind_in_a_deck_of_cards.py
1,322
3.765625
4
""" X of a Kind in a Deck of Cards In a deck of cards, each card has an integer written on it. Return true if and only if you can choose X >= 2 such that it is possible to split the entire deck into 1 or more groups of cards, where: Each group has exactly X cards. All the cards in each group have the same integer. ...
8b6531d6439f9ef8670ca256efd4d2d817006e5e
RianRBPS/PythonMundos
/Exercícios/Mundo01 001-035/ex034.py
531
3.9375
4
#Escreva um programa que pergunte o salário de um funcionário e calcule o valor do seu aumento. # Para salários superiores a R$1250,00, calcule um aumento de 10%. # Para os inferiores ou iguais, o aumento é de 15%. salario = float(input('Qual o salário do funcionário? R$')) if salario > 1250: aumento = salario * 0...
0481decb204b0d916ea832eaba3ad47c88bd08ac
aviranjan2050/share1
/coding_challenge5.py
263
4.03125
4
def divison(dividend , divisor): try: print(dividend/divisor) except ZeroDivisionError: print("division by zero is not allowed") dividend = float(input("enter dividend")) divisor = float(input("enter divisor")) divison(dividend, divisor)
0d2c28667da2776df4a56f6e8a599a4ebbd0168e
snpushpi/CTCL-Solutions
/remove_dup.py
404
3.703125
4
class Node(): def __init__(self,data,next): self.data = data self.next = next def remove_duplicates(head): node = head if node: values = {node.data:True} while node.next: if node.next in values: node.next = node.next.next else: ...
15267e75ad4510a9dde320066585cb21d9d1009c
guilherme-witkosky/MI66-T5
/Lista 3/L3E11.py
495
3.90625
4
#Exercício 11 num1 = input("Informe o primeiro número: ") num2 = input("Informe o último número: ") soma = 0 if int(num1) <= int(num2): primeiro = int(num1) ultimo = int(num2) else: primeiro = int(num2) ultimo = int(num1) while primeiro <= ultimo: soma = soma + primeiro primeiro += 1 print(...
463c6569dba827a411faf8de0dd8223ef6dca75c
RaimundoGallino/holbertonschool-low_level_programming
/0x1C-makefiles/5-island_perimeter.py
544
3.875
4
#!/usr/bin/python3 """ Defines an island perimeter measuring function """ def island_perimeter(grid): """returns the perimeter of the island described in grid""" edges = 0 size = 0 for i in range(len(grid)): for j in range(len(grid[i])): if grid[i][j] == 1: ...
399b615fb7a2488e24c6d26bf7d386ac70612589
Ganushkevych/Practice-2
/Practice_15_КМ-02_Ganushkevych/factorial/factorial.py
329
3.796875
4
def fact(n): try: n = int(n) if n<0: raise ValueError elif n==0: return 1 if n==1: return 1 else: r= n*fact(n-1) return r except ValueError: print("Введіть натуральне число")
5415f57aeb4541301432747e03b661aa58151531
Wiilz/Python-learning
/Chapter13/Practice 13-4.py
391
3.84375
4
def addUpChange(quarters, dimes, nickels, pennies): total = 0.25 * quarters + 0.10 * dimes + 0.05 * nickels + 0.01 * pennies return total quarters = int(raw_input("quarters: ")) dimes = int(raw_input("dimes: ")) nickels = int(raw_input("nickels: ")) pennies = int(raw_input("pennies: ")) total = addUpChange(q...
9208fa14724a27e8e9f9927c2038a8661e44f94d
filippopiconese/python3-experiments
/beginner-exercises/find-divisible-and-not-multiple-numbers/app.py
468
3.921875
4
''' Question: Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5, between 2000 and 3200 (both included). The numbers obtained should be printed in a comma-separated sequence on a single line. ''' min = 2000 max = 3200 divisible = 7 multiple = 5 numbers = [] for numb...
d33381e3d5c54ef909b84b9ca3070fa565fc31bc
paulchew/Citi-Hackoverflow-2022
/init_db.py
1,129
3.59375
4
# code to initialise customer database # contains 4 tables # loyalty for storing loyalty points of user (col names: userID, loyaltyPoints) #users for storing details of users and their vouchers they own (col names: userID, userPW, voucherID, voucherAmount, vendorID) #vendors for allowing vendors to check vocuhers they ...
484303f2fa0323e0373693224f03cb37aab3ae03
G3Kaliaperumal/PythonDeveloperCourse
/Testing/randomgame.py
871
4.03125
4
import sys from random import randint def is_the_guess_correct(guess, answer, start, end): if guess < start or guess > end: print(f'Please only select numbers between {start} and {end}!') return False if answer == guess: print(f'Woah!! You are a genious ;)') return True els...
3b35134c86ef9575852a60a8a4d8a6aae08a5502
aws108/Introduction_to_python
/02- ejercicios/Sesión 3/ex1.1.py
837
3.84375
4
#! /user/bin/python # -*- coding: utf-8 -*- # > < import random #crei una llista amb 10 valors aleatoris entre 1 i 5. lista = [] for x in range(1,11): valor = random.randint(1,5) lista.append(valor) print "llista amb 10 valors aleatoris entre 1 i 5" print lista #inserti un element al final amb el maxim valor de la...
8ef5763e42500e40a3ffbe74a31a2f2f6079bc4f
AntonMaxen/adventofcode2020
/day6.py
1,528
3.6875
4
def get_groups(): with open("files/day6input.txt") as my_file: lines = [line.strip() for line in my_file.readlines()] groups = [] group = [] for line in lines: if line == '': groups.append(group) group = [] else: group.append(line) if grou...
e34305e5b341685313c919f8b046d117d5017b54
abhinit75/PythonPlaylist
/PythonAlgorithms/Minesweeper.py
206
3.859375
4
""" import numpy as np n = int(input("n: ")) # rows m = int(input("m: ")) # columns arr = np.zeros((n, m)) print(arr) for i in arr.flat: a = input() np.where(arr == 0, a, arr) print(arr) """
585f37af22f61cc96d5a6428ef8059d2cbbd7622
vasile04/Introducere_Afisare_Calcule
/Problema4.py
723
4
4
#Un brăduţ este împodobit cu globuleţe albe, roşii şi albastre. Numărul globuleţelor albe se citeşte de la tastatură. Câte globuleţe are brăduţul, ştiind că numărul de #globuleţe roşii este cu 3 mai mare decât numărul de globuleţe albe, iar globuleţele #albastre sunt cu 2 mai puţine decât totalul celor albe şi roşii....
3729df702533586950bcc45e5c8ce0bbb7869e20
jschnab/leetcode
/sets/min_common_value.py
1,253
4.09375
4
""" leetcode 2540: minimum common value Given two integer arrays A and B, sorted in non-decreasing order, return the minimum integer common to both arrays. If there is not common integer amongst A and B, return -1. """ def min_com(A, B): """ Since arrays are already sorted, we compare array elements pairs wit...
7ca0ff04482489b90b71b36e70f95b2111472cd2
ShaunSEMO/wtc_minesweeper
/minesweeper_question.py
1,101
4.0625
4
import random print("Welcome to Minesweeper! \nTo play, please enter your name, board dimensions and number of bombs \nRemeber the number of bombs cannot exceed the board dimensions.") print("\n") name = input("Name: ") input_board_dim = int(input("Board dimension(Enter number only): ")) input_bomb_num = int(input("N...
77eb64c6243ad773ab6bf39b4c27200c3e9574c6
DilipBDabahde/PythonExample
/Assignment_2/Pattern4.py
350
3.984375
4
""" 8).Write a program which accept one number and display below pattern. Input: 5 Output: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 """ def Pattern4(iNo): for i in range(0,iNo): for j in range(0,i+1): print(j+1,"",end=""); print(""); def main(): ival = int(input("Enter a val: ")); Pattern4(ival); if __n...
31f2a8020a2a067c8da57f47216dae4d76f570c3
blackplusy/public
/例子-0308.05.字典操作.py
690
3.65625
4
#coding=utf-8 dic={'name':'gaga','QQ':110} dic2={'age':19} print(dic) print(dic['name']) print(dic['QQ']) dic={'name':'gaga','QQ':110} print(dic) dic['name']='simida' print(dic) dic['QQ']=500 print(dic) dic={'name':'gaga','QQ':110} print(dic) del dic['name'] print(dic) del dic #print(dic) di...
7e05fb84653ed54b948ffb38a02592610a3e8b44
jamtot/LearnPythonTheHardWay
/ex45/atDoor.py
1,534
3.734375
4
from room import Room from dead import Dead from comeIn import ComeIn class AtDoor(Room): def enter(self): print "LOCATION: AT FRED'S DOOR" print "You knock on the door." print "......" print "Fred, the neighbour answers the door." print "\"Oh hi there Bill. What can I ...
daa0ae82a020b4899abd453fc50015418eaf2fc4
naspredam/simple-chat-bot
/engine/infrastructure/repository.py
551
3.515625
4
from pathlib import Path import sqlite3 def create_connection(sqllite_file): """ create a database connection to a SQLite database """ conn = None try: conn = sqlite3.connect(sqllite_file) print(sqlite3.version) finally: if conn: conn.close() if __name__ == '__mai...
ff917dc52d724308fbbf2b8313d17d3899f0ae1d
JUNGEEYOU/Python-Basic
/chap1.Value&Data_Type/8_Variable.py
723
4.03125
4
#8. 자료형의 값을 저장하는 공간, 변수 from copy import copy a = 3 # a는 3 객체가 저장된 메모리의 위치를 가리킨다. / 3이 메모리에 생성됨! b= 3 # 같은 값을 참조함! #변수를 만드는 여러가지 방법 a,b =('jung','love') print(a) print(b) c = d = 'python' print(c) # 메모리에 생성된 변수 없애기 : del(a) # 리스트를 변수에 넣고 복사할 때 a = [1,2,3] b=a #같은 값을 참조하게 바뀜 그래서 a만 변경해도 같이 변경함 a[1] = 4 print(a) pr...
a7ca8d4b44ebc5f2c4ced55c649fca809610430c
pratham12345/python-practice
/Qr.py
178
3.578125
4
starts_with = lambda x: True if x.startswith('P') else False print(starts_with('Python')) starts_with = lambda x: True if x.startswith('P') else False print(starts_with('Java'))
1df66f8d5e7780da99a8f3fff360048a672a4aa8
dWang0/CS4341
/Assignment2/GeneticAlgorithm1.py
641
3.859375
4
import csv import math def readcsv(name): temp_input = [] with open( name, 'rt') as csvfile: input_reader = csv.reader(csvfile, quotechar='|') for row in input_reader: temp_input.append((int(row[0]))) # print ("Temp is:",temp_input) return temp_input def readcsv_float(nam...
e485ce5a9a09e0888d652af1f08fdb53360b8597
danieltshibangu/Mini-projects
/lot_num_gen.py
780
4.125
4
# this program will generate random numbers # for lottery then prints them # import the random module import random # define constant varibles # both up 1 for program limits PLACE_LIMIT = 8 NUM_LIMIT = 9 def main(): numbers = [] lottery_num = '' # create for loop that appends # 7 random numbers to n...
21df3b8ce4ccfcd3cfe9388da4cbd6930f19304b
idolustig/school
/03_Python/3.1.py
187
3.8125
4
hrs = raw_input("Enter Hours:") h = float(hrs) rate = raw_input("Enter Rate:") r = float(rate) if h > 40 : pay = (1.5 * r * (h-40)) + (r * 40) else : pay = r * h print pay
63639ffbc997aba2df936190430474f765511617
AndreaG93/Visibility-Degree-Graph
/AcyclicDirectGraph.py
5,390
3.625
4
''' Created on 01 gen 2018 @author: Andrea Graziani - matricola 0189326 @version: 1.0 ''' from abc import ABCMeta, abstractmethod from Queue import Queue class AcyclicDirectGraph(object, metaclass=ABCMeta): ''' This class represents a simple acyclic direct graph. ''' def __init__(se...
9c6d85e5f728e512b6f136fa7d685af1a702d418
inauski/SistGestEmp
/Tareas/Act01. Variables, ES y operaciones/ejer01/ejer01.py
215
3.828125
4
print ("Calculo de la media de dos numeros") a = int(input("Escribe un numero ")) b = int(input("Escribe otro numero ")) print ("La media aritmetica de " + str(a/1.0) + " " + str(b/1.0) + " es " + str((a + b)/2))
b1e40116f6690639136504c83e0e1997844e08d5
DJSiddharthVader/PycharmProjects
/PythonPractice/26. tic tac toe check.py
1,147
3.9375
4
''' make tic tac toe ''' import numpy as np gameover = False board = np.arange(2,20,2).reshape(3,3) for a in board: a = '' turncount = 0 def reset(): gameover = False for a in board: a = '' while gameover == False: print("0 goes first") winner = False play...
5ab8eb4a2cf8853cb54b63e13614819d59132a0f
chavp/MyPython
/learning_python/part_2/strings.py
704
3.578125
4
S = 'Spam' print(len(S)) print(S[0]) print(S[3]) print(S[-1]) print(S[1:3]) print(S[1:]) # slice 1:len(S) print(S[:2]) # 0:2 print(S + 'xyz') print(S * 8) L = list(S) L.extend('xyz') print(L) print(S.find('pa')) S.replace('xyz', '') print(S) line = 'aaa,bbb,ccccc,dd' print(line.split(',')) print(S.isalpha()) C = '...
834a9af15325f6e3a0a88c9196382cfbc2475ebb
yaleshen0/Algorithms
/LEETCODE/90.py
1,427
3.75
4
# Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set). # Note: The solution set must not contain duplicate subsets. # Input: [1,2,2] # Output: # [ # [2], # [1], # [1,2,2], # [2,2], # [1,2], # [] # ] class Solution(object): def su...
ad80806871fee5930e1d205dcdb04705693cf375
saurabhp46/ClockHandAngle
/ClockHandsAngle.py
516
4.0625
4
def findAngle(hour, mins): # find the position of the hour's hand h = hour * (360 // 12) + mins *((360 // 12) / 60) # find the position of the minute's hand m = (mins * 360) // (60) # calculate the angle difference angle = abs(h - m) # consider the shorter angle and return...
2deade622852d6341dc71da01656695b1d16d9f7
tirthankarkundu17/CSV2VCF
/ConvertCSVtoVCF.py
1,561
3.703125
4
import csv import os def createContactsDirectory(): file_path = "./contacts" #put the path as per your choice if not os.path.exists(file_path): os.mkdir(file_path); def convert(fileName): count = 0 with open(fileName) as csvfile: createContactsDirectory() spamreader = csv.read...
9c7da5826453545bb9420aad21f8381a838c4670
psteyer/Python3BootCampClass
/Section_26_OOP_Part_2/simple_inheritance.py
426
4
4
class Animal: cool = True def make_sound(self, sound): print(f"this animal says {sound}") # Cat class inherits from Animal class Dog(Animal): pass # Make a new dog instance Odin = Dog() # Because of inheritance, a dog has access to: Odin.make_sound("Woof") print(Odin.cool) #odin is both a dog and Animal (and...
01f4eb3bcd49ef631aa933aa38b64e42a3c585c4
Varnei/SOLID_LL_Learning_SOLID_Programming_Principles_Steven_Lott
/ch02/ch_02_isp.py
7,148
3.546875
4
"""S.O.L.I.D Design. Chapter 2. ISP. """ import random # 02_01_isp class Card: def __init__(self, rank, suit): self.rank= rank self.suit= suit self._text= "{:2d}".format(self.rank) def __str__(self): return "{_text:>2s}{suit}".format_map(vars(self)) def __repr__(self): ...
06fd29de1f04ff47a3a9b0a1d66278b37d1c1fcd
danhdoan/project-euler
/solutions/eulerlib.py
1,895
3.75
4
""" Euler Library ============= Support library for solving ProjectEuler problems """ # ============================================================================== def numToList(x): """Convert an integer to list in reversed order""" if x == 0: return [0] lst = [] while x > 0: lst.append(...
79ed0dce3db71fc2260e494dc72845e9a9117a79
valleyceo/code_journal
/1. Problems/h. Sort & Search/a. Binary Search - Median of Two Sorted Arrays.py
1,913
3.875
4
# LC 4. Median of Two Sorted Arrays ''' Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). Example 1: Input: nums1 = [1,3], nums2 = [2] Output: 2.00000 Explanation: merged array = [1,2,3] and media...
a6c6a79b92390f9c82e9e500a62b2bf3c2c0ee24
gwascak/LearningPython
/ex11.py
855
4.46875
4
# Here we print out a line. print "How old are you?", # Here we define a variable called age and then we ask for the user to input info. # That info is stored in the variable age. age = raw_input() # Here we print out a line. print "How tall are you?", # Here we define a variable called height and then we ask for the u...
228a2c95382035880b04d3024f2ba31b17dd6914
heySourabh/MyWebpage
/cff/chap01/files/code/q11.py
926
3.734375
4
# Copyright (c) Sourabh Bhat # Computer programs to solve problems from Compressible Fluid Flow (P. Oosthuizen, W. E. Carscallen) # Program written by Sourabh Bhat (mail.spbhat@gmail.com) # Chapter 1, problem 11 from lib.geometry import area_circle # Given data: Ve = 750 # m/s me = 350 # kg/s pe = 75e3 # Pa De = ...
aaf6d6dc5574777bfa3d1bab9e0f460fd3a493bb
hsaglamlar/flight-club
/main.py
1,784
3.90625
4
# This file will need to use the DataManager,FlightSearch, FlightData, NotificationManager classes to achieve the # program requirements. import data_manager from flight_data import FlightData from notification_manager import NotificationManager from flight_search import FlightSearch import pprint #instance for sendi...
4a80a6ddad9b72a6f83698c8dbb968ae968b397b
RookieBoi/PyUnittest
/square.py
667
3.84375
4
class square: def __init__(self, length=0): self.length = length def getArea(self): if type(self.length) not in [int, float]: raise ValueError("Square length should be non-negative real number") if self.length <0: raise ValueError("Square length should be non-neg...
181597fdd2286c2731b7269183ff541505e7932c
adam147g/ASD_exercises_solutions
/Graph algorithms/31_tree_of_the_shortest_paths.py
1,152
3.671875
4
# We are given a weighted graph G and a spanning tree T that contains the vertex s. Find algorithm that # checks if T is a tree of the shortest paths from the vertex s. from queue import PriorityQueue from math import inf def relax(distance, u, v): if distance[v[0]] > distance[u] + v[1] and distance[v[0]] != inf:...
74934e2055453e60de4a5fbaff67829e5ecfed17
BhavyaKanodia/smtp-mail-system
/smtp/mail.py
831
3.9375
4
class Mail: """ Class for describing an email message. """ def __init__(self, sender_ID, receiver_ID, timestamp, subject, body): self.sender_ID = str(sender_ID) self.receiver_ID = str(receiver_ID) self.timestamp = str(timestamp) self.subject = str(subject) self....
a65633eb62363b4fbb33f787470a841e13216625
Mygithub-projects/python_programs
/factorial.py
154
3.8125
4
''' num=5 fact=[] for i in num: fact = fact * (num-1) print("the factorial ofa number\n",fact) ''' print(map(lambda n: n*n(n-1),4))
0ffd47af8ee7a70e06f4563ae86c7ae8e50f873d
nilashan/Python
/exercises/ex05.py
320
4.125
4
#Write a program which accepts a sequence of comma-separated numbers from console and generate a list and a tuple which contains every number. #Suppose the following input is supplied to the program: print 'please enter your no' values=raw_input() l=values.split(',') t=tuple(l) di=dict(l) print(l) print(t) print(di)
98afb75d33bc20e9f53be7f59d7a2f7e5fd94b18
ericnc83/treinamento
/calcteste.py
610
3.921875
4
def main (): valor1 = int(input("Digite um valor: ")) valor2 = int(input("Digite outro valor: ")) soma = valor1 + valor2 sub = valor1 - valor2 mult = valor1 * valor2 div = valor1 / valor2 print("-="*15) print(f"A soma é {soma}") print(f"A subtração é {sub}") print(f"A mult...
2d130f6da11f6071cf9b3e89724d6e614dc92ed5
shuaiguan/MachineLearningAtoZ
/multiple_linear_regression.py
3,311
3.84375
4
#data preprocessing import numpy as np import matplotlib.pyplot as plt import pandas as pd from sklearn.preprocessing import LabelEncoder, OneHotEncoder #import the dataset #you have to first set upwork directory #the following split data set into independent variable and dependent variable dataset = pd.read_csv('50...
0cdfd234cd349f58d25a77b84d9685b9d7165118
chinmairam/Python
/dict_zip.py
128
3.703125
4
from string import ascii_lowercase as lower letters = lower num = list(range(1,27)) key = dict(zip(letters, num)) print(key)
17ebbb4e9d1eeda845dcac4fdf911a4ef9b005f6
Yuto2511/python_study
/if.py
124
3.890625
4
#!/usr/bin/env python3 age = 0 if age >= 20: print("adult") elif age == 0: print("baby") else: print("child")