blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
7494308f276e805511840f4ca73e2ca99eca0374
7201krap/COMS30014_AI-Prolog
/AI/labs/lab5/ga-code-coev.py
17,053
3.578125
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 1 10:17:54 2020 @author: sb15704 """ import random # we use "seed", "choice", "sample", "randrange", "random", "shuffle" import statistics # from statistics we just use "mean", "stdev" # Initialise a GA Population # Fill an empty population array w...
8ed426b87fdbb9f2aa2853125f8d98b7c5eed51a
SANAJESS/python-challenge
/mainpoll.py
2,535
3.671875
4
import os import csv total_votes = 0 khan_total_votes = 0 correy_total_votes = 0 li_total_votes = 0 otooley_total_votes = 0 candidates = {} election_csv = os.path.join("Resources", "election_data.csv") # Iterate through csv to count votes per candidate with open(election_csv, "r") as csvfile: csvreader = csv.rea...
5a5aa2d6c561aeadeab43417476e48334a2282b6
PeterSchell11/Python---Beginnings
/CalculatingARunningTotal.py
470
4.09375
4
# Calculating a Running Total MAX = 4 total = 0.0 print ('this program calculates sum of ',MAX, ' numbers') for counter in range(MAX): number = int(input('enter number: ')) total = total + number print (total) days = 5 total = 0.0 print ('How many bugs have you collected on each day') for...
67fc957dcc4c58e071af231ee8b140fdfdd18685
Jisan129/Card_War
/NewDir/main.py
2,465
3.5625
4
def myfunc(a): lenght = len(a) for i in range(lenght): if i % 2 == 0: a = a[:i] + a[i].upper() + a[i + 1:] else: a = a[:i] + a[i].lower() + a[i + 1:] return a # # exercise 1 def showRes(a, b): if a % 2 == 0 and b % 2 == 0: return min(a, b) else: ...
3c97754fd53207fb0efa3508269da1bd1325f9c5
mwong33/leet-code-practice
/medium/longest_str_chain.py
1,881
3.625
4
# O(n^2) time O(n) space class Solution: def longestStrChain(self, words: List[str]) -> int: # Convert our word list to a set word_set = set() for word in words: word_set.add(word) rolling_max = 0 cache = {} for word ...
785f31621932e2e3850a9b83bab58b33337b89fb
ethan-truong/interview-prep
/Sorting/mergesort.py
670
4.125
4
#Returns a sorted arr def mergesort(arr): if len(arr) == 0 or len(arr) == 1: return arr else: mid = len(arr) // 2 left = mergesort(arr[:mid]) right = mergesort(arr[mid:]) return merge(left, right) #Merges two sorted lists into one sorted list def merge(left, right): ...
3e2e1d38394a0316214e730eac595ba7468d8d25
MarkMoretto/project-euler
/incomplete/problem_699.py
2,930
3.84375
4
""" Purpose: Project Euler problems Date created: 2020-01-26 Contributor(s): Mark M. ID: 699 Title: Triffle Numbers URI: https://projecteuler.net/problem=699 Difficulty: ? Status: Incomplete Problem: Let ฯƒ(n) be the sum of all the divisors of the positive integer n, for example: ฯƒ(10)=...
2e990380c88674f503ff04e7e8a00ccd829ef78a
leeroddy17/Movie_Recommendations
/Cleaner/FKFixer.py
2,412
3.703125
4
import argparse import csv #This file will be used differently than the other, which is used for formatting. #This is more for inter-file corrections class ForeignKeyChecker(): def __init__(self, file1, file2, PK): self.file1 = file1 self.file2 = file2 self.Keys = set() se...
7925e2c78cf933c9e65c84ab47ef1333cb40d42d
siri-palreddy/CS550-FallTerm
/CS-InClass/work2-9-26.py
124
3.96875
4
import sys name = input('Please enter a name: ') while name == name: print('Hello', name) if name == 'goodbye': break
90f6db54d1b6d39edf95f6399abd2ee55a3517d7
happylixue/large-bipartite-graph-node-influence
/gen_bipartite_graph_random.py
1,300
3.640625
4
#randomly generate a bipartite graph #the storage is edge format without any order #the outcome may have duplicated edges #sorting process (in other programs) will be able to remove edge duplications import random import struct import time n_left_nodes = 1000000 n_right_nodes = 100000 n_edges = 10000000 #m...
85bc9890ef5daa020fe96faa4434685e7eb93f91
szhongren/leetcode
/394/main.py
1,594
4.1875
4
""" Given an encoded string, return it's decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer. You may assume that the input string is always valid; No extra white spaces,...
ed7297484b7ffa138dda987465613bcd08623b26
szeitlin/coding-on-paper
/k_last.py
394
3.9375
4
def k_last(sll, k): ''' singly-linked list -> element at index k find the k-th to last element of a singly-linked list. >k_last([1,2,3,4,k,last]) k ''' #have to start at the beginning #think this uses pop to remove each of the elements? #pop is by index, remove is by element ...
55e38dd1a5c74ad3a7d0c04f2705b2752d1a3c2e
EkaterinaArseneva/hometask_5
/task_5_3.py
978
4.0625
4
"""ะกะพะทะดะฐั‚ัŒ ั‚ะตะบัั‚ะพะฒั‹ะน ั„ะฐะนะป (ะฝะต ะฟั€ะพะณั€ะฐะผะผะฝะพ), ะฟะพัั‚ั€ะพั‡ะฝะพ ะทะฐะฟะธัะฐั‚ัŒ ั„ะฐะผะธะปะธะธ ัะพั‚ั€ัƒะดะฝะธะบะพะฒ ะธ ะฒะตะปะธั‡ะธะฝัƒ ะธั… ะพะบะปะฐะดะพะฒ (ะฝะต ะผะตะฝะตะต 10 ัั‚ั€ะพะบ). ะžะฟั€ะตะดะตะปะธั‚ัŒ, ะบั‚ะพ ะธะท ัะพั‚ั€ัƒะดะฝะธะบะพะฒ ะธะผะตะตั‚ ะพะบะปะฐะด ะผะตะฝะตะต 20 ั‚ั‹ั., ะฒั‹ะฒะตัั‚ะธ ั„ะฐะผะธะปะธะธ ัั‚ะธั… ัะพั‚ั€ัƒะดะฝะธะบะพะฒ. ะ’ั‹ะฟะพะปะฝะธั‚ัŒ ะฟะพะดัั‡ะตั‚ ัั€ะตะดะฝะตะน ะฒะตะปะธั‡ะธะฝั‹ ะดะพั…ะพะดะฐ ัะพั‚ั€ัƒะดะฝะธะบะพะฒ. ะŸั€ะธะผะตั€ ั„ะฐะนะปะฐ: ะ˜ะฒะฐะฝะพะฒ 23543.12 ะŸะตั‚ั€ะพะฒ 13749.32 ""...
97db12fd0768aedae3e54d8438298b50b205bce2
ipratikk/CollegeProject
/4th Sem/SW/code.py
615
3.828125
4
material=dict() def add2list(): print("Material Name :"); m=input() print("Quantity : ") q=int(input()) print("Rate : ") r=float(input()) if m in material: ar=material[m] if ar[1]==r: ar[0]+=q else: print("Cannot add different rates for same pr...
54c1e4eae52d5b47d9c8248448da4a2b12eb201c
anipmehta/InterviewCake
/arrays_and_strings/reverse_words.py
694
3.765625
4
def reverse_words(message): reverse_characters(message, 0, len(message) - 1) start_index = 0 for i in xrange(len(message) + 1): if i == len(message) or message[i] == ' ': reverse_characters(message, start_index, i - 1) start_index = i + 1 def reverse_characters(message, lef...
25f2c72e0e8da20223de2552e68e96f5b865fa9a
flame4ost/Python-projects
/ยง3(61-76)/z73.py
187
3.640625
4
k = int(input("Enter k: ")) l = int(input("Enter l: ")) if k != l: if k > l: l = k else: k = l else: k = 0 l = 0 print("k = " + str(k) + " l = " + str(l))
c4682e83811ad7bca62d8d03fc86a7f94af6d0e0
sherwin090497/PYTHON
/Basics/ex6-operationsBitwise.py
612
4.40625
4
# Bitwise operators in Python. This file also makes extended use of formatted # strings and Python 3's support for f-strings. This program uses variables # entered in as hexidecimal numbers and outputs at least 8 columns. It # includes leading zeros # enter our data in hex format first = 0xAA second = 0xBB # displ...
b8fb4811280f260b117e9ffbf5bc325f4b70a751
hantswilliams/Raspberrypi_Sensor_Scripts
/sensor_led2.py
1,034
3.9375
4
#NOTE - for this we are utilizing PI GPIO - GND along with GPIO #18 #ALONG WITH A 300 OHM RESISTOR import RPi.GPIO as GPIO ## Import GPIO library import time ## Import 'time' library. Allows us to use 'sleep' GPIO.setmode(GPIO.BCM) ## Use board pin numbering GPIO.setup(18, GPIO.OUT) ## Setup GPIO Pin 18 to OUT ##D...
2b09c81837c1c217501d91c2831411f63b6c3061
s4mto/Class5-Python-Module-Week5
/question_4.py
248
3.6875
4
class Employee: new_id = 1 def __init__(self): self.id = Employee.new_id Employee.new_id += 1 def say_id(self): return f"My id is {self.id}" e1 = Employee() e2 = Employee() print(e1.say_id()) print(e2.say_id())
ab9fc424b25395fe97bd9b2c3943dcef9ea53c99
chookie/pluralsight-coursework
/Python/python-getting-started/mycode/students.py
1,200
3.96875
4
students = []; def get_students_titlecase(): students_titlecase = []; for student in students: students_titlecase.append(student["name"].title()) return students_titlecase; def print_students_titlecase(): students_titlecase = get_students_titlecase() print(students_titlecase) def add_s...
5c500d19413fbd8c914413678a0be339cd78a6da
jiiFerr/exercism-python
/anagram/anagram.py
164
3.703125
4
def find_anagrams(word: str, candidates: list[str]): return [i for i in candidates if sorted(word.lower()) == sorted(i.lower()) and word.lower() != i.lower()]
cb365b746e12f27435e8b5002102e05b6d639946
erxclau/software-development
/spring/09_mongo/app.py
2,361
3.625
4
# Eric "Morty" Lau and Raymond Lee # SoftDev pd1 # K09 -- Yummy Mongo Py # 2020-02-28 from pymongo import MongoClient from bson.json_util import loads from pprint import pprint client = MongoClient('localhost', 27017) db = client.test_database restaurants = db.restaurants restaurants.drop() def insert_data(file): ...
0682062468ec4ad572df7bfee6fe72242d404318
Akshith-coder/Python-String-Exercises
/main.py
103
3.625
4
s = "apple" def Length(s): a = 0 for i in s: a += 1 return a print(Length(s))
a677dbeb38e95d64c01bdca8b48ec2139b103cdc
ibs13/My-Code
/python/442. Find All Duplicates in an Array.py
206
3.5625
4
nums = [4,3,2,7,8,2,3,1] result = [] len1 = len(nums) nums.sort() for x in range(0,len1-1): if nums[x]==nums[x+1]: result.append(nums[x]) x+=1 print(result)
ab7b6e07c560964119ad6e260a824a996e2d32fd
Gonzapepe/tkinter
/tilabu.py
388
3.75
4
import tkinter as tk from tkinter import ttk win = tk.Tk() win.title("Python GUI") win.resizable(0, 0) oracion = ttk.Label(win, text='A Label.') oracion.grid(column=0, row=0) def clicker(): action.configure(text='** fui clickeado.') oracion.configure(foreground='red') action = ttk.Button(win, text='clicke...
f524801a0694445543a07b41766a8f073da0771b
Metaphysics0/Codewars-Python-
/6kyu/build_tower.py
390
3.78125
4
# n integer determines the rows # # [ # ' * ', # ' *** ', # '*****' # ] # 1 row = 1 on the bottom # 2 rows = 3 on the bottom # 3 rows = 5 on the bottom # 4 rows = 7 on the bottom # 5 rows = 9 on the bottom # 6 rows = 11 on the bottom # 7 rows = 13 on the bottom def tower_builder(n): return [("*" * (i*2-1)...
c9c7a45e606ac6deb108969d58b4af0ff216fe69
Ricpalo/Resolving-Python-Problems
/27.py
251
4.53125
5
# Write a program to check if a number is positive, negative or 0 number = float(input('Enter a number: ')) if number > 0: print('The number is positive') elif number < 0: print('The number is negative') else: print('The number is zero')
bdac1d5c81910637f9c5b94964a66abcc9cb7cda
mustangman578/DSP2019F
/homework/Python_Programming/Problem1.py
589
3.890625
4
#! \usr\bin\env 'python' my_string = 'Python is the best language for String manipulation!' print("This is Python version 3.5.2 \n\n") print(my_string + '\n\n') print(my_string[::-1] + '\n\n') print(my_string[::-2] + '\n\n') print(my_string[:1].lower() + my_string[1:32].upper() + my_string[32].lower() +my_string[33:]....
e9f29bea690a20087adfbd08cc24e35261cb357a
dahymond/algorithms
/stack.py
385
3.609375
4
class Stack(object): def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def newPush(self, item): return self.items.append(item) def popItem(self): return self.items.pop() def peepItem(self): return self.items[len(self.items...
124a21733e91df3783ca2dcd6f979dc3343e2bc9
AnthonyKalampogias/UniversityProjects
/Python/LempeZiv77/Sender.py
3,317
3.578125
4
#################################################################### # # # Lempel-Ziv 77 Algorithm with Sliding Window # # Members # # Antonios Kalampogias P...
f6ce5a5d3a36ed673729c677bcfa877dc9b53ad4
vshypko/coding_challenges
/problems/leetcode/reverseWords151.py
454
3.59375
4
# 151 class Solution(object): def reverseWords(self, s): """ :type s: str :rtype: str """ splitted = s.split() for s in splitted: s = s.strip() if len(splitted) == 0 or s == '': return '' for i in range(len(splitted) // 2): ...
da7d3874c688ead58d4e61d59f0861ffd4c13102
khiladikk/Web_Scrapping_Using_Python
/Code_Web_Scrapping_Using_Python.py
1,079
3.5
4
#import the library used to query a wesite import urllib2 #Impoort the Beautiful soup functions to parse the data returned from the website from bs4 import BeautifulSoup #Specify the url url= "https://www.icc-cricket.com/rankings/mens/team-rankings/odi" #Query the website and return the html to variable 'page' p...
93c5f545ef1b9a117880c5adfc3daaaf8a478a41
aiwizard/test
/kb/basic/adv_filter.py
909
3.953125
4
# filter๋Š” ํŠน์ •ํ•œ f(x)์— ๋Œ€ํ•ด bloolean๊ฐ’์„ ํ•„ํ„ฐํ•˜์—ฌ ๋ฝ‘์•„๋‚ธ๋‹ค # ์Œ์ˆ˜๋ฅผ ์ œ๊ฑฐํ•˜๊ณ ์ž ํ•  ๋•Œ def print_result(datalist, title): print(f'--------- %s' %(title)) for item in datalist: print(item) print() mylist = [-3, 5, 1, 2, -5, -4, 14] print_result(mylist, '์›๋ณธ ๋ฆฌ์ŠคํŠธ') # filter ์ด์šฉ result = filter(lambda a: a>0, mylist) print_result(result, ...
8c7d1f3a3aafe0ff7e03a312b9cc4c8bfaddda06
brianhuynh2021/Python_fundamentals
/classpoint.py
233
3.796875
4
class Point: def __init__(self, x, y): self.x = x self.y = y def getX(self): return self.x def getY(self): return self.y point1 = Point(10, 10) print(Point(10, 10).getX()) print(point1.x)
0f04c8e897171c50fc7c8ab054631e0f9c71ce62
nanalevy/sca_pi
/Switch
527
3.890625
4
#!/usr/bin/env python import RPi.GPIO as GPIO import time # breadboard setup GPIO. setmode (GPIO.BOARD) GPIO. setwarnings (False) # assign pin number for Touch Switch; pin 31 = GPIO 6 touch_pin =31 # set Touch Switch pin's mode as input GPIO.setup(touch_pin,GPIO.IN) # create infinite loop that reads Touch Switch in...
c03305a875738cdafc3e753b595499ffdd7461d6
reverbdotcom/datarobot-2.25.1
/datarobot/utils/retry.py
1,031
3.671875
4
"""This module is not considered part of the public interface. As of 2.3, anything here may change or be removed without warning.""" import itertools import time def wait(timeout, delay=0.1, maxdelay=1.0): """Generate a slow loop, with exponential back-off. Parameters ---------- timeout : float or i...
4eed7f9abdeae559e241cc023f78f24feb60d46a
VishalJoshi21/Python_Program
/prg5.py
214
3.921875
4
num1=int(input("Enter number 1 :")); num2=int(input("Enter number 2 :")); num3=int(input("Enter number 3 :")); maxx=max(num1,num2,num3); minn=min(num1,num2,num3); print("Maximum :",maxx); print("Minimum :",minn);
a548ee05bdbadfbf684769fcfc0ef0f61d3024c0
chinku8431/PythonFolder
/dictionaryprogramme/demo10.py
105
3.609375
4
d1={ 101:"RaviKumar", 102:"Vishnu"} print(d1[101]) for i in d1: print(d1[i]) print(i,"\t",d1[i])
3f9dd161c74c1f9f8b9e1378c52ae2a8b5cae88f
mayank6/leetcode
/naryBFS429.py
691
3.5
4
""" # Definition for a Node. class Node(object): def __init__(self, val, children): self.val = val self.children = children """ class Solution(object): def levelOrder(self, root): """ :type root: Node :rtype: List[List[int]] """ if root is None: ...
39fc0b7746cc6e2a5faba0e13017a761e69a2f92
ZwEin27/Coding-Training
/LeetCode/python/lc347.py
459
3.59375
4
class Solution(object): def topKFrequent(self, nums, k): """ :type nums: List[int] :type k: int :rtype: List[int] """ ht = {} for num in nums: ht.setdefault(num, 0) ht[num] += 1 nums = sorted(ht.items(), key=lambda x: x[1], rev...
24fabf725eca5b90e2c5d8811ea21e96c76e7f14
hoang7276/PythonProgrammingCourseFirstYear
/S06 - Homework solution and class examples/S06FlipCoin.py
880
4.28125
4
# This program will flip a coin a number of times indicated by the user and then let the user know how many heads and tails were obtained from random import random def main(): print("This program flips a coin several times and will let you know how many tails and heads were obtained") print("Input num...
c650f02b0365f9502c5f6edf7eeb543bb73a4e7f
zenadot22/python-exercises
/sort_task1.py
321
4.125
4
def selection_sort(items): for step in range(len(items)): print(step) for location items range(step,len(items)): print(location) if items[location]<items[step]: items[location]=items[step] items[step]=item[location] print(items) x=[3,2,1,7,6,9] selection_sort(x) print(x)...
9e04d79fa5c51c6f72e30efbe7017fb7c9e74f25
liwei-yeo/100days
/Day30 Exceptions handling - Password Manager/Day30-PMExceptions.py
432
3.578125
4
try: file = open("a_file.txt") except FileNotFoundError as error_message: print("There was an error") file = open("a_file.txt", "w") file.write("Something") except KeyError as error_message: print(f"{error_message}: That key does not exist") else: content = file.read() print(content) finall...
b2924e30854cf658a9716925cb8656e2e8c13032
korbu/interview
/src/github odd number as sum of 2 primes.py
650
3.96875
4
def prime(x): if(x == 0 or x == 1) : return 0 i = 2 while i * i <= x : if (x % i == 0) : return 0 i = i + 1 return 1 def findPrime(n) : if (prime(n)): print(n, end = " ") elif (prime(n - 2)) : print ("2", end = " ") ...
18fbfde00409e1eae4c93758d6177cd46ca825f9
alexkinnear/snakeGame
/snake.py
1,699
3.515625
4
from random import randint class Snake: def __init__(self): self.width, self.height = 25, 25 self.vel = 15 self.color = (0, 255, 0) self.blocks = [Block(300, 250, 0, 0)] self.head = self.blocks[0] self.tail = self.blocks[-1] self.length = 1 def add_bloc...
50de75040f4fa52e0fec89f464d5756acd12f373
Garret-t/InClassActivityW7
/test_pal_unittest.py
940
3.90625
4
import unittest from palindrome import palindrome as pal class TestPalindrome(unittest.TestCase): #Test correct case for True def test_correct(self): self.assertEqual(pal("lol"), True) #Test correct case for False def test_correct2(self): self.assertEqual(pal("no"), False) #Test cor...
1927fec247a45aa597db1080f650d4834a58536a
tau94/PPTE
/c2/carSale.py
673
3.859375
4
# A program which adds bullshit fees to the base price of a carself. carTax = 1.15 carLicence = 1.05 dealerPrep = 125 destCharge = 50 print("_"*50) basePrice = float(input(''' Hello! I am the Car Sale 2000 Ultitron Calculator. Designed to add incredible fees for your profit! How much is the car worth? Input: $''')) ...
72f5ae7b58f213bbeecff4e8f3b30ac9d770b39b
clairebearz32bit/passpal
/passpal/passpal.py
865
3.90625
4
import os import random from string import ascii_lowercase as lower from passpal import PERMUTATIONS class PassPal: def __init__(self, pass_len, max_len=128, min_len=8): """ This class is the main object to generate a strong and secure password, along with a phrase to help remember it. ...
a3280cd755377829ff2e23919c9ae5dbd276c66f
sumitparw/leetcode_practise
/pure storage/pure-storage_computer_score.py
1,062
3.59375
4
def compute_number_score(number): number_score =0 prev =False seq_length = 1 remainder_prev = -10 if int(number%3==0): number_score +=4 while number>0: remainder = int(number%10) number = int(number/10) if remainder == 7: number_score +=5 if re...
9ebdd86ac728f5d94409ab6f1241476718902eb6
pradeepvallam/Pradeep
/Source/ICP3/web_scrapping.py
625
3.890625
4
#import necessary libraries for web scrapping import requests from bs4 import BeautifulSoup url = "https://en.wikipedia.org/wiki/Deep_learning" html = requests.get(url) #this get method requests to retrieve data from specified url webscrap = BeautifulSoup(html.content,"html.parser") #beautifulsoup is constructor whic...
16941ae6c7a36f0ce54892510aa853e0e147578a
akik22/hackerRank
/Introduction/if-else.py
237
4.0625
4
#!/usr/bin/python3 given_input = int(input()) if given_input%2: print("Weird") elif given_input>=2 and given_input<5: print("Not Weird") elif given_input >= 6 and given_input<=20: print("Weird") else: print("Not Weird")
95eda45a84bfc16f80af00058cff048d7999b4d1
rabdhir/Python
/Py15/currency_converter.py
292
3.640625
4
print('1') def currency_converter(rate, euros): dollars=euros*rate return dollars x = currency_converter(1.45, 2000000) #print('Value of {0} euros = {1} dollars '.format(euros, dollars)) #print(x) function = [currency_converter(1.62, 1000), currency_converter(1.65, 1000)] print(function)
e2b2c6f78aa2ed372762b1a7378e8faf5637ce27
satishrdd/comp-coding
/project_euler/20.py
228
3.671875
4
import math def sum_digits(n): s = 0 while n: s += n % 10 n //= 10 return s cases = int(input()) for i in range(0,cases): k = int(input()) ans = sum_digits(math.factorial(k)) print (ans)
af1ae221c9e662e1306154e00f465f59c12d8e38
namani-karthik/Python
/op_overloading.py
186
3.78125
4
class book: def __init__(self,a): self.pages=a def __add__(self,other): return self.pages+other.pages X_book=book('abc') Y_book=book('zxy') print(X_book+Y_book)
91e06faa63e632c214df802facf29bd35fcc9277
ilkunviktor/python-library-examples
/2 Built-in Functions/open.py
212
3.625
4
with open('data/open.txt', 'w') as f: f.write('You touch my ta la la\n') print('and again!', file=f) with open('data/open.txt', 'r') as f: for line in f.readlines(): print(line, end='')
20f9a920e3fe0d8331bd86ce5e2efa02f2201bee
LoTwT/clawer
/phase_1/demo4_2.py
2,159
3.609375
4
# ๅฐ่ฏดไธ‹่ฝฝๅ™จ # ่พ“ๅ…ฅๅžๅ™ฌๅฐ่ฏด็ฝ‘ๅฏนๅบ”ๅฐ่ฏด url, ไธ‹่ฝฝๅฐ่ฏด import requests from lxml import etree import os base_url = "https://www.tsxs.org" headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36", "referer": "https://www.doutub.com/" } def get_n...
c61cbcd74b9ec53255e4356fca66aa28e76da09d
jslx2/whatup
/spamandegg.py
225
3.921875
4
a = "Spam" b = "Egg" c = "Spam and Egg" d = input("What would you like to eat?") if d == a: print ("You need Egg!") elif d == b: print ("You need Spam!") elif d == c: print ("Wonderful!") else: print ("Make your mind!")
b126911adcd70fb9717e7ece2e2ce911d54d04d8
ColeTrammer/cty_2014_intro_to_computer_science
/Day 7/My Programs/Python Project/Average.py
570
3.859375
4
def average(list2): a = list2[0] for x in range(1, len(list2)): a = list2[x] + a print a/len(list2) def main(): while True: try: list2 = [] current_entry = int(raw_input("Please enter a number")) while current_entry != -99999: list2....
2d2d49cbb16065f08960b5dcd71144447219e159
zhangruochi/leetcode
/LZOF_40/Solution.py
1,422
3.78125
4
""" ่พ“ๅ…ฅๆ•ดๆ•ฐๆ•ฐ็ป„ arr ๏ผŒๆ‰พๅ‡บๅ…ถไธญๆœ€ๅฐ็š„ k ไธชๆ•ฐใ€‚ไพ‹ๅฆ‚๏ผŒ่พ“ๅ…ฅ4ใ€5ใ€1ใ€6ใ€2ใ€7ใ€3ใ€8่ฟ™8ไธชๆ•ฐๅญ—๏ผŒๅˆ™ๆœ€ๅฐ็š„4ไธชๆ•ฐๅญ—ๆ˜ฏ1ใ€2ใ€3ใ€4ใ€‚ ย  ็คบไพ‹ 1๏ผš ่พ“ๅ…ฅ๏ผšarr = [3,2,1], k = 2 ่พ“ๅ‡บ๏ผš[1,2] ๆˆ–่€… [2,1] ็คบไพ‹ 2๏ผš ่พ“ๅ…ฅ๏ผšarr = [0,1,2,1], k = 1 ่พ“ๅ‡บ๏ผš[0] ย  ้™ๅˆถ๏ผš 0 <= k <= arr.length <= 10000 0 <= arr[i]ย <= 10000 ๆฅๆบ๏ผšๅŠ›ๆ‰ฃ๏ผˆLeetCode๏ผ‰ ้“พๆŽฅ๏ผšhttps://leetcode-cn.com/problems/zui-xiao-de-kge-shu-lcof ่‘—ไฝœๆƒๅฝ’้ข†ๆ‰ฃ็ฝ‘็ปœๆ‰€ๆœ‰ใ€‚ๅ•†ไธš่ฝฌ่ฝฝ่ฏท่”...
b8c7e475a4d4be29823032bdd22910db7b164657
asabatba/mfrases
/lang_freq/es_minus_en.py
296
3.640625
4
f_es = open('es_dict.txt', 'r') f_en = open('en_dict.txt', 'r') f_out = open('es-en.txt', 'w+') es_words = f_es.readlines() en_words = f_en.readlines() for word in es_words: if word not in en_words: print(word) f_out.write(word) f_out.close() f_es.close() f_en.close()
d971479a50c55b04e22e07e3f3e4985801edd559
Pradeep-bheemavarapu/Swiss_Hackathon
/model.py
2,974
3.578125
4
# Importing the Keras libraries and packages from keras.models import Sequential from keras.layers import Conv2D from keras.layers import MaxPooling2D from keras.layers import Flatten from keras.layers import Dense # Initialising the CNN classifier = Sequential() # Step 1 - Convolution classifier.add(Conv2D(32, (3, 3...
7b23dc168f0ada73a72cd1feb26057de9702ab39
chizengkun/pytest
/base/cls1.py
365
3.515625
4
class person(): def walk(self): print('walk') @property def name(self): return self._name @name.setter def name(self, value): self._name = value @property def age(self): return 23 class student(person): #__slots__ = ('name','age') pass s = student()...
85e7653652f66f5e63a6d8d8da1bbee1ab537eb1
devedzic/becausethenight
/becausethenight/python/lists.py
5,852
4.5625
5
"""Demonstrates working with lists. """ def demonstrate_lists(): """Using just the simplest operations with lists. """ list_with_diverse_elements = ["Patti Smith", "Bruce Springsteen", 1978] # creating non-empty l. print(list_with_diverse_elements[0]) ...
57e9efb7fdd01a8fe0e8a33384da1ce7696528c1
kushal-07/DS281220-ML
/or_gate.py
1,005
3.546875
4
# -*- coding: utf-8 -*- #Initialize Learning rate, bias and weights lr = 1 bias = 1 weights = [-50, 20, 20] #Perceptron (x_1, x_2, output_A) def Perceptron(x_1, x_2, output_A): output_P = bias*weights[0] + x_1*weights[1] + x_2*weights[2] if output_P > 4: output_P = 1 else: output_P = 0 ...
1f96f4bd6cb2b4c62b3c5094ec3fb0875ad79b40
daglupinus/stage
/pyth_lekcja2.py
4,231
4
4
# PODSUMOWANIE: # ukล‚ad ifรณw: # 1) jeden z wielu (np. kanaล‚ wล‚ฤ…czony przez pilot; wybieram tam jeden z wielu) # 2) wiele z wielu (np. wybieram kilka skล‚adnikow z puli moลผliwych skล‚adnikรณw) # PEP8 - opis konwencji przyjฤ™tej w programowaniu pythonem # WNIOSEK: # Liczby zmiennoprzecinkowe sล‚uลผฤ… bardziej do szybkich ...
dd8339c3887150bb138bea20c41c1112b0b2e926
bats64mgutsi/MyPython
/Programs/get_colour.py
598
4.09375
4
# Extracts the an colour the colour of the fox in the string 'the quick brown fox jumps...' # Batandwa Mgutsi # 04/03/2020 sentence = 'The quick brown fox jumps over the lazy dog' # The one is the size of the space before the colour start = sentence.find('quick')+5+1 # The one is the size of the space after the col...
f5f1e4126c406e905a948899479f81017c2b92cb
Jwilson1172/cs-module-project-hash-tables
/applications/no_dups/no_dups.py
349
3.546875
4
def no_dups(s): d = {} for i in s.split(): d[i] = None print(d) return ' '.join(d.keys()) if __name__ == "__main__": print(no_dups("")) print(no_dups("hello")) print(no_dups("hello hello")) print(no_dups("cats dogs fish cats dogs")) print(no_dups("spam spam spam eggs spam s...
23d6d72232f0de56ef714900568d1b0daef86f9f
zjy-T/Codewars
/[7 Kyu] binary to decimal.py
311
4.09375
4
#Given an array of ones and zeroes, convert the equivalent binary value to an integer. def binary_array_to_number(arr): exp = len(arr) -1 integer = 0 for binary in arr: integer += binary * 2 ** exp exp -= 1 return integer arr = [0, 0, 0, 1] print(binary_array_to_number(arr))
06eb4f340b5f9679e3bec9cf0d2dcf6180d5b543
Cashcodex/monograms
/letterhashvalues.py
515
3.515625
4
hashvalues={"A":0, "B":1,"C":2, "D":3,"E":4, "F":5,"G":6, "H":7,"I":8,"J":9, "K":10,"L":11, "M":12,"N":13, "O":14,"P":15, "Q":16,"R":17, "S":18,"T":19, "U":20,"V":21, "W":22,"X":23, "Y":24,"Z":25} hashvalues_num=["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"] ...
0f09ead9bf137d4ba54d72e3f824d19df749265f
Zohu0/Python-Codes-For-Beginners
/07_average.py
126
3.734375
4
a= input("Enter Any No= ") a= int(a) b= input("Enter Other No= ") b= int(b) c= (a+b)/2 print("The Average OF Input= ", c)
fed30fb6e8bfd8791ce786facf712b3740cf9b8b
contea95/1Day-1Commit-AlgorithmStudy
/BOJ/Python/2750.์ˆ˜์ •๋ ฌํ•˜๊ธฐ/2750.py
581
3.546875
4
N = int(input()) sort_list = [] for i in range(N): sort_list.append(int(input())) # ์‚ฝ์ž…์ •๋ ฌ ''' for i in range(1, len(sort_list)): j = i - 1 key = sort_list[i] while sort_list[j] > key and j >= 0: sort_list[j+1] = sort_list[j] j = j-1 sort_list[j+1] = key ''' # ๊ฑฐํ’ˆ ์ •๋ ฌ for i in range(le...
dfc0ccbd27d6a648e11a616d93fa907ba9a4fcc9
bytoola/python2
/M9_error/_3.py
322
3.703125
4
try: n1, n2 = eval(input("enter two numner to divide: ")) div = n1/n2 print("%d/%d=%d"%(n1,n2,div)) except ZeroDivisionError: print("division by zero") except SyntaxError: print('comma is missing') except : print('something wrong') else: print('No exeption') finally: print('Must be done...
adb52a51b3551874e039fa85356370606347cf92
karolinanikolova/SoftUni-Software-Engineering
/2-Python-Fundamentals (Jan 2021)/Course-Exercises-and-Exams/07-Dictionaries/01_Lab/04-Odd-Occurrences.py
574
4
4
# 4. Odd Occurrences # Write a program that extracts all elements from a given sequence of words that are present in it an odd number of times (case-insensitive). # โ€ข Words are given on a single line, space separated. # โ€ข Print the result elements in lowercase, in their order of appearance. words = input().split() di...
518367c46708cb1658c00d56970425b9c4b15d78
HenryBrockman/pong-game
/pong_pvcomp.py
6,442
3.515625
4
# Imports and Initilization import pygame from math import ceil, floor import random pygame.init() # Classes class Ball: def __init__(self, win, color, ballX, ballY, radius): self.win = win self.color = color self.startPosX = ballX self.startPosY = ballY self.ballX = ballX ...
3607d21c9388ef1fb567ac9044a6746f251247f2
gitter-badger/Permuta
/tests/test_math_counting.py
821
3.5
4
import unittest from permuta.math import factorial, binomial class TestMathCounting(unittest.TestCase): def test_factorial(self): self.assertEqual(factorial(0), 1) self.assertEqual(factorial(1), 1) self.assertEqual(factorial(2), 2) self.assertEqual(factorial(3), 6) self.ass...
6b28aa690b2b78100f19df7ef477aa47df30df66
wajeshubham/Linked-list
/linked_list.py
3,102
4
4
class Node: def __init__(self, head=None, next=None): self.head = head self.next = next class LinkedList: def __init__(self): self.head = None def insert(self, data): node = Node(data, self.head) self.head = node def length(self): itr = self.head ...
f41a1881a86c49f4fad506fd40a3c0456cbfd426
ZhangShuaiyi/myTest
/python/algorithms็ฎ—ๆณ•/sorting/merge_sort.py
761
3.6875
4
from sort_base import SortBase class MergeSort(SortBase): aux = [] @classmethod def merge(cls, a, lo, mid, hi): if a[mid] <= a[mid+1]: # ๅฆ‚ๆžœๅทฒ็ปๆœ‰ๅบไบ†ๅฐฑไธ็”จๅœจ่ฟ›่กŒๆ•ฐ็ป„copy return i = lo j = mid + 1 aux = cls.aux aux[lo:hi+1] = a[lo:hi+1] # print("%...
9c0bb762f98c3ff4aab54eae07591a2efa0d0dac
gabriellaec/desoft-analise-exercicios
/backup/user_249/ch3_2019_03_14_21_19_58_250945.py
201
3.75
4
import math x=int(input('Numero: ')) ฮผ=int(input('Numero: ')) ฯƒ=int(input('Numero: ')) def calcula_gaussiana(ฯƒ,x,ฮผ): y=(1/(ฯƒ*math.sqrt(2*math.pi)))*math.exp(-0,5*((x-ฮผ)/ฯƒ)**2) return y
ad547165b056fbc7007b1b473a73c6db2e7c147b
BlueSu007/Test
/turtle_test 01.py
515
3.75
4
# ็”ปๅ‡บไบ”่ง’ๆ˜Ÿๅฅ—ไบ”่ง’ๆ˜Ÿ from turtle import* # print("่ฏท่พ“ๅ…ฅๅฑ‚ๆ•ฐ๏ผš") # a=input() pensize(5) color("gold") # ็”ปๅŸบๆœฌไบ”่ง’ๆ˜Ÿ for i in range(5): forward(50) right(144) # ๅทฆ่ฝฌ18ยฐ๏ผŒๆข้ขœ่‰ฒ๏ผŒ็”ปไบ”่พนๅฝขใ€‚ไบ”่พนๅฝขๅ†…่ง’108ยฐ left(36) color("cyan") for i in range(5): forward(30) right(72) color("purple") # ๅœจไบ”่พนๅฝข็š„ๆฏๆก่พนไธŠ็”ปๅ‡บๅค–็Žฏไธ‰่ง’ๅฝข for i in...
9668b1dec5f1b32e61a1111f33f73f9c5a27c0be
dseymo02/test_rep4
/question1/question1.py
183
3.6875
4
def swap(lst): minn = min(lst) maxx = max(lst) size = len(lst) for i in range(0,size): if lst[i] == minn: lst[i] = maxx elif lst[i] == maxx: lst[i] = minn return lst
14f22206a08c7b9c8e8af5de975b09981011e0ef
rtouze/yapong
/yapong/sprites.py
5,612
4
4
#!/usr/bin/env python """ This module cares about pong sprites (ball, rackets)""" import config import constants import pygame import random class Ball(object): """Defines ball object's behaviour.""" def __init__(self, sound_1=None, sound_2=None): self.color = constants.WHITE self.dimension = ...
79daf98c284852b11840fe96d3dfd8edd1faff55
wjr0102/Leetcode
/Easy/SubTree.py
967
3.828125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def isSubtree(self, s: TreeNode, t: TreeNode) -> bool: def isSame(a: TreeNode, b: TreeNode): ...
da368409bd4fbbd52c978e325a4e04801ad8dc86
weimingma/Kaggle_HousePrices
/house price.py
14,497
3.703125
4
#!/usr/bin/env python # coding: utf-8 # House Prices: Advanced Regression Techniques # # This project is a compeition in Kaggle with initially 79 features for the residential homes in Ames, Iowa. The goal of this challenge is to predict the final price of each home. # As usual, data exploration, feature engineering a...
b370bb0b93bdfdab1e2f32ac432f2211bbeae791
jigar-dhimar/Tetris
/shapeClass.py
7,115
4.125
4
from blockClass import* class Shape(): """ base class for all tetris shapes""" def __init__(self, coords, color): """the instance variables are: coords: a list for each of the blocks in a given tetris piece color: color of the piece""" #list to hold each of the bl...
6d67d89a865ffaefb96cbff38f05f7b9c01822e4
grebwerd/python
/practice/practice_problems/reverseWords.py
716
3.546875
4
class Solution: def reverseWords(self, s): """ :type s: str :rtype: str """ tokens = s.split() retval = "" for token in tokens: retval =retval + " " + self.reverseWord(token) return retval[1:] def rev...
95482998fa26880d1fb4af81d1c340f2595d3c8d
Ronak912/Programming_Fun
/FlattenList.py
2,386
3.671875
4
A = [2, 3, [1, 2], [5, [6, [3]], 7], 2] #sorted(flatten(A)) == sorted([2, 3, 1, 2, 5, 6, 3, 7, 2]) def FlattenListUsingIter1(temp): tmplst = [] for value in temp: if not isinstance(value, list): tmplst.append(value) else: temp.extend(value) # newtmplst = val...
7d8f99e8061f495fb1cc8c745ff6fb7aa4daca64
niksfred/SoftUni_Fundamentals
/Dictionaries_exercise/softuni_parking.py
717
3.8125
4
n = int(input()) parking = {} for _ in range(n): command = input().split() if command[0] == "register": name = command[1] vehicle = command[2] if name not in parking: parking[name] = vehicle print(f"{name} registered {parking[name]} successfully") else: ...
5c4b6ecce810bce4f5fcb65820975f5e52cc3336
Mourad-NOUAILI/Hackerrank
/practice/algorithms/2-implementation/utopian-tree/utopian-tree.py
71
3.5
4
for _ in range(input()): n=input() print pow(2,(n+1)/2+1)-1-(n%2)
c56b01a2f227f683ad65c93904efbede164e436b
lusan/Seismic-activity-monitor--SAM-
/matplotlib/stackplot.py
1,837
3.515625
4
""" Stacked area plot for 1D arrays inspired by Douglas Y'barbo's stackoverflow answer: http://stackoverflow.com/questions/2225995/how-can-i-create-stacked-line-graph-with-matplotlib (http://stackoverflow.com/users/66549/doug) """ import numpy as np __all__ = ['stackplot'] def stackplot(axes, x, *args, **kwargs): ...
dac0769c6287377292d0fc65d13bb666dd110eea
JohnMorrisonn/DS-Unit-3-Sprint-1-Software-Engineering
/SC/acme.py
1,871
3.703125
4
''' ACME Products ''' import random class Product: '''Models an ACME product. Parameters ----------------------------- name : str price : int weight : int flammability : float identifier : int ''' def __init__(self, name=None, price=10, weight=20, flammability=0.5, ...
8b4b5a92fd2f6432573d90d5fc34a7bf8757b3d1
nilsding/youreasquidnow
/python/python.py
132
3.8125
4
#!/usr/bin/env python import itertools for prefix in itertools.cycle(['squ', 'k']): print("You're a {}id now!".format(prefix))
c71143624a83b0ef080ad4c16ebdc09c51382850
Robert12354z/Class-Labs
/PROGRAMMING PARADIGMS/More Functional Programming/homework06_part01.py
4,069
3.9375
4
#Roberto Reyes #CIN:305807806 #Course: CS-3035-01 # Part 01 (1 point): For this problem you will generate lists of prime numbers # given different sets of criteria. # # Create a callable object by implementing a class named CustomPrimes, the skeleton # of which is given below. In order to create a callable ob...
7ff3fb6707c9bda8b3c1204a9670e03ea5e681e4
zNIKK/Exercicios-Python
/Python_1/FATORIAL.py
158
3.71875
4
def fat(num=1): f=1 for c in range(num,0, -1): f*=c return f f1=fat(4) f2=fat(6) f3=fat(2) print(f'Os resultados sรฃo {f1}, {f2} e {f3}')
650b5c96f6a6a4681b6b22efe93bc88f9e247963
brunomendesdecarvalho/utils
/utils/bm_strings.py
456
3.859375
4
def is_letter(string): if 65 <= ord(string) <= 90 or 97 <= ord(string) <= 122: return True else: return False def is_upper(string): if 65 <= ord(string) <= 90: return True else: return False def is_lower(string): if 97 <= ord(string) <= 122: return True ...
a6bc1a75f41c7ecf6d0456d6fc7fc6072a686938
pinheirogus/Curso-Python-Udemy
/CSV/aula133.py
839
3.609375
4
import csv with open('clientes.csv', 'r') as arquivo: # dados = csv.reader(arquivo) # # #next(dados) # for dado in dados: # print(dado) # dados = csv.DictReader(arquivo) # # for dado in dados: # print(dado['Nome'], dado['Sobrenome'], dado['E-mail'], dado['Telefone']) #...
564993837f6c08dc12c126968970e4ee67c8a068
scottwedge/40_python_projects
/RegisterToVote_Conditionals_Challenge_3.py
1,847
4.40625
4
#!/usr/bin/env python3 # A Register To Vote application that simulates a user registering to vote # Get user name # Get user age # Check user age # Give list of parties that one can join # Get party (case insensitive) to join from user # State user has been registered to that party # State whether it is a major part...
8ff46d40d1853020c9b261080a2fb5a575d7f79c
compilepeace/CTF_SOLUTIONS
/OverTheWire/BANDIT/ROT13_decoder.py
1,323
3.875
4
# Abhinav Thakur # compilepeace@gmail.com # # ROT13_decoder.py - This script is built for bandit11 level. This script rotates all the upper case # as well as lower case letters by 13 places. # We will test the example : Gur cnffjbeq vf 5Gr8L4qetPEsPk8htqjhRK8XSP6x2RHh # string = r...
a229ef04b62a2123be0defb6a83f510d37162bfe
emehbak/python
/p1.5game.py
737
3.875
4
#in this game, software takes a random number and you guess a number between 1,99 to get the correct answer def game(): import random javab=random.randint(1,99) name=input('Good:) , what is your name? ') print('OK ',name,' lets start...') hads=int(input('eneter a number between 1 and 99: ')) wh...
5244c8ec498583767883043917988b571a5cda40
meikefrdrchs/MyExercises
/assignment_2018_05_29.py
289
3.828125
4
random_animals = "cats dogs horses mice turtles lions bears cats meerkats dogs alpacas dogs cats horses dogs turtles cats dogs spiders bees dogs".split("cats") print("These are some of the best animals:") for animals_that_arent_cats in random_animals: print(animals_that_arent_cats)
53f9fb479f99082e3abd6d03942b7cdccc06816b
gayu-ramesh/IBMLabs
/factorial.py
221
4.28125
4
num=int(input("enter a number")) fact=1 if num==0: print("factorial does not exist") elif num<0: print("enter number greater than 0") else: for i in range(1,num+1): fact =fact* i print(fact)