blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
aec7383d4c7b4c4c380efaba55fe787acae1112a
dsanti4/ejercicios
/p7.py
713
3.984375
4
abecedario=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'ñ', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] def cifracesar(texto,key): resultado="" for letra in texto: nueva_posicion=(abecedario.index(letra)+key) if (nueva_posicion>26): ...
585912974d36b0058ccff56583591e4a0804de55
waikei1917/PythonBeginnerTube
/T8For.py
132
3.9375
4
foods = ['bacon','tuna','ham','sausage','beef'] for f in foods: print(f); print(len(foods)) for f in foods[:2]: print(f);
75916fa9df82a04134e1482e97e640aed5cd0272
endup/python_basic
/基础/first/class.py
1,652
4.03125
4
class Employee: '所有员工的基类' empCount = 0 def __init__(self, name, salary): self.name = name self.salary = salary Employee.empCount += 1 def displayCount(self): print ("Total Employee %d" % Employee.empCount) def displayEmployee(self): print ("Name : ", self.name, ", Sa...
0cd02c33c25435381b93d626214a901f6ce62a65
IsraMejia/AnalisisNumerico
/c2-MetodoIterativo.py
1,499
4.03125
4
from math import factorial print("\n\n\t Calculando tipos de Errores para el numero de Euler\n") #valorReal = 2.71828 #Cuando sabemos el valor real lo podemos definir asi #eAprox = 1 # El primer termino de la sumatoria de Euler #eAprox = 1 + 1/1 # El Segundo termino de la sumatoria de Euler #eAprox = 1 + 1 + 0.5 # El...
2c2e495878d3a2ffdd81722f18674f74be9db125
schwinnzyx/pydev
/leetcoder/game_of_life/game_of_life.py
3,496
3.734375
4
""" @Schwinn Zhang Game Rules (source: LeetCode, https://leetcode.com/problems/game-of-life/) Any live cell with fewer than two live neighbors dies, as if caused by under-population. Any live cell with two or three live neighbors lives on to the next generation. Any live cell with more than three live neighbors dies,...
cb28f4fbb898518215ae8e02b7513f1e06564773
miyahara1005/miyahara1005_day02
/sample02.py
432
4.15625
4
# データ型によって演算の結果が変わる話(データ型のはたらき) print(3 + 4) print('baseball' + 'succer') #文字同士の連結になる # * print(3 * 4) print('ピザ'* 5) #ピザピザピザピザピザ print('テーブルテニス' - 'テニス') #TypeError: unsupported operand type(s) for -: 'str' and 'str' print('3' + '野球') # TypeError: unsupported operand type(s) for -: 'str' and 'str'
9398961304892dd832efc9065823be3a3629bc56
dear-s/LeetCode-Solutions
/1379. Find a Corresponding Node of a Binary Tree in a Clone of That Tree.py
633
3.53125
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 getTargetCopy(self, original: TreeNode, cloned: TreeNode, target: TreeNode) -> TreeNode: self.dfs(cloned, target) ...
2124683384029d97fe1d774bf9d1c2bd33871eb0
sanaldavis/Anand-ch3
/4-6.py
401
3.515625
4
import urllib import sys import re def urlread(url): ufile=urllib.urlopen(url) f=ufile.info() text=ufile.read() #print text data=re.sub('<.*?>','',text) print data a=ufile.geturl() print a b=a.split('/') if b[-1]=='': urlprint('index.html',data) else: urlprint(b[-1],data) def urlprint(fn...
4548a869f50aec834a6d85d014f5a08ef44f2de4
noscetemet13/pp2_2021
/TSIS1/string/a.py
287
3.546875
4
a=input() print(a[2]) print(a[-2]) print(a[:5]) print(a[0:-2]) for i in range(len(a)): if i%2==0: print(a[i], end='') print() for i in range(len(a)): if i%2!=0: print(a[i], end='') print() print(a[::-1]) for i in range(len(a)-1, -1, -2): print(a[i], end='') print() print(len(a))
c56d821094ffeea0bc4a019221705dce57e7f1cb
PeterDrake/ShorttermStarryApplicationprogram
/main.py
468
3.78125
4
# Liz: Let's try an experiment in collaboration # Here's a function definition: def square(x): return x * x # Here's an invocation: print(square(4)) # Run it by clicking the "run" button at the top # Now can you try defining and invoking "cube" below this? # If this works, it could be fantastic for interactive l...
a563eab803ca3d18d044ddd199c011aa051861f5
zsXIaoYI/PythonDaily
/cn/zsza/DataType.py
485
3.65625
4
# __author__ = 'zs' # -*- coding: utf-8 -*- # @Time : 2017/7/6 12:05 # 字符串和元组是不可变的,而列表是可变(mutable)的,可以对它进行随意修改 # 我们可以将字符串和元组转换成一个列表,只需使用list函数 # 1、列表:用中括号表示(list) nums = [1, 2, 3, 4, 5] print('第一个元素:', nums[0]) print('最后一个元素:', nums[-1]) # 2、字符串(string) s = 'abcdef' print('字符串首个字母:', s[0]) # 3、元组
0c1f875deba901b074a9cf35740c584b8436916a
wxpwxpwxp/couple_leetcode
/problems/1-30/29-divide-two-integers/siri.py
444
3.78125
4
class Solution: def divide(self, dividend: int, divisor: int): less_than_0 = None if (dividend < 0 and divisor > 0) or (dividend > 0 and divisor < 0): less_than_0 = True dividend = abs(dividend) divisor = abs(divisor) result = -1 while dividend > 0: ...
558dfefbca7d86d9ce4488f6b2faa998ea6d3eab
labelexe/rdpchk
/crop.py
440
3.75
4
#Creates a copy image which crops the source image using numpy #Vincent Pham import cv2 as cv import numpy as np #Takes image from source and crops # pixel height def crop_image(source, height): img = cv.imread(source) h, w, c = img.shape img = img[h-height:h, 0:w] cv.imwrite('/opt/rdpchk/source_task...
34133c08dce77694da5b62e887ba2f4a7dc7a9b3
MCarlomagno/AlgoritmosGeneticos
/problema_mochila_exhaustivo.py
3,223
3.75
4
""""" encontrar subconjunto de la lista para el cual, el valor $ sea maximo y entre en la mochi tupla[0] = nro elemento tupla[1] = volumen tupla[2] = $ """"" VOL_MOCHILA = 4200 def calcula_valor(lista_elementos): acum = 0 for elem in lista_elementos: acum += elem[2] return acum def calcula_vol...
cc8326907ab34ac345680886e0367dabbec5cd62
vibhorsingh11/hackerrank-python
/05_Math/05_PowerModPower.py
276
4.1875
4
# You are given three integers: a, b, and m, respectively. Print two lines. # The first line should print the result of pow(a,b). The second line should print the result of pow(a,b,m). a = int(input()) b = int(input()) m = int(input()) print(pow(a, b)) print(pow(a, b, m))
2d5697d56a89c75de63af35f494163c9745d7a22
RodrigoSierraV/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/5-text_indentation.py
503
3.984375
4
#!/usr/bin/python3 """function that prints a text with 2 new lines after each\ of these characters: ., ? and : Args: text: string """ def text_indentation(text): """Raises: TypeError if text isn't string Return: Nothing """ if not isinstance(text, str): raise TypeError('text ...
f6126eb5394279178194dc25dd070397d92175b7
kayfour/learn_opencv
/image_processing/BitwiseOperations.py
1,067
3.703125
4
from cv2 import cv2 as cv img = cv.imread('datas/images/load_image.jpg') img2 = cv.imread('datas/images/opencv_logo.png') # cv.imshow('source image',img) # cv.imshow('logo',img2) # I want to put logo on top-left corner, So I create a ROI rows,cols,channels = img2.shape roi = img[0:rows, 0:cols ] cv.imshow('roi sourc...
49cbb409c05e2c88c86df46a02679a571d133ecd
furas/python-nbp
/nbp.py
6,505
3.640625
4
#!/usr/bin/env python3 ''' Getting data from http://api.nbp.pl/ ''' import urllib.request DEBUG = False '''Display request exception''' def get_tables(table='a', format_='json', today=False, date=None, last=None, from_date=None, to_date=None, show_url=False): ''' It gets tables from server a...
28588bce105b4238498cec3f612fda3164a93cb0
faris-shi/python_practice
/trick_dict.py
321
3.6875
4
from functools import reduce # what is the output of the following code? numbers = {} #dictory key must be immutable. In this case, tuple can be the key due to immutable feature. numbers[(1,3,5)] = 2 numbers[(3,2,1)] = 6 numbers[(1,3)] = 10 sum = reduce(lambda x, y: x + y, numbers.values()) print(len(numbers) + sum...
9daadf42df18835b97b92b20344e27b9aa47783d
Udit107710/CompetitiveCoding
/Skiena/Data Structures/3.2/solution.py
1,091
3.984375
4
class Node(object): def __init__(self, val): super().__init__() self.val = val self.next = None class LinkedList(object): def __init__(self, val): super().__init__() self.head = Node(val) self.tail = self.head def add_node(self, val): head = self...
cc1c5e9fdff8d1116d42b89ccb1795108d57d86e
nikutopian/pythonprojects
/G/ValidWordAbbr.py
1,307
3.59375
4
from collections import Counter class ValidWordAbbr(object): def __get_abbr(self, word): abbr = word if len(word) >= 3: abbr = '{0}{1}{2}'.format(word[0], len(word), word[-1]) return abbr def __init__(self, dictionary): """ :type dictionary: List[str] ...
97cf1d6549d1e0798fd9969f71e3c99e53902adb
sebutz/java-to-python-in-100-steps
/python-code/oops/newshit/tuples_play.py
698
4
4
def play_here(): return "Boom", 123, 23.0 some_tuple = play_here() print(some_tuple) # ('Boom', 123, 23, 0) print(type(some_tuple)) # tuple # multiple assignments : unpack a tuple x, y, z = play_here() print(x);print(y);print(z) ''' Boom 123 23.0 ''' # tuples got index print(some_tuple[0]) # Boom # tuple...
8a7c6c1ad2fb2710e5b9b68e7bf55bca4aaf638f
atulmhndrkr/oops
/map-list.py
743
3.859375
4
lloyd = { "name": "Lloyd", "homework": [90.0, 97.0, 75.0, 92.0], "quizzes": [88.0, 40.0, 94.0], "tests": [75.0, 90.0] } alice = { "name": "Alice", "homework": [100.0, 92.0, 98.0, 100.0], "quizzes": [82.0, 83.0, 91.0], "tests": [89.0, 97.0] } tyler = { "name": "Tyler", "homework":...
0cdbfffe800e1ecb26c54a6441bcf3e7f0a61ba2
cclaude42/python_bootcamp
/day03/ex00/NumPyCreator.py
1,714
3.515625
4
import numpy as np import collections class NumPyCreator(): """NumPyCreator class""" def _from_type(self, obj, otype): """Creates np array from simple type or nested type""" np.warnings.filterwarnings('ignore', category=np.VisibleDeprecationWarning) # Check type if not isinstanc...
502313f851be3ef52a2ed1daa622ccd7da4b2e52
jakubpulaczewski/codewars
/6-kyu/1-array.py
770
3.9375
4
""" +1Array The link: https://www.codewars.com/kata/5514e5b77e6b2f38e0000ca9 Problem Description: Given an array of integers of any length, return an array that has 1 added to the value represented by the array. - the array can't be empty - only non-negative, single digit integers are allowed Return nil (or your lan...
5f2d44612be48288dd804a9f3747c826a19d00fc
thiagosouzalink/my_codes-exercices-book-curso_intensivo_de_python
/Capitulo_07/exercise7_8.py
785
4.125
4
""" 7.8 – Lanchonete: Crie uma lista chamada sandwich_orders e a preencha com os nomes de vários sanduíches. Em seguida, crie uma lista vazia chamada finished_sandwiches. Percorra a lista de pedidos de sanduíches com um laço e mostre uma mensagem para cada pedido, por exemplo, Preparei seu sanduíche de atum. À medida q...
1f198ee60b1e4ee160c683ac5c21eae24d730e26
ProfNimnul/minesweeper
/saper.py
318
3.546875
4
import random from array import array x = input("x=") y = input("y=") print(x, y) baseX = int(x) + 1 baseY = int(y) + 1 t = [0 for i in range(0, baseX)] cells = array('I', t) print(cells[2]) random.seed() for i in range(0, baseX): for j in range(0, baseY): cells[i][j] = 0 # mine = random.randint(0, 1)
a0fd3fb14b95e91d3c5a0ebfb9e82e2e1cb2d861
SarahOsamaTalaat/Artificial-Neural-Networks-and-Deep-Learning-
/Labs/Lab 6 (Hebb Algorithm)/Hebb_weights_matrix_algorithm.py
3,193
4.1875
4
# -*- coding: utf-8 -*- """ Created on Mon Apr 2 21:15:56 2019 In this code, I implement Hebb Neural Network using alternative method: Weights_Matrix the inputSize,outputSize parameters contain the number of neurons in the input and output layers. So, for example, if we want to create a NN object with 5 n...
5f318305f00562124ca29597a49d6eba9f6970cd
thepros847/python_programiing
/lessons/floats.py
168
3.828125
4
x = float(1) # x will be 1.0 y = float(2.8) # y will be 2.8 z = float("3") # z will be 3.0 w = float("4.2") # w will be 4.2 print(x) print(y) print(z) print(w)
c1c4186038401993b164cdd2b1a40cbd785820a4
iamrishap/PythonBits
/InterviewBits/greedy/bulbs.py
1,807
4.25
4
""" N light bulbs are connected by a wire. Each bulb has a switch associated with it, however due to faulty wiring, a switch also changes the state of all the bulbs to the right of current bulb. Given an initial state of all bulbs, find the minimum number of switches you have to press to turn on all the bulbs. You can ...
65d59800af407eba919be70ec766174543c8db50
SirAnirudh/Minimax_Algorithm
/Computer strategies/a2_playstyle.py
10,070
3.703125
4
from typing import Any, List import random from stack import Stack class Playstyle: """ The Playstyle superclass. is_manual - Whether the class is a manual Playstyle or not. battle_queue - The BattleQueue corresponding to the game this Playstyle is being used in. """ is_manu...
313fa6f584dfe0dc8892ce4df931cde5f1052a31
vzpd/myBrushRecord
/exercise/每日一题_最佳买卖股票时机含冷冻期.py
1,916
3.71875
4
""" 给定一个整数数组,其中第 i 个元素代表了第 i 天的股票价格 。​ 设计一个算法计算出最大利润。在满足以下约束条件下,你可以尽可能地完成更多的交易(多次买卖一支股票): 你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。 卖出股票后,你无法在第二天买入股票 (即冷冻期为 1 天)。 示例: 输入: [1,2,3,0,2] 输出: 3 解释: 对应的交易状态为: [买入, 卖出, 冷冻期, 买入, 卖出] """ from typing import List """ 动态规划 第x天赚的钱为,昨天手里没有股票时的钱 和 今天卖掉昨天持有的股票时赚的钱 中比较大的那个 第x天手里持有股票时的钱为,前天卖...
1e557848e378d4202da8b978c8ce2d929dc60584
asmit222/Leet-Code-Problems
/organize.py
1,842
3.53125
4
import os dire = "/Users/stephengiardina/Desktop/Personal Projects/Leet-Code-Problems" files = sorted(os.listdir(dire)) directoriesToEdit = [] for i in range(len(files)): if '.' not in files[i]: # files[i] is changed to an int so that the array gets sorted properly. directoriesToEdit.append(int(files[i]))...
36cae1125ee24999d34aafeb6494f878d416db4a
JerinPaulS/Python-Programs
/ThirdHighestNumber.py
1,012
4.28125
4
''' Given integer array nums, return the third maximum number in this array. If the third maximum does not exist, return the maximum number. Example 1: Input: nums = [3,2,1] Output: 1 Explanation: The third maximum is 1. Example 2: Input: nums = [1,2] Output: 2 Explanation: The third maximum does not exist, so th...
16ce2bf6c4b6123e0a73c58352f74a217b095503
libhide/RPSpython_oldSchool
/RPS.py
2,076
4.0625
4
from random import randint class Player: ''' Applies for both human and computer''' def __init__(self, operator): self.operator = operator self.winCounter = 0 self.choice = "playing" def bout(self): if self.operator == "computer": self.choice = myDi...
0da1479ffbe80e92db00026a2fc5b159c1baf8a6
JanDimarucut/cp1404practicals
/prac_04/extended_exercise_4.py
208
3.59375
4
# 4 def main(): list1 = [1, 2, 3] list2 = [4, 5, 6] add_memberwise(list1, list2) def add_memberwise(list1, list2): list3 = [(x + y) for x, y in zip(list1, list2)] print(list3) main()
b51e897068a61a757a7b410c2e1234628195ef89
Vinaypatil-Ev/DataStructure-and-Algorithms
/3.LinkedList/Python/single_linked_list.py
2,137
4.09375
4
class Node: def __init__(self, value): self.value = value self.next = None class LinkedList: def __init__(self): self.head = None def __len__(self): if self.head == None: return 0 i = 0 temp = self.head while temp != None: i +=...
ce3ff4ea26abf32f57d4f5de022b9afb701d59c1
cherinda30/Cherinda-Maharani_064001900032_Prak2Algo
/prak2 elkom 1.py
1,569
3.84375
4
#AlgoPrak2_Cherinda Maharani print (" /$$ /$$ /$$ ") print (" | $$ |__/ | $$ ") print (" /$$$$$$$| $$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$$$$$$ /$$$$$$$ /$$$$$$ ") print (" /$$_____/| $$__ $$ /...
2db7faca95a50ad022a423eef306daf7ed2f0fde
sirishsilpakar/eadd-creational-patterns
/login_factory.py
1,054
3.578125
4
from login.login_gateways import GoogleLogin, FacebookLogin, EmailLogin from abstract_factory import AbstractFactory class LoginFactory(AbstractFactory): """ This class contains the method that returns the objects of the login gateways defined. This allows for dynamic object creation by providing an interf...
39dca73ff788c9a946edc24f75a1528f60670386
akashgupta-ds/Python
/30. Data Type -None.py
265
4.15625
4
#-------------None Data Type-------------- # 'Nothing' is 'None' : No value is associated or NULL # If no value then method shows 'None' def f1(): a=10 f1=None def f2(): print('Hello Don''t be like none') f1() f2() f1=None print(f1)
2618519bd1c3634ad67b4b7a1193cb71a864c0dc
danielzhang1998/xiaojiayu_lesson_coding
/python/lessons_coding/lesson68_tk_v2.py
771
3.8125
4
from tkinter import * root = Tk() Label(root, text = 'Account: ').grid(row = 0, column = 0) Label(root, text = 'Password: ').grid(row = 1, column = 0) v1 = StringVar() v2 = StringVar() e1 = Entry(root, textvariable = v1) e2 = Entry(root, textvariable = v2, show = '*') # 作为 星号 显示 e1.grid(row = 0, column = 1, padx = ...
7e53a547f1675dcc046b4cc73b0fc22591e2f7b0
amallik-ualberta/LeetCode
/DP/Coin Change/coin_change.py
707
3.71875
4
def coin_change(coins, amount): length = len(coins) if (length == 0 or amount == 0): return 0 coins.sort() #sorting is only required to improve runtime for average case table = [] for i in range (amount+1): table.append(amount+1) table[0] = 0 for i in range(1, amount+1): for j in range (length...
c8cdc18f0147a37d3538b82c9e2699afa7569a3b
diable201/WEB-development
/Laboratory Works/Lab_7/Problems/Informatics/Arrays/69.py
143
3.65625
4
n = int(input()) num_list = list(int(num) for num in input().strip().split())[:n] num_list.reverse() print(' '.join(str(i) for i in num_list))
ba48d0c1c3b1dfbd2bb8774af806b5df9e7c3d36
cperez58/chem160module2
/chem160module2/rwalknd.py
543
3.546875
4
from random import choice dim=6 #specifies dimension for random walker test trials=1000 steps=10000 gothome=0 for i in range(trials): point=[0]*dim #multiply list by dimension present for step in range(steps): for j in range(dim): #loop over number of dimensions point[j]+=choice((-1,1)) #poi...
5e0da033d418571c4ee2a8b564489622f7683ce8
vamshigadde/Library
/library.py
2,265
3.84375
4
class Library(): def __init__(self,bl=None): self.bl=bl self.lenddict={} if(bl is None): self.bl=[] else: self.bl=bl def displaybooks(self): print(f"we have following books in our library") for book in self...
3672fc471b9e71048633b0f9cae0c12ae9c74380
Antohnio123/Python
/Practice/d.shamin/hw_4/hw_4.3.py
327
3.515625
4
#3. Реализовать алгоритм сортировки выбором. arr = [12, 0, 3, 600, 24, 2, 3, 7, 43] lng = len(arr) new_arr = [] for k in range(lng): i = 0 for j in arr: if min(arr) == j: arr.pop(i) new_arr.append(j) break i += 1 print(new_arr)
b552b01b04dc3c2ea6f41852fcadfa6ab6dce7ad
Nobody0321/MyCodes
/OJ/LeetCode/92. Reverse Linked List II.py
407
3.734375
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def reverseBetween(self, head, m, n): h = ListNode(0) h.next = head pre = h for i in range(m-1): pre = pre.next # pre 现在指...
64ad2a7e43d87df886242505c6a3e00aae3bf80e
Code-Wen/LeetCode_Notes
/96.unique-binary-search-trees.py
1,049
3.546875
4
# # @lc app=leetcode id=96 lang=python3 # # [96] Unique Binary Search Trees # # https://leetcode.com/problems/unique-binary-search-trees/description/ # # algorithms # Medium (50.94%) # Likes: 3252 # Dislikes: 118 # Total Accepted: 292K # Total Submissions: 562.4K # Testcase Example: '3' # # Given n, how many str...
cbcdef796316faabc6898f07818a98302a477c1a
janinemartinez/calculator-2
/arithmetic.py
1,047
4.15625
4
"""Math functions for calculator.""" def add(num1, num2): """Return the sum of the two inputs.""" x = num1 + num2 return x def subtract(num1, num2): """Return the second number subtracted from the first.""" x = num1 - num2 return x def multiply(num1, num2): """Multiply the two inputs to...
f9ea931e5205c4f937141c12c208be747eb81ea3
GabrielSuzuki/Daily-Interview-Question
/2021-01-23-Interview.py
2,183
4.09375
4
#Hi, here's your problem today. This problem was recently asked by Uber: #Design a simple stack that supports push, pop, top, and retrieving the minimum element in constant time. #push(x) -- Push element x onto stack. #pop() -- Removes the element on top of the stack. #top() -- Get the top element. #getMin() -- Retri...
b06e1d475787079351ea1d066d22373134a815ef
Akash1684/NLTK-Head_Start
/Tokenize.py
693
3.828125
4
from nltk.tokenize import sent_tokenize, word_tokenize article = "Natural language processing (NLP) is a field of computer science, artificial intelligence, and computational linguistics concerned with the interactions between computers and human (natural) languages. As such, NLP is related to the area of human–compu...
40dfd579eef0deb228b0ad4834e9e20f7857d22e
qtsunami/UniPythonStudy
/04-functional/03-sorted.py
898
4.40625
4
#!/bin/python3 """ sorted: Python 内置函数 """ # 对list进行排序 L = [36, 5, -12, 9, -21] print(sorted(L)) # 同时sorted也是一个高阶函数,它还可以接收一个key函数来实现自定义排序 # 按绝对值大小来排序 print(sorted(L, key=abs)) # 以上是对数字进行排序,下面看下对字符串的排序 SL = ['a', 'b', 'z', 'X', 'm', 'y', 'J', 'V', 'N', 'j'] print(sorted(SL)) # 默认情况下,对字符串排序,是按照ASCII的大小比较的 # 同样,传入ke...
9fff4c18bc8155c154c3db971e3ab40ad0eda8f7
lilycoco/Python_study
/note/basic/dictionary.py
271
3.671875
4
# 辞書型はkey-valueで値を保持する # Create user_dict = { "Yohei": 30, "John": 35 } # Get user_dict["Yohei"] user_dict.get("Nao", 20) # Update / Delete user_dict["Yohei"] = 31 del user_dict["John"] # Get all for k, v in user_dict.items(): print(k, v)
c14bc227d1caffd70ad547d87e3904d416673947
Zmwang622/gae-webdev
/step04/gae-project/main.py
2,322
3.765625
4
import flask app = flask.Flask(__name__) operators = [ 'plus', 'minus', 'times', 'divided by', 'to the power of', ] MAIN_CONTENT = '''<html> <head> <title>Calculator Example</title> </head> <body> <header> <h1>Calculator</h1> </header> <sec...
08ed2c45c981bb9b09d92bf73dca3bbd28bb9765
srmcnutt/100DaysOfCode
/d7-hangman/main.py
1,728
4
4
from art import stages from word_list import word_list import logging logging.basicConfig( level = "WARNING" ) #Step 1 #TODO-1 - Randomly choose a word from the word_list and assign it to a variable called chosen_word. import random chosen_word = random.choice(word_list) hint_list = [] for letter in chosen_word...
92650c845797abf8517b9c39e0156cc61c249ec8
Melwyna/Algoritmos-Taller
/66.py
294
3.953125
4
n1=int(input("Ingresa un numero entero positivo:")) if n1>0: print("EL VALOR ES VALIDO:", n1) if n1<0: print ("EL NUMERO ES INCORRECTO, VUELVE A INGRESARLO, DEBE SER UN NUMERO ENTERO POSITIVO") n1=int(input("Ingresa un numero entero positivo:")) if n1>0: print("EL VALOR ES VALIDO:", n1)
5f94ebfba9118d5d40a433ca95bd696833ed8e92
tigreal/python
/fileOperationWithFoorLoop.py
122
3.6875
4
#leer un archivo de testo con un for loop f=open('myfile.txt','r') for lines in f: print(lines) f.close()
228ff1ba690469f57b066d8def3de435c7732c63
catalinc/codeeval-solutions
/src/python/longest_word.py
601
3.96875
4
import sys def longest_word(s): words = s.split(' ') return first_max(words, key=lambda w: len(w)) def first_max(iterable, key=None): item, max_value = None, None for x in iterable: if key: value = key(x) else: value = x if item is None or max_value < va...
4648e524afd356d69fdd8df04f2ff8df618d79a3
greenfox-zerda-lasers/tamasc
/week-03/day-3/11v2.py
646
3.90625
4
# Create a function that prints a diamond like this: # * # *** # ***** # ******* # ********* # *********** # ********* # ******* # ***** # *** # * # # It should take a number as parameter that describes how many lines the diamond has def pine(lines, direction=1, initial_space=0...
1cf05d8cd94306e93cdbd2f5c47adb4fa8f2f96b
CodecoolGlobal/lightweight-erp-python-fantastic-4
/accounting/accounting.py
6,001
3.640625
4
""" Accounting module Data table structure: * id (string): Unique and random generated identifier at least 2 special characters (except: ';'), 2 number, 2 lower and 2 upper case letters) * month (number): Month of the transaction * day (number): Day of the transaction * year (number): Year of t...
c7c948f139bd4ab21ba280115aedad1b3bb5815b
Spiritgyx/Technology-of-Programming
/crypt_choice/S_Z.py
1,489
3.703125
4
import string def main(): # Шифрование mode = input('Choice mode [E]ncrypt/[D]ecrypt: ') if mode.upper() != 'D': text = ''.join([i for i in input('Write text: ').lower() if i in string.ascii_lowercase+' ']) keys = { 'a': '!', 'b': '@', 'c': '#', 'd': '$', 'e': '%', ...
5760a91a94156beae373ca37e686db9dd75b3d12
shoaibrayeen/Python
/Bit Algorithms/powerOfTwo.py
208
4.03125
4
def powerOfTwo(x): if ( x & ( x - 1 )) == 0 : print( x, "is power of 2.") else: print( x, "is not power of 2.") powerOfTwo(14) powerOfTwo(8) powerOfTwo(2) powerOfTwo(1) powerOfTwo(9)
33d3c9390a0949a4dc36d3222207c1244189c9ce
ngladkoff/2020FDI
/EjercicioCajero.py
655
3.578125
4
# Ejercicio Cajero Automático # Entrada importeRetirar= int(input("Ingrese Importe a Retirar: ")) # Variables billetes100 = 0 billetes50 = 0 billetes10 = 0 billetes5 = 0 billetes1 = 0 # Proceso billetes100 = importeRetirar // 100 resto = importeRetirar % 100 billetes50 = resto // 50 resto = resto % 50 billetes10 = r...
3a53ed87af3757b8480769e9a5d57ee1ddefcac0
nikhilgiji/language-benchmarks
/python/go_board.py
13,991
3.6875
4
"""Go board implementation, based on the OpenSpiel implementation. This file is a straight translation of open_spiel/open_spiel/games/go/go_board.h, implementing the same algorithm and using the same datastructures. """ import enum import random from typing import Iterable, Text, Tuple import dataclasses Point = int...
67cfed4ce0bf24922c40d3a87cbe5a058d13922e
revsi/pacman-game
/game.py
3,280
3.5625
4
#!/usr/bin/python #This program is free software: you can redistribute it and/or modify #it under the terms of the IIIT General Public License as published by #the Free Software Foundation, either version 3 of the License, or #(at your option) any later version. #This program is distributed in the hope that it will be...
7730784d5e9706356012685b1094f683c1932cc9
abhinavsharma629/CODE2RACE
/OPEN CHALLENGE/newYearChaos.py
2,559
4.125
4
#!/bin/python3 """ file: newYearChaos.py author: Jay Welborn www.github.com/jaywelborn This is a solution to the New Year Chaos problem on hackerrank. Problem: https://www.hackerrank.com/challenges/new-year-chaos/problem Description: It's New Year's Day and everyone's in line for the Wonderland rollercoaster ride! Th...
aaf0c84d5fbdf0c4d65dc2da8db55b09b7cde071
treethree/LeetCode
/Python/Toeplitz_Matrix.py
1,595
3.96875
4
#Approach #1: Group by Category [Accepted] # Intuition and Algorithm # # We ask what feature makes two coordinates (r1, c1) and (r2, c2) belong to the same diagonal? # # It turns out two coordinates are on the same diagonal if and only if r1 - c1 == r2 - c2. # # This leads to the following idea: remember the value of t...
9dbfa9938c0972d2600605e13e18dacad706cd68
jloescher/COP-1000
/Chapter 5/Video Code/mileage.py
1,090
4.4375
4
##### gas_mileage.py # Finds and prints gas mileage after a trip # using a function. User enters gas used and # mileage data when program runs. ######### Pseudocode ########## # For main() # prompt user for odometer reading before trip, and # assign to variable start_miles. # prompt user for odometer reading after trip...
d4edf77fb1f10908d34fcbff9ad6d848c5ac9b65
helenbc/curso_python
/aula5.py
624
4.0625
4
#String - texto '' ou "" # + * #Concatenção # 01234 ... nome = 'Helen' sobrenome = 'Cavalcanti' #print(nome + sobrenome) #Repetição #print(nome * 3) #índice # 01234 ... # -1 nome2 = 'carol' i = 4 #print(nome2[i + 1]) #len - tamanho #print(len(nome2)) #fatiamento #print(nome2[:3]) #print(no...
30936e2fee018930e94313ccf616b0353cc17720
danielforero19/taller-30-de-abril
/ejercicio 2.py
141
3.96875
4
numero = int(input("ingresa un numero para elevarlo al cuadrado: ")) op = numero ** 2 print("el numero", numero,"elevado al cuadrado da", op)
1a6a230077e65df9f0ceca1130d2b73f28903ee4
daniel-reich/ubiquitous-fiesta
/LMoP4Jhpm9kx4WQ3a_3.py
323
3.578125
4
def is_ascending(s): lst = list(s) for n in range(1, len(lst)//2+1): groups = [int("".join(lst[i:i + n])) for i in range(0, len(lst), n)] if list(sorted(set(groups))) == groups and (groups[0] + groups[-1]) / 2 == sum(groups) / len(groups) and groups[0] == groups[1]-1: return True return Fals...
9ec708a52a65e7e34e58becd5d086f3297b67f1d
gokilaguna1998/Python-Programming
/index.py
225
3.5
4
g=int(input()) o=int(input()) li=[] a=[] for i in range(0,g): li.append(int(input())) for i in range(0,o): m=0 s=int(input()) p=int(input()) for i in range(s-1,p): m=m^li[i] a.append(m) print(a)
754dce5465f3a5f3dceb130fecbd685ba11fa39c
akiraboy/python_20191010
/basic_pgg/zad_11.py
896
3.890625
4
x = int(input("Podaj x: ")) y = int(input("Podaj y: ")) # if x >= 0 and x <= 10: # pass # if 0 <= x and x <= 10: # pass # if 90 <= x <= 100 and 90 <= y <= 100: # print("PGR") # ... if 0 <= x <= 10: if 0 <= y <= 10: print("lewy dolny rog") elif 10 < y < 90: print("lewy bok") el...
a3c327eacdfddf49ddaaff474414f2eaffae397c
brittany-morris/Bootcamp-Python-and-Bash-Scripts
/python/learndotlab/evenorodd.py
272
4.15625
4
#!/usr/bin/env python3 import sys list = sys.argv[1] with open(list, 'r') as f: for num in f: num = num.strip() value = int(num) if value % 2 == 0: print(num, True) # True means number is Even else: print(num, False) # False means number is Odd
05f089835a7d004dacd1d167eb2f900bda897de8
airrain/Algorithm-questions-and-answers
/LeetCode-python/ReverseInteger.py
657
3.859375
4
"""翻转一个intger类型的数字。 注意点: 注意末尾有0的情况不能直接当作字符串翻转 有正负两种情况 integer是32位整型,考虑溢出 例子: 输入: x=123 输出: 321 输入: x=-123 输出: -321 """ class Solution(object): def reverse(self,x): flag = 0 if x < 0: flag = -1 else: flag = 1 x *= flag result = 0 ...
d4c4eab2616dc610c995182a33d21e8a4279bebc
heecheol1508/algorithm-problem
/_baekjoon/1655_가운데를 말해요.py
532
3.703125
4
import sys sys.stdin = open('input.txt', 'r') def sorting(left, right, n): if left == right: nums.insert(left, n) return m = (left + right) // 2 if n > nums[m]: sorting(m + 1, right, n) elif n == nums[m]: nums.insert(m, n) else: sorting(left, m, n) r...
7c31e072279f2de5582f3393c269b8f781cdc30e
alenatorgasheva/books
/lc_eng.py
929
3.875
4
TXT_FIND_BOOK_BY = 'The book with {} {} is not found.' TXT_COUNT_BOOK_BY_YEAR = 'In {} {} books were published.' TXT_NO_INFORMATION = '''Data about the books published by "{}" in {} year have not been found.''' TXT_CHOOSE = 'Choose action from the list:' TXT_MENU = '\t1 - Print the full information about the book by id...
d775c7ad667dc3b54d5479e194d3e6c6e41ba340
Dyke-F/Udacity_DSA_Project3
/problem_6.py
574
3.96875
4
import math def get_min_max(ints): """ Return a tuple(min, max) out of list of unsorted integers. Args: ints(list): list of integers containing one or more integers """ min_val = math.inf max_val = -math.inf for i in ints: if i < min_val: min_val = i ...
8de3db19687c35ced4ca516354012071c6ee769a
omerfarukcelenk/PythonMaster
/17-Numpy/numpy-basics.py
361
3.625
4
import numpy as np # python list py_list = [1,2,3,4,5,6,7,8,9] # numpy array np_array = np.array([1,2,3,4,5,6,7,8,9]) print(type(py_list)) print(type(np_array)) py_multi = [[1,2,3],[4,5,6],[7,8,9]] np_multi = np_array.reshape(3,3) print(py_multi) print(np_multi) print(np_array.ndim) print(np_multi.ndim) print(np...
3c749be13f592e8f0d2365f461df099188ccf083
IIInvokeII/1st_sem_python
/Codes/6 - Dice Game(2P).py
483
3.90625
4
print("Welcome to the 2 player Dice Game!") name1=str(input("Enter Player 1 name: ")) name2=str(input("Enter Player 2 name: ")) print("Are you ready ???") print("Here we go!") import random s1=0 s2=0 for c in range(10): s1+=random.randint(1,6) s2+=random.randint(1,6) print(name1,"scored",s1) print(n...
d2a841e28c0c49d5af9cce14562179b6c0b7baba
mirzaakyuz/assignments
/inclass_0706.py
181
4.0625
4
age = input("please type your age: ") while not age.isdigit(): print("You entered in correctly!") age = input("Enter your age please: ") print("Your age is : ", age)
570f4838fdfc0f032fe2544f93a617e7309a3e03
rockdam/deep-learning-
/exam/count_1.py
334
3.609375
4
#coding:utf-8 """ 输入一个整数n,求从1到n这n个正数中,1出现的次数。例如:输入12,出现一的数字有1,10,11,12共有5个1,则输出5. """ def count_number_one(n): count = 0 for i in range(n+1): while i: if i % 10 == 1: count += 1 i = i/10 return count print(count_number_one(12))
a78474381e0927e438819b5f0c8a1c1c2d2124e1
saikiran-patro/APPLE-WATCH-PY-GRAPHICS-
/Apple watch.py
1,544
3.6875
4
##apple watch import turtle t=turtle.Turtle() b=turtle.Turtle() turtle.title("APPLE WATCH") def sq(length,radius,color,z): for i in range(4): z.fillcolor(color) z.forward(length) z.circle(radius,90) b.penup() b.right(90) b.forward(5) b.left(90) b.pe...
3a9119ac7011558585287de7dba9217095eb5102
lindongyuan/study2020
/project/9-4-test.py
1,844
3.875
4
''' #test 9-4 class Restaurant(): def __init__(self,restaurant_name,cuisine_type): #初始化属性restaurnt_name、cuisine_type self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type self.number_served = 0 def describe_restaurant(self): print(self.restaurant_name.t...
fcfa2125dee18ff5ab3996b95238bd6e3c384572
guidumasperes/testing-fundamentals
/selenium/selenium_other_form.py
936
3.609375
4
from selenium import webdriver import random #Get our browser driver = webdriver.Firefox() driver.get('https://www.seleniumeasy.com/test/basic-first-form-demo.html') #Get our elements input_a = driver.find_element_by_xpath('//*[@id="sum1"]') input_b = driver.find_element_by_xpath('//*[@id="sum2"]') #Generate random ...
82b13cbe90f53db140dea2b4c88708c84a454b28
asokolkova/itmo_python
/dz_1/task_1_5.py
733
4.0625
4
f=1 #будем вводить данные пока флаг не станет нулем while f!=0: x=int(input('Enter the first number: ')) y=int(input('Enter the second number: ')) op=input('Enter operation (+,-,*,/,//,%,**): ') k=1 #флаг, что была введена корректная операция if op=='+': z=x+y elif op=='-': z=x-y...
d2db6df73782c2334f3147112c7682a8e1a45864
henu-wcf/Python
/计蒜客A1004copy1.py
824
3.78125
4
# 前序遍历二叉树 # 算法:递归遍历 qianXu(root, kv) # 注意 根左右:左右是指左子树和右子树, # 对左子树再进行根左右直至结束,然后对右子树进行根左右直至结束 def main(): result = [] kv = {} line = input().split(" ") for li in line: newline = li.split("(") key = newline[1][0:3] value = newline[0] kv[key] = value root...
8afb1b7c7349ab00191871c348a97e862fffc06a
rafaelperazzo/programacao-web
/moodledata/vpl_data/303/usersdata/278/67968/submittedfiles/testes.py
117
3.578125
4
# -*- coding: utf-8 -*- #COMECE AQUI ABAIXO altura = float(input("Qual a sua altura?" )) print((72.7*altura) - 58)
7655a9ffcb720162eaa3222ded03254a096faee2
jcohut/driverlessai-recipes
/data/livecode/split_by_datetime.py
612
3.828125
4
# Data is called X and is a DataTable object # # Specification: # Inputs: # X: datatable - primary dataset # Parameters: # date_col: string - name of temporal column # split_date: date/time - temporal value to split dataset on date_col = "Date" # date column name split_date = "2013-01-01" # before this is trai...
d7f019f646f434729431ec70d43256cd9d19bf4f
lemonadegt/PythonPracticeWithMC
/odd100.py
81
3.53125
4
odd = [] for i in range(1, 100, 2): odd.append(i) print("odd100 = %s" %odd)
25d728b5cf54e25b9e2faaeb4fe8f0d29b56a114
Codechef-SRM-NCR-Chapter/30-DaysOfCode-March-2021
/answers/Khushi/Day 15/Question 1.py
113
4.15625
4
s=input("Enter string: ") word=s.split() word=list(reversed(word)) print("OUTPUT: ",end="") print(" ".join(word))
6d15aca0062150d2b1cb140acf263c05286078b7
lb3xx/Demo
/kaisa.py
1,266
3.625
4
msgbox = ''' ******************************************************* 欢迎使用20级计院13班蜡笔3小新的的恺撒密码系统 ******************************************************* ''' print(msgbox) def jiami(): wz = input("请输入需要加密的英文:") k = int(input('请输入偏移值(默认为3):') or 3) for c in wz: if "a"<=c<="z": pri...
6504ae1db9ae354fa5739b0596c211bf0880b7a7
Ekultek/exercism-io-answers
/python/pangram/pangram.py
531
3.796875
4
def is_pangram(sentence): data = split_sentence(sentence) item = check_for_letters(data) if item is True: return True else: return False def split_sentence(sentence): return list(sentence) def check_for_letters(new_list): chars = "abcdefghijklmnopqrstuvwxyz" count = 0 ...
3652541c2e8a1fde2e8924b18df74bdb508c739c
nicky1211/DSALabAssignments
/StackExceptionImplement.py
1,479
3.859375
4
class Error(Exception): """Base class for other exceptions""" pass class ArrayFullException(Error): """Raised when elements are tried to be added when the size if full""" pass class ArrayStack: """ LIFO stack implementation usinng Python list as underlying storage """ def __init__ (self,MAX_LEN = 1): ...
d8022814b2e9f788600d1a2f039c0626a9862408
malkoG/polyglot-cp
/BOJ/Implementation/Python/11367.py
479
3.546875
4
def report(num): if num in range(97, 999): return "A+" elif num in range(90, 97): return "A" elif num in range(87, 90): return "B+" elif num in range(80, 87): return "B" elif num in range(77, 80): return "C+" elif num in range(70, 77): return "C" elif num in range(67, 70): return "D+" elif num in ...
7bcb1a8e1cf79eddac8c227ffc5f95784a287878
Byliguel/python1-exo7
/fonctions/fonctions_cours.py
1,587
3.671875
4
############################## # Fonctions ############################## ############################## # Cours 1 ############################## ################################################## def dit_bonjour(): print("Bonjour le monde !") return # Appel dit_bonjour() dit_bonjour() ###############...
a95b883e7352c2c8587477f42d18946ad9ad8511
tedgjenks/School
/IntroCS_PythonProject/src/jenks/math/test/test_prime_factorization.py
5,915
3.765625
4
''' Created on Oct 8, 2014 @author: JenksT ''' import math import edu.prime_factorization.smithdeal.thomas.prime_factorization as student_prime_factorization from jenks.math.prime_factorization import is_prime as expected_is_prime from jenks.math.prime_factorization import factor as expected_factor from jen...
f6b63da3dd4011782eb4fefca528720dacef714b
Provinm/baseCs
/Books/Algorithms/Part-1/Chapter-7/quicksort_random.py
845
3.828125
4
#coding=utf-8 import random def quick_sort(lst, start, end): if start < end: pivot = random_partition(lst, start, end) quick_sort(lst, start, pivot-1) quick_sort(lst, pivot+1, end) def random_partition(lst, start, end): pick = random.randint(start, end) lst[pick], lst[end] = ls...
2b807a129691421a6bb67ed78f35d61fff3e2619
tangyingjin/Hogwarts
/python基础练习/exc_dict.py
310
3.515625
4
d={'mike':10,'lucy':2,'ben':30} for i in d.values(): print(i) i=d.items() # 查看对象的类型 print(type(i)) map(lambda x:x%2==0,[1,2,3]) i=sorted(d.items(),key=lambda x:x[1]) print(i) dict=[('mike', 10), ('lucy', 2), ('ben', 30)] for d in dict: print(d[1]) [ lambda x:x*x(x) for x in range(10)]
216ddc3cbae004312986ea6e7ccdf44bbf8dfa43
raiShashank/Discrete-Optimisation
/bestSearch.py
3,710
3.6875
4
class Node(object): def __init__(self ,value , capacity , maxPossible , item): """ value : current value of d node capacity : remaining capacity of d bag maxPossible : using remaining items what is d best dat can be filled, item : denotes itemNo. lik 2 which means dat maxPossible shd now focus on items ...