blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
20124716905e7280df81672bdfe4b95187a57db6
Anubis84/BeginningPythonExercises
/chapter6/py_chapter6/src/chapter6_examples.py
808
4.53125
5
''' Created on Nov 21, 2011 This file shows some examples of how to use the classes presented in this chapter. @author: flindt ''' # import the classes from Ch6_classes import Omelet,Fridge # making an Omelet # Or in python speak: Instatiating an object of the class "Omelet" o1 = Omelet() print( o1 ) print( o1.ge...
fe58e7dc93a95213f4edc53d91de3da4c64b49b1
Anubis84/BeginningPythonExercises
/chapter5/py_chapter5/src/ex_5.py
528
3.78125
4
''' Created on Nov 16, 2011 @author: pfl ''' def do_plus( firstNumber, secondNumber): return firstNumber + secondNumber def do_plus_ex(firstNumber, secondNumber): if type(firstNumber) != type( 1 ) or type(secondNumber) != type( 1 ): raise KeyError return firstNumber + secondNumber #==========...
68e1a4adcfa87aa9ea73119a062c522820304f33
TheRealFanjin/picalculator-chudnovsky
/picalculator-chudnovsky.py
868
3.921875
4
import decimal # sets number of digits def factorial(n): fact = decimal.Decimal('1') for i in range(1, n + 1): fact = fact * i return fact def findPi(numOfDigits): decimal.getcontext().prec = numOfDigits k = 0 result = decimal.Decimal('0') next = decimal.Decimal('426880') * decima...
5bf4a3e6fc1090536cb22aaa0944a6ebffe4e3fd
sabauandrei98/Licenta
/Python Server and Client/client/modules/ClientSocket.py
7,806
3.6875
4
import socket import sys import time import threading from Game import Game """ Client socket class is responsible for: - creating a socket which connects to the server - reading data from the server - processing the data - sending data back to the server """ class ClientSocket: """ __init__ function assi...
8bcdf622949e650a300e33433de3edfbafdfbebd
jdotjdot/Coding-Fun
/programmingchallenge2.py
2,683
4.1875
4
def __init__(): print('''Programming-Challenge-2 J.J. Fliegelman At least starting off with this now, this strikes me as a a textbook example of the knapsack problem. I'll start with that on a smaller scale, and then see how that scales when we go up to 70 users. As we scale to 70 people, it ...
d6b4a5b0e05d8305f318b22958eba3dc58b3ff5b
bestcourses-ai/math-through-simulation
/monty-hall.py
1,019
4.34375
4
''' https://en.wikipedia.org/wiki/Monty_Hall_problem Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what's behind the doors, opens another door, say No. 3, which has a goat. He then says t...
ca499babcd7fa093f4f78e841d5658dacfa0dad3
bestcourses-ai/math-through-simulation
/chuck-a-luck.py
1,114
3.875
4
''' Problem #6 in "Fifty Challenging Problems in Probability" by Frederick Mosteller. Chuck-a-Luck Chuck-a-Luck is a gambling game often played at carnivals and gambling houses. A player may bet on any of the numbers 1, 2, 3, 4, 5, or 6. Three dice are rolled. If a player's number appears on one, two, or three of th...
838819204e66a2e58e3a602e0db827d5120c24ed
bestcourses-ai/math-through-simulation
/hht-or-htt.py
836
4.25
4
''' You're given a fair coin. You keep flipping the coin, keeping tracking of the last three flips. For example, if your first three flips are T-H-T, and then you flip an H, your last three flips are now H-T-H. You keep flipping the coin until the sequence Heads Heads Tails (HHT) or Heads Tails Tails (HTT) appears. ...
06c95cb0c1bd472a79100de617ec56fa2ec8b43c
Ratan-Debnath/Python_BasicProgramming
/2. Data Types/2.3 List Data Types_Data Structure.py
543
3.875
4
#list :(elements and size can be changed,) Lists are similar to arrays in C. However; the list can contain data of different types. # The items stored in the list are separated with a comma (,) and enclosed within square # brackets []. content from javapoint website listValue = [1, "hi", "python", 2] listUpdate ...
f7dc753fc5a00453e38a18e778a7bd0b4fc06063
WuZhiT/xtpython
/xt17.py
587
3.5
4
from sys import argv from os.path import exists script,from_file,to_file = argv #print(f"Copying from {from_file} to {to_file}.") #We could do these two on one line,how? #in_file = open(from_file) #print(f">>>>> The in_file = {in_file}") #indata = in_file.read() indata = open(from_file).read() print(f"The input fil...
aecf8dd7aaed185d0f16820107b2d09eb18baf79
jamiejamiebobamie/CS-2.2-Labs
/Graph-Tutorial/challenge3.py
2,218
3.78125
4
from graph_adt_list import * from graph_reader import * from collections import deque def breadth_first_search(graph, node, n=1): """ This method assumes you want the vertex ids of all vertices that are less than the input n. """ def findVertexIndex(vertex_id): """ vertex_id argument ...
a2a6008f7c2d7b189bbea9f694f4d7cad454ca0d
rapenumaka/pyhton-cory
/Strings/python_strings.py
2,310
4.4375
4
""" Namespace is a way to implement scope. In Python, each package, module, class, function and method function owns a "namespace" in which variable names are resolved. When a function, module or package is evaluated (that is, starts execution), a namespace is created. Think of it as an "evaluation context". When a fu...
df6ae8b73a175c1d090d2c406c5272d372d65955
gogqou/BMI203
/Clustering/cluster_edited.py
28,597
3.828125
4
''' Created on Feb 16, 2015 @author: gogqou modified Scott Pegg's initial version clustering algorithms: hierarchical: bottom up partitioning: k mean ''' #!C:/Python22/python.exe ############################################################################### ###################################################...
bdba31eef5c63916f93603c11c1da19fdf07a1d5
Jitudebz/psychic-pancake
/Machine_Learning/Cost_Function_Example.py
949
3.515625
4
# -*- coding: utf-8 -*- """ Created on Wed May 6 17:32:14 2020 @author: Debasis """ import matplotlib.pyplot as plt import numpy as np #%matplotlib inline def cost_function(x,y): theta = [-0.5,0,0.5,1,1.5,2, 2.5] n = len(x) cost_fun = [] for i in theta: y_predicted = i * x ...
9660026af326657e1e73e902dc88627ae35be77e
jushwillcarriaga29/fcpc_phyton_project
/activity A_carriaga.py
340
3.96875
4
#Activity A #1st print("una") for x in range (1,17,3): print(x, end='\t') print() print() #2nd print("pangalawa") for x in range (100,75,-7): print(x,end='\t') print() print() #3rd print("pangatlo") for x in range(1,5): if x % 3 == 0: print ("1", end = '\t') else: print("0", end = '\...
b86fdbe13578a7706c8e71a5484c312745c3d335
MartinMosqueira/lab
/alumnos/56193-martin-mosqueira/TP 1/argumentos.py
308
3.578125
4
import re import os def validar_argumentos(argumento): if re.search(r'[a-z|A-Z|\-]', argumento) != None: print('ERROR: algun/os argumentos son invalidos') os.system('pkill -9 -f main.py') elif '.' in argumento: return float(argumento) else: return int(argumento)
c56a4786cc3a91db35eb720b14c5734e5af179d2
wscotten/Actioniks
/python/src/complete_second_layer.py
3,132
3.84375
4
def second_layer_algorithm_left(cube, solution): rotate_back(cube, 3, solution) rotate_left(cube, 3, solution) rotate_back(cube, 1, solution) rotate_left(cube, 1, solution) rotate_back(cube, 1, solution) rotate_up(cube, 1, solution) rotate_back(cube, 3, solution) rotate_up(cube, 3, solut...
8c3f278b4044f2c3db34f137e30341679f881338
math-miki/AtCoderTraining
/ABC097/B.py
487
3.828125
4
x = int(input()) def isPrime(n): if n%2 == 0 or n%3 == 0: return True if n<3: return False for i in range( 2, int(n**0.5) +1): if n%i == 0: return False return True primes = [i for i in range(1, 32) if isPrime(i)] def isExp(n): if n==1: return True for i in [p for p in primes if p<int(n**0.5)+1]: ...
c5ec1230ce9f702b21e8f6279d02e9e76b21c848
priitsepp/python
/Tund 2/kordus.py
621
3.5
4
index=100 yandex=2 #print(index) #while index<10: #print(index) #print(yandex) #index+=1 #yandex+=100 #if index==5: #continue #else: #print("Condition is False") #fruits=["apple","banana","cherry"] #for x in fruits: #print(x) #pass?? #for x in "auto": #print(x) #for x...
d756476dbf953983fc449c6a2cba3663b704ec31
takashaaark/ai_blog
/title_maker.py
1,394
3.5
4
""" 地名を与えたらタイトルをつくってくれる """ from random import choice from datetime import datetime # 記事の内容 def title_maker(pref_name, target_name): year = str(datetime.now().year) list_head = [pref_name, '絶対うまい', '絶品', '決定版', '幸せ', '美味い', 'よだれ', 'ロマン', '伝説の店'] list_word1 = ['生きているうちに', '死ぬまでに', '知らなきゃ損?', 'レビュワーおすすめの...
7645ddcca0b8d4b6706589d80e7ae74883197f6d
takashaaark/ai_blog
/201706291825_tabelog_search.py
2,635
3.515625
4
""" 食べログから情報をいただく """ import urllib.request as req from bs4 import BeautifulSoup from random import randint URL = 'https://tabelog.com/' class TabelogSearch(object): def __init__(self): # 都道府県の番号をランダム出力 self.num = randint(0, 46) # 都道府県リスト self.pref_list = self.get_prefecture_lis...
e32998dd28cc440f24fb59a43821e3c8fad6fc90
gamirou/ALevelProject
/lib/frames/progress_bar_footer.py
3,266
3.5625
4
import tkinter as tk from tkinter import ttk from ..utils.utils import DETERMINATE, INDETERMINATE, TRAIN class ProgressBarFooter(tk.Frame): """ A small tkinter box which shows a progress bar on a variety of actions that work on a separate thread. There is a special case on training the network when it has...
42683941d59ed23607fbccd319f3368fd0e5210f
999010alex/pizza
/pizza.py
763
3.71875
4
# pizza "this is a pizza making simulator" def mix_and_cook(): print("Flatten out dough") print("put tomato sauce on dough") print("put cheese and ingredients on dough") print("put pizza in oven") print("take pizza out of oven in 20 minutes") def make_pizza(ingredient): print("How to make an piz...
e33352708de4d7a14e320021cc983a02f00561cc
yang15/integrate
/integrate/store/order.py
862
4.46875
4
""" Example introduction to OOP in Python """ class Item(object): # count = 0 # static variable def __init__(self, name, num_items, unit_price): self.name = name self.num_items = num_items self.unit_price = unit_price print ('Hello world OOP') # Item.count += 1 ...
6fa65b20517fac737f6ca71c3c2f3b13d40ac37f
CJLucido/Data-Structures
/queue_and_stack/dll_queue.py
2,115
3.5625
4
import sys sys.path.append('../doubly_linked_list') from doubly_linked_list import DoublyLinkedList class Queue: def __init__(self): # should increase when we enqueue and decrease if we dequeue OR should always just match the dll length self.size = 0 # Why is our DLL a good choice to stor...
9bfcbd873d1d1a9b610c46150277b958fa02458d
RimikaM/Predict-Stock-Prices
/Support_Vector_Regression.py
1,615
3.640625
4
# Project uses the scikit-learn machine learning library to train # a support vector regression on the Google stock price dataset # to predict a future price. # SVR uses the space between points as a margin of error and # predicts the most likely next point in a dataset. import csv import numpy as np from sklearn....
f5e2b4837d5c888f73c555b6c91a25bfc29bc479
FullMasterDungeon/hw-2_7
/homework2_7.py
212
3.71875
4
class person: age = 30 height = 183 weight = 71 def printer(self): print(f"возраст = {self.age}, рост = {self.height}, вес = {self.weight}") ex = person() ex.printer()
da4f1e6c5ad389a1849d028a1f62b593fb696c78
danae678/techx-appliedds
/Associative Arrays/anagrams.py
427
3.859375
4
def anagrams(words): anagrams = {} for i in words: if str(sorted(i)) in anagrams: anagrams[str(sorted(i))].append(i) else: anagrams[str(sorted(i))] = [i] anagrams_list = list(anagrams.values()) return [x for x in anagrams_list if len(x) >1] #remove lists with one ...
e336b79128e8b59a036545dade31c816a1e19f42
lukaa12/ALHE_project
/src/BestFirst.py
2,416
4.25
4
import Graph from Path import Path import datetime class BestFirst: """Class representing Best First algorithm It returns a path depending on which country has the highest number of cases on the next day""" def __init__(self, starting_country, starting_date, alg_graph, goal_function): """Initializ...
832e0ad069ab5e8ac04349be0e69358467c57bf6
Freewin/mclass
/adv_features_classwork/complex_inherit_from_builtin_example.py
501
3.859375
4
# Mylist inherits from list object but indexes from 1 instead of 0! class MyList(list): def __getitem__(self, index): if index == 0: raise IndexError if index > 0: index = index - 1 return list.__getitem__(self, index) def __setitem__(self, index, value): if index == 0: raise...
686f07f9ef65ba86aba149796ca750af4fc99407
Freewin/mclass
/assignments/assignment_1/assignment1.py
362
3.578125
4
class MaxSizeList(object): def __init__(self, size): self.size = size self.my_list = [] def push(self, element): if len(self.my_list) < self.size: self.my_list.append(element) else: self.my_list.pop(0) self.my_list.append(element) def ge...
58e896e3e1f160649a9ec34f2631a1cfa0b2ff00
zealand2019e/PythoCodo
/snake.py
527
3.53125
4
from sense_hat import SenseHat import time sense = SenseHat() green = (0, 255, 0) yellow = (255, 255, 0) blue = (0, 0, 255) red = (255, 0, 0) white = (255,255,255) nothing = (0,0,0) pink = (255,105, 180) sense.clear() sense.set_pixel(1,1,yellow) print type(sense) sense.set_pixel(1,1,blue) x = 1 y = 0 while(y <...
98c426f2c343ce4d41089c0d96119fe9143bc258
SebastianThomas1/coding_challenges
/hackerrank/data_structures/linked_lists/print_the_elements_of_a_linked_list.py
389
3.71875
4
# Sebastian Thomas (coding at sebastianthomas dot de) # https://www.hackerrank.com/challenges/print-the-elements-of-a-linked-list # # Print the Elements of a Linked List class SinglyLinkedListNode: def __init__(self, node_data): self.data = node_data self.next = None def print_linked_list(head):...
5bd92fdf8e958a2c28b157dfd5f67ebde41c66cc
SebastianThomas1/coding_challenges
/hackerrank/algorithms/implementation/the_hurdle_race.py
300
3.5
4
# Sebastian Thomas (coding at sebastianthomas dot de) # https://www.hackerrank.com/challenges/the-hurdle-race # # The Hurdle Race def hurdle_race(k, height): return max(max(height) - k, 0) if __name__ == '__main__': print(hurdle_race(4, [1, 6, 3, 5, 2])) print(hurdle_race(7, [2, 5, 4, 5, 2]))
600455663b9b41c47b837bbd25bb99bec604c77f
SebastianThomas1/coding_challenges
/hackerrank/data_structures/linked_lists/cycle_detection.py
521
3.53125
4
# Sebastian Thomas (coding at sebastianthomas dot de) # https://www.hackerrank.com/challenges/detect-whether-a-linked-list-contains-a-cycle # # Cycle Detection class SinglyLinkedListNode: def __init__(self, node_data): self.data = node_data self.next = None def has_cycle(head): fast_node = h...
9e2897d2e8dbefdc73e7b09888e02928284a159d
SebastianThomas1/coding_challenges
/hackerrank/algorithms/warmup/staircase.py
327
3.609375
4
# Sebastian Thomas (coding at sebastianthomas dot de) # https://www.hackerrank.com/challenges/staircase # # Staircase def staircase(n): for idx in range(1, n + 1): print(' ' * (n - idx) + '#' * idx) if __name__ == '__main__': staircase(6) # # # ## # ### # #### # ##...
056be20ed1e3365c7fdde9a90eaa63c5dcb36b19
SebastianThomas1/coding_challenges
/hackerrank/data_structures/linked_lists/print_in_reverse.py
740
4
4
# Sebastian Thomas (coding at sebastianthomas dot de) # https://www.hackerrank.com/challenges/print-the-elements-of-a-linked-list-in-reverse # # Print in Reverse class SinglyLinkedListNode: def __init__(self, node_data): self.data = node_data self.next = None def reverse(head): current_node ...
ac344e36f3dce324aae4767dc22ef38ce73d50d6
SebastianThomas1/coding_challenges
/hackerrank/data_structures/linked_lists/merge_two_sorted_linked_lists.py
892
3.578125
4
# Sebastian Thomas (coding at sebastianthomas dot de) # https://www.hackerrank.com/challenges/merge-two-sorted-linked-lists # # Merge two sorted linked lists class SinglyLinkedListNode: def __init__(self, node_data): self.data = node_data self.next = None def merge_lists(head1, head2): if he...
402ac6c6d6bf0b011b5f6c1620fd7ad829ae53cd
SebastianThomas1/coding_challenges
/codility/9_maximum_slice_problem/max_slice_sum.py
1,693
3.921875
4
# Sebastian Thomas (coding at sebastianthomas dot de) # https://app.codility.com/programmers/lessons/9-maximum_slice_problem/max_slice_sum/ # # MaxSliceSum # # Find a maximum sum of a compact subsequence of array elements. # # A non-empty array A consisting of N integers is given. A pair of # integers (P, Q), such tha...
b88694787e760fc402a79b903e10fe1a05a3f64a
SebastianThomas1/coding_challenges
/leetcode/97_interleaving_string.py
1,874
4.0625
4
# Sebastian Thomas (coding at sebastianthomas dot de) # https://leetcode.com/problems/interleaving-string/ # # 97. Interleaving String # # Given strings s1, s2, and s3, find whether s3 is formed by an # interleaving of s1 and s2. # # An interleaving of two strings s and t is a configuration where they # are divided in...
5d7a976e31386cb8a6f6f77d269e4886f9d2c8ba
SebastianThomas1/coding_challenges
/hackerrank/algorithms/implementation/divisible_sum_pairs.py
579
3.703125
4
# Sebastian Thomas (coding at sebastianthomas dot de) # https://www.hackerrank.com/challenges/divisible-sum-pairs # # Divisible Sum Pairs from collections import Counter def divisible_sum_pairs(k, ar): ar = [value % k for value in ar] counter = Counter(ar) res = 0 for i in range(k // 2 + 1): ...
c412ba036185888f18f9c65e651095d44f7ef0ea
SebastianThomas1/coding_challenges
/leetcode/42_trapping_rain_water.py
952
3.75
4
# Sebastian Thomas (coding at sebastianthomas dot de) # https://leetcode.com/problems/trapping-rain-water/ # # 42. Trapping Rain Water # # Given n non-negative integers representing an elevation map where the # width of each bar is 1, compute how much water it can trap after # raining. from typing import List def t...
1caf104568ce8b26b1f56bc5a6f84eacc0f6f306
SebastianThomas1/coding_challenges
/codewars/6kyu/strongest_even_number_in_an_interval.py
716
3.65625
4
# Sebastian Thomas (coding at sebastianthomas dot de) # https://www.codewars.com/kata/5d16af632cf48200254a6244 # # Strongest even number in an interval def compute_strength(k): v = 0 while k % 2 == 0: k = k / 2 v += 1 return v def strongest_even(n, m): strength = 0 k = n s...
7613cf0d025b428df2b9b1378cf571d896e10f10
SebastianThomas1/coding_challenges
/hackerrank/data_structures/arrays/arrays.py
286
3.6875
4
# Sebastian Thomas (coding at sebastianthomas dot de) # https://www.hackerrank.com/challenges/arrays-ds # # Arrays - DS def reverse_array(a): return a[::-1] if __name__ == '__main__': print(reverse_array([1, 2, 3])) # [3, 2, 1] print(reverse_array([1, 4, 3, 2])) # [2, 3, 4, 1]
5d0225d3d47583ad338dae3e5e16774e7e17cd47
SebastianThomas1/coding_challenges
/hackerrank/algorithms/implementation/electronics_shop.py
451
3.53125
4
# Sebastian Thomas (coding at sebastianthomas dot de) # https://www.hackerrank.com/challenges/electronics-shop # # Electronics Shop def get_money_spent(keyboards, drives, b): costs = {keyboard + drive for keyboard in keyboards for drive in drives if keyboard + drive <= b} return max(costs) if cos...
a1c30e9434000329dbcf35689299dbabe9a93662
SebastianThomas1/coding_challenges
/hackerrank/python/introduction/python_if-else.py
331
3.671875
4
# Sebastian Thomas (coding at sebastianthomas dot de) # https://www.hackerrank.com/challenges/py-if-else # # Python If-Else def if_else(n): if n % 2 == 1 or 6 <= n <= 20: print('Weird') elif 2 <= n <= 6 or n > 21: print('Not Weird') if __name__ == '__main__': if_else(3) # Weird if_e...
77163cdb86b05315890c5dc96d4a6598eef2acdb
SebastianThomas1/coding_challenges
/codewars/7kyu/two_to_one.py
458
3.5
4
# Sebastian Thomas (coding at sebastianthomas dot de) # https://www.codewars.com/kata/5656b6906de340bd1b0000ac # # Two to One def longest(s1, s2): return ''.join(sorted(set(s1 + s2))) if __name__ == '__main__': print(longest('aretheyhere', 'yestheyarehere')) # aehrsty print(longest('loopingisfunbutdang...
2977af25235183b601155c4059ba4100faa3aec1
EmperorEuler/leetcode
/数组/[118]杨辉三角.py
1,199
3.53125
4
# 给定一个非负整数 numRows,生成「杨辉三角」的前 numRows 行。 # # 在「杨辉三角」中,每个数是它左上方和右上方的数的和。 # # # # # # 示例 1: # # # 输入: numRows = 5 # 输出: [[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]] # # # 示例 2: # # # 输入: numRows = 1 # 输出: [[1]] # # # # # 提示: # # # 1 <= numRows <= 30 # # Related Topics 数组 动态规划 👍 600 �...
b896357362fc264e855a58407884d0f008552c75
EmperorEuler/leetcode
/数组/[88]合并两个有序数组.py
3,518
3.921875
4
""" 给你两个按 非递减顺序 排列的整数数组 nums1 和 nums2,另有两个整数 m 和 n ,分别表示 nums1 和 nums2 中的元素数目。 请你 合并 nums2 到 nums1 中,使合并后的数组同样按 非递减顺序 排列。 注意:最终,合并后数组不应由函数返回,而是存储在数组 nums1 中。为了应对这种情况,nums1 的初始长度为 m + n,其中前 m 个元素表示应合并的元 素,后 n 个元素为 0 ,应忽略。nums2 的长度为 n 。 示例 1: 输入:nums1 = [1,2,3,0,0,0], m = 3, nums2 = [2,5,6], n = 3 输出:[1,2...
bc294004a8f0809a678a8e999b8d3e0026c9c0cd
clinnus7/Bacon-Number
/lab2/lab.py
8,151
3.578125
4
# NO IMPORTS ALLOWED! import json filename = 'resources/names.json' with open(filename, 'r') as f: names = json.load(f) # Dictionary with keys as actor names and values as actor IDs filename = 'resources/movies.json' with open(filename, 'r') as f: movies = json.load(f) # Dictionary with keys as actor names a...
e342fdef15e574d32f02c3671f89897d0ca2a119
yyyy777/python
/pythonDataStructures/insertionSort插入排序.py
337
4
4
# 插入排序 def insertionSort(alist): for index in range(1,len(alist)): currentvalue = alist[index] position = index while position > 0 and alist[position-1] > currentvalue: alist[position]=alist[position-1] position = position-1 alist[position]=cur...
37f5fa0af464c83717170005f29dddeb0a7aaa37
AtharvaDev/Python-Programs
/Basic Programs/2_max_num.py
79
3.765625
4
def max(a,b): if a >= b: return a else: return b print(max(2,3))
c5830c48b57296318990ebf97542b596eeeee799
kamalk028/Handwritten_digit_classification
/facennScript.py
6,473
3.515625
4
''' Comparing single layer MLP with deep MLP (using TensorFlow) ''' import numpy as np from scipy.optimize import minimize from math import sqrt import pickle import datetime # Do not change this def initializeWeights(n_in,n_out): """ # initializeWeights return the random weights for Neural Network given the ...
7309a377af0802fee1b441108e9bd1768e0044ba
Athenian-ComputerScience-Fall2020/mad-libs-eskinders17
/my_code.py
1,164
4.15625
4
# Collaborators (including web sites where you got help: (enter none if you didn't need help) # name = input("Enter your name: ") town = input("Enter a name of a town: ") feeling = input("Enter how are you feeling now. Happy, sad or bored: ") trip = input("Enter a place you want to visit: ") friend = input("Enter the n...
a49681829f540e02bdf29d466738a26e5e0a9c93
nicolo-felicioni/recsys-polimi-2019
/Utils/weights_generator.py
1,298
3.53125
4
import math import numpy as np def linear (mean = 0.5, offset = 0.5, size=30): min = mean - offset max = mean + offset if min < max: step = (max - min) / 10 list = np.array([range(size)], dtype=np.float) + 1 list = list * step + min list = list / list.max() delta = ...
6046c3ee74511094ce6e98fe84746235141cf768
AP-MI-2021/lab-4-konyaanna
/main.py
2,046
3.796875
4
def citire_lista(): """ functia citeste o lista :return: lista citita """ l = [] n = int(input("dati numarul de elemente: ")) for i in range(n): l.append(int(input("l[" + str(i) + "]="))) return l def nrpozcat (l): """ concateneaza toate nr pozitive din si...
f44a8f98c47fef4cc394dc0e554bb1021275e519
Mayaaugustine/Python
/assign1.py
287
3.65625
4
##A sequence consists of integer numbers and ends with the number 0. ##Determine how many elements of this sequence are greater than their neighbors above. a = [10,30,50,100,60,190,5650,55650,600] b = len(a) count=0 for i in range(0,b-1) : if a[i+1] > a[i]: print(a[i+1])
02ff74fc6b15f9fd90ac791199556361e642a96c
wfhendrix11/PPL
/A1/Scanner.py
3,962
4.03125
4
from Token import Token import os.path import sys # Class Scanner - Reads a TINY program and emits tokens. class Scanner: # Constructor - Is passed a file to scan and outputs a token # each time nextToken() is invoked. def __init__(self, fileName): self.position = 0 sel...
3708b164b2d3a6e31ea212b4b07156ee62eca4d5
makirodriguez/SintaxisYSemanticaDeLenguajes
/tadCola.py
556
3.765625
4
def crearCola(): #Crea la cola vacia cola=[] return cola def encolar(cola,proceso): #Agrega un proceso al final de la cola cola.append(proceso) def desencolar(cola): #Elimina el primer proceso de la cola elem=cola[0] del cola[0] return elem def esVacia(cola): #Retorna true si la cola est...
99bed9407ddea288afaab36de01881c0a538a293
WillAlex2017/-offerPython-
/copydfh.py
600
3.546875
4
# -*- coding: utf-8 -*- """ Created on Wed Apr 25 11:47:51 2018 @author: willalex """ def get_mode(arr): mode = []; arr_appear = dict((a, arr.count(a)) for a in arr); # 统计各个元素出现的次数 if max(arr_appear.values()) == 1: # 如果最大的出现为1 return; # 则没有众数 else: for k, v in arr_appear...
c61e3b6cbd4e92b8bb86c6b0ebcab7c2ff2e665f
Pocom/Programming_Ex
/137_Single Number II/t_2.py
278
3.5
4
class Solution: def singleNumber(self, nums: List[int]) -> int: nums.sort() ans = None n = len(nums) for i in range(0, len(nums), 3): if i == n - 1 or nums[i] != nums[i + 1]: return nums[i] return nums[-1]
8d074cbc55082e6076e4aca5bb6996b3398bfc0b
Pocom/Programming_Ex
/_28_Implement_strStr()/t_1.py
325
3.828125
4
class Solution: def strStr(self, haystack: str, needle: str) -> int: if not needle: return 0 if needle not in haystack: return -1 else: return haystack.index(needle) # testing t = Solution() haystack = "aaaaa" needle = "bba" print(t.strStr(haystack, need...
e173e1b2159697d01d83403442e5bc2741c9592a
Pocom/Programming_Ex
/26_RemoveDuplicatesfromSortedArray/t.py
95
3.59375
4
nums = [0, 0, 0, 3, 4, 5, 6] for item in nums: print(nums) print(item) print(3 and 4)
daeaba5d4388308be9aa532cc91b1d8efa32b6b7
Pocom/Programming_Ex
/9_PalindromeNumber/t_1.py
831
4.375
4
""" Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Input: 121 Output: true Example 2: Input: -121 Output: false Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome. """ ...
fed7e125b5ee9150008cb0e32035351811096195
Pocom/Programming_Ex
/167_Two Sum II - Input array is sorted/t_1.py
459
3.5625
4
class Solution: def twoSum(self, numbers, target): """ :param numbers: List[int] :param target: int :return: List[int] """ if not numbers: return None i, j = 0, len(numbers)-1 while i<j: s = numbers[i]+numbers[j] if s>target: ...
49f004cfa129b07f45bf4e5dca1377b22efc2c34
Pocom/Programming_Ex
/104_MaximumDepthofBinaryTree/t_1.py
793
3.828125
4
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def maxDepth(self, root: TreeNode) -> int: queue = [root] cnt = 0 if not root: return 0 while queue: ...
f136b57278b647996f09d5175fb8d414c1cbdb33
Pocom/Programming_Ex
/7_ReverseInteger/t_1.py
1,089
4.09375
4
""" Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231,  231 − 1]. For the p...
04cf63d0a4f53cdc7f0c0af2d8772cba314da9b0
Pocom/Programming_Ex
/1160_Find Words That Can Be Formed by Characters/t_1.py
337
3.546875
4
class Solution: def countCharacters(self, words: List[str], chars: str) -> int: ans = 0 for word in words: # for s in word: for s in set(word): if word.count(s) > chars.count(s): break else: ans += len(word) ...
c237011b226614afcb3484b92190dcf1750161f7
Pocom/Programming_Ex
/83_RemoveDuplicatesfromSortedList/t_1_wrong.py
550
3.671875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def deleteDuplicates(self, head: ListNode) -> ListNode: if not head: return head if not head.next: return head l1, l2...
39f3d467d948f05da2709f417229e33e1a596a76
hjwp/ttt
/ttt.py
2,106
3.546875
4
from typing import List from dataclasses import dataclass from enum import Enum class Rows(Enum): TOP = 1 MIDDLE = 2 BOTTOM = 3 class Cols(Enum): LEFT = 1 MIDDLE = 2 RIGHT = 3 @dataclass class Position: col: Cols row: Rows class Positions(list): def __init__(self, positions: Li...
b6a10c8cebf705eb4a6a0db5689d8ee67f21b357
wizerdspell2007/fcconverter-2.0
/fcconverter.py
243
3.859375
4
print("welcome to fcconverter 2.0!") while(True): a=input("input fahr value (q to quit): ") if a == "q" or a == "Q": break f = float(a) c = (f - 32) * 0.5556 print("your value is") print("...") print(c)
ebccdf62ed0774eddad34d530c44f444e91c5fce
jm-rives/Euler_exercises
/EUex3.py
686
3.578125
4
# To determine what is the largest prime factor of the number 600851475143 ? factors = 0 # a place to put the factors which are the divors and quotients #big_num = 600,851,475,143 big_num = 50 # chosen for known factors of 1, 2, 5, 10, 25, 50, of which 2 & 5 are primes factors the largest of which is 5 divisor = 2 # k...
59518d3b077d8e33bf1c5ef3e53b636f2f325c54
Julchu/Algorithms
/leetcode.py
1,630
3.65625
4
from typing import List class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: # 153: my attempt def findMin(self, nums: List[int]) -> int: if len(nums) == 0: return elif len(nums) == 1: return nums[0] ...
8600f596d6e775cf4f4caaa96e5135106601c136
joelm97/Leasing-app
/leasingApp.py
4,854
4.3125
4
#Name: Joel Mondal #Project: Leasing application # opens intro file intro = open("intro.txt", "r") print(intro.read()) #list of apartments apartmentList= [["(1)Bedroom(1)Bath","1500","800","1" ], ["(2)Bedroom(1)Bath","1800","1000","2"], ["(2)Bedroom(2)Bath","2000","1200","3"], ...
a2545f4836cc17e78884eb6e0ce8bd6f30fc45b0
NoahMeislik/stock-trading-with-rl
/agents/agent.py
644
3.65625
4
from abc import ABCMeta, abstractmethod import numpy as np class Agent(metaclass=ABCMeta): """Abstract Agent class""" @abstractmethod def _model_init(self): """ Initializes parameters used by the model based on predefined settings """ raise NotImplementedError @abstra...
01850cff5a7e0a8099728d2e8cfb2dd79afd991c
Pigot12/onlinecoursesvertex
/19122020.py
435
4.03125
4
# Hello World print("Hello World") # 5 + 3 - 1 print(5 + 3 - 1) # 3 *(2+5) print(3 * (2+5)) # 3 * 2 print(3 * 2) #Value Name name = ("name") print("name Age ...") #Value P p = 3.14 print ("p") #Value X x = (5) print (5 * 5 / x) name = "name" age = "14" color = ...
095152216a1e8e84006cd5207a480efe2098206e
Pigot12/onlinecoursesvertex
/3120212.py
499
3.921875
4
# pairneis input 2 ari8mous # input metavlith(*, +, -, /) number1 = int(input(print("Ton ariumo sas PARAKALW"))) number2 = int(input(print("Enan allo ariumo PARAKALWW"))) variable = input(print("Kai teletaio thn metablth sas PARAKALW")) if(variable == '+'): print(number1 + number2) elif(variable == '-'...
79563c8be2fcd56c3d7a5c9708110b7cd7e64fdb
darioradio1man/cmc_msu_2019
/SelfCount.py
683
3.9375
4
# Написать класс WeAre, объекты которого содержат поле count, содержащее количество существующих экземпляров # этого класса. Игнорировать попытки изменить значение этого поля вручную или удалить его. class WeAre(object): rcount = 0 def __init__(self): WeAre.rcount += 1 @property def count(se...
938ceceaa47ac97c7a1219dd07729eb3ab267af9
Fundamental-Basic/Fundamental-Python
/if_else.py
1,497
3.984375
4
#CONDITIONS AND IF STATEMENTS a = 10 b = 20 if b > a: print("b is greater than a") #INDENTATION c = 30 d = 40 if d > c: print("d is greater than c") # ada indentation #ELIF e = 30 f = 30 if e > f: print("e is greater than f") elif e == f: print("e and f are equal") #ELSE g = 50 h = 40 if h > g: print...
19fa94e8b19cc14f4fc91b0a8e6daa7cd98a5dfb
Fundamental-Basic/Fundamental-Python
/data_type.py
1,431
3.890625
4
''' TIPE DATA / DATA TYPE ''' a = 6 #tipe data integer (int) b = 2.1 #tipe data float c = 'Hello World' #tipe data string (str) '''tipe data stirng bisa diakses sesuai indeksnya dan berapa karakter yg akan diakses, contohnya dari vaiable c hanya akan diakses karakter 'Wor' maka cara aksesnya seperti ini print (c[6:9...
31fc463b4b6ddf773f3db7ca30d431184562f711
tofritz/example-work
/practice-problems/reddit-dailyprogramming/yahtzee.py
1,614
4.25
4
# The game of Yahtzee is played by rolling five 6-sided dice, and scoring the results in a number of ways. # You are given a Yahtzee dice roll, represented as a sorted list of 5 integers, each of which is between 1 and 6 inclusive. # Your task is to find the maximum possible score for this roll in the upper section of ...
7520153742f75c48b6b23f35837689ca41f09048
tofritz/example-work
/py4e/Ch9/ex_09_02.py
301
3.859375
4
fname = input('Enter a filename:') try: fhand = open(fname, 'r') except: print('Invalid filename:', fname) quit() count = dict() for line in fhand: words = line.split() if len(words) >= 3 and words[0] == 'From': count[words[2]] = count.get(words[2], 0) + 1 print(count)
e5ff39ad1b98b89a33f3704cc3eebbaf1fea46d6
tofritz/example-work
/py4e/Ch10/ex_10_03.py
702
3.84375
4
import string fname = input('Enter a filename:') try: fhand = open(fname, 'r') except: print('Invalid filename:', fname) quit() char_dict = {} for line in fhand: line = line.translate(line.maketrans('', '', string.whitespace)) line = line.translate(line.maketrans('', '', string.digits)) line ...
0ce19499a509e084ae3ceff1e29aa2b13328cd73
SurajKhot/Python-practice
/evenodd.py
123
4.125
4
n=int(input("enter n: ")) """ if n%2==0: print("even") else: print("odd") """ print("even") if n%2==0 else print("odd")
c7aacbbc5f2da83c0ddd9639270156ea58ce03dd
SurajKhot/Python-practice
/playstring.py
513
3.921875
4
msg="good afternoon" print(msg.capitalize()) name="mehul chopra" print(name.title()) print(name.upper()) print(name.lower()) print(msg.find("afternoon")) print(msg.find("evening")) #-1 since not found msg1="hello " print(msg1.rstrip()) #lstrip #length of the string print(len(msg)) #no of characters in the str #...
c8828daf8e280300450c7e8cb2ef951f4f1c93b6
iamdanahn/Learning-Python
/W1D1/test.py
1,547
4.03125
4
# x = 25 # y = 17.6 # print(x) # print(x+y) # print(x * y) # print(x ** y) # print(x / y) # print(x // y) # print(x % y) # print(f'The result is {int(x // y)} remainder {x % y}') ## INPUT # name = input("what is your name? ") # print(f"hello {name}") # print("Hello, %s" % name) # print(len('box')) # a = ['a', 'b']...
422375bff1786e0fad4c2b08d0c5e19dfec1491f
kartikadur/PracticeCodePy
/src/regex-7.py
324
3.578125
4
''' Created on Jul 3, 2013 @author: zeroshiiro ''' import re line = [] for i in range(0, int(input())): line.append(input()) for i in range(0,int(input())): count = 0 w = input() for j in line: m = re.findall(r"(?<!\w)" + w + "(?!\w)", j) count += len(m) print(co...
ab20cd679bef8478b9422caf93339eb7404f9adf
bboyrankingz/codejam
/adventofcode/day9/stream_processing.py
310
3.640625
4
def stream(sequence, step=1): if len(sequence) == 0: return 0 for i in range(len(sequence)): if sequence[i] == "{": print(sequence[i+1:len(sequence) - i - 1]) step = step + stream(sequence[i+1:len(sequence) - i - 1], step + 1) break return step
d94e7a023aa1e5bef17c269e2493150679124ccb
hytsang/Python_ML
/Tensorflow_CNNtest1.py
3,290
3.546875
4
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data # input and datatype mnist = input_data.read_data_sets("MNIST_data/", one_hot = True) x_ = tf.placeholder(tf.float32, [None,784]) ##28*28 y_ = tf.placeholder(tf.float32, [None,10]) x_image = tf.reshape(x_, [-1,28,28,1]) ## Gray scale:1...
c587a0f255108121e387c57352ede30114afa8d2
devjoag/PyAssignments
/Assignment_3/isPrime.py
144
3.734375
4
def checkPrime(no): isPrime=True for i in range(2,no): if(no%i==0): return False return isPrime
6aed4a035dd07fd7b50f736bae29cffe254a9dee
devjoag/PyAssignments
/Assignment_1/Assignment1_4.py
262
3.734375
4
""" Write a program which display 5 times Marvellous on screen """ def PrintMessage(number,message="Marvellous"): print((message+"\n")*number) def main(): PrintMessage(5) PrintMessage(5,"Python") if(__name__) == "__main__": main()
2e48b94c08e857770a8d48047090faf3ffe36780
devjoag/PyAssignments
/Assignment_4/Assignment_4_1.py
181
4.0625
4
pow=lambda n:n**2 def main(): n=int(input("Please Enter number")) print("power of two of {} is {}".format(n,pow(n))) if(__name__) == "__main__": main()
1252708614b6857073d21facbe33805818a8911a
Saber307/My-University-Life-Learning
/100 Days of Code - The Complete Python Pro Bootcamp for 2021/Day 4/rock-paper-scissors-start.py
1,098
4.03125
4
#Link: https://replit.com/@appbrewery/rock-paper-scissors-start import random rock = ''' _______ ---' ____) (_____) (_____) (____) ---.__(___) ''' paper = ''' _______ ---' ____)____ ______) _______) _______) ---.__________) ''' scissors = ''' _______ ---...
9c9be5d737228ac0d903dea945ef42c1380fd043
Saber307/My-University-Life-Learning
/100 Days of Code - The Complete Python Pro Bootcamp for 2021/Day 2/day-2-1-exercise.py
336
3.71875
4
#Link: https://replit.com/@appbrewery/day-2-1-exercise # 🚨 Don't change the code below 👇 two_digit_number = input("Type a two digit number: ") # 🚨 Don't change the code above 👆 #################################### #Write your code below this line 👇 sum=int(two_digit_number[0])+int(two_digit_number[1]) print(su...
614c1bd32b0b3d498941a4b8b530e82bdb10deed
Saber307/My-University-Life-Learning
/Assignment/task 7.py
356
3.640625
4
n1_list=input() n2_list=input() list_1=n1_list.strip('][').split(',') list_2=n2_list.strip('][').split(',') list_one=[] list_two=[] for x in list_1: list_one.append(int(x)) for y in list_2: list_two.append(int(y)) list_three=list_one+list_two list_four=[] for i in list_three: if i not in list_four: ...
062bb7390ee04144ac2c2ca04143f363cd4cc416
Saber307/My-University-Life-Learning
/52 programming problems/problem 1.py
242
3.96875
4
val_1=int(input("")) val_3=[] for x in range(0,val_1): val_2=int(input("")) if val_2% 2 == 0: val_3.append(1) else: val_3.append(0) for j in val_3: if j==1: print("even") else: print("odd")
eb9dc79b9f194a8f5ad44996b6a9a1e3bb76e84e
Saber307/My-University-Life-Learning
/Assignment/assignment 5 question 11.py
172
3.546875
4
val_0=input("").strip('""').lower() val_1=[] for i in val_0: val_1.append(i) val_2={} for i in val_1: if i!=" ": val_2[i]=int(val_1.count(i)) print(val_2)
f8118fb74fe4412a265a38bd9c3b4becbdd6248a
Saber307/My-University-Life-Learning
/100 Days of Code - The Complete Python Pro Bootcamp for 2021/Day 3/day-3-5-exercise.py
1,020
4.09375
4
#Link: https://replit.com/@appbrewery/day-3-5-exercise # 🚨 Don't change the code below 👇 print("Welcome to the Love Calculator!") name1 = input("What is your name? \n") name2 = input("What is their name? \n") # 🚨 Don't change the code above 👆 #Write your code below this line 👇 name1=name1.lower() name2=name2.low...
ee05f9705eced496fb97e81f7acef7d9e69af005
Saber307/My-University-Life-Learning
/100 Days of Code - The Complete Python Pro Bootcamp for 2021/Day 5/day-5-3-exercise.py
159
3.859375
4
#Link: https://replit.com/@appbrewery/day-5-3-exercise #Write your code below this row 👇 sum=0 for x in range(1,101,1): if x%2==0: sum+=x print(sum)
e80b9773e3b60c88cda0d7d41aebe30cc0739b00
huizai-zhong/operational-tool
/remote_comm.py
2,010
3.546875
4
''' 并行批量管理远程服务器 Usage: python remote_comm.py 服务器IP地址文件 "需要执行的命令" Example: python remote_comm.py serverips.txt "useradd dcc" ''' import sys import os import getpass import threading import paramiko def remote_comm(host, passwd, command): # 创建用于连接SSH服务器的实例 ssh = paramiko.SSHClient() # 设置自动添加主机秘钥 ssh.se...