blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
6c31abcce8c523fd07f4b1fb7e6be1a395b6f72c
bradysalz/Laverna-Viewer
/parser/notebooktree.py
3,852
3.5
4
from parser.notebook import Notebook class NotebookTree(): """A NotebookTree represents our Laverna notebook structure. Each node in tree is a Notebook. We initialize it as a strucutre containing a root node with a blank Notebook and a no parentId.""" def __init__(self, notebook_list=None): s...
9c935745876373f99296f9b703b2691c2bda5d8c
penguinsss/Project
/面向对象/面向对象基本语法.py
3,473
4.21875
4
class Fruits: # 类名大驼峰 def __init__(self, color, name): # 使用场景:初始化 self.color = color self.name = name def zd(self): # self对应的实参是 调用该方法的对象(由解释器自动设置); 使用场景:想在方法中使用对象自己的属性 print('我长大啦') print("我是:%s" % self.name) def __str__(self): return '颜色:%s,名字:%s' % (self.col...
0f970945158abfa4462cef8a21ff8ad80fbb30b4
bwotten/starsandswag
/db2.py
934
3.515625
4
#Simple script to get the idea for connecting to the db import psycopg2 import getpass # Run this command to start ssh tunneling # ssh -L 63333:localhost:5432 zpfallon@db.cs.wm.edu password = getpass.getpass('Password: ') params = { 'database': 'group3_stars', 'user': 'zpfallon', 'password': password, 'host...
16be585bcd3d0499413a5ab8007448486376a270
samadhan563/Python-Programs
/Logical Program/CheckInputTypes.py
458
4.28125
4
# Program for ASCII Value pattern ''' Author : Samadhan Gaikwad. Software Developer Location: Pune. ''' char=(input("Enter char : charactor")) # char2=(input("Enter char1 : ")) if char>='A' and char <='Z': print(char, "is a upper case charactor.") elif char>='a' and char <='z': print(char, "is a lo...
1118c7cd44d7d9e6314479424f6ddce5b84f7814
yugant6/100-days-of-code
/day-12/strings.py
356
3.9375
4
a = "Hello, World!" print(a[0]) print(a[1]) print(a[2:5]) # from second character to 4th character b = " Hello, World! " print(b.strip()) print(len(a)) print(len(b)) print(a.lower()) print(a.upper()) print(a.replace("H", "J")) print(a.split(",")) print("Enter your name:") x = input() print("Hello, " + x) y = i...
81cb52843367b21e7c713f5e6d5bbc71217cdaa9
danoliveiradev/PythonExercicios
/ex039.py
570
3.703125
4
from datetime import date anoNasc = int(input('Digite seu ano de nascimento com 4 digitos: ')) idade = date.today().year - anoNasc if idade < 18: print('\033[32mVocê não completou 18 anos! Vai poder se alistar daqui a {} anos.'.format(18 - idade)) elif idade == 18: print('\033[33mVocê completou 18 anos! Procure...
31cc5a2e481301104bbde979f720284b5b625440
juanarmond/HackerRankCode
/Count Triplets.py
2,331
3.9375
4
# You are given an array and you need to find number of tripets of indices such that the elements at those indices are in geometric progression for a given common ratio and . # For example, . If , we have and at indices and . # Function Description # Complete the countTriplets function in the editor below. It s...
d465964ca43fbfe940ccce4fe5807167fd9e7aa6
yunaranyancat/personal_projects
/project_7/caesarCipher.py
2,385
4.21875
4
import argparse def caesar_cipher(filename_to_read,filename_to_append,mode): with open(filename_to_read, "r+") as thefile: lines = thefile.readlines() if (mode=="encrypt"): with open(filename_to_append, 'w+') as theEncryptedFile: for each_line in lines: ...
93ad9c33f5797f7c585ed94ba199ac13c9198216
Jean-Bi/100DaysOfCodePython
/Day 13/day-13-3-exercise/main.py
578
4.4375
4
for number in range(1, 101): #if number % 3 == 0 or number % 5 == 0: -> "FizzBuzz" has to be displayed when both the conditions are true, not only one of them if number % 3 == 0 and number % 5 == 0: print("FizzBuzz") #if number % 3 == 0: -> elif has to be used as only one condition should be fulfilled at max ...
9b8b117f3a8fd5ccc76ff499dbf7af9f082a93d7
smiroshnikov/telegramBotforMiningControl
/linxacad/basics/bmi.py
1,481
4.25
4
#!bin/python def validate_input(input): for e in input: if not e.isdigit(): print("only digit input allowed :") return False else: return True def get_user_data(): height = input("Whats your height :? (inches or meters) ") while not validate_input(heig...
b51be2cfcae5c1fd31e2e2cd945b119ab87b4e4a
Rup-Royofficial/Codeforces_solutions
/codeforces_AIsitrated_contest.py
100
4.125
4
for i in range(3): n = str(input()) if n=="Is it rated?": print("NO")
4ab7b5da9ffc099c7b89a4eabe7fb112d066af68
astrid23/cmp2035-homework
/04/pythonworkshop.py
658
3.765625
4
A = 100 B = 300 C = STRING print type class (object): """docstring for """ def __init__(self, arg): super(, self).__init__() self.arg = arg print C + "" print str(A) # data structures # list listofwww = [" different type of variables"] print listofwww[1] print listofwww [0:2] print len(listofwww) for album in lis...
4fd18ba2ade552e1a5708d36e582248280969270
sid-verma/Coding-Interview-Questions
/DP-Recursion-Bktracking/ClimbStairs.py
629
4
4
# You are climbing a stair case. It takes n steps to reach to the top. # Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? # Note: Given n will be a positive integer. # Key step: Write out the patterns for n = 1,2,3... and you will see it is a Fibonacci Series. # Thus you...
311bb4f3e2f7a7f488b46df96df158f22e914131
alissabaigent/Election-Analysis-Alissa-Baigent
/Python_practice.py
1,960
4.28125
4
counties = ["Arapahoe", "Denver", "Jefferson"] if counties[1] == 'Denver': print(counties[1]) if counties[2] != 'Jefferson': print(counties[2]) if "El Paso" in counties: print("El Paso is in the list of counties") else: print( "El Paso is not in the list of counties") if "Arapahoe" or "El Paso" in cou...
85b781baf80568e981973ca5cd7902c82ba092bb
lucasdmazon/CursoVideo_Python
/pacote-download/Exercicios/Desafio02.py
698
3.78125
4
var = input("{}Digite algo: {}".format('\033[1;31m', '\033[m')) print('{}O tipo primitivo desse valor é: {}'.format('\033[1;35m', type(var))) print('Somente Espaços: {}'.format(var.isspace())) print('Numerico: {}'.format(var.isnumeric())) print('Alfabetico: {}'.format(var.isalpha())) print('Alfanumerico: {}'.format(var...
e3c486c81f16a40e954ad036aaf4ccab6ba720f6
seweissman/advent_of_code_2020
/day21/day21.py
5,656
3.578125
4
""" You reach the train's last stop and the closest you can get to your vacation island without getting wet. There aren't even any boats here, but nothing can stop you now: you build a raft. You just need a few days' worth of food for your journey. You don't speak the local language, so you can't read any ingredients ...
89adf53e265f6d0e5804ee013ec38dee60628ca0
PdxCodeGuild/class_redmage
/code/cory/Python/lab20_credit_card_validation/credit_card_validation.py
1,033
3.984375
4
# Setup main function def credit_checker(card_number): card_list = list(card_number) # convert string to list of ints last_digit = card_list.pop(-1) # slice off and save digit card_list.reverse() # reverse card list for i in range(len(card_list)): card_list[i] = int(card_list[i])...
7630757e5125133c66aac47d0ec50741cc243670
gschen/sctu-ds-2020
/1906101105-石涛/day0225/test03/02.py
416
3.828125
4
# coding=utf-8 # if嵌套 num=int(input('请输入一个数字:')) if num % 2==0: if num % 3==0: print('这个数字既能被2整除,也可以被3整除') else: print('这个数字能被2整除,但不能被3整除') else: if num % 3==0: print('这个数字能被3整除,不能被2整除') else: print('这个数字既不能被2整除,也不能被3整除')
1a8ef6f571133782744603b9925cf810d775d811
dcryptOG/pytutorial
/2/2.py
5,840
4.40625
4
# 2. Using the Python Interpreter # 2.1. Invoking the Interpreter # The Python interpreter is usually installed as /usr/local/bin/python3.7 on those machines where it is available; putting /usr/local/bin in your Unix shell’s search path makes it possible to start it by typing the command: # python3.7 # to the shell....
8119dfc230ff8cdb1751ebb6f77af30adcc076a4
invalidsyntax1/randomize_mafia_telegram
/randomize.py
1,054
3.609375
4
#распределение на 2 команды from random import randint def sort_for_two_commands(players: list) -> list: first_len_players_command = len(players) / 2 first_command = [] while len(players) != first_len_players_command: index_random_player = randint(0, len(players)-1) random_player = player...
dea602c5ef90516037808f65421b2a39712a81c3
AdamZhouSE/pythonHomework
/Code/CodeRecords/2482/60769/262153.py
731
3.5
4
num = int(input()) for j in range(num): dividend = list(input()) divisor = int(input()) last = 0 res = "" for i in dividend: temp = last * 10 + int(i) res += str(temp // divisor) last = temp % divisor # 处理整数部分结束 if last == 0: print(eval(res)) continue ...
7d11d86bfbdf0210ed19ce8f844dfd653e816795
MCVitzz/AED
/Fraction.py
1,977
3.640625
4
import math class Fraction: def __init__(self, num, den): if not (type(num) is int and type(den) is int): raise ValueError() gcd = math.gcd(num, den) self.den = int(den // gcd) self.num = int(num // gcd) def getNum(self): return self.num def getDen...
a6d386eee5ce79fe241d04aa40321fc84b534abf
Abhishek-IOT/Data_Structures
/DATA_STRUCTURES/DSA Questions/Searching and sorting/Pairdiff.py
845
4.0625
4
""" Find Pair Given Difference Easy Accuracy: 47.62% Submissions: 16791 Points: 2 Given an unsorted array Arr[] and a number N. You need to write a program to find if there exists a pair of elements in the array whose difference is N. Logic=Have two counter and check that the difference is equal or not ,if not th...
2477ba014fadb55d1f1a5651c8d62098dccddd08
Vasilic-Maxim/LeetCode-Problems
/problems/409. Longest Palindrome/1 - Counter.py
414
3.5625
4
from collections import Counter class Solution: """ Time: O(n) Space: O(1) because there would be 52 or less keys (lower and upper case chars of English alphabet) """ def longestPalindrome(self, string: str) -> int: div, mod = 0, 0 for count in Counter(string).values(): ...
725c7b6124151f82b5cc3d02033be1d36c7372f1
withoutwaxaryan/programming-basics
/Python/inheritance.py
664
4.0625
4
# University has some stuff which can be used by both Teachers and Student. THerefore we can use inheritance to reuse code class University: def __init__(self, fname, lname): self.fname = fname self.lname = lname def fullname(self): print(self.fname + ' ' + self.lname) class Student(...
9ea3aa699485622c17b8f54c882f3dfddbd895b7
luizffdemoraes/Python_1Semestre
/AC/Área de um hexágono regular.py
909
4.34375
4
""" Escreva um programa em Python3 que peça o valor do lado de um hexágono regular, calcule e imprima sua área e seu perímetro. Sabemos que um hexágono regular é o polígono de 6 lados iguais e com todos os ângulos internos iguais entre si. Sabemos ainda que um hexágono regular de lado L é formado por 6 triângulo...
009356adfad3179a5ef369df70ec6a284e6faeaa
wallge/interviewTestProblems
/python/fibonacci.py
6,672
4.4375
4
# -*- coding: utf-8 -*- """ Created on Sun Nov 1 11:59:44 2015 @author: Geoffrey Wall usage: python fibonacci.py -n <number of fibonacci numbers to generate> usage: python fibonacci.py -t <number of fibonacci numbers to generate and test against reference implementation> """ #!/usr/bin/python import sys...
151c2ac39fa9ce8778a277bec391984c24d063f6
Poluru-Venkata-Koushik/SIMPLE_PROJECTS
/temp.py
1,839
3.59375
4
from tkinter import messagebox import xlrd import random import tkinter as tk from PyDictionary import PyDictionary loc = (r"C:\Users\Hp\Downloads\allword.xls") #change this as per requirement dict = PyDictionary() wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) sheet.cell_value(0, 0) def create_w...
fedf8995642dc771864e444787e82bd9376784cf
Omkar02/FAANG
/UnboundedKnapsack.py
1,936
3.84375
4
import __main__ as main from Helper.TimerLogger import CodeTimeLogging fileName = main.__file__ fileName = fileName.split('\\')[-1] CodeTimeLogging(Flag='F', filename=fileName, Tag='Dynamic-Programing', Difficult='Hard') '''Given a knapsack weight W and a set of n items with certain value vali and weight wti, we need...
5c1623a75da7d69c1966ca3a2675895627a25600
ChuixinZeng/PythonStudyCode
/PythonCode-OldBoy/Day1/随堂练习/5_Interaction.py
1,751
4.28125
4
# -*- coding:utf-8 -*- # Author:Chuixin Zeng # raw_input 2.x input 3.x #input 2.x 里输出的结果必须是定义好的变量,不建议用,很多余的语法,忘记他,不要用它 #要求格式化输出为下面的格式 name = input("name:") age = int(input("age:")) #强制数据类型转换,默认age是string,这里强制转换成int #打印当前数据类型 print(type(age),type(str(age))) #把int再转换成string job = input("job:") salary = input("salary:...
5fd5f9bc78d9eb8848f5925603b497a6b561a5f6
byj9511/Hello-world
/判断列表数字累加和.py
268
3.671875
4
def sum2(list1): number = len(list1) list2 = [list1[i] for i in range(number)if type(list1[i])== float or type(list1[i])== int] #列表中的数为小数或者整数式,进行累加 return sum(list2) a = [1, 2, 3, 4, 2.41, "a", "b"] print(sum2(a))
7d3c2541393ef9f935939989a4ee61f532535592
abdullahmehboob20s/Python-learning
/chapter-11-inheritance/5-super.py
1,087
3.90625
4
import os os.system("cls") # multiLevel-inheritance # Parent class Person: country = "Pakistan" city = "Karachi" gender = "male" def __init__(self): print("Intializing Person...\n") def takeBreath(self): print("I am breathing...") # Child class Employee(Person): company =...
7e34de6796d430af09f0c47c7be281b8a3878f53
lavanya-shirur/Computer-Vision
/KMeans.py
4,252
4.21875
4
class KmeansSegmentation: def segmentation_grey(self, image, k = 2): """Performs segmentation of an grey level input image using KMeans algorithm, using the intensity of the pixels as features takes as input: image: a grey scale image return an segemented image -------------...
052e3ed9101f06e9525c169502ee963485674e98
PullBack993/Python-Fundamentals
/07. Dictionaries - Exercise/08. Company Users.py
597
3.734375
4
command = input() company_users = {} while not command == 'End': company, id = command.split(" -> ") if company not in company_users: company_users[company] = [id] else: if id in company_users: command = input() company_users[company].append(id) command = input() s...
0b34a7942bc398a6c45228f3c7116ecfcce8ce4d
jorien-witjas/python-labs
/python_fundamentals-master/03_more_datatypes/2_lists/03_08_reorder.py
914
3.84375
4
''' Read in 10 numbers from the user. Place all 10 numbers into an list in the order they were received. Print out the second number received, followed by the 4th, then the 6th, then the 8th, then the 10th. Then print out the 9th, 7th, 5th, 3rd, and 1st. Example input: 1,2,3,4,5,6,7,8,9,10 Example output: 2,4,6,8,10,...
a79bf9fb6882143be4de92fdeb703746134788cd
yaHaart/hometasks
/Module15/03_cells/main.py
387
3.578125
4
cell_list = [3, 0, 6, 2, 12, 3, 2, 6, 9, 7, 6, 55, 14, 16, 1] bad_cells = [] print('Кол-во клеток: ', len(cell_list)) for i in range(len(cell_list)): print(f'Эффективность {i + 1} клетки: {cell_list[i]}') if i > cell_list[i]: bad_cells.append(cell_list[i]) print('Неподходящие значения: ', bad_cells) # ...
8926f73f9d11355c06f028b6f276d2bd0ff958bf
Draeriel/Advent-of-Code
/Day2/Part Two.py
886
3.625
4
from itertools import permutations def preparador(casostest, lista): fichero = open(casostest, 'r') fila = [] for linea in fichero: numeros = [] for j in linea: try: j = int(j) numeros.append(str(j)) except ValueError: if not j.isdigit(): numeros = "".join(numeros) fila.append(numero...
274ca9658832c197a8f91fccd7b659490f314f97
thai321/data-structures-alogrithms
/Stacks Queues and Deques/queue.py
353
3.84375
4
class Queue(object): def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def enqueue(self, item): self.items.insert(0,item) def dequeue(self): return self.items.pop() def size(self): return len(self.items) q = Queue() q.isEmpty()# True q.enqueue(1) q.enque...
79d19230275c01c26ba96f99263b3558973102d0
andrewonyango/bioinformatics
/1-finding-hidden-messages-in-dna/week1/reverse_complement.py
317
4.3125
4
def reverse_complement(string): """ returns the reverse complement of a dna string string: the original dna string """ dna_dict = {"A": "T", "G": "C", "T": "A", "C": "G"} complement = [] for char in string: complement.append(dna_dict[char]) return "".join(complement[::-1])
8639c01c07a320a2e76d08b2d7e6d2c879a3bb15
Dragonway/LeetCode
/py/remove_linked_list_elements.py
762
4.09375
4
# Remove all elements from a linked list of integers that have value val. # # Example: # # Input: 1->2->6->3->4->5->6, val = 6 # Output: 1->2->3->4->5 from typing import Optional from py.collections.list import ListNode class Solution: def remove_elements(self, head: Optional[ListNode], val: int) -> Optional[L...
5e383a596f1bf14f671a77e0756b259b1efc200f
gaurav-dalvi/codeninja
/python-junk/balance_array.py
683
3.734375
4
def merge(intervals): intervals = sorted(intervals, key = lambda x: x[0]) print intervals stack = [] stack.append(intervals[0]) for item in xrange(1, len(intervals)): stack_elem = stack.pop() if stack_elem[1] >= intervals[item][0]: low = min(stack_elem[0], intervals[...
dfbe6bf9e06278aa4ea0cad505443058ba7a55b9
fengbaoheng/leetcode
/python/876.middle-of-the-linked-list.py
913
3.71875
4
# # @lc app=leetcode.cn id=876 lang=python3 # # [876] 链表的中间结点 # class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: # 快慢指针 def middleNode(self, head: ListNode) -> ListNode: try: if head is None: return None ...
3f8f5527a36b2c9fac380b594ff9a8aee804afc6
ghoshorn/leetcode
/leet01_2.py
1,349
3.6875
4
# encoding: utf8 ''' Two Sum Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and ...
30e04f6509927677aabd850a3164cdca1ba3f808
rroberts1990/Exercism
/python/pangram/pangram.py
212
3.734375
4
import string def is_pangram(sentence): alphabet = set(string.ascii_lowercase) letter_list = set([char.lower() for char in sentence if char.lower() in alphabet]) return len(letter_list) == len(alphabet)
f59cb5ab086ff40ce4002f9da69efff2589b3b0b
SupakornNetsuwan/Prepro64
/test131.py
435
3.734375
4
"""Func""" def func(): """#2""" numbers = list(map(float, input().split(" "))) lookfor = float(input()) findnum = [i for i, x in enumerate(numbers) if x == lookfor] if findnum: print("Index: %d" %findnum[-1]) else: findnum2 = [abs(lookfor - i) for i in numbers] print("In...
61957581321a62fca45c2d3ea6ca8fc1d1942863
JulianoA28/TrabalhoPratico_TeoricaDaComputacao
/Máquina de Turing/maquina.py
4,333
3.921875
4
''' TRABALHO PRATICO GCC108 - Teoria da Computacao Nome: Juliano Expedito de Andrade Godinho Turma: 14A Matricula: 201811302 ''' # Funcao para checar se a fita esta correta! def checarFita(fita, alfabeto): for f in fita: # Se nao pertencer ao alfabeto, retorna Fa...
71553365dd09d1202bd814a49fe1fdc14b8a547a
zickalate/CP3-Phatcha-Kambor
/assignments/Lecture50_Phatcha_K.py
230
3.84375
4
def plusNumber(x,y): print(x+y) def minusNumber(x,y): print(x-y) def multiplyNumber(x,y): print(x*y) def divideNumber(x,y): print(x/y) plusNumber(20,10) minusNumber(20,10) multiplyNumber(20,10) divideNumber(20,10)
94e6c62de029b35883066ead225c7aed8ff658d7
Darrian5120/CIS2348
/HW2/woodard_6_17.py
403
3.671875
4
#Darrian Woodard #1593984 word = input() password = '' for i in range(0, len(word)): if word[i] == 'i': password += '!' elif word[i] == 'a': password += '@' elif word[i] == 'm': password += 'M' elif word[i] == 'B': password += '8' elif word[i] == 'o': passwo...
417d251240aaf565c206b7c366a6952dd4c1f5fc
bernardombraga/Solucoes-exercicios-cursos-gratuitos
/Curso-em-video-Python3-mundo1/ex025.py
147
3.59375
4
lido = str(input('Qual é seu nome completo? ')) nome = lido.strip().lower() silva = 'silva' in nome print('Seu nome tem Silva? {}'.format(silva))
250944e7eacbfc433ca960298509c4d791c763f7
danielrazavi/Garner-Assessment
/shipment_stats.py
8,369
3.5
4
""" Created on Tue Feb 19 17:16:19 2019 .Done @author: Dan """ import sys import re import datetime as dt from dateutil import tz # Check to see if ther right amount of parameters are given. if len(sys.argv)!=2: print("Need to give the right number of parameters (one).\nFor example:\n\t python shipment_stats.py ...
11f44f9c0f466a8343463fac09d2e24c96f911f4
rnaster/python-study
/order.py
2,265
3.8125
4
""" first-class function design pattern practice """ from collections import namedtuple Customer = namedtuple('Customer', 'name fidelity') promos = [] def promotion(promo_func): promos.append(promo_func) return promo_func @promotion def fidelity_promo(order): """ apply discount 5% of total price to...
6dc79dd6ca1390e37938db236fded066e6ec8f4f
bespontoff/checkio
/solutions/Storage/braille_translator.py
4,097
3.984375
4
#!/home/bespontoff/PycharmProjects/checkio/venv/bin/checkio --domain=py run braille-translator # Brailleis a tactile writing system used by the blind and the visually impaired. It is traditionally written with embossed paper. Braille characters are small rectangular blocks, called cells, which contain tiny palpa...
795afad9a9710cd6cb2d9ccd7aa013a1d9c260ae
safwanc/python-sandbox
/recursion/fibonacci.py
155
3.9375
4
def fibonacci_recursive(n): if n in [0, 1]: return 1 return fibonacci_recursive(n - 1) + fibonacci_recursive(n - 2) print(fibonacci_recursive(10))
d89be24a6349cce2dbd0470f61b86907a2860285
danui/project-euler
/solutions/python/problem-7.py
890
4.09375
4
""" By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10001st prime number? """ # This uses a growable sieve def kth_prime(k): P = [2] # list of primes A = [1, 1, 1] # seen. x = 3 ...
f6f7c32b7b803142a3d4a0b8e3f962e06f2bde77
phuycke/Project-Euler
/Code/problem_40.py
1,543
4.15625
4
#!/usr/bin/env python3 # Problem setting """ An irrational decimal fraction is created by concatenating the positive integers: 0.123456789101112131415161718192021... It can be seen that the 12th digit of the fractional part is 1. If dn represents the nth digit of the fractional part, find the value of the following...
ed3935c3f18bc462e58a1b84c771c0d12ea99f95
hackingmaterials/duramat_dashboard
/degradation/degradation_functions.py
4,775
3.515625
4
""" These are 'toy' smoothing/degradation functions. These will eventually be replaced by those in existing analytics software (RdTools) or refactored to be more robust/easier to read. """ import pandas as pd import numpy as np from sklearn import linear_model import statsmodels.api as sm def trendline(df, column=...
9f80119bfcdf9fa7321c2fcd814e34858c22f4be
Aakancha/Python-Workshop
/Jan19/Assignment/Dictionary/Q12.py
548
4.21875
4
dict1 = { 'mother': 53, 'father': 62, 'sister': 35, 'brother': 26, 'me': 20, 'uncle': 43 } ''' maxval = max(dict1.keys(), key=lambda x: dict1[x]) minval = min(dict1.keys(), key=lambda x: dict1[x]) print(f"Minimum value: {dict1[minval]}") print(f"Maximum value: {dict1[maxval]}") ''' minval = list...
ef2093898cab746a11d3372d7cffe00f143b295d
SThomas1234/EscapeTheGhost
/ghost.py
16,280
4.0625
4
import sys, random def check_options(options, inp): # This function checks to see if the user's input can be found in the list of potential options per situation # The list of options is represented by the options variable found before each while True loop. # If the input is found in the list, the f...
468c432e5d49a90c7aed95ef4e721dbd5ab5ca62
walkerone/pythonalex
/day1113/login_homework.py
1,515
3.953125
4
# -*- coding:utf-8 -*- """ while 循环最多输入三次账号名称和密码, 先判断输入的name是否在lockfile,若是被锁定直接退出,with可以同时打开多个文件 若是不在loclfile,再判断name是否在loginfile,若是则输入密码尝试登录三次,若是正确,则提示欢迎语: 若是输入三次密码且一直未正确,则直接写入lockfile """ count = 0 while count < 3: flag = False account_input = input("input your account:") password_input = input("input th...
e49798fb7679be5f54487930672eb3bfb924b3bc
joehammer934/python-program
/斐波那契数列.py
312
3.625
4
# -*- coding: utf-8 -*- """ Created on Wed Oct 5 15:43:47 2016 @author: li """ class Fib(object): def __getitem__(self, n): a, b = 1, 1 for x in range(n): a, b = b, a + b return a #for n in Fib(): #if n<1000: #print(n) f=Fib() print(f[20])
aaecd87baa6e5c5c9a29d8ff5649d7eeff8767a7
mikeflowerdew/DMSTA_calibration
/CombineCLs.py
43,184
3.53125
4
#!/usr/bin/env python import pickle,math class CLs: """Small data class""" def __init__(self, value): try: # Maybe "value" is actually a CLs object self.value = value.value self.valid = value.valid self.ratio = value.ratio except AttributeError:...
ad12922f69612f9cf7525b4795c3e1abb5e00233
Mr-Rakib/Python
/FileIO/main.py
624
3.890625
4
""" r - read mode - default w - write mode x - create file if not exist a - append to the file t - text mode - default b - binary mode + - read and update file.read() -> read the hole file as a text file.readLine() -> read by line file.readLines() file.open() file.close(...
f8e1592a3803f01017496bf6f67411712b8fac3d
ranrolls/pythonExFiles
/4-ELHCLT00046625/basic_dataStructure.py
1,563
3.96875
4
Python 3.6.0a4 (v3.6.0a4:017cf260936b, Aug 16 2016, 00:45:10) [MSC v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> print('hey') hey >>> aL = [] >>> for n in range(1,4): aL += [n] >>> aL [1, 2, 3] >>> for n in range(5,9): aL.append(n) >>> aL [1, 2, 3, 5, 6, 7,...
e86b773f209395a03aa64681e360a367de349136
alexander-travov/algo
/InterviewBit/GraphAlgorithms/CommutableIslands.py
2,672
4.0625
4
# -*- coding: utf8 -*- """ Commutable Islands ================== There are A islands and there are M bridges connecting them. Each bridge has some cost attached to it. We need to find bridges with minimal cost such that all islands are connected. It is guaranteed that input data will contain at least one possible sc...
db67594fddca76f2bed9632a2a48a1cdadb3d4dc
rafaelperazzo/programacao-web
/moodledata/vpl_data/59/usersdata/195/61943/submittedfiles/testes.py
684
3.765625
4
# -*- coding: utf-8 -*- def interseção(a,b): cont=0 indice=0 if len(a)<len(b): while indice<len(a): for j in range(0,len(b),1): if listaindice==b[j]: con=cont+1 indice=indice+1 else: while indice<len(b): for j in ran...
06c5a955b925276dcd46be316f0f917727a2ee7c
vanshaw2017/leetcode_vanshaw
/349_intersection/349_solution.py
447
3.78125
4
class Solution: def intersection(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: List[int] """ intersection=[] for i in nums1: for j in nums2: if (i==j ): if(i in intersection): ...
47ccdd71212ca7c53eb5854b9bdf6a97cc4b9b7e
vegetdove/learngit
/homework1/YearJudge.py
175
3.828125
4
print("请输入一个年份",end=" ") year = int(input()) if(year % 4 == 0 and year % 400 != 0) : print(year,"年是闰年") else : print(year,"年不是闰年")
f5db747c8f42a3cb02d14169733f8e015571d462
dguelde/python
/Algorithms/hw2/Guelde_Donovan_HW2.py
3,763
4.09375
4
# Author: Donovan Guelde # CSCI-3104 FAll 2015 # HW 2: write a python program implementing RSA encryption to encrypt and decrypt a simple message # Automatically executes RSA algorithm with 8,16, and 24 bit-length keys, and displays relevant info # On my honor, as a University of Colorado at Boulder student, # I hav...
070a4f1449ee54ffcd1cc4e0d89b8464bdd71daf
niladri18/coding_problems_python
/chap5.py
1,113
3.84375
4
import sys ''' Problem 5.1 You are given two 32-bit numbers, N and M, and two bit positions, i and j. Write a method to set all bits between i and j in N equal to M (e.g., M becomes a substring of N located at i and starting at j). ''' x = int('101011',2) y = int('1000111100000',2) j = 2 i = 7 #All 1's max_i = ~0 ...
2be0b04a612847ea0417bf0095a2329a06e6a846
mrarmyant/python_oop
/car.py
599
3.5625
4
class Car: def __init__(self,price,speed,fuel,mileage): self.price=price self.speed=speed self.fuel=fuel self.mileage=mileage self.salesTax=15 if price>10000 else 12 def display_all(self): return ("price:" + str(self.price), "speed:" + str(self.speed), "fuel:" + s...
bc6668fa0dfee7eb0cf2c585fede81a9724a8706
human02/solved-questions
/349. Intersection of Two Arrays.py
1,739
3.984375
4
""" Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must be unique and you may return the result in any order. Example 1: Input: nums1 = [1,2,2,1], nums2 = [2,2] Output: [2] Example 2: Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] Output: [9,4] Explanation...
2cb01bbf4052151df651fec433eaa20c9eb63541
SandraCoburn/cs-module-project-hash-tables
/applications/word_count/word_count.py
651
3.984375
4
import re #regular expressions def word_count(s): d = {} #ignored = ['"', ':', ';', ',', '.', '-','+','=','\\','|','[',']','{', '}', '(', ')','*', '^', '&', '/'] words = s.lower().split() for w in words: w = re.sub(r'[^\w\']+', '', w) if w == "": continue if w n...
f151670e1f909e20e59fa0f3bd398e993546a173
nsapundzhiev/HackBG
/week2/ 2-File-System-Problems/cat.py
236
3.59375
4
import sys def cat(): if len(sys.argv) > 1: filename = sys.argv[1] file = open (filename, "r") content = file.read() return content file.close() else: return "Please enter a file" if __name__ == '__cat__': print(cat())
b533ba3978f6e642e4853da1e631c37da785e73b
celetrik/bug-free-umbrella
/my_info.py
1,146
3.96875
4
# get the user name when the file is run # from sys import argv # filename, name = argv # prompt = ">>" # print(f"Hi {name}") # print(f"I'm going to ask you a series of questions") # print(f"How many keys are there on a computer keyboard?", end = '') # keys = int(input(prompt)) # #conditions # #if the answer 296 the...
e6c5ab088004f2540ca6a4d25bc041e5a287e86c
quangineer/soccerdatawithpandas
/SQLdatasoccer.py
1,962
4.21875
4
import pandas as pd filedata = 'data.csv' #Read File : data = pd.read_csv(filedata) #Make an object out of an object: data_Age = data["Age"] #Make a list from object of data["Age"] from object of data: # data_Age = data["Age"].tolist() #Use python to find out how many players' age equal and over 30: # A = [] # fo...
1f654d5893c3cc754458592e7d53160d792210ad
EpsilonHF/Leetcode
/Python/1041.py
1,097
4.25
4
""" On an infinite plane, a robot initially stands at (0, 0) and faces north. The robot can receive one of three instructions: "G": go straight 1 unit; "L": turn 90 degrees to the left; "R": turn 90 degress to the right. The robot performs the instructions given in order, and repeats them forever. Return true if an...
21e49d1ad698cd59df0c262c7ee21287a9759072
ShellCode33/CompressionAlgorithms
/compress/algorithms/huffman.py
9,856
3.6875
4
# coding: utf-8 from compress.utils.binary_tree import * class HuffmanNode(Node): """Unlike the classic Node, the HuffmanNode is sorted by frequency and not value. Attributes ---------- frequency : int Holds the frequency of the byte(s). """ def __init__(self, frequency=0, value=No...
51d054fa29a5c65a12b0f5556bea69e7c4f0ed57
DasisCore/python_challenges-master
/pyChallenge_058.py
399
3.78125
4
import random score = 0 for i in range(1, 6): r_num1 = random.randint(1, 50) r_num2 = random.randint(1, 50) answer = r_num1 + r_num2 print(r_num1, '+', r_num2, '= ?') reply = int(input('Your answer? : ')) if reply == answer: print('"Well done!"\n') score = score + 1 else: ...
2aa16eaad49faac5b6cd268e1923bd2a9f26a51b
Sauluslo/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/4-only_diff_elements.py
211
3.578125
4
#!/usr/bin/python3 """ A Function that returns a set of all elements present in only one set. """ def only_diff_elements(set_1, set_2): set_list = set_1.symmetric_difference(set_2) return set_list
32d93e5c2a76460809f71b66c4d95929a19294e4
chuckinator0/Projects
/scripts/mergesort.py
1,966
4.4375
4
''' Mergesort! ''' def merge(left, right): """ This function merges two sorted subarrays into one sorted array. """ result = [] left_index = 0 right_index = 0 # We check each subarray from left to right, appending the lower value # to a result array. The left_index is updated when a value from the left # sub...
c90954c0d3273c5a3ee4d3c99f9925f6371f519b
wang264/JiuZhangLintcode
/DP/L6/29_interleaving-string.py
3,230
3.953125
4
# 29. Interleaving String # 中文English # Given three strings: s1, s2, s3, determine whether s3 is formed by the interleaving of s1 and s2. # # 样例 # Example 1: # # Input: # "aabcc" # "dbbca" # "aadbbcbcac" # Output: # true # # Example 2: # Input: # "" # "" # "1" # Output: # false # # Example 3: # Input: # "aabcc" # "dbbc...
71948ab032a1959e2ff30fa9b83d79c606fd537f
GGbb2046/ST018
/Assignments/Assignment03/Turtlegraphics.py
160
3.765625
4
import turtle gal= turtle.Turtle() C = (input("Please enter the color of the circle ")) gal.color(C) gal.circle(100) window = turtle.Screen() window.mainloop()
a08be912d3fe75de2f3751f88ad191ea21dd5d45
tanxvyang/Python-
/src/day06/coach2.py
2,186
3.71875
4
def sanitize(time_string): if '-' in time_string: splitize = '-' (mins, secs)=time_string.split(splitize) elif ':' in time_string: splitize = ':' (mins, secs)=time_string.split(splitize) else: return(time_string) return(mins+'.'+secs) ''' #1,2 def get_coach_data(f...
6d184c91577ff8f0c3b8ecaab2efaec7b0874c34
daniel-reich/ubiquitous-fiesta
/r9y4yrSAGRaqTT7nM_4.py
346
3.578125
4
def find_missing(lst): if lst == None: return False for i in range(len(lst)-1): if lst[i] == []: return False lst = sorted(lst, key=len) for i in range(len(lst)-1): increment = 1 if len(lst[i]) + increment != len(lst[i+1]): return len(lst[i+1])-in...
d48bb6afed7e891b4e82e5eb4b6c20f9466ceb00
BillMaZengou/nature_of_code
/0_Introduction/04_custom_distribution/custom_random_number_with_MonteCarlo.py
615
3.59375
4
import numpy as np import matplotlib.pyplot as plt def monteCarlo(): selection = True while selection: r1 = np.random.rand() r2 = np.random.rand() probability = r1 * r1 # Custom function (only polynominal, for logrithmic r1 and r2 need modification) if r2 < probability: ...
208b31101fa7b95f2f61e33388da8f1c0a4ef85e
woofan/leetcode
/530-get-minimum-difference.py
836
3.578125
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 getMinimumDifference(self, root: TreeNode) -> int: if not root: return 0 tree_ele = [] def myhelp...
afc7190d651de40cff29bce59147d5db13211bbf
noahlwest/leetcode
/python/medium/74_Search_a_2D_Matrix.py
458
3.625
4
class Solution: def searchMatrix(self, matrix: List[List[int]], target: int) -> bool: #search down, then right row = 0 for i in range(0, len(matrix)): if matrix[i][0] <= target: row = i for j in range(0, len(matrix[row])): ...
6d758f9949483fd7387820fd5d6d5245ca5a086e
suddencode/pythontutor_2018
/7.3.py
108
3.515625
4
a = input().split() for i in range(1, len(a)): if int(a[i]) > int(a[i-1]): print(int(a[i]), end=' ')
28717e9f466d1e98c66a1a5152564c8fe861ef5c
4dv3ntur3/bit_seoul
/keras/keras18_simpleRNN2_scale.py
2,029
3.546875
4
#2020-11-12 (4일차) #RNN(Recurrent Neural Network): LSTM, SimpleRNN, GRU # LSTM -> SimpleRNN (용법 같다) import numpy as np #1. 데이터 x = np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 11], [10, 11 ,12], [20, 30, 40], [30, 4...
b45737a281d71ee6c336e72e8e109452eae4287d
wenjunz/leetcode
/swap_nodes_in_pairs.py
667
3.75
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def swapPairs(self, head): """ :type head: ListNode :rtype: ListNode """ dummy = ListNode(0); dummy.n...
0266201f9a5b1c1656a80ab1f40f9558ddaf7361
ErikLeemet/python-test
/8.py
466
3.921875
4
year = int(input("Sissesta aasta: ")) if year % 4 == 0 and year % 100 != 0 or year % 400 == 0: print("on liigaasta") else: print("pole liigaasta") if (year % 4) == 0: if (year % 100) == 0: if (year % 400) == 0: print("{0} is a leap year".format(year)) else: print("{0}...
c243083a97b553340c0ab8461f1a8c361c730dd9
MasterCoookie/python_advanced
/Templates/cart.py
911
4.34375
4
''' Templates are used to build a number of strings using, you guessed it, templates. Variables in templates are preceded with a $ sign. May be useful for ex. while writing a programme that renames pictures The placeholder can be specified using {} ex ("The ${place}yard") ''' from string import Template class MyTemp...
783456d0f344db493b3c4ddab81127f714cb0be0
Nockternal/Burger
/intro to programming/Completed Tasks/Task 10/example.py
4,638
4.4375
4
#************* HELP ***************** #REMEMBER THAT IF YOU NEED SUPPORT ON ANY ASPECT OF YOUR COURSE SIMPLY LOG IN TO www.hyperiondev.com/support TO: #START A CHAT WITH YOUR MENTOR, SCHEDULE A CALL OR GET SUPPORT OVER EMAIL. #************************************ # PLEASE ENSURE YOU OPEN THIS FILE IN IDLE oth...
08b0a3056f070aba2d74c466a213f2324f5f9ba7
a8578062/store
/day02/demo10.py
251
3.84375
4
username = 'jason' password = 'admin' username1 = input("请输入用户名:") password1 = input("请输入密码:") if username1 == username and password == password1: print("登录成功") else: print("用户名密码错误!")
e2b281a48696cd6cd16626b99f55af5e0d77497f
yuriscripnic/kmeans
/kmeans_question.py
1,838
3.765625
4
""" KMean Question: Given a set of two dimensional points P (e.g. [(1.1, 2.5), (3.4,1.9)...]; the size of set can be 100s), write a function that calculates simple K-means. The expected returned value from the function is 1) a set of cluster id that each point belongs to, and 2) coordinates of centroids at the end of ...
de869f9b795105e4eacafd21a930a27906276df8
CLCdawn/Hello-world
/PycharmProjects/dataScience/lowerAndUpper.py
196
3.96875
4
s = input() result = "" for c in s: if 'A' <= c <= 'Z': result += c.lower() elif 'a' <= c <= 'z': result += c.upper() elif c == ',': result += ',' print(result)
a0788563b6405befb47b3adc68952c92a1b5b1a7
DennisSoemers/MultiMAuS
/authenticators/abstract_authenticator.py
596
3.875
4
from abc import ABCMeta, abstractmethod class AbstractAuthenticator(metaclass=ABCMeta): def __init__(self): """ Every authenticator has to have a name :param name: """ super().__init__() @abstractmethod def authorise_transaction(self, customer): """ ...
efeb734cb5de30824245bdd5fad0dcbc589d29ab
czar3985/mini-projects
/03_Secret_Message/rename_files.py
954
3.96875
4
# TITLE: Secret Message Decoder # DESCRIPTION: A secret message is in folder decodeThis. # Running this program will rename the files to remove the numbers # from the file names. When the files are sorted, a secret message # will appear. # NOTE: The translate method is different in Python 3.x. # This was run using Pyth...
057fe131d6d1718c861bf70cea95a3816f42d588
233-wang-233/python
/day15/15day_2.py
361
3.78125
4
""" 动态规划 - 适用于有重叠子问题和最优子结构性质的问题 使用动态规划方法所耗时间往往远少于朴素解法(用空间换取时间) """ def fib(num,temp={}): if num in (1,2): return 1 try: return temp[num] except KeyError: temp[num]=fib(num-1)+fib(num-2) return temp[num]
9a793efb0bdbba6573c82ad1fc6b41025fd3dd36
nsiicm0/project_euler
/15/impl2.py
721
3.515625
4
''' Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner. - RRDD - RDRD - RDDR - DRRD - DRDR - DDRR How many such routes are there through a 20×20 grid? ''' from math import factorial # for lattice path, the number of ...