blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
3a35fdabcdce00465003f0558e93a3c5c60200a7
zabcdefghijklmnopqrstuvwxy/AI-Study
/1.numpy/topic41/topic41.py
2,886
3.546875
4
#numpy.ufunc.reduce #method #ufunc.reduce(a, axis=0, dtype=None, out=None, keepdims=False, initial=<no value>, where=True) #Reduces a’s dimension by one, by applying ufunc along one axis. #Let a.shape = (N_0, ..., N_i, ..., N_{M-1}). Then ufunc.reduce(a, axis=i)[k_0, ..,k_{i-1}, k_{i+1}, .., k_{M-1}] = the result of...
bfb9662c70d09b9c383075eea4fa8a3cd7735e0f
rrwt/daily-coding-challenge
/gfg/bst/sorted_ll_to_balanced_bst.py
1,354
4.28125
4
""" Given a Singly Linked List which has data members sorted in ascending order. Construct a Balanced Binary Search Tree which has same data members as the given Linked List. Balanced BST: A bst with max height difference between the left and the right subtree is 1 recursively. """ from typing import Optional fro...
32fe761be849aa0edd66106a6ce316d076c9fb4f
rgouda/Python
/Euler/sum_square_diff_euler6.py
186
3.734375
4
import functools import operator def sum_square_differences(n): X = functools.reduce(operator.add, (i*i for i in range(1, n+1))) Y = n * (n+1) / 2 Z = Y*Y - X return Z
e3a03761d62bd971b99a3176436b25bb3bc86ded
Algorismia/Aquaeductus
/python/aqueducte_recursive.py
5,072
3.921875
4
import sys import math class Point: def __init__(self, x, y): self.x_coord = x self.y_coord = y def x_distance_to(self, second_point: 'Point') -> int: return second_point.x_coord - self.x_coord def y_distance_to(self, second_point: 'Point') -> int: return second_point.y_c...
1fba106a17a08b55de4e8d4c0c1a234ea89d7be4
tonyyo/algorithm
/Python算法指南/全排列_回溯递归.py
670
3.625
4
class Solution: def quanpailie(self, List, start, results): size = len(List) if start == size: results.append(list(List)) # 必须加上这个, 不然会默认排序 for i in range(start, size): # 以不同位置的元素作为开头进行全排列 List[i], List[start] = List[start], List[i] self.quanpailie(List,...
7727cd72ef8d851ee11b61827178bf5040a11ff8
leapfrogtechnology/lf-training
/Python/shresoshan/task1/store.py
1,818
3.515625
4
import sys import argparse from datetime import datetime import csv import operator import os #Convert to datetime type def dob(value): return datetime.strptime(value,'%d/%m/%Y') #Calculate percentage def calcpercentage(total, score): return ((score/total)*100) #Duplicate Check def isDuplicate(args): wit...
fdd80f7548e2175a4ab94787a57cdf5c87d58cf6
SuperGuy10/LeetCode_Practice
/Python/119. Pascal's Triangle II.py
921
3.828125
4
''' Tag: Array; Difficulty: Easy. Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3,3,1]. Note: Could you optimize your algorithm to use only O(k) extra space? ''' class Solution: def getRow(self, rowIndex): """ :type rowIndex: int :rtype: ...
e517e45ad662a52fc05aa15f07d1d053e504292c
yeonjooyou/algorithm
/baekjoon/Python/10809.py
275
3.609375
4
# 알파벳 찾기 S = list(input()) spot_list = [] for _ in range(26) : spot_list.append(-1) for i in range(0, len(S)) : string = ord(S[i])-97 if spot_list[string] == -1 : spot_list[string] = i for i in range(0, len(spot_list)) : print(spot_list[i])
75da9e361823babde5d7b960793c64fb8150bee4
eduardorasgado/machine-learning-cursoSentdex
/knearestOwn.py
1,699
3.546875
4
# -*- coding: utf-8 -*- """ Created on Mon Jun 26 03:38:07 2017 @author: Eduardo RR K nearest neightbors from scratch. Machine learning p 16 """ #distancia en 3-nearest neighbors import numpy as np from math import sqrt import matplotlib.pyplot as plt from matplotlib import style from collections import Co...
4ca5b0c5ef25c05e02e54fe84dc2ae9b5d4a5bb7
alekhaya99/DSA_Python
/Recursion/GCD.py
338
4
4
a=int(input("Please Enter the first number")) b=int(input("Please Enter the second number")) def GCD(a,b): assert int(a)==a and int(b)==b, "Please Enter a positive integer" if (a%b==0): return b if(a<0): a=-1*a if(b<0): b=-1*b else: return GCD((int(b)),int(a%b)...
9585f570decc13418bc9fc92486c7f2299d972b2
Divya-780/Python-Training-Program
/Day_2/tw0_dates_diff.py
274
4.375
4
#Write a Python program to calculate number of days between two dates. #Sample dates : (2014, 7, 2), (2014, 7, 11) #Expected output : 9 days from datetime import date first_date = date(2014, 7, 2) last_date = date(2014, 7, 11) diff = last_date - first_date print(diff.days)
552462aec53a47278fd6bd00e4dc9c6b183bc448
atehortua1907/Python
/MasterPythonUdemy/7-Funciones/7.4-RetornarDatos.py
629
3.921875
4
def calculadora(numero1, numero2, soloBasicas = False): suma = numero1 + numero2 resta = numero1 - numero2 multi = numero1 * numero2 division = numero1 / numero2 resultados = f"Suma = {suma}" resultados += "\n" resultados += f"Resta = {resta}" resultados += "\n" if soloBasicas == ...
f6c67d09c3244e4e5d27b83609f9d317b5a31e17
williancae/pythonGuanabara
/mundo03/Exercicios/ex105.py
307
3.96875
4
def leiaInt(num): while True: valor = str(input((num))).strip() if valor.isnumeric(): return valor else: print('\033[1;31mERRO! Digite um número inteiro válido\033[m') if valor.isnumeric(): break n = leiaInt('Digite um número: ') print(f'Você digitou o número {n}')
7f0353b6bddb34750dd7615d2876625bbd600c79
ElenaRoche/python
/triangulo_rectangulo.py
334
4.03125
4
def triangulo_rectangulo(): a=input("Cuanto mide un cateto") b=input("cuanto mide el otro cateto") c=input("cuanto mide la hipotenusa") if (c*c==a*a+b*b): print ("Efectivamente, es un triangulo rectangulo") else: print ("No vas bien, no es un triangulo rectangulo") triangulo_...
8a557c0810d95d1802532538fab261a50dae7293
Pumala/python_loop_exercises
/print_a_square.py
116
3.75
4
print "Print a Square Exercise" # Print a 5 x 5 square of "*" characters for row in range(0, 5): print "*" * 5
4f7e827051a42ae4bb9e220e94bc18374029718f
MateusMartins/python
/Exercicios/DESAFIO 34.py
167
3.703125
4
salary = float(input('Digite seu salário: ')) if salary > 1250: newSalary = salary*1.1 else: newSalary = salary * 1.15 print('R$:{:.2f}'.format(newSalary))
e779d3784a6ae29396d036102ad6178394dec169
hallzy/DailyInterviewProSolutions
/2019/09-september/09/solution.py
534
4.0625
4
def staircase(n): # Fill this in. if n <= 0: return None return fibonacci(n+1) def fibonacci(n): if n < 0: return None if n <= 1: return n; # First 2 fibonacci numbers num1 = 0 num2 = 1 for x in range(1, n): sumVal = num1 + num2 num1 = num2...
b708ffe773ddc9e48734e5c12ab5ff2492c85499
veltman/euler
/28/28.py
488
3.953125
4
def get_corners(size): # special case for center of spiral if size == 1: return [1] # upper-right corner is size^2 # other three corners each subtract size - 1 return map(lambda x: size * size - (size - 1) * x,range(4)) def corner_total(size): # size needs to be odd assert size % 2 == 1 # odd num...
9afc094719a770d17ddf5ff748b8290080fed378
jiangchuanwei/gittest
/图书管理系统.py
2,195
3.65625
4
#!/usr/bin/python #-*-coding:utf-8-*- class BOOK(object): books=[['三国','罗贯中','1','A区'], ['西游记','吴承恩','1','B区'], ['水浒传','施耐庵','1','C区']] def __init__(self,name,zuozhe,zhuangtai,weizhi): self.name=name self.zuozhe=zuozhe self.zhuangtai=zhuangtai self.weizhi=w...
3bb4ebb9bf452e0d8387826190f42fda106a2c98
corniab/cse210-tc06
/mastermind/game/colors.py
1,393
4
4
from colorama import init, Fore, Back, Style class Colors: """This class is designed to look at the inputs of the players and the board, and adjust the color depending on the player and make the code more visual to interact with""" def __init__(self, name): """This is the class constructor, the v...
4e55009afee48335bf0717ee02318b46bc3c8cd4
Kew-Forest/chapters2-4
/chapter_3/5a.py
200
4.03125
4
#Assume you have the assignment xs = [12, 10, 32, 3, 66, 17, 42, 99, 20] #Write a loop that prints each of the numbers on a new line. xs = [12, 10, 32, 3, 66, 17, 42, 99, 20] for i in xs: print(i)
10cc9e17a9d08d54d53dfdd1ef852d6cf66beb35
mary-tano/python-programming
/python_for_kids/book/Examples/graphic1.py
760
4.03125
4
# Графика в Python from tkinter import * # Размеры окна Breadth = 500 Highness = 330 # Функция события def buttonClick() : Graphic.create_rectangle(20, 20, Breadth-20, Highness-20) Graphic.create_oval(20, 20, Breadth-20, Highness-20) Graphic.create_line(Breadth/2, 20, Breadth/2, Highness-20) Graphic.create_li...
ee0376a694e54bbb551dc4e125848ea1b0a8ff8b
jemd321/LeetCode
/112_path_sum.py
950
3.796875
4
class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class PathSum: def hasPathSum(self, root, sum): return self.path_sum_helper(root, sum, 0) def path_sum_helper(self, node, path_sum, count): if not node: return...
4f43e4cd1a1b6e6fe94e502ab5f6caab3163a72b
BSir17/python_study_100days
/day8_class.py
2,163
4.125
4
#类 这里讲的是封装 #day9继续 class Student(object): # __init__是一个特殊方法用于在创建对象时进行初始化操作 # 通过这个方法我们可以为学生对象绑定name和age两个属性 #在Python中,属性和方法的访问权限只有两种,也就是公开的和私有的, # 如果希望属性是私有的,在给属性命名时可以用两个下划线作为开头 def __init__(self, name, age): self.name = name self.age = age self.__foo = "afoo" #方法也是私有 加两...
02468c3669104c1ad2f3d867c8833c16304fe167
jsvmelon/pythonUdemy
/basics/truefalse.py
356
4.1875
4
day = "Friday" temperature = 30 raining = False if (day == "Saturday" and temperature > 27) or not raining: print("Go swimming") else: print("Learn Python") # if 0: print("True") else: print("False") name = input("Name:") #if name: if name != "": print("Hello {0}".format(name)) else: pri...
590cea0c8ba776b7c65bd6e66f55956c2411b793
naedavis/db-notes
/main.py
3,174
3.765625
4
# DDL - Data Definition Language # DDL Statements or Commands are used to define and modify # the database Structure of your tables or schema. # DDL Statement, it takes effect immediately. # DDL COMMANDS ARE : # CREATE – to create table (objects) in the database # CREATE database Hospitals; # ALTER – alters the str...
64f7b84a6fd80baf4f78a2f378e098c1236287c8
kangness/PythonTest
/for.py
326
4.15625
4
#!/usr/bin/env python for country in ["Denmark","Finland","Norway","Sweden"]: print(country) countries = ["Denmark","Finland","Norway","Sweden"] for country in countries: print(country) for letter in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": if letter in "AEIOU": print(letter,"is a vowel") else: print(letter,"is a conson...
610dfcf32e22219f9f3dca7a996d9c0c333eef35
kadedemytgithub103/Python_pg
/4-10.py
183
3.59375
4
num = int(("0~100までの得点(整数値)を入力してください")) if num >= 0 and num <= 100: print("正しい入力値です") else: print("入力値が不正です")
3ef8280dd4008ce2f27fb71550a783dd244427c7
SoraGefroren/Practicas_relacionadas_al_NLP_utilizando_Python
/Práctica_01/Practica1_Ejer.3.3.py
2,368
3.75
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import codecs import random _stdin_encoding = sys.stdin.encoding or 'utf-8' # 3.3. Ejercicio: Ahorcado class Ahorcado: # Constructor def __init__(self, p, E): # Palabra objetivo self.p = p self.pTemp = "" # Ajuste ...
077dfa8684c307a323ba42c36b1e0f156ebfc858
Kadasix/four_point_calculator
/main.py
5,050
4.28125
4
# Grade Calculator import math import sys import time print("Welcome to the Grade Calculator. This only works on a 4-point scale.") print("Input all grades in the following format:") print("If it's one grade, input the only the letter A, B, C, D, or F. Ignore any X grades. Enter Z grades as an F.") print("If it's more...
5573e6969f51e5edad9dcf8f3ed4856d5c5d8dfe
skylinebin/AlgorithmPractice
/HuaWeiOJ Algorithms/What-I-had/encryanddecry.py
1,347
3.640625
4
def encry(strone): beencry = [] for w in strone: if w>='a'and w <='z': if w =='z': w ='A' else: w = chr(ord(w.upper())+1) elif w>='A'and w <='Z': if w =='Z': w ='a' else: w = chr(ord(w...
5c15bf0fc0c60b6bc8536e17decacd955c34956b
brycekelleher/pythondev
/reverse_dict.py
250
3.90625
4
def reverse_dict(d): r = {} for k in d: v = d[k] if v not in r.keys(): r[v] = [] r[v].append(k) r[v] = sorted(r[v]) return r test = {1:10, 2:20, 3:30} print reverse_dict(test) test = {4:True, 2:True, 0:True} print reverse_dict(test)
aa35f18c5e5054e2284052bd26f109ac24cb5967
xiangkangjw/interview_questions
/leetcode/python/150_evalRPN.py
669
3.765625
4
import math class Solution: # @param {string[]} tokens # @return {integer} def evalRPN(self, tokens): operators = {'+', '-', '*', '/'} nums = [] for token in tokens: if token in operators: num2 = nums.pop() num1 = nums.pop() if token == "+": nums.append(num1 + num2) ...
268af8163bd72a8f5414ef6f21334c871169f71b
Xin-SHEN/CIE-ComputerScience
/A-Level/2019_ALevelCS_Pre-Release/Pre-Release Ref/task1.py
1,785
4.4375
4
# Task 1.1 # Input student data in the format <student_name>#<email_address> # Task 1.2 # Find if there are empty arrays in student data and do not output this # Task 1.3 # Allow the user to search the array by name and return the name and email size_of_class = 3 # 1.1(1) - declare the array student_data = [] # 1....
8ee66f3bfdd28d5c85d3ab66e2fbe1b3345ab9dc
Meg2tron/ACM-ICPC-Algorithms
/2Sum/2 Sum.py
332
3.5
4
a=input().split() print("Enter number you want to check:") x=int(input()) f,s=0,0 flag=0 for i in range(len(a)): for j in range(i+1,len(a)): if(x==int(a[i])+int(a[j])): f,s=i,j flag=1 break if(flag==1): break if(flag==1): print(f,s) else: print('Sum n...
6762a6575114f1dd42de1de7d850e7cf02da048f
gilmp/python-development
/python-if-statements/excercise_if_operator.py
1,000
4.09375
4
#!/usr/bin/env python number = 18 second_number = 0 first_array = [1, 2, 3] second_array = [1, 2] # If number which is 18 is greater than 15 print out 1 if number > 15: print("1") # If the first_array has ANY value (ie, it is not empty) print 2 if first_array: print("2") # Using the len function, if no. of...
bcbffd10cce660db5b1517228540e5636030089c
C-Camarillo/prueba
/PISA_lectura.py
1,091
3.515625
4
#PISA_lectura from tkinter import Tk,Label proceso = 0 def Cronometro(x): def iniciar(x): global proceso # mostramos la variable contandor time['text'] = x #Este es el cronometro que cada 1000 ejecuta la #funcion iniciar() con el argumento x r...
1107c27799d5526ffa77611be029b1297f41875f
zehraribic/DOMACA-NALOGA-2
/DOMACANALOGA2.py
975
4.15625
4
print('Hello users! This program will convert km to miles.') #vnasanje števila v km number_km = int(input("Enter the number!")) print ('Vrednost pretvorjena v milje:', 0.621 * number_km ) #vprasaj uporabnika ce zeli nadaljevati answer = "yes" while answer == "yes": answer = input("D...
3ac4ba5231d45deab15680dfbe988609aa8437a9
alexcs123/Rubik
/classes/Cube.py
37,075
3.671875
4
from random import choice from classes.Side import Side from enums.States import States from enums.Colours import Colours class Cube: """Cube object""" def __init__(self, state=States.solved, shuffles=100): """Constructs cube in given state""" self.up = Side(Colours.white) self.front =...
cc4ca487a5b0e57217c3003235dfd42982131bdf
MrHamdulay/csc3-capstone
/examples/data/Assignment_9/cvdsha002/question3.py
915
3.828125
4
"""Shahrain Coovadia""" list=[] #create empty list for grid grid1='' #create a holder cont1='no' #creates continuation/stopping clauses cont2 ='yes' b=0 while len (list)<9: list.append(input()) #add input to list for i in range(9): if str(1+i) in list[i]: #checks if number...
ce255d37a87c1bc214351bc4c1f14e7523a26616
Derrior/tutorials
/python-tutorial/set.py
810
3.90625
4
a = [1, 2, 3, 4, 3, 2] print(a, len(a)) print("creating set from list") print(set(a), len(set(a))) print("\n\n\n") #how to add, remove and check if element is in Set = set() for i in range(1, 10): Set.add(i) print("add from 1 to 10") print(Set, len(Set)) for i in range(5, 15): Set.add(i) print("add from 5 to ...
d0e2cbbe578705d8d58ae778c1cc1ecdd40e4b8c
Moglten/Nanodegree-Data-structure-and-Algorithm-Udacity
/Data Structure/linked_lists/Swap-Nodes_solution.py
1,429
4.1875
4
def swap_nodes(head, left_index, right_index): """ Given a head of LinkedList, swap Left index with right index in that linkedList Args: head : head of LinkedList left_index : index will be swapped left_index : index will be swapped Returns: head : Return the head of new Lin...
7bc53ee269ea36fbe6b7d07029e19eb6a25c942f
JohnTuUESTC/leetcode_program
/ReverseLinkedList.py
1,477
4
4
#coding:utf-8 ''' leetcode: Reverse Linked List ''' # Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def reverseList(self, head): """ :type head: ListNode :rtype: ListNode "...
59e92fd70a5325f90acb8b6e46a8bbe3e86a8452
suryaambrose/boardgame
/boardgame/player.py
1,066
3.890625
4
class Player(object): """ Base class for players """ def __init__(self, name): """ :param name: player's name (str) """ self.name = name def play(self, state): """ Human player is asked to choose a move, AI player decides which move to play. :param state: Current state of the game (GameState) "...
e8ac316413d2c351b77d9f2fc0251b8c469c2b6f
zeroTwozeroTwo/MyNoteBook
/Python/Example/05_高级数据类型/ex_20_for语法练习.py
234
3.890625
4
for num in [1, 2, 3]: print(num) if num == 2: break else: # 如果循环体内部使用了break退出了循环 # else 下方的代码就不会被执行 print("会执行嘛?") print("循环结束")
c7b77ab1a92dc8bc7af58b0e9a47af93cfb6450e
coreyderosa/Python-Tkinter
/LyndaCourse3.5.py
900
3.609375
4
from tkinter import * from tkinter import ttk root = Tk() month = StringVar() combobox = ttk.Combobox(root, textvariable = month) combobox.pack() combobox.config(values = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')) #displays the values in...
e9c492ba60114964c47281d3d051afe890b2b52f
316328021/TallerdeHerramientasComputacionales
/Programas/Tarea04/Problema07.py
340
4.03125
4
# -*- coding: utf-8 -*- #Definir un función que identifique un número mayor de dos números def mayor(a,b): if a > b: return a else: return b #Para 3 números def mayor2(a, b, c): if a > b and a>c: return a if b > a and b>c: #Aquí se puede usar elif return b else: ...
df46f92315a7aefd19e55392ea7d4536c954a642
nialaa/blurred-notes
/python/ex10.py
559
3.546875
4
print "I am 6'2\" tall." #escape double-quote inside string print 'I am 6\'2" tall.' #escape single-quote inside string tabby_cat = "\t I'm tabbed in." persian_cat = "I' split \non a line." backslash_cat = "I'm \\ a \\ cat." installation = 0 fat_cat = """ I'll do a list: \t* Cat food \t* Fishes \t* Catnip\n\t* Gras...
8b70b29cf39fe5781cc12ce92ae3a7de99fc6548
guppikan/PythonLearning
/PritningFucnAgrs.py
415
4
4
# Author : Guru prasad Raju ''' Function such that it can accept a variable length of argument and print all arguments value''' '''To create functions that take n number of Positional arguments we use * with arguments ''' def newfunction(*args): for i in args: print(i) newfunction(10, 20, 30, 40....
07eb04debfc79295565626cfef43477a945b26ca
raghu1199/Advance_Python
/File_Handling/CSV_file.py
498
3.734375
4
file=open("csv_data.txt","r") lines=file.readlines() file.close() lines=[line.strip() for line in lines[2:]] for line in lines: person_data=line.split(",") name=person_data[0].title() age=person_data[1] university=person_data[2].title() degree=person_data[3].capitalize() print(f"{name} is {a...
d962158d9c6a67810c0fc9c080e25891525e76a7
Scott-Larsen/HackerRank
/BirthdayCakeCandles.py
1,059
4.15625
4
# You are in charge of the cake for your niece's birthday and have # decided the cake will have one candle for each year of her total # age. When she blows out the candles, she’ll only be able to blow out # the tallest ones. Your task is to find out how many candles she can # successfully blow out. # For example, if y...
6fe02509edc4c2a3d3f32eb40d04dca92cdbf5b1
gsbelarus/ds
/src/task6.py
440
3.96875
4
def calc_det2x2(m): return m[0][0] * m[1][1] - m[0][1] * m[1][0] def calc_det3x3(m): return m[0][0] * calc_det2x2([[m[1][1], m[1][2]], [m[2][1], m[2][2]]]) \ - m[0][1] * calc_det2x2([[m[1][0], m[1][2]], [m[2][0], m[2][2]]]) \ + m[0][2] * calc_det2x2([[m[1][0], m[1][1]], [m[2][0], m[2][1]]]) if __name__ ==...
d4b983f180eb70b573fc382078ee46d441923e83
lxiaokai/team-learning-python
/取个队名真难-H/day03/simpleadd.py
1,376
3.71875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- #主程序入口 if __name__ == '__main__': flag = 1 while True: a=input("请输入一个数字:") if a == "q": break else: b=input("请再输入一个数字:") pi=3.14 #计算加法 sum=float(a)+float(b) print('数字 {0...
4cea5fcfe92f3c1dc796c906e06b909d1e4079da
Aayush-Ovhal/C105-standard_deviation_homework
/std_deviation_hw.py
569
3.78125
4
import csv import math with open("std_deviation.csv", newline='') as f: reader = csv.reader(f) fileData = list(reader) newData = fileData[0] def mean(data): n = len(data) total = 0 for i in data: total += int(i) mean = total/n return mean squareNo = [] for...
226c02d5fbb647807ecc2894d8a87f36a50dcd68
jdblackstar/cs-module-project-hash-tables
/Assignments/Assignment-1.py
1,171
4.1875
4
# Hash Tables # What they solve # Standard Array Search # Main Hash Table operations: # GET # PUT # DELETE HASH_DATA_SIZE = 8 hash_data = [None] * HASH_DATA_SIZE def hash_function(s): ''' Take in a string, return sequence of bytes. ''' # O(n) over the key length # O(1) over the...
039cd3c52e49b78565a8fffaba4842b9d3a20d8b
mahamatnoumai/Python-Training-Code
/solutions.py
242
3.734375
4
if __name__ == '__main__': n = int(raw_input()) if((n%2) == 0) print"Weird" elif((n%2)==0 && n<2 && n>5) print"Not weird" elif((n%2)==0 && n>6 && n<20) print"Weird" elif((n%2)==0 && n>20) print"Not Weird"
0ea349ba3475e07402a3f8d5c734c4d1862f810a
c0ns0le/HackBulgaria
/week01/week01_03/p04_iterationsOfNaNExpand.py
468
3.78125
4
def iterations_of_nan_expand(expanded): if expanded == "": return 0 occurances = expanded.count("Not a") if occurances == 0: return False return occurances if __name__ == "__main__": print(iterations_of_nan_expand("")) print(iterations_of_nan_expand("Not a NaN")) print(it...
89827fc1dbb9b966190c44fe3a37c12fdf68fd82
aizedsumbal/Python-for-everyone
/python_for_everyone/Chapter 5/Q2c.py
242
4.125
4
num1 = input("Enter your number") num2 = input("Enter your number") num3 = input("Enter your number") def sorted(x,y,z): if x < y and y < z: return "true" else: return "false" a = sorted(num1, num2, num3) print(a)
ad24d782ec882ecef976ba6399359f1c5b81aad6
AstroHeyang/-offer
/009-变态跳台阶/jumpFloorII.py
280
3.625
4
# 动态规划 def jumpFloorII(n: int) -> int: dp = [0] * (n+1) dp[0], dp[1] = 0, 1 for i in range(2, n+1): dp[i] = 2 * dp[i-1] return dp[n] # 数学归纳法 & 递归 def jumpFloorII(n: int) -> int: if n == 0: return 0 return 2 ** (n-1)
3ab6ec88967a141deb5be35295f7526700b5ac29
dispe1/Hackerrank-Solutions
/Algorithms/05. Search/004. Minimum Time Required.py
782
3.515625
4
# Problem: https://www.hackerrank.com/challenges/minimum-time-required/problem # Difficulty : Medium # Score : 35 import math import os def minTime(machines, goal): minday = math.ceil(goal / len(machines)) * min(machines) maxday = math.ceil(goal / len(machines) * max(machines)) while minday < maxday: ...
b1e3343474d22903e458ec331eef294addfd8a98
jianzuoyi/jianzuoyi.github.io
/post/rosalind/code/Counting_DNA_Nucleotides.py
590
3.6875
4
from collections import defaultdict; def count_dna_nucleotides(dna): d = defaultdict(int) for c in dna.upper(): d[c] += 1 return "%d %d %d %d" % (d['A'], d['C'], d['G'], d['T']) def test(): dna = 'AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC' ret = count_dna_nucl...
987d50a4149bee9220e1e1ddc4f3f7781c42d0be
elijahknight/Python-School-Projects
/decryptVignere.py
4,742
3.609375
4
Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "copyright", "credits" or "license()" for more information. >>> WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable. Visit http://www.python.org/download/mac/tcltk/ for current information. >>>...
0b0c76b61d5bce8faceb5c09faa675152f3c9e60
balasesh/Data-Engineering-Qs
/pythonPracticeTest/fillupNone.py
827
3.859375
4
# Given an array containing None values fill in the None values with most recent non None value in the array # - input array: [1,None,2,3,None,None,5,None] # - output array: [1,1,2,3,3,3,5,5] def mostRecentNonNull(arr): if not arr: return arr temp = None for i in range(len(arr)): if arr[i...
358a762a045a2019bde220147c370f23b9c76c93
sohannaik7/python-fun-logic-programs-
/all_kind_of_string_inbuild_functions.py
2,021
3.765625
4
import random myList1 = [0]*10 myList2 = [0]*20 for i in range(0,10): myList1[i]= random.randint(0,20) myList2[i] = random.randint(1,100) name="sohan naik" if 10 in myList1: print('30 is present') if 20 not in myList1: print('120 is not present') print("concatinated list= ",myList1 ...
af4e9118564691fe71e2ba60f94d5cd32d6b1fc6
appeltone/WorldOfGames_Classes
/GuessGame.py
1,341
3.890625
4
from Game import Game from random import randint from Utils import clean_screen class GuessGame(Game): def __init__(self, diff): self.diff = diff def generate_number(self): secret_number = randint(1, self.diff) return secret_number def get_guess_from_user(self): print("==...
3fb9f32d4737a72a0483b63f747b13f6cc2b6fb7
Menighin/Studies-Tests
/Python/Python for Zombies/Exercises/Exercise 5/exercicio05_joaomenighin_01.py
65
3.703125
4
x = 2 y = 5 if y > 8: y *= 2 else: x *= 2 print (x + y)
062fced3a2d72f4c99ad8cf5eec972c4ea3934c9
zeng-team/zeng
/hao/基础_04多值参数.py
777
3.921875
4
# 多值参数 # 定义支持多值参数的函数:在参数名前加个“*”可以接收元祖 # 在参数名前加个“**”可以接收字典 # *args存放元祖参数, **kwargs存放字典参数 def demo5(num,*nums,**person): print(num) print(nums) print(person) demo5(1,2,3,4,5,name="小明",age="18") # 数字累加 def sum_numbers(*args): num = 0 print(args) # 循环遍历 for n in args: ...
a3539a18017935807680ad55dfc28b3d8d3a9525
danijar/training-py
/list_find_nth_last.py
622
3.8125
4
from list import random_list def find_nth_last(head, n=0): behind, current = head, head for _ in range(n): if not current: raise IndexError current = current.next while current.next: current = current.next behind = behind.next return behind if __name__ == ...
8e87c901035d57e0d125b3dcdd88b507c544c0b5
TuWeilin/CP1404
/prac_04/quick_picks.py
388
3.765625
4
import random def quick_picks(): CONSTANTS = [] quick_p = int(input("How many quick picks? ")) for i in range(quick_p): CONSTANTS=[] while len(CONSTANTS) != 6: numbers = random.randint(1,45) if numbers not in CONSTANTS: CONSTANTS.append(numbers) ...
2d8a5599e1d6c002cd17de1bf723a331203d64a5
kondrashov-do/hackerrank
/python/Strings/merge_the_tools.py
330
3.59375
4
def merge_the_tools(string, k): for i in range(0, len(string), k): s = set() for char in string[i:i+k]: if char not in s: print(char, end='') s.add(char) print() if __name__ == '__main__': string, k = input(), int(input()) merge_the_tools(s...
e5428649e4f17ad8f431fd91ff221aeb1a2d8517
yokonsan/Daily-LeetCode
/two-sum.py
1,020
3.859375
4
# Description: # Given an array of integers, return indices of the two numbers such that they add up to a specific target. # You may assume that each input would have exactly one solution, and you may not use the same element twice. # Example: # Given nums = [2, 7, 11, 15], target = 9, # Because nums[0] + nums[1] ...
54f08ab258eff28fc38dccd708a664f5d025ce27
TahirMia/RusheyProjects
/11 Modulus.py
353
3.65625
4
account=input("Please enter a 7 digit account number.\n") weight=[8,7,6,5,4,3,2] mult=[] for i in range (7): num=(int(account[i])*weight[i]) mult.append(num) total=sum(mult) modulus=total%11 check_digit=11-modulus print("The check digit is", check_digit,".") print("So the full account number...
944b1b7966113a0520127752e8f62a2be7e6e097
fredy-prudente/python-brasil-exercicios
/Estrutura Sequencial/ex02.py
180
4.15625
4
# Faça um Programa que peça um número e então mostre a mensagem O número informado foi [número]. n = int(input('Digite um número: ')) print(f'O número informado foi {n}!')
a340643175c266cea09bf321d5ee7691b19a630a
pyunixdevops/scripts
/Python/sort_list.py
427
3.890625
4
#!/usr/bin/python3 import random def insert_sorted(elem,list): if list == []: return [elem] elif elem < list[0]: return [elem] + list else: return [list[0]] + insert_sorted(elem, list[1:]) def gensort(list): sorted_list = [] for item in list: sort...
e5bc78d14cf72f37ed43f976efc7ef8dcead2c91
marciorela/python-cursos
/luizotavio/aula020/aula021 - for_else.py
325
3.640625
4
""" For / Else """ lista = ['nome1', 'axis'] for item in lista: if (item.startswith('x')): print(f'{item} começa com x') else: print(f'{item} não começa com x') for item in lista: if item.lower().startswith('x'): break else: print(f'Não existe uma palavra que comece com x.') ...
d986edecb0c0f414486a925012142e2a308f966a
JeongHM/coding_test
/codewars/Level_6/Making_Change.py
1,261
4.09375
4
# Making Change # Complete the method that will determine the minimum number of coins needed to make change for a given amount in American currency. # Coins used will be half-dollars, quarters, dimes, nickels, and pennies, worth 50¢, 25¢, 10¢, 5¢ and 1¢, respectively. # They'll be represented by the symbols H, Q, D, ...
f2286b101491c72bc67b87fad1e263c4e126fff4
sidhumeher/PyPractice
/Amazon/StringMatching.py
1,783
3.875
4
''' Created on Oct 21, 2020 @author: sidteegela ''' # Finding Substring or pattern matching of a string with Rabin Karp algorithm # Time complexity: Avg case: O(n+m). Worst case: o(n*m) for a bad hash function def search(pattern, text, q): d = len(text) # Taken as length of text. But can be any number m = ...
cd02dda7ee36f51762e8eb5345190a7fb696d1e1
ARJUNRAGHUNANDANAN/PY-DROID__for-Python-Programming
/area.py
336
4.4375
4
''' Python program to find area of a Circle given its Radius By - Arjun Raghunandanan ''' RAD=float(input("Enter the radius of the circle")) ''' Accepted the measure of radius as RAD ''' area=3.14*RAD**2 ''' Formula for finding area of circle is (3.14*(RADIUS**2)) ''' ''' printing the value of area ''' print...
22f643e37442e96a89cb55a21186bfdc7df15cf3
kasu-Ruby/Learn-To-Use-Github
/Projects/function_def.py
242
4.03125
4
def f(x): r=3*x+5 return r y=f(3) print(y) y10=f(10) print(y10) ############################### def greet(name): print("Welcome" +name) greet("abc") greet("xyz") ############################### #1.has argument ,no return value
6dccfaa9a670735f40c04a00ca429dc0f6372b59
SensenLiu123/LeetCode
/CompleteTreeNode.py
1,318
3.828125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def countNodes(self, root: TreeNode) -> int: if root is None: return 0 height = self.getHeight(root) ; ...
5384341b99c9da044a9e96cedfc22417d1f12d66
salma1415/Project-Euler
/022 Names scores/022.py
2,038
4.21875
4
''' Names scores ================================================== Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alpha...
b89dab8a28de0aa756c0b31dfb2b77900d57306e
thisnameisprivate/tkinter
/func_code1.py
249
3.65625
4
class Student (): def __init__(self, name="NoName", age = 18): self.name = name self.age = age def say (self): print("My name is {0}" . format(self.name)) def sayHello (): print("hi, 欢迎来到图灵学院")
6b87d13f3287506d9c9593de3c879877721c4a3a
Win-Htet-Aung/kattis-solutions
/alphabetSpam.py
393
3.765625
4
st = input() space = 0 upper = 0 lower = 0 symbol = 0 upperLis = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" lowerLis = "abcdefghijklmnopqrstuvwxyz" total = len(st) for i in st: if i == "_": space = space + 1 elif i in upperLis: upper = upper + 1 elif i in lowerLis: lower = lower + 1 else: symbol = symbol + 1 print(space...
b830bcf18a972b298f8510778ff3a23f883ba43f
Park-liv/DataStructure
/DS_class.py
2,248
3.515625
4
''' 클래스에선 __init__ 메소드가 필수 객체화가 될때 바로 호출됨 인스턴스 생성 초기에 변수를 지정해줌 self란 레퍼런스를 가르킴 클래스 내부 함수는 무조건 self가 필요 실제 사용되지 않음 다른 목적으로 사용됨 클래스 메소드의 첫번째 인수로 self를 써줘야 해당 메소드를 인스턴스의 메소드로 사용할 수 있게 됩니다. 클래스 변수와 함수는 클래스 내에 하나만존재 스태틱 함수는 클래스내에 있는 변수를 사용하지않는다. 스태틱함수를 쓰면 객체를 사용하지 않아도된다 클래스 함수와 스태틱 함수는 self를 사용하지 ...
b6c94032a0d456c43c14a21a0277d4d743b40480
michaelbradley91/sokoban
/coordinate.py
1,617
4.09375
4
from math import sqrt from typing import Tuple class Coordinate: def __init__(self, x: int, y: int): self.__x = x self.__y = y @property def x(self): return self.__x @property def y(self): return self.__y def to_float(self) -> Tuple[float, float]: ret...
2d40e55b64346bb64da17507d4aab2765a71d094
Bashtenko/markup
/homework/fizzbuzz3.py
666
3.5625
4
"""fizz = int(input("enter number 1: ")) buzz = int(input("enter number 2: ")) n = int(input("enter number 3: "))""" import sys in_filename = sys.argv[1] out_filename = sys.argv[2] in_file = open(in_filename, "r") out_file = open(out_filename, "w") for line in in_file: numbers = line.split() fizz = int(numbers[0]) ...
fb01349a1827d449863b9b669c64375caf7c6d0a
laxmi18/APS-2020
/CodeChef/laser.py
3,209
4.15625
4
# A Python3 program to find if 2 given line segments intersect or not try: class Point: def __init__(self, x, y): self.x = x self.y = y # Given three colinear points p, q, r, the function checks if # point q lies on line segment 'pr' def onSegment(p, q, r): if ( (q.x <...
4a95cf9ed19ab3fb989f3c001c219f91c075692f
Diqosh/PP2
/TSIS3/3760.py
312
3.75
4
if __name__ == '__main__': num = int(input()) dic = dict() for i in range(num): st1, st2 = input().split() dic[st1] = st2 textToSynonim = input() for m, n in dic.items(): if textToSynonim == m: print(n) elif textToSynonim == n: print(m)
e053de02dcc64ebf6ee2dd1b7ed833c81e5f9ed5
Car-Scz/Python-Projects
/TextSearch&Extract.py
3,071
3.890625
4
''' Python version: 3.8.2 Author: Carol Schultz Purpose: The Tech Academy - Python Course This script will create a database and then create a table with two fields. Then an array will be processed and those elements that end with '.txt' will be written to t...
179bb7bbf1276517be341004b34178a5be93e5c6
hearsid/hackerrank
/__python/py-strings/find-a-string.py
227
3.78125
4
def count_substring(string, sub_string): loop_times = int(len(string)/len(sub_string)); total = [1 for i in range(0,len(string)) if string[i: i+len(sub_string)] == sub_string] total = sum(total) return total
a2e756c998e2d37014dadcb35bb6e394ae768bfe
Ydeh22/QuantumComputing
/quirkspace/gates.py
2,421
3.703125
4
''' File: gates.py Author: Collin Farquhar Description: Defining the basic quantum gates in matrix representation Note: I will take the "first bit" to mean the bit on the left of the binary representation, to compliment the standard textbook representation Note1: This is a work in progress. More gates to come! ''' ...
7e6fdd692f3957f02236f099395f65e00e7f707b
Prashant47/algorithms
/tree/print_root_to_leaves_path.py
805
4.21875
4
# print path to leaves class Node: def __init__(self,val): self.left = None self.right = None self.val = val def printPathToLeaves(root,path): if root is None: return # append the current node in list path.append(root.val) # you have reached to leave now print th...
abebd06788fd47dbab9773fc1f64e100de2476e2
ATLS1300/pc04-generative-section12-kaily-fox
/PC04_GenArt.py
2,262
4.125
4
""" Created on Thu Sep 15 11:39:56 2020 PC04 start code @author: Kaily Fox ********* HEY, READ THIS FIRST ********** My image is of a star and a moon in the night sky. I decided to do this because the sky is one of my favorite parts of nature. Its' beauty is so simplistic yet breath taking. The natural phenomenas t...
c8d667e9ea07bbb2f45ace63c50f883f6bb9ff52
abhabongse/aoc2020
/mysolution/day09_encoding_error/solve.py
2,688
3.6875
4
from __future__ import annotations import collections import os from collections.abc import Sequence import more_itertools def main(): this_dir = os.path.dirname(os.path.abspath(__file__)) input_file = os.path.join(this_dir, 'input.txt') numbers = read_input_files(input_file) # Part 1: find the fir...
e703a1f3c71246e23ea0c4769f9589eee2e4774f
viniferraria/URI
/Python/1116.py
249
3.65625
4
def _divisao_(x,y): try: return x/y except: return "divisao impossivel" def _main_(): x = int(input()) for i in range(x): x,y = map(int,input().split()) print(_divisao_(x,y)) _main_()
e1e3902aff98379a151c841ffb9491e7894df885
27hope/snehu
/ntimes.py
56
3.5
4
n=int(input()) for n in range(n): print("Hello")
278e1e572da8c86252e840d18387ddebf9a77a07
neilmarshall/Project_Euler
/134/PE_134.py
1,501
3.6875
4
#! venv/bin/python3.7 """ Consider the consecutive primes p1 = 19 and p2 = 23. It can be verified that 1219 is the smallest number such that the last digits are formed by p1 whilst also being divisible by p2. In fact, with the exception of p1 = 3 and p2 = 5, for every pair of consecutive primes, p2 > p1, there exist ...
4ae5f973c40dc36433539d0d2f2145c7d865a022
benjief/pcc_alien_invasion
/exercises/rocket_bullet.py
2,891
3.90625
4
import pygame from pygame.sprite import Sprite from math import sin, cos, radians class RocketBullet(Sprite): """A class to manage bullets fired from a rotating rocket.""" def __init__(self, ai_game): """Create a bullet object at the rocket's current position.""" super().__init__() self.screen = ai_game.scree...
a88bab872a4494330032b255cbff472b9fa1d40f
Eddwaily/-Simple-Forum
/atm solution/atm_class.py
1,542
3.84375
4
from time import ctime, sleep from collections import namedtuple class ATM: def __init__(self, balance, bank_name): self.balance = balance self.bank_name = bank_name self.withdrawal_tuple = namedtuple( 'withdrawal','value date' ) self.withdrawal_list = [] def _line(se...
6a9dc751e06689e45be14b06c9f447a27872512f
korea3611/practice
/comento/자료형의 값을 저장하는 공간, 변수.py
557
4.09375
4
a = [1,2,3] print(id(a)) # 리스트를 복사하고자 할 때 # 이렇게 하면 id 값이 동일하게 나옴 b = a print(a is b) # a 를 바꾸면 b 도 바뀜, 동일한 id 값을 가지고 있기 때문 # 1. [:] 이용하기 a = [1,2,3] b = a[:] a[1] = 4 print(a,b) # 2. copy 모듈 사용 from copy import copy b = copy(a) # 변수를 만드는 여러가지 방법 a, b = ('python', 'life') (a, b) = 'python', 'life' [a,b] = ['python...