blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2798a03bfa336ccb28af67c8b1641cec58ed7a63
NikoLa437/oisisi2
/Ostalo/mergeSort.py
919
3.578125
4
def mergeSort(lista_prikaza): if len(lista_prikaza) > 1: mid = len(lista_prikaza) // 2 # trazenje sredine niza L = lista_prikaza[:mid] # deljenje elemenata liste R = lista_prikaza[mid:] # na 2 polovine mergeSort(L) # sortiranje prve polovine mergeSort(R) # sortiranje dr...
e10cf4a5b594509bf6429151199b46b035dfe6e2
ssarangi/algorithms
/facebook/regex_match.py
1,961
3.71875
4
class Pattern: def __init__(self, ch, repeated=False): self.ch = ch self.repeated = repeated self.match_all = False def __str__(self): return str(self.ch) + ": Repeated --> " + str(self.repeated) __repr__ = __str__ def create_pattern_list(pattern): ps = 0 last_patt...
63776f652169e22e966a194bcf823340f9cc6e8c
israelmendez232/data-modeling-rdb
/create_tables.py
2,272
3.765625
4
# Code that creates the datatabase and call the sql_queries.py to produce the tables. import psycopg2 from sql_queries import create_table_queries, drop_table_queries def create_database(): """ DESCRIPTION: This function is used to connect to the database 'studentdb'. It drops any other databa...
2f71e427712d34155c1c10ed76afab9a33d78488
nishantpa/python-prep
/leet/sortNames.py
556
4.125
4
# Swami Shreeji # 7 Feb 2018 # Sorting names, instead of numbers. And get the most frequent name at the start def sortNames(names): # Check if in dict, increment if yes. Else, add to dict myDict = {} for elem in names: if elem in myDict: myDict[elem] += 1 else: myDict[elem] = 1 # Reverse sort and retur...
3691aa5a2a5706a96b4b0f0c4c718c582ce3a785
dattgoswami/syntax_java_js_python_ts
/syntax.py
3,288
4.0625
4
print("Hello Python!") bicycles = ['trek', 'cannondale', 'redline', 'specialized'] print(bicycles) print(bicycles[0]) print(bicycles[0].title()) print(bicycles[-1]) #returns last item motorcycles = ['honda', 'yamaha', 'suzuki'] print(motorcycles) motorcycles.append('ducati') print(motorcycles) motorcycles = ['honda...
b595091cc574d7cf4fec59089fc00011f84853a5
flyoverGu/play-leetcode
/004_add_two_numbers.py
767
3.640625
4
class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: # @return a ListNode def addTwoNumbers(self, l1, l2): carry = 0 head = ListNode(carry) ll = head while carry or l1 or l2: node = ListNode(carry) if l1: node.val += l1.val l1 = l1.next i...
5bba4991709d3a63630503df1909451a030377e7
NacevskiD/Week1
/Guess the Number.py
584
3.953125
4
import random randNumber = random.randint(1,100) print(randNumber) guessNumber = int(input("Guess the number from 1 to 100.\n")) while randNumber != guessNumber: if guessNumber > 100 or guessNumber < 1: print("You entered a number bigger than 100 or smaller than 1, try again:\n") guessNumber = in...
d2ec1f0794a604ed3b6ddc1fe2c03e1dbdfff567
SateehTeppala/Data
/Sorting Algorithams/mon.py
875
3.53125
4
from pymongo import MongoClient myclient = MongoClient("mongodb://localhost:27017/") # database db = myclient["GFG"] # Created or Switched to collection # names: GeeksForGeeks collection = db["Student"] # Creating a list of records which we # insert in the collection using the # update_many(...
fcd4f120911af66ac2b4d6411650266b8352e374
sabrinaspage/Interview-Solutions
/PracticeProblems/decorators.py
2,352
4.65625
5
# functions are first class objects # functions are objects # can be referenced to # passed to a variable # return functions and variables # functions can be defined insie other functions # functions can be passed as arguments to other functions # modified behavior of function or class # allows us to wrap a...
03b4dbe6356bacd696670d4dfc918636b522633d
xenatisch/functional
/numbers/pi.py
1,383
3.5
4
#!/usr/bin/env python3 """ <Description of the programme> Programmed in Python 3.5.1-final. """ # Imports # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Python: # 3rd party: from math import fsum # Internal: # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...
c8c454c17d302afe71fce5cb4d3e609488392a09
SebastianErrazuriz/atamostec-sebastian-errazuriz
/src/utils/read_files.py
629
3.796875
4
from datetime import datetime import pandas as pd from pandas.core.frame import DataFrame def read_txt_file(path: str) -> DataFrame: ''' Read txt file and return a dataframe object Parameters ---------- path : str location of the file. Returns ------- DataFrame Result...
856d278476560b757a9e2f047b99558c6ac722f4
morgankb17/cis122
/Week 7/cis122-lab07-lists.py
4,522
4.4375
4
''' CIS 122 Summer 2020 Lab 7 Author: Morgan Bartlett Credit: Description: List exercises with score-related functions ''' import random def gen_random_integer_list(num, start_range = 1, end_range = 100, sort_list = 'N'): ''' This function returns a list of random numbers between two integers given num for the...
06099ce6d9a14426cbc7ca3e327438b67bd10799
ShaneKelly89/pands-problem-sheet
/task03_collatz/collatz.py
1,839
4.46875
4
#This is a program that asks the user to input any positive integer #and outputs the successive values of a calculation #Author Shane Kelly #First thing I must code is the users input number #https://stackoverflow.com/questions/42894178/python-validating-user-input #https://stackoverflow.com/questions/26198131/check...
c82f37e37f5e5884bfac60d8ba205714fc9a50bf
angelaclan/Python_ULIL
/TP1/Card/src/card.py
1,233
4.09375
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- """ :mod:`card` module :author: ` YOUR NAME Univ. Lille <http://portail.fil.univ-lille1.fr>`_ :date: 2017, september. Last revision: 2017, september """ import random class Card(object): VALUES = ("Ace", "2", "3", "4", "5", "6", "7", "8", "9", "...
28ba7a90cba3216bb615ed8dde68c3541be5ea59
barmi/CodingClub_python
/LV4/Chapter1/hello_world.py
904
3.59375
4
# hello_world.py introduces the turtle module. # hello _ world.py 프로그램은 turtle 모듈을 소개합니다. from turtle import * # change line width. 선의 너비를 조절합니다. pensize(5) # change to an actual turtle. 모양을 거북이(turtle)로 바꿉니다. shape("turtle") # draw the letter H. H를 그립니다. H를 어떻게 그릴지 상상해보세요. left(90) forward(100) back(50) right(90) ...
5a0dfd48f47df9abf31654fa051a62055bb8f5a4
hxk11111/Danny-Huang
/leetcode_py2/Hard 154. Find Minimum in Rotated Sorted Array II.py
1,593
4.28125
4
# -*- coding: utf-8 -*- # !/usr/bin/env python """ This module is provided by Authors: hxk11111 Date: 2019/1/21 File: Hard 154. Find Minimum in Rotated Sorted Array II.py """ ''' Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,7] might become [4,...
9fcab876df68eb2a9fe55c067b03c61e862027fb
B-MaTe/emeltErettsegiKeszules
/otszaz/otszaz.py
3,005
3.546875
4
# 2016 majus emelt erettsegi programozas # 1. Feladat FILENAME = "penztar.txt" lista = [] templista = [] with open(FILENAME) as f: for line in f: if line[:-1] == "F": lista.append(templista) templista = [] else: templista.append(line[:-1]) listahossz = len(lista)...
e2cc53379ce0a067370cbc4f282ae85d8e37d6d6
rodrigoferrazazevedo/dojo-python
/fruits.py
546
3.75
4
width = input('Please enter width: ') price_width = 10 item_width = width - price_width header_format = '%-*s%*s' format = '%-*s%*.2f' print '=' * width print header_format % (item_width,'Item',price_width, 'Price') print '-' * width print format % (item_width,'Apples',price_width,0.4) print format % (item_width,'Pear...
0291167fab0c21d105140721cd8d8227aaa1c320
shirmani/math_quiz_first_class
/evenuneven.py
1,456
4
4
import random import math # definition func def hint(a): d = int(a / 2) for i in range(1, d + 1): print('* *') def fixworng(e,x): while e != x: e = int(input('please put the right answer:')) # start print ('the computer give you a number \n ' 'if the number even click on 2 \n' ...
a047450ca28e236fc533e9acbdfcf150c65f4c9d
mameen-omar/EDC310_Practical-1
/SOFTWARE/question_2.py
2,896
3.5
4
#Mohamed Ameen Omar #16055323 #################################### ### EDC 310 Practical 1 ### ### 2018 ### ### Question 2 ### #################################### import numpy as np import matplotlib.pyplot as plt import time import datetime from scipy.st...
b3c8e98fd0dfba2ad92c49bfea190df1ba277c93
xyzhangaa/ltsolution
/LargestRectangleinHis.py
616
3.6875
4
###Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, ###find the area of largest rectangle in the histogram. # O(n), O(n) def largestRec(height): stack = [] maxArea = 0 height.append(-1) index = 0 while index < len(height): if len(stack) == 0: stack.appe...
5719345bbce75afc3e0f4b1919a202410213ef64
odellus/year_of_code
/meal_cost.py
238
3.875
4
#! /usr/bin/env python3 mealCost = float(input().strip()) tip = int(input().strip()) tax = int(input().strip()) totalCost = (1 + tip/100. + tax/100.) * mealCost print("The total meal cost is {} dollars.".format(int(round(totalCost))))
8fc37e4069bea45d650c9fa1dd3d151e63162572
Lee-ArnoldIII/python_learning
/advanced_python/oop/inheritance.py
470
3.5625
4
class Decimal: def __init__(self, number, places): self.number = number self.places = places def __repr__(self): return f"%.{self.places}f" % self.number class Currency(Decimal): def __init__(self, symbol, number, places): super().__init__(number, places) self.symb...
29d35a7d3dde00e5de5d351e7e96de81561f9880
Sahanduiuc/RoboticAI
/localisation_robotic_problem.py
5,598
4.125
4
# The function localize takes the following arguments: # # colors: # 2D list, each entry either 'R' (for red cell) or 'G' (for green cell) # # measurements: # list of measurements taken by the robot, each entry either 'R' or 'G' # # motions: # list of actions taken by the robot, each entry of the f...
e00267af3b119c030d1198c43db1084f909f4efe
cyberskeleton/sandbox
/2020-01-22cw3.py
353
3.90625
4
import random num = random.randint(0, 5) num_of_shops = random.randint(2, 6) print('we have ', num_of_shops, ' shops') A = set() shopname = [] for i in range(0, num): A.add(input('food: ')) print('assort: ', *A) for i in range(num_of_shops): products = set(random.sample(A, random.randint(1, num))) shopname....
b5285452925c18534ef657d42965e2d544da37eb
RockyMtnHighThere/Adventure-House
/AdventureHouseJess2.py
14,419
4.0625
4
""" Initialize a global variable named ghost, to be used with the functions of program 134 on pages 299-300. """ #10.1 Optimize showRoom() method - completed Bobby ghost = 0 bomb = 0 def playGame(): """ Prog 126 p 283: top-level function of adventure game """ """ (this function is redefined below in p...
4b6e1e096c12952fc167521938f5210d4aa7282d
fazalshaibaaz66/PythonPractise
/env/Scripts/inzi.py
1,392
3.828125
4
class MyClass(): #add def add(self, a,b): self.var = a self.van = b c = a + b return c #substract def sub(self, a, b): self.var = a self.van = b c = a - b return c #multiply def mul(self, a, b): self.var = a self.van = b c = a * b return c #divide def div(self, a, b): self.var = a ...
0a27de4dfb329af35fbf44ccaefd0ecd7a9beda4
raulsanika015/python
/character find.py
152
3.75
4
s1=input("Enter word to check:") s1=s1.lower() c=s1.count("a")+s1.count("e")+s1.count("i")+s1.count("o")+s1.count("u") print("Number of vowels:",c)
988500637c9fca3c16301fde41910109adccf1da
Clint-cc/Leecode
/力扣/每日一题/20-05/507另一棵树的子树.py
1,336
3.9375
4
# !D:/Code/python # -*- coding:utf-8 -*- # @Author : Clint # @Question : 给定两个非空二叉树 s 和 t,检验 s 中是否包含和 t 具有相同结构和节点值的子树。s 的一个子树包括 s 的一个 # 节点和这个节点的所有子孙。s 也可以看做它自身的一棵子树。 # @Thinking : 需要编写一个函数判断s中某个节点所对应的子树是否和t完全相同。如果s和t直接满足了相同的条件就直接返回,否则 # 递归求解 s 的左右子树是否含有和 t 相同的结构 # Definition for a binary tree no...
1e3e980090f0b5213d979e9f19c13b37694c4674
jensu0/python-harjoitteet
/mastermind.py
1,388
3.828125
4
# -*- coding: cp1252 -*- import sys if len(sys.argv) == 1: print "Give secret code" elif len(sys.argv[1]) != 4: print "Use 4 symbols!" #elif True: # for i in range(0,4): # if int(sys.argv[i]) > 6: # print "Invalid symbol! Use numbers between 1-6!" # break ...
0892c5bcbe22e09dc19f0efa174558addae561db
bhatiakomal/pythonpractice
/Exercise/Data_Structure/Linked_List2(15-09-2020/Delete.py
864
4
4
class Node: def __init__(self,data): self.data=data self.nextNode=None class LinkedList: def __init__(self,value): self.head=Node(value) self.tail=self.head def insert(self,data): newNode=Node(data) self.tail.nextNode=newNode self.tail=newNode def ...
ed262efa29cc07de64cecb4004f4c92f0d75de1d
jamesbting/COMP-400-Research-Project
/filtering/src/loader.py
1,624
3.546875
4
import csv def load_data(file_name, team_dictionary): print("Loading data into the program") dataset = {} with open(file_name,'r') as f: reader = csv.reader(f, delimiter = ',') i = 0 for row in reader: add_data(dataset, row) i += 1 print(i, 'data poin...
26aee87a6b42f3b2cfab4ab2f93affcf3b4c6e91
clopez5313/Python
/1. Become a Python Developer/11. 8 Things You Must Know in Python/enumerate() and zip() Methods/challenge2.py
665
3.859375
4
years = [2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019] births = [723_165, 723_913, 729_674, 698_512, 695_233, 697_852, 696_271, 679_106, 657_076, 640_370] def annual_births_average(year=years, births=births): '''Return a list of tuples with each entry in this format (year, birth, running_avera...
e8048eb56c4a6afbb4601ebd43e137b5ce09b2cc
skafis/python-essentials
/for.py
141
4.0625
4
#!/usr/bin/python3 def main(): s = "this is a string" for i, c in enumerate(s): print(i, c) if __name__=="__name__": main()
ba38d072dd139164faafafbe160357e837febc70
MrZhangzhg/nsd2019
/nsd1905/py01/day05/randpass2.py
458
3.6875
4
import random from string import ascii_letters, digits all_chs = ascii_letters + digits # 从大小写字母和数字中选取字符 def mk_pwd(n=8): result = '' # 结果保存到变量result中 for i in range(n): ch = random.choice(all_chs) # 随机选出一个字符 result += ch # 将选出的字符与result拼接 return result if __name__ == '__main__': ...
313df179513214afa9c7f6674f98a0fddbe8c7f4
Glucose-IV/TP_Hugo
/affichage.py
1,257
3.75
4
#------------------------------------------------------------------------------- # Name: affichage # Purpose: # # Author: hugot # # Created: 24/11/2020 # Copyright: (c) hugot 2020 # Licence: <your licence> #------------------------------------------------------------------------------- #...
adf34a0a97a911fb9ece21ccbce044cbd442be46
Neo-Teyrall/Mydock
/Langage/Python/Class/addition.py
745
3.765625
4
import sys import traceback class addition(): def __init__(self, new_x, new_y): self.x = new_x self.y = new_y pass def __add__(self,add): if not isinstance(add, addition) : traceback.print_stack() sys.exit("Error: is not addditon class. Addition Impossi...
fcbd7f02f778fac58d459f07dbce02188d4ba60e
mSE26/Calculator
/calc.py
1,162
4.46875
4
def calc(): operation = input(''' Введите математическую операцию, которую вы хотите выполнить: + - * / ''') num1 = int(input('Первая цифра: ')) num2 = int(input('Вторая цифра: ')) if operation == '+': print('{} + {} = '.format(num1, num2)) print(num1 + num2) elif operation ==...
1606f11308876369c7f9d60a9654273a298136bf
MrZiemni0k/Learning
/Done/100DaysChallenge/#019-Turtle_Race/main.py
1,742
4.1875
4
from turtle import Turtle, Screen import random _width = 500 _height = 500 screen = Screen() screen.setup(width=_width, height=_height) #Turtles _r = Turtle(shape="turtle") _r.color('red') _r.speed('fastest') _g = Turtle(shape="turtle") _g.color =('black') _g.speed('fastest') _b = Turtle(shape="turtle") _b.color('blu...
959e199f68c6c230e828f1ccc26ccc90097d042b
mattgraham93/mattgraham93.github.io
/examples/python/personal/practice/locate_left_insert.py
1,036
3.8125
4
import bisect def index(a, x): # 'Locate the leftmost value exactly equal to x' i = bisect.bisect_left(a, x) if i != len(a) and a[i] == x: return i raise ValueError def find_lt(a, x): # 'Find rightmost value less than x' i = bisect.bisect_left(a, x) if i: return a[i - 1] ...
e8e7c2d5368141fa4e9d8fcae0d06acb5a3d560e
ziaurjoy/Python-Data-Structure-And-Algorithm
/Stack Queue/queue.py
1,511
4.03125
4
# class Queue: # def __init__(self): # self.items = [] # def enqueue(self, item): # self.items.append(item) # # def dequeue(self): # return self.items.pop(0) # # def is_empty(self): # if self.items == []: # return True # return False # # s1 = Queue()...
55c8350a85acfb969371a74a324481b3ea8ee3d7
chrisleee/college-scrape
/usnews_scrape.py
5,265
3.59375
4
from bs4 import BeautifulSoup from urllib2 import urlopen from urllib2 import Request from urllib2 import HTTPError from csv import DictWriter from csv import writer import json import urllib import urllib2 #from time import sleep def make_soup(url): html = '' request = '' try: request = Request(ur...
442856400cf6e3f285774ec06a12d1dde051fd28
monikalakshmanan/moni
/3.vowel.py
105
4.0625
4
q=input() if (q=="a" or q=="e" or q=="i" or q=="o" or q=="u"): print("vowel") else: print("consonant")
38f08ce2add4fa5a2b91823f91de7b908e00fc51
ben-hunter-hansen/ProjectEuler
/problem_9.py
1,612
4.125
4
# Project Euler Problem #9 # ----------------------------------------- # A Pythagorean triplet is a set of three natural numbers, # a < b < c, for which, a^2 + b^2 = c^2 # # For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2. # There exists exactly one Pythagorean triplet for which a + b + c = 1000. # # Find the product abc. ...
6c8f2b38bf235df9d15bd78b66fa9935831b8841
ChristensenJacob/SchoolCode
/Python/whitestrip.py
276
3.546875
4
import sys def stripWSpace(input): input = "".join(input.split()) return input path = sys.argv[1] file = open(path, 'r') outfile = open ('out.txt', 'w') input = file.readline() while input: outfile.write(stripWSpace(input)) outfile.write('\n') input = file.readline()
afffd7decf6a79947b57e42f14b46b02b15d5de8
aldoup84/ejeps
/02volume/00Nombre/src/exercise.py
282
3.703125
4
import math import os def main(): os.system("clear") radio = float(input("Escribe el valor del radio de la esfera: ")) vol = 4 / 3 * math.pi * math.pow(radio,3) print(f"El volumen de la esfera de {radio} radio es de {vol} cm3") if __name__=='__main__': main()
88512b3c6185d2f0a2da0362638a4f663578c87e
samir711/webdriverpythonappium
/PythonAppiumProject/PythonTraining/Day4/code/upperLower.py
100
4.1875
4
str=input("Enter string: ") if(str.isupper()): print(str.lower()) else: print(str.upper())
39e52434c545c18faec2dea3ce928ffb3cd64d14
mosobhy/google-hash-code-qualifications
/main.py
5,395
3.640625
4
import random def writeOutput(orders, outputs): with open('output', "w") as file: file.write(str(orders)) file.write("\n") # iterate and print the output list of dicts for output in outputs: file.write(str(len(output))) file.write(' ') ...
eac18f1117bfa93cdbbfafc035b5801e93186284
sssurvey/EulerQuestions
/euler00005.py
918
4.09375
4
#python programing questions No.5 #smallest multiple #2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. #what is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? #version 0.1 int0 =4 int1 =0 dividerCounter =0 divider =[1,...
6cc260c20819884bbe134a10708598410d18ef3d
nikkisora/cses_problemset
/1 Introductory Problems/14 Tower of Hanoi.py
1,236
3.859375
4
''' CSES - Tower of Hanoi Time limit: 1.00 s Memory limit: 512 MB The Tower of Hanoi game consists of three stacks (left, middle and right) and n round disks of different sizes. Initially, the left stack has all the disks, in increasing order of size from top to bottom. The goal is to move all the disks to the ...
7ca337d1a0185b1e7015242c1cce698e9f0330b1
anwarsk/DecisionTree
/DecisionTree/InputHandler.py
2,549
3.84375
4
import os.path class InputHandler: """ This is InputHandler class responsible for reading inputs to the program """ def convertToInteger(self, numberString): """ This function checks if input is number and if yes then convert it into integer. :param numberString: Nu...
43da3a4ed3352a373063c78754dc069d8ebc63d3
nithintech/datastructures_and_algorithms
/7_queue.py
1,152
4.125
4
class queue: def __init__(self): self.items = [] def enqueue(self, item): self.items.append(item) def isEmpty(self): if self.items == []: return True else: return False def dequeue(self): print "The last element is " + str(self.items[-1]) ...
09fe3d449d5f24afaa0698a2394a4cdf7503e73b
Maryville-SWDV-610-3W18SP2/week-3-writing-recursive-functions-CodeNamor
/ReverseList.py
451
4.40625
4
#Python Program to reverse the elements in a list #F. Derek Roman - GitHub Profile: CodeNamor #SWDV-610-3W Week 3 Assignment I attest that this is my own work def revList(lst): if len(lst) == 0: return ([]) else: return (revList(lst[1:]) + [lst[0]] ) def main(): list = eval(...
34ef9dbe30a50b51dd3719c299b0559d187af006
MrCodeGuy/Jerry1.2
/Jerry 1.2.py
2,877
4.25
4
def favor(): # ask to define favor favor = int(input("Do you need any help from me? (reply with a positive number for yes and a negative number for no do not type zero).")) # says do you need help if favor < 0: # if the favor is less than zero print("Bye! More upgrades will come!") # say bye! ...
59f2cf1177429a67b2d2cc3518d901e128e7e88b
esergly/PythonStartLessonTen
/LessonTenTaskOne.py
124
3.640625
4
def max_of_list(my_list): return print(max(my_list)) my_list = [5, 7, 8, 1, 2, 9, 5, 5, 3] max_of_list(my_list)
1730f8c2636a02d9901ea38e92eb66b884395499
WhiteSheep-y/Python
/源代码/p4/p4_11.py
289
3.5
4
# p4_11.py bingo = '清蒸' answer = input('小甲鱼是清蒸还吃还是炖了好吃?') while True: if answer == bingo: break answer = input('抱歉,错了,请重新输入(答案正确才能退出游戏):') print('对嘛,只有清蒸才能原汁原味~')
b0cc34611486287cd31fce5598ace304982e26e3
SupratimGhosh/Telephone_Book
/Telephone_Book/insert.py
964
3.625
4
# from check import check from connect import * class insert: def insert(name): cursor = mydb.cursor() # name = input("Enter your username (name of directory): ") # ch=check.chck(name) print('Directory opened!') while True: n = input('Name of the person: ') ...
73f0b2da6267c2c08102e48fa18400b39f606e56
mengyx-work/CS_algorithm_scripts
/leetcode/LC_133. Clone Graph.py
955
3.8125
4
# """ # Definition for a Node. class Node(object): def __init__(self, val = 0, neighbors = []): self.val = val self.neighbors = neighbors # """ class Solution(object): ### BFS def cloneGraph(self, node): m = {node: Node(node.val)} stack = [node] while len(stack) > 0:...
061c26e0a5946e05690eb0daf345f45e2a966cf5
alifa-ara-heya/My-Journey-With-Python
/day_13/exercises.py
2,405
4.4375
4
# Day_13: August/09/2020 # In the name 0f Allah.. # Me: Alifa # From: Book : Python for everybody # chapter: 3 # Conditional operator: Exercises # Exercise of chapter 2: # Exercise 3: Write a program to prompt the user for hours and rate per hour to compute gross pay. hours = input("Enter hours: ") rate = input("Enter...
fac4fa10cdeb1c14b9d98165e42976a601256aab
heitorchang/learn-code
/levelup/2018_jan/python/strings/minion_game.py
2,994
3.671875
4
""" Kevin and Stuart want to play the 'The Minion Game'. Game Rules Both players are given the same string, S. Both players have to make substrings using the letters of the string S. Stuart has to make words starting with consonants. Kevin has to make words starting with vowels. The game ends when both players have ...
6bb3bd4f5695c85aaac11738f21d904bf99b8a25
aswinmurali-io/magiclist
/magiclist/magic.py
9,881
4.21875
4
""" Magiclist is an awesome data type ! Magiclist has the ability to release memory on a per element basis rather than the object itself! This way magiclist can store a large amount of data inside it without running out of memory. When magiclist runs out of memory, then purge() function can be called and all the inacti...
debf5783c4b01a61bf41915c1f1fc74d795030bc
RusyaDeWitt/ICT
/task_3/74.py
114
3.8125
4
print(" 1 2 3 4 5 6 7 8 9 10") for i in range(1,11): print(i, i*1, i*2, i*3, i*4, i*5,i*6,i*7,i*8,i*9,i*10)
552a93636728e32cd3dd27b9d81f3334d019546e
probabilistic-numerics/probnum
/src/probnum/linalg/solvers/stopping_criteria/_maxiter.py
1,193
3.5
4
"""Stopping criterion based on a maximum number of iterations.""" from typing import Optional import probnum # pylint: disable="unused-import" from ._linear_solver_stopping_criterion import LinearSolverStoppingCriterion class MaxIterationsStoppingCriterion(LinearSolverStoppingCriterion): r"""Stop after a maxim...
d9e32081a2039117ee0ad6ab0520609446d08317
RobbertSinclair/adventOfCode2020
/day1/challenge2.py
553
3.859375
4
def find_multiplication(filename): total_pair = [] num_list = [] with open(filename) as f: num_list = [int(line.strip()) for line in f] for number in num_list: new_total = 2020 - number for other_num in num_list: third_num = new_total - other_num ...
bd2121d1e6fdaa56bc281a917b2269da0f093d8e
Eobodoechine/poll-voter
/PyBank/main.py
2,527
3.8125
4
import os import csv # Path to collect data from the Resources folder bank_csv = os.path.join('/Users/eobodoechine/fake directory/python-challenge/PyBank', 'Resources', '03-Python_Homework_Instructions_PyBank_Resources_budget_data (2).csv') #set total to 0 total = 0 #open file and set inital variables and lists to ...
a46219460691951e37ab1bfdc3f38bd0714dcc77
r-flowers/cycle
/cycle.py
2,603
4.09375
4
# import the necessary random number generator module from random import randint # print the game's "opening" print("Welcome to Cycle!") print("You have stolen a bicycle in the mad max apocalypse.") print("The punks want their bicycle back and are chasing you down.") print("Can you survive the apocalypse and outrun th...
ee2882f5500c66666b4d5014402b8a5a6688268d
amrkhailr/python_traning-
/Week5_/exo9.py
290
4.21875
4
#The following statement calls a function named half, #which returns a value that is half that of the argument. #(Assume the number variable references a float value.) Write code for the function. #result = half(number) def half (number): print(number/2) half(5) # show me 5's half
c212c554e676ab9ab535dfe9ae695576915cbac5
TheolZacharopoulos/algorithms-playground
/algorithms/sorting/not_elementary/merge_sort/counting_inverstions.py
1,296
3.96875
4
# https://www.hackerrank.com/challenges/ctci-merge-sort def merge(array_low, array_high): result = [] global sort_counter for i in range(0, len(array_low) + len(array_high)): if not array_high: result.append(array_low.pop(0)) continue if not array_low: ...
12f208f12b917e4b6656bb3f9b78d9781ee7cc17
jiangshshui/leetcode
/thirdPage/Balanced_Binary_Tree_110.py
1,002
3.71875
4
class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None # class Solution(object): # def isBalanced(self, root): # def check(root): # if root is None: # return 0 # left = check(root.left) # ...
137e20990369d9e24c63b5b5a8dd5ee75eddd4a1
AAMU-CS104/practice-problems
/lists/shuffle_array/main_solutions.py
1,107
4.34375
4
# Sample solutions # This is a simple solution that creates a brand new list and loops through # the given list to append the elements in the correct order. The main trick # here is to figure out how to append append the correct y elements. Drawing # a diagram here can help. def shuffle(nums, n): result = [] f...
1b0fbf8b079e5f734aaf8990d2808056cd453cf8
shashankvivek/Udacity_ML
/Foundation_course/1_Intro_To_Programing/BikeSharing/bikeshare.py
7,610
4.5
4
import time import pandas as pd import numpy as np import datetime CITY_DATA = { 'chicago': 'chicago.csv', 'new york city': 'new_york_city.csv', 'washington': 'washington.csv' } def get_filters(): """ Asks user to specify a city, month, and day to analyze. Returns: (st...
fc78ea23f77df88d8c88ccf06ee7ba2efa3455b1
Susama91/Project
/Programs/Oops/destuctor2.py
256
3.609375
4
class x: def __init__(self): print("in constructor of x") def m1(self): print("in m1 of x") def __del__(self): print("in destructor of x") x1=x() print(x1) x2=x1 print(x2) x3=x2 print(x3) x1=x() print(x1) x2=x() print(x2) x3=x() print(x3)
edb26970aa342ea368f62d9a4c2246eaa2c69491
msaio/pythonstuff
/Class/inheritance/test.py
1,126
4.25
4
####################################################### # class First(object): # def __init__(self): # print "first" # class Second(First): # def __init__(self): # print "second" # class Third(First): # def __init__(self): # print "third" # class Fourth(Second, Third)...
b784f66dc2cb2410b179b3b94d27b9f6c68727e8
jbauermanncode/Curso_Em_Video_Python
/Python_Exercicios/Mundo3/Listas em Python/python_067.py
909
4.09375
4
''' Crie um programa que vai ler vários números e colocar em uma lista. Depois disso, crie duas listas extras que vão conter apenas os valores pares e os valores ímpares digitados, respectivamente. Ao final, mostre o conteúdo das três listas geradas. ''' # Aplicar uma lista numeros = [] pares = [] impares =[] # Ap...
46ff483f5a7ec55ae24b3ca70cebb1a2896463ee
Mimitwinkle/GWC-Python
/Shapes.py
747
4.28125
4
from turtle import * import math import random import colorsys # Name your Turtle. tia = Turtle() # Set Up your screen and starting position. tia.penup() setup(500,300) x_pos = 0 y_pos = 50 tia.setposition(x_pos, y_pos) ### Write your code below: sides = input("How many sides should the shape have?") rcolor = ["po...
88c7d8e7cb609754cb59b4b19b2d1f6f728e5571
Soltis12/learn_python
/7_links.py
2,306
4.46875
4
""" This is just a list of links to other resources so you can continue your learning journey. I've picked various different topics so you can follow your passion. === BUILD A GAME === 1) Build the snake game in python using the turtle package: https://www.edureka.co/blog/python-turtle-module/ 2) Build the game 'co...
c7ccca5f47a677f713f87dae84fc5d7fc4e767c9
w5802021/leet_niuke
/niuke/调整数组顺序是奇数位于偶数前面.py
386
3.609375
4
def reOrderArray(array): ''' O(1)的空间复杂度 若在开新数组需要O(n)的时间复杂度 ''' for i in range(len(array)): key = array[i] j = i - 1 while j >= 0: if (array[j + 1] % 2 != 0) and (array[j] % 2 == 0): array[j + 1] = array[j] array[j] = key ...
ff4965806ddb327d12ae1669f2dd3c12c9de1e5c
GeoffroiB/advent_code_2020
/days/day_6.py
1,470
3.515625
4
# -*- coding: utf-8 -*- import numpy as np from string import ascii_lowercase from typing import List from .abstract_day import AbstractDay from .utils import read_lines class Day6(AbstractDay): def partOne(self) -> int: total: int = 0 group_answers = "" for line in read_lines(self.inpu...
de80f7c11e5b743b6798957e7cef2fe3aadda44b
roned465/networks_assignments
/assignment 1/question 3/server.py
2,294
3.984375
4
from socket import socket, AF_INET, SOCK_DGRAM from sys import argv # assign line arguments my_port = int(argv[1]) parent_ip = argv[2] parent_port = int(argv[3]) file_name = argv[4] source_ip = "127.0.0.1" # local ip for the server to bind to # open and read the ip mapping from the given file ip_file ...
c480b8c0d08222e5e03ebaafa05ff30244f7c5eb
juanibutter/Curso_2
/#29 - Archivos Externos II.py
924
3.84375
4
from io import open archivo_texto=open("#29_archivo2.txt","r") archivo_texto.seek(6) print(archivo_texto.read()) #Vamos a ver como desplazar el puntero y escribir en donde nosotros queramos con el método "seek(posición_deseada)" archivo_texto.seek(len(archivo_texto.read())/2) #Esto sirve para posicionar el cursor en...
6078cc1dddb50efaf398b28c5d675660d6835c10
natc79/EducationalAchievement
/exploration.py
460
3.515625
4
import pandas as pd data = pd.read_csv("data/CRDC2013_14.csv", encoding="Latin-1") #look at value counts in these two columns print(data["JJ"].value_counts()) print(data["SCH_STATUS_MAGNET"].value_counts()) #Create two pivot tables that aggregate tot_enr_m and print(pd.pivot_table(data, values=["TOT_ENR_M", "TOT_ENR...
8f3828548095a715c758765dbe7091e0476a9096
phananhnguyen1204/EGR101
/Homework/Homework6/Homework6.py
2,126
4.28125
4
#Exercise 1: Create a simple chatbot following these rules: #Firstly, create a dictionary named manage_subjects #Use input to ask number of subjects want to manage #After that use input to ask each name of subject and its score (out of 10) and add them to dictionary #Secondly print "We can do 3 options. 1) Check every ...
ceb5813d869d4ea00edb1a8cb7a20598bd316e0e
kenziebottoms/euler-python
/cheatsheet.py
449
3.796875
4
def product(list): product = 1 for item in list: product = product * int(item) return product def even(x): return x % 2 == 0 def palendromic(x): return str(x) == str(x)[::-1] def square(x): return x**2 def is_prime(x): for i in range (2,x/2+1): if x % i == 0: return Fal...
04f66c2429a8bad301e6828637de1f3f3ef4b970
cameron-teed/ICS3U-3-01-PY
/adding.py
505
4.125
4
#!usr/bin/env python # Created by: Cameron Teed # Created On: September 2019 # This program adds two numbers together def main(): # This program adds two numbers together # Input first_number = int(input("enter the first number: ")) second_number = int(input("enter the second number: ")) # Proc...
32a90db0eb1891fe6b68ced9dd05ae3a5ab8ac1d
hubbm-bbm101/lab5-exercise-solution-b2210356114
/b2210356114/3.py
485
3.84375
4
import random n = random.randint(0,10) a = int(input("What is your guess: ")) def asking(): global a a = int(input("What is your guess: ")) return checking() def checking(): if a == n: print("Your guess is correct") else: if a > n: print ("Decreas...
e2b29d30d9df7aa57d4a6d70cc7f7e90c2cb01a9
danceyat/Python-Study
/built-in_func/sorted.py
1,468
4.4375
4
""" sorted(iterable[, key][, reverse]) Return a new sorted list from the items in iterable. Has two optional arguments which must be specified as keyword arguments. key specifies a function of one argument that is used to extract a comparison key from each list element: key=str.lower. The default value is None (comp...
c6d98b14f57cd8885ce19bcfcdc1fbb0a381fc29
jordanhong/Auto_Chess_Player
/prelim_ttt/ttt_lab/tit_draft.py
1,148
3.65625
4
## Tic TaT Toe board=[2, 1, 2, 1, 2, 2, 2, 1, 1, 0] def genBoard(): board=[] board_len=9 i=0 while i<board_len: board=board+[0] i=i+1 return board def printBoard(T): i=0 display=[] board_len=9 if not len(T)== board_len: return False while i<board_len: if T[i]==0: ...
357503614f65cf13048bf2aa6030af9660abc52a
baiden00/selfStudyDataStructures
/stack.py
1,451
3.984375
4
from nodes import Node class Stack: def __init__(self, limit=1000): self.top_item = None self.size = 0 self.limit = limit def push(self, value): if self.has_space(): item = Node(value) item.next = self.top_item self.top_item = item self.size += 1 print("Adding {} to t...
6c0b72371aec197184107d3e4fa72c9f2829c506
nomad0x/itp-u4-c2-hangman-game
/hangman/game.py
4,085
3.859375
4
from .exceptions import * import random # Complete with your own, just for fun :) LIST_OF_WORDS = ['geek', 'nerd', 'Super', 'Marvel'] def _get_random_word(list_of_words): # if there is no list an exception is raised. if not list_of_words: raise InvalidListOfWordsException() # if there is a list a...
66e4df77f7a6e2fe36063f03b0e4aa7cdf24441d
mike006322/ProjectEuler
/Solutions/PE045_triangular_pentagonal_hexagonal/triangular_pentagonal_hexagonal.py
1,481
4.1875
4
#!/bin/python3 # https://www.hackerrank.com/contests/projecteuler/challenges/euler045 def hexagonal_number(n): """ return nth hexagonal number """ return n*(2*n-1) def pentagonal_number(n): """ returns nth pentagonal number """ return n*(3*n - 1)//2 def is_pentagonal(n): """ ...
30815b406f483b863677e51b054463465e2eab57
kelr/practice-stuff
/leetcode/1171-removezerosumconsecutive.py
1,517
3.546875
4
class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next # Create a map for running sum values to node pointers. If the sum is ever found again, set the node in the map's next value to the next value of the curr node. # Essentially deleting the sublist that has the zero...
5cedfcb6369cb799769c5a74c5702b41579240f6
TheSleepingAssassin/CodeFolder
/py/School/FINAL/Practice Worksheet/Q7/app.py
432
3.671875
4
inp = input("Enter the range separated by a comma: ") a = 0 b = 0 if "," in inp: str = inp.split(",") a = int(str[0]) b = int(str[1]) elif ", " in inp: str = inp.split(", ") a = int(str[0]) b = int(str[1]) evenTotal = 0 oddTotal = 0 for i in range(a, b + 1): if i % 2 == 0: evenTo...
ddc6d48280344d801937b36bea781f67facaf676
ntihindukkipati/CS5590_Python_DL
/ICP_1/SOURCE_CODE/arthemetic.py
112
3.609375
4
a=10 b=11 print("add",a+b) print("sub",a-b) print("mul",a*b) print("div",a/b) print("pow",a**b) print("mod",a%b)
3565883e41f38d1e37a90992f9f2ede58881172b
Bertram-Liu/Note
/NOTE/02_PythonBase/day01/code/is.py
87
3.5
4
x = 10000 y = 10000 print(x is y) # python 解释执行器会对此程序进行优化
301f1cf7e3e219f5e65152a170ce3c27e386aa83
ilante/python_coursera
/classes.py
1,044
4.0625
4
# # Classes jupyter # # Import the library # import matplotlib.pyplot as plt # matplotlib inline # #creating the class circle. # class Circle(object): # #constructor # def _init_(self, radius=3, color='blue'): # self.radius = radius # self.color = color # # method # def add_radius(self, r):...
634df56119962a24e0b22d609edb1f8cd80aacc8
Xu-Angel/pyLearn
/import-print-string.py
2,683
4.40625
4
# python中单引号和双引号使用完全相同。 # 使用三引号('''或""")可以指定一个多行字符串。 # 转义符 '\' # 反斜杠可以用来转义,使用r可以让反斜杠不发生转义。。 如 r"this is a line with \n" 则\n会显示,并不是换行。 # 按字面意义级联字符串,如"this " "is " "string"会被自动转换为this is string。 # 字符串可以用 + 运算符连接在一起,用 * 运算符重复。 # Python 中的字符串有两种索引方式,从左往右以 0 开始,从右往左以 -1 开始。 # Python中的字符串不能改变。 # Python 没有单独的字符类型,一个字符就是长度为 1 ...
3fc99faca53c89bec327c57ee63fb98594b1baa1
MounishP/Elite
/sort.py
269
3.8125
4
l = [1, 26, 4, 59, 0, 3, 68, 7, 8] # str = "mounish" # sort the list #bubble sort algorithm for i in range(0, len(l)): # 0,1 # n = l[i] # 1 for j in range(0, len(l)): # 0,1,2 if l[j] > l[i]: # 1>1,1>0 l[i], l[j] = l[j], l[i] print(l)
527b38c39cc6bf33e165d30787dba139312d7fe2
deepsjuneja/tathastu_week_of_code
/day6/program12.py
438
4
4
n = int(input("Enter the no. of strings in array: ")) array = [] print("Enter strings in array one by one: ") for i in range(n): word = input() array.append(word) prefix = array[0] for i in array: if len(i) < len(prefix): prefix = i i = 0 l = len(prefix) while i < n: if prefix not in array[i]...
51406dad216d2a5405433828c8627b2b8900c46a
sivaneshl/pyhton-tutorials
/regexsumnumbers1.py
373
3.609375
4
import re fname = input('Enter file name: ') try: fhand = open(fname) except: print('using default file name to continue') fhand = open('regex_sum_42.txt') tot = 0 for line in fhand: num = re.findall('[0-9]+', line) if len(num) == 0: continue else: for i in range(len(n...
dd94de139024560d5bcf9ee40348dd04c5b338d2
Sabrejq/Minimum-Spanning-Tree-Algorithm
/uhd_weighted_Grapth/functions/prims_functions.py
1,186
3.734375
4
# Function that sums the cost of the edges for a given Tree def cost(G, e): return G.edges()[e]['weight'] # Function that counts the Edges aviable of a given Tree. def incident_edges(G, T): # Creates empty list of edges edges = [] #Checks for edges in graph for e in G.edges(): for v in T....