blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
5a9986049bc98641d28595d3bd0047beaef46a6f
jakehoare/leetcode
/python_1_to_1000/402_Remove_K_Digits.py
995
3.6875
4
_author_ = 'jake' _project_ = 'leetcode' # https://leetcode.com/problems/remove-k-digits/ # Given a non-negative integer num represented as a string, remove k digits from the number so that the new number # is the smallest possible. # Iterate over num. If previous digit > current digit then preferable to remove previ...
6b2722114a6e9058de753e910ea158a9c5c94da7
HuXuzhe/algorithm008-class02
/Week_07/208.实现-trie-前缀树.py
4,716
3.890625
4
''' @Descripttion: @version: 3.X @Author: hu_xz @Date: 2020-06-07 17:34:00 @LastEditors: hu_xz @LastEditTime: 2020-06-19 14:25:10 ''' # # @lc app=leetcode.cn id=208 lang=python # # [208] 实现 Trie (前缀树) # # @lc code=start # 用dict模拟字典树 class Trie(object): def __init__(self): """ Initialize your ...
76a10f7760ef95391cabdbb21a7d55f56c5d5dd6
thorenscientific/py
/Simple Programs/Simple_Loop.py
101
3.78125
4
print "Hello, World!" #a = range[0,10] def loop(): for x in range(0,10): print x
1aabde13f113adcf0bc3e510a5d0438a86ecdbd8
RobertHan96/CodeUP_BASIC100_Algorithm
/1070.py
531
4
4
# 월이 입력될 때 계절 이름이 출력되도록 해보자. # 예 # 월 : 계절 이름 # 12, 1, 2 : winter # 3, 4, 5 : spring # 6, 7, 8 : summer # 9, 10, 11 : fall def season(): month = input("원하는 달을 숫자를 입력해주세요") month = int(month) if 1 <= month <= 2: print("winter") if 3 <= month <= 5: print("spring") if 6 <= month...
1f98b64149895ca2044f5496ced79abfd3cdccd9
jkotanjian/Python-Django
/python/python-fundamentals/bubble_sort.py
564
3.96875
4
arr=[8,1,5,3,2,0] def bubbleSort (arr): for y in range(len(arr)-1): for x in range(len(arr)-1-y): if arr[x]>arr[x+1]: arr[x], arr[x+1]=arr[x+1], arr[x] return arr print(bubbleSort (arr)) def selectionSort(arr): for x in range(len(arr)): minPosition = x for y in ran...
e256e9ec17b633a10c5baa7aa9ae38c4059ac123
capoletti/python-basico
/python-basico/iteradores_aleatoriedade.py
526
3.796875
4
""" Iteradores e numeros aleatorios """ import random #lazy range def lazy_range(n): i = 0 while i < n: yield i i += 1 for i in lazy_range(10): print str(i) #numeros randomicos four_random = [random.random() for _ in range(4)] print four_random random.seed(5) print "seed: " + str(rando...
cc9a7fe5d91428e0f7fcf6515390775016a22699
LordBao666/MITLecture6.0002_introduction_to_computational_thinking_and_data_science
/pset/pset5/ps5.py
17,198
3.5625
4
# -*- coding: utf-8 -*- # Problem Set 5: Experimental Analysis # Name: # Collaborators (discussion): # Time: import pylab import re # cities in our weather data CITIES = [ 'BOSTON', 'SEATTLE', 'SAN DIEGO', 'PHILADELPHIA', 'PHOENIX', 'LAS VEGAS', 'CHARLOTTE', 'DALLAS', 'BALTIMORE',...
fcd42db3bf4e8e9aaea120b0b226fff346975d4a
zhangjiapeng23/my_algorithm_practice
/exercises_lib/sort_list.py
2,101
3.765625
4
from typing import List class Solution: def bubble_sort(self, s: List) -> List: s_le = len(s) for i in range(s_le): for j in range(s_le-1-i): if s[j] > s[j+1]: s[j], s[j+1] = s[j+1], s[j] return s def select_sort(self, s: List) -> List:...
bfb3e155ac07f9155a51f62d813e951d1e2b0132
btoll/howto-algorithm
/python/tree/traversal/postorder.py
1,502
3.65625
4
import ipdb from Tree import TreeNode # Recursive def postorder(root, visited=[]): if not root: return ipdb.set_trace() postorder(root.left) postorder(root.right) visited.append(root.value) return visited # Iterative #def postorder(root): # stack = [] # current = root # v...
2103fa90a8fb8cf9f7e435f63ffae05100ac98ec
chruxin/AdventOfCode
/2018/day03.py
2,295
3.90625
4
import argparse input = [] def main(): parser = argparse.ArgumentParser() parser.add_argument('--part', dest='part', type=int) args = parser.parse_args() if args.part == 1 or args.part == 2: parse_input() if args.part == 1: part1() elif args.part == 2: part2() def p...
ea4a66c928cb3765d878b6f8aa3289d115146cef
wlf773/dwarfMountainGame
/Tile.py
378
3.5625
4
from enum import Enum class TileType(Enum): stone=1 wood=2 treasure=3 monster=4 ironOre=10 dross=11 iron=12 silverOre=20 pewter=21 silver=22 goldOre=30 lead=31 gold=32 def __repr__(s): return s.name class Tile: def __init__(s,v): if isinstance(v,int): s.type = TileType(v) else: s.type ...
b486e274d228c873ae18ab32676b353be8c2b16d
MaurizioMartin/codewars
/Katas/2-sum_mixed_array.py
528
3.609375
4
# -*- coding: utf-8 -*- """ Created on Wed Aug 21 09:31:12 2019 @author: macl3 URL: https://www.codewars.com/kata/sum-mixed-array/train/python """ lista = [1,4,"3",1,"4",5,"5"] def sum_mix(arr): for idx, e in enumerate(arr): if type(e) == str: arr[idx] = int(e) suma = sum(arr) return ...
66c8fb5c2ffd17a1c26bca618bca7562154e64f9
sheldonzhao/LeetCodeFighting
/492. Construct the rectangle.py
745
4
4
''' 1. The area of the rectangular web page you designed must equal to the given target area. 2. The width W should not be larger than the length L, which means L >= W. 3. The difference between length L and width W should be as small as possible. ''' import math class Solution(object): def constructRectangle(s...
0c47037cc393fd568764e6928ab3c6a855f4a401
joepvdbogaert/fire.ai
/work/spyro/targets.py
6,097
3.75
4
from __future__ import division import numpy as np # from numba import jit def n_step_advantage(rewards, state_values, gamma=0.90, n=10): """Compute the n-step forward view advantages of a series of experiences. This function calculates the n-step forward view temporal difference and subtracts the estima...
54aa4e6a6154bdba5bfeceaf67d852dce4dc7c2c
joinalahmed/University_of_Michigan_Python_for_Informatics_Certificate
/3_Using_Python_to_Access_Web_Data/Week4_Ch12_Programs_that_Surf_the_Web/urllinks.py
1,109
3.96875
4
# In this assignment you will write a Python program that expands on http://www.pythonlearn.com/code/urllinks.py. # The program will use urllib to read the HTML from the data files below, extract the href= values from the anchor tags, # scan for a tag that is in a particular position relative to the first name in the l...
9d2a2f0d5dd952d17563802973bf733b8f2abc5e
sevvalyogurtcuoglu/GlobalAIHubPythonHomework
/hw2.py
828
3.890625
4
user_number=int(input("please input users number : ")) informations=[] while user_number>0: first_name=input("please input first name : ") last_name=input("please input last name : ") age=int(input("please input age : ")) d_year=int(input("please input date of birth (just year) : ")) c=...
c4408ef4ab74c3768ac78eceb9cb72eb7be0b62c
StellaaaHu/leetcode
/leetcode_350.py
535
3.703125
4
#encoding:utf-8 #Given two arrays, write a function to compute their intersection. #Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. class Solution: def intersect(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: List[int] """ n...
466095fd0c2ca3cd87946d742108a03ff540012b
hsvu/Tutorial_T18B
/Tute 5: Classes and Abstract Classes/classes.py
2,025
4.25
4
# recall the general structure of a class and understand that # the Constructor and attribute definition are combined # class definition, # the brackets would contain the class it inherits from (if it inherits from anything) class Rectangle(): # Constructor for this class, so that we can create objects of this t...
f2ac490a99e7d6412f7bb2dac0b75606bad065a0
Dsalce/TFM
/Model/inspector.py
1,333
3.515625
4
""" Class Model of Inspector """ import statistics as stats class Inspector(object): #Constructor def __init__(self,id): self.totalDefect=0 self.propor={} self.defects={} self.id=id #Add a new defect to the dictionary def addDefect(self,defect): value=self.defec...
2cd3d7f271c6848fa3daa6f8313838904ebd9489
Sushmita00/class-5
/cw.py
503
3.875
4
''' print("1\n 2\n 3\n 4\n 5") for x in range(1,1000000): print(x) for x in range(1,10,2): print(x) else: print("thats all") i=0 while i<5: print(i) i=i+1 name=input("enter the name") while name.isdigit()==True or len(name)<4: name=input("please enter the name") print("Name acc...
f3bab26f8b4420ef08e209d3299657843e701d41
zeel2321-lit/Project-s-
/python/inputt.py
136
3.875
4
#name =input("Enter your name") #input in one line name , age = input("Enter your name and age ").split(",") print(name) print(age)
9d3d14df765e226c5d500bd8512de9885c241f20
rcjdiv/Python_Procedural_Programming
/blindAuction/main.py
723
3.921875
4
from replit import clear from art import logo flag = True participants = {} def find_highest_bidder(bidding_record): highest = 0 winner = "" for i in bidding_record: value = bidding_record[i] if value > highest: highest = value winner = i print(f"The winner is {winner} with a bid of ${...
9af31e9272e0ec62d7006fe6aef9aa823866bbb4
andrewsala16/HCS2
/Class4.py
1,171
3.78125
4
# Andrew Sala # 4B import random class Card: suits = ["Clubs", "Diamonds", "Hearts", "Spades"] rank = [2, 3, 4, 5, 6, 7, 8, 9, 10, "A", "J", "Q", "K"] def __init__(self): self.rank = Card.rank[random.randint(0, len(Card.rank)-1)] self.suit = Card.suits[random.randint(0,3)] ...
56e0d505867dc002bf74b91900fd75e5321f7720
jdaeira/Udemy-Python
/Data-Types/lists.py
640
4.3125
4
my_list = [1, 2, 3] my_mixed_list = ["John", 50, "Jackie"] # lists can have different data types print(my_list) print(my_mixed_list) print(len(my_mixed_list)) print(my_mixed_list[1:]) combined_list = my_list + my_mixed_list # combines the two lists print(combined_list) my_mixed_list.append("Honda") # adding items...
74908e12721083f679e6395b359341918b87a0b3
piush2611/Masai-Submissions
/week_13/day_4/countOccurancesString.py
215
3.796875
4
string = input("Please enter the string : ") dictionary = {} for i in string: if i in dictionary: dictionary[i] += 1 else: dictionary[i] = 1 for k,v in dictionary.items(): print(k, v)
1ec27ffd56a2ad45ed6ff505e2f4b1a1acce41c2
ArthurSpillere/AulaEntra21_ArthurSpillere
/Exercícios Resolvidos/Maykon/01-Exercicios/Aula008/Ex3.py
1,086
4.15625
4
#--- Exercício 3 - Funções #--- Escreva uma função para listar pessoas cadastradas: #--- a função deve exibir todas as pessoas cadastradas na função do ex1 #--- Escreva uma função para exibi uma pessoa específica: #--- a função deve exibir uma pessoa cadastrada na função do ex1 filtrando por id def listar_cadastro...
564d5f082d753ede65efb79cff3aff82d9d86a3d
Volkov-da/Python-projects
/lab3_contest/D-task.py
118
3.578125
4
import math c = int(math.sqrt(int(input()))) i = 1 while i <= c: out = i ** 2 print(out, end=' ') i += 1
de5c8bbe67899239fc6f4fae96d51ecb57239eef
NoSpectators/python-examples
/bobbles_class.py
883
3.890625
4
class Bobblehead(object): def __init__(self, bobbles): #creates instance of the class self.bobbles = bobbles def number_of_bobbles(self): #prints number of bobbles print 'number of bobbles =', self.bobbles class Karthik(Bobblehead): def __init__(self, bobbles): self.bobbles = bobbles def print_u...
e31ee4709dada24d7a4133447499e3323c2e65d5
mattbachmann/pythontutorial
/extension.py
590
3.90625
4
from abc import ABC from abc import abstractmethod class Papa(ABC): cool = "Yea!" def __init__(self, name: str): self.name = name @abstractmethod def apply(self, input: str) -> str: pass class Bobo(Papa): def apply(self, input): print(Bobo.cool) return self.name ...
789ce3b5aa549f240dad7f389596b80faacf2d6c
fred-13/Python-practices-from-GeekBrains
/Python_Basics/Python-1-lesson6-normal.py
1,647
3.890625
4
print("---------------------Task-1--------------------------\n") class Person: def __init__(self, name, health, damage, armor): self.name = name self.health = health self.damage = damage self.armor = armor def __damage(self, damage): if self.armor > 0: sel...
58d9c26193393586349f1c05ff439168552cade8
kidcats/LintCode_python
/rotateright.py
920
3.96875
4
class ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next ''' 递归的思路是求两个数满足 ''' def rotateRight(head, k): # write your code here #指针走到倒数第K个位置处,形成环然后打断 if head==None or head.next==None: return head pre=head end=head...
46d48ef17cefd2ad86755f562101ed096c79baf9
xuefengCrown/Files_01_xuef
/all_xuef/ComposingPrograms/python-cookbook/1.4_获取最大的n个元素.py
2,659
3.734375
4
""" 怎样从一个集合中获得最大或者最小的N个元素列表? heapq模块有两个函数:nlargest() 和 nsmallest() 可以完美解决这个问题。 """ import heapq nums = [1, 8, 2, 23, 7, -4, 18, 23, 42, 37, 2] print(heapq.nlargest(3, nums)) # Prints [42, 37, 23] print(heapq.nsmallest(3, nums)) # Prints [-4, 1, 2] # 两个函数都能接受一个关键字参数,用于更复杂的数据结构中: portfolio = [ {'name': 'IBM', 'sh...
f21b71092b63e1c631b3ddf6f986e4151f7a5c52
fadeawaylove/leetcode_practice
/数组/867_转置矩阵2.py
965
3.921875
4
""" 给定一个矩阵 A, 返回 A 的转置矩阵。 矩阵的转置是指将矩阵的主对角线翻转,交换矩阵的行索引与列索引。   示例 1: 输入:[[1,2,3],[4,5,6],[7,8,9]] 输出:[[1,4,7],[2,5,8],[3,6,9]] 示例 2: 输入:[[1,2,3],[4,5,6]] 输出:[[1,4],[2,5],[3,6]]   提示: 1 <= A.length <= 1000 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/transpose-matrix 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 """ fr...
a322f008d8a4f188ce3990cf1c4a50eed7ba9102
VarshiniBalaji/tomtom_techgig
/code/logval.py
334
3.5
4
import pandas as pd data=pd.read_csv('db/data.csv') df=pd.DataFrame () def validate(name,contact): if(name != None and contact != None): print(type(contact),type(name)) print(contact,name) df=data[data['contactno']==int(contact)] print(df) nm=str(df['name'].str) print(type(nm)) print(nm,'==',name) ret...
0a09b1a0bb23f8cc64bc8ebb1d0b1eea87a44957
jack2784/Artificial-Intelligence
/draw.py
657
3.5
4
import matplotlib.pyplot as plt import matplotlib.lines as lines import matplotlib.text as mtext class MyLine(lines.Line2D): def __init__(self, *args, **kwargs): # we'll update the position when the line data is set self.text = mtext.Text(0, 0, '') lines.Line2D.__init__(self, *args, **kwar...
6648a0a313b020527a78bdfef00cbbcc6ffaf483
lucasgnavarro/python-design-patterns
/structural/bridge.py
1,997
4.1875
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- __author__ = "Lucas Navarro (lucasgnavarro@gmail.com)" __copyright__ = "Copyright (C) 2018- Lucas Navarro" # Python Version 3.6 # # Example of bridge design pattern # from abc import ABC, abstractmethod class Website(ABC): def __init__(self, implementation): ...
a2d99cda54b39fb97dc0aaa5c52f8e9a770d586a
kdar/challenges
/hackerrank/challenges/Functional Programming/Recursion/python3/crosswords_101.py
1,782
3.578125
4
#!python3.5 from enum import Enum INPUT="""+-++++++++ +-++++++++ +-++++++++ +-----++++ +-+++-++++ +-+++-++++ +++++-++++ ++------++ +++++-++++ +++++-++++ LONDON;DELHI;ICELAND;ANKARA""" # 6 -> (0,1), (1,1), (2,1), (3,1), (4,1), (5,1) # 6 -> (7,2), (7,3), (7,4), (7,5), (7,6), (7,7) # 7 -> (3,5), (3,...
26efb820f14fa19f10f148d671a714422a17daf1
yangtao0304/hands-on-programming-exercise
/data_structure/queues_and_stacks/733_flood_fill.py
836
3.59375
4
class Solution(object): def floodFill(self, image, sr, sc, newColor): """ :type image: List[List[int]] :type sr: int :type sc: int :type newColor: int :rtype: List[List[int]] """ directions = ((-1, 0), (1, 0), (0, -1), (0, 1)) queue = [(sr, sc)...
9c859347b0d2a500ec5c3766d24b4036c2d2bcc2
The-Mosher-Lab/genomics_tools
/bedtools_merge_id_assigner.py
1,281
3.5
4
#!/usr/bin/env python3 # Author: Jeffrey Grover # Purpose: Take a file output by bedtools merge and assign IDs to the rows. # Output a bed file with 6 columns. # Created: 2019-04-19 from argparse import ArgumentParser def assign_bedtools_merge(input_file, basename): line_count = 0 with open(input_file, 'r')...
299287d3c26c7b6f5c21cf82c9e3d1a633a9c38e
Mavuks/Iti0102
/EX13A/recursion.py
43,608
4.34375
4
"""Recursion vs loops.""" def loop_reverse(s: str) -> str: """ Reverse a string using a loop. :param s: input string :return: reversed input string """ a = "" for i in range(1, len(s) + 1): a += s[len(s) - i] return a def recursive_reverse(s: str) -> str: """ Revers...
182824d49b21cf272617da38a09043db99660a06
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/223/users/4191/codes/1807_2571.py
136
3.578125
4
from numpy import * vet=(input("string: ")) b= "" for i in range(len(vet)): if(vet[i]!="a" and vet[i]!="A"): b=b+vet[i] print(b)
92024807e65cf1cfe8325015ddd0cfe88eeeef0c
daredumidu/secret_message
/secret_v6.py
2,925
4.375
4
#this python program use to encrypt and decrypt messages using Caesar cipher try: import getpass #password module alphabet = 'abcdefghijklmnopqrstuvwxyz' alphabet1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' #print (alphabet[0]) #print (alphabet[7]) #print (alphabet1[17]) new_message = '' #- - - - - -...
9d97a24ab521e61468aeb3b81dff059e9ae0b195
ch3rag/Python
/Examples/Permutations.py
645
3.84375
4
myList = [1, 2, 3] newList = [[x] for x in myList] permutations = [] for k in range (0, len(myList) - 1): for i in range(0, len(myList)): for j in range(0, len(newList)): if myList[i] not in newList[j]: temp = newList[j].copy() temp.append(myList[i]) ...
11378b30d7c8984a4c3986b9a9a593ca57026e0e
ratuljain/dp
/graphs/DetectCycle.py
2,011
3.828125
4
def dfs(graph, start): color = {i : 'white' for i in graph} stack = [start] visited = [] while stack: vertex = stack.pop() if color[vertex] == 'grey': return True break color[vertex] = 'grey' visited.append(vertex) stack.extend((graph[vert...
5cabe5f8de6969eaaa0b0d7561353ccacb225f5d
wendreof/pyExercises
/05_conditions/ex031.py
447
4
4
# [PT-BR] Desenvolva um programa que pergunte a distância de uma viagem em Km. Calcule o preço da passagem, # cobrando R$0,50 por Km para viagens de até 200Km e R$0,45 parta viagens mais longas. distance = int(input('Type the distance in km: ')) if distance <= 200: toPay = distance * 0.5 print('Buss ticket v...
4df6b3bd0818ef850ee909baf301e2bf6a0504d1
bermetkaa/homeworks
/hw_3.py
1,323
3.921875
4
""" Для выполнения этого задания вам помогут методы списков""" # Покупки на сегодня today = ["лемон", "блокнот", "кола", "ручка", "сигареты", "молоко", "лампочка"] # Покупки на завтра tomorrow = [] # Удалить сигареты из списка today today.remove(today[4]) # Добавить все орехи из списка nuts в список today nuts = ["ф...
9ffa8ee6e8364d1b3f65b45930cf1274bf1cb285
creativelaurels/learn-python-the-hard-way
/ex17.py
1,552
4.25
4
# module <from> called on module <sys> # to <import> the module <argv> (argument) # module <from> called on <os.path> module # to import the function <exists> from sys import argv from os.path import exists script, from_file, to_file = argv # ^ user needs to enter the script to run (this file) # followe...
8a0e71194ee249f42bbd00a491716e7d27cc0a8b
peachgo-/learn-python-Stanford-lab
/labs/lab1/collatz.py
1,515
4.625
5
#!/usr/bin/env python -3 tt # using recursion def collatz(n): """ Return the collatz sequence starting at `n `. a collatz sequence is an iterative sequence defined on the positive integers by n -> n / 2 if n is even n -> 3n + 1 if n is odd for example, collatz(13) should yield th...
9ee1df35539ede3601c81a8b18dbe11b85e17e9a
diligent-1618/test1-python-
/15data view-learn/15.3随机漫步/2-rw_visual-隐藏坐标轴.py
732
3.546875
4
import matplotlib.pyplot as plt from random_walk import RandomWalk#从rand_walk.py模块导入Randomwalk类 #只要程序处于活动状态,就不断模拟随机漫步 while True: #创建一个RandomWalk实例,并将其包含的点都绘制出来 rw = RandomWalk() rw.fill_walk() #更换颜色,渐变色 plt.scatter(rw.x_values,rw.y_values,c='red',edgecolors='none',s=10) #隐藏坐标轴,注意此处一定是在输出图片之...
9a10929c8246418b141de5cc5f549130d15af274
james4388/algorithm-1
/algorithms/google/MinimumWindowSubstring.py
1,012
3.5
4
# min window string contains all string # https://leetcode.com/problems/minimum-window-substring/description/ # Running low and high pointer, count number of character cover # if found window, increase low pointer to shorten window size def minWindow(s, t): c = Counter(t) need = len(t) n = len(s) lo, ...
f3dcae7a965e7df6a7dda58d4b9fe69efb963cee
BrucePorras/PachaQTecMayo2020-1
/Semana3Sesion2/rpineda/listas.py
1,137
3.84375
4
<<<<<<< HEAD #Diccionario dicnuevo ={ "clave1":1, "clave2":"string", "clave3":1.44, "clave4": True } print (dicnuevo) ======= #string "hola mundo" #int 12 #float 13.66 #bool True False #list lstEnteros = [1,2,3,4,5,6] ["uno","dos","tres","cuatro"] [12.4,14.5,16.7] [True,True,False] [1,"uno",12.6,True...
c5fa975c65986accfbbe3129c823fa3952babdc5
LRieger13/Python_Practice
/Python/Oceans.py
453
4
4
''' AUTHOR: Leah Rieger Oct 4th PROGRAM: Ocean Levels ''' #Ocean Levels # Constant for the rise per year. RISE_PER_YEAR = 1.8 # Declare a variable to store the rise. rise = 0.0 # Calculate and print value for the rise each year. print ('Year\t\tRise (in millimeters)') print ('----------------------------------------...
592738bb185cb212cc664dda4c3705f2a2d623a3
NamJinWoo/BaekJoonAlgorithm_Python
/Baekjoon_2164.py
215
3.515625
4
import collections card_num = int(input()) card_deque = collections.deque([i for i in range(1, card_num +1)]) while len(card_deque) != 1: card_deque.popleft() card_deque.rotate(-1) print(card_deque[0])
03dcf7aa2fde70491cb6bce5b8e798311daa7f4c
davidsmiles/filesandsqlite
/milestone2/db/sql_db.py
1,335
3.796875
4
from typing import List, Dict, Union from .db_conn import DatabaseConnection """ Concerned with storing and retrieving books from a csv file Format of the csv file: name,author,read """ Book = Dict[str, Union[str, int]] def create_book_tables(): with DatabaseConnection() as connection: cursor = connect...
fef503d132ce8c5738ba7a5661ec80b080e6a261
robinyms78/My-Portfolio
/Exercises/Python/Learning Python_5th Edition/Chapter 9_Tuples, Files & Everything Else/Examples/Tuples in Action/Example1/Example1/Example1.py
134
3.6875
4
# Concatenation print((1, 2) + (3, 4)) # Repetition print((1, 2) * 4) # Indexing, slicing T = (1, 2, 3, 4) print(T[0], T[1:3])
ac575c068c54ec4d056432938bf7ea4384cf03aa
Igoren007/CODEWARS
/ticket.py
890
3.671875
4
def tickets(people): vas_mon = [] for item in people: if item == 25: vas_mon.append(item) if item == 50: if 25 in vas_mon: vas_mon.append(item) vas_mon.remove(25) else: return 'NO' if item == 100: ...
2147a7b0a57875abf6af6d64de520b86b5cfe4af
ahmedjyusuf/automation
/rename_files.py
581
3.875
4
import os count = 0 #folder containing the files os.chdir(f'/Users/ahmedyusuf/Test/') for f in os.listdir(): # the if statement is for text files only. if you need to rename all files in the directory # remove the if statement or specify the file type you want to rename if f.endswith(".txt"): ...
247b21e99a170f6eded597bfa5721e0393ed6b0f
arvind-mocha/Python-Basics
/polymorphism/method_overloading_overrinding.py
410
4.15625
4
#there is no method overloading concept in python we cant have functions with same name is same class #method overriding class a: def mybike(self): print("i have duke") class b(a): #class b inherits a so b contains two mybike function def mybike(self): print("i have bu...
b9ec4b30293e279dc7e67171132e08160cdac577
mmcheng93/common_interview_questions
/fibonacci_sequence.py
663
4.25
4
def fibonacci(n): """Function for nth Fibonacci number.""" a = 0 b = 1 if n == 1: # First number in the Fibonacci Sequence is 0 return a elif n == 2: # Second number in the Fibonacci Sequence is 1 return b else: for i in range(2,n): #Fibonacci Sequence is F(n) = F(n-1) + ...
c61ed246862d20e8477edb14a8be789c7041ce4c
jakub-wtorek-uek/pp1
/02-types_and_variables/after_class/e16.py
647
3.96875
4
# 16. Evaluate the following expressions. # a. The product of 15 and 38 # b. The product of the sum of the pairs of numbers 3 and 4, and 5 and 9 # c. Integer part of dividing the numbers 7 and 2 # d. The remainder of the division of 48 and 5 # e. Arithmetic mean of the numbers 8, 7, 4, 2 # f. 210 # g. Square root of 49...
c5be5f274770f5474014b93ba54721ace9133f17
JasonFaas/pythonhelloworld2
/src/edx/intro_to_cs/week5/coordinate.py
881
4.09375
4
class Coordinate(object): def __init__(self, x, y): self.x = x self.y = y def getX(self): # Getter method for a Coordinate object's x coordinate. # Getter methods are better practice than just accessing an attribute directly return self.x def getY(self): # ...
7c44af62eacceb433638ffb51c98f1fa7424837a
carleton-cs257-fall-2018/assignments-mydan123
/using-apis/api-test.py
1,440
3.71875
4
#!/usr/bin/env python3 ''' api-test.py Daniel Busis 10/1/18 ''' import sys import json import urllib.request def main(): base_url = 'https://data.cdc.gov/resource/u4d7-xz8k.json?cause_name=Stroke&state=Minnesota' if len(sys.argv) > 1: base_url += "&year="+sys.argv[1] data_from_server ...
4d14cf87f23de3daa882bb53b7c7b68c4c055cf6
kevinsung123/Python
/boj/sorted.py
73
3.546875
4
arr=[1,2,3,4,5,6,7] print(sorted(arr)) print(sorted(arr,reverse=True))
1be058955040e037aa16dbcc2ea7e5e75443ac14
mithlesh4257/Molecular-Dynamics
/call_gaussian.py
1,681
3.546875
4
# This code calls the gaussian software... # 1. make the input file for gaussian.. # 2. script the gaussian calling code.. # 3. take the input from the gaussian # 4. pass the output to main.f90 from periodicTable import * import pandas as pd import json import numpy as np import os # load the data set of the molec...
662dd1a8b49e5083e6fd26fbffc511a45191284e
developeryuldashev/python-core
/python core/Lesson_9/list_30.py
168
3.71875
4
a=[1,6,5,3,4,5] sanoq=0 for i in range(len(a)-1): if a[i]>a[i+1]: print(i) sanoq+=1 print("o'ng tomondagi elementdan katta elentlar soni=:",sanoq)
93dc0a880bf9d61481d40f0e9f49e7e2e034d8d2
cg342/iWriter
/start.py
1,728
4.21875
4
''' https://hashedin.com/blog/how-to-convert-different-language-audio-to-text-using-python/ Step 1: Import speech_recognition as speechRecognition. #import library Step 2: speechRecognition.Recognizer() # Initializing recognizer class in order to recognize the speech. We are using google speech recognition. Step 3: ...
3d40393d8c95908c961fd5b716980032a7aae5e2
GH-Jo/HMQ_practice
/common/single_best.py
596
3.890625
4
class IsBest(object): def __init__(self): """ This class check if a given value is the best so far """ self.val = None def is_best(self, val) -> bool: """ This function returns the status of the current value and update the best value. :param val: The cur...
0934089ee033e868f7ebdf3b9a4528f6059d2cb0
karthikvijay5227/Basic-Programming
/Vowel Remover.py
172
4.09375
4
name=input("Enter the name:") vowels=["a","A","E","e","i","I","O","o","U","u"] for i in name: if i in vowels: name=name.replace(i,"") print(name)
0f76e52ee00aa117f90999e9d48c15ad24fcd3fe
BillyCussen/CodingPractice
/Python/Data Structures & Algorithms Module - Python/Week6/LinkedStack.py
3,804
3.890625
4
""" LinkedStack.py Billy Cussen 16/11/2020 """ class Node: def __init__(self, element, next): self.element = element self.next = next class LinkedStack: def __init__(self): self.first = None def isEmpty(self): return self.first == None def getSize(self): retur...
a403bef7be7334a9681c6abf8a7eb733f81842ba
ELC/frro-soporte-2019-04
/practico_01/ejercicio-04.py
448
3.515625
4
# Implementar la función conversor, que ingrese desde la consola grados Celsius # y los devuelva transformados a Fahrenheit. def is_vocal(char): return char.lower() in 'aeiou' # Testing # Classical def test_vowel(): assert is_vocal('a') is True assert is_vocal('e') is True assert is_vocal('i') is T...
763718e20464e1c3060e5a21df7eeccbcbfa30b9
omaralhariri/lpthw
/ex16-newf.py
836
3.96875
4
question = input("Wanna create a new file? (Yes or No) ") question = str.lower(question) if question[0] == "y": filename = input("Write the name of the file...\n") filename = filename + ".txt" # Just to turn it a text file newFile = open(filename, 'x') # Create a new file and open for writing fileConte...
a2265c933d1c0bda887af69d63b2e4b45f80d045
dbaroli/holbertonschool-machine_learning
/supervised_learning/0x0F-word_embeddings/2-word2vec.py
1,332
3.546875
4
#!/usr/bin/env python3 """word2vec technique""" import gensim def word2vec_model(sentences, size=100, min_count=5, window=5, negative=5, cbow=True, iterations=5, seed=0, workers=1): """ word2vec using gensim Args: sentences: list of sentences to be trained on...
6a985bf47c80a41aaa4d4b90a83dfcb802b2cc5a
AkankshaRakeshJain/CodeChef
/FLOW007_ ReverseTheNumber.py
249
3.734375
4
user = int(input()) for _ in range(user): number = int(input()) reverse = 0 first = 1 while number > 0: first = number % 10 reverse = reverse*10 + first number = number // 10 number = 0 print(reverse)
e2348215e5dc5e714ea2f7df1295cbaf95703e07
MortyTheMage/mortythemage
/media/changecalc.py
1,434
3.890625
4
#! /usr/bin/python # change calculator from decimal import * def menuChoice0(): getcontext().prec = 2 valid = [1,2] choice = ['Would you like to start over?', 'Sorry, I didn\'t catch that. Try again.', '1: Yes', '2: No', 'How much did the item cost?', 'How much money did you hand over?', ...
59396946a33e689e574f1e6e7b1c2de50500f830
clairejrlin/stanCode_projects
/stanCode_Projects/my_photoshop/mirror_lake.py
1,309
3.71875
4
""" File: mirror_lake.py ---------------------------------- This file reads in mt-rainier.jpg and makes a new image that creates a mirror lake vibe by placing an inverse image of mt-rainier.jpg below the original one. """ from simpleimage import SimpleImage def main(): """ TODO: to make a new image the create...
c3d902d88c6c2795c27aa957a4b42efdf4237b4d
madebr/ncurses_programs
/python/JustForFun/queens.py
3,272
3.90625
4
#!/usr/bin/env python import curses import sys QUEEN_CHAR = "*" def main(): if len(sys.argv) != 2: sys.stderr.write("Usage: {} <number of queens (chess board order)>\n".format(sys.argv[0])) sys.exit(1) try: num_queens = int(sys.argv[1]) except ValueError: sys.stderr("In...
e2517359e9f2179994f6e62ca1a5a20bfc10cdaf
gmccreight/omnigrok
/data_structures/linked_list/linked_list_py/code.py
898
4.0625
4
class node: def __init__(self): self.data = None # contains the data self.next = None # contains the reference to the next node class linked_list: def __init__(self): self.cur_node = None def add_node(self, data): new_node = node() # create a new node new_node.data ...
08d55bfe840d8427d1e54c8722756c85c750b291
BohdanPolulikh/ThirdLab
/words_game.py
3,480
4.1875
4
import codecs import re from collections import Counter def get_words_from_file(file_path): file = codecs.open(file_path, 'r', 'utf8') words = file.read().lower() file.close() return words.split() def create_base(pattern, old_base): result_base = [] for word in old_base: ...
f890818365a32e9571c41728eade50a3e1731161
Renwoxin/Python
/Python/Python_code/07_语法进阶/hg_01_引用.py
751
3.671875
4
def test(num): print("在函数内部 %d 对应的内存地址是%d " %(num,id(num))) # >1 定义一个字符串变量 result = "hello" print("函数要返回数据的内存地址是%d" % id(result)) # >2 将字符串变量返回,函数返回的是数据的引用,而不是数据本身 return result # 1.定义一个数字的变量 a = 10 # 数据的地址本质上就是一个数字 print("a变量保存数据的内存地址是%d" %id(a)) # 2.调用test函数,本质上传递的是实参保存数据的引用,而不是实参保存的数据! # 注意:如...
6f425dcd63413ed33b4d1130a5eb4b51dae599dd
YonatanQuintero/ComputerScience
/PracticeCounting.py
581
3.71875
4
from itertools import product #Question #What is the number of non-negative integers with at most four digits at least one of which is equal to 7? #Answer 10^4 - 9^4 = 3439 count = 0 for d in product(range(10), repeat= 4): if 7 in d: count += 1 print(count) print(10**4 - 9**4) #Question #What is the num...
77326a5b4cd05b23628e99ac943759676b1916c9
inderpal2406/python
/udemy/02_walkthrough/08_add_two_numbers.py
336
4.34375
4
#!/usr/bin/env python3 # This script will add 2 numbers # The 2 numbers will be taken as user input # The 2 numbers can be of int or float data types print() # print a blank line num1=eval(input("Enter first number: ")) num2=eval(input("Enter second number: ")) sum=num1+num2 print(f"\nThe sum of {num1} and {num2}...
8dc155abb1cd32b06789a8ab4b45cd1e54128318
DimaDanilov/algoritm-programming
/2 Tasks/3 two numbers/leet_add_two_numbers.py
2,837
3.796875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: arr1 = self.traverseToArr(l1) arr2 = self.traverse...
8a04060ffb6264bfe33521233317d3760c8ff57c
Sengxian/cogdl
/cogdl/trainers/base_trainer.py
319
3.5
4
from abc import ABC, abstractmethod from argparse import ArgumentParser class BaseTrainer(ABC): @classmethod @abstractmethod def build_trainer_from_args(cls, args): """Build a new trainer instance.""" raise NotImplementedError("Trainers must implement the build_trainer_from_args method")
54f9bf37fd5fb39f19c8fb05080a0d57e599987d
arcaputo3/algorithms
/EPI/time_angle.py
715
4.03125
4
def time_angle(time): """ Returns the angle between the minute hand and hour hand. Args: time: str represented as 'HH:MM:SS' Returns: Angle between minute hand and hour hand. """ # Get each time measurement time = time.split(':') hr, min, sec = time[0], int(time[1]), int(ti...
8a72483d44d495f4f0a35a7527bd5f766e985d98
j30393/NTHU_PYTHON_PYMONEY
/week5~8.py
2,973
3.734375
4
import sys import os.path exist = 0 valid = 1 row_list = [] def initialize(): try: open('record.txt') return 1 except: return 0 exist = initialize(); if(exist): cur = 0 with open('record.txt' , 'r') as fh: for thing in fh.readlines(): if(cur == 1): ...
3941b63f2cd9f1a6c7fe4d61353d07271dcf69b2
Ssidss/leet
/hash/WordPattern290.py
785
3.953125
4
""" 290. Word Pattern Easy Favorite Share Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str. """ class Solution: def wordPattern(self, pattern: str, str: str) -> bool: ...
c284668c066f9364307f176ff71a63200cd288c5
alokkjnu/PythonBasicPrograms
/2 FlowControls and Loops/PassStatement.py
99
3.921875
4
a = 5 while a: print(a) a = a-1 if a ==2: pass print("remaining statement")
b642b1365fd570428d1a621d9c8283c260c0ab71
LarisaOvchinnikova/python_codewars
/Complementary DNA.py
391
3.6875
4
https://www.codewars.com/kata/554e4a2f232cdd87d9000038 # def DNA_strand(dna): # return dna.replace("A", "t")\ # .replace("T", "a")\ # .replace("C", "g")\ # .replace("G", "c").upper() def DNA_strand(dna): dct = { "A": "T", "T": "A", "C": "G", ...
5b6f31bcd3981bce2e4889bf06c2556d7ac1527b
xim9160/2018-Read-Record
/Content/Compiler Interpreter/ECHO_LANG/AST.py
1,655
3.6875
4
class AST(object): pass class Program(AST): def __init__(self): self.statements = [] # while block declaration class WhileBlock(AST): def __init__(self,condtion_node, block_node): self.condition = condtion_node self.block = block_node # if-else condition declaration class CondBloc...
f92443dc59f296ed7f7380219b306eba3faf25a6
gaoxy123/Python001-class01
/week07/my_zoo.py
2,994
4.21875
4
''' 背景:在使用 Python 进行《我是动物饲养员》这个游戏的开发过程中,有一个代码片段要求定义动物园、动物、猫三个类。 这个类可以使用如下形式为动物园增加一只猫: 复制代码 if __name__ == '__main__': # 实例化动物园 z = Zoo('时间动物园') # 实例化一只猫,属性包括名字、类型、体型、性格 cat1 = Cat('大花猫 1', '食肉', '小', '温顺') # 增加一只猫到动物园 z.add_animal(cat1) # 动物园是否有猫这种动物 have_cat = getattr(z, 'Cat') 具体要求:...
ebc27467b2216f9d16abaeec9c91593449efd6a1
ovr1/my-Git-
/Lessons/Lesson3/test3.py
488
3.828125
4
cycles = ["утро", "день", "вечер", "ночь"] i = 0 while i < len(cycles): print(cycles[i]) i = i + 1 print('\n') cycles = ["утро", "день", "вечер", "ночь"] for i in range(len(cycles)): print(cycles[i]) print('\n') for i in range(5): print(i) print('\n') for i in range(10, 15): print(i) print('\n') fo...
96f402a06167ecf33eeb33364ca69d6bd662e82c
Esteban0122/Python
/clase8/objetos.py
3,994
4.46875
4
# Es un paradigma que trata de imitar el comportamiento del mundo real. # Clase: es un modelo, molde o plantilla. # Ejemplar de Clase, Objeto o Instancia: es una clase en particular # con caracteristicas y funciones(metodos). # Modularizacion: Es cuando se pueden separar varias clases de manera # independiente. # Cl...
639441f4af38f79d2baff694d94c8d642daca361
brrgi/Algorithms
/프로그래머스/2021 카카오 블라인드/지영/problem01.py
784
3.5
4
pos = set({'-', '_', '.'}) def solution(new_id): new_id = new_id.lower() # 2단계 answer = '' for word in new_id: if word.isalnum() or word in pos: answer += word # 3단계 while '..' in answer: answer = answer.replace('..', '.') # 4단계 if answer and answer[0] ==...
a9ee5e97bf566b16fef3707f91e8a44d234f827b
tbille/INF4215
/TP1/LOCAL/piece.py
2,331
3.546875
4
class Piece(): counter=0 def __init__(self, _piece): print "Creating piece" Piece.counter+=1 self.id = Piece.counter _piece = map(lambda s : self.replaceStar(s) , _piece) self.piece=[_piece] self.cost = self.getCost(self.piece) self.genererListeRotation() self.placed = Fa...
c8210742dd781533a06a725181ae1f540b678971
kylegit1999/palindrome
/PALINDROME.py
371
4.46875
4
# Python Program to Check a Given String is Palindrome or Not def is_palindrome(s): if len(s) < 1: return True else: if s[0] == s[-1]: return is_palindrome(s[1:-1]) else: return False a=(input("Enter string:")) if is_palindrome(a): print("String is a palindrom...
601cf4f7ace7280921609bc0a317f23d4da7248e
camilaffonseca/Learning_Python
/Prática/ex063.py
1,216
3.609375
4
# coding: utf-8 ''' Crie uma tupla preenchida com os 20 primeiros colocados da Tabela do Campeonato Brasileiro de Futebol, na ordem de colocação. Depois mostre: a) Os 5 primeiros times. b) Os últimos 4 colocados. c) Times em ordem alfabética. d) Em que posição está o time do Grêmio. ''' times_brasileirão = ('Atlético...
3eff9b4348babfa24ec6ed467fdf208c1f0165e8
zahraamoradi/A_Z
/q.py
662
3.59375
4
n = 6 s = n for i in range(n): for j in range(n): if i == 0 and j == 0: print(' ', end='') elif i == 0 and j == n-1: print('*', end='') elif j == 0 and i == n - 1: print(' ', end='') elif j == n - 1 and i == n - 1: print('*', end='') ...
e2cb7d9786860d166ffb38b34b2a6b05bca0dc98
Pwojton/python
/Calculator/main.py
2,995
3.609375
4
import tkinter import tkinter.messagebox root = tkinter.Tk() root.title('Calculator') def entry_number_1(): calculator_entry.insert(tkinter.END, 1) def entry_number_2(): calculator_entry.insert(tkinter.END, 2) def entry_number_3(): calculator_entry.insert(tkinter.END, 3) def entry_number_4(): c...
552985bd28ff429772eaebad5cabce4e1dfdeda0
m4gicpur22/yelpcamp
/Documents/COP4020/Python/PythonHm/PsyAssign1.py
1,507
4.1875
4
#Affner Lefevre #COP 4020 #2/24/2019 import sys import re import importlib #make a list of words that have more than three letters #begin with a vowel or contain any letters from 2nd string #compares first string with chars in 2nd string def word_smith(string1, string2): removeSymbs = re.sub(r'[?|$|.|!]',r'',string...
f04d247e64703875e8b3fd5d2e713ff4d3cccd88
SamiaAitAyadGoncalves/codewars-1
/Python/7kyu/Leap Years.py
700
4.125
4
# https://www.codewars.com/kata/526c7363236867513f0005ca # # In this kata you should simply determine, whether a given year is a leap year # or not. In case you don't know the rules, here they are: # # years divisible by 4 are leap years # but years divisible by 100 are no leap years # but years divisible b...