blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
49713799dca629c6241c231cee6c665ba878eb31
miclindb/BioSim_G09_Michael_Daniel
/src/biosim/island.py
8,925
3.625
4
# -*- coding: utf-8 -*- """ Island Module """ __author__ = "Michael Lindberg, Daniel Milliam Müller" __email__ = "michael.lindberg@nmbu.no, daniel.milliam.muller@nmbu.no" from .cell import Ocean, Mountain, Jungle, Savannah, Desert from .animals import Herbivore, Carnivore class Island: """ Island class. Su...
0651263e6c6455bfacbe5fd2f7f54ac39cad0d60
Aries5522/daily
/2021届秋招/leetcode/面试真题/美团/美团.py
2,425
3.59375
4
import sys class UnionFindSet(object): """并查集""" def __init__(self, data_list): """初始化两个字典,一个保存节点的父节点,另外一个保存父节点的大小 初始化的时候,将节点的父节点设为自身,size设为1""" self.father_dict = {} self.size_dict = {} for node in data_list: self.father_dict[node] = node self...
5d47636a8a87897ea60e875853b2edfc91614d96
whigg/maidenhead
/maidenhead/__init__.py
2,291
3.84375
4
from typing import Tuple """## mlocs - Maidenhead toMaiden([lat, lon], level) returns a char (len = lvl*2) toLoc(mloc) takes any string and returns topleft [lat,lon] within mloc Beyond 8 characters is not defined for Maidenhead. """ def toLoc(maiden: str) -> Tuple[float, float]: """ input: maidenhead locator...
35d638266300040f9b11441c829f1601e6dec65c
pradeep-gnr/realtime_word_cloud
/utils/nlp.py
421
3.875
4
from nltk import word_tokenize from nltk.corpus import stopwords def tokenize(text): tokens = word_tokenize(text) words = [w.lower() for w in tokens if w.isalnum()] return words def filter_stop_words(tokens): filtered_words = [word for word in tokens if word not in stopwords.words('english')] return filtered_wor...
549e8eb8b865c152bf9cd0ea0fe3b47f09007305
LaxmanMaharjan/Python
/venv/Codes/Decorators/with_logging.py
826
3.625
4
import time import logging import functools def logged(method): """ Causes the decorated function to run and log the result and some diagnostic info :param method: :return: """ @functools.wraps(method) def inner(*args,**kwargs): #Record start time start = time.time() ...
fb55f62c6cecf3f2ecd74af7e4b57312235e361f
eldorbaxtiyorov/python-darslar
/20-functions/javoblar-20-06.py
351
3.828125
4
""" 18/12/2020 Dasturlash asoslari #20-dars: FUNKSIYADAN QIYMAT QAYTARISH Muallif: Anvar Narzullaev Web sahifa: https://python.sariq.dev """ def fibonacci(n): sonlar = [] for x in range(n): if x == 0 or x == 1: sonlar.append(1) else: sonlar.append(sonlar[x - 1] + so...
bd239decefaf26c68ddf1b51363914ab2ffadaf5
Jaymark-Nam/python_basic
/practice4_string.py
1,091
4
4
# string sentence = 'I wish I were a boy' print(sentence) sentence2 = "python is easy" print(sentence2) #slicing jumin= "950120-1654321" print("sex :" +jumin[7]) print("year :" +jumin[0:2]) print("month :" +jumin[2:4]) print("day :" +jumin[4:6]) #string python = "Python is Fancy" print(python.lower()) #all lower...
de2a2711415b04324770eeb730be2c30904cc3ef
mumarkhan999/python_practice_files
/Dictionaries/2_looping_techniques.py
1,870
4.25
4
# looping technique of dictionary knights = { ' gallahad ' : ' the pure ' , ' robin ' : ' the brave ' } print("=====================") print(1) print("=====================") for k in knights.keys(): print(k, knights[k]) # When looping through dictionaries, # the key and corresponding value # can be retrieved at ...
ab7b0d09e046f4cc26a0349f3001a2f874dfa119
PouringRain/Algorithmn
/26.py
626
3.59375
4
# -*- coding:utf-8 -*- # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: # 返回构造的TreeNode根节点 def reConstructBinaryTree(self, pre, tin): # write code here # 前序+中序-->二叉树 if not tin: return...
cf6d364266ff340469f803c78844917adb968ec2
osamascience96/CS50
/python/lists.py
189
4.0625
4
# define the set of names names = ["Harry", "Ron", "Hermoine", "Ginny"] # add the new element to the list names.append("Draco") # sort out the list of elements names.sort() print(names)
0e9422e854a0f8424746d9715314698fc838394d
gamesbrainiac/Project_Euler
/__2.py
393
3.703125
4
__author__ = 'Nafiul Islam' __title = 'Even Fibonacci numbers' def fibonacci(start=1): a, b = start, start yield start while True: _ret = a + b a, b = b, _ret yield _ret if __name__ == '__main__': total = 0 for i in fibonacci(): if i < 4*10**6 and not i % 2: ...
47ad326873e8c8cd332de25cce058f8e25e84295
shetty019/Python
/evenood.py
146
4.21875
4
num=(int(raw_input('enter the input: '))) if(num%2)==0: print ('The entered number is even') else: print ('the entered number is odd')
5c7893dcb5cf41fcc90552498f248fddf1cb6d1f
gavinaguiar/challenges
/singleNumber.py
623
3.953125
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. For example: Given nums = [1, 2, 1, 3, 2, 5], return [3, 5]. ''' def singleNumber(nums): xor=nums[0] for n in range(1,len(...
fe9a514d9fa39a22e54ef6d3043357deb5c9def9
mukuld/python
/again/04_volume.py
274
4.25
4
# Python program # 4 # Programmer: Mukul Dharwadkar # Date: 3 Nov 2012 # Program to calculate the volume of a cube. length = 8 width = 5 depth = 4 volume = length * width * depth print "The volume of the cube having length", length, "width", width, "and depth", depth, "is", volume
df511ebe0226262ba967674ddc6a679d1ca057a2
nataliecosta0/curso-python-dn
/semana_1/exercicios_aula_1/Ex06.py
641
4.21875
4
''' Exercício #6 Faça um programa que pergunte o preço de três produtos e informe qual produto você deve comprar, sabendo que a decisão é sempre pelo mais barato. ''' preco1 = float(input("Informe o preço do primeiro produto: ")) preco2 = float(input("Informe o preço do segundo produto: ")) preco3 = float(inpu...
ab1253e96f3c262b61b865aa2b549c928009598a
saurabh0471/DataStructure_and_Algorithms_Python_and_cpp
/HackwithInfy/Playing_with_Prime.py
885
3.78125
4
# Function for check prime. def is_prime(a): c = 0 if a > 1: for i in range(2, a // 2): if a % i == 0: c += 1 if c == 0: return True return False # Driver Code. for _ in range(int(input())): n = int(input()) if n < 1 : print(-1) c = 0 o...
d89d269714b0ed96276c48688aa02f454a3da59b
coquelin77/PyProject
/leetcode/I though I have idea/29. 两数相除.py
1,520
4.3125
4
'''给定两个整数,被除数 dividend 和除数 divisor。将两数相除,要求不使用乘法、除法和 mod 运算符。 返回被除数 dividend 除以除数 divisor 得到的商。 示例 1: 输入: dividend = 10, divisor = 3 输出: 3 示例 2: 输入: dividend = 7, divisor = -3 输出: -2''' class Solution: def divide(self, dividend, divisor): result = 0 if dividend == 0 or divisor == 0: ...
7d97479fa1af156f0b9ab4d3cde84b6ebab417c6
pbandi2020/Election_Analysis
/PyPoll_Datetime.py
3,542
3.96875
4
# A quick test before starting the code # my_string = "Hello!" # print(my_string) #********************************************************* #Election Analysis Psuedo Code #******************************************************** # Instantiate the CSV API import csv import os import datetime as dt # Get the current ...
c569e965e7694ec21c5dd9fbad7d9df8f5e67d60
edwardcodes/Udemy-100DaysOfPython
/Day-15/CoffeeMachineProject_angela.py
1,943
3.984375
4
from data import MENU, resources machine_on = True profit = 0 def is_resources_sufficient(ingredients): for item in ingredients: if ingredients[item] > resources[item]: print(f"Sorry there's no enough {item}") return False return True def process_coins(): print("Please ...
7b24631c319937f219f898de2f2c624c2d912e89
Aditya-Pundir/VSCode_python_projects
/VS_Code_Folder_2/python_learning_from_cwh_course/string_slicing.py
215
4.15625
4
myStr = "Aditya is a programmer." print(len(myStr)) # print(myStr[-11:-2]) # ——> Negative indices(This is same as [12:21]) # print(myStr[12:21]) # To reverse a string: # print(myStr[::-1]) # print(myStr[::-2])
297b6aa43fff09c02d837f1a58ede03ef4a8903b
toeysp130/Lab-Py
/lab2-3.py
260
4.03125
4
#watcharakorn# qty = int( input( "Enter number product : ") ) price = float( input( "Price per unit : ") ) total = price * qty print( "Total money : ", total) pay = float( input( "Enter pay money : ") ) change = pay - total print( "Money change : ", change)
08ef2ed502a2b70362cd47d35d33bc4a94b1a66d
camilooob/pythonisfun
/allmethodtogether.py
488
3.8125
4
class Player: teamName = 'Liverpool, soy class method' # class variables def __init__(self, name, text): self.name = name self.text = text # creating instance variables @classmethod def getTeamName(cls): return cls.teamName @staticmethod def demo(): print ("Soy static method."...
d17e7fae336c83b5580327ddbe4ea54b50db304a
Engrsolomighty/my-first-website
/rasheed/calculator.py
543
3.703125
4
def Add(x,y,z): print(x+y+z) Add(5,6,7) class calculator: color ='red' # properties battery = 2 def Add(x,y,z): #method print("addition ",x+y+z) def Subtr(x,y,z): #method print("subration ",x-y-z) def Multiply(x,y,z): # method print(" Multiply ",x*y*z) ...
2d1bbd4b78cda602eace995167c23036ada14c3a
23thibja/code
/thibeault_unit1_practice.py
2,250
3.9375
4
#!/usr/bin/env python3 # PART A print("welocme to information Technolgy\n\nProgramming and\nWeb Development") print("") print(" _ ___________\n| | / /_ __/ |\n| | /| / / / / / /| |\n| |/ |/ / / / / ___ |\n|__/|__/ /_/ /_/ |_|\n") # PART B print ("A lighting flash:\nbetween the forest trees\nI have...
ecdb9e59a97ef1a613a2aa5e4af276aebe6ee8ad
vadim0311/python
/1-9.py
54
3.546875
4
a=0 while a!=10: a=a+1 x=a**2 print(x)
43b298ac7cdeee8ecc3a88d7d5e45322169e91d4
PokerAI/Poker-Game
/poker-hand-evaluator/CT.py
788
3.8125
4
"""card_translate.py""" import arrays """card_translate(rank, suit): Translate the card into the evaluator's inner representation and return it. rank: (Number) (deuce=0,trey=1,four=2,five=3,...,ace=12) suit: (String) 's','h','c','d' """ def card_translate(rank, suit): suitInt = 0 if suit == 's': ...
e47166dcabccfcf8e959a516288c30b0190ecb5b
byrenx/algorithms-exercise
/count_inversion_using_mergesort.py
1,359
4.0625
4
def gelistintegers(file_name): file_content = open(file_name) lst = [] for num in file_content: lst.append(int(num)) file_content.close() return lst def mergesort(lst): '''Recursively divides list in halves to be sorted''' if len(lst) == 1: return lst, 0 middle = int(l...
7cc0c4188ca37edbcd1a6102f082cdc8e0854535
mjimenez421/QuantLabEx
/build/lib/src/outputBuilder.py
4,893
4
4
import csv import os # Throughout class, "row" is used to denote data from the output file # e.g, "new_row" is data to be written to the output file class OutputBuilder: #class attributes to represent fields of the csv file __iTime = 0 __iSymbol = 1 __iQuant = 2 __iPrice = 3 __oSymbo...
765b9712520f4f8b08ac13ca4bc11629dab9dc11
adityakangune/HackerRank-Problem-Solving
/Funny String.py
641
3.5625
4
l = [] lr = [] dl = [] dlr = [] def FunnyString(s): for i in s: k1 = ord(i) l.append(k1) for j in r: k2 = ord(j) lr.append(k2) # print(l) # print(lr) for i in range(1 , len(l)): dl.append(abs(l[i] - l[i-1])) # print(dl) for i in range(1 , l...
06222657f38c48b418fb798c3e79d2830a12c5f5
srinijakalluri/Python-Learning
/Day-4-lists.py
839
4.5625
5
#creating and printing a list fruits = ['apple', 'mango', 'grapes'] print(fruits) #adding elements to a list fruits.append('cherry') print(fruits) fruits.insert(1,'kiwi') print(fruits) #length of the list print(len(fruits)) #replacing an element fruits[1]= 'banana' print(fruits) #deleting elements ...
862241736566821695eaa5805f0df4ec209c763b
kucengorenji/Python-tutorial-Youtube
/11_casting/main.py
457
4.1875
4
# Casting in python x = int(1) y = int(4.123) z = int("3") print("---------------------------------------------") print(x) print(y) print(z) print("---------------------------------------------") x = float(1) y = float(4.123) z = float("3") print(x) print(y) print(z) print("-----------------------------------...
ae3d9f5b6dcce57ae5341e9a6f5af2c478209ee2
saikrishna1909/Python-Programming
/week4(c).py
235
3.734375
4
num = int(input("Enter the length of the list:")) lis = [] print("Enter the elements of list:") for i in range(num): e = eval(input()) lis.append(e) filters = lambda x:x*2 result = map(filters,lis) print(list(result))
14b146706a8ee3c554725fc56af29cdbac0d7dcc
nyqtofovian/py_folder
/test17.py
89
3.6875
4
list1 = [7, 5, 9, 5, 2, 0, 3, 6, 8, 1] for i in range(len(list1)): print(list1[0:i])
f1628a947a172dec520221f2f8fc620502ce9adf
AdityaSharma6/Python
/new folder/Project14.py
1,481
4.125
4
# ********************************************************** # Assignment: Project 14: List Remove Duplicates # # Description: Write a program (function!) that takes a list # and returns a new list that contains all the elements of # the first list minus all the duplicates. # # Author: Aditya Sharma # # Date Start: (...
43c1b02a53a602131446223a590b4e978ea708de
incrediblejustin/PythonProgramming
/Python入门/类-对象/02-protect.py
994
4.125
4
class Point: def __init__(self, _x, _y): self.__x = _x # 属性前加__, 变为私有属性,类内可修改, 类外不可修改 self.__y = _y def __str__(self): return "__x = %d, __y = %d"%(self.__x, self.__y) def setx(self, new_x): self.__x = new_x def sety(self, new_y): self.__y = new_y # ...
d371c4c13a5d7408967c2d517730a7aa7f39f3fa
syashakash/codeBase
/randoms/8puzzle_bfs.py
4,489
3.890625
4
import random from collections import deque, namedtuple from operator import eq class Puzzle(namedtuple("PuzzleFields", ["board", "width", "zero_at"])): """ A class representing an '8-puzzle'. - 'board' should be a square list of lists with integer entries 0...width²-1 e.g. [[1,2,3],[4,0,6],[7,5,8]...
043f4a35bcb80f35ebe70d56f860cfeefc35e047
ksuarz/hundred-days
/text/piglatin.py
815
4.21875
4
#!/usr/bin/env python ''' Converts words to pig latin. This is a very naive implementation. All non-alphanumeric, non-whitespace characters are treated as part of a word. ''' import sys if len(sys.argv) < 2: print 'Usage: piglatin.py [TEXT]' else: # First, build up our vowels and consonants start, end = o...
32ad24dbfb9a5f211b1673db77d339de670664c8
roaden/adventofcode2015
/1.py
242
3.65625
4
#Find the floor floor = 0 #get the input fin = open('input1.txt', 'r') theMap = fin.readline().strip('\n') #( goes up, ) goes down for i in theMap: if i == '(': floor += 1 elif i == ')': floor -= 1 print(floor)
50779020d2baa3bcbef5765289d84cfc64cfba4f
Nanutu/python-poczatek
/module_2/zad_38/main.py
809
3.578125
4
class Product: pass class Order: pass class Apple: pass class Potato: pass if __name__ == "__main__": apple_1 = Apple() apple_2 = Apple() potato_1 = Potato() potato_2 = Potato() order_1 = Order() order_2 = Order() order_3 = Order() order_4 = Order() order_5 = ...
7e285caa54b85feb70b2f03f011085a69adceecd
Roberto117/Rush_Hour_Solver
/main/Car.py
2,763
4.03125
4
from Orientation import Orientation import collections #Structure to keep the coordinates of a car Coordinates = collections.namedtuple('Coordinates', ['x1', 'x2', 'y1', 'y2']) MAX_CAR_SIZE = 3#the biggest size a car can be MIN_CAR_SIZE = 2#the minumum size a car can be class Car(): initial_x = 0 #the first x positio...
a84a8226495e5017648ee8e165d5d85091ddbe25
github-mohsinalam/Python
/Advance Function/together.py
402
4.15625
4
#Write a function called together that takes three parameters, the first is a required parameter that is a number (integer or float), #the second is a required parameter that is a string, and the third is an optional parameter whose default is ” “. #What is returned is the first parameter, concatenated with the second...
61f3ca6f7ebf4a82b83fb05e7a1a4be9bb8c02f5
Leownhart/My_Course_of_python
/Geek University/Seção 5/Exercicios/EX15.py
601
3.609375
4
''' 15 - Usando um switch, escreva um programa que leia um inteiro entre 1 e 7 e imprima o dia da semana correspondente a este numero. Isto é, domingo se 1, segunda-feira se 2, e assim por diante. Obs: if, elif, else no caso do Python. ''' opção = int(input('Informe um número [1 a 7]: ')) if opção == 1: print('...
3eddbb39c4e97b6b7149901622885d397580ed3c
sheikh210/LearnPython
/functions/is_palindrome.py
188
3.796875
4
def is_palindrome(string: str) -> bool: return string[::-1].casefold() == string.casefold() print(is_palindrome("racecar")) print(is_palindrome("cat")) print(is_palindrome("Radar"))
811a99f35ac4ed58849835db81539e01035e3b62
miaopei/MachineLearning
/LeetCode/github_leetcode/Python/shortest-unsorted-continuous-subarray.py
1,708
3.90625
4
# Time: O(n) # Space: O(1) # Given an integer array, you need to find one continuous subarray that # if you only sort this subarray in ascending order, # then the whole array will be sorted in ascending order, too. # # You need to find the shortest such subarray and output its length. # # Example 1: # Input: [2, 6, 4...
522b1b01a64b08202f162b7fae780dbf2219066e
szhongren/leetcode
/473/main.py
1,692
4.3125
4
""" Remember the story of Little Match Girl? By now, you know exactly what matchsticks the little match girl has, please find out a way you can make one square by using up all those matchsticks. You should not break any stick, but you can link them up, and each matchstick must be used exactly one time. Your input w...
8c4e51b1a4ef78adced5b5577f13e07e987183ed
Aasthaengg/IBMdataset
/Python_codes/p03085/s321247736.py
132
3.609375
4
b = input() lst = [["A", "T"], ["G", "C"]] print(lst[0][lst[0].index(b) - 1]) if b in lst[0] else print(lst[1][lst[1].index(b) - 1])
c4191ac7113c9fb584a04e1831409eb421abb7eb
Md-Saif-Ryen/roc-pythonista
/Competitive Codes/is_sastry_num.py
273
3.515625
4
import math #183 is a sastry number as 183184 is a #perfect square number of 432 def sastry_num(n): """returns True if a number n is sastry number,False otherwise""" num = str(n) + str(n+1) sqt = math.sqrt(int(num)) if int(sqt) - sqt == 0: return True return False
81ba5b9b1c7b45750c69d29eae90e0c5d9503677
vijaykarthik123/icing
/icing/__old/parallel_distance_old.py
10,948
3.671875
4
import numpy as np import multiprocessing as mp def _dense_distance_dual(lock, list1, list2, global_idx, shared_arr, dist_function): """Parallelize a general computation of a distance matrix. Parameters ---------- lock : multiprocessing.synchronize.Lock Value returned from multiprocessing.Loc...
77fe1c9610212c84a5cd3ea2793392603d5564fb
gkouretas/evision-scraper
/directory_setup.py
753
3.578125
4
import os from datetime import datetime def create_dir(dir): if not os.path.exists(dir): # checks to ensure no duplicate directories exist (shouldn't ever happen) os.makedirs(dir) # creates directory return dir def dir_exists(dir): # checks to see if file downloaded before resuming while(True): ...
a82e9d7d1b991d87b9686d4079d6ccae2edf125b
xiaoruijiang/algorithm
/.leetcode/108.将有序数组转换为二叉搜索树.py
1,438
3.796875
4
# # @lc app=leetcode.cn id=108 lang=python3 # # [108] 将有序数组转换为二叉搜索树 # # https://leetcode-cn.com/problems/convert-sorted-array-to-binary-search-tree/description/ # # algorithms # Easy (67.94%) # Likes: 325 # Dislikes: 0 # Total Accepted: 49K # Total Submissions: 70.8K # Testcase Example: '[-10,-3,0,5,9]' # # 将一个按...
b16a43a1a498394691bb400a7b4d5a6c9420ee23
klo9klo9kloi/TJHSST-AI
/ai/Graph Search/bfs_Torbert_1_2017jzou.py
1,909
3.59375
4
def findInfo(start, end, dict): queue = Queue() nextlevel = Queue() lvl = {} parents = {} level = 1 lvl[start] = 0 parents[start] = None nextlevel.put(start) queue.put(nextlevel) found = False while queue.empty() == False: current = qu...
4c8c7a899992a034872fd606fcf1f6f36990617f
Saikiran2457/Innomatics_Internship
/Day - 5/3_Groups and Group addict.py
112
3.578125
4
import re S=input() a = re.search(r'([A-Za-z0-9])\1+',S) if a: print(a.group(1)) else: print(-1)
264f48813c2c9115d7ce7947e5af1165eaaf2370
u101022119/NTHU10220PHYS290000
/student/100022141/HW3/Sorting.py
576
3.921875
4
import random def random_list(N,a,b): x=[] for i in range(N): x.append(random.randint(a,b)) return x def selection_sort(x,N): print random.sample(x,N) def insertion_sort(x,N): for i in range(N): x.append(random.randint(a,b)) print x def bubble_sort(x): for i in range(len(x)...
e67ce16a2e1da2a679c0b6a4a38ba1944596d0de
eturanalp/Python-read-Excel-and-left-join
/rs_credit_debit_data_proc_exercise.py
4,253
3.625
4
# coding: utf-8 # In[ ]: # OVERVIEW and APPROACH # This python program separates the matched records from the unmatched ones after reading data from URL. # # I had two possible solutions in my mind. The first one was to iterate through the data set and # for each record identify if there is matching credit\debit. W...
530b48ac50ee05590c4a7010a3720ea4b666ec02
nyakerariomokaya/andelabs3
/missing_number_lab.py
539
3.859375
4
def find_missing(list1, list2): list3 = [] l1 = len(list1) l2 = len(list2) for x in range(len(list1)): for y in range(len(list2)): if len(list1) ==0: return 0 if len(list2) == 0: return 0 elif l1 ==l2: return 0 ...
c3e043df404931e4b4c92bc70b9965787b95e7d5
Lusius045/LucioRP
/Primeros Condicionales/Iniciales2/complementarios/TP5.py
490
4.09375
4
print("-------------------------------------------------------") print("VELOCIDAD DE DOS VEHÍCULOS") print("-------------------------------------------------------") print("Ingrese la velocidad de dos vehículos:") v1 = float("Vehìculo 1: ") v2 = float("Vehìculo 2: ") print("Ingrese la distancia:") dis = floa...
de167b900a5edb09e4d6f8cad0150da0800c0825
extraname/sometask
/task.py
6,589
3.546875
4
from math import factorial """ Task 1. Если мы из корректно записанного арифметического выражения, содержащего числа, знаки операций и открывающие и закрывающие круглые скобки выбросим числа и знаки операций, а затем запишем оставшиеся в выражении скобки без пробелов между ними, то полученный результат назовем правиль...
4e559e59d88e0fc08927505b2aca7591f7cfb042
SnehalSutar9823/PythonAssignment4
/Assg4_1.py
165
3.765625
4
def main(): number=int(input("Enter number:")) ans=lambda number : number * number print(ans(number)) if __name__=="__main__": main()
0e0d2f4d12c5d503f50997bdd6ef6941b56f2695
adinhobl/GeneticAlg
/GA.py
10,695
3.984375
4
import numpy as np import random import pandas as pd import matplotlib.pyplot as plt import matplotlib.animation as animation from typing import List, Dict, Tuple, Any # Inspired by: http://alturl.com/f6mot class City: def __init__(self, x: float, y: float) -> None: # init defines a single city's locatio...
645912292753b747440d66dbd1ba49e09f16bb12
TJSGITTO/Project01
/Test01.py
1,252
4.1875
4
#populate a list of students student_names = ["Mark","Katarina","Jessica","Connor","Ian","Natalie", "Brad","Amy","Sarah","Kelly"] Building_materials = ["Studs", "Sheetrock", "Fastners", "Doors", "Lights"] #Adding a name to the list #student_names.append("Homer") #Printing the list using for loop #x=0 #for name in st...
576913e1b39a6e703fe2e433de664d031a481e3c
Fischerlopes/EstudosPython
/cursoEmVideoMundo3/ex093.py
911
3.984375
4
# Crie um programa que gerencie o aproveitamento de um jogador de futebol. # O programa vai ler o nome do jogador e quantas partidas ele jogou. Depois vai ler a quantidade de gols feitos em cada partida. # No final, tudo isso será guardado em um dicionário, incluindo o total de gols feitos durante o campeonato. jogado...
2b8c44fd3cbeffdfd1ba11fe7e842e6bc3c6df3c
dtrodger/undergrad-python
/lists.py
1,356
4.1875
4
import random # David Rodgers # INFO-I 210 # Define functions that contain nouns, verbs, and abjective in lists. # Each function should return an item from its list when called. def random_noun(): nouns = ["Carrot People","Zombie Fat Albert","potato salad","Nick Cage","Steve Buscemi"] return nouns[random.ran...
ac5066fb72fb52966c523a9d0fe350d4b376712d
Hanjongwon/algorithm
/11_dynamic programming/fibonacci.py
628
3.9375
4
import time start_time = time.time() # def fibonacci(n): # if n < 2: # return n # else: # return fibonacci(n-1) + fibonacci(n-2) # # # print(fibonacci(36)) # print(time.time() - start_time) def fibonacci_td(n): if n < 2: return n if _memo[n] is None: _memo[n] = fibon...
80b841980f8bae50f9663229d67897a4221a0fa4
ZuoYaoyao/python_ML1
/udacity/python/Project2/sort.py
698
3.8125
4
import operator x = {'china':2, 3:4, 4:3, 2:1, 0:0} x['china'] += 1 sorted_x = sorted(x.items(), key=operator.itemgetter(1)) print(sorted_x) location = {'大陆': 0, '美国': 0, '香港': 0, '台湾': 0, '日本': 0, '韩国': 0, '英国': 0, '法国': 0, '德国': 0, '意大利': 0, '西班牙': 0, '印度': 0, '泰国': 0, '俄罗斯': 0, '伊朗': 0, '加...
55f625c2b9c535bdb3a89b923fa0020d7ce8582d
Yang-Jianlin/python-learn
/pycharm/day17_3_22/fibo.py
148
3.6875
4
def fibo(num): n, a, b = 0, 0, 1 while n < num: yield b a, b = b, a+b n += 1 f = fibo(6) for n in f: print(n)
3838ade06500d2165fd00bcb89ec3d54a27acd69
raunaklakhwani/Algorithms
/Combinations/MainHandlingDuplicates.py
816
3.734375
4
count = 0 def generateCom(lists,r): ''' This method takes the input list and generates all the combinations. Does handle duplicates ''' lists.sort() if r > len(lists): return else: generateComUtil(lists,r,[],0) def generateComUtil(lists,r,gen,index): global count ...
acfff741192c081a6853db45ed11f334fd2304fc
barathviknesh/Python
/miniex1.py
127
4
4
name=str(input("ENTER UR NAME: ")) year=int(input("UR DOB YEAR:")) age=2020-year print(name+" age is approx. "+str(age))
ca7e8853f6fe5fa32fd2932cdc5cd49d1c3f626a
amalfiyd/explore-repo
/11 - HackerRank/HackerRank/DrawingBook.py
482
3.546875
4
def drawingBook(n,p): if p <= n // 2: # start from left print('left') counter = 0 curPage = 1 while curPage < p: curPage += 2 counter += 1 else: # start from right print('right') counter = 0 curPage = n + 1 if n % 2 ...
24d111c81fc7f6ed12a15e96f75faf9765457c1f
temirbekbalabek/webdev2019
/week 10/HackerRank/14.py
281
3.6875
4
def mutate_string(s, p, c): l = "" for i in range(len(s)): if i == p: l += c else: l += s[i] return l if __name__ == '__main__': s = input() i, c = input().split() s_new = mutate_string(s, int(i), c) print(s_new)
863c0a4827563e86a5859d69c3c50ff9200011dd
bemarte/Exercicios-Basicos-Python
/Estrutura_Repetição/Ex_ER_2.py
286
4.125
4
#Faça um programa que receba dois números inteiros e # gere os números inteiros que estão no intervalo # compreendido por eles. num1 = int(input("Insira o numero x: ")) num2 = int(input("Insira o numero y: ")) lista = range(num1,num2+1) for item in lista: print(item,end=" ")
f42842bb034e4f8baf44912a3be4d1fda694a471
carlygrizzaffi/Girls-Who-Code-2019
/chatbot.py
1,618
4.40625
4
# --- Define your functions below! --- # --- Put your main program below! --- def default(): print("Welcome to Sugars! My name is Jeff.") def say_default(): print("Hint: try saying hi") def say_hello(name): print ("Hi,\n" + name) def location(x): print() if x == "New York": ...
acd547227a90ffe1a23d913e8950197b37253e20
ludovici-philippus/projetos_tkinter_excript
/Aula 18.py
423
3.640625
4
from tkinter import * janela = Tk() lb1 = Label(janela, text="ESPAÇO", width="20", height="3", bg="blue") lb_horizontal = Label(janela, text="HORIZONTAL", width="10", bg="yellow") lb_vertical = Label(janela, text="VERTICAL", bg="green") lb1.grid(row=0, column=0) lb_horizontal.grid(row=1, column=0, sticky=E)...
5cd4312f7ea771f7eec6e722c6dc641cd3a6df66
flightdutch/Python-HomeTasks
/L3/first_simple_n.py
408
3.734375
4
# Вывести на экран 10 первых простых чисел def is_prime(n): for i in range(2, n): if (n % i) == 0: print('{} % {} = {}'.format(n, i, n % i)) return False return True n = 1 i = 1 while True: if is_prime(n): print('Simple Number N {} : {}'. format(i, n)) i += ...
43172380454490320135fb51b43bf414aa51c708
github653224/HogwartsLG7
/python_practice/hero.py
636
3.875
4
class Hero: hp = 0 power = 0 name = "" def fight(self, enemy_hp, enemy_power): """ 两方进行一回合制的对打 :param enemy_hp: 敌人的血量 :param enemy_power: 敌人的攻击力 :return: """ # 我的血量 # 通过实例变量的方式调用类变量 final_hp = self.hp - enemy_power enemy_f...
9868df6b8c5f26a3bea3dce58fa4b701447d7803
s18011/programming-term2
/src/basic-c2/task20180712.py
228
3.921875
4
for x in range(1, 10): str_line = "" for y in range(1, 10): ans_int = x * y ans_str = str(ans_int) ans_str = ans_str.rjust(3) str_line = str_line + ans_str print(str_line) print()
3a63c1336d4a73999221e0a97ad8819637c84d8c
divyagahlot99/Interview_Prep
/sorting_techniques/insertion_sort.py
310
3.984375
4
def insertion_sort(arr): n = len(arr) for i in range(1, len(arr)): key = arr[i] j = i - 1 while j >= 0 and arr[j] > key: arr[j+1] = arr[j] j -= 1 arr[j+1] = key return arr arr = [4, 2, 8, 6, 4, 1, 0, 15, 4, 3] print(insertion_sort(arr))
e6cd59d4bc1ec26de1904bdf299cea4b1c303e6a
samaromku/python_lessons
/server/ClassTest.py
985
3.546875
4
class MyClass: variable = "blah" def function(self): return "This is a message inside the class." + str(self) myObject = MyClass() class UserFirstLastNames: def __init__(self, first_name): self.first_name = first_name first_name = "" lest_name = "" user = UserFirstLastNames("...
8eb55a84b955da5159e3c61ff48b61547009a2a7
ucsb-cs8-s18/LECTURE-05-29-Recursion-part-2
/sumOfListRecursive.py
507
3.5625
4
def sumList(intList): if intList==[]: return 0 else: return intList[0] + sumList(intList[1:]) def sumList2(intList): if intList==[]: return 0 first = intList[0] rest = intList[1:] return first + sumList2(rest) def sumList3(intList): return sumListHelper(0,intLis...
cc3432197f62e8fc7cd9806215f690d5c5bab038
hdb169/git
/python/examples/three.py
627
4
4
import math#continued to basics oct 30, 2019 def areaofcircle(r):# so need top give value of r PI = 3.1416 return (PI * r* r) print ("Area of circle is %.6f" % areaofcircle(19)) def area_square(l): return(l*l) print("Area of square is %.2f" % area_square(25.67) ) c = 3 *100000000 def energy(p,m): r...
55b2f9d36a20286347641e906c13dd11c40dda01
savvyknee/OOP100
/numbers.py
3,012
4.125
4
# Andrew Savini CST100 23Feb2014 numbers.py # Takes a bunch of numbers that the user enters, computes their total average, the average of the positive numbers, and the averages # of the negative numbers, then outputs the list of numbers and the key:value dictionary entries of everything. def main(): # get a list o...
cd414ead6a256ce54815e1a8a41bbbe7d702810c
VikramVikrant/Python-DS
/palindrome2.py
287
4.15625
4
## To check whether a string is palindrome or not. x=input() w='' for i in x: ## if we take input string as mada w = i + w ## see here i + w ,so it's added like this m,am,dam,adam if(x==w): print('Yes it is a palindrome.') if(x!=w): print("It's not a palindrome.")
312d7e349baf0f5f695bb3b17d06df6901072569
NoctemLeges/School-Project_again
/prog1.py
366
4.15625
4
l1 = eval(input('Enter a list:')) l2 = eval(input('Enter another list:')) intersection = [] for i in l1: if i in l2: intersection.append(i) print("The intersection of the two lists is:",intersection) union = [] for i in l1: union.append(i) for i in l2: if i not in union: union.append(i) ...
e84a741192a6713014d4f5e1cf34e6d75b3261da
rolmos14/Loan_Calculator
/Problems/What day is it/main.py
159
3.953125
4
hour_offset = int(input()) if -12 <= hour_offset <= -11: print("Monday") elif -10 <= hour_offset <= 13: print("Tuesday") else: print("Wednesday")
1b72c7c7bca2364040744b842e874ded0da04c13
edu-athensoft/stem1401python_student
/sj200917_python2m6/day10_201119/file_4_open.py
980
3.890625
4
""" open a file at a specified location error-free mode of file opening r for reading w for writing x for creating a for appending t in text mode b in binary mode rb mode for reading a binary file rt mode for reading a text file wt wb default: none (rt) default: w ...
0fd63668918236256c1d6a3f6ef4e5efe2999bed
AllenZhangzz/learnPyhton1
/class.py
896
3.765625
4
# -*- coding:utf-8 -*- __author__ = 'Allen' 'Class Learing' # class Student(object): # def __init__(self,name,age): # self.name=name # self.age=age # def print_age(self): # print self.age # def print_name(self): # pass # ss=Student('SDfsdf',23) # ss.print_age() class Student(object): """docstring for ...
e5f350a72462fcab1115463eb5db717db0d90a0f
Pyk017/Competetive-Programming
/HackerRank/Data_Structures/Arrays/Array-DS.py
228
3.875
4
""" An array is a data structure in which element or data can be stored of same data type in a contiguous block of memory. Problem : Reversing an Array """ n = int(input()) ar = list(map(int, input().split())) print(*ar[::-1])
3401831eec04868d25359746319abc0ffce66190
python-the-snake/mai_informatics
/theme 8/f.py
154
3.578125
4
x = float(input()) y = float(input()) def IsPointInArea(x, y): return if IsPointInArea(x, y): print("YES") else: print("NO")
689136e6586bebeac25a3722611bd0bd9a4af570
jakubov/pyjkstra
/tests/queue_tests.py
1,746
3.765625
4
import unittest from pyjkstra.data_structures.queue import Queue class QueueTestCase(unittest.TestCase): def setUp(self): """ Init the Queue """ self.q = Queue() def tearDown(self): """ Empty the Queue """ self.q = [] def test_is_empty(self): """ Test Empty Qu...
f7679dd84367addc37f8c3e4a9f6827df248b456
wyounas/python_training_hq
/blog_iterator_code_samples/iterate_over_builtin_types.py
1,071
3.984375
4
""" Source code given in the third section of the blog article (Iterating over built-in types) URL: http://www.pythontraininghq.com Author: Waqas Younas <waqas@pythontraininghq.com> """ file_name = "somefile.txt" some_int = 10 try: iterator = iter(some_int) # throws exception except TypeError as type_error: p...
f77aee88a2909537f8063be98bc6ec16f278a101
codingnoye/eachday-algo
/10814.py
192
3.515625
4
n = int(input()) l = [] for i in range(n): age, name = input().split() l.append((int(age), name)) l.sort(key = lambda x:x[0]) for item in l: print('{} {}'.format(item[0], item[1]))
4469f2ed23e044c2c43bc4603b5b408ac6a847b1
om-henners/advent_of_code
/2018/day13/solution_combined.py
5,611
4.40625
4
""" Navigating the cart maze, using a numpy array to represent a maze. A cart with a centre square X has a value of the sum of the directions that can be travelled as below: 1 2 4 8 X 16 32 64 128 So, according to the map the directions get numbered as follows: - => 24 | => 66 / => 80 or 10 \ => 72 or 18 + =...
a946a2084232627bb4f755eff398e71e65d86a29
kmishra9/Suitcase-Class-Utility-Scripts
/homeworkChecker.py
9,376
3.640625
4
""" Python Script designed to output names of all students who did not complete the homework usage: python3 homeworkChecker.py Outputs the name of each student who missed a homework, sorted by their UGSI and the number of homework assignments missed. In addition, creates a file named (students_without_submissions) th...
8423c822e2c16941fe38c2467aabf5fd847bc2fe
TomD0wning/DataStructuresAndAlgorithms
/Sorting.py
2,789
3.71875
4
#!/usr/bin/env python3 import time aList = [1, 2, 54, 96, 31, 305, 232, 3023492, 3243, 22, 3, 12, 2345,64,23421,9862,9076523,1144,65,19,8,55,34,29,163578,789641,3984841,1000000,101010101] def bubbleSort(aList): start = time.time() for x in range(len(aList)-1, 0, -1): for i in range(x): if ...
b50d86677d4f84808863cb70f3892a95dd872ecb
DedaLenya/python_baisik_31.10.2020
/les1_31.10.20/HomeWork_les1_31.10.20/task3_1.py
299
3.796875
4
# 3. Узнайте у пользователя число n. Найдите сумму чисел # n + nn + nnn. Например, пользователь ввёл число 3. # Считаем 3 + 33 + 333 = 369 n = str(input('input number >>')) a = f"{int(n) + int(n*2) + int(n*3)}" print(a)
ce7eb09e8859142a7b6dfd1371027e28ea253fb1
Wwwangi/LeetCode-Competition
/Wangi/448.py
1,211
3.59375
4
#可运行 class Solution: def findDisappearedNumbers(self, nums: List[int]) -> List[int]: if(nums==[]): return [] n=len(nums) temp=set([n for n in range(1,n+1)]) nums=sorted(set(nums)) result=temp.difference(nums) return result #using hash t...
32ca96a91a77166afca3a22c613d40562ed0f65e
BryanBumgardner/dsp
/python/advanced_python_csv.py
660
3.828125
4
import pandas as pd from pandas import DataFrame, read_csv #where is your file? here! path = '/Users/bryanbumgardner/anaconda/faculty.csv' #convert into pandas dataframe, and be picky about your column names. df = pd.read_csv(path, header=0) df.columns = ['Name', 'Degree', 'Title', 'Email'] #you must create variables,...
e4a18819c3a3003bf0ada3a51e3cea0871f7da8e
Hardik-Sihmar/string-functions
/stringfunctions.py
406
4.53125
5
# Some functions of Strings hello = "my name is Hardik" standard = "I am in eleventh standard." print(hello + standard) # 1. Len print(len(hello)) # 2. endswith print(hello.endswith('Hardik')) # 3. capitalize print(hello.capitalize()) # 4. count print(hello.count('a')) # 5. replace print(...
7b554d3d1a784aa74818f63e0594b1eec75a3c8d
mengyangbai/leetcode
/tree/recoverbinarysearchtree.py
628
3.609375
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 recoverTree(self, root): swap = [None, None] self.prev = TreeNode(float('-inf')) def dfs(node): if node: ...
c5db5acabf371ba9a991a5f0156e65c1b0c286c8
krishnaqa64/Pythonlearning
/pandas cleaningData.py
882
3.671875
4
import pandas as pd import numpy as np people = { 'first': ['Corey', 'Jane', 'John', 'Chris', np.nan, None, 'NA'], 'last': ['Schafer', 'Doe', 'Doe', 'Schafer', np.nan, np.nan, 'Missing'], 'email': ['CoreyMSchafer@gmail.com', 'JaneDoe@email.com', 'JohnDoe@email.com', None, np.nan, 'Anonymous@email.com', 'N...
ec92f238fa0c3658c8e8a71fd60fd0d4bdd6cf3f
beber89/pcap-instructor-samples
/recursion example.py
208
3.703125
4
def mydigit(p): s = 0 for x in p: s += int(x) if s < 10: return s else: return mydigit(str(s)) user_input = input("birthday \n") print(mydigit(user_input))