blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
1accadb201f9775b87b3d1029b2d0ac2e1646245
htmlprogrammist/kege-2021
/Bariants/polyakov-2301/task_2.py
636
4.0625
4
""" (№ 70) Логическая функция F задаётся выражением (a ∧ b) ∨ (a ∧ ¬c). Определите, какому столбцу таблицы истинности функции F соответствует каждая из переменных a, b, c. В ответе напишите буквы a, b, c в том порядке, в котором идут соответствующие им столбцы (без разделителей). """ print('a b c F') k = 0, 1 for a in ...
be51b6c5a2cc47dc025a0b617062fba5201ae59c
polyankaglade/Proga
/bonus/2.py
447
3.828125
4
celsi = input("Введите градусы Цельсия (дробную часть - через точку): ") if celsi == "": print("Вы ввели не число, попробуйте ещё раз") else: celsi = float(celsi) farenh = celsi * 1.8 + 32 kelvin = celsi + 273.15 print(round(farenh, 2), "градусов Фаренгейта") print(round(kelvin, 2), "г...
a397c642ef030d3470ced2a170d365972d27b45e
rodrigua6751/cti110
/P5LAB1_StepCounter_Rodriguez-AguirreAllan.py
228
3.78125
4
def steps_to_miles(user_steps): miles = user_steps / 2000 return miles if __name__ == '__main__': user_steps = int(input()) miles = user_steps / 2000 print('{:.2f}'.format(steps_to_miles(user_steps)))
54859bb721b99999f56b95cc05ac0b5476eb81ef
mdanlowski/algorithms
/matching_brackets.py
1,371
3.75
4
# matching brackets - a VERY provisional approach def validate(title): # go through a string, return false if brackets are: ## unmatched - if not all the opening brackets are paired - invalid ## in wrong order - if one of closing brackets appears first - invalid ## in wrong order by type - if other bracket clo...
cd93cc93feee4c50de8b196236dbe09cb9eca13a
ejaj/30days
/lists.py
538
3.71875
4
N = int(input()) output = [] for i in range(0,N): user_input = input().split() if user_input[0] == "print": print(output) elif user_input[0] == "insert": output.insert(int(user_input[1]), int(user_input[2])) elif user_input[0] == "remove": output.remove(int(user_input[1])) ...
0add60f53073a6d5d384a8d51fead87847e1a740
WinPlay02/Python-Vorkurs
/Tag 2/a3_schöneLösung2.py
340
3.6875
4
#Aufgabe 3 Zettel 01 import random def sort(liste): sorted = False while not sorted: sorted = True for i in range(len(liste) -1): if liste[i] > liste[i+1]: liste[i+1], liste[i] = liste[i], liste[i+1] sorted = False return liste Zahlen = [] for i in range(10): Zahlen.append(random.randrange(0,99)) ...
a6269cc2613fef7db98a7b7604570b5b637d8b68
hinduck/FullPythonProject
/HelloWorld/SayHello.py
83
3.765625
4
print("Làm chủ Python") x = 5 y = 8 z = x + y print("{0}+{1}={2}".format(x,y,z))
f7af8276c71278394f2a9fec4d3dc8c99acaa2cc
fluidesign/automate-using-python
/dictionary-simple_example.py
850
4
4
## Dictionary bDay = {'Alice' : '01-02-87', 'Bob' : '02-03-66'} def addBday (pName): global bDay print ('Type a birthday for ' + pName + ' : [dd-mm-yy]') pBDay = input() bDay[pName] = pBDay print (str(pName) + ':' + str(bDay[pName]) + ' Was added') while True: print ('Please type a name...
8f7e8a7dafc85b88c43646738e4de08fc1f8463e
vamsikrishna6668/class-examples
/prime number.py
203
4.0625
4
n =int(input('enter a number:')) count =0 for i in range(1,n+1): if n%i==0: count +=1 if count ==2: print(n ,'it is a prime number') else: print(n ,'it is not a prime number')
d1e7cf371abccd026d6ce842fa9fba10ec5d4dbf
ankitomss/python_practice
/Findmax_rotate.py
430
3.796875
4
def findmax(nums): n=len(nums) s,e=0,n-1 if nums[s] < nums[e]: return nums[e] while s<=e: m=(s+e)/2 if s==e: return nums[s] if nums[s] > nums[e] else nums[e] elif nums[m] > nums[m+1] and nums[m] > nums[m-1]: return nums[m] elif nums[m] > ...
c86c7b2308003ddd4733b85ed1d2534fc7292889
Felipecard/Codigos-Exercicios-Python
/3. Tuplas/Consulta tabela do Baasileirao.py
649
3.890625
4
print('Consulta tabela brasileirao 2019') tabela = ('Flamengo', 'Santos', 'Palmeiras', 'Gremio', 'Atl Paranaense', 'Sao Paulo', 'Inter', 'Corinthias', 'Fortaleza', 'Goias', 'Bahia', 'Vasco', 'Atletico MG', 'Fluminense', 'Botafogo', 'Ceara', 'Cruzeiro', 'CSA', 'Chape', 'Avai') print(f'A) Irão pa...
2955a1dac0e1ff268564954509c7100dcbe8c334
shazia90/code-with-mosh
/numbers.py
268
4.25
4
print (10 + 3) print (10 - 3) print (10 * 3) print (10 / 3) #which gives float no print (10 // 3)# this gives integer print (10 % 3)#modulus remainder of division print (10 ** 3)#10 power 3 x = 10 x = x + 3 # a) x += 3 # b) a, b both are same print (x)
3308eb604aaf52a86a5ecd2d6e5843897fd4190e
crawsome/Python-programming-exercises
/100q/question_047/exercise047.py
150
3.734375
4
"""3.5 Question: Write a program which can map() and filter() to make a list whose elements are square of even number in [1,2,3,4,5,6,7,8,9,10]. """
ebea8692d251c1ea0ef8552fa59cee39c2d74153
ambassadeurdufeu/python_intermediate
/hangman.py
2,127
3.953125
4
import os import random def read(): words = [] with open ('random_word.txt', 'r') as f: for line in f: words.append(str(line)) return words def choose_a_word(words_before): lenght = len(words_before) word_to_play_number = random.randrange(lenght) word_to_play = words_befo...
8deb472aedf5726a410242823f73ef5f59497ec8
nya3jp/aoc2020
/day10/day10a.py
614
3.59375
4
import collections from typing import List def solve(ns: List[int]) -> int: ns = [0] + sorted(ns) + [max(ns) + 3] counter = collections.Counter(b - a for a, b in zip(ns, ns[1:])) return counter[3] * counter[1] def test_solve(): assert solve([16, 10, 15, 5, 1, 11, 7, 19, 6, 12, 4]) == 7 * 5 asser...
12b80e970af6fc15f2dac788210ec0c6aafeadf3
dock123/part6
/task.py
1,942
3.78125
4
""" Написать три класса: Human: -перегрузить конструктор, чтоб объект принимал на вход значения age(типа int) и ‘name’ (типа str) -добавить метод say_hello(), который бдует возвращать сообщение ‘hello, my name is (входящий аргумент name)’. Отнаследовать от этого класса новый – Builder, пусть он принимает, в дополн...
eb7c3ae80ac4613ef4c184483779610cdeec60f4
kvitek/PCG
/word.py
3,756
3.515625
4
# -*- coding: utf-8 -*- """ Created on Sun Oct 21 13:58:54 2018 @author: Asus """ class Word(object): def __init__(self, s_word=None): self.letter = 'a' self.symbols = [] if s_word is not None: self.read(s_word) def __str__(self): s = '' for e in se...
6bc675af110064de3e2e08d36b7433bd51e52484
Luckercorgi240/python_codes_2019
/exponential_stuff.py
99
3.6875
4
def stuff(n): number= 2 for x in range(n): print(number * 2) anwser = number print(anwser)
ef7e164e182bacba075f430ff024f232f3831b7f
VictorCatacora/python-challenge
/PyBank/main.py
2,120
3.765625
4
import os import csv import statistics # Path and read budget_csv = os.path.join('budget_data.csv') with open(budget_csv, 'r') as csvfile: # Split the data on commas and skip header csvreader = csv.reader(csvfile, delimiter=',') header=next(csvreader,None) months=0 total=0 change_array=[] init=0 dates_array=...
816f660892a68fd9054345747495b700f25f36d2
Reetishchand/Leetcode-Problems
/00053_MaximumSubarray_Easy.py
1,311
3.8125
4
'''Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example 1: Input: nums = [-2,1,-3,4,-1,2,1,-5,4] Output: 6 Explanation: [4,-1,2,1] has the largest sum = 6. Example 2: Input: nums = [1] Output: 1 Example 3: Input: nums = [0] Ou...
92b4bce001fac95cadcd7967cea62b165e29ab18
jm-rives/advent_of_code_2017
/Day_2/December_2_2017a.py
1,002
3.828125
4
from file_reader import * results = [] for row in rows: big_num = None little_num = None for elem in row: # print(f"Current Elem is: {elem}") if big_num == None and little_num == None: big_num = int(elem) little_num = int(elem) # print(f"Little Num p ...
b9edadb86114c645d31cf97c7a6538994eebb78a
MusulmonLolayev/AIPython
/lessons/other/test8.py
1,066
3.65625
4
from math import sqrt # Biribchi funksiya, 3 ta kesmani funksiya bo'lishiga tekshirish def IsTriangle(a, b, c): return a + b > c and a + c > b and b + c > a # Yuzasini topsih def Uchburchak_Yuzasi(a, b, c): p = (a + b + c) / 2 return sqrt(p * (p - a) * (p - b) * (p - c)) try: a = float(input("a = ")) ...
5f88d87a11290e90da9107be6735d653fdcb9945
13OT/Spatial-DS-Alathel
/Assignments/Program_5/query3.py
5,352
4.03125
4
""" Program: -------- Program 4 - Query Assignments - Query 3: Clustering query3.py Description: ------------ Use dbscan to find the top 3 clusters of volcanoes, earthquakes, and meteors, seperately, that satisfy the requirements. Also, it will draw a bounding box around each cluster. Example Usage...
004206d1f46e6ee5a6cbaae2840cbac0eb97eb7d
MazokuCZ/CS455
/kruskal.py
1,829
3.625
4
class Graph: def __init__(self, vertex): self.V = vertex self.graph = [] def add_edge(self, u, v, w): self.graph.append([u, v, w]) def search(self, parent, i): if parent[i] == i: return i return self.search(parent, parent[i]) def apply_union(se...
0bbe18bfe03216b86f34fc8080e2ed7a8eedc267
HaukurPall/kr-sudoku
/sudoku_to_dag.py
8,666
3.9375
4
class Cell: # set of possible values values = [] # reference to the whole sudoku sudoku = {} # row and column indexes row = 0 column = 0 final_value = 0 # initialize the cell with every possible value def __init__(self, row, column, sudoku): self.values = [] for...
ed336321b4821a17bcefd92925e87123871d08cd
bridgette/Python100
/palindrome_product.py
1,196
4.15625
4
# -*- coding: utf-8 -*- """ Created on Sun Nov 29 18:28:46 2015 @author: bridgette Project Euler Largest Palindromic Product A palindromic number reads the same both ways. The smallest 6 digit palindrome made from the product of two 3-digit numbers is 101101=143×707 Find the largest palindrome made from the pro...
b228813b92246d734d8c2cb59b137df60643d883
Caitlin576/ICS4U-final-project
/button.py
1,315
3.75
4
import pygame pygame.init() pygame.mixer.music.load('GameMusic.wav') pygame.mixer.music.play(-1) #create sprite class for the buttons class Button(pygame.sprite.Sprite): #take x, y, width, height, and colour values during initialization def __init__(self, x, y, w, h, colour1, colour2): #...
b9ad3bd9d50f54fe6742a5f3a3ddf5bd92518e9d
flavius87/aprendiendo-python
/21-tkinter/08-alertas.py
575
3.734375
4
from tkinter import * from tkinter import messagebox as Messagebox ventana = Tk() ventana.config(bd=70) def sacarAlerta(): Messagebox.showinfo("Alerta", "Hola, soy Flavio Scheck") Button(ventana, text="Mostrar alerta!!!", command=sacarAlerta).pack() def salir(nombre): resultado = Messagebox.askquestion("Sal...
82796fe72642fc1fac20bc93489f7e53101405eb
FJYang96/capturetheflag
/agent/abstractagent.py
882
3.78125
4
class Agent: ''' Abstract class of agents. ''' def __init__(self, num_players): self.num_players = None def get_action(self, observation): ''' This is the general interface for agents. They take an observation and return a control output ''' raise Not...
db9a35dd9eaf1add95e5897eee0df2d1f8783012
Chisanan232/Crawler
/ConnectDataBase/crawler-connect-sql-multithreading.py
15,572
3.71875
4
''' I write this program because I want to crawler and insert data to DataBase with multithreading. But there is a question: Currently, we know the method to realize the idea is to write with python package "threading", but now, I use package is "tomorrow", it doesn't have "lock" and "release" function to ensure you...
a4edd81b14892c6f6fb31ec9d1a477c4ce45feab
HuShuangPing/Study
/day02/schooltest.py
745
3.640625
4
#!/usr/bin/env python # -*- coding:utf-8 -*- # Author:HuShuangPing func_str =''' #include "stdio.h" void test(){ //测试方法 "printf("in the test") /*打印一个值 并且没有返回值*/ } main() { int a=1,b=2; // 定义两个变量 test() //调用方法1 } ''' index=-1 while True: index =func_st...
6d0e702bdc604888922e2f27c29ec741c77ab93c
DedaLenya/python_basic_19.11.2020
/hw6_folder/hw6_4.py
2,834
3.515625
4
"""4. Реализуйте базовый класс Car. У данного класса должны быть следующие атрибуты: speed, color, name, is_police (булево). А также методы: go, stop, turn(direction), которые должны сообщать, что машина поехала, остановилась, повернула (куда). Опишите несколько дочерних классов: TownCar, SportCar, WorkCar, PoliceCar. ...
fcbe6d3180a55799dd9f8487821af659d8120e57
ellismckenzielee/codewars-python
/thinking-and-testing-true-or-false.py
203
3.609375
4
###Thinking & Testing: True or False ###https://www.codewars.com/kata/56d931ecc443d475d5000003 def testit(n): '''Returns the number of 0's in the binary form of n''' return bin(n)[1:].count('1')
4822b39347ee958d87796e5038375f7092711979
SG150607/For_chess
/For_chess/Main.py
5,698
4.03125
4
# CHESS THE GAME # ♙ - пешка белая # ♔ - король белый # ♕ - ферзь белый # ♖ - ладья белый # ♗ - слон белый # ♘ - конь белый # ♟ - пешка черная # ♚ - король черный # ♛ - ферзь черный # ♜ - ладья черная # ♝ - слон черный # ♞ - конь черный # ================ WHITE ================ class White_Pont: def __init__(s...
a3de9c088eb2204ed2a8cf51ae5b338e2be0d859
lucasolifreitas/ExerciciosPython
/secao4/exerc11.py
124
3.546875
4
vel_ms = float(input('Digite a velocidade em m/s: ')) vel_kmh = (vel_ms * 3.6) print(f'A velocidade em km/h é: {vel_kmh}')
0903c1568af10006e033b2daacac26e14e2b6311
raj8524/Core-python
/DS-python.py
16,890
3.734375
4
# x=[100,20,6,840,50,-1,4] # greater=x[4] # for i in x: # if i<greater: # greater=i # print(greater) # -----------------------------------singly linked list -------------------------------- """ class Node(object): def __init__(self,data): self.data=data self.nextNode= None class ...
d19606fd1dd00406c720a6c0f823492b6eb76864
Hani1-2/All-codes
/Untitled Folder/binartsearchtree.py
4,805
3.859375
4
from binarytree import * def build_bst(v): if len(v) == 0: return None root = BTree(v[0]) for i in range(1, len(v)): root = addtobst(root, v[i]) return root def getsortedlist(node, v=[]): if node.lc is not None: getsortedlist(node.lc, v) v.append(node.data) if nod...
fa8d3b3180786f7dda2d2483188d1147ff0758dd
davejlin/py-checkio
/friendly-number.py
4,604
4.40625
4
''' Long numbers can be made to look nicer, so let’s write some code to do just that. You should write a function for converting a number to string using several rules. First of all, you will need to cut the number with a given base (base argument; default 1000). The value is a float number with decimal after the poi...
01d7677224a4ad40e6969c6c1db3560f8dc62877
christopher-burke/warmups
/python/misc/middle_element.py
889
4.40625
4
#!/usr/bin/env python3 """Finding middle element in a linked list. Given a singly linked list of N nodes. The task is to find middle of the linked list. For example, if given linked list is 1->2->3->4->5 then output should be 3. If there are even nodes, then there would be two middle nodes, we need to print secon...
71802a2c69126100726778f507841cbb47d85572
baietoo/python-training-oct2020
/circu_day2.py
3,352
4.15625
4
# try statement exercises # Write a program to read two numbers: x and y from standard input and print the result of x / y. If the user inputs invalid data, display an error message and exit gracefully. x = input('x : ') y = input('y : ') try: result = int(x) / int(y) except ArithmeticError as ex: print(f"cann...
c88283d25124905827e2796dfe6144ddcac2dcf0
ShivaniAsokumar/problems-py
/Plus_One.py
751
4.15625
4
""" !PROMPT: Given a non-empty array of digits representing a non-negative integer, increment one to the integer. TODO: Understand * Take each integer and combine them to make a number. * Add 1 to that number * Edge case => [9,9,9] Array containing number 9 ? Can you return an array of strings containing each digit? ...
87b33e0e7c16ce09928405e2a96c3d9421fa9ea0
andrefcordeiro/Aprendendo-Python
/Uri/strings/2174.py
231
3.5625
4
# Coleção de pomekon n = int(input()) pomekons = [] cont = 151 for i in range(0, n): pome = input() if pome not in pomekons: pomekons.append(pome) cont -= 1 print("Falta(m) {} pomekon(s).".format(cont))
5efc241943c292e28db2592cd5e1552bf71ed255
consciousprogramer/Code_wars
/code_wars/find_point_in_array_where_sum_is_same_bothsides.py
470
3.828125
4
# -*- coding: utf-8 -*- """ Created on Thu Dec 27 17:38:51 2018 @author: RAVI SHANKAR SINGH """ def find_even_index(arr): ll = len(arr) counter = 0 while counter <= ll: sum1 = 0 sum2 = 0 for i in range(counter): sum1 += arr[i] for n in range(counter + 1,ll): ...
6b683770c22afdef8584275602a21c9d69e90d9f
HeywoodKing/mytest
/MySortAlgorithm/7_binarysearch.py
1,282
3.828125
4
# -*- coding: utf-8 -*- import time # 最优时间复杂度O(1) 最坏时间复杂度O(log以2为底的n) 稳定性:不稳定 # 搜索 二分查找,折半查找 # 递归 def binary_search(alist, item): """ 二分查找 :param alist: :return: """ n = len(alist) mid = n // 2 if n > 0: if alist[mid] == item: return True elif item < ali...
8810798a2adbb1cdeba871f6f381c96918d174d1
evilwarlock/leetcode
/numberOfIslands.py
1,169
3.5625
4
import collections # numberOfIslands.py bfs/dfs class Solution: def numIslands(self, grid): if not grid: return 0 rows, cols = len(grid), len(grid[0]) visit = set() islands = 0 def bfs(r, c): q = collections.deque() visit.add((r,...
17dfc714163d95c66f05278ffc62b2b69ec0b967
jinwei15/java-PythonSyntax-Leetcode
/LeetCode/src/FindtheDuplicateNumber.py
1,020
3.53125
4
# # import collection # class Solution: # def findDuplicate(self, nums): # """ # :type nums: List[int] # :rtype: int # """ # a = collections.Counter(nums) # return a.most_common(1)[0][0] # class Solution: # def findDuplicate(self, nums: List[int]) -> int: # ...
34b779d8f93184df06d4b09c3a94d2a717c59290
pietrodasilva/HousePricePredicting
/documents/code/matplotlib visualisation/barcharts.py
928
4.21875
4
import matplotlib.pyplot as plt x = [2, 4, 6, 8, 10] ## list for the bar y = [1, 3, 5, 7, 9] ## list for the bar x2 = [1,3,5,7,9] ## second list for the bar y2 = [3,4,6,7,8] ## second list for the bar plt.bar(x, y, label = "Bar 1", color = 'r') ## the 1st bar chart, which uses the x and y lists for the values. ...
292b33cbc71355951b4f55c967085e309fc8700b
bowei437/UNIX-Systems-ECE-2524
/PythonCar/Backup/block_car2.py
7,724
3.90625
4
#Import rpi.gpio is raspberry pi specific to get use of the GPIO on it # It comes pre-installed generally on the full Raspbian image import RPi.GPIO as GPIO #setmode BCM is just a general Raspberry pi command telling it to use the BCM manufacturered chip GPIO that the Pi uses. # These are hard set functions that you ...
d8b624f4b4b08fb9e0f821a5f2a4c037b410d950
dmittelstaedt/script-collection
/python/d-version/version/version.py
2,152
3.5625
4
from bs4 import BeautifulSoup import requests import sys version_url = "http://localhost:8080" index_html = "my-index.txt" search_string = "KIDICAP Version" def get_old_version(input_file, search_string): """ Return the old version of the KIDICAP installation. The path to to the current index.html and a sear...
d607c23083470ac5fb9ea328d4aef8231dab3672
Abhiram2001/Encryption-Codes
/Playfair_Encryption.py
5,280
3.71875
4
import sys import numpy as np from collections import OrderedDict from string import ascii_lowercase from os import system, name def removeDupWithOrder(str): return "".join(OrderedDict.fromkeys(str)) def missing_letters(string): alphabet = set(ascii_lowercase) return ''.join(sorted(set(alphabe...
9a1b9ab5c0124b2eb875c19b642cdb592f53a88b
versace123mx/pythontaboada
/num_par.py
337
4.03125
4
num1 = int(input("Ingresa un numero: ")) num2 = int(input("Ingresa otro numero: ")) if num1 % 2 == 0 and num2 % 2 == 0: print("Los numero ingresados son pares") elif num1 % 2 == 0: print(f"El numero {num1} es par") elif num2 % 2 == 0: print(f"El numero {num2} es par") else: print("Ninguno de los...
e145a074617ad8910074678525f44b8e521a5d12
kellydingzx/tetris-assignment-y1
/player.py
7,940
3.765625
4
from board import Direction, Rotation, Shape from random import Random import statistics # reference: # CS 6601 - Artificial intelligence, Mini-project paper # Improvement on a Tetris Agent # https://pdfs.semanticscholar.org/2d0d/eb544439e96f9f84fe1afc653bbf2f3bcc96.pdf # date of access: 20/11/2019 class Player: ...
e2c4fcd53290feb3af07cf4718109f74874f3784
hemantpn/my-python
/os/os.path.py
848
4.09375
4
#!/home/ec2-user/my_app/env/bin/python import os ''' os.path.sep : to check seprator, win(\) ,linux(/) os.path.basename(path): it shows tail part , like in /home/ubuntu/a.py , So here output is a.py os.path.dirname(path): it show head part like in home/ubuntu/a.py , So here output is /home/ubuntu/ os.path.join(pa...
a8fd83af0ba6451cdfc49a867318a9e81fed63ae
Saptarshidas131/NPTEL
/Data Structure and Algorithms using Python/original_euclid_gcd_while.py
371
4.0625
4
# Original Euclid's algorithm using while loop # finding gcd of two numbers using euclid's algorithm def gcd(m,n): if m < n: #Assume m >= n (m,n) = (n,m) while (m%n) != 0: (m,n) = (n,m%n) # m%n < n, always return(n) # input print("Input value for m:") m = int(input()) print("Input value f...
0943c5a8eb0a574716cfc135619b25138112df49
bajabera/210ct-
/1st week number 2.py
769
4.53125
5
def factorial(): ''' Takes a factorial number and counts the number of trailing zeroes Returns the number of trailing zeroes ''' try: number=int(input("Please enter the factorial number you want to check for ")) if number<5 and number>0: print('No traili...
31920f43207b01aaf911cbde9265de6c7fe9e6d8
keepmovingon33/algorithms_practice
/python/Leetcode5_LongestPalindromicSub.py
589
3.875
4
''' Input: "babad" Output: "bab" Note: "aba" is also a valid answer. Input: "cbbd" Output: "bb" ''' def PalindromeCheck(str): if len(str) <= 1: return True if str[0] != str[-1]: return False return PalindromeCheck(str[1:-1]) def longestPalindromicSub(str): longest = 0 result = '' for i in range(len(str)-1):...
dc35a4d373016860ac49499b489660d23b571a4c
djangogirl-crypto/Hello-world
/time.py
930
3.515625
4
from datetime import datetime,timedelta try: t = int(input()) for i in range(t): nw = input().split(" ") h,m =nw[0].split(":") n = int(input()) for i in range(n): lst = input().split(" ") h1, m1 = lst[0].split(":") h2, m2 = lst[2].s...
66635f94b599eb686c59802194fa794401e7b3d8
stedevine/advent2020
/day14/problem14.py
3,013
3.859375
4
import math def apply_mask_to_value(value, mask): # mask is zeros, ones and Xs # zero sets the matching bit to 0 # one sets the matching bit to 1 # X does nothing # extract the ones from the mask. OR this with the value to set all the masked values to 1 mask_1 = int(mask.replace('X','0'),2) ...
85e83e88757e8f70bc206853839df948a0bc1220
garikapatisravani/PythonDeepLearning
/ICP2/LbstoKgs.py
583
4.15625
4
# Author : Sravani Garikapati #program reads weights (lbs.) of N students into a list and convert these weights to kilograms # creating an empty list lbs = [] kgs = [] # Ask user to enter no of students n = int(input("Enter number of students : ")) # iterating till the range # Using for loop for i in range(n): el...
51cb8cba67edfc3b22f42686e0e15aa98c991532
gabrielvtan/ByteAcademy-FullStack
/Phase1/Week1/Python/1.3_4-Read-McNugget-Matrix-Hanoi/2-mcnugget-numbers/test.py
440
3.765625
4
def McNuggets(n): Non_McNuggets = [] McNuggets = [] for number in range(1, n+1): for a in range(0,n): for b in range(0,n): for c in range(0,n): if 6*a + 9*b + 20*c == number: McNuggets.append(number) if number...
55e9de8b4919fbdfdaba4c29541a220c84fd6df2
FlameFractal/CSD302-342-Algorithms-DataMining
/recurse.py
250
3.859375
4
def move(n,current,target,empty): if(n==1): print "move disk %d from %d to %d" %(n,current,target) return; move(n-1,current,empty,target) print "move disk %d from %d to %d" %(n,current,target) move(n-1,empty,target,current) move(3,1,2,3)
32140039ed8e69f23617e5932c03b017ecb30888
Sanchi02/Dojo
/LeetCode/Logical/RottingOranges.py
2,490
3.859375
4
# In a given grid, each cell can have one of three values: # the value 0 representing an empty cell; # the value 1 representing a fresh orange; # the value 2 representing a rotten orange. # Every minute, any fresh orange that is adjacent (4-directionally) to a rotten orange becomes rotten. # Return the minimum number...
0b8c6e6b5a484da0fc808bd27f543fb31545080e
sukanta-27/DSA_prep
/Trees/IterativeTreeTraversals.py
2,434
3.875
4
from BinaryTree import Tree def iterativePreorder(tree): if not tree.root: print("Tree is Empty") return stack = [] current = tree.root while len(stack) > 0 or current: if current: print(current.data, end=" ") stack.append(current) current ...
e5e662aec7c386986aef08b3f1a06bb1a0d083de
paisap/holbertonschool-machine_learning
/unsupervised_learning/0x01-clustering/3-optimum.py
1,762
4.03125
4
#!/usr/bin/env python3 """Tests for the optimum number of clusters by variance""" import numpy as np kmeans = __import__('1-kmeans').kmeans variance = __import__('2-variance').variance def optimum_k(X, kmin=1, kmax=None, iterations=1000): """ Tests for the optimum number of clusters by variance Args: ...
f1c6ea9e9e89e50fa63734944ee862c6faa01ca1
pysudoku/sudoku
/src/sudoku/algorithm/backTrackingAdapter.py
2,354
4.25
4
from sudoku.algorithm.Algorithm import Algorithm from sudoku.algorithm.backtrackingAlgorithm import BacktrackingAlgorithm class BackTrackingAdapter(Algorithm): """ BackTracking is a class convert the sudoku from dictionary into a List of list structure. When sudoku is solved then this class also convert the...
f20ff6c7b07b6225c28388d08d2230550377548e
sravankghantasala/Ideas
/Python/Numbers/PrimeFactors.py
637
4.28125
4
''' Prime Factorization - Have the user enter a number and find all Prime Factors (if there are any) and display them. Created on 10 Oct 2014 @author: sraone ''' def get_factors (num): temp = list() for i in range(2,num) : if num%i == 0: temp.append(i) return temp def is_prime (number...
0b5b20b16d98e7d77ce25c02955436644bbad012
xiaozefeng/learn-python3
/the_string.py
433
3.578125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # ASCII 一个字节 Unicode 2个字节 UTF-8 一个或者3个字节 print('包含中文的str') # ord()函数获取字符的整数表示 chr()将对应的整数转换成字符 print(ord('A')) # 65 print(ord('中')) # 20013 # 字符和字节的相互转换 'abc'.encode('ascii') 'abc'.encode('utf-8') b'abc'.decode('utf-8') # 字符串格式化 print('Hello ,%s' % 'World')
d5e18fb5246b8734fb851a893f0d945107a6389b
EmersonBraun/python-excercices
/cursoemvideo/ex057.py
368
3.765625
4
# Faça um programa que leia o sexo de uma pessoa, # mas só aceite os valores 'M' ou 'F'. Caso esteja errado, peça a digitação novamente até ter um valor correto while True: sexo = str(input('Informe seu sexo: [M/F] ')).strip().upper()[0] if sexo in 'MF': break else: print('Sexo inválido!')...
411c729ac4f3f36d7e977c76c51da0b2905ed1ea
five510/atcoder
/20190526/main_b.py
563
3.5
4
N = int(input()) SPn =[] for i in range(N): SP = input().split(' ') S = SP[0] P = int(SP[1]) SPn.append([S,P,i+1]) SPn.sort() first_val = SPn[0][0] current_list = [SPn[0]] for i in range(1,N): if first_val == SPn[i][0]: current_list.append(SPn[i]) else: current_list.sort(key=lamb...
0a757691615dda777639cdb3bd2ee0b352263b9b
breezekiller789/LeetCode
/33_Search_in_Rotated_Sorted_Array.py
1,075
3.59375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # https://leetcode.com/problems/search-in-rotated-sorted-array/ # Output: 4 nums = [4, 5, 6, 7, 0, 1, 2] target = 0 # Output: -1 nums = [4, 5, 6, 7, 0, 1, 2] target = 3 # Output: -1 # nums = [1] # target = 0 length = len(nums) low = 0 high = length - 1 while low <= hi...
a3917d344a2cc63749747301f2ac4430f4e45d49
brenj/solutions
/hacker-rank/python/regex-and-parsing/findall_and_finditer.py
640
4.125
4
# Findall and Finditer Challenge """ You are given a string S. It consists of alphanumeric characters, spaces and symbols(+,-). Your task is to find all the substrings of S that contains 2 or more vowels. Also, these substrings must lie in between 2 consonants and should contain vowels only. """ import re VOWELS = '...
f0182a7324765a2053be4692d98ec435cac75e0b
snowdj/cs_course
/Algorithms/challenges/lc126_word_ladder_2.py
3,762
3.765625
4
""" Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation sequence(s) from beginWord to endWord, such that: Only one letter can be changed at a time Each transformed word must exist in the word list. Note that beginWord is not a transformed word. For example, Given: b...
573901378d13b0058d6b57fc7bfa05953d165c1a
lixx5578/lixx5578
/lab08.py
1,787
3.671875
4
#warmup2 def print_matrix(): mat = [] ls = [0,0,0,0] for i in range(4): mat.append(ls) print(ls) print(mat) mat[i][i] = 5 print(mat) print(mat) def print_matrix2(): mat = [] for i in range(4): ls = [0,0,0,0] mat.append(ls) ...
aff4686e7f58e9fbd01838b0d8c12f597f46328d
deepakshinde18/Python
/src/bin/Regular_Expression/validation_test.py
5,333
3.578125
4
"""Tests for validation exercises""" import unittest from validation import (has_vowel, is_integer, is_fraction, is_number, is_hex_color, is_valid_date) class HasVowelTests(unittest.TestCase): def test_rhythm(self): self.assertFalse(has_vowel("rhythm")) def test_exit(self):...
fb1029359bd6250ecdc6212bdd6395bb5ac01e3b
marioperezmon/Space-invaders
/start_game.py
3,853
3.546875
4
import pygame from time import sleep from nave import nave black = (0, 0, 0) white = (255, 255, 255) red = (252, 3, 23) pygame.init() dificultad = 1 delay = 1 / dificultad # numero de naves por fila numero_naves = 11 * dificultad # en funcion de las dimensiones de la pantalla, se adaptan el resto de elementos # mon...
2daff405a238660d4a94ddd83299ce623a3b111c
dingweihua/PythonCertSpring
/week-03/code/lambda/lambda_functions_global_scope.py
270
3.6875
4
#! /usr/bin/env python # # # This program demonstrates how lambda functions interact with surrounding scopes glob = 8 f = lambda x: x-glob print f(2) glob = 15 print f(3) def incr(n): return lambda x: x-n h = incr(2) i = incr(4) print h(3), i(3) print incr(6)(9)
bef3029f8d6c61b598cb771937f7df16c4fcdcda
JackBmann/computational-physics
/projectile.py
1,370
4.0625
4
""" projectile.py 10/6/16 """ import matplotlib.pyplot as plt from math import sin, cos, pi, sqrt # define global parameters g = 9.81 # SI units, magnitude of gravitational acceleration # define an euler function to solve Newton's 2nd law and also plot def euler(y, vx, vy, vt): # initialize t = 0 x = ...
dfca603abed74b07b682a41d57f240bc803cb2ea
ruanrochaas/python_studies
/URI/uri1012.py
372
3.515625
4
# -*- coding: utf-8 -*- """ Created on Thu Jun 28 23:43:12 2018 @author: ruan_ """ A,B,C = input().split() A = float(A) B = float(B) C = float(C) areaTri = A*C/2 areaC = 3.14159*C**2 areaTrap = (A+B)*C/2 areaQ = B*B areaR = A*B print("TRIANGULO: %.3f\nCIRCULO: %.3f\nTRAPEZIO: %.3f\nQUADRADO: %.3f\nRET...
6ab8b0d4b8967274a8f612b14319ba09dfd7df8e
aProudCynic/udemy-python-100-days-30
/main.py
3,811
3.53125
4
import json from tkinter import * from tkinter import messagebox from random import choice, randint, shuffle DATA_FILE_NAME = "data.txt" def generate_password(): letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B',...
23fa1bee9b51a274dd57976ea0d4a2543ccdc926
aautcsh/cum
/cum/output.py
980
3.703125
4
import click from math import ceil def chapter(msg): click.echo( click.style('==> ', fg='green') + msg ) def error(msg): click.echo( click.style('==> ', fg='red') + msg ) def list(items): """Print out a list of items in columns much like `ls` in bash.""" if items: w...
9b15d0c9a1524975a02e8894c1a55b160f75ef25
santoshikalaskar/Basic_Advance_python_program
/Python-dataStructure/dataStructure/stackUsingLL.py
633
3.78125
4
from node import * class StackUsingLinkedList: def __init__(self): self.head = None def push(self,data): new_node = Node(data) if self.head == None: self.head = new_node else : new_node.next = self.head self.head = new_node def po...
7b63a9cc3c524e43ac605f5ecc4a54d546425a50
Laksh8/competitive-programming
/hackerearth/CodeMonk/Monk and Digital World.py
269
3.5625
4
# Monk and Digital World def check(a,b): for i in set(a): if a.count(i) != b.count(i): return False return True n = int(input()) a = list(map(str,input())) b = list(map(str,input())) if check(a,b): print("YES") else: print("NO")
32c5484b1cea6c6e2f3cdba3891e61b550789559
buyat/buy.at-API-SDKs
/src/python/buyatapi/Entities.py
1,871
3.578125
4
''' @LICENCE@ ''' class Category(): ''' Represents a simple category ''' def __init__(self, client): ''' Constructor ''' self._client = client self._subcategories = None def get_subcategories(self): if self._subcategories == None and self.le...
353132a241a3f8fbea7095ca8c72cf64c7b4cd6d
kinleydeki/kinley
/even and odd.py
103
3.515625
4
def even(nop): if(nop%20==0): print("Even") else: print("odd") even(7)
5864aa821bb7a7e041cc4f486cca4c20c5780d6f
genos/online_problems
/prog_praxis/longest_palindrome_176.py
682
3.53125
4
#!/usr/bin/env python # Find the longest palindrome in a given text def is_pal(s): return s == s[::-1] def flp(s): longest, len_longest = 'g', 1 for i in xrange(len(s)): for j in xrange(1,len(s[i:])): sub_s = s[i:i+j+1] if is_pal(sub_s) and len(sub_s) > len_longest: ...
9ef15e2de182b69b2520ab98e029b9d060137c2c
valeriynasonov/Homeworks.-Class-1
/Homeworks-2.py
1,404
3.765625
4
class Track: def __init__(self, name, long): self.name = name self.long = long def show(self): print(self.name, self.long) track_1 = Track("Pink Floyd", 24) print(track_1.name) class Album: def __init__(self, name, group): self.name = name self.group = group ...
3f19b8b008a4156adfeac794951040329fad1784
swapnilborkar/MITx-6.00.1x
/PSET1/countVowels.py
146
4
4
vowels=0 for i in s: if (i=='a') or(i=='e') or (i=='i') or (i=='o') or (i=='u'): vowels += 1 print("Number of vowels: " + str(vowels))
6a7e7c380a88871754ff6be56eee78a0285ccc01
thehighestmath/ANN-2021
/8383/Stepanov/pr/1/main.py
702
3.84375
4
def task10(number): string = str(number) lenStr = 0 if len(string) < 3: return True if len(string) % 2 == 0: lenStr = len(string) / 2 - 1 else: lenStr = (len(string) - 1) / 2 leftValue = 0 rightValue = 0 for i in range(0, int(lenStr), 1): leftValue += int(st...
9db7cf4a8b8f6cf3f0fa0a3020c0f2292ae0ee32
Jacob-Bankston/DigitalCrafts-Assignments
/Week1/Week1-Friday-Assignments/algorithms-practice.py
2,703
3.984375
4
# Array Duplicate Remover def array_duplicate_remover(array): # With the in function new_array = [] for item in array: if item not in new_array: new_array.append(item) print(new_array) new_array = [] def array_duplicate_remover2(array): # Without the in function for index in range(...
b3465aca1a2b3710acc5552a51e6073e0193966c
snehashis365/PythonNoob
/Calculate.py
1,336
4.03125
4
class Calculator: def adder(self, x, y): result = int(x + y) return result def subtractor(self, x, y): result = int(x - y) return result def product(self, x, y): result = float(x * y) return result def divide(self, x, y): result ...
1659e3989d78106673c8f9122eea2a58689a763f
smilejakdu/algorithm_interview_study
/tree/leetcode/543.py
2,069
3.890625
4
''':cvar 이진 트리에ㅏ서 두 노드 간 가장 긴 경로의 길이를 출력하라. Example 1: Input: root = [1,2,3,4,5] Output: 3 Explanation: 3is the length of the path [4,2,1,3] or [5,2,1,3]. 가장 긴 경로는 4 -> 2 -> 1 -> 3 또는 5 -> 2 ->1 -> 3 으로 3이다. Example 2: Input: root = [1,2] Output: 1 ''' class TreeNode1(object): def __init__(self, x): se...
7d7fed260ac4f4de4a8e7a99ac54ae006de9cdb4
pratikjgec/Directorywise-file-search
/search.py
1,102
3.71875
4
#-----------------------------Author- Pratik Dutta--------------# #-----------------------------App Version 1.0 #-----------------------------Automation using python 3.8.2 #---It will find the string Only from Word Document with .docx extention file. from docx2txt import * import os from docx import Document print("*...
04a8f46ac2aa5383eade388d953e6217fad7954b
ReversePenguin/my_python_project
/DeepLearning_py3/LogisticRegression/logistic_regression.py
3,823
3.515625
4
#_*_ coding:utf-8 _*_ ''' logistic回归算法 z = w*x+b 激活函数:sigmoid 梯度下降法训练模型 ''' import numpy as np from sklearn.model_selection import train_test_split from sklearn.datasets import make_blobs import matplotlib.pyplot as plt class LogisticRegression: def __init__(self): pass def sigmoid(self,z): ...
2affa841a7b65d40d56bc49d97cdc0752e6e7946
lord63/pyhipku
/pyhipku/encode.py
6,265
3.75
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import absolute_import, division import socket from .dictionary import (adjectives, nouns, verbs, animal_adjectives, animal_colors, animal_nouns, animal_verbs, nature_adjectives, nature_nouns, plant_nouns, ...
b09b228f492342f49e0bc8e90b2c5a1e1527fb2d
AndreaCrotti/ep2013
/tdd/code/show_cov.py
1,030
3.5
4
import unittest def smart_division(a, b): """Run a 'smart' division """ if b == 0: raise Exception("Can not divide by 0") res = a / b back_res = res * b if back_res != a: return a / float(b) else: return res class TestSmartDivision(unittest.TestCase): pass ...
c39c6356fea43dbf0462acb127b01a5d6944a122
WaivedAnswer/AdventOfCode
/2015/Day_11/Program.py
3,466
3.59375
4
def incrementChar(char): if(char == "z" or char == "Z"): return "a" return chr(ord(char) + 1) def incrementedWord(word): return incrementedWordAtIndex(word, -1) def incrementedWordAtIndex(word,index): if(word[index] == "z" or word[index] == "Z" ): if(index == 0 or len(word) == 1 ): return "...
deada59de331ee2df4a602898bc8ae05f306be84
laowucqy/git
/test/test6/test6.py
576
3.5
4
def fun (a): if ord(ss[a])>=ord('a') and ord(ss[a])<=ord('z'): return True elif ord(ss[a])>=ord('A') and ord(ss[a])<=ord('Z'): return True else: return False ss = raw_input() str = '' ll = [] for i in range(len(ss)): if fun(i): str=str+ss[i] else: if len(str)!=0 : ll.append(str) str = '' if len(st...
f7123ca814c88fe8f0a82d8efa06c66ee34e5182
AnastasiyaW/lessons
/lesson2.py
2,380
4.0625
4
#a = int(input()) #print(a) #print ("введите радиус ") #f = int(input()) #print (3.14*(f**2)) #a = 1 #b = 1 #if a == b: # print("ИСТИНА") #else: # print("Лож") # оператор вводит стороны прямоугольника. он вводит площадь этого прямоугольника и программа говорит верно ли это/ программа выводит верно...
d3aac67d02b5e5b21f4fbdfd2fe57ef339a009f4
xiongxiong109/py_go
/features/split.py
1,385
3.953125
4
# list切片 # arr = ['a', 1, '2', 'ss']; # print(arr[:3]) 0 - 3 # print(arr[-2:]) # 倒数(倒数切片同样需要从小到大取,只是起点位置倒数,但是不会倒序) # 间隔取数 # print(arr[::2]); # 第三个冒号后面是间隔数 # 可以利用切片复制一个数组 # newArr = arr[:] # print(newArr) # print(newArr == arr) # 相等? # 利用list切片来实现string的strip()效果 testStr = " hello world "; specStr = "hello wor...
81679b58d98da1cefd5aa9f50ef4e0971212bb56
Milan-Adhikari/Pandas
/real_world_business_analysis/real_world_business_analysis.py
2,865
3.609375
4
import pandas as pd import matplotlib.pyplot as plt data = pd.read_csv('all_months_data.csv') #data.dropna(axis = 0,inplace=True) # dropping null rows pd.set_option('display.max_columns',None) # print(data.head()) # removing NAN values and cleaning data nan_data = data[data.isna().any(axis=1)] # print(nan_data) data....