blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
be1394890cd197071436eed4cea3244113774d01
ursaMaj0r/python-csc-125
/Snippets/intro-1/method_of_transportation.py
541
4.03125
4
# prompt is_it_raining = input("Is it currently raining? ") # responses response_bus = "You should take the bus." response_bike = "You should ride your bike." response_walk = "You should walk." if is_it_raining.casefold() == "yes" or is_it_raining.casefold() == "y": print(response_bus) else: travel_distance =...
a5bd0c58ae2c38e1b6f77b3986ec83d8476284c5
iankit25/leet_code
/reg_exp_match.py
1,216
3.84375
4
#Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*' class Solution(object): def check_star(self,p,preceeding_ele): print p for i in range(len(p)): if p[i] == '*': continue else: if i+1== len(p): return False else: if p[i+1] ==...
51838cf853c0a252dce2d495bd3bed05d081744e
ericsolis8/curso_Python
/seguimiento-enumeracion.py
251
3.6875
4
# -*- coding: utf-8 -*- """ Created on Fri Oct 18 14:48:26 2019 @author: nomameserick """ print ('Lista de usuarios') usuarios = ('Margot', 'Rechell', 'Jhon', 'Alex', 'Jonathan') for indice, nombre in enumerate(usuarios): print (indice, nombre)
b468a9aca3cba39ad61d59f4998f247084b32404
jesprna/python
/decision-making/if-else.py
117
4
4
x = 3 y = 2 if(x == y): print("Equal") else: print("Not Equal") print("The program is working properly")
0938cac93c24473f7cb276fedd1741bab9af7e13
lkguevara/Fundamentos-de-Programacion-Mision-TIC2022-Ciclo1
/Semana3/Funciones/lamda.py
324
3.953125
4
#LAMBDA """Una función lambda es una pequeña función anónima. Una función lambda puede tomar cualquier número de argumentos, pero solo puede tener una expresión.""" #Sintaxis: """lambda arguments : expression""" """Ejemplo Agregue 10 al argumento ay devuelva el resultado:""" x = lambda a : a + 10 print(x(5))
08dffb53b2cb97d7b01d1f7c8009f4438fbc9484
dnlcrl/AlgorithmsAndDataStructures
/Implementations/Python/binary_tree.py
1,225
3.75
4
binary_tree = {'A': ['B', 'C'], 'B': ['D', 'E'], 'C': ['F', 'G'], 'D': ['H', None], 'E': [None, None], 'F': [None, None], 'G': [None, None], 'H': [None, None], } def left_son(node): return binar...
51e5ab9bbecea112261454937bd547c923808570
Bigbys-Hand/crash_course_git
/lists.py
456
4
4
bicycles = ['trek', 'cannondale', 'specialized', "whatever it was Eval Knievel's mom rode", 'redline'] print(bicycles) print(bicycles[0].upper()) # The first item in a list is always at 0, not at 1 # You can run methods on list print commands! Fancy. print(bicycles[-1]) # negative values let you select from right to le...
06828634d5cdd5e3469c4bbdd117a5bf5d75d4b5
sidchilling/Programming-Practice
/reviews.py
1,510
3.71875
4
import sys import string from operator import itemgetter valid = string.lowercase + string.digits + string.whitespace table = string.maketrans(valid, valid) remove = ''.join(set(string.printable) - set(valid)) def count_occurence(word, review): return review.lower().translate(table, remove).split().count(word) ...
1412c4b45449c71f7d9ae512b18c1543b4c8b8de
trickaugusto/python
/funcoes.py
484
4.09375
4
# Declaração de função, é usado red def print_hello_world(qtd): for i in range(0, qtd): print("Hello world! %d" % i) print_hello_world(5) ############################################# ########### Função recursiva ################ ############################################# def print_numbers_recursive(nu...
ef49de61816baac10c1cc44f1d734ae39cdd4efc
Devil8899/Python_demo
/Day6/shopping.py
1,518
3.78125
4
#__author: Administrator #date: 2016/8/23 product_list=[ ('Mac',9000), ('kindle',800), ('tesla',900000), ('python book',105), ('bike',2000), ] saving=input('please input your money:') shopping_car=[] if saving.isdigit(): saving=int(saving) while True: #打印商品内容 for i,v in ...
9565288137147e15231c3228d49df95eb116060d
cboopen/algorithm004-04
/Week 03/id_624/LeetCode_322_624.py
1,283
3.609375
4
# # @lc app=leetcode.cn id=322 lang=python3 # # [322] 零钱兑换 # # https://leetcode-cn.com/problems/coin-change/description/ # # algorithms # Medium (35.87%) # Likes: 263 # Dislikes: 0 # Total Accepted: 27.5K # Total Submissions: 75.9K # Testcase Example: '[1,2,5]\n11' # # 给定不同面额的硬币 coins 和一个总金额 # amount。编写一个函数来计算可以...
cb82f5c9dcf485fb8e0b6a3eff672677f30812d6
israelreyes01/Seguridad-de-la-Informacion
/Script1.py
223
3.640625
4
#Mi Primer Script #Certificado de seguridad de la info. print("Programa que suma 2 numeros") a = int(input("Ingrese el sumando 1: ")) b = int(input("Ingrese el sumando 2: ")) suma = a + b print("El resultado es : ", suma)
5a1dd616942a1fdaffacca2b47056276ea136eff
kamran1231/selenium_practice_2021
/unitTest_framework3.py
1,320
3.609375
4
''' Python unitTest Framework 1- setup 2- teardown 3- setUpClass 4- tearDownClass 5- setUpModule 6- tearDownModule ''' import unittest #will executed before executing any class or any menthod def setUpModule(): print('setUpModule') #will executed after the every present in the python module...
1c386c1c2095967013d7a90796f562130ea36ad3
liupy525/LeetCode-OJ
/25_Reverse-Nodes-in-k-Group.py
1,741
4.0625
4
#!/usr/local/env python # -*- coding: utf-8 -*- ''' Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is. You may not alter the values in the nodes, only nodes itself may b...
34e8ddef0eb186d749db7710c4decf5ad9e83200
viniromao159/PythonOrientadoObjetos-Alura
/Python OO II/abc.py
358
3.734375
4
from collections.abc import Sized #Importa uma classe abstrata (ABC) class MinhaListagem(Sized): def __init__(self, descricao): self.descricao = descricao def __str__(self): return self.descricao def __len__(self): #Método implementado para contagem return self.descricao lis...
fe2dc49ad647e9643f6a23b0d41f2255e8a4343b
EricShingleton-Smith/Bioinformatics
/rosalind_problems/stronghold/GC_content.py
1,124
3.515625
4
def readFile(filePath): '''Reading a file and returning a list of lines''' with open(filePath, 'r') as f: return [l.strip() for l in f.readlines()] def GCcontent(seq): #tmpFreqDict = {"A": 0, "C": 0, "G": 0, "T": 0} #for nuc in seq: # tmpFreqDict[nuc] += 1 #return tmpFreqDic...
9038c56c5b793a3a292033fd238c31112f01be6d
petlight45/Python-Scripts
/amicable_numbers_checker.py
2,084
4.4375
4
def compute_divisors(arg): """ This function computes the proper divisors and the sum of the proper divisors of a given integer. Parameters: args (int): The integer to work with. Return list: list of proper divisors. int: sum of proper divisors. """ sum_...
dd8a113d294d984dc4410240bfe0fd4ebff95f6a
ShedrackGodson/pySubnet
/binary_to_dotted_decimal.py
771
4.125
4
# A function that converts the Binary values to Decimal values def to_decimal(binary:str): """ Returns the Dotted format of the Binary values """ binary = binary.split(' ') new_binary = [] decimals = [] for value in binary: if len(value) > 8 or len(value) < 8: return print("Not a...
f592d4f598ec510ad260fb6133460514ea38e7d4
UjjwalP08/Basics-Of-Python
/Exercises/Exercise 1.py
353
4.125
4
"""In This exercise we can take input from user and compiler return according to its out put Eg:- Key now we can provide some details about it.""" a = {"key": "Use to open lock", "greet": "Means to Call about Good mornig", "IT": "Study of Website and Computer"} "" print(a.keys()) print("Enter Key which details you wan...
b7aaab5f7cbb133e48942ce4368099e467cf86d5
snake1015/Turtle
/pentagram_v1.0.py
441
3.765625
4
''' 作者:snake 功能:五角星绘制 日期:12/16/2017 ''' import turtle def onepentagram(lenth): for count in range(5): turtle.forward(lenth) turtle.right(144) def main(): ''' 主函数 :return: ''' lenth = 50 while lenth <= 150: onepentagram(lenth) lenth += 20 turtle.penup() ...
cd7d170322c12ae3a35f1b31ed0fb65b75376a98
rawan-al-maawali/String-Manipulation-Program
/operations.py
1,121
3.90625
4
def cont(): x = input("Enter first String:") y = input("Enter Second String:") return (x+" "+y) def rept(): x= input("Enter String:") n= int(input("Enter number of reptition:")) for r in range(n): print(x) def edit(): s=input("Enter String") index=int(input("Enter Index")) ch=input("...
b86f62c7865c806f0eba501b6e5936fecf839a7a
kiir07/test_python
/week_4/w4_Untitled-1_Минимальный делитель числа=.py
1,001
3.65625
4
# Дано натуральное число n>1. Выведите его наименьший делитель, # отличный от 1. Решение оформите в виде функции MinDivisor(n). # Алгоритм должен иметь сложность порядка корня квадратного из n. # Указание. Если у числа n нет делителя не превосходящего корня из n, # то число n — простое и ответом будет само число n. # ...
639c20fd4925cd204c5c24e12465f568b574e4c6
PravinSelva5/InterviewCake
/Array_and_String_Manipulation/ReverseWords.py
2,143
4.09375
4
import unittest def reverse_words(message): # We will first reverse the characters in the list reverse_characters(message, 0, len(message) - 1) # Need to reverse the words into the right word # Find the last letter of each word current_word_start = 0 for i in range(len(message) + 1): ...
1b9fc39428324c02ba71b3173d3727de20e3cc78
matta174/python_practice
/src/Chapter 9/9-3_users.py
807
3.546875
4
class User (): def __init__(self,first_name,last_name,age,hair_color): self.first_name = first_name self.last_name = last_name self.age = age self.hair_color = hair_color def describe (self): message = self.first_name.title() + ' ' + self.last_name.title() + ' is ' + str...
54630b03ccca4d9832bd160ae1f98d62ca9a87b1
IntroProgramacion-P-Oct20-Feb21/trabajofinal-1bim-KrissBustamante
/Taller6/ejercicios-clase06/ejemplos-while/ejemplo4.py
350
3.5625
4
##Se genera un codigo de repeticion que se va a repetir hasta determinado numero limite_inferior = 10 limite_superior = 20 contador = 10 suma = 0 while ((contador >= limite_inferior) and (contador <= limite_superior)): suma = suma + contador print("Contador %d\n"% (contador)) contador = contador + 2 print("La sum...
e64483925209048960701bc4212cd4549ac67794
joshpace8/cs205
/scripts/dbCreate.py
4,506
3.53125
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 19 16:30:44 2019 @author: nanan """ import sqlite3 as sq import csv def connect_database(): # database try: connection = sq.connect('../data/warm-up-DB-205.db') print("Database was created successfully locally") except sq.Error as err: ...
8dafb6e39f8edbea6a7008983eeb6c460a798893
vanshikasanghi/dv.pset
/0021 Largest Palindrome Product/largestpalin.py
570
4.375
4
def isPalindrome(num) : #to check if a number is palindrome or not reverse = '' length = len(num) for i in range(length-1,-1,-1): #checking in reverse reverse = reverse + num[i] if num == reverse : return True else : return False largest = 0 for x in range(100,1000) : #checking for all three digit numb...
4fa33e5551b33efa77629036edd975a66e659382
ajyoung21/Polling-Data-Analysis
/PyPoll/main.py
2,686
4.09375
4
#Imports the tools we need to read the csv. import os import csv csvpath = os.path.join('election_data.csv') #Opens the csv. with open(csvpath, newline='') as csvfile: # CSV reader specifies delimiter and variable that holds contents csvreader = csv.reader(csvfile, delimiter=',') # Read the header row...
00af67c800f92ef73c259f1358413a14f78cc19d
vinodsubbanna/Python
/asmnt23.py
144
3.984375
4
# 23)Write a method which can calculate square value of number # Hints: # Using the ** operator def square(n): return n*n print(square(4))
29ca06cf62add8a40c4b0a3fdc2f4a229a2c02dc
Jacob1225/katas
/interview-katas/roman-integer.py
554
3.703125
4
# ------------- ROMAN TO INTEGER INTERVIEW KATA LEETCODE ----------------- # Input: s = "MCMXCIV" # Output: 1994 # Explanation: M = 1000, CM = 900, XC = 90 and IV = 4. def romanToInt(s): roman = { 'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1...
599f15deaef19b2acc66861c786677d811a6f7c5
KaranJaswani/Codes
/LeetCode-Python/127. Word Ladder.py
6,591
3.578125
4
# import sys # # class Solution(object): # def ladderLength(self, beginWord, endWord, wordList): # """ # :type beginWord: str # :type endWord: str # :type wordList: Set[str] # :rtype: int # """ # visited = [] # result = self.backtrackLadderLength(begin...
de8df9e10d3c94eb4c1b2a4848f7f07798380d35
liao2014/Python20190618
/day07/socket_server2.py
802
3.5
4
# Author:UserA # socket示例2——服务端 # 发多次接收多次版本 import socket server = socket.socket() server.bind(('localhost', 1313)) # 绑定要监听端口 server.listen(5) # 监听,最多同时打开5个客户端进行排队传数据 print("开始等待客户端传递过来的数据") while True: conn, addr = server.accept() # 等电话打进来 # conn就是客户端连过来而在服务器端为其生成的一个连接实例 print(conn, addr) print("客...
70016c9f6c36f1d24a728c8127529a02bbf1613a
umbanhowar/mnist-neural-net
/network.py
7,367
4.21875
4
""" network.py ~~~~~~~~~~ Simple neural net implementation from Michael Nielsen's Neural Networks and Deep Learning book. Here, I've retyped all the code and commented each line for understanding. """ import random #standard lib import numpy as np #np for linalg class Network(object): def __init__(self, sizes...
3726d43a96c8013b95451ed8af7814935e8f9287
SmitRao/Games-Interface
/strategy.py
812
3.546875
4
""" Back-end code implementation for game_interface. CSC148 Winter, Assignment 1. January 30, 2018. """ from typing import Any import random from interface_set_up import Game # TODO: Adjust the type annotation as needed. def interactive_strategy(game: Game) -> Any: """ Return a move for game through intera...
bfb9467111d1f252c86d04f795260de79cc9b604
cuauhtemoc33/Python-1
/day06/decorator7.py
415
3.625
4
# 内置装饰器(不用导包) class Test(): __a = 10 # 装饰器@property,能用方法a直接调用它的一些内置方法 @property def a(self): return self.__a @a.setter def a(self, value): if isinstance(value, int): self.__a = value @a.deleter def a(self): self.__a = None t = Test() t.a = 123 prin...
6d271e230658260af04899d5e7a783cf78a9c6ad
TarandeepSingh562/BasicTemperatureConverter
/TempConverter.py
2,516
4.09375
4
from tkinter import * from tkinter import messagebox #Creates a class class MyGUI: def __init__(self): root = Tk() root.geometry("400x200") root.title("Temperature Conversion") # creates a Frame frame = Frame(root) frame.pack(fill = BOTH, expand = True) #cr...
605ed4e1b88efabc878076f7708692f25baca202
NilanshBansal/CircleofSquares
/turtleCircleOfSquares.py
420
3.953125
4
import turtle myturtle=turtle.Turtle() def square(length): myturtle.forward(length) myturtle.right(90) myturtle.forward(length) myturtle.right(90) myturtle.forward(length) myturtle.right(90) myturtle.forward(length) squareLen=int(input("enter length of square")) gapAngle=int(input("enter gap angle b/w ...
bf0e89240f4f37a580aab9569f8991173681907d
thompsta/100daysofcode-python
/days/13-15 textgames/actors.py
1,274
3.6875
4
import random # classes are blueprints of the objects we want to create # every method has the __init__ self, assign new fields (characteristics) with self class Creature: def __init__(self, name, level): self.name = name self.level = level # add new behaviors (methods) with new functions withi...
ea5961b86f3e92ead665ea8c48129e36ca3020d0
fylr/algorithm
/codeup/100000567/C.py
213
3.515625
4
#!/usr/bin/python3 a, b, c = input().split() a = float(a) b = float(b) c = float(c) if a > b: a, b = b, a if a > c: a, c = c, a if b > c: b, c = c, b print("{0:.2f} {1:.2f} {2:.2f}".format(a, b, c))
59aed7350f2b21560327ab968bc07d5edbed35cf
guimmp92/python
/rotate_matrix.py
1,693
3.625
4
#!/usr/bin/python # vim: foldlevel=0 """ Problem 1: Rotate an NxM matrix by 90 degrees. http://www.geeksforgeeks.org/turn-an-image-by-90-degree/ Input: 1 2 3 4 5 6 7 8 9 10 11 12 Output: 9 5 1 10 6 2 11 7 3 12 8 4 Problem 2: Rotate an NxN matrix in p...
4bd3bb9f7faf1a6d16ee2886539bbcf4c94608d4
opnsesame/Data-Structures-and-Algorithms-Exercises
/test/factorial.py
341
3.59375
4
import functools import time def timer(func): functools.wraps(func) def wr(*a): start = time.time() rv = func(*a) end = time.time() #print('elapsed: ',end-start) return rv return wr @timer def factorial(n): if n == 0: return 1 return n*factorial(n-1)...
1bbb81346068d3bda560a602044a59e847eb5438
mxmaria/coursera_python_course
/week2/Количество четных элементов .py
294
4.15625
4
# Определите количество четных элементов в последовательности, завершающейся числом 0. n = int(input()) quant = 0 while n != 0: i = n % 2 if i == 0: quant += 1 n = int(input()) print(quant)
3bf4c3cbead83b3d6638abb868fefaafbb82a6dd
paulohcs/Lista-2-Python
/6.py
508
3.9375
4
#!/usr/bin/python3 dinheiro = float(input('Dinheiro ganho por hora(R$): ')) horas = int(input('Horas trabalhadas no mês: ')) salarioB = dinheiro*horas ir = salarioB * 0.11 inss = salarioB * 0.08 sindicato = salarioB * 0.05 salarioL = salarioB - ir - inss - sindicato print('+ R$ ' + str(salarioB) + ' Salário Bruto'...
0f5db31630ed97e31cddfbd69b560ce42c2d8de6
tmtowtdi/Python-Challenge
/problems/3/test.py
1,194
3.859375
4
# http://www.pythonchallenge.com/pc/def/equality.html import pagestring, re """ This is another puzzle with a huge mass of text buried in an HTML comment in the page source. Again, I've copied that string into ./pagestring.py - see get_pagestring(). The text on the page says: One small letter, surrounded by ...
6332637ee0774660ed2090041cb2821294ea518c
cnsapril/JZAlgo
/Ch 1 - Introduction & Subsets/subsets.py
589
3.78125
4
""" Given a set of distinct integers, return all possible subsets. Elements in a subset must be in non-descending order. The solution set must not contain duplicate subsets. """ class Solution(object): def subsets(self, s): def _subsets(result, temp, nums, pos): result += [temp] fo...
4defede08f39a1c277ade2b4fda77a6f284647d6
gavrbot/Miller_Rabin_test
/main.py
963
3.875
4
import random from random import randint def miller_rabin(n, k): if n == 2 or n == 3: return True r, s = 0, n - 1 while s % 2 == 0: r += 1 s //= 2 for _ in range(k): a = randint(2, n - 1) x = pow(a, s, n) if x == 1 or x == n - 1: continue ...
3b511fefeb0a5d0abf99012257dfc40fc8053679
ConnorDesmond/Personal_Projects
/Function_Template.py
638
4.0625
4
import numpy as np import matplotlib.pyplot as plt #gives the set of x values that will be evaluated by f(x) t = np.linspace(0, 1, 256, endpoint = True) #f(x) equation #-- equation goes here -- #plots f(x) plt.plot(f, x) #initializes the axes for the plot axes = plt.gca() #describes the horizontal and vertical ran...
6f670f2931b434964bcb749b9e9421ffc5e9eacf
tospolkaw/CloanGit_PythonHealthcare
/py_files/0028_merging_data_with_pandas.py
2,867
4.03125
4
# coding: utf-8 # ## Using Pandas to merge or lookup data # # Sometimes we may want to cross-reference data between different data tables. This may be in order to perform a full merge of data, or just to produce a summary lookup table referencing across different tables. # In[18]: import numpy as np import pandas...
878fd1c9ff0373bd1dbec466e0b2d08895338ffa
zoeyzou/uopeople-cs-course
/CS1101/week6/index.py
282
3.75
4
# Part 1 delicious_food = "fried_noodle dim_sum pasta sushi tepanyaki tom_yum" food_list = delicious_food.split(" ") print(food_list) food_list.pop() print(food_list) food_list.remove("pasta") print(food_list) del food_list[2] print(food_list) food_list.sort() print(food_list)
36029fd5972698a6ec2eb714057e17cc8a931e84
Eric-D-Stevens/OHSU
/OHSU_Spring_2019/CS559/ML_Homework_2/main1_2.py
1,891
4.0625
4
#!/usr/bin/python3 ''' main1_2.py Write and submit the program main1_2 that: *loads the train and test set. * learns the weights for the training set. * computes the mean squared error of your predictor on: * The training set. * The testing set. ''' import numpy as np def LR_solve(X,Y)...
607c98daa2606c9de29250aa8184ed0f9e99b4c1
laubatista/Curso_Python3
/aulas/A09Manipulando_strings.py
574
4.3125
4
frase = 'Curso em Video Python' print(frase[3:13]) #Fateamento -> mostra as letras da posição 3 a 12. print(frase.count('o')) # Conta quantos 'o' têm na frase. print(frase.upper()) # Colocar todas as letras em maiusculas print(len(frase)) # Mostra o tamanho da frase. print(frase.replace('Python', 'Android'))# Troc...
4ae647639e8a93fa90d8eb7bf49e2f071d800374
dpinezich/python_algorithms
/sorting/selection_sort.py
365
3.890625
4
def selection_sort(numbers): for i in range(len(numbers)): lowest_value_in_index = i for j in range(i + 1, len(numbers)): if numbers[j] < numbers[lowest_value_in_index]: lowest_value_in_index = j numbers[i], numbers[lowest_value_in_index] = numbers[lowest_va...
59602afb19ce621578540f3feaa2058e750f1e74
Coscos12/Python_HW
/week_5/Task3.py
561
3.671875
4
class Human: def __init__(self, first_name, last_name): self.first_name = first_name.capitalize() self.last_name = last_name.capitalize() self.full_name = first_name.capitalize() + ' ' + last_name.capitalize() class Employee(Human): def __init__(self, first_name, last_name,...
b6a90059807fee6c39ee9f5a978592d6b155274b
collective/collective.portlet.geo
/collective/portlet/geo/utils.py
374
3.546875
4
class CommentedFile: def __init__(self, f, commentstring="#"): self.f = f self.commentstring = commentstring def __iter__(self): return self def close(self): self.f.close() def next(self): line = self.f.next() while line.startswith(self.commentstring): ...
b8f60c1feb24c1337060b5c9fda54b48cab87835
rafaelperazzo/programacao-web
/moodledata/vpl_data/103/usersdata/147/49910/submittedfiles/av1_3.py
165
3.921875
4
# -*- coding: utf-8 -*- import math n1=int(input('digite n1:')) n2=int(input('digite n2:')) cont=0 x=n1//n2 while x>0: cont=cont+1 x=n1//n2 print(x)
3efacf35a2b0379f2afaf6d343d4c256dce55486
lostsollar/Leetcode
/135 Candy/solution.py
3,765
4.0625
4
def candy1(ratings): """ Solution: Brute Force [Time Limit Exceeded] Time complexity: O(n2) Space complexity: O(n) :param ratings: :return: """ length = len(ratings) candies = [1] * length flag = True while flag: flag = False for i in range(length): ...
37b95fc25ed3a119d74ae5401027d8428075c646
samjaninf/pyshuffle
/tablegen/csv_to_table.py
237
3.515625
4
import csv import sys with open(sys.argv[1]) as csv_file: csv_reader = csv.reader(csv_file, delimiter=',') line_count = 0 for row in csv_reader: print(f"{{\"e\":\"{row[0]}\",\"h\":\"{row[2]}\",\"k\":\"{row[1]}\"}},")
8447ccac58f6f2f01574745b599d4477a6ba3251
W1nU/algorithm
/first/11279.py
2,409
3.734375
4
import sys input = sys.stdin.readline class MaxHeap: def __init__(self): self.heap = [None] def swap(self, a_index, b_index): temp = self.heap[a_index] self.heap[a_index] = self.heap[b_index] self.heap[b_index] = temp def insert(self, value): self.heap.append(value...
2cb0590ce453b1148f6aaf5b9cf20e46e2d2b951
Pelos17/python_OOP
/C3Clases_objetos.py
173
3.84375
4
class empleado: name = "Pedro" def changename(self): self.name = input("Ingresa el nuevo nombre:\n") pedro = empleado() pedro.changename() print(pedro.name)
49f2e153500f25a6ad9fda76e38ad3248cb772c9
sagarnikam123/learnNPractice
/hackerRank/tracks/languages/python/13_regexAndParsing/7_validatingRomanNumerals.py
1,119
4.46875
4
# Validating Roman Numerals ####################################################################################################################### # # You are given a string, and you have to validate whether it's a valid Roman numeral. If it is valid, print True. # Otherwise, print False. Try to create a regular ...
e5701d67ac5854cde904e3698b1bcf1712887a3b
pacos-br/Aprendendo_Python
/exercicios/contagem_caracteres_lista.py
778
3.921875
4
def contar_caracteres(s): """Função que conta caracteres de uma string ex: >>> contar_caracteres('paulo') a: 1 l: 1 o: 1 p: 1 u: 1 >>> contar_caracteres('banana') a: 3 b: 1 n: 2 :param s: string a ser contada """ caractere_ordenado = sorted(s) caractere_...
d682e5e35c450d42b7d2ef022a1f93436f46ad3d
divyatejakotteti/100DaysOfCode
/Day 08/ArrayRotation.py
1,258
4.5
4
'''A left rotation operation on an array shifts each of the array's elements 1 unit to the left. For example, if 2 left rotations are performed on array [1,2,3,4,5], then the array would become[3,4,5,1,2]. Given an array 'a' of n integers and a number, d, perform 'd'left rota Function Description: Complete the...
d1a453564837dc467286f94959b2e06a15379733
guadalupeaceves-lpsr/class-samples
/skgrfbkj.py
1,943
4.46875
4
# I first made a list of all the names of my family and friends, and I # assigned it to friendsandfamilymembers, making it a list variable. friendsandfamilynames = ["Brenda","Kimberly","Jennifer","Armando","Alicia","Mariana","Angy","Lidia","Elizabeth","Nancy"] # I assigned il to the value of 0, which makes it into an ...
8a100342762feeb6a63315b880dc341d536cd3b8
drcsh/tumblelog
/tumblog/utils/security.py
1,949
3.65625
4
import bcrypt from tumblog.exceptions import security_exceptions ENC_COST = 14 PREFIX = "2b" PREFIX_ENCODED = b"2b" PW_MIN_LENGTH = 6 def hash_password_string(password_str): """ :param str password_str: :return: key :rtype str: """ bstring = bcrypt.hashpw(password_str.encode(), bcrypt.ge...
4c3e58e4eb5401ae07eac4886aeeb1f2731c2f2c
cwray01/BigDataLearning
/CodingLanguage/Python/PycharmProjects/tutorial/HelloWorld/ds_using_tuple.py
577
4.28125
4
#I would recommend always using parentheses #to indicate start and end of tuple #even though parentheses are optional. #Explicit is better than implicit #tuple zoo = 'python', 'elephant', 'penguin' print 'Number of animals in the zoo is', len(zoo) #tuple new_zoo = 'monkey', 'camel', zoo print 'Number of cages in the ...
0168c78ae957915df9c9f31acf6a8b2b29dd3845
adpoe/Artificial_Intelligence_Algorithms
/puzzlesolver/pancakes_tests.py
4,221
3.578125
4
""" Tests for the pathplanning puzzle endpoints """ import pancakes as pancakes class PancakeTests: def __init__(self): self.pancakes = pancakes.BurntPancakes() print "===== TEST PANCAKES PUZZLE ======" # check that parse is okay self.pancakes.parseInput("test_pancakes1.config") ...
0ec4af8298774b84cd55dac82affa9063930927e
rafaelperazzo/programacao-web
/moodledata/vpl_data/59/usersdata/184/47586/submittedfiles/testes.py
119
3.921875
4
# -*- coding: utf-8 -*- a=float(input('digite a:')) b=float(input('digite b:')) c=a a=b b=c print('%f'%a) print('%f'%b)
5e639837f1b82286238d7af324e0acf9209b38e4
BitnooriLee/Python-Opentutorial-Lecture
/Inheritance/2.py
719
3.78125
4
class Cal(object): def __init__(self,v1,v2): if isinstance(v1, int): self.v1=v1 if isinstance(v2, int): self.v2=v2 def add(self): return self.v1+self.v2 def subtract(self): return self.v1-self.v2 def setV1(self,v): if isinstance(...
29d0e0dd123689970c7d610a49a12d288f41759d
SoumodeepSaha/october1
/add.py
92
3.5625
4
print("Give 2 numbers :") y = int(input()) x = int(input()) print(y+x) print("Hello World")
c4a6ef0c04c4bad755d097e4033db87bf2d0a4e2
YEL-59/python_labtest
/6.py
670
4.0625
4
contact_lists = [] name = input("enter your name :") father_name = input(f"enter {name}'s father's name :") mother_name = input(f"enter {name}'s mother's name :") number = input(f"enter {name}'s mobile number :") contact_lists.append(name) contact_lists.append(father_name) contact_lists.append(mother_nam...
a2e1677cc89a064e58fd10365e8d04f4d68990ad
kspnec/RealPython
/1.Basic Data Types/vars_ref_scope_1.py
780
4.09375
4
num = [1, 2, 3, 4, 5] print(dir(num)) a = 1 b = 'global' c = 'another global' def function(): a = 2 b = 'local' print(a, b) # vars() will show all the variables available for this function. # i.e (local variables) # Dictionary format. print(vars()) # you can also use globals() functio...
b44f721ec3135df7b744df8a99b80807e325f48e
GoannaCodes/IFB104TUT2018
/WorkshopExercises/Wk2_PredefinedFunctions/2_concentric_circles.py
2,365
4.9375
5
# Concentric circles # # As an exercise in using the Turtle package and lists you are # required to draw three concentric circles on the screen. # These circles must be centred in the drawing window. The # radii of the circles are given to you as a list of numbers. # You must develop your program so that it is easy to...
08139242e6e6d6be952ca826a0256dbadd4d7086
apdaza/python_UEFI_2021-1
/06 tkinter/temporizador/guitemporizador.py
1,970
3.53125
4
from tkinter import * from temporizador import Temporizador from threading import * from time import sleep class AppTemporizador(Thread): def __init__(self): self.principal = Tk() self.crono = Temporizador() self.frame = Frame(self.principal) self.frame.pack() self.valor =...
6c73f50b8c4541078c910f43f54f54edf7e32e1b
gfYaya/yayaPython
/tutorial/classes/mutiple inheritance nd.py
589
3.75
4
# coding = utf-8 class A: def __init__(self, a): print('A') self.a = a def comeon(self): print('A.comeon') class B(A): def __init__(self, b): super().__init__(b) print('B') self.b = b def comeon(self): print('B.comeon') class C(A): def _...
a16e3ddbe75190d9e4a2260a6a1cf4b69dfeeeeb
sapkalrohit0909/Blood_Distribution_Database_System
/Application_File/App.py
9,441
3.53125
4
import requests import json def reveiverFunctionalities(): print("===========================================") print("0.EXIT") print("1.NEW RECEIVER") print("2.OLD RECEIVER") receiverChoice = input("Enter your choice :") if receiverChoice == 0: return if receiverChoice == 1: ...
f50dcf87ceb26ff0a348226ba81af6c8ae6faeff
nateKiprotich/Python-Basics
/functions/multiple_return.py
293
4.0625
4
def total_avg(*num): s = 0 l = len(num) for i in range(l): s += num[i] return s, (s/l) # total function takes in any number of arguments total, avg = total_avg(2, 3, 6, 48) print(total) print(avg) rslt = total_avg(2, 3, 6, 48, 78) print(rslt[0]) print(rslt[1])
cb93bf8511461d57dd2557ab0aeb2ec3eb89ef7f
SickanEkman/Labbar
/Labb_1/translator.py
841
3.65625
4
class Translator(object): def __init__(self, lexicon, english): self.lexicon = lexicon self.text = self.modify_input(english) def modify_input(self, english): if ".txt" in english: with open(english, "r") as p_file: lines = p_file.readlines() ...
851173acbf2cacb5124191b7b4bbd0799dac4abf
noopurkharche/dataStructuresAndAlgorithms
/numberOfIslands.py
734
3.78125
4
# depth first traversal def dfs(i,j,m,n,matrix): # check for bounds or value not equal to 1 if i < 0 or j < 0 or i >= m or j >= n or matrix[i][j] != 1: return # mark the cell as visited matrix[i][j] = -1 dfs(i + 1, j, m, n, matrix) dfs(i - 1, j, m, n, matrix) dfs(i, j + 1,...
2a4eba5dd0d75ae4c3ea29bbd10c3dc96f01200a
conradylx/Python_Course
/05.05.2021/exc1/exc1.py
449
3.578125
4
# Utwórz dekorator @uppercase_decorator, który przyjmuje dowolną funkcję zawracającą łańcuch # znaków i zwracający ten sam tekst zmieniony na wielkie litery. def uppercase_decorator(f): def uppercase_method(): text_to_format = f() print(text_to_format.upper()) return uppercase_method @upperc...
96382c063587b5c4cd4285babfde9e4a66c634f1
euribates/advent_of_code_2020
/day09/loader.py
235
3.546875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- def read_input(filename='sample'): with open(filename, 'r') as stream: for line in stream: line = line.strip() if line: yield int(line)
8c4f9e11e8c14816df283f6c62840f02ed42faf7
ayoubabounakif/edX-Python
/sum_of_rows_of_a_2D_list.py
192
3.765625
4
def sum_rows_2d(list): sum_row = [] for row in list: sum_row.append(sum(row)) return sum_row print (sum_rows_2d([[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]))
68ffdb409d39c252c631fb6dd38b52696538b2bd
sy1wi4/ASD-2020
/graphs/Prims_MST.py
1,946
3.609375
4
# MINIMUM SPANNING TREE O(ElogV) # graf nieskierowany # bardzo podobny do algprytmu Dijkstry # dla każdego wierzchołka będziemy pamiętać min wagę dojścia z sąsiedniego # wierzchołka oraz rodzica # -> wszystkie wierzchołki umieszczamy w kolejce priorytetowej z wagą inf # a wierzchołek startowy z wagą 0 # -> ...
b520f0b3389a6ceefc353e1d47045656902de023
a1ultima/learn_ML
/2_Regression/Regression_andy/Section 4 - Simple Linear Regression/data_preprocessing_template.py
1,649
4.09375
4
# Data Preprocessing Template # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('Salary_Data.csv') X = dataset.iloc[:, :-1].values y = dataset.iloc[:, 1].values # Splitting the dataset into the Training set and Test set from...
01bfbe474d0fdcfa7f0d015197bfe9630bb9774c
cheery/lever
/runtime/bon.py
2,383
3.625
4
""" binary object notation A data-interchange format. Used here because it is simpler to decode than other similar formats and can contain custom encodings. """ from space import * from rpython.rlib import rfile from rpython.rlib.rstruct import ieee from rpython.rtyper.lltypesystem import rffi import patho...
81c8ec802fd355b1eaeb0c4565065e76a109d1b9
colivet1193/MSING055
/Tweet collection.ipynb
2,111
3.5
4
import tweepy import requests from requests_oauthlib import OAuth1 import json import csv from datetime import datetime #Credentials consumer_key = ['consumer key 1','consumer key 1'] consumer_secret = ['consumer secret 1','consumer secret 2'] access_token = ['access toke 1','access toke 2'] access_token_se...
5b3e3815c05a12d53bb86c14b0109841471dd5be
vadim-kravtsov/Numerical_methods
/5/main.py
1,725
3.515625
4
import numpy as np from math import sqrt, sin, pi, cos, log import scipy.integrate as integrate import matplotlib.pyplot as plt from numpy.linalg import solve def chebyshev(x, n): ''' Chebyshev polynomials of the first kind. n - order of polynom. ''' if n == 0: y = 1 elif n == 1: y = x else: y = 2.0*x*ch...
7f3407e6b2278f1f78c62c3d8b1e696ec2b6b019
ThallysSo/CursoEmVideoPython
/Exercicio_71.py
923
3.6875
4
valor_sacar = int(input('Digite o valor a ser sacado: R$ ')) cinquenta = vinte = dez = um = 0 while True: if valor_sacar >= 50: cinquenta += 1 valor_sacar -= 50 elif valor_sacar >= 20: vinte += 1 valor_sacar -= 20 elif valor_sacar >= 10: dez += 1 valor_sacar -...
105effdf988d88e45560d9df29433299a9025d14
liaofei1128/Goq
/engine/shared_logic/Point.py
1,256
3.75
4
class Point(object): def __init__(self, name="<?P?>"): if name.startswith("_"): name = "<"+name+"_>" self.name = name def bind(self, points): if self.unbound(): return points[self] else: return self def match(self, other) -> bool: ...
a25c51e4066866622ac557fdd849cc2786f88aad
damicoat/advent-of-code-2020
/day5/part1.py
751
3.515625
4
import math def read_input_file(): with open("./input.txt") as file: for row in file: yield row.rstrip("\n") def get_seat_id(b_pass): row = [0, 127] col = [0, 7] for char in b_pass: row_mid = ((row[1] - row[0]) // 2) + 1 col_mid = ((col[1] - col[0]) // 2) + 1 if char == "F": # lower ...
c77fdc684eeddb683e08841d6d52a283f5903738
zhangjingrui123/python
/8.if条件控制语句.py
1,217
3.8125
4
#(一)if条件控制语句:if-else-elif num = float(input("输入一个数字:")) if num > 0: #每个条件后面要使用:,表示接下来是满足条件后要执行的语句块 print("ture") elif num == 0: print("0") else: print("flase") #elif=else-if的缩写 num = float(input("输入一个数字:")) if num >=0: if num == 0: print("0") else: print("ture") else: pri...
c611e7f7a821c1ee1b9156c9ab148a624bbb7a70
Niimaa/python_tutorial
/Computational Python/dictionary.py
738
4.3125
4
#Key and its value in the dictionary employee = {'name': 'Tom', 'age': '30', 'expertise': ['Java', '.net']} print(employee) print(employee['name']) print(employee.get('address')) print(employee.get('age')) print(employee.get('address','Value is not found')) #add, edit values from dictionary employee['years']= 5 print...
f0363e563f7570bafbac9c59bb5a340ed49085f1
wttttt-wang/leetcode_withTopics
/Tree/BinaryIndexedTree/reverse-pairs.py
1,298
3.515625
4
""" Reverse Pairs @ Explanation: BIT. remember to add all the indices that needed to add / sum to allVals. """ class BIT(object): def __init__(self, n): self.n = n self.arr = [0] * (n + 1) def lowBit(self, x): return x & (-x) def add(self, ind, val): while ind <= self.n: ...
b41732ec3867cddb4f2e344e52b34318f9fa8eeb
carlanlinux/PythonBasics
/9/9.9_Non-mutating Methods on Strings.py
2,154
4.34375
4
''' upper is a method that can be invoked on any string object to create a new string in which all the characters are in uppercase. lower works in a similar fashion http://docs.python.org/3/library/stdtypes.html#string-methods ''' ss = "Hello, World" print(ss.upper()) tt = ss.lower() print(tt) print(ss) ss = " He...
cf96b13f4dd340763367e3f19246f21514bc8236
s3818775/share-bai
/piechart.py
1,168
4.03125
4
# RMIT University Vietnam # Course: COSC2429 Introduction to Programming # Semester: 2020B # Assignment: 2 # Author: Truong Thanh Long (s3818775) # Created date: 08/08/2020 # Last modified date: 09/08/2020 import turtle from itertools import cycle a = float(input('a: ')) b = float(input('b: ')) c = float(input('c: '...
45b824883894b269011ef4e9013e7134ed285a31
brajeshrai821/Personal
/Python/while.py
558
3.625
4
import random import sys import os ''' random_num= random.randrange(0,100) while (random_num != 15): print(random_num) random_num = random.randrange(0,100) i = 0; while(i <= 20): if(i%2 == 0): print(i) elif(i ==9): break else: i += 1 continue i += 1 ''' x = 0 while x<5:...
bd4dedb4ab5d35d252659aa5e9bf0ae3a37c2d78
zhudingsuifeng/python
/code/kitchen.py
570
3.859375
4
#!/usr/bin/env python #coding=utf-8 #python3.6.5 import sys res=[] for line in sys.stdin: #sys.stdin.readline() get all standard input including '\n',input() get all standard input without '\n' if line.strip()=='': #str.strip([chars]) return a new string generated by removing the characters specified at the begi...
799686f2f0ccd412d70253d95b9b4b8b2cf82bec
vitormrts/python-exercises
/Desafios/des074.py
1,014
3.546875
4
cont = 0 cont18 = 0 conthomem = 0 contmulher = 0 continuar = '' while True: cont += 1 print('='*40) print(' CADASTRE UMA PESSOA') print('='*40) idade = int(input('Idade: ')) while idade < 0: idade = int(input('\033[1;31mOPÇÃO INVÁLIDA\033[m\nIdade:')) if idade > 18: cont18 +=...
e4e633d236236aad385fd1c260adb8ed569ad5c1
Asunqingwen/LeetCode
/easy/Maximum Product of Three Numbers.py
1,170
4.46875
4
# -*- coding: utf-8 -*- # @Time : 2019/8/12 0012 10:01 # @Author : 没有蜡笔的小新 # @E-mail : sqw123az@sina.com # @FileName: Maximum Product of Three Numbers.py # @Software: PyCharm # @Blog :https://blog.csdn.net/Asunqingwen # @GitHub :https://github.com/Asunqingwen """ Given an integer array, find three numbers who...
c228ee6d9212f42e00bd3470bf1b5602f3dfb77e
gabriellaec/desoft-analise-exercicios
/backup/user_088/ch8_2020_09_05_17_56_11_609859.py
327
3.6875
4
def calcula_posicao(so,v,t): calcula_posicao= so+ v*t return calcula_posicao so=int(input('diga a posição inicial') v=int(input('diga a velocidade') t=int(input('diga o tempo') print('para a posicao inicial {0}, a velocidade {1} e o tempo {2} temos a posicao final'.format(so,v,t,calcula_posicao)) ...
8707b6a6c4990a6700efad0ec609869846f4d378
DarioBernardo/hackerrank_exercises
/strings/longest_consecutive_substring.py
1,669
3.640625
4
""" Find the longest Consecutive Substring (Increasing Alphabetically) from the below pattern that starts with A. You can assume ? as any character. it can be repace by 0 or 1 character. Note: Consider all as upper case. Example : [?, B, A, ?, C, D, ?, ?, F, I, ?, ?, ?, ?, D, ?, ?, ?, H] result 8 Exp: One of the Subst...