blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
b83627edd6786755ea028b55670281982f22896d
egalli64/pythonesque
/cip/karel/ch04.py
1,298
3.734375
4
""" Karel the Robot - Learns Python Source: https://compedu.stanford.edu/karel-reader/docs/python/en/intro.html My notes: https://github.com/egalli64/pythonesque/cip/karel Chapter 3: Decomposition https://compedu.stanford.edu/karel-reader/docs/python/en/chapter4.html """ from stanfordkarel import * def main(): ...
a1869bcb396ba2682988b98d3b1aa0d57f2e4d37
Aryank47/PythonProgramming
/encapsulation.py
282
3.75
4
# -*- coding: utf-8 -*- """ Created on Tue Jun 4 14:12:56 2019 @author: Aryan Kumar """ class student: def display(self,name=None): if len(name)<= 5: print('hello') else: print(name," hello") s=student() s.display('aryan')
d58522df78cb862ca60bc6c86bd6b865f1f8517f
hansrajdas/algorithms
/Level-3/letter_and_numbers.py
1,608
3.890625
4
#!/usr/bin/python # Date: 2020-11-27 # # Description: # Given an array filled with letters and numbers, find the longest subarray # with an equal number of letters and numbers. # # Approach: # Scan given array and create another delta array which has difference of # number of numbers seen and number of letters seen ti...
104fc9f285a0bd2b94fd3143fe445dff0b690a9e
pooja-pichad/more_excersise
/q8.duplicate.py
907
3.8125
4
# Socho aapke paas do lists hain. Ab aapko nayi list banani hai jisme dono lists ke elements # hone chaiye. Lekin yeh dhyan mein rakhna hai ki dono lists ke saare elements sirf ek-ek # baar hi hone chaiye. Agar humare paas yeh do lists hain: list1 = [1, 5, 10, 12, 16, 20] list2 = [1, 2, 10, 13, 16] # Toh humari ...
f773087fe699bcec83fe2310160534da45ec1a22
limciana/cs150-project
/iowithparse.py
8,041
3.5
4
# list of tokens # storing and printing of variables, integer muna # specify sa pagrun ng python yung filename # not \n sensitive # string variable value has "" # CONSIDER ARRAY IN TYPE CHECKING # KUNG MAY TIME: LINE NUMBER SA PARSING # TYPE CASTING (kung may time) # float and int can be stored vice versa # PAALALA # ...
773c12943c7b0e20132e4bfbd9fe781ec95938b5
vivianLL/LeetCode
/10_RegularExpressionMatching.py
3,522
3.984375
4
''' 10. Regular Expression Matching https://leetcode.com/problems/regular-expression-matching/ Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching should...
ff19c4c667a1af7f347f5404e31e747af77222bc
bdebelle/lpfs
/controlstructure/whileloopdemo.py
454
3.8125
4
""" execute statements repeatedly conditions are used to stop the execution of loops iterable items are strings, lists, tuples, dictionary """ # while x < 10: # print("value of x is " + str(x)) # x = x + 1 # print("one more line") l =[] num =0 while num < 10: l.append(num) print("Value if x is " + ...
500a82a7a65ec692131a56c91e05bf75d5e5dfc6
LaxmanRaikar/PythonPrograms
/bridge/quadratic.py
411
4.0625
4
""" this program is used to find the quadratic roots author:Laxman Raikar since:8 JAN,2019 """ from tech import functional try: a = int(input("Enter the value of a ")) b = int(input("Enter the value of b ")) c = int(input("Enter the value of c ")) functional.quadraticFunctions(a,b,c) # calls...
6a6b0972cbd1dcf62ca827482e55d07e4af017a0
HIT-jixiyang/offer
/banlance_tree.py
1,524
3.53125
4
# -*- coding:utf-8 -*- class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def IsBalanced_Solution(self, pRoot): # write code here self.deep = {} self.getDeep(pRoot) return self.isBan(pRoot) def isBan...
bccfabbd00eeb884107f1bd1ef3fa8705f272865
asliboyar/freshman_codes
/assignment_4.py
1,883
4.5
4
''' Write a python program with appropriate comments that accepts an input text file from user and performs the following operations: - Reads the file and finds the longest word in the file and writes the length of the longest word, longest word, and its line number in the source file to a result file (all the results...
f714f1cb2aa6b511990cfeeffe14888c06b3d912
aamlj/GitPython
/reverseOrder_MikeJones.py
277
4.09375
4
#a = input("Enter fifteen numbers in [ ] seperated by commas to be reversed: ") #a.reverse() #print ("Your numbers reversed are", a) #author: Mike Jones # This program will return a list of numbers in reverse order using the append command # and the reverse function
cd120a7c977322d6bdda4b825c2759a64156690a
andrewlee21/PythonFundamentals
/Weeks 1-2/cc_nestedif.py
243
4.09375
4
priceIsRight = 15 if priceIsRight<5: print("Price is too low!") elif priceIsRight>=5 and priceIsRight<=9: print("Price is almost there!") elif priceIsRight==10: print("Price is exactly that!") else: print("Price is too high!")
34a873caa3c40e219985d3c40ed7fef17c7a82e7
juanfariastk/FunnyAlgorithms
/Factorial/Factorial.py
484
4.28125
4
def factorial(n): fact = 1 for i in range(1, n+1): fact *= i return fact def factorial_recursion(n): if (n == 0): return 1 else: return n * factorial_recursion(n-1) number = int(input("Enter a number: ")) if num < 0: print("Sorry, Factorial does not exist for negative ...
3df75daafd0477df1c0cddd7ee2f2bc1ff4d7416
ronaldvilchez98/Santotomas_estructuras_programacion
/python_3/guia4/Ejercicio_7.py
1,038
4.0625
4
''' :::::::::::::::::::::::::::::::::::::::::::::: :: @github: adrian273 :: :: @email: adrianverdugo273@gmail.com :: :::::::::::::::::::::::::::::::::::::::::::::: 7@ Lea las horas trabajadas de un trabajador, valor hora, número de cargas y determine,Si el número de carga...
d6c14b925991cd8fc80cc012a12f8708b867c7d6
fadhiladiahap/Fadhila-Diah-Ayu-P._I0320038_Andhika_Tugas7
/I0320038_Soal1_Tugas7.py
323
3.546875
4
# Metode center Judul = "Survei Pelanggan Rumah Makan Selera Kita" a = Judul.center (50,'=') print (a) # Metode endswith str = "Apakah makanannya higenis?" print("Apakah makannnya higenis?") print (str.endswith("higenis?")) #Metode replace dan endswith str = "Apakah makanannya enak?" b = str.replace ("enak","sedap") ...
9ee1b825d49e9187a2afce2897f03280abca332d
Mepacor/AdventOfCode
/5/main.py
1,113
3.765625
4
# Reading data and defining general functions boardingPasses = open("boarding-seats.txt", 'r').read().splitlines() def binToDec(string): result = 0 for index, char in enumerate(string): result += toBit(char) * (2 ** (len(string)-index-1)) return result def toBit(char): if(char == "B" or char ...
2c3ab1c730c64088ec1d6f768d5634d556417ff7
Tuchev/Python-Fundamentals---january---2021
/10.Exams/03. Programming Fundamentals Final Exam Retake/03. Need for Speed III.py
1,761
3.875
4
class Car: def __init__(self, car_name: str, mileage: int, fuel: int): self.car_name = car_name self.mileage = mileage self.fuel = fuel n = int(input()) garage = [] for _ in range(n): car_name, mileage, fuel = input().split("|") car = Car(car_name, int(mileage), int(fu...
0cfc5f52a1b0bb0b35a34b5d5660f4b92ac02734
bruno-victor32/Curso-de-Python---Mundo-1-Fundamentos
/ex030.py
164
3.921875
4
n1 = int(input('Digite na tela um número inteiro: ')) res = n1 % 2 if res == 1: print('O número digitado e IMPAR') else: print('O número digitado e PAR')
0296bf48105d04f51407e54d7c5102551848ec91
jchigne/T09_ChigneGarrampie
/ChigneGarrampie/funciones24.py
570
3.640625
4
# Ejercicio 23 import os import libreria # Calcular el area lateral de una piramide # Declaracion de datos #imput pi=int(os.sys.argv[1]) radio=int(os.sys.argv[2]) generatris=int(os.sys.argv[3]) piramide=libreria.piramide(pi,radio,generatris) if (piramide>=200): # Si la piramid...
0c64ae29817587b9073ac98b4ce98cc78119c062
Malak-Ghanom/Python
/Class_Assignment/CA04/q4.py
400
4.0625
4
"""Given a list of numbers iterate over it and print numbers which are divisible by 5. If you find number greater than 150 stop the exit iteration.""" my_list = [20,13,15,80,99,111,116,120,170] print(f"The numbers that are divisible by (5) are: ", end=" ") for i in range(0,len(my_list)-1): if my_list[i]> 150: ...
0db6403ffa26562178f64642c73198a1bcff593f
Nikdwal/YetAnotherScrambleGenerator
/yasg/scramble.py
470
3.984375
4
import kociemba # the inverse of a single move def inverse_move(move : str): if len(move) <= 1: return move + "\'" if move[-1] == "'": return move[0] return move # the inverse of an algorithm def inverse_alg(alg : str): return " ".join(reversed([inverse_move(move) for move in alg.split...
26fd68aa9be0e213353292bf55516fdf18737e47
romponciano/py_useful-scripts
/replace-image-pixels.py
539
4.125
4
# Rmulo Ponciano # 03 Nov 2018 # This script replace all the pixels of a defined color, in an image, for another defined color. E.g. If you want to replace all red pixels with white pixels. from PIL import Image imgPathWithFormat = '' rgb = (0, 0, 0) finalColor = (255, 255, 255) imgOutputPathWithFormat = '' im = Im...
4412d560d7b31d2b5aa3551953a543226be1a390
Damoy/AlgoTraining
/AlgoExpert/src2/python/RemoveKthNodeFromEnd.py
1,205
3.859375
4
class LinkedList: def __init__(self, value): self.value = value self.next = None def getNodesInArray(self): nodes = [] current = self while current is not None: nodes.append(current.value) current = current.next return nodes def removeKth...
93cdf9cc7a1e1dc5cd3acb9ba1e3c403fc2748cf
vitalizzare/NumFOCUS_Telethon_by_James_Powell
/code_snippets/Z_zip.py
1,260
3.640625
4
''' From the @NumFOCUS telethon title: Z for zip author: @dontusethiscode date: December 19, 2020 python version: >= 3.8 video: https://youtu.be/gzbmLeaM8gs?t=15648 edited by: @vitalizzare date: January 10, 2021 ''' xs = [1, 2, 3, 4, 5, 6, 7] print(f'{xs = }') for x, y, z in zip(xs[0:], xs[1:], xs[2:]): print(f'...
4112228fae4c271fb32c4aaccbc858e21625bdef
machinemessiah/python-sample-neural-networks
/3L3D1SizeNetwork.py
12,040
3.5625
4
import sys #print (sys.version) #sys.exit() import numpy as np def pprint(*arg): for a in arg: print(a) return def prnt(*arg): for a in arg: print(a) return # sigmoid function # this is used to output a probability value between 0 and 1 from any value # we use a sigmoid function as a default model def nonlin...
96bf7d6ee8aaf93b1a95ab958c26e69dd0e0d0e3
SMS-NED16/crash-course-python
/python_work/chapter_7/exercises/7_4_pizza.py
221
4.21875
4
user_input = "" while user_input.lower() != 'quit': user_input = input("What topping would you like to add to your pizza? ") if user_input.lower() != 'quit': print("Adding " + user_input.title() + " to your pizza.")
3ae4f01221e3508b79cd7135a1cfd360a8245c13
Saboorhub/movie_website
/media.py
1,086
3.9375
4
#the webbrowser module is imported so the open(url) function can be used to allow for displaying web page contents. import webbrowser #As the doc string states, this class is used to store movies-related information which are then used with other modules or files such as entertainment_center and fresh_tomatoes. clas...
956ed834afa213f012df30c677ed7ac164f708ed
paulolemus/leetcode
/Python/add_digits.py
971
3.796875
4
# Source: https://leetcode.com/problems/add-digits/description/ # Author: Paulo Lemus # Date : 2017-11-16 # Info : #258, Easy, 92 ms, 92.50% # Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. # # For example: # # Given num = 38, the process is like: 3 + 8 = 11, 1 +...
46b9e87c2c97450e20bdf258c9d24c47a8a8c909
codeperson1/coderbytes
/array_addition.py
897
3.703125
4
def ArrayAddition(arr): # tmparr = arr.copy() tmparr = [] for i in range(0, len(arr)): tmparr.append(arr[i]) tmparr.sort(reverse=True) most = tmparr[0] for i in range(0, len(tmparr)-1): total = tmparr[i] j = i + 1 while(j < len(tmparr)): ...
10a53f64bb745f4ff74151f36854556ebd924b3b
raotarun/ASSINMENT-python_advance
/ASSINMENT-python_advance/ASSIGNMENT13.py
1,886
4.59375
5
################################LIST COMPREHENSION & GENERATOR EXPRESSION########################## #Q.1- Write a python program to print the cube of each value of a list using list comprehension. lst=[1,2,3,4,5] lst=[i**3 for i in lst] print(lst) #Q.2- Write a python program to get all the prime numbers in a spec...
b98efc9ee480c1de93ae6a9949280fa0bdc25968
leet23/python_kurs
/03_Kolekcje/LISTzad5.py
811
3.59375
4
'''Utwórz “na sztywno” 2-wymiarową tablicę, tak, by kolejne wiersze zawierały dane osób, natomiast w kolumnach będzie znajdować się imię, nazwisko, zawód, np: Dorota, Wellman, dziennikarka Adam, Małysz, sportowiec Robert, Lewandowski, piłkarz Krystyna, Janda, aktorka Wyświetl w sposób przyjazny dla użytkownika''' t...
106e09f271a148a511df01bdef495cb12172b3d4
EVERLYNE/python-class
/income.py
912
4.03125
4
class Taxpayer: income = 0 name = "Jane Doe" minimum = 0 def __init__(self,name, income ,minimum): self.income = income self.name = name self.minimum = minimum self.validateIncome() self.validateName() self.ValidateMinimum() def validateIncome(self): if self.income.isnum...
86734f4f0b422a213480654aa1215c0a48084bb9
YiWaiChow/leaguetool
/main.py
2,756
3.6875
4
from Champion.Champ_List import ChampionList from Champion.Score.ScoreCalculator import Scorecalculator from Champion.Score.decisionTree import ScoreAVLTree from Game.CurrentGame import Game from User.User import User CL = ChampionList() CG= Game() name = input("enter your user name below:") perfer = input("enter your...
3024f8db2db0c05114bfa1bfd2696c5c7fe3e1c9
anchalgithub/Project-100
/atm.py
1,588
4.03125
4
print("Welcome to the Toronto Bank.") class atm: def __init__(self,cardNo,pin): self.cardNo=cardNo self.pin=pin def check_balance(self): print("Your balance is 50K.") def withdrawl(self,amount): if amount<50000: new_amount=50000-amount ...
c0988dcf62d0c384ff26f8692a5dda7eaa8d4b50
ahmedyoko/python-course-Elzero
/string7.py
3,869
4.34375
4
# string method ####################### # method is the function of object or dotted function to do something #1-len => length or the number of the characters #2-strip method : to remove space from the right and left , rstrip : for right only, lstrip : for left only #3-Title method : convert first letter to capital ca...
3f5d1a9ec154209edb7adbf888e08eb2ff4d4039
slohani-ai/Set_password_at_Terminal
/user_pass.py
4,716
3.640625
4
'''@Sanjaya Lohani, Uploaded July 24, 2017''' import sqlite3 as sq import getpass import os import sys def open_account(name): def openn(): conn = sq.connect(name) cur = conn.cursor() #cur.execute("DROP TABLE IF EXISTS ACCOUNTS") cur.execute('''CREATE TABLE ACCOUNTS (ID INTEGER PRIMARY K...
67ff30bf6095d176377d78a8d233491240b29a24
pybites/challenges
/39/habereet/wordvalue.py
944
4.0625
4
from data import scrabble_scores, LETTER_SCORES def get_data_file(): return "dictionary.txt" def read_dictionary(): with open(get_data_file()) as file: lines = file.readlines() lines = [line.strip() for line in lines] return lines def word_value(word): word_score = 0 for character in word: if character....
ea6085172dc3034af4a6fd2f33b8dc880c5779fc
zorga/python
/divers/prod.py
304
3.6875
4
#!/usr/bin/python from itertools import product def main(): A = map(int, raw_input().strip().split(' ')) B = map(int, raw_input().strip().split(' ')) res = (list(product(A, B))) fin = "" for e in res: fin += str(e) + ' ' print fin if __name__ == '__main__': main()
7e69d07c6b5c07417b7f36e8ed923614d7a0d895
kxu68/BMSE
/examples/AY_2017_2018/semester_2/Week 6- Non-parametric statistics/Statistics_is_Easy_Codes/OneWayAnovaSig.py
7,374
3.921875
4
#!/usr/bin/python ###################################### # One-Way ANOVA Significance Test # From: Statistics is Easy! By Dennis Shasha and Manda Wilson # # Assuming that there is no difference in the three drugs used, tests to see the probability # of getting a f-statistic by chance alone greater than or equal to t...
4d59faad874c3d94d1e7daba1d3b9080fe1b7baf
KDjonev/SyllabusParser
/venv/VotedPerceptron.py
3,119
3.78125
4
import csv from math import log def RunVotedPerceptron(Xtrain_file, Ytrain_file, test_data_file, pred_file): '''The function to run your ML algorithm on given datasets, generate the predictions and save them into the provided file path Parameters ---------- Xtrain_file: string the path to Xtr...
225f18c7342af2874635578a53241566268c2bb5
cliu0507/CodeForFun
/Coding Topics/Binary Search Tree/Search and Insertion.py
2,017
3.75
4
BST Search and Insertion Binary Search Tree, is a node-based binary tree data structure which has the following properties: The left subtree of a node contains only nodes with keys less than the node’s key. The right subtree of a node contains only nodes with keys greater than the node’s key. The left and right subtr...
2e314abb7161302971b9d9e1f6303d7c9928ad17
gmaurer/algorithmPractice
/structures/bfs.py
968
3.53125
4
from assets import graph, queue def breadth_first_search1(graph, start, target): frontier = queue.Queue() frontier.put(start) visited = {} visited[start] = True while not frontier.empty(): current = frontier.get() print("Visiting %r" % current) if current is target: ...
e594930a374c348c6eba7a60a1932cfb375be658
DILLORG/CIS189
/Module 13/numberGuesser/game/numberGuesser.py
2,170
3.953125
4
from random import randint, shuffle class NumberGuesser: def __init__(self, min, max, amount): """ Construct all number guesser objects :params min smallest generated number, max largest generated number amount amount of numbers to generate. :returns NumberGuesser. ...
74ac39d1dfaf7036a56fcc239a83dcf52eed3fe8
sandykrishdaswani/5-1.py
/5-18.py
64
3.59375
4
z=int(input()) sum=0 for i in range(1,z+1): sum +=i print(sum)
426cf3cae5172633c4d28bc52af8778c78725f04
viewv/leetcode
/35. Search Insert Position.py
219
3.6875
4
class Solution: def searchInsert(self, nums, target): nums.append(target) nums=sorted(nums) for x in range(0,len(nums)): if nums[x]==target: break return x
7ada7cb544d8bdb1c651bab03c9ca4d7be7a7e15
jwyx3/practices
/leetcode/dynamic-programing/count-the-repetitions.py
1,719
3.546875
4
# https://leetcode.com/problems/count-the-repetitions/ # http://www.cnblogs.com/grandyang/p/6149294.html # find repetition pattern for s2 from S1 # find count of s2 in S1 as count, then answer will count / n2. # the problem can be two subproblems: count of repeat pattern part and remaining part # use Pigeonhole Princip...
3bce7717ccc755a128b2a8e614155bd97dab0b48
s38m/Python_learning
/password_guest.py
377
3.53125
4
#encoding = utf8 #password guest print('猜密碼遊戲') pwd = '123456' chance = 3 while chance > 0: data = input('請輸入密碼: ') chance -= 1 if pwd == data: print('恭喜你!猜對了!') break else: if chance > 0: print('密碼錯誤! 剩餘%d次機會' %chance) else: print('遊戲失敗!!')
3284e932c2feb37b54fc25c3987665a320f7be46
HasunSong/maestro-gtl-mileage
/mileage_graph.py
1,339
3.59375
4
# %% import numpy as np import matplotlib.pyplot as plt # 주어진 E(e)와 초기 마일리지에 대해, 예상되는 진행 라운드 수를 대강 예상한 것. def max_round(e, init_mileage): cost = 0 for k in range(1, 100000000): if cost + (k+e) > init_mileage: return k-1 else: cost += (k+e) # 총 라운드 진행 수 K와, 라운드별 보상 poi...
95d1d9824513e8c9b1ee02100f50cc71e8e21252
adarshav/Python-
/assignment4a.py
4,390
4.125
4
#1. Find the maximum of three numbers. # def max(a, b, c): # if(a > b): # if(a > c): # return a; # elif(b > c): # return b; # else: # return c; # print(max(3,9, 5)); # 2. Find the sum of the numbers in a list. # def sum(list1): # sum = 0; # for i in list1: # ...
975593541457bce016567ded8efbf51c0a12da69
laxminagln/IOSD-UIETKUK-HacktoberFest-Meetup-2019
/Beginner/fibonacciSequence.py
675
4.34375
4
########################## Code By - ORASHAR ########################### ########################## Fibonacci Sequence ########################### def Fibonacci(n): n1 = 0 n2 = 1 c = 0 ans = [] if n == 1: ans = n1 else: while c < n: ans.append(n1) nth = ...
74635914f2726b51d2a7b1fca2ab180674ad5eab
jinho9610/py_algo
/sw_academy/2050.py
97
3.515625
4
data = list(input()) for i in range(len(data)): print(ord(data[i]) - ord('A') + 1, end=' ')
718bee2247c870bfd52d223c45b42796834edf9d
sergiogbrox/guppe
/Seção 4/exercicio12.py
565
3.953125
4
""" 12- Leia uma distância em milhas e apresente-a convertida em quilômetros. A fórmula de conversão é: K=1,61*M, sendo K a distancia em quilômetros e M em milhas. """ print('\nDigite uma distância em milhas para ser convertida em quilometros\n') milhas = input() try: milhas = float(milhas) print(f''' ...
2ec08599413f86e31d80b13b3a7af37d7fbf1c0a
YaChenW/LeetCode
/876. Middle of the Linked List.py
535
3.90625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def middleNode(self, head, depth=1, stop=-1): """ :type head: ListNode :rtype: ListNode """ if stop == -1: stop =...
168fa00ddc607c36de61c958124be6b0856f43a0
k4nuck/practice
/LinkedList.py
2,396
4.1875
4
import os class ListNode(object): def __init__(self): self.next = None self.value = None self.prev = None class LinkedList(object): def __init__(self): self.head = ListNode() self.tail = self.head self.head.value = 1 self.num_nodes = 1 # Add a new node at the head of the list def append(self,n...
d58f3293579765b743b4c794596ad1caeaf1461f
tuhiniris/Python-ShortCodes-Applications
/file handling/Read a String from the User and Append it into a File.py
505
4.21875
4
''' Problem Description: ------------------- The program takes a string from the user and appends the string into an existing file. ''' print(__doc__) print('-'*25) fileName=input('Enter file name along with path: ') file3=open(fileName,"a") string=input('Enter string to append: ') file3.write(string) file...
84e672eeeabe633e629c5e5c65f0eddccff95798
KrisCheng/HackerPractice
/Python/oop/property.py
1,361
3.78125
4
# @property # -*- coding: utf-8 -*- # without property # class Student(object): # def get_score(self): # return self._score # # def set_score(self, value): # if not isinstance(value, int): # raise ValueError('score is not a integer!') # if value < 0 or value > 100: # ...
46f7374a7bbbced567979f480fbea3c249d40a14
chefmohima/DS_Algo
/min_heap_implementation.py
1,864
3.671875
4
# Min heap implementation class minHeap: def __init__(self): self.heap = [] def insert(self,val): self.heap.append(val) if len(self.heap) > 1: self.restoreUp(len(self.heap)-1) def getMin(self): if self.heap: return self.heap[0] return None def remov...
72e7ff0d8e2efd5db7fff1d5a79b646a0dfda01c
coreyryanhanson/tanzania_water_project
/visualization_functions.py
10,822
3.65625
4
import functools import pandas as pd import seaborn as sns import numpy as np import matplotlib.pyplot as plt class Multiplot(object): """An object to quickly generate multiple plots for each column in a DataFrame""" def __init__(self, df, n_cols=3, figsize=(15, 15), style="darkgrid"): """Sets up the...
ce8a8cb5a96d364ee9a01545c4a27429518aca7c
fikriauliya/CS6.006
/dynamic_programming_test.py
1,489
3.640625
4
import unittest from dynamic_programming import * class DynamicProgrammingTest(unittest.TestCase): def test_fibonacci(self): self.assertEqual(fibonacci(1), 1) self.assertEqual(fibonacci(2), 1) self.assertEqual(fibonacci(3), 2) self.assertEqual(fibonacci(4), 3) self.assertEqual(fibonacci(5), 5) ...
e7ea691047aa336b116a8bacead90686cf8cd445
bcdavis/python-scripts
/scripts-2017/1-99.py
1,004
4.65625
5
#1 use for loop to print odd numbers form 1 to 99 """ for i in range(1,100,2): print(i) """ #2 use for loop to print the multiples of 3 from 300 down to 3 """ for i in range(300,2 ,-3): print(i) """ #3 use for loop to print the first power of 2 starting at 2 """ prod = 2 print(prod) for i in range(9): pr...
b221d1b04ce209be539b01022b029425250b2edc
alivcor/leetcode
/20. Valid Parentheses/main.py
525
4
4
def isValid(s): """ :type s: str :rtype: bool """ stack = [] match = {'(': ')', '{': '}', '[': ']'} for x in s: if x == '(' or x == '{' or x == '[': stack.append(x) elif x == ')' or x == '}' or x == ']': if len(stack) > 0 and x == match[stack[len(stac...
32faf3f2fa4e78271ea6d800ab06838862276e56
Duckancover/02_python_puzzle
/brascets.py
1,114
3.609375
4
# -*- coding: utf-8 -*- """ Created on Mon Dec 4 13:40:20 2017 @author: Oleg.Shcherbinin """ def checkio(expression): d = {"{":1, "[":2, "(":3} e = [] f = {"}":1, "]":2, ")":3} for i in expression: if i in d.keys(): e.append(d[i]) if i in f.keys(): ...
d392e65a3adbd71c97945b87a4651343c1a7040e
datalyo-dc-m1/tp-python-AwfulJojo
/tp1/guess_number.py
1,594
4.03125
4
# from random import randint # number_to_guess = randint(0, 10) # has_won = False # while has_won is False: # user_propal = int(input("Essayez de deviner le nombre entre 0 et 10 : ")) # while user_propal < 0 or user_propal > 10: # print("Vous devez entrer un nombre entre 0 et 10 !") # user_propa...
21552a2d049c363f4bd746e440586fb8c6cf597c
mmiocic/MarketPolo
/MarketPolo_Py38/main.py
7,064
4.03125
4
# Description : This program uses an artificial recurrent neural network called Long Short Term Memory (LSTM) # to predict the closing stock price of a corporation (Apple Inc.) using the past 60 day stock price. # Import libraries import math import pandas_datareader as web import numpy as np import pand...
5d7344e3f26aaddf774cc11d8fd1e996a2b38c06
Pyk017/Python
/Tkinter/Radio_Button_and_Message_Boxes.py
2,398
3.71875
4
from tkinter import * from tkinter import messagebox root = Tk() root.title("Tkinter") root.iconbitmap("G:\Tkinter\Images\MyIcon.ico") mylabel1 = Label(root, text="This is a Radio Button and Message Box Combo.").pack() option = StringVar() option.set("showinfo") def clickable(val): if val == "showinfo": ...
c3cda5a5c9e98f7bc32286cb95bb2d86d1573a32
nickbaf/Snake-Adventure
/myLib2383.py
13,873
3.640625
4
#***************************************# # Nikolaos Bafatakis, AEM 2383 # # nikompaf@csd.auth.gr # # Snake Adventure Beta v1.10.0 # # # # >>Libraries<< # #***************************************# import ...
264d742b5948faf19305f86d3d36f54eeb3fd62f
heneryville/aind-udacity
/isolation/tests/reachability_test.py
2,725
3.515625
4
import unittest import isolation import game_agent from reachability import * from importlib import reload class ReachabilityTest(unittest.TestCase): def test_it_finds_reachability_on_open_board(self): player1 = "Player 1" player2 = "Player 2" game = isolation.Board(player1, player2, 4,4...
3f81ae070a09cd33d6075a74a0baedaad99bd4f9
ParkDAY/basic1
/basic1.py
1,288
3.5
4
#직원들의 급여를 5%인상하고 거주 지역을 파악하는 코드 SALARY_RAISE_FACTOR=0.05 # 5%인상하기 위한 변수 STATE_CODE_MAP = {'WA': 'Washington', 'TX': 'Texas'} # key와 value를 할당하는 문법{} def update_employee_record(rec): # def는 define. 즉 정의하는 것. rec은 딕셔너리를 사용하는 매개변수. old_sal = rec['salary'] new_sal = old_sal * (1 + SALARY_RAISE_FACTOR) rec['sa...
b0f10b174ed1b6c19816d7cd6363164ecc977446
JasonMace/Tic-Tac-Toe_final
/Problems/Party time/main.py
153
3.6875
4
names = list() actual = "" while actual != ".": actual = input() if actual != ".": names.append(actual) print(names) print(len(names))
64c50d61c43dca374d27774c8e382634fae4191c
AdvonKoulthar/DanzaharArteest
/tooltip.py
3,212
3.609375
4
import tkinter as tk import math class Example(tk.Frame): def __init__(self, *args, **kwargs): tk.Frame.__init__(self, *args, **kwargs) self.l1 = tk.Label(self, text="Hover over me") self.l2 = tk.Label(self, text="", width=40) self.l1.pack(side="top") self.l2.pack(side="top"...
542f339220419b31ca91c909d33a8da4bbec4b63
gguillamon/PYTHON-BASICOS
/python_ejercicios basicos_II/Ejercicio9.py
530
3.9375
4
# 9.- Escribir un programa que pida cuatro números enteros por teclado y determine el mayor y el # 2 # menor de los cuatro números. Ejemplo: # Introduzca 4 números enteros: 20 34 10 -18 # Mayor número: 34 # Menor número: -18 mayor=1 menor=0 numeros=[] for i in range(4): elementos=int(input("Introduzca un numero: ")...
79cc62b5e9eb6f6ceb412579886bca1b8868298d
serdarkocerr/Python_Calismalar
/ornekler.py
15,732
4.03125
4
#!/usr/bin/env python # coding: utf-8 # In[3]: sayi = 1; while(sayi<10): print(sayi) sayi = sayi+1 # In[4]: for sayi in range(10): print(sayi) # In[5]: for sayi in range(1,10): print(sayi) # In[6]: for sayi in range(10,1,-1): print(sayi) # In[7]: basariNotu = 50; if(basariNotu > 5...
1520dcca401820d363cf8d39136fdf5dfec9b280
Jamaliela/Intro-to-Classes
/t13_point.py
4,349
4.3125
4
###################################################################### # Author: Emily Lovell & Scott Heggen TODO: Ela Jamali & Thomas West # Username: lovelle & heggens TODO: Jamalie & Westt # # Assignment: T13: Intro to Classes # # Purpose: Demonstrates a Point class and a related main() to create o...
24086693998f535168f9594d6a7c88f14ecb7006
thirihsumyataung/Python_Tutorials
/inherentence_Area_Calculation_Python.py
806
3.96875
4
class Area: def __init__(self, length , width, height): self.length = length self.width = width self.height = height def getLength(self): return self.length def getWidth(self): return self.width def display(self): print(f'Length is: {self.length} ') ...
9ebc8072d48df6cc0efea3fc0422268c7a86c38e
sashapotash29/CTCI_brainteasers
/chapter_1_arrays_and_strings/1_arrays_strings.py
4,301
4.25
4
# 1.1 is unique? - Determine if a string contains unique characters def is_unique(string): comparison_list=[] for letter in string: if letter.lower() in comparison_list: return False comparison_list.append(letter.lower()) if len(comparison_list) == len(string): return True else: pass # # TESTIN...
41bc4f6869948ac6b9f7b4f011cb79ef98a7368d
pahuja-gor/Python-Lectures
/CS 1064/dictionary_lookup.py
2,529
3.8125
4
import time def load_words(): ''' This function opens the words_alpha.txt file, reads it line-by-line, and adds the word with a different fake definition into both a list and a dictionary ''' with open('words_alpha.txt') as word_file: word_list = [] word_dictionary = {} ...
69e2a85ce1d61c83fe24b7061415669fbe135f53
XZANATOL/HR-PS
/Python/Easy/Text Wrap/Method.py
555
3.96875
4
#!/bin/python3 import textwrap def wrap(string, max_width): # count variable to add a newline for the max_width value count = 0 # string after wrapping variable output = "" # convert into list string = list(string) # wrapping loop for i in string: output += i count +=1 ...
05148eb7c5e7af4e59bdb6099937de6a2eb53684
snowlance7/Python-Projects
/week5/tree_pattern.py
263
4.03125
4
print("Tree Pattern\n") branches = int(input("Enter the number of branches: ")) def printTree(maxN): def tree(n): if n > 0: tree(n-1) print(n,"*" * n * maxN) tree(n-1) tree(maxN) printTree(branches)
af4047e7ebcc15abfc144b2c83c3e3196b8a72a0
francosbenitez/unsam
/04-listas-y-listas/05-arboles-2/lista-de-altos.py
743
3.5625
4
""" Ejercicio 4.19: Lista de altos de Jacarandá Usando comprensión de listas y la variable arboleda podés por ejemplo armar la lista de la altura de los árboles. H=[float(arbol['altura_tot']) for arbol in arboleda] Usá los filtros (recordá la Sección 4.3) para armar la lista de alturas de los Jacarandás solamente. """...
776893028cff2254a172405757fcad8f4806af75
Aasthaengg/IBMdataset
/Python_codes/p03803/s651862453.py
125
3.515625
4
M,N = map(int,input().split()) if M == N: print('Draw') elif (M>N and N!=1) or M==1: print('Alice') else: print('Bob')
8d25d7eaaa4831572cff7471af811861dafc9477
Dilip992801/Assignment_4
/321810304005_prime no.py
259
4.09375
4
def prime(n=int(input('Enter a number: '))): if n<=1: return False elif n==2: return True else: for i in (2,n//2): if(n%i==0): return False return True if(prime()): print('Number is prime number') else: print('Number is not prime number')
e7d0483533d01794877cd262dd43c7420578a2d1
Avery123123/LeetCode
/dataStructure/queue/Dqueue.py
944
3.828125
4
class DQueue(object): def __init__(self): self.data = [] def isEmpty(self): return self.data == [] def insertHead(self,newElem): self.data.insert(0,newElem) def insertTail(self,newElem): self.data.append(newElem) def deleteHead(self): if self.isEmpty(): ...
93d3bc2a9eeb1ae1b5c9610aee0524242d976a0b
Remyaaadwik171017/mypythonprograms
/collections/dictionary/dict2.py
282
3.796875
4
employee={"id":1001,"employee_name":"remya","designation":"manager","salary":20000} print(employee["employee_name"]) print("company" in employee) employee["company"]="luminar" print(employee) employee["salary"]+=15000 print(employee) for i in employee: print(i,":",employee[i])
c37166f6bd9ecf9217d30419d3faf2e4917f6fc7
alexcarlos06/CEV_Python
/Mundo 1/Desafio 026.py
875
4.375
4
# Faça um programa que leia uma frase pelo teclado e mostre #quantas vezes aparece a letra desejada e em que posição ela aparece a primeira vez e em que posição ela aparece a úlitma vez # Lendo o nome informado excluindo os espaços do inicio e do final da frase e transformando todos os caracteres da sting em letra mai...
685de3db9b7ea6967629302afcc30a6f401ceca4
negonzalez1024/Python
/Ejercicio2.py
202
3.78125
4
def calcularnumero(numero): while 1: if numero%2==0: aT = True else: aT=False if aT: print("El numero es par") else: print("El numero no es par") return aT
f48a14cbfcf33d4b6fedb3792f1d2e947d5b50f7
ger-hernandez/UTP-backup
/week3/while5.py
250
3.5625
4
#Mostrar los múltiplos de 8 hasta el valor 500. Debe aparecer en pantalla 8 - 16 - 24, etc. def while_exercise5(): i = 1 m = 8 r = 0 while r < 500: r = m * i print(f'{r}', end = '-') i += 1 while_exercise5()
514054723de2954d274c021457426660087f5742
mahaderony/Computational-Methods-In-Hydrology
/P1.py
1,194
3.921875
4
# Problem 01: Calculating Cosine of an angle with Maclaurine Series and comparing it with exact result import math x = int(input('Enter the angle in degree ')) xr = float(x * (math.pi / 180)) # Using Exact Formula Exact_cos = math.cos(xr) print('The Exact value of Cos', x, 'degree is', Exact_cos, ) # Using Macla...
f8abf3c1a6c5f61ed350ed5bfa0ba21e0371c628
WitRud/Python
/acro.py
1,030
3.515625
4
import re try: inputFile = open('inp.txt','r') inputF = inputFile.read() inputFile.close()#opening file except IOError: print "Cannot read a file . Check if inp.txt exists in this directory" else: names = re.findall(r'[A-Z][a-z]*\s[A-Z][a-z]*',inputF,re.M|re.S)#list of names(first na...
73991166ce413af12df6f4a0b204e5d5b455737e
Madhivarman/DataStructures
/leetcodeProblems/removeDuplicates.py
560
3.859375
4
""" Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. """ def removeDuplicates(nums): seen = set() count = 0...
dfa67916c3170ca81507f71241f7336b1e0e5d7c
anaswara-97/python_project
/exam2/file_obj.py
489
3.703125
4
class Student: def studDetails(self,name,roll,course,mark): self.name=name self.roll=roll self.course=course self.mark=mark def display(self): print("name : ",self.name) print("roll no : ",self.roll) print("course : ",self.course) print("mark : ",s...
874f89495b2c241a2d81b1aea256a5a6dc36eb29
yangwei-nlp/LeetCode-Python
/OldBoy/p9_4 栈和队列.py
1,612
3.78125
4
# 记住原则,栈:后进先出;队列:先进先出。在编程中,我们常常用到这两个简单的原则来帮助我们解决复杂的问题。 # 检测括号是否有效 def bracket_match(s): """ 检查括号是否有效 """ stack = [] d = {'{':'}', '(': ')', '[': ']'} for cha in s: if cha in ['(', '[', '{']: stack.append(cha) elif cha == d[stack[-1]]: # 消掉,如[] ...
d0d79240fe9198925a0c15d5465a4a3d96de60d5
TessFerrandez/AdventOfCode-Python
/2017/Instruction.py
627
3.5
4
class Instruction: def __init__(self, instr_str): parts = instr_str.strip().split(" ") self.dest = parts[0] self.op = parts[1] self.by = int(parts[2]) self.left_comp = parts[4] self.comp = parts[5] self.right_comp = int(parts[6]) def __str__(self): ...
2cdfa125086a97e778d7b5b78847c9da6d7aadcb
TryNeo/practica-python
/ejerccios/ejerccio-89.py
1,230
4.1875
4
#!/usr/bin/python3 """ Omirp se define como un número primo que al invertir sus dígitos da otro número primo. Escriba un algoritmo para determinar si un número n tiene la característica de ser un número Omirp. """ def isPrime(num): if num < 1: return False elif num == 2: return True else: ...
86960227f33e6733636c1f9ddcd88bc33f1a10e5
AvramPop/Fundamentals-Of-Programming
/lab03/Validation/ExpenseValidation.py
890
3.90625
4
from Constants import * def isValidDay(day): """ Checks whether day is a valid day (it is a natural number between 1 and 30) :param day: (int) the day to be checked :return: True if day is valid, False otherwise """ return type(day) == int and 1 <= day <= 30 def isValidAmount(amount): ""...
26436cb63a73a5618133638e421a071620b4e5b2
Jecoro/BoletinPythonVoluntario
/EJ5.py
636
3.65625
4
class Peers(object): # Atributo de Clase. list_Numbers = [10, 20, 10, 40, 50, 60, 70] # Constructor. def __init__(self, int_Obj): self.int_Obj = int_Obj # Método de Instancia. def findPeers(self): for i in range(len(self.list_Numbers)): if (self.list_Numbers[i] + self.list...
c702961173e9941be0ac766b09ee1d90a6799f07
dswisher/rosalind
/BioinformaticsStronghold/revp/revp.py
732
3.703125
4
import sys if len(sys.argv) < 2: print 'You must specify the name of the file to load.' sys.exit(1) def read_fasta(fname): seq = "" with open(fname, "r") as file: for line in file: line = line.strip() if line[0] != '>': seq += line return seq def ...
e56ae5ed7eba7bf0721288e1eba05581215bf394
azavana/Machine-Learning_Deep-Learning
/Regression/Linear/linear_regression.py
855
3.609375
4
import tensorflow as tf import numpy as np import matplotlib.pyplot as plt learning_rate = 0.01 training_epochs = 100 a = 2 # y = ax x_train = np.linspace(-1,1,101) y_train = a*x_train+np.random.randn(*x_train.shape)*0.33 # Solving linear regression X = tf.placeholder(tf.float32) Y = tf.placeholder(tf.float32) d...
6b901290181af0b3adc272bb6008a15a53d1d2dc
ncfoa/100DaysOfCode_Python
/027/gui_playground.py
969
4.125
4
from tkinter import * def reset(): label["text"] = "Hello World" def button_click(): label["text"] = "OMG YOU CLICKED IT!" def display_text(): label["text"] = text.get() # Create window w = Tk() w.title("Dave's Window") w.minsize(width=800, height=600) w.config(padx=20, pady=20) # Create border fra...
833a138a2fb25bf9354f196ec1845f5f2a8e2e81
1234567890boo/ywviktor
/OOPcoinfliptkcopy.py
1,011
3.859375
4
from tkinter import * from random import * class Guess: def __init__(self): self.window=Tk() self.select=StringVar() self.select.set('head') self.guess=['head','tail'][randint(0,1)] self.head=Radiobutton(self.window,text='head',variable=self.select,value='head') self...
98c2e9adfa0c288262cbfd2b0fe5b6a866b36f3b
nadav366/intro2cs-ex10
/ship.py
984
3.75
4
from game_object import * LIFE_QUANTITY = 3 START_DIRECTION = 0 class Ship(GameObject): """ A class that is the game ship. The class inherit GameObject. """ SHIP_RADIOS = 1 def __init__(self, x_location, y_location): """ Constructor ship :param x_lo...