blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
75c83598acdaf3a8bd2930d7408315655d32f744
AyushSri19-777/ITT-Lab2
/LAB5/A1.py
538
3.765625
4
m = int(input("Enter Lower limit:\n")) n = int(input("Enter Upper limit:\n")) prime = [] count=0 for i in range(m,n+1): if int(i/2)>=2: for j in range(2,int(i/2)+1): #print("i ",i," j ",j) if(i%j)==0: count=count+1 else: 1+2 ...
02b195ecf50754ea486e0480851b330a6037b7b0
nailyav/ssad
/program/main.py
327
3.515625
4
# official link: https://github.com/nailyav/ssad/edit/main/program/main.py s = input()[::-1].lower() alph = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] for letter in s: print(str(alph.index(letter) + 1), end=' ', flush=...
e8f8509c317c1461e425f946cba5e015a6a391cf
dalekim79/TicTacToe
/Board/Board.py
2,824
3.671875
4
import math import pandas as pd import numpy as np # N x N board (always square, any size # M connected marks for a win class Board: def __init__(self, length): self.rows = length self.cols = length # self.board = pd.DataFrame(); # print('in init') def create_board(self): ...
ee597ffadb3bcb27aa1ee9200dae91332139d191
thestellarl/python-neuroevolution
/PythonNN.py
1,362
3.578125
4
import math import numpy as np class NN: def __init__(self, w1 = None, w2 = None): if(w1 == None and w2 == None): self.weights1 = (np.random.rand(3, 4) - .5) * 2 self.weights2 = (np.random.rand(4, 2) - .5) * 2 else: self.weights1 = w1 self.weights2 = ...
518068c607539206a41bd775dbdf405c917ee543
heddilee/python
/week1/pratice3.py
2,786
3.765625
4
''' # ๋ฆฌ์ŠคํŠธ [] # ์ง€ํ•˜์ฒ  ์นธ๋ณ„๋กœ 10, 20,30 ๋ช… subway = [10,20,30] print(subway) subway = ["์œ ์žฌ์„", "์กฐ์„ธํ˜ธ", "๋ฐ•๋ช…์ˆ˜"] print(subway) # ์กฐ์„ธํ˜ธ๊ฐ€ ๋ช‡๋ฒˆ์งธ ์นธ? print(subway.index("์กฐ์„ธํ˜ธ")) #ํ•˜ํ•˜๊ฐ€ ๋‹ค์Œ ์นธ์— ํƒ“์„ ๊ฒฝ์šฐ subway.append("ํ•˜ํ•˜") print(subway) # ์ •ํ˜•๋ˆ์„ ์œ ์žฌ์„ ์กฐ์„ธํ˜ธ ์‚ฌ์ด์— ํƒœ์›€ subway.insert(1, "์ •ํ˜•๋ˆ") print(subway) # ์ง€ํ•˜์ฒ  ๋’ค์—์„œ ํ•œ ๋ช…์”ฉ ๊บผ๋ƒ„ print(subway.pop()) print(subw...
a4e082db11fca8aae2219f7a7a30d071b31647ce
heddilee/python
/week1/pratice2.py
2,499
4.09375
4
''' sentence = '๋‚˜๋Š” ์†Œ๋…„์ž…๋‹ˆ๋‹ค.' print(sentence) sentence2 = "ํŒŒ์ด์ฌ์€ ์‰ฌ์›Œ์š”" print(sentence2) # ์•ž๋’ค๋กœ ํ•œ ์ค„ ์”ฉ ๋น„์›Œ์ง sentence3 = """ ๋‚˜๋Š” ์†Œ๋…„์ด๊ณ , ํŒŒ์ด์ฌ์€ ์‰ฌ์›Œ์š” """ print(sentence3) ''' ''' #์Šฌ๋ผ์ด์‹ฑ jumin = "990120-1234567" print("์„ฑ๋ณ„ : " + jumin[7]) print("์—ฐ : " + jumin[0:2]) # 0๋ถ€ํ„ฐ 2์ง์ „๊นŒ์ง€ print("์›” :" , jumin[2:4]) print("์ผ :" , jumin[4:6]) print...
fc275b4452370213c90728f6afb249568854a3df
josephmorrisiii/pythonProject
/lab_three_one_eight.py
1,079
4.15625
4
#Student name - Joseph Morris #Student ID - 1840300 import math # Press the green button in the gutter to run the script. if __name__ == '__main__': #Part1 wall_height = int(input("Enter wall height (feet):\n")) wall_width = int(input("Enter wall width (feet):\n")) wall_area = wall_width * wall_height ...
8430eacaa8d07327f76588e345d9b10fdd565f56
josephmorrisiii/pythonProject
/lab_two_one_nine
2,751
4.25
4
#Student Name - Joseph Morris #Student ID - 1840300 if __name__ == '__main__': #Part 1 lemon_juice_cups = float(input('Enter amount of lemon juice (in cups):\n')) water_cups = float(input('Enter amount of water (in cups):\n')) agave_nectar_cups = float(input('Enter amount of agave nectar (in cups):\n')) n...
03da0289cff44f798991b547854bd7448ac60a85
geekture/trouver_chiffre_aleatoire_python
/number_guest.py
1,924
3.546875
4
#Importation du module random pour la valeur alรฉatoire import random #Importation du module date import datetime #Variable stockant la valeur alรฉatoire random_number = random.randint(1, 200) #Variable stockant le nombre d'essai effectuรฉ par l'utilisateur counter = 0 #Variable qui vรฉrifie si le programme est dรฉmarrรฉ ou ...
c9cb633f9e3485a904396aed4f330c99ff8b1b99
VoLinhTruc/pyExample
/work-with-file/tempCodeRunnerFile.py
273
3.609375
4
for file_name in os.listdir(this_dir_path): if(os.path.isfile(this_dir_path + "\\" + file_name)): base_name, extension = os.path.splitext(file_name) print("This is file: " + base_name + extension) else: print("This is folder: " + file_name)
8abcfcc0a81f66e787278d60bc891df5418d2ffa
AvanindraC/Python
/string.py
298
3.984375
4
# Write a Python program to get a string which is n (non-negative integer) copies of a given string def str_multiply(user_str, num_copy): print(user_str*num_copy) user_str = str(input("Sentence: ")) num_copy = int(input("How many times? ")) res = str_multiply(user_str, num_copy) print(res)
6b72a8852c7517e7677437fd3b7da7eb185e9881
AvanindraC/Python
/num_days.py
142
4.125
4
# Write a Python program to calculate number of days between two dates date1 = (2014, 7, 2) date2 = (2014, 7, 11) print(date2[-1] - date1[-1])
c2e9c44b1d13fe12cd8a81001d1e0444ab001d8d
AvanindraC/Python
/packing and unpacking.py
567
4.78125
5
# Packing # Used when we dont know how many arguments we must give to a function def func(*args): return sum(args) print(func(1,2,2,3,3,4,4,4,5)) # We can give as many arguments as we want # OUTPUT : 28 # Unpacking # Used when we want to pass a mutable iterable as an argument # *<iterable name> # These can be use...
e663ade5b642391a368fbd32073c8199175ed331
Karavay/project_eiler
/7_remade.py
632
3.53125
4
import numpy as np boolean_arr = [True]*1000 int_arr = [] i = 2 while i < len(boolean_arr) + 2: int_arr.append(i) j = 2 while j <= np.sqrt(i): if i%j == 0: boolean_arr[i-2] = False break else: j += 1 i += 1 print(int_arr) print(bo...
d162b101606eeed456439887a65404f9d72f8c18
Paul-Cl-ark/sorting-algorithms
/bubble_sort.py
839
4.15625
4
def bubble_sort(arr): # loop backwards from the end of the list for i in range(len(arr) -1, -1, -1): # this value is used to break out of the list if values are # sorted before the last item in the range no_swaps = True # loop 'forwards' through a shortening list (end is sorted) for j in range...
d92cab6a21e70f7a1b2e659fd27ab07da1344be5
kamiszczu/PythonKata
/codewars/IQ_Test.py
1,403
3.75
4
""" PASSED: https://www.codewars.com/kata/552c028c030765286c00007d/solutions/python """ def iq_test(numbers): numbers_list = numbers.split(" ") numbers_list = list(map(int, numbers_list)) result_value_pos = 0 result_value_neg = 0 counter_positive = counter_negative = 0 for i in numbers_list: ...
b8f0c44a1b13df50661aad382fac12ddf2b9d152
kamiszczu/PythonKata
/codewars/Number_People__Bus.py
857
3.59375
4
""" PASSED: https://www.codewars.com/kata/5648b12ce68d9daa6b000099/solutions/python """ def number(bus_stops): get_in = [i[0] for i in bus_stops] get_of = [i[1] for i in bus_stops] # print(sum(get_in) - sum(get_of)) return sum(get_in) - sum(get_of) """ another solution """ # def number(bus_stops): ...
f1a745abc787edb598bc58f51a99022cceae21a9
rtimbro185/uw_nlt_ling571_deep_nlp
/assignments/ling_571_h3_cky_parser/hw3_parser.py
3,131
3.75
4
"""LING 571 - Homework #3 - Ryan Timbrook ################################################################################################ Implementing a CKY Parser Based on the material in the lectures and text, develop an implementation of the CKY algorithm that will parse input sentences using a CNF grammar. You ma...
ec90f86b1bf1c1fc11bdd0f4773786af4a4acdb0
rtimbro185/uw_nlt_ling571_deep_nlp
/assignments/ling_571_h2_context_free_parser/hw2_tocnf.py
4,272
3.828125
4
"""LING 571 - Homework #2 - Ryan Timbrook ################################################################################################ ##########################################################################################################################################################""" import sys import nlt...
1c816a208314423e8f8b0df3040a9a6bc9b676c8
A-CGray/learningCython
/Tutorials/Fibonacci/pyFib.py
213
3.640625
4
from __future__ import print_function def pyFib(n): """Print the first n terms of the fibonacci series""" a = 0 b = 1 while b < n: # print(b, end=" ") a, b = b, a + b return b
0f14b46ba508dc79eab0b4cc5330f908a7b98e12
arcosin/WorldGame
/CoordMap.py
2,751
3.8125
4
from collections import defaultdict ''' Builds a coordinate ring in the form of a list. In order of w, nw, n, ne, e, se, s, sw. ''' def coordRing(coord): ringCoords = ((coord[0] - 1, coord[1]), (coord[0] - 1, coord[1] + 1), (coord[0], coord[1] + 1), (coord[0] + 1, coord[1] + 1), ...
92712b7bd705c9642d73f767a60599ac35db2e93
maxter252/Coding-Questions-Solutions
/StringManipulation/SherlockString.py
900
4.0625
4
from Collections import Counter def isValid(s): """ Sherlock considers a string to be valid if all characters of the string appear the same number of times. It is also valid if he can remove just one character from everywhere in the string, and the remaining characters will occur the same numbe...
da3add9936c17fffebd3751ce863fa656a014ae7
shoaibsattar823/ArbisoftProjects
/Month1/Week1/Day5/Task/weather.py
1,010
3.96875
4
"""In this program we are fetching weather data from web page and then displaying the informations. """ import requests import json def main(): print '***Please enter the latitude and longitude where you want to know\ the weather***\n' lat = input('Enter the latitude: ') # 31.4839658 longit = input('E...
20c256d29fc6a36a5503e1a37e4e8c46f075dfd5
Bautronis/Python
/ex21.py
1,265
4.15625
4
def add (a,b): print "ADDING %d + %d" % (a, b) return a + b def subtract (a,b): print "Subtracting %d - %d" % (a, b) return a - b def multiply (a, b): print "Multiply %d * %d" % (a, b) return a * b def divide (a, b): print "Dividing %d / %d" % (a, b) return a / b print "Let's do some...
f428c6a19eb70720efcf336ec469b607792966b0
Bautronis/Python
/ex11.py
515
4.03125
4
print "How old are you", age = raw_input () print "how tall are you", height = raw_input () print "how much do you weight", weight = raw_input () print "so you are %r old, %r tall and %r heavy." % (age, height, weight) # Study grill print "please enter a random number" number = int(raw_input()) math = number / 2 + 2...
ec3203acfde84ef191c3d2a90098a1030dba0c6b
Bautronis/Python
/ex14.py
471
3.546875
4
from sys import argv script, user_name = argv prompt = '> ' print "Hi %s, Im the %s script" % (user_name, script) print "Id like to ask you a few Q" print "do you like me %s" % user_name likes = raw_input(prompt) print "where do you live %s" % user_name lives = raw_input(prompt) print "What kind of computer do you ...
56c140e65f4aa4498a2dcc0e28a9e2c426850565
BigMountainTiger/python-excercise-repository
/miscellaneous/a_00_dict_example/text.py
270
3.625
4
def test_keys(): d = { 'A': 'This is A', 'B': 'This is B' } keys = d.keys() if 'A' in keys: print('A is in the keys') if not ('C' in keys): print('C is not in the keys') if __name__ == '__main__': test_keys()
d83610fac3d70c38dd1ff299510684a725c126ba
BigMountainTiger/python-excercise-repository
/miscellaneous/a_01_oo_excercise/p_04_instance_class_static_methods.py
761
4.03125
4
# A class with an instance method, a class method, # and a static method class AClass: a_class_attr = 'The class attribute' def __init__(self): self.a_instance_attr = 'The instance attribute' def an_instance_method(self): print("From the instance method - {}".format(self.a_instance_attr)) @classmetho...
6cf8ad8c9388c7e63befe635a851cb22b52795f7
samguyer/comp10-clustering
/clustering.py
5,540
4.28125
4
import math # -- Compute the distance between two entries # An entry is a tuple of (name, values) and # values is the vector representing the features def entry_distance(entry1, entry2): d = 0.0 return d # -- Compute the minimum distance between two clusters # Loop over all pairs of entries (one fro...
16235e0e7bfb881ffae9e8455df1b25db937305f
mathivanansoft/algorithms_and_data_structures
/data_structures/stack.py
660
3.9375
4
class Stack(list): def __init__(self, size): list.__init__(self, []) self.size = size def push(self, data): if self.size > len(self): self.append(data) else: raise Exception("Stack overflow") def pop(self): if len(self) != 0: retu...
1c262044c07fd9be9ed789f51463e040d324c022
mathivanansoft/algorithms_and_data_structures
/data_structures/bs_tree.py
3,150
3.796875
4
from binary_tree import BinaryTree from binary_node import Node class BSTree(BinaryTree): def __init__(self): BinaryTree.__init__(self) def insert(self, data): self.root = self.__insert(self.root, data) def __insert(self, node, data): if node is None: return Nod...
46048313d7f8b5305b2a4dbfd9821adb97d65e05
mathivanansoft/algorithms_and_data_structures
/algorithms/searching.py
502
4.03125
4
def linear_search(arr, key): for index, elmnt in enumerate(arr): if key == elmnt: return index return -1 def binary_search(arr, start, end, key): if start <= end: mid = start + (end - start + 1) // 2 if arr[mid] == key: return mid elif key < arr[mid]: return binary_search(arr, start, mid-1, key) ...
fc29077d52e694981ab80a7daf14796a0e98afaa
mathivanansoft/algorithms_and_data_structures
/algorithms/divide_and_conquer/nuts_bolts.py
1,066
4
4
# nuts and bolts # should not compare two nuts and two bolts # find the pair of nuts and bolts of equal size def match_nuts_and_bolts(nuts, bolts, start, end): if start < end: pindex = partition(bolts, start, end, nuts[end]) partition(nuts, start, end, bolts[pindex]) match_nuts_and_bolts(nu...
09a58ac780d3caf53fbb581a44bf801b87fd1559
susimpostor4444444/Calculator
/Calculator.py
1,304
4.0625
4
print(' ADDITION ') add1 = input("Enter a number: ") add2 = input("Enter another number: ") answer = float(add1) + float(add2) print (add1, "+", add2, "=", answer) print(' SUBTRACTION ') sub1 = input('Enter a number: ') sub2 = input('Enter another number: ') answer2 = float(sub1) - float(sub2) prin...
06b889b664528d67230c69c14a84c4fd6803e206
cleviane/CampinasTechTalentes-Python
/Aula_0012/dict2.py
380
4.1875
4
dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'} # para modificar usa a chave exemplo "Age" e atribui outro valor dict['Age'] = 8 # update existing entry dict['School'] = "DPS School" # Add new entry # adicionar uma nova entrada aqui adicionamos o valor (chave) 8 e School print("dict['Age']: ", dict['Age'...
881eb531dd60839598f357f4bb6df487b3a245ed
cleviane/CampinasTechTalentes-Python
/Aula_0010/lista2.py
420
4.1875
4
list = ['physics', 'chemistry', 1997, 2000] print("Value available at index 2 : ") print(list[2]) list[2] = 2001 print("New value available at index 2 : ") print(list[2]) # append adiciona um valor na lista, e sempre adiciona o valor no final list.append("hahaha") list.append(["ajajaja", 1995]) list.appe...
20e312b536147d807a467c2622098ecee09ab7bf
cleviane/CampinasTechTalentes-Python
/Aula_0014/Pessoa.py
366
3.640625
4
class Pessoa: """ Classe para pessoa """ def __init__(self, nome, salario): """ inicializando a classe """ self.nome = nome self.salario = salario def minha_funcao(self): """ mostra mis funciรณn """ ...
119647b638675b75c781e87de69fe57c9c0ae1f9
cleviane/CampinasTechTalentes-Python
/Aula_007/fordentrodefor.py
238
3.75
4
lista_matriz = [["a","b","c"],# posiรงรตes da matriz ["d","e","f"], ["g","h","i"]] #for denrto do for for it1 in lista_matriz: print(it1) for it2 in it1: print(f"O item รฉ: {it2}")
87dafe10bd76861ddac71f49c5cad99bac659d42
cleviane/CampinasTechTalentes-Python
/Aula_008/deltupla.py
134
3.921875
4
arr = (10, 30, 20) del arr arr = () arr[0]= 11 print(arr) # fazer o estudo de cada funรงรฃo sobre funรงรตes matemรกticas
2e48e273cfd4e7db343aec24443d5406398d77ec
HowardM12138/Advent-of-Code-2020
/day16/answer.py
1,912
3.5
4
def part1(lines): ranges, tickets = parse_part1(lines) valid_tickets = [] def valid(x): for range in ranges: if (range[0] <= x <= range[1]): return True return False for ticket in tickets: valid_ticket = True for num in ticket: if...
c93e8a2e75a1171aba9a148c09e7267df4115d04
ccompton94/Game_Selector
/Role_Playing_Game.py
38,852
4.125
4
#Imports import random import time #Useful functions def choice_validation(x): """Turns a string into a user interface. Answers are restricted to the choices. Arguments: x {string} -- Content for user interface Returns: ans {integer} -- User's answer to available choices """ ...
e902e4b817889b79ceef6f6a27f9e21a34751bb3
samuelarcher/blackjack-udemy-assignment
/Hand.py
1,942
4.03125
4
import inspect class Hand(object): ACE_LOW = 1 ACE_HIGH = 11 card_value_by_name = { "ace": ACE_HIGH, # or 1 if it would cause a bust "two": 2, "three": 3, "four": 4, "five": 5, "six": 6, "seven": 7, "eight": 8, "nine": 9, "t...
58ec952c56c8f43f98028654cab7ffebca7c7308
ThinkerDreamer/CPT051
/noelle_object_1.py
1,095
4.125
4
#class_name #minutes_teaching #avg_rating #class_hours #class_type -dictionary #class_date #lesson_title #pay_amount #students_enrolled def take_input(): print("Enter your selection here") selection = input() selection = selection.upper() selection = selection[0] return selection class_types = ['...
aeb5d1af6abf200bbaba31b6c87d259214fdd8aa
waleedalbaz/cs-course
/Projects/Solitaire Mancala.py
4,232
4.25
4
""" Student facing implement of solitaire version of Mancala - Tchoukaillon Goal: Move as many seeds from given houses into the store In GUI, you make ask computer AI to make move or click to attempt a legal move """ class SolitaireMancala: """ Simple class that implements Solitaire Mancala ...
b2883b94a418e75f1e614ebc7967dd676af2ae03
dannyjew/Data22
/pythonProject_1/main.py
1,582
4.1875
4
# user inputs word # hidden word is generated "_____" # whilst the user has lives left, # guess a letter # if letter is in word and has not been guessed before, # then reveal the letter "_e___" # else if letter not in word, then take away a life word_to_guess = input("Please pick a word to guess......
45e7e7f04cd6391f0acf4b9b2f4c881096970b09
dannyjew/Data22
/Classes/main.py
334
3.625
4
class Dog: animal_kind = "Dolphin" # class variable which returns an attribute string def bark(self): # method return "woof" Myles = Dog() Oscar = Dog() print(type(Myles)) print(type(Oscar)) Oscar.animal_kind = "Big Dog" print(Myles.animal_kind) print(Oscar.animal_kind) print(Myles.bark()) print(...
0e3880d34762df5f3c4abd758d268a714023899c
Graham84/DiveIntoPython
/Chapter 04 - The Power of Introspection/Understanding the Pecuiar Nature of and & or.py
719
4.28125
4
""" Introducing and #>>> 'a' and 'b' 'b' #>>> '' and 'b' '' #>>> ' ' and 'b' 'b' #>>> 'a' and 'b' and 'c' 'c' #>>> Introducing or #>>> 'a' or 'b' 'a' #>>> ' ' or 'b' ' ' #>>> '' or 'b' 'b' #>>> '' or [] or {} {} #>>> ' ' or [] or {} ' ' #>>> def sidefx(): print "in sidefx()" return 1 #>>> 'a' or sidefx() 'a' #>>>...
b16d821b0c0e0908d42a171f03892ab24c4d714e
Graham84/DiveIntoPython
/Chapter 03 - Native Datatypes/NativeDatatypes.py
3,435
4.15625
4
#dictionary d = {"server":"mpilgrim", "database":"master"} print d print d["server"] print d['database'] d['database'] = "pubs" print d d['uid'] = "sa" print d #dictionary keys are case sensitive k = {} print k #key k["key"] = "value" print k #key k["key"] = "other value" print k #Key k["Key"] = "third value" print k ...
c585e803dbcdf8c3d1028276d10e3fe7c6d2ca71
Graham84/DiveIntoPython
/Chapter 05 - Objects and Object-Orientation/Modifying Class Attributes.py
256
3.5625
4
class counter: count = 0 # class attribute def __init__(self): self.__class__.count += 1 print counter print counter.count c = counter() print c.count print counter.count d = counter() print d.count print c.count print counter.count
27a86a58339b4cbe9e45a55c304ca3c07dc36adb
Giordano26/Python-Web
/Ref/startswith.py
180
3.5625
4
import re txt = open("mbox-short.txt") for line in txt: line = line.rstrip() if re.search('^From:',line): # ^ Return true if From is in the beginning print(line)
8bf2efbf8bb6d3a78430dc0959843cf16a727614
falahat/hangman
/players.py
958
3.65625
4
class Guesser(object): def __init__(self, game): self.game = game self.word_db = game.word_db def best_letter(self): game_word = self.game.visible_word() no_contains = self.game.wrongs self.word_db = self.word_db.filter(game_word, no_contains) guesses = self.game.guesses for letter, num_occurrences in...
80ccaadc47cbc72850e48915ee1c229e67128e1f
stonematt/ida_dec5
/2-Pandas/d3-1-modify dataframe.py
613
3.75
4
# import codecademylib import pandas as pd df = pd.DataFrame([ [1, '3 inch screw', 0.5, 0.75], [2, '2 inch nail', 0.10, 0.25], [3, 'hammer', 3.00, 5.50], [4, 'screwdriver', 2.50, 3.00] ], columns=['Product ID', 'Description', 'Cost to Manufacture', 'Price'] ) # Add column, by simply declaring it and setting...
fb9bc6c512226fea0509569059f638c7a80e4341
bglossner/Python-Calculator
/Calculator/facTester.py
2,808
3.78125
4
##print(type("Str")) ##if str == type("str"): ## print("yes") ##from calc_methods import isFloat ## ##def putInNegs(string1, numOfNeg, indexList): #putInNegs(string, string.count("-"), list(filter(lambda x: string[x] == "-", range(len(string))))) ## if numOfNeg == 0: ## print(string1) ## return stri...
cfa792a1aefcefbfc7206cf524b340bbff568ff9
jugonzalez40/Ciencias
/Galactic Taxes/main.py
2,064
3.5625
4
import heapq import sys inf = float("inf") # GALACTIC-TAXES # Juan Sebastian Gonzalez Rivera # Politรฉcnico Grancolombiano - 2019 # Clase nodo class Node: def __init__(self, id, value): self.value = value self.id = id def __lt__(self, other): return self.value < other.value def dijk...
e6ff26b67e7d3e9d5b64e889843983c002680094
Ajay6533-hacker/my_python_tutorial
/firstfrog/practice 2.py
1,768
3.875
4
# Metlhod (function) # def function1(): # function with without arguement # a=78 # b=89 # c=a+b # print("additon of two numbers ",c) # function1() # function with arguement # def function2(a,b): # """this is used for functi...
098c62d1cd9028f3246e6988b6817cfcddcd3b77
Ajay6533-hacker/my_python_tutorial
/firstfrog/join__func.py
1,249
3.71875
4
# list1=["ajay","vijay","vijay","aman","nitish","rohan"] # for item in list1: # print(item,"kumar",end=" ") # a=" kumar ".join(list1) # print(a) # ---------------------------------------------Join function 2 --------------------------------------------------------- # list2=["vijay","ajay","deepak","rahul"] # b=" ...
4c16cf3d5414232a03ce9b42bc26e2c85a2237ce
Ajay6533-hacker/my_python_tutorial
/firstfrog/classes__object_(oops1).py
2,000
4.0625
4
# Creating class # class Student: # pass # ajay=Student() # vijay=Student() # print(ajay,vijay) # ajay and vijay both are store in different memory address # # ajay.name="ajay" # ajay.branch="C.E" # ajay.roll=1 # vijay.name="ajay" # vijay.branch="C.E" # vijay...
a08b11a87c62056602a13ca3e48aee109aeb82f8
Ajay6533-hacker/my_python_tutorial
/firstfrog/my_recursion.py
3,093
4.1875
4
# Recursion # # j=0 # def rec(): # global j # j=j+1 # print("This is used for recursion",j) # # rec() # rec() # import sys # print(sys.getrecursionlimit()) # fibonacci numbers(4) = 4*3*2*1 # # def fibonacci(n): # if n==1: # return 0 # elif n==2: # ...
31c3e150edf57d61bc74c4fbbe6bd3ab252de2a5
tirkarthi/weinvest_assignment
/weinvest.py
4,901
3.625
4
from __future__ import print_function import string import re from itertools import product from collections import defaultdict def find_optimal_word(number, dictionary): ''' Accepts a number and a dictionary of the form as below to return the appropriate word for the number Dictionary form : dicti...
dce8db47f71c4a18711b9bf5908a272dea901d19
mihai-bontea/Google-Hash-Code-2021-Qualification-Round
/calculate_score.py
7,460
3.8125
4
class Street: def __init__(self, info_str): info = info_str.strip().split(" ") self.intersect = (int(info[0]), int(info[1])) self.name = info[2] self.length = int(info[3]) class Car: def __init__(self, info_str, streets): info = info_str.strip().split(" ") str...
7c1c046d7b504401a54ade4797b9620d985b7eff
jbmenashi/learning-data-science
/multiple_linear_regression/mlr.py
1,401
3.59375
4
# MLR is the same formula, just longer: y = b0 + b1*x1 + b2*x2... # where y is the dependent variable, b0 is the constant, the rest is indep import numpy as np import matplotlib.pyplot as plt import pandas as pd dataset = pd.read_csv('OPS.csv') X = dataset.iloc[:, :-1].values y = dataset.iloc[:, 5].values # Splittin...
9613ade6e73b9bbd64b698a1b22754d761d2e823
clur/QuickQuote
/QuickQuote.py
2,145
3.515625
4
__author__ = 'claire' import string import re import subprocess import os def segmentcount(text): splitter = re.compile('\r|\.\s|\?\s|!\s') # text= re.sub("^\d+\s|\s\d+\s|\s\d+$", " ", text) # remove digits text = re.sub('\d', '', text) segments = re.split(splitter, text) segments = [s for s in s...
aba7dfcd259cd60e3b73d801cf95f136a1f96686
EWilcox811/UdemyPython
/FirstPython.py
13,682
4.5
4
print('hello world') mystring = "Hello World" print(mystring[0]) print(mystring[8]) print(mystring[-2]) print(mystring[-1]) print(mystring[0:4]) v = [2,1,12,13,8,6,7,9,10,5] v[2:10:3] v[9:3:-2] mystring.lower() print(mystring) mystring.upper() mystring.split() #print formatting for strings. #known as string interpolati...
88c05a2ac2e6d4c7dd91b1f56d0ff99b47340cbf
lingxueli/CodingBook
/Python/Test/main.py
788
3.84375
4
import random # wrap this in a function for unit test def run_guess(guess, answer): try: if 0 < guess < 11: if guess == answer: print('you are a genius!') return True else: return False else: print('hey bozo, i said...
4e6eade9ad46df1099d89a051985bd8c54aa76ac
lingxueli/CodingBook
/Python/Scripting/Image/JPGToPNGConvertor.py
669
3.515625
4
# python Scripting\Image\JPGToPNGConvertor.py Scripting\Image\image\ Scripting\Image\new\ import sys import os from PIL import Image # grab the first and second argument image_folder = sys.argv[1] output_folder = sys.argv[2] # check if new/ exists, if not, create it if not os.path.exists(output_folder): os.makedi...
0a7f4cfe77753a8c62183598761252938a84147e
lingxueli/CodingBook
/Python/Basics/NewFeatures.py
275
4.09375
4
# what's new in python 3.8 # read summary # walrus operator # := a = 'helloooooooo' if ((n := len(a)) > 10): # print(f"too long {len(a)} elements") print(f"too long {n} elements") while ((n := len(a)) > 1): print(n) a = a[:-1] # remove the last character
f8f2b92e1b4a83885f622b2f8a43b28978d82067
lingxueli/CodingBook
/Python/OOP/super.py
1,154
3.921875
4
# super() class User(object): def __init__(self, email): self.email = email def sign_in(self): print('logged in') def attack(self): print("do nothing") class Wizard(User): def __init__(self, name, power, email): # inherite the attribute # User. is legitimate,...
ed3e1eddbb984f0bb511274ee716b6359eed572e
lingxueli/CodingBook
/Python/Basics/enumerate.py
191
4.1875
4
# enumerate takes an iterable objects, it returns an index counter and the item for i, char in enumerate('hello'): print(i, char) if char == 'e': print(f'index of e is: {i}')
1579e6ec08c756a0a87a7927af3f51eaa0cb74b2
keshiki808/python-blackjack-game
/db.py
652
4.03125
4
# Reads the money from a text file, creates a file if one doesn't exist. Player's betting money. def money_reader(): try: with open("money_store.txt") as file: for line in file: player_money = line except FileNotFoundError: print( "Player money inventory n...
a47662f67bed871da3882df14b732b09f76723e5
brucehuang368/awsome-ML-DL-leaning
/lihang-reading_notes (with code)/็ฌฌ6็ซ  ้€ป่พ‘ๆ–ฏ็‰นๅ‡ฝๆ•ฐไธŽๆœ€ๅคง็†ตๆจกๅž‹(LogisticRegression)/LR.py
2,280
3.5625
4
from math import exp import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.datasets import load_iris from sklearn.model_selection import train_test_split # data def create_data(): iris = load_iris() df = pd.DataFrame(iris.data, columns=iris.feature_names) df['label'] = iris.t...
92b247950e7f996934614cfb6aeadbd77c746236
kychunab/LessonPythonCode
/Lesson40-Model-Deployment-Flask/app.py
1,075
3.84375
4
# ็ฌฌไบŒๆญฅๅœจlocalhostไธŠๅปบ็ซ‹flask-app # ๅฎ‰่ฃ…pip install flask import numpy as np from flask import Flask, request, render_template import pickle # ็ฌฌ2.1ๆญฅ Loading the saved model # We load the model.pkl file and initialize the flask app. app = Flask(__name__) model = pickle.load(open('model.pkl', 'rb')) # ็ฌฌ2.2ๆญฅ Redirecting the AP...
87ab02a7ba7c4423764ad87057859aa0397acb36
madhu20336/function
/3and5Sum.py
289
3.84375
4
def num(limit): i=0 sum=0 while i<=number: if i*3==0: sum+=1 return (sum) if i*5==0: sum+=1 return (sum) i+=1 number=int(input("enter a number: ")) print(num(number))
8cdb12e905a75864152028b230274a08cb576e84
madhu20336/function
/Question5.py
3,827
4.0625
4
#FIRST PART # def Even_Number(numbers): # i=0 # while i<numbers: # if numbers%2==0: # print(numbers,"is even number") # break # else: # print(numbers,"is not even number") # break # i+=0 # Even_Number(13) # Even_Number(20) #SECOND PART # s...
755a56e4e25e77dce518ee6680b4770b617eb65e
mjindal585/snapbuzz
/codes/greenband.py
1,507
3.765625
4
# Example Python Program for thresholding from PIL import Image import math import time import tkinter from tkinter import filedialog import os # Method to process the red band def pixelProcRed(intensity): return 0 # Method to process the blue band def pixelProcBlue(intensity): return 0 # Method to process ...
b02fdc922c89fb2174294340a4c3f41423f6ab46
daoudclarke/sempre-baselines
/kernelparsetest/randomdata.py
1,546
3.9375
4
from random import Random class RandomData(object): def __init__(self): self.random = Random(1) choices = [ 'banana', 'apple', 'fish', 'socks', 'orangutan', 'organism', 'cheetah', 'mixer', 'potato', 'john', 'examp...
4385afdcea29c232dfe3160b8845ce4afb2846a3
ishambhandari/Python
/readfiles.py
356
3.6875
4
#This function reads the text files.. def readInventory(): inventory = [] file = open("stock.txt", "r") #Reading the text file lines = file.readlines() for line in lines: product = line.split(',') product[1] = int(product[1]) product[2] = int(product[2]) inventory.append(...
a3fd9a4676014c1e72e44fd792d2e30c4e0d8642
JeffDev31/ProjetoN1A2
/sistemaEventoA2.py
3,526
3.953125
4
listaUsuarios = [] cadastros = [] def alterarNome(): procurar = input("Insira o email do usuรกrio que deseja alterar o nome: ") alterar = input("Insira o novo nome para alteraรงรฃo: ") for cadastro in listaUsuarios: if(procurar == cadastro["email"]): cadastro["nome"] = alterar ...
4d680ad7fbafc13e2b45c4dd4f9c3a9c0c0ebaaf
dauletkali/algo
/insertion_sort.py
326
3.859375
4
def insertion_sort(arr): for i in range(1,len(arr)): pick = arr[i] hole = i while hole > 0 and arr[hole - 1] > pick: arr[hole]=arr[hole-1] arr[hole-1]=pick hole-=1 arr[hole]=pick return arr # O(n*n), O(n) print(insertion_sort([0,9,8,7,6,5,4,3,...
be5f370d8f56f4101cfb05e6e51f3c369bac12f6
dauletkali/algo
/queensAttack.py
3,374
3.90625
4
#!/bin/python3 import sys TOP = 0 BOTTOM = 1 LEFT = 2 RIGHT = 3 TOP_RIGHT = 4 TOP_LEFT = 5 BOTTOM_RIGHT = 6 BOTTOM_LEFT = 7 NONE = 8 def drawBoard(board): print("================") [print(i) for i in board] def detectDirection(queen,obstacle): if queen[0] > obstacle[0] and queen[1] == obstacle[1]: ...
f97437770f397b06be9e8270d9754a7d45c60d5a
shiki7/algorithm
/library/copy_deepcopy.py
147
3.859375
4
# ใใฎใพใพไปฃๅ…ฅใ—ใŸใจใใฎๅ€คใŒๅค‰ใ‚ใ‚‹ๅ‰ฏไฝœ็”จใ‚’้˜ฒใ from copy import deepcopy A = [1,2,3] B = deepcopy(A) B[1] = 100 print(A)ใ€€
6d1e64fe67810f651b7b051a200aba016ba4c39e
shiki7/algorithm
/select_sort/select_sort.py
343
4.15625
4
def select_sort(arr): for i in range(len(arr)): min_val = min(arr[i:]) min_idx = arr.index(min_val) arr[i], arr[min_idx] = min_val, arr[i] return arr # ใƒ‡ใƒใƒƒใ‚ฏ if __name__ == "__main__": arr = [3, 4, 6, 10, 2, 1, 7, 11] print("before: ", arr) arr = select_sort(arr) print("...
96e682f1b05d42454fd7192dbaa7de129b3a465c
williampark73/connect-four
/minimax_agent.py
1,293
3.765625
4
import random def minimax_agent_first(game, state): return minimax_agent(game, state, 1, 2) def minimax_agent_second(game, state): return minimax_agent(game, state, 2, 2) def minimax_agent(game, state, agent_index, depth): actions = game.actions(state) assert len(actions) > 0 scores = [minimax_value(game, game....
c8c2b6c6e4d8b2daeb11505a53ee6ffef755aae3
mchen1235/cs-362
/5-in-class/leap_year.py
217
3.828125
4
def leap_year(number): #check if the year is a leap year if number % 4 == 0: if number % 400.0 == 0: return True else: if number % 100.0 == 0: return False return True return False leap_year(400)
bc27ef74ab7023c699242ec3f830bfe2157d1971
penkeerthi/python-programming
/unit-2/Homework/hw-1.py
355
4.09375
4
numvar = 0 for evennumber in range (1000,10001): if evennumber % 2 == 0: numvar += evennumber print(numvar) print (f'The sum of even numbers between 1000 and 10,000 is:{numvar}') #make sure print is outside the for loop so you dont get repeated prints #or you can also print print('T...
51790940617f20fff75091bdc54bda8910c5a793
penkeerthi/python-programming
/unit-3/sets_tuples.py
930
4.0625
4
#sets do not allow duplicates rainbow_colors = {'Red','Orange','Yellow','Green','Blue','Indigo','Violet'} print(type(rainbow_colors)) values = [1,5,7,2,5,5,9,7] unique_values = set(values) print(unique_values) #add values to a set unique_values.add(3) #remove a value from a set unique_values.remove(3) print(un...
ae9a16bb97e828b42b051ed2948584939bf1ffde
penkeerthi/python-programming
/unit-3/func.py
1,975
4.375
4
#define functions is by def #parameter vs arguments #function is a block, Function followed by parameters but are not needed. #functions are written to do a specific job and return something, think of functions as helpers. #when writing a function that returns value use "Return" #Things go inside function are arg...
fb55b4e8240497339ec9939cdd869e943ebae82d
penkeerthi/python-programming
/unit-3/dictionary.py
2,150
4.5625
5
#a dictionary is a collection of a key/value pair student = {'name': 'keerthi', 'age': 30,'address': 'Scarborough'} #how to access elements in a dictionary print(student['name']) print(student['age']) print(student['address']) #dictionary name [value] = always gives value #dictionarycannot have duplicate keys #a...
f8d48493616c57b466ed3870432396a0776814e0
penkeerthi/python-programming
/unit-3/Homework/problem2class.py
589
3.671875
4
def encode_string(string): letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] result = '' for character in string: for idx in range(len(letters)): if character == letters[idx]: ...
b9d6c0fbbd67b69d4d397a9d0b4e3fc22357a188
penkeerthi/python-programming
/unit-2/fizzbuzz.py
817
4.34375
4
#for all numbers from 1 to 50 #if its a multiple of 3, print "fizz" #if its a multiple of 5, print "buzz" #if its a multiple of 15, print 'fizzbuzz' #otherwise print the number ''' 1 // 1 # if result is 1 , result is going to be 1 2 // 2 # if result is 2 , result is going to be 2 3 // 'fizz' # if result is a multip...
938b4c4c127ba74596f7d10cef3d388a49b56039
sac-1234/sg
/test.py
311
3.921875
4
a=str(input("what is your first name\n")) e=str(input("what is your last name\n")) f=a+" "+e print("hello!",f,"\n") print("i can add any two number\n") b=float(input("enter first number\n")) c=float(input("enter first number\n")) d=b+c print("sum=",d) import math print('Sin value of your number', math.sin(d))
6a0aa93cabd85d2c982969ec8653449b3b7d88b5
Mattkitkat/PyPoker
/River.py
297
3.578125
4
class River: def __init__(self, cards): self.cards = cards def __getitem__(self, item): return self.cards[item] def __str__(self): return ', '.join([str(x) for x in self.cards]) def __add__(self, o): return River(self.cards + o.cards)
57efdefb9f6da45a2bd357021a411981dfd1ea1a
wangweihsin/learning-note
/Leetcode/7#_ReverseInteger_06170115.py
459
3.890625
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: class Solution: def reverse(self, x: int) -> int: y=0 if x>0: while x!=0: y=y*10+x%10 x=x//10 elif x==0: return x else: x=-x while x!=0: ...
b7a23451a6db5cf2f82ab2d0eb7aad4100dfbd1d
zhihong96/program
/mit/me11.py
564
4.0625
4
# -*- coding: utf-8 -*- def silly(): res = [] done = False while not done: elem=raw_input('enter element. return when done.') if elem == '': done = True else: res.append(elem) #print 'res should be[1, a, 2]', res tmp = res[:] #print 'tmp', tmp, 'r...
c01fec0b2755a748450ef1cc633aaddbed73f6c7
zhihong96/program
/coursera/average.py
223
4.15625
4
# -*- coding: utf-8 -*- numlist = list() while True: inp = raw_input("Enter a number:") if inp == "done": break value = float(inp) numlist.append(value) average = sum(numlist) / len(numlist) print average
6455635297f9fc8d1fc522796612c8b72495c611
haodayitoutou/Algorithms
/LC50/lc50.py
333
3.875
4
""" Implement pow(x, n) """ def mypow(base, power): if power == 0: return 1 if power < 0: power = -power base = 1 / base if power % 2 == 0: return mypow(base * base, power // 2) return mypow(base * base, power // 2) * base print(pow(3, 2)) print(pow(3, -2)) print(pow(...
a45f324fcb88d497dd50e37e743db7555e0dd6fa
haodayitoutou/Algorithms
/LC50/lc02.py
1,148
3.9375
4
""" You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself. In...
3d5f7a6e927a430021f94a35ca5b4768871774be
haodayitoutou/Algorithms
/LC150/lc133.py
981
4.03125
4
r""" Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. Nodes are labeled uniquely. First node is labeled as 0. Connect node 0 to both nodes 1 and 2. Second node is labeled as 1. Connect node 1 to node 2. Third node is labeled as 2. Connect node 2 to node 2 (itself), thus ...
e7d2cf14491b9432abd6c8a1ceeeeeacb6eaac59
haodayitoutou/Algorithms
/LC50/lc11.py
1,052
3.875
4
""" Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water. Note: You ...
0b59eb20e38be4a69e152f23ada37d49ccb9dc0d
haodayitoutou/Algorithms
/LC100/lc81.py
1,818
3.984375
4
""" 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 5 6 7 0 1 2). Write a function to determine if a given target is in the array. The array may contain duplicates. """ def search(nums, target): if not nums: return False...
dd05a73e4d4f0f09a7773703c6bea2a42fcf5924
haodayitoutou/Algorithms
/LC50/lc21.py
1,131
4.1875
4
""" Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. """ from util import ListNode, create_node_list, print_node_list def merge(list1, list2): output = ListNode(0) first = output while (list1 is not None) and (lis...