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
c009226d54e7f5379790946bdfd24d8648ca6d2e
TraceOnBrainOff/pp1
/02-ControlStructures/zadania/10.py
57
3.84375
4
x = int(input("X: ")) if x>0 and x%2!=0: print(True)
ebb3fdd5fa12b2fcdd6ffc7d55561a00907f717c
TraceOnBrainOff/pp1
/08-DataStructures/zadania/10.py
188
3.640625
4
student = { "imie": "Adam", "nazwisko": "Nowak", "wiek": 20, "rocznik": 2, "wydzial": "Zarzadzanie", "index": 300111 } for item in student.items(): print(item)
67a54718b4d7fc7510c2c4e7d76a8dac7b42c7ce
TraceOnBrainOff/pp1
/05-ModularProgramming/zadania/QuadraticEquation.py
821
3.921875
4
import math def czytajWspolczynniki(): wspolczynniki = [] while len(wspolczynniki) < 3: wspolczynniki.append(int(input("Podaj współczynnik "+ str(len(wspolczynniki))+": "))) return wspolczynniki def obliczDelte(wspolczynniki): return wspolczynniki[1]**2 - 4*wspolczynniki[0]*wspolczynniki[2] de...
42cd2d96a6d1fa382239504b6047efcd6c0c2d4e
cyxlareina/python
/myfunction.py
216
3.734375
4
__author__ = 'lenovo' def floor(number): result = 0 while result <=number: result = result+1 result =result - 1 return result x=2.7 y=floor(x) def sum(x,y): return x+y print(sum(x,y))
951aa3468c7d034edeff0f7245f64b75d5d7da92
shkmk/AdventOfCode
/2020/3/part1.py
253
3.578125
4
TREE = '#' def main(): with open('in') as f: m = f.readlines() n_tree = 0 l_row = len(m[0]) - 1 for r in range(1, len(m)): n_tree += m[r][(r * 3) % l_row] == TREE print(n_tree) if __name__ == '__main__': main()
cf24cdec92f3b8905cb52f6d6e53124905faac5a
Renwoxin/leetcode
/Hash_Table/hg_884_Uncommon_Words_from_Two_Sentences.py
1,231
4.03125
4
""" We are given two sentences A and B. (A sentence is a string of space separated words. Each word consists only of lowercase letters.)A word is uncommon if it appears exactly once in one of the sentences, and does not appear in the other sentence.Return a list of all uncommon words. You may return the list in any or...
61950280c8b0d397af6ded7891fb7c77fdca3844
Renwoxin/leetcode
/Linked_List /hg_160_Intersection_of_Two_Linked_Lists.py
1,800
4.03125
4
""" Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: A: a1 → a2 ↘ c1 → c2 → c3 ↗ B: b1 → b2 → b3 begin to intersect at node c1. Notes: 1. If the two link...
b4b26076875578b98b5a37c6409327d5d2d9e4df
Renwoxin/leetcode
/array/hg_643_Maximum_Average_Subarray_I.py
1,120
3.953125
4
""" Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum average value. And you need to output the maximum average value. Example 1: Input: [1,12,-5,-6,50,3], k = 4 Output: 12.75 Explanation: Maximum average is (12-5-6+50)/4 = 51/4 = 12.75 Note: 1. 1 <= k <= n <...
fc1bea20adc03d66c8758be3e4e4c6b042279b13
Aayan000/learning-python
/Assignment #2 Q7.py
99
3.75
4
hours = input("Enter a amount of hours: ") pay_rate = float(hours) * float(10.75) print(pay_rate)
4d7d44318533689e43a378d5babcc5ffd1ead0eb
Aayan000/learning-python
/Assignment #2 Q1.py
317
4.0625
4
R = input("Enter a numbers: ") J = input("Enter a numbers: ") add = float(R) + float(J) multiple = float(R) * float(J) subtract = float(R) - float(J) print ("If you add" ,R,"and", J,"you get",add,) print ("If you multiple" ,R,"and", J,"you get",multiple,) print ("If you subtract" ,R,"and", J,"you get",subtract,)
b909c426b9308862f39c1a9eec2389920891fdda
turkishviking/Python-Robocode
/Python-Robocode/Robots/demo.py
4,055
4
4
#! /usr/bin/python #-*- coding: utf-8 -*- from robot import Robot #Import a base Robot class Demo(Robot): #Create a Robot def init(self):# NECESARY FOR THE GAME To initialyse your robot #Set the bot color in RGB self.setColor(0, 200, 100) self.setGunColor(200, 200...
ae9cd1f772145eaf1ca6349026c69c3ecd413697
pbrebner/mini-python-projects
/weather_app.py
984
3.65625
4
# Simple Python Weather App from bs4 import BeautifulSoup import requests headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3" } def weather(city): city = city.replace(" ", "+") x = requests.get( "https://w...
d7cfc5ab4e6ee45b677b0b4351d6222e3f96af13
izukua11might/belajarpython
/for loop.py
1,072
4.125
4
# list sebagai iterable gorengan = ['bakwan','cireng','tahu isi','tempe goreng','ubi goreng'] for g in gorengan:# g yang di depan for merupakan variable baru print (g) #yang mengakses data di variable gorengan oleh command for print(len(g)) #yang di aplikasikan dengan menprint g #Co...
22045a0fda47f225a1f1f9a64de17df058eff400
izukua11might/belajarpython
/tuples.py
719
4.0625
4
# menggunanakan tuples dan membandingkan dengan list data_list = [1,2,3,4,5,6,7,8,9,10] #menggunkan kurung siku data_tuple = (1,2,3,4,5,6,7,8,9,10) #menggunkan kurung biasa #membaca jenis class print(type(data_list)) print(type(data_tuple)) #fitur tuple print(dir(data_tuple))#melihat kegunaan yang tersedia p...
d035b02257f25f757c193b591c4641c8bd3f4a0e
rboudet/Scripts
/Compare.py
1,767
3.53125
4
import xlrd import xlwt file1 = open("C:/Users/RBoudet1/Desktop/365Days.txt", "r") file2 = open("C:/Users/RBoudet1/Desktop/Jan.txt", "r") testComps = file1.readlines() allComps = file2.readlines() CompList = [] # this will be the list that contains all the computers from file 2 f = open('file.txt', 'w') count =0 #C...
132c094cd48bf1917979c3f2b6cde18ea06b1547
lepodl/mnn_box
/test_case/regression.py
4,948
3.515625
4
import mnnbox as mnn import matplotlib.pyplot as plt import random import numpy as np import os def data_iter(batch_size, features, labels): num_examples = features.shape[0] index = list(range(num_examples)) random.shuffle(index) for i in range(0, num_examples, batch_size): j = index[i: min(i +...
8586604f193ad220fb0e871dc52e267eb7e28038
squadran2003/worklog
/task.py
6,890
3.515625
4
import datetime import time import csv import os import re class Task: date= None task_name = None time_spent = None notes = None headers = ["ID", "Date", "Task_name", "Time_spent", "Notes"] def __init__(self): self.date = datetime.date.today().strftime('%d/%m/%Y') def task_as_dict(self): """this ...
bfaee5dd2a9d10b4c1d67debb9acfb72b4ec2c60
alexlimatds/objective_method
/other/extraction_word-frequency.py
2,529
3.640625
4
# Code to perform keyword extraction based on word frequency. It outputs a CSV file # containing a keyword set for each input paper and a keyword set for all the papers import re from nltk.corpus import stopwords import pandas as pd from sklearn.feature_extraction.text import CountVectorizer import preprocessing # Fun...
2eb68b66fe1f0d7d2a6f5d729ed9740494450c6e
alexlimatds/objective_method
/data_readers.py
4,791
3.9375
4
""" Functions to perform reading from the data files. """ import pandas as pd import numpy as np def seed_set(): """ Reads the data from the seed dataset. Returns ------- corpus : list of strings The seed corpus. Each element in the list is a document. known_terms : list The ke...
452b696d838bfd7d77b0c02ea9129f168d6b1786
SuproCodes/DSA_PYTHON_COURSE
/OOP.py
1,994
4.125
4
class Employee: def __init__(self, name): self.name = name def __repr__(self): return self.name john = Employee('John') print(john) # John #---------------------------- # Dog class class Dog: # Method of the class def bark(self): print("Ham-Ham") # Create a new instance charlie = Dog() # C...
9207852a93d1a56f42d0b16fe03e60bdf3c09fe9
oluwa2000/Blackjack
/blackjack.py
9,093
3.765625
4
import random class Card: def __init__(self,suit,rank): if rank == "king" or rank == "queen" or rank == "jack": self.rank = 10 elif rank == "ace": self.rank = 1 elif int(rank) < 2 or int(rank) > 10: raise ValueError else: self.rank = i...
a38dfbc6b365c59f6cf0d419d7f03f726d2ed35f
HallowTeam/Tools
/Crypto/vigenere.py
1,572
3.640625
4
#!/usr/bin/python2 # coding: utf-8 import string CHARSET = string.uppercase class Vigenere(): def formatText(self, text): return text.upper() def formatKey(self, key): return [c for c in key.upper() if c in CHARSET] def encrypt(self, plain, key): key = self.formatKey(key) ...
df7131508d6a7c82e7d2e65cda4525c208e1af6f
deesaw/PythonD-005
/Functions/getindices.py
226
4.03125
4
#write a function which returns all the indices of a char in a string def getindices(word,char): indices=[] for x in range(len(word)): if word[x]==char: indices.append(x) return indices print getindices('cisco','c')
3ea56c6948bf8fb9fbef880a43661c24c1c8abff
deesaw/PythonD-005
/Revise/5.py
1,423
4.09375
4
#Strings #Strings can be concatenated with the + operator, and repeated with *: >>> word = 'Help' + 'A' >>> word 'HelpA' >>> '<' + word*5 + '>' '<HelpAHelpAHelpAHelpAHelpA>' #string index >>> word[4] 'A' >>> word[0:2] 'He' >>> word[2:4] 'lp' >>> word[:2] # The first two characters 'He' >>> word[2:] # Everyth...
d4aec6270fe5e3839121e721c73df2550649ee29
deesaw/PythonD-005
/Revise/2.py
3,057
4.25
4
#let's play with numbers >>> 2+2 4 >>> # This is a comment ... 2+2 4 >>> 2+2 # and a comment on the same line as code 4 >>> (50-5*6)/4 5 >>> # Integer division returns the floor: ... 7/3 2 >>> 7/-3 -3 #The equal sign ('=') is used to assign a value to a variable. #Afterwards, no result is displayed before the next i...
ba457b6bd3dcd2da6a00d0b7daf075cef9e203b1
deesaw/PythonD-005
/Functions/simple-timer.py
239
3.765625
4
#this is a simple timer implementation import time def measure_time(function): start_time=time.time() function() end_time=time.time() print (end_time-start_time) def loop(): for x in range(1000): print x*x measure_time(loop)
8fe2611e0792da6f47520b2c046a74f65c910384
amankirat/RuntimeAnalyzer
/Algorithms/SelectionSort.py
442
3.65625
4
def selection_sort(l): count = 0 swap_happened = True spot_marker = 0 while swap_happened: swap_happened = False for num in range(spot_marker+1,len(l)): # print('Selection sort status: ' + str(l)) count +=1 if l[spot_marker] > l[num]: l...
46cd7d43dabbffbda73627130fe756ced6c051c4
ortizadrian23/Conversions
/webapp.py
1,375
3.578125
4
from flask import Flask, url_for, render_template, request app = Flask(__name__) #__name__ = "__main__" if this is the file that was run. Otherwise, it is the name of the file (ex. webapp) @app.route("/") def render_main(): return render_template('home.html') @app.route("/response") def render_response(): B...
24757eda09b9656b9dde69ad19d06c662bc3beb0
caterinalorente/mooc
/coursera/crafting-quality-code/week3/linearSearchUnitTest.py
2,223
4.0625
4
import unittest import linearSearch class TestLinearSearch_ForLoop(unittest.TestCase): def test_value_at_the_beginning(self): "The value to be searched is at the beginning of the list" #given L = [2, 3, 5, 3] value = 2 expected = 0 # when val...
791a3561e06d61102e5d786c04353f3f38f254ca
caterinalorente/mooc
/hacker_rank/search/sherlock_and_array_tests.py
1,277
3.515625
4
import unittest from mooc.hacker_rank.search.sherlock_and_array import sherlock_and_array_elegant, sherlock_and_array_brute_force class MyTest(unittest.TestCase): def test(self): self.assertEqual(sherlock_and_array_brute_force("1\n1\n1"), "YES") self.assertEqual(sherlock_and_array_brute_force("1\n...
3264d864d7cfa3e600d0d3f534208b9bee90d9b4
caterinalorente/mooc
/coursera/learn-to-program/a3.py
6,482
4.1875
4
''' http://spark-public.s3.amazonaws.com/programming1/a3/a3.html A3 Problem Domain: Word Search Game For A3, you will implement a word search game. The game involves an rectangular board of uppercase letters that is read from a file. For example, here are the file contents representing a (tiny) 2 row by 4 column boa...
a7ffe669be5aac4232f5a6c8d564db68bafd3d16
dubesar/ParkingLot
/main.py
3,844
3.6875
4
class ParkingLot: def __init__(self,n): self.n = n self.occupied_no = 0 self.__slots = {} #For maintaining the slots along with color and regestration number (private dictionary) self.__colors = {} #For maintaing the colors for every regestration number (priva...
144881f3606cb2a390974afe3a9278f58f6bbc2f
vipin-s0106/DataStructureAndAlgorithm
/SortingAlgorithm/InsertionSort.py
328
4.03125
4
#O(n^2) complexity def insertion_sort(arr): length = len(arr) for i in range(1,length): temp = arr[i] j = i -1 while (j >= 0 and arr[j] > temp): arr[j+1] = arr[j] j -= 1 arr[j+1] = temp print(arr) return arr print(insertion_sort([2,1,3,4,5,6,7...
e8ebc9a34d9f96c944b1973bb91474278b87a99a
vipin-s0106/DataStructureAndAlgorithm
/Tree/BinarySearchTree.py
2,104
3.984375
4
class Node: def __init__(self,data): self.data = data self.left = None self.right = None class BST: def __init__(self): self.root = None def insert(self,data): if self.root == None: new_node = Node(data) self.root = new_node retu...
f6e13f9d47f8524f63c175d086f49de917c678d4
vipin-s0106/DataStructureAndAlgorithm
/Linkedlist/reverse_linked_list.py
1,465
4.125
4
class Node: def __init__(self, data): self.data = data self.next = None class Linkedlist: def __init__(self): self.head = None def add(self, data): new_node = Node(data) if self.head is None: self.head = new_node else: temp = self.h...
19a4c52fb041971268f9732d3505c303c29f1649
vipin-s0106/DataStructureAndAlgorithm
/Queue1/CircularQueueUsingArray.py
1,773
3.953125
4
#circular Queue using Array class CircularQueue: def __init__(self,size): self.front = -1 self.rear = -1 self.size = size self.list1 = [None]*size def enque(self,data): if (self.rear+1 % self.size == self.front): print("Queue is Full") return ...
4b3f0bfa0eb3e5cf8e94471c775a63d11938330f
vipin-s0106/DataStructureAndAlgorithm
/Tree/CountLeafNode.py
1,021
3.9375
4
class Node: def __init__(self,data): self.data = data self.left = None self.right = None class Tree: def __init__(self): self.root = None def inorder_traversal(self,root): if root == None: return self.inorder_traversal(root.left) print(r...
f4087a23da66467531dad5854f7f316e7ae55bc6
vipin-s0106/DataStructureAndAlgorithm
/Tree/CheckTwoBinaryTreeSame.py
1,350
3.921875
4
class Node: def __init__(self,data): self.data = data self.left = None self.right = None class Tree: def __init__(self): self.root = None def inorder_traversal(self,root): if root == None: return self.inorder_traversal(root.left) print(r...
7e2cdc1c7e4e4acf279a429bfb6d9e34952466a3
Shaurya0802/C97
/tuple.py
121
4.03125
4
tuple1 = ("Maths", "Science", "English", "Hindi", "Social Science") print(tuple1[1:3]) for tup in tuple1: print(tup)
18fe807129a2065c513de0cac5ec4021eaba50bf
rodrez/LearningPython
/LP PT2/escape_sequence.py
517
3.890625
4
# We use the backslash to display a single quote print('I can\'t stop 🎶🎵') # In this case we use \t to add a tab at the beggining of the string print('\t And it was in that moment he realized...') # Now we use the escape character to add double quotes print("The comedian said \"The problem with kleptomaniacs is tha...
5786122201c21dc3642ada5bd5cccaa1c3fd6a93
firstprateek/leetcode
/rotate.py
793
3.734375
4
class Solution: def rotate(self, matrix): """ :type matrix: List[List[int]] :rtype: void Do not return anything, modify matrix in-place instead. """ if not matrix: return n = len(matrix) if n < 2: return if n == 2: matrix[0][0], ma...
57c36175b65edf59028e8884ff15c3fe8e9b09cd
firstprateek/leetcode
/LRU.py
1,085
3.578125
4
class Node: def __init__(self, key, val): self.key = key self.val = val self.prev = None self.next = None class LRUcache: def __init__(self, capacity): self.capacity = capacity self.storage = {} self.head = Node(0, 0) self.tail = Node(0, 0) self.head.next = self.tail self.ta...
9f7b0dacd39eb9937a7d7416d82a9d6164ba9258
scoyne2/skillbuilding
/python/practice_scripts/generator_test.py
1,507
3.828125
4
def is_palindrome(num): # Skip single-digit inputs if num // 10 == 0: return False temp = num reversed_num = 0 while temp != 0: reversed_num = (reversed_num * 10) + (temp % 10) temp = temp // 10 if num == reversed_num: return True else: return False...
f3ff7e4c8f8bafa9f6ea2920100bfe7fc9e7b664
Parkyunhwan/Programmers
/Level_1/문자열내림차순으로배치하기.py
798
3.75
4
## 반대로 sorting하는 함수가 있다는 것은 알았지만 기억이나지않아 버블소팅으로 풀었다. ## 버블소팅은 소팅할 수록 범위가 주는 것이 특징이다. def solution(s): s = list(s) for i in range(len(s)): for j in range(len(s)-i-1): if s[j] < s[j+1]: temp = s[j+1] s[j+1] = s[j] s[j] = temp print(s) re...
837b10c6e8ff62db48dce643f93fc7d2df792b76
Parkyunhwan/Programmers
/Level_1/행렬의덧셈.py
482
3.78125
4
# 어떤 풀이나 핵심은 바로 answer에 넣기 전에 서브 리스트를 어떻게 구성할 것이냐가 문제였다. # zip() 내장함수를 써도 좋고 미리 서브 리스트를 구성해서 append()해도 된다. def solution(arr1, arr2): print(len(arr1)) answer = [] for i in range(len(arr1)): content = [] answer.append(content) for j in range(len(arr1[i])): answer[i].appen...
5802f2ae51092f9488c510d1886c12af3ad14663
Evans-colon/python_programming
/JustThinkering/iteration_collect_valid_score.py
750
3.9375
4
total_score = 0 counter = 0 print("Welcome to result portal") print("===========================================") print("kindly enter a valid score between 1 and 100") print("please, feel free to exit by entering '999'") score = int(input("please, enter a valid score between 1 and 100: ")) while True: if score > 0...
e890ecdc401cf00aadba54cc8f1c767fbc775d7a
adviksinghania/shamir-secret-sharing
/shamir_secret_galois.py
6,583
3.609375
4
#!/usr/bin/env python3 # shamir_secret_galois.py # Author: Advik Singhania """Implementing Shamir's Secret Sharing algorithm in Python3 with Galois Field.""" import random class ShamirSecret: """ Encode and share a secret based on Shamir's Secret Sharing algorithm. Attributes ---------- secret: ...
8f6a29f620c8180fdea9052249115abcb1e74142
larryokubasu5460/Algorithms
/brute force/Graph DFS.py
1,102
3.890625
4
# creating a graph using adjacency lists # use a dictionary to represet it # print(graph) # using the iterative method def dfs_iterative(graph,source): if source is None or source not in graph: return "invalid input" path=[] stack=[source] while len(stack)!= 0: s=stack.pop() i...
fb6bfed8bfd9b9c035acef1b176e645f08ebf32b
larryokubasu5460/Algorithms
/Quick sort.py
929
3.859375
4
# based on the divide and conquer technique # start with the partitions and choose the first element as the pivot and increment to the next element to scan def partition(array,start,end): pivot=array[start] low=start+1 high=end # loop and swap values while True: while low<=high and array[...
abfa53fba7dcec8f2720994e6d44b1efb02002a9
LiyangTseng/stonecampus_pythonlab
/4_dict/dict_1.py
466
3.59375
4
ages = {} def prAges(name): if ages.get(name): print(name, ages.get(name)) else: print("N/A") def test(): num = int(input()) for i in range(0, num): line = input() tokens = line.strip().split() name = tokens[0] age = int(tokens[1]) ages[name] = ...
8ab31fb515174598de421baf2bbae20bd043fc1d
Vitamin-111/py-web-hack
/Python/interquartile.py
507
3.578125
4
def median(list): if len(list)%2 == 0: median = (list[(len(list)//2)]+list[(len(list)//2-1)])/2 else: median = list[(len(list)//2)] return(median) N = int(input()) X = list(map(int, input().strip().split(' '))) F = list(map(int, input().strip().split(' '))) S=[] for i in range(le...
2e69cdd8c2b9e064ed797f37c20d55abada362aa
ScottValle/WIP-Game
/Functions.py
684
3.53125
4
import sys import time def title_screen(): print(" Welcome to the game ") print("___________________________") choice = input("> ").lower().replace(" ", "") if choice == "start": start_game() elif choice == "help": help_menu() elif choice == "quit": p...
331df9b8e43ea5aeb93db7a1cc1aa3d4b4e88b39
jonathan1929-cmis/jonathan1929-cmis-cs2
/WHILE.py
589
3.8125
4
def count(x): while x > 0: print x x -= 1 while x < 0: print x x += 1 #count(-10) def countfrom(x, y): if x <= y: while x <= y: print x x += 1 elif x >= y: while x >= y: print x x -= 1 #countfrom(0, 9) #countfrom(10, 0) def oddodds(x, stack): if x <= 0: while x <= 0: if not x %...
fd879e688bc00a100698b5f53fcf5731c22ebcd4
AlanAloha/Learning_MCB185
/Programs/completed/at_seq_done.py
694
4.1875
4
#!/usr/bin/env python3 import random #random.seed(1) # comment-out this line to change sequence each time # Write a program that stores random DNA sequence in a string # The sequence should be 30 nt long # On average, the sequence should be 60% AT # Calculate the actual AT fraction while generating the sequence # Rep...
5b3fc259f16f57d97e950677a0dc5d1586ac5544
opcecco/AOC2017
/day06/day06part2.py
767
3.59375
4
#!/usr/bin/env python """ Advent of Code 2017: Day 6 Part 2 https://adventofcode.com/2017/day/6 """ import sys # Function to redistribute memory def redistribute(state): value = max(state) index = state.index(value) state[index] = 0 for i in xrange(index + 1, index + value + 1): state[i % len(state)] += 1 ...
901cc9cc231441db417e2180a7d2c3b9bf38670a
opcecco/AOC2017
/day10/day10part1.py
1,126
3.90625
4
#!/usr/bin/env python """ Advent of Code 2017: Day 10 Part 1 https://adventofcode.com/2017/day/10 """ import sys # Return a sublist from our circular list def get_circular_sublist(start, length): global circular_list sublist = [] for i in xrange(start, start + length): sublist.append(circular_list[i % len(circu...
1ac490039902a23e7c985a8842094a544d773381
opcecco/AOC2017
/day11/day11part2.py
1,394
3.625
4
#!/usr/bin/env python """ Advent of Code 2017: Day 11 Part 2 https://adventofcode.com/2017/day/11 """ import sys # Use a dictionary to store how movement steps reduce reduce_dict = { ('n', 's',): None, ('ne', 'sw',): None, ('se', 'nw',): None, ('ne', 'nw',): 'n', ('n', 'se',): 'ne', ('ne', 's',): 'se', ('se',...
76d4f66688c8bf78560167c28eb3feec55da8228
om-mahato/python_weather_check
/weather_check.py
2,247
3.828125
4
from urllib.request import urlopen #import urlopen from request module import json #import json module print('-'*50) print('Please Enter your city:\n') city = str(input()) #asks for city name #url to request for weather imformation from yahoo weather api. City name is concatenated in the url url = 'https:...
b94ec62a255d55a3bf8b1fcfb404385eaaf55c1a
alecbrick/Course2Graders
/grader.py
852
3.546875
4
import sys def main(correct, student): answers, resp = map(lambda x: open(x).read().rstrip().split('\n'), [correct, student]) penalty = 1.0 / len(answers) score = 1.0 num = 0 if len(answers) != len(resp): score = 0.0 feedback = "Incorrect number of answers." else: f...
b421fa6e3c25abb6e9b2c439ccbb8f82b759fc74
gardnerm4128/CTI110-repository
/M3T1.py
701
3.90625
4
# CTI-110 # M3T1 - Area of Triangle # Gardner # 09/13/2017 #calc first Triangle firstWidth = int(input('width of first?')) firstLength = int(input('length of first?')) secondWidth = int(input('width of second?')) secondLength = int(input('length of second?')) #calc area firstArea = firstWidth * firstLengt...
1eaae0114d7ca723612676dc35d398836978c29f
gardnerm4128/CTI110-repository
/M4T2_Gardner.py
577
3.921875
4
#Ask usr for string tag = input("Type Tag: ") #Tags #if one of tags, print what tag it is, give exmpl of use if tag == "p": print("p is paragraph tag") print("example: <p>paragraph<p>") elif tag == "h1": print("h1 is header tag") print("example: <h1>First Header<h1>") elif tag == "b": pri...
f7ca18b3210101e0027f6cd183f73394aca8c5e2
eyucherin/Hangman-Geo-
/hangmanGame.py
2,853
3.765625
4
from getword import wordList def pictures(num): stages=[ """ ------ | | | | | | - """, """ ------ | | | o | | | - """, """ ------ | | | o | | | | | - """, """ ------ | | ...
a38142d960e2529cd5583aa895142ebd12d2edca
IratePirates/AoC2020
/advent5.py
1,139
3.5625
4
def parse_input(in_f): f = open(in_f, 'r') for x in f: yield x.strip() f.close() def interpret_code(code, maximum, higher, lower): s = 0 r = maximum for c in code: r = (r + 1) // 2 if c is higher: s += r return s def parse_column(code): return inter...
5eae65c8171ba97b5b4d4d2163acc9078eb5fdbc
PavlovIS/plabs
/lab1/HW3.py
319
3.6875
4
arr = list() for a in input().split(','): arr.append(int(a)) if len(arr) > 8: print('Значений больше 8!') exit() elif len(arr) < 8: print('Значений меньше 8!') exit() a = (arr[3]-arr[1])/(arr[2]-arr[0]) b = (arr[7]-arr[5])/(arr[6]-arr[4]) if a == b: print('YES') else: print('NO')
21bb0f0a3b8e859b77e788314c7ac680b93d5bd9
Subangani/TSA-with-SelfTraining
/src/writingStyle.py
693
3.5625
4
from __future__ import division def uppercasedWordsInTweet(tweet): words=["I","A"] count=0 if(len(tweet) != 0): for w in tweet.split(): if w.isupper(): if w not in words: count =count+1; return count def exclamationCount(tweet): ...
57aa92e507775b57f276deeafdc436083b22b30b
kamakuni/language_processing
/01/09.py
474
3.53125
4
import random sentence ="I couldn't believe that I could actually understand what I was reading : the phenomenal power of the human mind ." words = sentence.split() result = [] for word in words: if len(word) <= 4: pass else: head = word[0] mid_chars = list(word[1:len(word)-1]) ...
f9ffce504105688a96fdda7398128b19ec1eba69
liuyang1/test
/lang/python/codewars/hamming1.py
559
3.859375
4
def isfactorl(n, lst): """ >>> isfactorl(10, [2,5]) True """ def factor(n, f): if n == 0: return 0 while n % f == 0: n //= f return n for f in lst: n = factor(n, f) return n == 1 def hamming(n): """ >>> hamming(1) 1 >>>...
de76ff3a33eecc3871bbb6f21ed95bd0c68e5312
liuyang1/test
/lang/python/issue/2to3/dict.py
72
3.640625
4
a = {} a["A"] = 'a' a["B"] = 'b' for i in a.iteritems(): print(i)
e03f1fb743697365f6eb3c4fc5c463d2daf72c35
liuyang1/test
/course/algs4/05_kdtree/kdtree.py
1,142
3.78125
4
""" Ref: https://en.wikipedia.org/wiki/K-d_tree """ from collections import namedtuple from operator import itemgetter from pprint import pformat class Node(namedtuple('Node', 'location left_child right_child')): def __repr__(self): return pformat(tuple(self)) def kdtree(point_list, depth=0): try: ...
1d93915e737224b111597ada58ece5ba299d0c52
liuyang1/test
/codeforces/problemset/653/653B.py
777
3.796875
4
#! /usr/bin/env python3 def applyRule(rule, s): a, b = rule[0], rule[1] if a == s[0]: return b + s[1:] return None def applyRules(rules, ss): ret = [applyRule(r, s) for r in rules for s in ss] return [i for i in ret if i is not None] def search(rules, m): """ search from 'a', ext...
1e33a028f6765d8d0aacf75eaade79e557e12bfa
PeeranachSripayungchan/myFirstPythonHW
/Oilprice0.py
2,197
3.71875
4
import time while True: a = input("Select L to Baht or Baht to L (L to Baht is 1 and Baht to L is 2)") if a == '1': y = input(("Select operations form 1-6 : ")) x = float(input("Enter the amount of L : ")) if y == '1': print("Gasoline 95") z = x*29.16 ...
6b0d75a084d4e81a684eef94acc67c6dc65145b7
KevinWMatthews/python-lists
/index_integer.py
329
4.09375
4
# [] is Python's index operator # The key can be an integer or a slice! # Retrieve a single item the_list = [0, 1, 2] result = the_list[1] # Update a single item the_list = [0, 1, 2] the_list[1] = 42 # [] with an integer key can only update elements that already exist the_list = [] # the_list[0] = 42 # Raises an In...
f60c1706160f484e9eb103b77258f3359bcea3f2
bopopescu/projects-2
/cs370/hw1/temps_berry.py
1,394
3.5
4
#!/usr/bin/env python3 # #!/usr/bin/env python3 # # August 2013 High Temps for Knoxville,TN # August 2013 High Temps for Knoxville,TN # Hwk 1 for COSC 370 (Summer Sesstion II 2016) # from numpy import arange import matplotlib.pyplot as plt xData = arange(1,32) # Ranges for x and y axes must match tData = [86,87,84,8...
13240d9ac7a02f30b8a8140b30cffe53e5a71231
bopopescu/projects-2
/cs365/hw9/comparatorFct.py
294
3.859375
4
# comparatorFct.py # Mitchell Wade # April 3, 2015 # This program compares two objects to determine # where to place them on a binary tree in tree.py def comparatorFct(key1, key2): if key1 < key2: return -1 elif key1 == key2: return 0 elif key1 > key2: return 1
4f8a4ab0d45db2220ef7f9eab9a674ee78b355a0
bopopescu/projects-2
/cs370/test/precision.py
238
3.546875
4
a = 123.456 n = 5789 print ('{:6.2f}'.format(a)) print ('n={:7d}'.format(n)) # pad with 3 spaces print ('n={:07d}'.format(n)) # pad with 3 zeros print ('{:11.3e}{:7d}'.format(a,n)) # print tuple with 2 different formats
b655c56f7d9aaa034731e628064808292fd387f7
alvi-subhan/numpy-and-matplot-1-
/assignment 2.py
856
3.515625
4
from matplotlib import pyplot as plt from collections import Counter grades = [83,95,91,87,70,0,85,82,100,67,73,77,0] decile = lambda grade: grade // 10 * 10 histogram = Counter(decile(grade) for grade in grades) #print(histogram) cluster={0:0,1:0,2:0} for key,val in histogram.items(): if key<50: cluster[...
bbe8af4a3f9a2ad574c646f119a9a15f7ddb6093
singh0021/DataScienceMasters
/closest_pair.py~
367
3.625
4
#!/usr/bin/python # Given a set of points, find closest Euclidean pair oneD_points = [4,9,21,1,200,22] def closest_1D(points): if len(point) == 1: return points[0] i = 1 closest_distance = points[len(points)-1] curr_point = points[i] for prev_point in points: if curr_point - prev_p...
cec9f9df494489d7adcd6e684ba15bf7af56daff
Ilgrim/cwmud
/cwmud/core/text.py
853
3.5
4
# -*- coding: utf-8 -*- """Text manipulation and processing.""" # Part of Clockwork MUD Server (https://github.com/whutch/cwmud) # :copyright: (c) 2008 - 2017 Will Hutcheson # :license: MIT (https://github.com/whutch/cwmud/blob/master/LICENSE.txt) # TODO: should every character after a caret be considered a code? CAR...
77b6f8cb77f9ca5043733dee95de249bb2fd0ca1
yiy1156/Regular-Expressions
/telephone_regex.py
1,449
3.671875
4
''' Note: if program does not run in Python 3, try running using Python 2 ''' import re import sys def main(): if len(sys.argv) == 1: sys.argv = [sys.argv[0], "test_dollar_phone_corpus.txt", "telephone_output.txt"] if len(sys.argv) == 3: INPUT_FILE = str(sys.argv[1]) OUTPUT_F...
67b49efe9a380fa4fa1f2f870cdcecba549eba58
AlwaysStudent/Operating_System_Task
/operating_system_task/Disk_Schedule/Disk.py
11,273
3.625
4
import random class Counter(object): count = 0 class Disk(Counter): def __init__(self, disk_number): self.disk_number = disk_number self.id = Counter.count Counter.count += 1 class DiskList(object): def __init__(self, begin=0, algorithm='SCAN', max_disk=500): ...
fefa5c676deab6c1cfcc325915949a98ac16b4b4
wangdepin/algorithm022
/Week_02/剑指offer 40-最小的k个数/剑指offer40-最小的k个数.py
1,115
3.53125
4
# 最小的k个数 # 方法一:使用堆 # 思路:我们用一个大根堆实时维护数组的前k小值。首先将前k个数插入到大根堆中,随后从第k+1个数开始遍历数组,如果当前遍历 # 的数比大根堆堆顶的值小,我们将堆顶的值弹出,将当前遍历的数插入堆顶。最后将弹出的堆顶值存入数组返回即可。注意: # Python语言中只有小根堆,因此我们要对数组中所有的数取其相反数,才能使用小根堆维护前 k 小值。 class Solution: def getLeastNumbers(self,arr: List[int],k: int) -> List[int]: if k == 0: return list() ...
8241b6ba8e8ddb44e4cef872bab429c057b54c02
lalusafuan/DPL5211Tri2110
/Lab 2.6.py
308
4.125
4
# Student ID: 1201201699 # Student Name : Lalu Muhammad Safuan Bin Maazar import math radius = float(input("Enter radius :")) volume = (4/3)*math.pi * radius**3 surface = 4 * math.pi * radius **2 print("The volume of the sphrere is : {}".format(volume)) print("The surface area of the sphrere is : {}".for...
01d632d6197fb44a76eadc59fba2ea73f48d3c70
jptheepic/Sudoku_Solver
/main.py
2,359
4.21875
4
#The goal of this project is to create a working sudoku solver #This solution will implement recustion to solve the board #This function takes in a 2D array and will print is as a sudoku board def print_board(board): for row in range(0,len(board)): for col in range(0,len(board)): #prints the boarder for ...
2ab328204bf87801984926f3f8a7af19e432db2c
rjmarshall17/graphs
/breadthFirstSearch.py
864
3.59375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import networkx as nx import matplotlib.pylab as plt graph = {'A': ['D', 'C', 'B'], 'B': 'E', 'C': ['G', 'F'], 'D': ['H'], 'E': ['I'], 'F': ['J']} # Time: O(V+E), space: O(V) def breadthFirstSearch(graph, source): array =...
eaa974351eda2bf4b009d200b75956ac7f22ae14
rjmarshall17/graphs
/depthFirstSearchRecursive.py
2,120
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from timeit import timeit import networkx as nx import matplotlib.pyplot as plt import matplotlib matplotlib.use("macosx") class Node: def __init__(self, name): self.children = [] self.name = name def addChild(self, name): self.children.a...
8559b07469cf5c588942cb9ccf96839a99d373c6
kuroroblog/atcoder216
/C.py
777
3.609375
4
# 標準入力を受け付ける。 N = int(input()) ans = [] # Nが0になるまで継続する。 while N > 0: # 現在のNの値が奇数の場合、Aの魔法を挟む。 if not N % 2 == 0: ans.append('A') N = N - 1 # Aの魔法を最後にN=0になることを考慮する。 if N == 0: break # 偶数のNに対してBの魔法を利用する。 ans.append('B') # // : 小数点以下を切り捨てるため。 # 参考 : https://www.tohoh...
2ec7f661d8c6baa02cebcc3d5d11822f91bb9b19
ValentinaServile/stupid-lists-kata
/stupid_lists_test.py
3,006
3.578125
4
import unittest from stupid_lists import * class StupidListsTest(unittest.TestCase): sut = StupidLists() def test_cannot_sort_empty_list(self): self.assertRaises(StupidListNotSortableException, self.sut.sort, []) def test_cannot_sort_list_of_one(self): self.assertRaises(StupidList...
937346c8f5337e997b15e795e7a24d08f3ce26cb
vA6corporation/calcuvampi
/Modulos10.py
2,084
3.9375
4
estV = False valor = 0 est = "" def Suma(num): global valor valor = valor+float(num) return valor def Resta(num): global valor if estV == False: valor = float(num) return valor else: valor = valor-float(num) return valor def Multi(num): global valor glo...
959f6649dcedb7c3521a54fcf325126b3a5cc4b9
Lamchungkei/Unit6-02
/yesterdays.py
830
4.3125
4
# Created by: Kay Lin # Created on: 28th-Nov-2017 # Created for: ICS3U # This program displays entering the day of the week then showing the order from enum import Enum # an enumerated type of the days of the week week = Enum('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday') # inp...
d371413b9939b06e9782646e9f70762eb32c5ec5
jaebeezy/spellchecker
/spellcheck.py
4,284
3.875
4
# hw6 # cs435 # created by jae young choi # spellchecker program ''' this program utilizes the unix command line to run: python hw_6.py linux.words (textfile with the sentence to spellcheck) ''' import re, sys d = {} # opening the text file with correct words and creating a hash table with open(sys.argv[1]) as file...
5fad1a4c35d7846acd493066931d40f1157d9d20
zwscode/leetcode
/problems/top_100_liked_problems/41-first-missing-positive.py
1,013
3.828125
4
""" Given an unsorted integer array nums, find the smallest missing positive integer. Example 1: Input: nums = [1,2,0] Output: 3 Example 2: Input: nums = [3,4,-1,1] Output: 2 Example 3: Input: nums = [7,8,9,11,12] Output: 1 Constraints: 0 <= nums.length <= 300 -231 <= nums[i] <= 231 - 1 Follow up: Could you im...
184955d8e1a46b7c22c6bb56da0545728d89a150
zwscode/leetcode
/tag/backtrack/131-palindrome-partitioning.py
1,247
4.03125
4
""" Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. A palindrome string is a string that reads the same backward as forward. Example 1: Input: s = "aab" Output: [["a","a","b"],["aa","b"]] Example 2: Input: s = "a" Output:...
6345ba09eeaf5446e3202fef5c2a8faa43591d9d
ArildH/Python-exercises
/if-loop-test.py
476
4.15625
4
#test of for loops students = {} students[001] = "Arild Heyyland"; students[002] = "Turid Hoeyland"; students[003] = "Oddrun H. Heyyland"; students[004] = "Harald Heyyland"; students[005] = "Signe Heyyland"; students[006] = "Arne Heyyland"; students[007] = "Ivar Heyyland"; def search_students(student_no): for ke...
ada55c89498501889d56f9aa759f816ef9bbbd50
lilypolonetsky/stocks-and-weather
/graphing/priceToWeather.py
955
3.59375
4
""" graph the standard deviation of the weather against the standard deviation of the avg stock price change """ import matplotlib.pyplot as plt graph = plt.figure() #get the standard deviation of the avg stock price change stocks = {} f = open("data/dji_price_changes.csv") lines = f.readlines() for line in lines...
34051b0a62bdfb4a91fc7f1723681ba4759e688c
grindvince/fourre-tout
/mystere.py
324
3.953125
4
from random import randint nombre_mystere = randint (0, 100) nombre = int(input("Quel est le nombre mystere ? ")) if nombre_mystere == nombre: print ("Bravo, vous avez trouvé le nombre mystère !") elif nombre_mystere > nombre: print ("Votre nombre est trop petit !") else: print ("Votre nombre est trop grand...
6151a31269bf23ac646bc6c76021b903da6d7732
grindvince/fourre-tout
/Hacking/bases5.py
653
3.671875
4
#!/usr/bin/env python3 # coding:utf8 import random import time import string mot_de_passe = input("Quel est le mot de passe à deviner : ") # parfois il convient d'utiliser raw_input pour éviter d'interpréter le contenu fourni def mot_aleatoire(): lettres = string.printable suiv = "" resultat = "" fo...
e914c700478c81421356c0e7181b07c7f68bea61
pratik-walawalkar/Auto-Backup
/AutoBackup.py
17,557
3.515625
4
#!/usr/bin/env python # ============================================================================= # This script is written to copy files from a source folder to destination folder # It can be used to copy large number of files from mobile or other devices # It can be further programmed to backup mobile data automa...
2d35e850a18fa374b0ba3f13d921812b1426cb4a
kingkf/myPractice
/pro.py
866
3.515625
4
n=raw_input() n=int(n) score={} result={} for i in range(0,n): s=raw_input() s=s.split(' ') if s[0] not in score: score[s[0]]=int(s[1]) elif int(s[1])>score[s[0]]: score[s[0]]=int(s[1]) #print score for key in score.keys(): minNum=0 maxNum=0 value=score[key] for val in score.values(): if val<=value: ma...
06cef5f3a3d4fb02d07db685f6df96f0be53b9d6
yanganto/NgML_Py
/machine-learning-ex2/ex2/ex2.py
4,564
4.0625
4
""" Machine Learning Online Class - Exercise 2: Logistic Regression Instructions ------------ This file contains code that helps you get started on the logistic regression exercise. You will need to complete the following functions in this exericse: sigmoid.py costFunction.py pr...
0bef60f5394d49f89fcda46fd5faf07aac66cd06
yeoyeoh/python1
/test25.py
455
3.65625
4
list1=[] list2=[] list3=[] result="" value=0 for i in range(0, 5): for k in range(0, 4): value=value+3 for j in range(1, 10): result= ("%d * %d = %d" % (value, j, value * j)) list1.append(result) list2.append(list1) list1 = [] list3.append(list2) li...