blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
8b7564e7d455e89b129e36852f851a5f2c9b1e2f
code-ninja-james/MachineLearning-DataScience
/Python/built_in.py
125
3.546875
4
#inbuilt functions and methods quote='to be or not to be' quote2=print(quote.replace('be','me')) print(quote2) print(quote)
dc0238dfd80b7303d03f763713238469352da9a1
brij2020/Ds-pythonic
/Quiz-Linked-List/Student_information.py
1,882
3.765625
4
""" QUIZE : Store information in linked list """ '''****** MARK Linked List for Each Students ******** ''' class Mark(object): next = None mark = None pass class Mark_lis(object) : head = None def markList(self, val): node = Mark() node.mark = val node.next ...
dad9b00b0340802b7326eb77981d794712ffb051
lishuchen/Algorithms
/lintcode/31_Partition_Array.py
654
3.703125
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- class Solution: """ @param nums: The integer array you should partition @param k: As description @return: The index after partition """ def partitionArray(self, nums, k): # write your code here # you should partition the nums by k ...
7013a8cde90c6f411724d6dfb748a6624163bf7b
KnightChan/LeetCode-Python
/Median of Two Sorted Arrays.py
1,105
3.5
4
class Solution: # @return a float def findMedianSortedArrays(self, A, B): '''There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). ''' la = len(A) lb = len(B) l =...
7c4cd9fb12ff84f37bac18da8a3882a2996d74b7
EduardoShibukawa/UEM
/MOA/Puzzle15/Utils/PriorityQueue.py
609
3.6875
4
import heapq class PriorityQueue: def __init__(self): self._queue = [] self._dic = {} def empty(self): return len(self._queue) == 0 def put(self, item): if str(item) in self._dic and \ self._dic[str(item)].fn() > item.fn(): self._dic[st...
a78b80791666b2554082bcd62730d5d079b743fb
RSANJAYKUMAR/THALA-DHONI
/vowel.py
154
3.84375
4
test=['a','e','i','o','u','A','E','I','O','U'] ss=raw_input() if(ss in test): print('Vowel') elif(ss!=test): print('Consonant') else: print('invalid')
465fc00d09131237489aed7d3b5fd1c98840aa4a
alexblumenfeld/gas-lines-puzzle
/gui-main.py
1,423
3.546875
4
from tkinter import * from tkinter import ttk # Set up a master frame for the whole window, as well as one frame for the game board and one for the configuration section root = Tk() general_frame = ttk.Frame(root,width=1000,height=1000) general_frame.grid(column=0,row=0,columnspan=20,rowspan=20) general_frame.columnco...
8e69a4426ce814d3124745a4f5cd7489dbdcfc52
tashvit/beginner_python_problems
/6_tiles_cost.py
744
4.5
4
# Find Cost of Tile to Cover W x H Floor - # Calculate the total cost of tile it would take to cover a floor plan # of width and height, using a cost entered by the user. # Floor tile cost calculator import math floor_width = float(input("Enter floor width: ")) floor_height = float(input("Enter floor height: ")) tile...
6ec7f51e6a0798b93e58d6a2b23565e644623bc3
hmhuan/advanced-python
/sets.py
713
4.21875
4
# This is sets 101 my_set = {"pomme", "orange", "chocolat", "gateau"} print(my_set) my_set = set([1, 2, 3, 4, 4]) print(my_set) my_set = set((1, 2, 3, 4, 4)) print(my_set) my_set = set("abcdefffgggghhhiii") print(my_set) # default {} -> dict a = {} print(type(a)) a = set() print(type(a)) # methods my_set = set() ...
8349ae8b4f1a41add64ec40c181c8739259223df
nathanielatom/Gravity-Well
/dimmer.py
2,532
4
4
""" Dimmer class Tobias Thelen (tthelen@uni-osnabrueck.de) 6 September 2001 PUBLIC DOMAIN Use it in any way you want... tested with: Pyton 2.0/pygame-1.1, Windows 98 A class for 'dimming' (i.e. darkening) the entire screen, useful for: - indicating a 'paused' state - drawing user's attention away from ...
0d237e78581e9bb73316d8f35a5f868e047963cb
frsojib/python
/Anisur/demo.py
146
3.609375
4
n = 20 m = 60 sum = n+m print("Your sum is " + str(sum)) print(f"{n} + {m} = {n+m}") # stop new line print("fayzur Rahman",end=" ") print("01779031617")
919c692bc6316ec4fa9e616cd2ca2d5a6feb6e49
danuker/piggies
/piggies/processing.py
1,598
3.5
4
import logging from decimal import Decimal from time import sleep logger = logging.getLogger('piggy_logs') def inexact_to_decimal(inexact_float): """ Transforms a float to decimal, through its __str__() method. >>> inexact_to_decimal(3.14) Decimal('3.14') Avoids doing the following: >>> D...
d2c1e86b6bd345c54188b982464fdb98a7166a8a
tuhiniris/Python-ShortCodes-Applications
/file handling/Reads a Text File and Counts the Number of Times a Certain Letter Appears in the Text File.py
439
4.09375
4
''' Problem Description The program takes a letter from the user and counts the number of occurrences of that letter in a file. ''' fileName=input('Enter the file Name: ') character=input('Enter letter to be searched: ') k=0 with open(fileName,'r') as f: for line in f: words=line.split() for i in wo...
c0520baa42a12071a220ffec33ea0629527ebf04
huiba7i/Mycode
/python/class code/code4.23/bank.py
2,760
4.15625
4
class Account: def __init__(self, card_code, name, password): """ 银行账户类 :param card_code:卡号 :param name:开户人 :param password:密码 """ self.card_code = card_code self.name = name self.password = password self.money = 0.0 def in_money(s...
7bae7a197afaf09e9b4b3bcb2e269ac099c75b4e
dimitrisarnellos/ThesisScripts
/extractFastaSeq.py
658
4.125
4
#!/usr/bin/python3 # # Program that outputs selected sequences from a FASTA file. # User supplies the FASTA file as first argument and the file with the sequence IDs # whose sequences we want to output as the second argument. import sys, re idList = [] with open(sys.argv[2], 'r') as f: for line in f: line = line....
116c32f8e4d3fc7296ce32fbb73b66459f1cd9c2
SherifElbishlawi/My-Codewars-Katas-Python-Solutions
/6kyu/Counting Duplicates/CountingDuplicates.py
874
4.34375
4
# Count the number of Duplicates Write a function that will return the count of distinct case-insensitive alphabetic # characters and numeric digits that occur more than once in the input string. The input string can be assumed to # contain only alphabets (both uppercase and lowercase) and numeric digits. # # Example #...
3c25d46c38984b86cad4634d6e9195f7a9e55fc8
HienPhanVN/Nguyen_Ly_May_Hoc
/TH_1.py
1,875
3.609375
4
# Cau 1 A = [2,5,3,6,7,8] # Cau 2 B =[] for i in range(200): B.insert(i,i+1) print(B[i]) #Cau 3 import numpy as np B = np.linspace(2,1000,500) #Cau 4 A5 = [] count = 0 for i in A: A5.insert(count,i+5) count += 1 #Cau 5 B3 = [] count = 0 for i i...
deb4063298f25b5a0319ce0b9d49b08f7a9b217b
MichaelIseli/GEOG5991_ABM
/agentframework_final_180204.py
2,251
3.875
4
#------------------------------------------------------------------------------- # Name: agentframework_final_180204 # Purpose: # # Author: Michael Iseli # # Created: 23/01/2018 # Copyright: (c) iseli 2018 #------------------------------------------------------------------------------- ''' Coding for...
3105ce97b8fca9539721b5b0b0e04c16b8b6e986
sunshinedude/practice
/leetcode/1002_find_common_characters.py
1,272
3.71875
4
# Problem # Given an array A of strings made only from lowercase letters, # return a list of all characters that show up in all strings within the list (including duplicates). # For example, if a character occurs 3 times in all strings but not 4 times, # you need to include that character three times in the final answ...
fc9db1f92dd41844c742c26f92449a65ea15135b
douglasleandro/adventure-game
/adventure_game.py
4,385
4
4
import time import random monsters = ['pirate', 'gorgon', 'troll', 'wicked fairie'] def print_pause(message): print(message) time.sleep(2) def intro(monster): print_pause("You find yourself standing in an open field, filled with " "grass and yellow wildflowers.") print_pause(f"Rumor...
ec269b0b75181455e4c50b55a81661fd4a042fbf
nandadao/Python_note
/note/my_note/second_month/day05/homework_day05.py
1,043
3.890625
4
""" 质数又被称为素数,是指一个大于1的自然数, 除了1和它自身外,不能被其它自然数整除, 且其个数是无穷的,具有许多独特的性质,现如今多被用于密码学上。 求100000以内的质数之和 """ # 自己的想法 # 做一个生成器,需要一个加一个 import time # def prime(): # # 求质数 # # for item in range(2, 1000): # 5 # if item == 2: # yield item # for i in range(2, item): # (2, 5) # if item % i == 0: # break # # y...
202e7daa2c1eefd3e77a07b2e05217999fc88faf
andysai/python
/风变编程/python基础-山脚班/fb_22.py
256
3.875
4
# 八、让用户输入一个数字,并指出这个数字是否是10的整数倍 number = int(input("请输入一个数:")) if (number % 10) == 0 : print("{}是10的整倍数".format(number)) else: print("{}不是10的整倍数".format(number))
566f5b664446a8cb27c14c8f954a19693cda2746
ESzabelski/Good-Projects
/better guessing game.py
2,323
3.984375
4
import random secretword=input("Please pick a secret word for the other person to match.\ It must be 4 letters or longer.") listb=[] listb.extend(secretword) lengthb=len(listb) #eg. result is v a n q u i s h AND length 8 while lengthb <4: secretword=input("Try again. It must be 4 letters or long...
3d03c3a3d003db3db750226fbfc3d0537900a6f4
Chamangro/PythonPUNCHIT
/Ejercicio 5 Edades.py
887
4.0625
4
#Ingresar las edades de dos personas. Si una de ellas es mayor de edad #y la otra menor de edad, calcular y mostrar su promedio. En caso #contrario mostrar las edades. MAYOR_DE_EDAD = 18 persona_1 = int(input("Ingrese edad de la persona: ")) persona_2 = int(input('Ingrese edad de la segunda persona: ')) if ...
0d7597237234e90a862b5f53c28dab847dd0ca26
Lawapaul/Fair-Calculator
/Travel Agency.py
476
3.796875
4
print(" F A R E C A L C U L A T O R ") a = int(input("Enter Distance: ")) b = int(input("Enter no of Children: ")) c = int(input("Enter no of adults: ")) if a>=1000 : Fare = 500 TF = c*500 + b*250 print("Total Fare: ",TF) if a<500 : Fare2 = 200 TF2 = c*200 + b*100 ...
aad1ed452a09af623ace7e24b40ead14f96baa09
ShimSooChang/exercicosdepython6
/1.py
257
4.09375
4
numero_1=int(input("entre com o primeiro numero:")) numero_2=int(input("entre com o segundo numero:")) numero_3=int(input("entre com o terceiro numero:")) soma= numero_1 + numero_2 + numero_3 quadrado= soma * soma print("o quadrado da soma é:" ,quadrado)
a329bdb126ec4caaec57fec32dc392259d6a660a
fywest/python
/shiyanlou_python3/student_teacher.py
1,927
3.703125
4
#!/usr/bin/env python3 import sys from collections import Counter class Person(object): def __init__(self, name): self.name = name def get_details(self): return self.name def get_grade(self, grade): print(grade) class Student(Person): def __init__(self, name, branch, yea...
3dd8c047c87c0b27781ed3c578bddf2f82287635
white812/tools
/deeplink/Lib/generate_func/base_class.py
1,752
4.25
4
INDENT = ' ' class FuncLine(object): __doc__ = """ This file is aimed to provide basic function line as an object. Generate() is able to return a function line with indent choosen """ def __init__(self, content='', next_indent_level_change=0, indent_level=-1): __doc__ = """ ne...
d509415e805166bbb1ca0a932fc52642a514321a
AlonsoCerpa/Tipos-de-Ordenamiento
/OrdBurbQuicksort.py
1,040
3.671875
4
def ordBurbuja(lista): a = len(lista) b = True while b: b = False for i in range(0,a - 1): if lista[i] > lista[i+1]: x = lista[i] lista[i] = lista[i+1] lista[i+1] = x b = True a = a - 1 return lista def ...
b0838c59349b32aa80c8b15ce4eccb8011982ffc
Alinda-Azzahra/POSTTEST
/percabangan.py
2,061
3.765625
4
#Program Percabangan import os def clear_screen(): os.system('cls' if os.name == 'nt' else 'clear') print("*" * 50) print("\t\t SELAMAT DATANG\n") print("\t\tTAKOYAKI ENAK LOH") print("*" * 50) beli = str(input("Apakah anda ingin membeli takoyaki?")) def varian(): clear_screen() print("~...
8dd0f231a9708c0ea83eba1710a22b8c7f46b29f
kailash-manasarovar/A-Level-CS-code
/algorithms/binary_search.py
2,155
4.125
4
# BINARY SEARCH # input - list, value to search for # algorithm # output - boolean # PREREQUISITE: list has to be in order!! # Big O (worst case scenario runtime) of Binary Search = log n # list has n items # _ _ _ _ _ _ # _ _ _ # _ # _ _ _ _ _ _ # _ _ _ # _ #import time def binary_search(list_of_elemen...
fe50cc22f8ad59b0106a003c653f3edb5e3805b9
jkaalexkei/TrabajosEnPython
/ejemplos/manejodearrays.py
337
3.875
4
def selectionSort(array): for i in range(len(array)-1): min_idx = i for idx in range(i+1,len(array)-1): if array[idx]<array[min_idx]: min_idx = idx array[i],array[min_idx] = array[min_idx],array[i] return array lista = [1,2,3,4,True] print(sele...
d1a9268efc0d6de57ff9023b5761d5a0b9b5e1ca
knrastogi/PythonPrograms
/EndTermLabExamSol/CA/mymath.py
721
4.34375
4
def square(n): ''' A function to return the square of a number. ''' return n**2 def cube(n): ''' A function to return the cube of a number. Usage: cube() ''' return n**3 def power(a,n): ''' A function to calculate power of n to a ''' return a**...
07d6d20fe97f18b7524621dcbd9b369b10d7890f
Eric-cv/QF_Python
/day5/test.py
350
3.75
4
''' break continue 跳转语句 ''' # 方式一 sum = 0 for i in range(10): if i%3 != 0: sum += i print('sum---111',sum) # 方式二 sum = 0 for i in range(10): if i%3 == 0: # pass 占位符 # break 跳出循环 continue # 跳过循环体中continue下方的语句不执行,直接执行下一次循环 sum += i print('sum---222',sum)
accd0244e45445ded5d5ea0ac6e2e2cd96178045
Man0j-kumar/python
/areaofcircle.py
101
4.21875
4
r=float(input("enter the radius of circle")) pi=3.14 area=pi*r*r print("area of circle is",area)
be8a85adf79d3a40f4ad3f005239bbc199565d47
ZDawang/leetcode
/144_Binary_Tree_Preorder_Traversal.py
1,971
3.546875
4
#!/usr/bin/python # -*- coding: utf-8 -*- #author : zhangdawang #data: 2017-12 #difficulty degree: #problem: 144_Binary_Tree_Preorder_Traversal #time_complecity: #space_complecity: #beats: class Solution(object): #递归 def preorderTraversal(self, root): def dfs(node, res): res.append(nod...
4437c504e3e7b77cd81662adc6d252251c20e3c9
MoreiraMatheus/Projetos_curso_em_video
/desafio 036.py
506
3.765625
4
casa = float(input('me diga o valor da casa: ')) salario = float(input('me diga seu salário: ')) anos = int(input('me diga em quantos anos você pretende pagar a casa: ')) prest = casa/(anos*12) print('o valor da casa será: \033[32mR${:.2f}\033[m, em parcelas de'.format(casa), end=' ') print('\033[32mR${:.2f}\033[m por ...
9267b15177e70556de8c9bcdfee63815e4121886
Celot1979/liga
/Jugadores.py
1,811
3.5625
4
import csv jugador = {} jugador_Segunda = {} jugador_SegundaB = {} def archivo_primero(): with open("jugador_uno.csv", "w") as csv_file: write = csv.writer(csv_file) for key, value in jugador.items(): write.writerow([key, value]) def archivo_segundo(): with open("jugador_dos.csv", "...
76c20ab1595d91c77539117f16b7b6f3f456dd76
multiscripter/python
/wikibooks/ch12_07_stdlib_array.py
535
3.984375
4
from array import array # Эффективные массивы числовых значений. # https://docs.python.org/3/library/array.html arr = array('i', [1, 2, 3, 4, 5, 6]) # Создаёт экземпляр класса Array типа int. print('arr.itemsize:', arr.itemsize) # Размер одного элемнета массива в байтах. arr.append(10) # array.count(x) # Вернуть коли...
6b16b04a69f3421e84af32931be6d98b70848cb3
mukeshkumarsahani/Python-for-Beginner
/Python/Function.py
933
4.09375
4
''' Keyword ---> def Syntax ---> def function-Name(): ## Body calling ---> function-Name() ''' def First(): print("Hello Mukesh!") # ending function print("Top") First() # Function is calling print("Bottom") # Top # Hello Mukesh! ...
5286488c5904134801ec8d69ccb19ece283e6102
superY-25/algorithm-learning
/src/algorithm/202003/countCharacters.py
697
3.71875
4
class Solution: def countCharacters(self, words: list, chars: str) -> int: count = 0 for item in words: temp = 0 temp_chars = chars for c in item: if c in temp_chars: temp += 1 temp_chars.replace(c, '', 1) ...
317f45348f7452d662102ac867f6c4da6e47571f
Hawk453/Project-Euler
/even fibonacci clever approach.py
799
4.125
4
#Each new term in the Fibonacci sequence is generated by adding the previous #two terms. By starting with 1 and 2, the first 10 terms will be: #1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... #By considering the terms in the Fibonacci sequence whose values do not #exceed four million, find the sum of the even-valued terms. #By...
6b9a791d54fee75423af97194a5a9c04ff81b93b
blitzbutter/MyCode
/netCalc.py
1,718
4.25
4
### Jacob Bryant ### 12/8/2018 ### Program to calculate the network address # --- Takes a string to ask a user as input --- # def calc_bin(user_in): bin_f = "{0:08d}" # Pads binary numbers with 8 bytes # --- Formats the input IP address and converts it to binary --- # ip_in = input(user_in) ...
5885a848ed12b11b85465e2e63cae652fa547da2
DaHuO/Supergraph
/codes/CodeJamCrawler/16_0_1/ghonyme/1.txt
498
3.890625
4
#!/usr/bin/python import sys def isDigitInStr(digit,str): return digit in str def problem(number,res): for i in range(0,10): if str(i) not in res and isDigitInStr(str(i),number): res.append(str(i)) return res res = [] number = int(sys.argv[1]) number_tmp = number if number == 0: ...
23a8e224e3b450a5603812bd276aa5f0b2f5bcb8
DemetriosP/lp2-exercicios
/lista_1/exercicio_7.py
335
3.921875
4
distancia_quilometros = float(input("Informe a distancia percorrida pelo objeto em quilometro: ")) tempo_minutos = int(input("Informe o espaço em tempo em minutos: ")) velocidade_projetil = (distancia_quilometros * 100) / (tempo_minutos * 60) print(f"A velocidade do projetil é de {round(velocidade_projetil)} metros p...
9619eab19b6b41c8b723e79c4bc248c054e9714d
laffitto/test
/numpy_test.py
888
3.625
4
import numpy as np # # 可以自动判断数据类型 # arr1 = np.array([2,3,4]) # 定义一个数组 # print(arr1) # print(arr1.dtype) # # arr2 = np.array([1.2,2.3,3.4]) # print(arr2) # print(arr2.dtype) # # 实现列表的累加 # print(arr1+ arr2) # # print(arr2*10) # # 定义二维数组(矩阵) # data = [[1,2,3],[4,5,6]] # arr3 = np.array(data) # print(arr3) # print(arr3.dt...
016386f97f0cbf7ee1826415f878c47c439df51b
elfeasto/house-price-models
/ML_Models/Parametric models/Simple Linear/sqft_living_Linear.py
697
3.671875
4
""" Simple linear regession using one feature(sqft_living) """ import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression import tools from project_tools import * # load train data train_data, test_data = get_train_test_data() # pick feature features = ["...
79a807b684016008dc33ef4c0bbcfab9fefb1195
Christopher102/IntroToProgramming-Labs
/extracredit/question7.py
448
4.09375
4
# Calculates babysitter pay def main(): start = float(input("At what hour did you start? Input in HH:MM. " )) Starttime = input("What this AM or PM?") end = float(input("At what hour did you end? Input in HH:MM. ")) endtime = input("Was this AM or PM?") if Starttime.lower() == "am": print(...
c518381f8e76ea3c266c15edeba999182e1cbe8c
justinh5/CipherBox
/Crypt0/Caesar/CEnDecode.py
2,232
4.53125
5
def encode(plaintext, shift): """Encode plaintext Encode the message with a given shift key. Offset each character in the message by 'shift' number of letters in the alphabet """ ciphertext = "" # shift each character for x in plaintext: if 97 <= ord(x) <= 122: # if charact...
dedf161447234f2f5e6507ff0cf4dfd097d47852
penelopy/Hackbright_Classwork
/SkillsExercises/skills_wendy_version.py
2,678
3.984375
4
# Things you should be able to do. number_list = [-5, 6, 4, 8, 15, 16, 23, 42, 2, 7] word_list = [ "What", "about", "the", "Spam", "sausage", "spam", "spam", "bacon", "spam", "tomato", "and", "spam"] # Write a function that takes a list of numbers and returns a new list with only the odd numbers. def all_odd(number_l...
dee8e06ea937a6c4f83d42a98440535675743161
RandhirJunior/Python
/Oops/Static_Variables.py
3,424
4.375
4
# If the value not varied from object to object ,such types of variable we have to declare at class level and such type of variable is called static variable. # static variable:- For all objects a single copy maintained at class level. class Student: cname='IIT' def __init__(self,name,rollno): sel...
00fd23048aa3d9c7384099b1dbf6e2c28a66c6ac
Jenionthenet/Week-2
/Day-3/remove_duplicate.py
544
3.609375
4
with open("emails.txt") as file: emails = file.read() split_emails = emails.split(',') #print(split_emails) #emails_arr = split_emails dup_arr = [] unique_arr = [] for email in split_emails: if email not in unique_arr: unique_arr.append(email) if emai...
7289c9b37fa3cc91ba4e68f3ed45d1e765aa5df4
aditya-doshatti/Leetcode
/largest_time_for_given_digits_949.py
1,041
3.890625
4
''' 949. Largest Time for Given Digits Easy Given an array of 4 digits, return the largest 24 hour time that can be made. The smallest 24 hour time is 00:00, and the largest is 23:59. Starting from 00:00, a time is larger if more time has elapsed since midnight. Return the answer as a string of length 5. If no val...
758c89716ac881741456e162191363c8e742080f
b1ueskydragon/PythonGround
/leetcode/p0048/test_rotate.py
1,127
3.734375
4
import unittest from leetcode.p0048.solve01 import Solution as A class RotateTest(unittest.TestCase): def test_rotate_2x2(self): a = A() matrix = [ [1, 2], [4, 5] ] expected = [ [4, 1], [5, 2] ] a.rotate(matrix) # in...
5617bd4bcc3351ac9f7508e016c0152cf1b4b162
ymirthor/hr-forritun
/PC/midterm1.py
74
3.671875
4
n=int(input("Number of stars: ")) for i in range(1,n+1): print("*"*i)
68b0bac24e3007c876266e1df14c4d141d509618
TejaswitaW/DataScienceMachineLearningCourse
/12_day/factorial_number.py
310
4.0625
4
#facto_number = 1 def facto(number): if number == 1: return number else: return number*facto(number-1) # return facto_number number = int(input("Enter the number, to find factorial : ")) facto_number = facto(number) print("Factorial of number is : ", facto_number)
b9bd9fb1a2b056b07dd1b860212076783ad39ab7
Maheboopathy/FST-M1
/Python/Activities/activity4.py
1,339
4.15625
4
#Get the user names user1=input("What is Player1's name:") user2=input("What is Player2's name:") #looping endlessly while True: #Ask user's answers user1_answer = input(user1 +", do you want to choose rock, paper or scissors?").lower() user2_answer = input(user2 +", do you want to choose rock, paper or...
e29c2870e0313c7f02cf4e00f3425f233a77ac17
michalrom089/PythonCourse-ex
/04_exceptions/4_1_basics/00-basic.py
234
3.53125
4
def div(a, b): if b == 0: raise Exception('dividing by 0') return a/b if __name__ == '__main__': try: result = div(2, 0) except Exception as e: print(str(e)) print('End of thre program')
5168be409b78274bde4c321b644bbf7f615e1a43
ELOISESOULIER/acterrea
/descriptor_model.py
5,591
3.796875
4
""" Model to load the data, compute the Y variable to predict and the descriptors """ import numpy as np import pandas as pd import matplotlib.pyplot as plt def plot_two_scales_y(plot1, plot2, title='', x_label='', y_label1='', y_label2='', label1='', label2=''): """ Plot two curves with different Y-axis """ ...
556fe27d50b1c0b3104aff7e56982282fe2707c0
v2krishna/PythonRoutines
/06_ControlStatements/09_NestedForLoops.py
149
4.03125
4
""" Using the nested for loops """ for i in range(0,3): for j in range(0,4): print("i= ", i, "\t", "j = ", j) print("End of the program")
a6389f0dd28bd9991403a6662a7ce3cd99b2e2b0
pinky0916/python_Basics
/Handson_Exercise/f_Tuple_unpacking.py
544
4.15625
4
def emp_month(list1): max_hrs=0 min_hrs=0 for name,no_of_hours in list1: print(name,no_of_hours) if max_hrs<no_of_hours: max_hrs=no_of_hours emp_month=name else: min_hours=no_of_hours worst_emp=name return (emp_month,max_hrs,worst...
7a362edad6c89eca2840fba9910f600ec568e884
fatezy/Algorithm
/offer2/43LeftRotateString.py
677
4.09375
4
# 汇编语言中有一种移位指令叫做循环左移(ROL),现在有个简单的任务,就是用字符串 # 模拟这个指令的运算结果。对于一个给定的字符序列S,请你把其循环左移K位后的序列 # 输出。例如,字符序列S=”abcXYZdef”,要求输出循环左移3位后的结果 # ,即“XYZdefabc”。是不是很简单?OK,搞定它! class Solution: def LeftRotateString(self, s, n): if not s: return "" s = list(s) s[0:len(s)-n],s[len(s)-n:len(s)] = s[n:...
1acc058ac820f28cd05741abacda589acf4da145
Izardo/my-work
/Topic_6_functions/pop.py
153
3.921875
4
# This program creates a list and pops of the item at index 1 # Author: Isabella list = [1, 2, 3] a, b, c = list list.pop(1) print(list) print(a, b, c)
8ed2e63fc5698bd5d687bdc87531b9496a532ac7
dmcdekker/interview-and-coding-problems
/easy-python-problems/python_problems_3.py
5,879
4.3125
4
#reverse_digits #pair_product #slice_between_vowels #array_times_two (don't modify array) #array_times_twoo (modify array) #redact_five_letter_words #largest_pair #boolean_to_binary #third_largest #time_conversion ##################### Reverse Digits ################### ''' >>> reverse_digits(5) [5, 4, 3, 2, ...
3839258f6b3f3ba380106b166ba6fc430a6ded3c
MaxT2/EWPythonDevelopment
/PythonCodingClub/pygameGameWithEnemy.py
2,252
3.609375
4
# import pygame library so we can use it! import pygame # define player sprite class Enemy(pygame.sprite.Sprite): def __init__(self,screen_width,screen_height): pygame.sprite.Sprite.__init__(self) self.image = pygame.Surface((50, 50)) self.image.fill((0,255,0)) self.rect = self.i...
cfa9722112cf5be23f0c64ca3be69f2f495e8a4a
natalieparellano/dat-chapter-1
/labs/exercise_1/solution.py
210
4.0625
4
def divisible_by_33( numbers ): to_return = [] for num in numbers: if num % 33 == 0: to_return.append( num ) return to_return numbers = [ x for x in range( 1, 999) ] divisible_by_33( numbers )
106b30480a4d36a0f8beecd7dfe78834f591ddc6
molchiro/AtCoder
/random/ATC001B.py
659
3.671875
4
class union_find: def __init__(self, N): self.par = [i for i in range(N)] def root(self, i): if self.par[i] == i: return i else: # 経路圧縮 self.par[i] = self.root(self.par[i]) return self.par[i] def same(self, a, b): retu...
aa2403bea4086199b568c49d98bae41d9363f0c4
kanukolluGVT/CP-and-DSA
/selection_sort.py
406
4.0625
4
def find_smallest(arr): smallest=arr[0] smallest_idx=0 for i in range(1,len(arr)): if arr[i]<smallest: smallest=arr[i] smallest_idx=i return smallest_idx def selection_sort(arr): new_arr=[] for i in range(len(arr)): smallest=find_smallest(arr) new...
4ca752c4354477560fa66d7a42486e8f2ae9894b
AdrianoKim/ListaDeExerciciosPythonBrasilAdrianoKim
/PythonBrasil/1. Estrutura Sequencial/7. area do quadrado.py
316
4.09375
4
""" 7.Faça um Programa que calcule a área de um quadrado, em seguida mostre o dobro # desta área para o usuário. """ lado = float(input('Digite o tamanho do lado do quadrado: ')) # Obs.: Fórmula da área do quadrado = lado * lado print('O dobro da área deste quadrado é: ', format((lado * lado) * 2, 'n'))
e3e204509cd7641583cfc9d02634a1396d826a1e
donpaul999/UBB
/Year 1/Semester 1/python/Seminar/seminar_07_08/ui.py
2,891
4.125
4
''' Create an application for a car rental business using a console based user interface. The application must allow keeping records of the company’s list of clients, existing car pool and rental history. The application must allow its users to manage clients, cars and rentals in the following ways: * Clients - A...
5d6d3b599649c44a78d2598db3542accf92ce100
mfarukkoc/8-queen-problem
/hillclimb.py
5,686
4
4
# -*- coding: utf-8 -*- import random class Board: def __init__(self, n, board_map): for i, q in enumerate(board_map): if(q >= n): print('error: queen is out of boundry on column {}: (val:{})'.format(i,q)) board_map[i] = random.randrange(n) print('replaced randomly with {}'.format(b...
4edc6fa78b171007555266e932b53aad2cc30d52
mmanishh/codilitysolution
/stackqueue/paranteses.py
921
4.09375
4
def check_parentheses(a): inputs = a.split() print(inputs) stack = [] for i,input in enumerate(inputs): if input == '{' or input=='(' or input=='[': stack.append(input) print(i,stack) if input == '}' or input==')' or input==']': if len(stack) <=0: ...
4d9d13f611730f765601f4fc684337c3fd909f60
KermanJR/URI
/Uri1066.py
604
3.625
4
def main(): par = 0 imp = 0 posit = 0 neg = 0 Z = 0 while Z < 5: x = int(input()) if x % 2 == 0: par = par + 1 if x % 2 != 0: imp = imp + 1 Z = Z + 1 if x == 0: Z = Z + 1 if x > 0: posit = p...
77aa420758f3df45f589d4f052f92f04b5e380f7
LeeInHaeng/algorithm
/프로그래머스(Python3)/level1/두 정수 사이의 합.py
166
3.609375
4
def solution(a, b): sum=0 if b>a: for x in range(a,b+1): sum+=x else: for x in range(b,a+1): sum+=x return sum
dcdc74ab2be3afe4bc085d2855caf59b68cbf7c0
atsin6/Fibonacci_numbers
/Fibonacci-numbers.py
226
4.15625
4
#fibonacci Numbers : 0,1,1,2,3,5,8,13,21,34,55,........ x = 0 y = 1 a = int(input('Enter how many fibonacci numbers you want to be printed:',)) for i in range(a): print(x) print(y) x = x + y y = y + x
d7ddf1eb5af4e487709083065f81a0c8c8cfa62c
shichao-an/ctci
/chapter2/question2.2.py
952
4.03125
4
from __future__ import print_function from linked_list import create_list, restore_list def nth_to_last(head, k): """nth to last node (recursive) If k is greater than the length of the linked list, return head node """ if head is None or k == 0: return None elif nth_to_last(head.next, k - ...
e96be88c1043d9219b520298322566099a59e9c7
pmarcol/Python-excercises
/Python - General/List/31-40/excercise36.py
318
3.640625
4
""" Write a Python program to get variable unique identification number or string. """ """ SOLUTION: """ myVars = [True, 100, 3.14, 'test'] testVar1 = 'test' testVar2 = 'test' print(format(id(myVars), 'x')) print(format(id(testVar1), 'x')) print(format(id(testVar2), 'x')) # the last two ones will have the same ids
a3e678d9ab83d20ec6502b19f781b60805006b0e
sherifkandeel/hackerrank
/Algorithms/Strings/easy/Funny_String.py
428
3.671875
4
import math def is_funny(s, r): for i in range(1,len(s)): s_diff = math.fabs(ord(s[i]) - ord(s[i-1])) r_diff = math.fabs(ord(r[i]) - ord(r[i-1])) if s_diff != r_diff: return False return True cases = int(raw_input()) for c in range (0, cases): s = raw_input() r = s...
40ae43f47dc4bf0aacba285271bca05b7bee1353
nickfang/classes
/projectEuler/webScraping/problemTemplates/383.py
424
3.5625
4
# Divisibility comparison between factorials # # #Let f5(n) be the largest integer x for which 5x divides n. #For example, f5(625000) = 7. # # #Let T5(n) be the number of integers i which satisfy f5((2·i-1)!) &lt; 2·f5(i!) and 1 ≤ i ≤ n. #It can be verified that T5(103) = 68 and T5(109) = 2408210. # # #Find T5(10^18)....
28873ab23768ff48c7831c51f330e615f97d0565
montaro/CtCI-6th-Edition-Python
/chapter1/1.2-check_permutation.py
1,303
3.78125
4
import unittest from collections import Counter def check_permutation(word1, word2): if len(word1) != len(word2): return False word1 = sorted(word1) word2 = sorted(word2) if word1 == word2: return True else: return False def check_permutation_2(word1, word2): if len...
fd8762faea1d66a13ed24b6b3696c6873c4154e0
alcoccoque/Homeworks
/hw3/ylwrbxsn-python_online_task_3_exercise_3/task_3_ex_3.py
1,746
4.46875
4
""" Write a Python-script that: 1. Searches for files by a given pattern (pattern can include: *, ?) 2. Displays the search result 3. Gets access rights for each file that is found and displays the result The script should have 2 obligatory functions: - finder - a generator function searches for files by a give...
6f83b0f126ae0ecc4fd331c40d24c92ec96ddf94
saidatta/Project-euler
/lib/Problems_1_100/Euler041.py
265
3.5
4
import prime from itertools import permutations # Pan-digital primes are 4 or 7 digits. Others divisible by 3 for perm in permutations(range(7, 0, -1)): num = 0 for n in perm: num = num * 10 + n if prime.is_prime(num): print(num) break
79ef1ff3ba38596b2dd1ee8c8a1e2aae5532f740
MazanYan/pHash-image-recognition
/raw_algorithms_python/HashAlgorithms.py
4,577
3.6875
4
from functools import reduce from PIL import Image import numpy as np # Class to get images from some folder and hash them with simple pHash algorithm class HashBuilder: def __init__(self, path): self.images_path = path """ Compresses image object into 8x8 square array to be used in saving as a ...
625d6d7af86693494b3afea155ae3308557ca12e
clamli/ml_algorithms
/knn_kdtree/myutil.py
562
3.59375
4
import numpy as np def get_median(data): """input: list : one-dimension feature output: int/float : middle value --------- """ data.sort() half = len(data) // 2 return data[half] def eucli_distance(point_1, point_2): """input: list : point_1, point_2 output: ...
5919a6170b192cd9f4eb0d2aff467855c82ecab3
AndreiZavo/Graph-Algorithms
/Lab_1/main.py
2,297
4.03125
4
import random from repo import GraphFile, Graph from service import GraphService from ui import UI ''' This function creates a random graph which will be stored in a file. It uses two inputs from the user, a number of vertices and a number of edges ''' def create_random_graph(): number_of_vertices = int(...
fb40cfb7161067d0a5200fcb88117e6c010bb6f8
gandastik/365Challenge
/365Challenge/sortArrayByParityII.py
661
4.09375
4
#60. Mar 1, 2021 - Given an array of integers nums, half of the integers in nums are odd, and the other half are even. # Sort the array so that whenever nums[i] is odd, i is odd, and whenever nums[i] is even, i is even. # Return any answer array that satisfies this condition. def sortArrayByParityII(nums: List[int]) -...
8dd2ce714e3e02a71db859de475023f399670fa2
BScheihing/03Tarea
/P2.py
1,494
3.90625
4
''' Este script resuelve el sistema de Lorenz usando el integrador dopri5 de la libreria scipy.integrate. Los parametros asociados al sistema de Lorenz estan fijos en la implementacion, para obtener la solucion conocida como el Atractor de Lorenz. La funcion f define el sistema con los parametros ya fijados. Luego el ...
1b16499d81c7e42482b47ee5735680a6559b0efc
PaweenJabberry/Practice
/Python/LongestWord.py
886
4.375
4
# Longest Word # # Have the function LongestWord(sen) take the sen parameter being passed # and return the largest word in the string. If there are two or more words that # are the same length, return the first word from the string with that length. # Ignore punctuation and assume sen will not be empty. # # Examples ...
05bfcb97a9dabab31be6cf195e50a16df9a2abb8
jkjit/pyLearning
/com/jkpy/dictionary/dictionary_Sample.py
1,182
4.15625
4
# my_dict = dict({1:'apple', 2:'ball'}) # print(my_dict) # print(type(my_dict)) # # my_dict1 = dict([(1,'apple'), (2,'ball')]) # print(my_dict1) # print(type(my_dict1)) my_dict = {'name': 'jack', 'age': 20} print(my_dict) print(my_dict['name']) print(my_dict.get('name')) print(my_dict.get('age')) squares = {1:1, 2:...
e3366659693861186f18404c47a1a59e1d04d74e
qsyPython/Python_play_now
/wangfuhao/04-share/01-GUI.py
8,390
4.0625
4
print('------------------label-button-----------------') import tkinter as tk # # window = tk.Tk() # window.title('my window') # window.geometry("200x100") # # var = tk.StringVar() # # l = tk.Label(window,textvariable=var,bg='green',font=('Arial',12),width=15,height=2) # l.pack() # # l.place #自己指定位置 # # on_hit = False...
a1cde60ed5ac3b8093d684070e0165b9fb28ac15
RobbertSinclair/Chess
/main.py
9,019
3.5625
4
import pygame import time from piece import * pygame.init() #create the window screen = pygame.display.set_mode((800,800)) #Set up colours WHITE = (255, 255, 255) BLACK = (40,40,40) GREEN = (0,128,0) ORANGE = (255, 69, 0) board = [[0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0...
5838e3917920808c9790cc93a1cb94abafb27e3b
ksomemo/Competitive-programming
/yukicoder/problems/level3.0/0572/0572.py
375
3.546875
4
def main(): n = int(input()) m = int(input()) def argmax(xs): return sorted(enumerate(xs), key=lambda x: x[1])[-1] code = [ list(map(int, input().split())) for _ in range(m) ] from pprint import pprint pprint(code) for c in code: p...
34910c05c75b315bc803ba219586d60b8ab0f4b0
vabbybansal/Java
/Others/codes/DFS_state_locally_trav 695. Max Area of Island.py
2,693
3.78125
4
# Learning # 1) Baking it further - varible sum in recursion function passed over locally, no global class variable used # 2) used constant space by changing the input - marking visited node as -1 # Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionall...
4a9d536187abe7763af32704ef898eac453fb8fe
KushalkumarUmesh/Internal-Initiative
/GoalSheet/empDash_Goalsheet_OnlineExam/realapp/shared/readconfig/appconfig.py
1,258
3.53125
4
import openpyxl class AppConfig(object) : def __init__(self, configInfile) : self.configInfile = configInfile self.attribute = {} # Dict of Attributes self.readConfigFile() #Reading the file, and save keyValue pairs, convert everything into String def readConfigFile(self)...
2f6b1f2e00b169f38bdfff98008525405b3856e5
ayumitanaka13/python-basic
/basic/base14.py
603
3.796875
4
# セットの関数 s = {'a', 'b', 'c', 'd'} t = {'c', 'd', 'e', 'f'} u = s | t # 和集合 u = s.union(t) # 和集合 print(u) u = s & t # 積集合 u = s.intersection(t) print(u) u = s - t # 差集合 u = s.difference(t) print(u) u = s ^ t u = s.symmetric_difference(t) print(u) s |= t # => s = s | t => sがsとtの和集合=>sにtの要素が...
b08287d65dddc19f8087fc1c88a7df9155c55060
azhu51/leetcode-practice
/contest/easy_5396.py
468
3.65625
4
# https://leetcode-cn.com/contest/biweekly-contest-26/problems/consecutive-characters/ class Solution: def maxPower(self, s: str) -> int: prev = "" max = -1 res = 0 for word in s: if word != prev: res = 1 if res >= max: max = res if word == prev: res ...
3ceed8b359fe0b704bed8029f9493d41eac70be6
DynamiteJohnny/final_project_methods
/proyecto.py
3,059
3.78125
4
import ciw import math print("\nMétodos Cuantitativos y simulación\nAlumnos:\n\tShara Teresa González Mena\n\tEsteban Quintana Cueto\n\tJuan Luis Suarez Ruiz\n") print("\n Proyecto final: Simulación de un sistema de colas\n") l = float(input("\n Introduce el valor de lambda: ")) miu = float(input("\n Introduce el va...
90bb31c28ba80ddc6c6081f383682b969eccb176
iamtu/leetcode
/graph/dfs.py
819
3.8125
4
from __future__ import print_function graph = { 'A' : ['B','C'], 'B' : ['D', 'E'], 'C' : ['F'], 'D' : [], 'E' : ['F'], 'F' : [] } visited = set() # Set to keep track of visited nodes. def dfs_recursive(visited, graph, node): if node not in visited: print (node, end= ' ') v...
5347a67c5f048e17c39753684dba43dc18a492ba
V-Plum/ITEA
/homework_9/pw_manager_json.py
12,420
3.65625
4
""" This program requires Tkinter and PySimpleGUI to run, because of used GUI To install Tkinter use your terminal and enter: $ sudo apt-get install python3-tk To install PySimpleGUI use your terminal and enter: $ pip install PySimpleGUI """ import string import PySimpleGUI as sg import secrets import json ukr = "а...
97343ea451d8731fe499a844b405e90d46b99238
novigit/learn_ete3
/06_check_monophyly.py
3,034
3.671875
4
#!/usr/bin/env python from ete3 import Tree t = Tree("((((((a, e), i), o),h), u), ((f, g), j));") print(t) # /-a # /-| # /-| \-e # | | # /-| \-i # | | # /-| \-o # | | # /-| \-h # | | # | \-u # --| # | /-f #...