blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a1f9f339424711a8493e89eb801ca0e845d08daa
srikanthpragada/PYTHON_25_MAY_2020
/demo/table.py
340
4
4
import sys if len(sys.argv) < 2: print("Usage : python table.py <number> [length]") exit(1) if len(sys.argv) == 2: length = 10 # Default length else: length = int(sys.argv[2]) num = int(sys.argv[1]) # Number for which table is to be displayed for i in range(1, length + 1): print(f"{num:3} * {i...
e3007b36261824aa5a1b779bfd70192ec1ce9de3
daksh5/GUI-python
/ProjectGUI.py
2,068
3.703125
4
# Daksh Parikh # This is a GUI application that will let user to login, create new_account, edit and delete account # with the help of the Mongodb that provides backend support to this application. # For this I'm using pymongo library and for GUI tkinter import tkinter as tk from tkinter import filedialog import tkint...
8805dd39f822191bc0a42ecc458712422f2d35a5
aaiirr123/GoodTrainerApp
/databaseStuff.py
1,410
4
4
import sqlite3 # c.execute("DROP TABLE UserInfo") # c.execute("""CREATE TABLE UserInfo( # first text, # last text, # email text, # password text # )""") # conn.commit def lookForUser(username, password): conn = sqlite3.connect('Users.db') c = conn...
4ba88a1c203520889d118096f0715fc603e3961c
mortontaj/Python_5
/Part 5/spiliting_things.py
819
3.90625
4
panagram = """The quick brown fox jumps\tover the lazy dog""" words = panagram.split() print(words) numbers = "9,223,372,036,854,775,807" print(numbers.split(",")) print() print("***" * 30) print() generated_list = ['9', ' ', '2', '2', '3', ' ', '3', '7', '2', ' ', ...
0cd6381f10dc8ce5cb830a7bd48aa7760fd9fd74
CMS-APP/Elevator-Model
/elevator_sim/animations.py
1,834
3.578125
4
import pygame DisplayWidth = 1280 DisplayHeight = 720 white = (255, 255, 255) black = (0, 0, 0) def animation_init(model): pygame.init() pygame.font.init() pygame.display.set_caption("Elevator Simulation") model.elevator.image = pygame.image.load('lift.png') model.elevator.image = pygame.transfor...
ef13a842f357f9c2824d1ec08a8acbf1bc511173
icot/euler
/p13.py
245
3.59375
4
#!/usr/bin/python import utils with open('13.txt') as fp: lines = fp.readlines() lines = map(lambda x: x[:-1], lines) if __name__ == "__main__": num = 0 for item in lines: num += int(item) print "Result: ", num
f72e8ed6ea3289b9dfb853fe3518f2b70d7ae453
Priya96-sketch/Py-Scripts
/Email_Slicer/code.py
748
4.1875
4
--- #Project Name: Email Slicer #Author: Priya Mondal --- #BREAKDOWN OF MAIL ADDRESS-priyapujamondal@gmail.com : USERNAME:priyapujamondal, DOMAIN:gmail.com, @ symbol: Divider. # The symbol is required for all SMTP email addresses. #Get the user's mail address email = input("What is your email address? ").strip() #...
bb790d8c60869b433a8b649e6a4ca00b9478a5e3
chenjinpeng1/python
/day17/快速排序.py
1,186
3.828125
4
#python 3.5环境,解释器在linux需要改变 # -*- encoding:utf-8 -*- #Auth ChenJinPeng import random,time def quick_sort(array,start,end): if start>=end: return k = array[start] left_flag = start right_flag = end while left_flag < right_flag: #右边小旗子往左移动 while left_flag < right_flag and arr...
4038313e674105d176c0f12d91de8fdd932491a0
Guilherme-Schwann/Listas-de-Exercicios-UFV-CCF-110
/Lista06/ex016.py
309
3.6875
4
tam = int(input('Tamanho dos vetores: ')) v1 = [int(input('Vetor 1: ')) for x in range(tam)] v2 = [int(input('Vetor 2: ')) for x in range(tam)] v3 = [0 for x in range(tam * 2)] for i in range(tam * 2): if i % 2 == 0: v3[i] = v1[int(i / 2)] else: v3[i] = v2[int(i / 2)] print(v3[i])
0d1d7f377969b6f2330d018e3c2e9baef6cfc448
xzha0006/Leetcode
/Python/0547_FriendCircles.py
790
3.59375
4
class Solution: def findCircleNum(self, M): """ :type M: List[List[int]] :rtype: int """ if not M: return 0 n = len(M) id = [i for i in range(n)] #Initial id list. All nodes' parents are themselves. count = n def find(node):...
5792752afe7f4d0f15bfbc1d3aec7e74743f8cd2
juned8236/Head_pythonbook_comprehanded_data
/original.py
1,968
3.875
4
with open("james.txt") as jaf:#Open the file. data=jaf.readline()#Read the line of data. james=data.split(',') #split=Convert the data to a list. """ if split() then output ['2-34,3:21,2.34,2.45,3.01,2:01,2:01,3:10,2-22'] means only 1 value and each value will not iterate therfore use split(',') = ['2-25', '2-55'...
9f85502b107a76107ad3845dd4dba8d97ca23e18
ImHouses/Modelado-y-Programaci-n
/Proyectos/proyecto01/clientebanco.py
5,992
3.703125
4
# -*- coding: utf-8 -*- import socket """Método auxiliar para recibir un mensaje de una conexión. Regresa una cadena con el mensaje recibido. :param conexion: La conexión de dónde se recibirá el mensaje. """ def recibir_mensaje(conexion): return conexion.recv(2048).decode() def enviar_mensaje(mensaje, conexion): c...
cadb0653b3274a5b73846acd42e7654aa873f7f6
daniele-mc/java_example
/semaphore/mutex.py
738
3.5
4
import threading import time import os lock = threading.Lock() class MutexExample: def __init__(self, id): self.threadid = id self.t = threading.Thread(target=self.thread_func, args=()) def thread_func(self): global lock print("Locking ", self.threadid) lock.acqui...
144952765aaeae175654c02ea3ef3c21558a788d
hobart2018/python123
/base/strtest.py
157
3.703125
4
strgroup = "摄氏度 sheshidu ℃" for i in range(len(strgroup)): print("符号“{}”的Unicode值为{}。".format(strgroup[i], ord(strgroup[i])))
d80a35e919757048bb5d5ef844fb2288955572ee
froggengoing/LeetCodeInPython
/20210805-[88]Merge-Sorted-Array.py
2,013
3.90625
4
# Input: nums1 = [1,2,3,0,0,0], m = 3, nums2 = [2,5,6], n = 3 # Output: [1,2,2,3,5,6] # nums1的长度为m+n # 必须在num1的基础上修改 class Solution(object): def merge(self, nums1, m, nums2, n): ''' nums1的长度为m+n,要将nums2的值直接加入nums1 所以应该在nums1从后往前加载元素 ''' i1 = m - 1 i2 = n - 1 w...
b29979cf9f4f471dad9b9fd715fe802ea9d10519
nixieonix/Python
/shoppingCart.py
903
3.703125
4
seznam = { "mleko": 2.25, "kruh": 1.22, "jajca": 2.5, "paprika": 3.1 } nakupovanje = True vsota = 0 maxVrednostNakupa = 5 seznamIzdelkov = [] while nakupovanje: #prodajalka nas prasa kaj bomo kupili izdelek = raw_input("Kaj nakupujemo?") if izdelek in seznam.keys(): seznamIzdelkov.append(izdelek) cenaIzde...
56d0bf24157e126df257ee8fdb5b3f5549a872c1
MikeEngerer/project-euler
/solutions/56.py
438
3.59375
4
from time import time def digit_sum(num): arr = list(str(num)) sum = 0 for i in range(0, len(arr)): sum += int(arr[i]) return sum def max_digit_sum(): highest = 0 for base in range(1, 100): for exp in range(1, 100): current = digit_sum(base ** exp) if (current > highest): highe...
62ba9d0c6c7e2291a47c9e8d973b28cc6387fc81
bomcon123456/DSA_Learning
/Python/Chapter 1/ex6_7.py
88
3.515625
4
n = int(input("Integer: ")) print(sum([k * k if k % 2 == 1 else 0 for k in range(n)]))
94fdab43efc35a1785eeeb17b4fd7b2e62927751
deepalichugh/PythonProgramming
/check_integer_type.py
187
3.953125
4
def check_integer_type(n): if n >= 1: return "Positive" elif n<0: return "Negative" else: return "Zero" n = int(input()) print(check_integer_type(n))
ba274544beb316a38f273e064011e10481dcb8b8
ZhenyaTurkina/HSE-Programming
/hw7/hw7.py
1,735
3.765625
4
import re def get_word(filename): # эта функция прочитывает файл и сплитит текст по возожным знакам прtпинания with open (filename,encoding = 'utf-8') as f: text = f.read() lines = text.splitlines() a = len(lines) b = re.split(r'[.,“"?—:;*!\n\s\t]+',text) a = le...
31c88290a7cf193c0d9f0d9def55329863c77bc2
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/222/users/4272/codes/1578_2897.py
179
3.703125
4
# Use este codigo como ponto de partida # Leitura de valores de entrada e conversao para inteiro num = int(input("11")) dobro = num*2 # Impressao do dobro do numero print(dobro)
8dbfd0e742469f794bf50f8b10290b1ecb7b6d7a
BUPT402/cs231_idea
/assignment1/cs231n/classifiers/softmax.py
3,192
3.828125
4
import numpy as np from random import shuffle def softmax_loss_naive(W, X, y, reg): """ Softmax loss function, naive implementation (with loops) Inputs have dimension D, there are C classes, and we operate on minibatches of N examples. Inputs: - W: A numpy array of shape (D, C) containing weights. (3073,...
a1a0b13d97172b102c2ecb51efd9122c8eed62b7
sdytlm/sdytlm.github.io
/downloads/code/LeetCode/Python/Flatten-Binary-Tree-to-Linked-List.py
880
3.9375
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def flatten(self, root): """ :type root: TreeNode :rtype: void Do not return anything, modify ro...
f6bfbf222a60c5d4c3863d5eb2ed4c8c84b7143d
kimdanny/Coding-Questions
/Algorithms/Jumping_on_clouds.py
633
3.578125
4
# https://www.hackerrank.com/challenges/jumping-on-the-clouds/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=warmup def jumpingOnClouds(c): current = 0 endIndex = len(c)-1 jumps = 0 while current != endIndex: try: if c[current+2]==0: ...
3a08664592791e9c44e4bcfb4d7cc68b7d1bfb7a
Alfred-Vivek/Competitive-Programming
/Week 1/Day 5/rotation point.py
990
3.84375
4
def countRotations(allwords,low,high): if (high < low): return 0 if (high == low): return low mid = low + (high - low)/2; mid = int(mid) if (mid < high and allwords[mid+1] < allwords[mid]): return (mid+1) if (mid > low and allwords[mid] < allwords[mid - 1]): r...
07fd823e5239723cf43753396ce26b764c9e8354
priteshbonde/LearnPython
/3_control_flows.py
389
3.984375
4
#> dfdsfds #! If condition a = 1 if a==1: print("yes") else: print("no") if a==1: { print('yes') } else: print("no") #! If else condition if a==1: print("one") elif(a==2): print("two") else: print("Something else") #! while while a<10: a=a+1 print(a) #! for for a in ["a", ...
5206770dec627c02b70bb625ab37bf726affafb2
rosexw/Practice_Python
/10-List_Overlap_Comprehensions.py
1,700
4.09375
4
# 10: List Overlap Comprehensions # The exercise for this week is going to be revisiting an old exercise (see Exercise 5), except require the solution in a different way. import random # Take two lists, say for example these two: a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1...
74b0d5d86128ef0d872801090f79ca2cad2c364c
PythonProgramm3r/PracticePython
/collatz.py
370
4.0625
4
def collatz(usrinpt): if(usrinpt == 1): return elif(usrinpt%2 == 0): print(str(usrinpt//2)) return collatz(usrinpt//2) elif(usrinpt%2 == 1): print(str((3*usrinpt+1))) return collatz((3*usrinpt+1)) numberToCollatz = int(input("Digit to collatz: ")) collat...
4197d10387be4a9f775f42c58e61717eb565d20e
OC-Coder/Python-Classes
/Class 3/Class 3 Solutions/3.1 - Grades.py
602
4.25
4
#Defines a function called letter_grade that takes one variable as input def letter_grade(grade): if grade >= 90: return "A" elif grade >= 80: #No need to check whether grade < 90, since if it wasn't the first if statement would have been called return "B" elif grade >= 70: #Same as above. Elif is only calle...
ad32f9cff32e84d19563f7f894faf0510b75deb8
safwanvk/py
/exerices/ex1.py
951
4.125
4
# Make a Python program that prints your name. print('safwan') # Make a program that displays the lyrics of a song. print('Vathikkalu vellaripravu \n Vaaku kondu muttanu kettu \n \n Vathikkalu vellaripravu \n Vaaku kondu muttanu kettu \n Thulliyamin ullil vannu \n Neeam kadalu \n Priyane neeyam kadalu') # Make a prog...
39e95ccf07081c32aebb7fd7bae6d3e2fc826cc8
mmrobi/Python
/DataStructures/matchmaking.py
687
4.03125
4
# Write function that joins the two lists by matching one girl with one boy in a new list # If someone has no pair, he/she should be the element of the list too # Exepected output: ["Eve", "Joe", "Ashley", "Fred"...] girls = ["Eve", "Ashley", "Claire", "Kat", "Jane"] boys = ["Joe", "Fred", "Tom", "Todd", "Neef", "Jeff...
fb721aa495c42a788c4af8c8eb514ff981e4e459
jaronjlee/algorithms
/hacker_rank/get_max_colors.py
1,224
3.5625
4
# def getMaxColors(prices, money): # totalSum = sum(prices) # L = 0 # R = len(prices)-1 # incrementR = 1 # previousRightSum = 0 # leftSum = 0 # rightSum = 0 # while L < R: # currentSum = totalSum - leftSum - rightSum # if currentSum > money and R == len(prices)-1: # ...
4c496af484bddc04ddb37dad7343ec25cdc89356
Wamique-DS/my_world
/Lists - one of the Data Structure in Python....py
10,070
4.40625
4
# coding: utf-8 # # Lists: One of the Type Of Data Structure in Python # In[2]: ''' Lists: Collection of values in square bracket,elements in a list are separated by comma and enclosed within a square bracket.Elements can be of samne or mix type, list is a sequence of any elements and it's mutable as wel...
6a15b4739ce073aabde6123f7f637aa694d4271b
MahjubeJami/Python-Programming-01
/python numbers/mod07-exe_7.2.py
830
4.28125
4
""" 2. The data type integer signed range is from -2,1471483,648 to 2,1471483,648 (4 bytes). Write a program that determines the range of numbers for an integer based on the number of bytes it can encode (Hint integral type with n bits can encode 2n numbers). Console: Enter number of Bytes you would like to dete...
e5bcdaa58257ecad81638e89946f0dd0714797a6
vraj152/projectcs520
/readingData.py
2,419
3.5
4
import numpy as np """ This method reads entire file and returns as a list Params: souce_file = file path total_images = dataset size length = length of pixel width = length of pixel Returns: Entire file in list """ def load_data(source_file, total_images, length, width): datasetFile = op...
bf602f9d7a935ffd5257af22bc926a1cd6d78ca3
d-laub/TritonHacks-Data-Viz
/utils.py
7,286
3.625
4
#### TODO #### ## subset() # Add Nine Nations of North America? import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns import plotly.express as px import pickle # load_data: loads and returns datasets def load_data(): geo_cnty = pickle.load(open('Datasets/geocnt...
b50769e10e73bd6e704260c6ba73a06b1890f22c
Yun-Kim/handwritten_digits_recognizer
/scipy_neural_network.py
2,248
3.65625
4
import numpy as np import matplotlib.pyplot as plt from sklearn import datasets import scipy def sigmoid(x): return 1/(1+np.exp(-1*x)) def first_order_sigmoid_derivative(x): return sigmoid(x)*(1-sigmoid(x)) class NeuralNetwork: def __init__(self): self.input = np.zeros((64, 1)) self.weigh...
8c8bd78a5c2d6c4625df9bf7f63bf7eeb1bf6a80
strawsyz/straw
/ProgrammingQuestions/leetcode/260-2.py
548
3.546875
4
# Given an array of numbers nums, in which exactly two elements appear only once and # all the other elements appear exactly twice. # Find the two elements that appear only once. class Solution: def singleNumber(self, nums: List[int]) -> List[int]: diff = 0 for num in nums: diff = diff...
4f2e88f5b3e8b6f6c2890cc4fdccb279e95c27fb
phuwadonop/Python-Lab
/MBC.py
169
3.578125
4
from math import asin, pi import math ########################## AB,BC = int(input()),int(input()) print(round(math.degrees(math.atan(AB/BC))),chr(176),sep='')
3bc5390ba573e96ff3031a826a45362b97c7d626
IvayloSavov/Programming-basics
/exams/6_7_July_2019/shopping.py
660
3.875
4
# 1. Read input data budget = float(input()) number_video_cards = int(input()) number_processors = int(input()) number_ram_memory = int(input()) # 2. Prices price_video_card = number_video_cards * 250 price_processors = price_video_card * 35/100 * number_processors price_ram_memory = price_video_card * 10/100 * number_...
a3eaebee6efeb471d82cc7b2319c1a9b694b6574
Javierzs/Algoritmosyprogramacion-Grupo2Ciclo4
/Semana6/try.py
251
3.90625
4
c=0 while True: try: if(c==3): print("demaciados intentos") break contraseña=int(input("Digite numero: ")) break except ValueError: c=c+1 print("Solo se puede ingresar numero enteros") print("demas lineas")
79747b79c64619a433760c998bb74e379145eb94
alelimasilva/Exercicios-em-Python
/ex042.py
843
3.953125
4
''' Crie um programa onde quatro jogadores joguem um dado e tenham resultados aleatórios. Guarde esses resultados em um dicionário. No final, coloque esse dicionário em ordem, sabendo que o vencedor tirou o maior número no dado. ''' from random import randint from time import sleep from operator import i...
ee361b6e7ec840c3cc9a8903986701d8653097a1
kwokmoonho/Game_Python
/Asteroid/angle.py
309
3.734375
4
""" Author: Kwok Moon Ho Class: Angle It use to determine the obj angle of movement """ class Angle: def __init__(self): ##construction self.angle = 0.0 @property def angle(self): return self._angle @angle.setter def angle(self, new_angle): self._angle = new_angle
52049647d3d135058503fe0e689a2908a1e6384a
rickyma9/15112TermProject
/objects.py
5,812
3.703125
4
import pygame import math # all the objects that are used in making the game and playing it # add time parameter, so the thing knows what time to come in class Circle(pygame.sprite.Sprite): def __init__(self, x, y, r, screen): self.x = x self.y = y self.r = r self.screen...
8420314d3eb385a1063a5828c756ba4a7069c295
Vision5011/selfteaching-python-camp
/exercises/1901100372/1001s02E04_control_flow.py
247
3.765625
4
for a in range(1,10): for b in range(1,1+a): print(f'{a} * {b} = {a*b}',end='\t') print() for i in range(1,10,2): j = 1 while j <= i: print(f'{i} * {j} = {i*j}',end='\t') j+=1 print()
1f586a2149a01e71678f979c661f716df15a9d1c
min-0/pitapat_python
/3장 실습문제.py
1,088
3.921875
4
# 3장 실습문제 3.1 # fahrenheit = eval(input('Enter the temperature in degrees Fahrenheit: ')) # celsius = 5/9 * (fahrenheit-32) # print('The temperature in degrees Celsius is', celsius) # 3.2 (a) # age = eval(input('age: ')) # if(age >= 62): # print('You can get ypur pension benefits') # (b) # lst = ['Musial', 'Aaraon...
cde6b771f54983b04d0a562fac3a04fde240c3e1
0as1s/leetcode
/653_two_sum_iv_input_is_a_bst.py
1,035
3.8125
4
class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def findTarget(self, root, k): return self.f(root, root.left, k) or self.f(root, root.right, k) def f(self, root1, root2, k): if not root1 or no...
6ecea716c2fe525d5cd5d4899fabd375c4de2d2f
xmonkee/Shards
/Python/Elements_of_programming_interviews/test_all.py
573
3.609375
4
from partition import partition def listEqual(l1, l2): return len(l1) == len(l2) and all([l1[i] == l2[i] for i in range(len(l1))]) def test_partition(): def is_part(A, x): if all([y<x for y in A]): return true if all([y>x for y in A]): return true f = A.index(x) l = f w...
abc14685613013fa3b48f3193b153826f062525d
antonioravila/Exercicios-CEV-Python
/ex_026.py
261
3.84375
4
frase = str(input('digite uma frase: ')).lower().strip() print(f'a letra A aparece {frase.count("a")} vezes na frase ') print(f'a primeira letra A aparece na posição {frase.index("a")+1}') print(f'a ultima letra A aparece na posição {frase.rfind("a")+1} ')
a20aa9faa6c12e97cf3ba865faba7c28bf475dd3
sharbatc/seqhopfieldnet
/pattern_tools_seq.py
10,402
4.3125
4
""" Sharbatc changed the following for his semester project EPFL, Lausanne, March 2017. """ # The original documentation is given below """ Functions to create 2D patterns. Note, in the hopfield model, we define patterns as vectors. To make the exercise more visual, we use 2D patterns (N by N ndarrays). """ # This fil...
a694aac39e101bac2cfca02431ef46b20600a4a4
theshivambedi/Pythonprojetcs
/Bmicalci(2).py
198
4.34375
4
# How to calculate BMI in python height = float(input("enter your height in m : \n")) weight = float(input("enter your weight in kgs : \n")) bmi = int(weight/(height**2)) print(f"your BMI is {bmi}")
d3ba4ed0d18cc1e062e7e057ce767610e14acfe8
AlexandreL1984/Py4e
/ListDictionaryComparison.py
243
3.96875
4
# 9.1 Dictionaries, Py4E # This compares a list and a dictionary lst = list() lst.append(21) lst.append(183) print(lst) lst[0] = 23 print(lst) ddd = dict() ddd['age'] = 21 ddd['course'] = 182 print(ddd) print(ddd) print(ddd)
c7ef375a067bfd6274545839b3626c027500beec
nickfang/classes
/projectEuler/webScraping/problemTemplates/303.py
557
3.59375
4
# Multiples with small digits # # #For a positive integer n, define f(n) as the least positive multiple of n that, written in base 10, uses only digits â&permil;¤ 2. #Thus f(2)=2, f(3)=12, f(7)=21, f(42)=210, f(89)=1121222. #Also, <img src="project/images/p303_formula100.gif" style="vertical-align:middle;" alt="p303_f...
3e98bfc0f53bc81cfc963875dda94790097dcc1a
imyeego/PythonDairy
/Code/basic/if.py
583
3.640625
4
#!/usr/bin/python # _*_ coding:utf-8 _*_ ''' 布尔表达式,只要不为0或false,就为真 if True: print 'True' else: print 'False' if 0: print 'True' else: print 'False' if 4: # 非0即真 print 'True' else: print 'False' if -5: # 非0即真,无论正负 print 'True' else: print 'False' if 'liuzhao': # 字符串为真 print 'True' else: print ...
22d7fcca7988dd4a6c3fdc577e954817a8f1010e
Adamouization/ASP-Timetable
/src/Timetable.py
7,051
3.625
4
#!/usr/bin/env python """ University Timetable UI Generator DESCRIPTION: Script to parse the solved ASP Clingo output into JSON format and create a Tkinter UI. HOW TO RUN: Run with the following command from the command line, in the project's "src" folder: clingo -n 0 asp/timetable.lp asp/atoms.lp --outf=2 | python T...
48cc563aa780afff8f163ac799d0bdf1d7c00f56
szabgab/slides
/python/examples/pandas/so_top_countries.py
526
3.8125
4
import sys import pandas as pd filename = "survey_results_public.csv" if len(sys.argv) == 2: filename = sys.argv[1] df = pd.read_csv(filename) country_count = df['Country'].value_counts() N = 20 # Take the top N countries first = country_count.head(N) print(first) print(type(first)) # Series # first = country_...
2fa032071616249d82d09d98263d4f4b41217486
Hansung-Lee/TIL
/Algorithm/SWEA/5174_subtree.py
548
3.625
4
def check_node(node): global result if node: check_node(tree[node][0]) check_node(tree[node][1]) result += 1 T = int(input()) for t in range(T): E, N = map(int, input().split()) edges = list(map(int, input().split())) tree = [[0]*2 for _ in range(E+2)] for i in range...
707e872d6dea97b4cc3c02a20cfaf06900494073
deardosatria7/Python-Projects-Protek
/Chapter 07/Latihan/Menambahkan isi file.py
810
3.5625
4
try : namaFile = input ("Silahkan masukkan alamat file Anda : ") file = open (namaFile, "r") status = True file = open(namaFile, "a") while (status == True): isi_file = input ("Masukkan data yang ingin Anda tambah :") file.write(isi_file) file.write("\n") konfirmasi =...
4247aaa43853e6fe482bd4c7b3001f11254089fd
SanthoshKR93/Python_Anandology_Solutions
/Getting_Started/problem_8.py
153
3.96875
4
# what is the output of this code? x = 1 def f(): y = x x = 2 return x + y print (x) print (f()) print (x) # result is : 1 3 1
a41c9c8634fe256cc66088c314543264bddd5006
idobleicher/pythonexamples
/examples/functional-programming/decorators.py
1,117
4.9375
5
# Decorators provide a way to modify functions using other functions. # This is ideal when you need to extend the functionality of functions that you don't want to modify. def decor(func): def wrap(): print("============") func() print("============") return wrap def print_text(): ...
691ab48338138ca6823f0aa85bde2ff61a56792c
captainhcg/leetcode-in-py-and-go
/captainhcg/py/105-construct-binary-tree-from-preorder-and-inorder-traversal.py
957
3.84375
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def buildTree(self, preorder, inorder): """ :type preorder: List[int] :type inorder: List[int] ...
82ec6c6e556fbdea10546f268184b3778bc75860
hemzraj/hemalatha
/palindrome.py
150
3.828125
4
i=int(raw_input()) temp=i z=0 while(temp!=0): z=z*10+int(temp%10) temp=int(temp/10) if(x==i): print("palindrome") else: print("not a palindrome")
94c533167176e1548e74c7a782233b262f5da733
Akash-94/python-coding2
/find error2.py
1,120
4.0625
4
Employee = {"Name": "John", "Age": 29, "salary": 25000, "Company": "GOOGLE"} print(type(Employee)) Employee["Country"] = "United States" Employee["State"] = "Albuquerque" print(Employee) print("printing Employee data .... ") print("Name : %s" % Employee["Name"]) print("Age : %d" % Employee["Age"]) print("Salary : ...
d4f264c1e50cdc2cda370d32334e2fd2c97ed1e6
Dukon/py
/choice/msq.py
529
3.59375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import math def sqeq ( a=1.0, b=1.0, c=0.1 ) : try : D = b*b - 4*a*c if D < 0 : return [] else : x1 = ( -b + math.sqrt( D ) )/(2 * a) x2 = ( -b - math.sqrt( D ) )/(2 * a) return [ x1, x2 ] exc...
ef613420a8bf6f00158d413b79c848ce22d458a2
tukki-0000/io
/SPM_RPM_INPUT.py
2,203
3.578125
4
###直径80~130[mm]のタイヤを使用することを想定### ###速度5~13[m/s](18~46.8[km/s])を実現するモータに必要な回転数[SPM, RPM]と動力[W]を求める### #インポート import math #初期設定 Distance = 100000 #[mm] ######## 関数群 ######## #円周 Circumference def Circumference(Diameter): Circumference = Diameter * math.pi return Circumference #100m到達できる回転数 Complete_Rotatio...
38ec3c60f8006cbd5222953e7986fbfb6409fb43
nptit/python-snippets
/merge2-stack.py
1,541
3.734375
4
def merge(l1, l2): stack1 = l1[:] stack2 = l2[:] res = [] while stack1 and stack2: if stack1[0] <= stack2[0]: res.append(stack1.pop(0)) else: res.append(stack2.pop(0)) return res+stack1+stack2 def merge(l1, l2): stack1 = l1[:] stack2 = l2[:] res ...
f8708dd329daa27455ed251d763cc8e09e819627
haggbart/IN1900
/Øve/7.12.py
867
3.734375
4
class Sum: def __init__(self, fk, M, N): self.fk = fk self.M = M self.N = N def __call__(self, x): S = 0 for k in range(self.M, self.N+1): S += self.fk(k, x) return S def term(self, k, x): return self.fk(k,x) def test_Sum(): def fk(...
3dcce3eedda867ace1a850e3fce84b18be966580
15929134544/wangwang
/py千峰/day2函数/func07.py
677
4.03125
4
# 装饰器 """ 加入购物车、付款、修改收货地址... 判断用户登录状态, """ def func(num): a = 100 def inner_func(): nonlocal a nonlocal num num += 1 for i in range(num): a += 1 print("修改后的a的值为:", a) return inner_func # 调用函数 x = func(5) x() # 定义: # 函数作为参数 a = 50 f1 = f...
d772ec127a00c230ed9a39f137bcaa22aa6f3e82
darren573/Study_Python
/test/TestThree.py
304
3.71875
4
#!/usr/bin/python # -*- coding UTF-8 -*- """编程第一步""" # 斐波纳契数列 a, b = 0, 1 while b < 10: print(b) a, b = b, a + b 'end 关键字' # 关键字end可以用于将结果输出到同一行,或者在输出的末尾添加不同的字符 for x in (1, 2, 3): print(x, end=';')
0465d21b5819d94a8b601a9285323eda7f3c6927
keerti-1997/web-api-clinical-visit
/backend/filter.py
176
3.578125
4
import pandas as pd import numpy as np def get_data(data): print(type(data["value"])) df = pd.DataFrame(data["value"]) #print("Number of rows in the data :- ",df.shape)
cc1e6c0483e482adf4c81073f7bd878c4b3a78cd
Venkatesh123-dev/Python_Basics
/Day_11_02.py
848
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Sep 3 12:59:32 2020 @author: venky With a given integral number n, write a program to generate a dictionary that contains (i, i x i) such that is an integral number between 1 and n (both included). and then the program should print the dictionary.Supp...
1a0b47890ee654b786ed3519d9a944d5a9609824
snmsaj/Digital-Craft
/Week-1/Day-3/palindrome.py
243
4.34375
4
word = input("Please type in a word: ") reversed_word = "" for index in range(len(word)-1,-1,-1): reversed_word += word[index] if word == reversed_word: print(f"{word} is a Palindrome") else: print(f"{word} is NOT a Palindrome")
5e778ba91617ebb0b4c3df2b9449223706ad62f3
HigorSenna/python-study
/guppe/lambdas_e_funcoes_integradas/len_abs_sum_round.py
879
3.96875
4
""" Len. Abs, Sum, Round len() -> retona o tamanho de um iteravel abs() -> Retorna o valor absoluta de um número inteiro ou real sum() -> Recebe como parâmetro um iteravel, podendo receber um iteravel, retorna a soma total dos elementos, incluindo o valor inicial OBS: O valor inicial default é 0 round() -> retorn...
c80dee7d10a7e692e6a5ad9c402ac1699ba1c3b2
run-fourest-run/PythonBeyondTheBasics
/duringtheday.py
442
3.515625
4
from datetime import datetime x = 'SE unavailable' def not_during_the_day(f): def wrapper(*args): if 7 <= datetime.now().hour < 22: f(*args) else: print("none of the SE are available") return wrapper @not_during_the_day def ask_question(list_se): for y in list_se: ...
df5f36946a2d9eeccc52bc74e9bd1916384a3c0d
horatiuluci/report-game-theory-social-learning
/moran_process.py
2,548
3.75
4
# Horatiu Luci # import numpy as np import random import math import matplotlib.pyplot as plt def get_state(population): s = 0 for i in population: if i == 0: s += 1 return s def play_game(strategy1, strategy2, A): return A[strategy1][strategy2], A[strategy2][strategy1] def se...
95afcd957714b895135f212d32c2d9a399788978
Joes-BitGit/Leetcode
/leetcode/town_judge.py
1,707
3.578125
4
# DESCRIPTION # In a town, there are N people labelled from 1 to N. There is a rumor that one of these people is secretly the town judge. # If the town judge exists, then: # The town judge trusts nobody. # Everybody (except for the town judge) trusts the town judge. # There is exactly one person that satisfies prope...
09d7c1749b1cbbe0934e04a41ecc563f6f3f04fa
luamnoronha/cursoemvideo
/ex.041.py
464
4.15625
4
from datetime import date nascimento = int(input('Qual ano que você nasceu ?:')) atual = date.today().year idade = atual - nascimento print('você tem {} anos.'.format(idade)) if idade <= 9: print('E esta na categoria MIRIM') elif idade <= 14: print('E esta na categoria INFANTIL') elif idade <= 19: print('E ...
b75fdae38fa0fbaccd763b7257fe9184719d6f50
mcewenar/PYTHON_INFO_I_BASIC
/Python algoritmos/No_importante/algoritmos guardar actualizado 1234 (2).py
4,887
4.0625
4
##print("Promedio de 5 notas") ##a=float (input("Ingrese la primera nota")) ##b=float (input("ingrese la segunda nota")) ##c=float (input("ingrese la tercera nota")) ##d=float (input("ingrese la cuarta nota")) ##e=float (input("ingrese la quinta nota")) ##a=a*0.30 ##print(a) ##b=b*0.15 ##print(b) ##c=c*0.15 ##print(c)...
8d6cab4d84e46974291343cb06549105a74cbbed
JuliaBrazolim/AprendendoPython
/PythonBrasil/EstruturaSequencial/IMC.py
198
3.609375
4
# -*- coding: utf-8 -*- print('Calculo de IMC') altura = float(input('\n Insira o valor da sua altura: ')) IMC = (72.7 * altura) - 58 print('Seu peso ideal é de ', round(IMC, 1), 'kilos')
4952d661fbbb9c92948fa315260e843252a54beb
Luis-Mercado94/ECE129
/cv_function.py
1,646
3.5
4
# File name model_test.py # Date of creation: May 16, 2020 # Author: Luis Mercado #Description: Take in a image from the raspberry pi camera, and classify # the image by using the CNN computer vision. Turn on/off GPIO depending # on which classification the CNN returns #Function: Prepare # resize the images, and stor...
5a80bc4151ccbcfd3f5f2fe147bc09ded8f782c0
sangam92/https---github.com-sangam92-data_structure
/tree_operations.py
2,129
3.953125
4
""" Tree Traversal and Operations """ class Node: def __init__(self,data=0): self.left=None self.right=None self.data=data def display_tree(self): if self.left: self.left.display_tree() print(self.data) if self.right: self.right.display_tree...
17332b3b129fe349c7f1b47e003392c6e9669b9a
JackAMorton/Lesson1
/Lesson2/fun1.py
493
3.578125
4
# FUNCTIONS # Special relationship where each input has single output # input -----> Blackbox -----> Output # FUNCTION WITHOUT ARGUMENTS # def balls(): # print("Balls") # balls() # FUNCTION WITH ARGUMENTS # def func(a, b): # return a + b # print("The sum is", func(10,20)) # def func(a=10, b=30): # return...
9d27fac0b13b4ce5ff0270d814604292057c5ac8
ByeongjunCho/Algorithm-TIL
/백준/4947_Bertrand.py
320
3.5
4
# 베르트랑 공준 M = 46 N = 47 while True: M = int(input()) if M == 0: break N = 2*M prime_num = [] for i in range(M, N+1): for j in range(2, i // 2 + 1): if i % j == 0: break else: prime_num.append(i) print(len(prime_num))
8bffa21400840fe4819d3517ed659d71d67c2eca
garethquirke/Web-API-and-Android-Client-Python
/Python/lambda1.py
498
4.25
4
# lambda is a way to make annoymous functions average = lambda x, y, z:(x + y + z)/3 print(average(10,20,30)) eligbleVoter = lambda age: True if age>= 18 else False print("i can vote when i am 17 years old.....") print(eligbleVoter(17)) # binary -> powers of two powerList = [lambda x: x**0, lambda x: x...
9da93f211d43489df690c085a17a126761bfc40d
sourabbsridhar/devops-setup
/calculator.py
1,523
4.375
4
# Implementation of a simple "Calculator" program # The calculator consists of four functions: add, subtract, multiply and divide def add(x, y): """ Function to add two numbers Parameters ---------- x : int/float First number to be added y : int/float Second number to b...
3f1ce06769563335f7c7e632fc3a090c64a1252d
gouthambs/Flask-Blogging
/flask_blogging/utils.py
516
3.828125
4
def ensureUtf(s, encoding='utf8'): """Converts input to unicode if necessary. If `s` is bytes, it will be decoded using the `encoding` parameters. This function is used for preprocessing /source/ and /filename/ arguments to the builtin function `compile`. """ # In Python2, str == bytes. # In...
38f7693db2fd90e7f4484f15a44dc9f0aa172146
manastole03/Programming-practice-2
/python2/Day 005/name_age.py
268
4.09375
4
# day 5 # 2. Create a function that can accept two arguments name and age and print its value. def name_age(name, age): print("Name: ", name) print(f"Age: {age}") n = input("Enter your Name: ") a = int(input("Enter your age: ")) name_age(n, a)
478bb7416f727b95fe76db0728db5e2a5eb1d60e
bhagatashish/practise_programs
/Reverse.py
1,352
4.0625
4
import itertools class Reverse: def reverse_string(self): a = ['nitin','subash','susu'] b = [] j=0 reverse=[] list= [] list3=[] for i in a : print[i] name= a[j] j=j+1 print(...
47dd4943082cf7157613c7c9145bd9562a72d925
nandini8/Cryptography_Algorithms
/Index_Calculus/modular.py
4,291
3.609375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Mar 3 21:08:55 2018 @author: brianhumphreys """ #import flint as ft import numpy as np ''' These are the functions that I personally wrote and tested ''' #inputs a negative number and modulus p. Converts negative to corresponding positive value in m...
963636bb28aeb2e0e3bd3857ad64743d56c60a20
lhd0320/AID2003
/official courses/month01/day17/exercise02.py
3,548
3.796875
4
from typing import List class StudentModel: """ 学生信息模型 """ def __init__(self, name="", age=0, sex="", score=0.0, sid=0): self.name = name self.age = age self.sex = sex self.score = score self.sid = sid # 学生编号 自增长 def __str__(self): return "%s的...
7f28f8ea36d683c2fa7ae3bac5d13f7988285850
williamjiamin/Pure_Python_for_DS_ML
/2.数据预处理/data_reader.py
659
3.90625
4
from csv import reader def read_csv(the_name_of_file_to_be_read): dataset=list() with open(the_name_of_file_to_be_read,'r') as file: csv_reader=reader(file) for row in csv_reader: if not row: continue dataset.append(row) return dataset def convert_st...
7f030f73ccecf029b12fc7a653cc72dfdd991eb2
Tan28-art/Python_Programs
/Class 11 Python Programs/Pyprograms/convert time from sec.py
142
4.25
4
#program to convert time in seconds to mins and secs t=int(input("Enter time in seconds here:")) print("Time is:",t//60,"Mins",t%60,"Seconds")
b0efb1233e09013a6fdd2c69122c07d65bceeaf9
DayGitH/Python-Challenges
/DailyProgrammer/DP20161107A.py
2,531
3.828125
4
""" [2016-11-07] Challenge #291 [Easy] Goldilocks' Bear Necessities https://www.reddit.com/r/dailyprogrammer/comments/5bn0b7/20161107_challenge_291_easy_goldilocks_bear/ Once upon a time, there lived an adventurous little girl called Goldilocks. She explored the world with abandon, [having a lot of fun](http://www.iv...
35e4e0fc224ca481e57b5fd542ac7b266bcbd0e5
Carvanlo/Python-Crash-Course
/Chapter 5/more_conditional_tests.py
845
4.3125
4
# equality and inequality phone = 'apple' print(phone == 'apple') print(phone != 'apple') # use lower() function car = 'BMW' print(car.lower() == 'bmw') print(car.lower() == 'BMW') # numberical tests age = 18 print(age == 18) print(age != 18) print(age > 16) print(age < 21) print(age >= 18) print(age <= 21) # and ...
cb9d8b3afd825fc1d8dce8c016fa94de46027f56
HiteshKhandelwal901/Data-Structures-And-Algorithms
/lsingle_linked_list.py
1,604
3.921875
4
#!/usr/bin/env python # coding: utf-8 # In[149]: class node: def __init__(self,data, next = None): self.data = data self.next = next class LinkedList: def __init__(self): print("inside inti") self.head = None self.currnode = None def insert(self,...
40a2b44f4de6b72719a5b6e8a071f007b5711274
sjr125697/PythonBasicDemo
/黄白作业.py
1,026
3.6875
4
sr="生人" jr="家人" class Dog: def __init__(self,newcolor,newname): self.color=newcolor self.name=newname def __str__(self): # print("一只%s的狗狗叫%s"%(self.color,self.name)) return "一只%s的狗狗叫%s"%(self.color,self.name) def act(self,judge): if self.name=="大黄": if jud...
7009c5236d09e5c6578274ca138febdb91879e81
yachu0721/Introduction-to-data-sciencl
/Week12/IDS_20200522_12.py
144
3.546875
4
weekdays = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'] for i, wd in enumerate(weekdays): print("{}:星期{}".format(wd, i+1))
d814a54546fb5176cb98bd8b7edab14b4f1e37fe
jigsaw2212/Learn-Python-The-Hard-Way
/ex19.py
1,229
4.28125
4
#Function and Variables def cheese_and_crackers(cheese_count, cracker_boxes): print "We have %d boxes of cheese" %cheese_count print "We have %d boxes of crackers" %cracker_boxes print "Man! That's enough for a party!" print "Let's get a blanket.\n" print "We can give the arguments to the functio...
afce9e98dcf606a2d766b275ff5ff154ee3454cf
PramaTSR/CP3-Norrarat-Thongkhumdee
/Assignments/Exercise5_1_Norrarat_T.py
118
3.6875
4
a = 10 b = 5 print(a,"+",b,"=",a + b) print(a,"-",b,"=",a - b) print(a,"*",b,"=",a * b) print (a,"/",b,"=",int(a / b))
5916795618142b752154002913fbaf62684deb74
hyang012/leetcode-algorithms-questions
/235. Lowest Common Ancestor of a Binary Search Tree/Lowest_Common_Ancestor_of_a_Binary_Search_Tree.py
1,634
3.921875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Leetcode 235. Lowest Common Ancestor of a Binary Search Tree Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nod...