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
31054b203952df25b1f6987652c89f3c9502fe76
chenxu0602/LeetCode
/1034.coloring-a-border.py
2,792
3.875
4
# # @lc app=leetcode id=1034 lang=python3 # # [1034] Coloring A Border # # https://leetcode.com/problems/coloring-a-border/description/ # # algorithms # Medium (44.65%) # Likes: 142 # Dislikes: 280 # Total Accepted: 11.3K # Total Submissions: 25.2K # Testcase Example: '[[1,1],[1,2]]\n0\n0\n3' # # Given a 2-dimen...
3d7a4330fab53daa9a035fc989f5b80636b45118
chenxu0602/LeetCode
/445.add-two-numbers-ii.py
1,543
3.875
4
# # @lc app=leetcode id=445 lang=python3 # # [445] Add Two Numbers II # # https://leetcode.com/problems/add-two-numbers-ii/description/ # # algorithms # Medium (50.42%) # Likes: 764 # Dislikes: 101 # Total Accepted: 95.1K # Total Submissions: 188.6K # Testcase Example: '[7,2,4,3]\n[5,6,4]' # # You are given two ...
aead98ecd14d9b495c2dbc52a59e86235b6e67d3
chenxu0602/LeetCode
/473.matchsticks-to-square.py
5,972
3.703125
4
# # @lc app=leetcode id=473 lang=python3 # # [473] Matchsticks to Square # # https://leetcode.com/problems/matchsticks-to-square/description/ # # algorithms # Medium (37.59%) # Likes: 596 # Dislikes: 61 # Total Accepted: 37K # Total Submissions: 98.1K # Testcase Example: '[1,1,2,2,2]' # # Remember the story of L...
1a1f64488e9fbf8bfbe23c47112a26f2e6a90741
chenxu0602/LeetCode
/38.count-and-say.py
1,708
3.75
4
# # @lc app=leetcode id=38 lang=python3 # # [38] Count and Say # # https://leetcode.com/problems/count-and-say/description/ # # algorithms # Easy (41.39%) # Likes: 918 # Dislikes: 7268 # Total Accepted: 322.4K # Total Submissions: 767.8K # Testcase Example: '1' # # The count-and-say sequence is the sequence of i...
18e09db8e683bf2f0e856e69ae9260f1202e16d0
chenxu0602/LeetCode
/1012.numbers-with-repeated-digits.py
1,851
3.515625
4
# # @lc app=leetcode id=1012 lang=python3 # # [1012] Numbers With Repeated Digits # # https://leetcode.com/problems/numbers-with-repeated-digits/description/ # # algorithms # Hard (37.42%) # Likes: 223 # Dislikes: 45 # Total Accepted: 5.6K # Total Submissions: 14.9K # Testcase Example: '20' # # Given a positive ...
f9dc4116e5b27423a204b65b286241d90dfd9809
chenxu0602/LeetCode
/30.substring-with-concatenation-of-all-words.py
1,866
3.578125
4
# # @lc app=leetcode id=30 lang=python3 # # [30] Substring with Concatenation of All Words # # https://leetcode.com/problems/substring-with-concatenation-of-all-words/description/ # # algorithms # Hard (23.98%) # Likes: 640 # Dislikes: 1024 # Total Accepted: 148.9K # Total Submissions: 613.9K # Testcase Example: ...
a197349d1ed28c0001f6c2ae2ad973ec31ef40c8
chenxu0602/LeetCode
/43.multiply-strings.py
2,188
3.703125
4
# # @lc app=leetcode id=43 lang=python3 # # [43] Multiply Strings # # https://leetcode.com/problems/multiply-strings/description/ # # algorithms # Medium (32.54%) # Likes: 1429 # Dislikes: 658 # Total Accepted: 254.9K # Total Submissions: 783K # Testcase Example: '"2"\n"3"' # # Given two non-negative integers nu...
77c1f00c09fba699dc5b3aa6cb7589187eff5b87
chenxu0602/LeetCode
/752.open-the-lock.py
3,263
3.84375
4
# # @lc app=leetcode id=752 lang=python3 # # [752] Open the Lock # # https://leetcode.com/problems/open-the-lock/description/ # # algorithms # Medium (49.13%) # Likes: 638 # Dislikes: 34 # Total Accepted: 38.8K # Total Submissions: 78.9K # Testcase Example: '["0201","0101","0102","1212","2002"]\n"0202"' # # # Y...
97cfdb7cee7f7e0cc8d5d82dc7d03afcc35a6f14
chenxu0602/LeetCode
/1879.minimum-xor-sum-of-two-arrays.py
2,096
3.5625
4
# # @lc app=leetcode id=1879 lang=python3 # # [1879] Minimum XOR Sum of Two Arrays # # https://leetcode.com/problems/minimum-xor-sum-of-two-arrays/description/ # # algorithms # Hard (35.40%) # Likes: 224 # Dislikes: 6 # Total Accepted: 4.5K # Total Submissions: 12.5K # Testcase Example: '[1,2]\n[2,3]' # # You ar...
274b1d8a88d93bbf245f723dcb99ed64fe833823
chenxu0602/LeetCode
/1467.probability-of-a-two-boxes-having-the-same-number-of-distinct-balls.py
3,743
3.6875
4
# # @lc app=leetcode id=1467 lang=python3 # # [1467] Probability of a Two Boxes Having The Same Number of Distinct Balls # # https://leetcode.com/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/description/ # # algorithms # Hard (61.34%) # Likes: 139 # Dislikes: 108 # Total Accepted: ...
3e8673f9ac358dbc848c4a3875e139bbf16e0f42
chenxu0602/LeetCode
/1004.max-consecutive-ones-iii.py
1,816
3.59375
4
# # @lc app=leetcode id=1004 lang=python3 # # [1004] Max Consecutive Ones III # # https://leetcode.com/problems/max-consecutive-ones-iii/description/ # # algorithms # Medium (56.39%) # Likes: 616 # Dislikes: 14 # Total Accepted: 32.7K # Total Submissions: 58K # Testcase Example: '[1,1,1,0,0,0,1,1,1,1,0]\n2' # # ...
9c879cea1ecf4e48fe94af03d51920f82c0c4504
chenxu0602/LeetCode
/1702.maximum-binary-string-after-change.py
1,795
3.703125
4
# # @lc app=leetcode id=1702 lang=python3 # # [1702] Maximum Binary String After Change # # https://leetcode.com/problems/maximum-binary-string-after-change/description/ # # algorithms # Medium (62.25%) # Likes: 132 # Dislikes: 16 # Total Accepted: 6K # Total Submissions: 9.7K # Testcase Example: '"000110"' # # ...
c032b327e9aac6b14bb1c77cd5eece8eb0ff80e7
chenxu0602/LeetCode
/1016.binary-string-with-substrings-representing-1-to-n.py
1,183
3.515625
4
# # @lc app=leetcode id=1016 lang=python3 # # [1016] Binary String With Substrings Representing 1 To N # # https://leetcode.com/problems/binary-string-with-substrings-representing-1-to-n/description/ # # algorithms # Medium (59.30%) # Likes: 58 # Dislikes: 212 # Total Accepted: 9.3K # Total Submissions: 15.8K # T...
ed66b1b93cc624da82fde988e989532880b483c1
chenxu0602/LeetCode
/540.single-element-in-a-sorted-array.py
1,146
3.578125
4
# # @lc app=leetcode id=540 lang=python3 # # [540] Single Element in a Sorted Array # # https://leetcode.com/problems/single-element-in-a-sorted-array/description/ # # algorithms # Medium (57.48%) # Likes: 777 # Dislikes: 62 # Total Accepted: 58.6K # Total Submissions: 101.8K # Testcase Example: '[1,1,2,3,3,4,4,...
14763b1e6f346f505f3e8f53d775a9b30762d273
chenxu0602/LeetCode
/1395.count-number-of-teams.py
2,432
3.734375
4
# # @lc app=leetcode id=1395 lang=python3 # # [1395] Count Number of Teams # # https://leetcode.com/problems/count-number-of-teams/description/ # # algorithms # Medium (82.03%) # Likes: 606 # Dislikes: 99 # Total Accepted: 39.7K # Total Submissions: 48.3K # Testcase Example: '[2,5,3,4,1]\r' # # There are n soldi...
0499a4d500825566bb49b8c98db67211c3a74aef
chenxu0602/LeetCode
/741.cherry-pickup.py
3,803
3.703125
4
# # @lc app=leetcode id=741 lang=python3 # # [741] Cherry Pickup # # https://leetcode.com/problems/cherry-pickup/description/ # # algorithms # Hard (33.82%) # Likes: 1088 # Dislikes: 79 # Total Accepted: 26.8K # Total Submissions: 79K # Testcase Example: '[[0,1,-1],[1,0,-1],[1,1,1]]' # # In a N x N grid represen...
80812faf39a830770bbe15ef0175ac438e83aafc
chenxu0602/LeetCode
/1588.sum-of-all-odd-length-subarrays.py
1,679
3.859375
4
# # @lc app=leetcode id=1588 lang=python3 # # [1588] Sum of All Odd Length Subarrays # # https://leetcode.com/problems/sum-of-all-odd-length-subarrays/description/ # # algorithms # Easy (81.23%) # Likes: 322 # Dislikes: 45 # Total Accepted: 20.3K # Total Submissions: 25K # Testcase Example: '[1,4,2,5,3]' # # Giv...
bc1b4d875342a7ad410b34f9b7bc3305e54c5b24
chenxu0602/LeetCode
/172.factorial-trailing-zeroes.py
1,039
3.625
4
# # @lc app=leetcode id=172 lang=python3 # # [172] Factorial Trailing Zeroes # # https://leetcode.com/problems/factorial-trailing-zeroes/description/ # # algorithms # Easy (37.80%) # Likes: 891 # Dislikes: 1135 # Total Accepted: 213.4K # Total Submissions: 564.7K # Testcase Example: '3' # # Given an integer n, r...
2cbecb1550401c3c5c7062fad537ce9a1ee49e83
chenxu0602/LeetCode
/270.closest-binary-search-tree-value.py
2,477
3.75
4
# # @lc app=leetcode id=270 lang=python3 # # [270] Closest Binary Search Tree Value # # https://leetcode.com/problems/closest-binary-search-tree-value/description/ # # algorithms # Easy (43.88%) # Likes: 395 # Dislikes: 30 # Total Accepted: 87.9K # Total Submissions: 200.3K # Testcase Example: '[4,2,5,1,3]\n3.71...
a18bb0f6bf974c3f6d70c686e10539318a8e1143
chenxu0602/LeetCode
/611.valid-triangle-number.py
1,326
3.625
4
# # @lc app=leetcode id=611 lang=python3 # # [611] Valid Triangle Number # # https://leetcode.com/problems/valid-triangle-number/description/ # # algorithms # Medium (48.39%) # Likes: 1091 # Dislikes: 95 # Total Accepted: 65.4K # Total Submissions: 134.9K # Testcase Example: '[2,2,3,4]' # # Given an array consis...
76fb4a6873b544124fbcde5868bdce24a4a34150
chenxu0602/LeetCode
/1401.circle-and-rectangle-overlapping.py
2,134
3.734375
4
# # @lc app=leetcode id=1401 lang=python3 # # [1401] Circle and Rectangle Overlapping # # https://leetcode.com/problems/circle-and-rectangle-overlapping/description/ # # algorithms # Medium (42.23%) # Likes: 131 # Dislikes: 43 # Total Accepted: 6.4K # Total Submissions: 15.1K # Testcase Example: '1\n0\n0\n1\n-1\...
7a3b13e7497d4ab49ff8cd4b2dff7d1c961010dd
chenxu0602/LeetCode
/305.number-of-islands-ii.py
3,079
3.75
4
# # @lc app=leetcode id=305 lang=python3 # # [305] Number of Islands II # # https://leetcode.com/problems/number-of-islands-ii/description/ # # algorithms # Hard (40.57%) # Likes: 705 # Dislikes: 15 # Total Accepted: 67.8K # Total Submissions: 167.2K # Testcase Example: '3\n3\n[[0,0],[0,1],[1,2],[2,1]]' # # A 2d...
1a988bbb657bb2e9ccd0fdbd67a709d2bb625810
RaveEef/Phwar-AlphaBetaSearch
/phwar.py
3,721
3.59375
4
from game_functions import * player = 'black' # player white if ai is first, black if ai is second (bottom) ai = "white" # keep ai white to circumvent evaluation bug ## Flip plot if AI plays 'white' or top flip_plot = False if player == 'white': flip_plot = True b = game_positions(grid, player, None) ## create b...
06e0eeff8467efd1538056e984644ea665656c0c
mobbarley/python2x
/fizzbuzz.py
559
4.3125
4
# This program mocks the script for the game fizz - buzz where we print all the numbers # from 1 to the number entered by the user but we say Fizz when number is divisible by 3 # and Buzz when it is divisible by 5, when it is both like in 15, 30 etc we will say FizzBuzz num = int(raw_input("Enter a number : ")) if nu...
88663a9fba92b5e8ca7a0121d3fdfabea283cb05
cindygao93/Dartboard
/assignment 2 third try.py
2,469
4.1875
4
##this is a program in turtle that will draw a dart board from turtle import * def main() : shape("turtle") pendown() pencolor("yellow") pensize(5) speed(20) radius=200 subradius=0 forward(radius) left(90) sideCount = 0 color = "yellow" while sideCount <80: ...
602c6ead4d20f32426fa59ac22beb990ea80a651
rssquad/Star
/python-programm/Python/python/vehicle/vehicle.py
487
3.5
4
class vehicle: name = "" kind = "car" color = "" value = 100.00 def description(self): description_str = "%s is %s %s worth $%.2f." %(self.name, self.color, self.kind, self.value) return description_str car1 = vehicle() car1.name = "porsche" car1.color = "black" car1.kind = "convertible" car1.va...
8dc6e4c41403953b42dde18cfb626598815bcee7
rkuzmyn/DevOps_online_Lviv_2020Q42021Q1
/m9/task9.1/count_vowels.py
428
4.125
4
vowels = 'aeiou' def count_vowels(string, vowels): # casefold() it is how lower() , but stronger string = string.casefold() # Forms a dictionary with key as a vowel count = {}.fromkeys(vowels, 0) # To count the vowels for character in string: if character in count: count[...
58f2d99235a876d016aa8eee216624b1bc51e302
ANuttinck/facts-extractor
/extractor.py
3,127
3.65625
4
'''Extracts type facts from a wikipedia file usage: extractor.py wikipedia.txt output.txt Every line of output.txt contains a fact of the form <title> TAB <type> where <title> is the title of the Wikipedia page, and <type> is a simple noun (excluding abstract types like sort, kind, part, form, type, number, ...). ...
819c382c09d918a430ff373894a8a9854e3db74c
brianchung0803/Leetcode
/Leetcode_70_climbing_stairs.py
468
3.609375
4
class Solution(object): def climbStairs(self, n): """ :type n: int :rtype: int """ if n==0: return 0 if n==1: return 1 ways=[] for i in range(n+1): ways.append(0) ways[0]=0 ways[1]=1 ...
a8d461007de3374edb18e83b496d9064cb9d0e87
CellEight/interview_puzzle
/py_src/question.py
857
3.78125
4
def final_postion(r, v, t, w, h): """ Finds the final position of a ball starting at position r moving on a w by h billiards table with no friction and perfect reflection with velocity v after a time period of t """ return [compute_position_1d(r[0],v[0],t,w),compute_position_1d(r[1],v[1],t,h)] def compute_posi...
899721b5c37fc46b0ff9cc23180428800a349589
rogerroxbr/pysuinox-sprint-zero
/capitulo 04/exercicio-04-08.py
415
4.125
4
a = float(input("Primeiro número:")) b = float(input("Segundo número:")) operação = input("Digite a operação a realizar (+,-,* ou /):") if operação == "+": resultado = a + b elif operação == "-": resultado = a - b elif operação == "*": resultado = a * b elif operação == "/": resultado = a / b else: ...
1e57faa053e5cd79adfa9fa5d3303a16732ede79
rogerroxbr/pysuinox-sprint-zero
/capitulo 11/exercicio-11-01.py
758
3.546875
4
import sqlite3 from contextlib import closing with sqlite3.connect("precos.db") as conexao: with closing(conexao.cursor()) as cursor: cursor.execute(''' create table preços( nome text, preço numeric) ''') cursor.execute(''' ...
ee2b8b6e5ff1cd5792fc88b83669cf400a9c7d8f
rogerroxbr/pysuinox-sprint-zero
/capitulo 06/exercicio-06-13.py
412
3.765625
4
T = [-10, -8, 0, 1, 2, 5, -2, -4] # A escolha do primeiro elemento é arbitrária, poderia ser qualquer elemento válido mínima = T[0] máxima = T[0] soma = 0 for e in T: if e < mínima: mínima = e if e > máxima: máxima = e soma = soma + e print(f"Temperatura máxima: {máxima} °C") print(f"Tempera...
671269c9b6ef61207b195877228fe2f7cc6829ec
rogerroxbr/pysuinox-sprint-zero
/capitulo 06/exercicio-06-12.py
99
3.515625
4
L = [4, 2, 1, 7] mínimo = L[0] for e in L: if e < mínimo: mínimo = e print(mínimo)
21fa5eacfc1c2c43e8f9cb92bdaa4405c9988b57
rogerroxbr/pysuinox-sprint-zero
/capitulo 03/exercicio-03-11.py
375
3.796875
4
preço = float(input("Digite o preço da mercadoria:")) desconto = float(input("Digite o percentual de desconto:")) valor_do_desconto = preço * desconto / 100 a_pagar = preço - valor_do_desconto print("Um desconto de %5.2f %% em uma mercadoria de R$ %7.2f" % (desconto, preço)) print("vale R$ %7.2f." % valor_do_desconto) ...
bde19d2f158298bcda452882b1e372dd973dca7a
rogerroxbr/pysuinox-sprint-zero
/capitulo 07/exercicio-07-04.py
231
3.765625
4
sequencia = input("Digite a string: ") contador = {} for letra in sequencia: if letra in contador: contador[letra] += 1 else: contador[letra] = 1 for chave in contador: print(f"{chave}: {contador}x")
1b982a9fcc14766059b23e761254c27f33037ff8
pokeyjoey/think-python
/find_string.py
232
3.921875
4
def find(word, letter, start): index = start while(index < len(word)): if word[index] == letter: return index index = index + 1 return -1 fruit = 'banana' x = find(fruit, 'n', 3) print(x)
d643bffc1fc1c1c029543510b66c5a0b1bc77377
slauney/Portfolio
/Python/InClassMarking/TC5/HighestCommonDivisor.py
2,611
4.125
4
########################################### # Desc: Highest Common Divisor # # Author: Zach Slaunwhite ########################################### def main(): #initialize the continue condition continueLoop = "y" #while continue loop is equal to y, repeat the program while(continueLoop == "y"): ...
6c85d89a5becfcce7df81801b3cd511c82b829b8
slauney/Portfolio
/Python/Labs/Lab04/ProvincialTaxes.py
2,194
4.21875
4
########################################### # Desc: Enter application description here. # # Author: Enter name here. ########################################### def main(): # Constants GST = 1.05 HARMONIZED_TAX = 1.15 # PROVINCIAL_TAX will be added onto GST to bring tax to 1.11 PROVINCIAL_TAX = 0....
df11e224537c2d5ea2aa747b7a71e12b0c4a975c
slauney/Portfolio
/Python/InClassMarking/TC2/taxCalculator.py
1,638
4.25
4
########################################### # Desc: Calculates the total amount of tax withheld from an employee's weekly salary (income tax?) # # Author: Zach Slaunwhite ########################################### def main(): # Main function for execution of program code. # Make sure you tab once for every li...
0768f9d42a0e15b0df99f862dd494ff8df153409
aikim/nespython2017hw4
/PYTHON HW IV
2,272
3.75
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Feb 12 09:15:46 2018 @author: Anastasiia """ import requests import zipfile import io import pandas as pd #%% QUESTION I #Downloading data from the webpage url = 'https://drive.google.com/uc?export=download&id=0B6ZlG_Eygdj-c1kzcmUxN05VUXM' response ...
36a6b5e2f6797df75da1bb1af892270d4051c60f
SarahAbney/biosystems-analytics-2020
/assignments/05_hamming/hamming.py
1,449
3.78125
4
#!/usr/bin/env python3 """ Author : seabney Date : 2020-03-03 Purpose: Rock the Casbah """ import argparse import os import sys # -------------------------------------------------- def get_args(): """Get command-line arguments""" parser = argparse.ArgumentParser( description='Rock the Casbah', ...
957c7b7248472db4eed43cb794b03a0f3e49cdfb
RedAnanas/macbendi
/2018.12.03/test2.py
2,205
3.734375
4
#!/usr/bin/env python #-*- coding:utf-8 -*- # author:Administrator # datetime:2018/12/3 17:15 # software: PyCharm # 数据类型-元组练习 #1.创建一个元组,分别进行索引、添加、长度计算、切片操作。 # a=("a","b","c","d","e") # print(a[2]) # # print(len(a)) # print(a[1:3]) #2.创建两个元组,进行连接操作。 # a=("a","b","c","d","e") # b=(1,2,3,4,5,6,7) # c=...
7965d2cd90239fc71e31d82c354c2082cba91206
Retler/TrollAccountsClassification
/data_sampling/calculate_follower_progression.py
4,345
3.53125
4
""" This script read the information of random sampled users, their age and followers/following count This information is aggregated to calculate the average follower/following progression over time """ import pandas as pd from datetime import datetime import matplotlib.pyplot as plt import numpy as np plt.style.use('s...
46dd105f707c2c9d6852ba3db86b4a1e59b0fca5
JadeByun/ethical-hacking
/password_cracking/sha1_bruteforce.py
743
3.515625
4
from urllib.request import urlopen import hashlib from termcolor import colored def sha1_bruteforce(): sha1_hash = input('[*] Enter SHA-1 Hash value: ') password_list = str(urlopen('https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/Common-Credentials/10-million-password-list-top-10000...
067ba4d62b07896b1a484dc7a47a39d9aba968e7
ggibson5972/Project-Euler
/euler_prob_1.py
232
4.15625
4
result = 0 #iterate from 1 to 1000 for i in range(1000): #determine if i is a multiple of 3 or 5 if ((i % 3 == 0) or (i % 5 == 0)): #if i is a multiple of 3 or 5, add to sum (result) result += i print result
44b0c19b61fb2d9a315ba804a4a5e00b30c626e6
ggibson5972/Project-Euler
/euler_prob_2.py
304
3.5
4
import math #initiate first, second, and third fib numbers curr = 1 prev = 1 prev2 = 0 total = 0 #loop to find new fib numbers while curr <= 4000000: curr = prev + prev2 if curr % 2 == 0: total = total + curr #shift numbers to next label prev2 = prev prev = curr print total
cfb8a1ff5b28e4207c25b1fcb5854c7ce339a1f9
JonathanJdeKoning/CS50
/Week7/roster.py
494
3.78125
4
import sys from cs50 import SQL db = SQL("sqlite:///students.db") houses = db.execute("SELECT first, middle, last, birth FROM students WHERE house = (?) ORDER BY last, first", sys.argv[1]) for row in houses: if row["middle"] is None: print(row["first"] + " " + row["last"] + ", bo...
052857681781833e79edd5eecb1e32b99f561749
chmod730/My-Python-Projects
/speed_of_light.py
944
4.375
4
''' This will query the user for a mass in kilograms and outputs the energy it contains in joules. ''' SPEED_OF_LIGHT = 299792458 # c in m/s2 TNT = 0.00000000024 # Equivalent to 1 joule def main(): print() print("This program works out the energy contained in a given mass using Einstein's famous equation:...
3ac3d6addabc45af281233973eef93af3629c26f
Astroneko404/DES_Encryption
/Convert.py
745
3.890625
4
# Convert a binary string to a hex string def bin_2_hex(bin_str): return hex(int(bin_str, 2))[2:] # Convert a hex string to a bin string def hex_2_bin(hex_str): return bin(int(hex_str, 16))[2:].zfill(len(hex_str)*4) def str_2_hex(s): result = '' for c in s: result += hex(ord(c))[2:] retu...
24f4bd5a2124be3d110d15fdbacb8da1dbb34ec9
r2dme/COMP-5005_FOP
/FOP/FOP/Prac04/conversions.py
398
3.609375
4
# # conversions.py – module with functions to convert between units # # fahr2cel : Convert from Fahrenheit to Celsius. # def fahr2cel(fahr): celsius = (fahr - 32) * (5/9) return celsius def kel2cel(kel): celsius = kel + 273.15 return celsius def cel2kel(cel): kelvin = celsius + 273.15 retu...
15fbbd2655817a0f2d67084dd5cebf4656405c7e
r2dme/COMP-5005_FOP
/FOP/FOP/Prac01/numbers3.py
441
4.0625
4
# # numbers3.py: Read in a list of numbers (negative to exit) and # give the sum of the numbers count = 0 total = 0 print("Enter a list of numbers, negative to exit...") number = int(input()) while number >=0: count += 1 #equivalent to count = count+1 total += number #equivalent to total =...
b8f910f3685924815cc672df9175acdb5d4fcc21
r2dme/COMP-5005_FOP
/FOP/FOP/Prac02/bucket1.py
830
4
4
# # bucket1.py - use a python list for items in a bucket list # print('\nBUCKET LIST\n') bucket1 = ['Witness something truly majestic', 'Help a complete stranger', 'Laugh until I cry', 'Drive a Shelby Mustang'] bucket1.append('Kiss the most beautiful girl in the world') bucket1.append('Get a ...
37483c63bf86b8f5d5f9add21043e590f0591525
r2dme/COMP-5005_FOP
/Prac3/plottest.py
325
3.609375
4
import matplotlib.pyplot as plt import numpy as np march2017 = np.array([37.7, 29.9, 35.2, 36.1, 36.2, 34.7, 33.8, 34.5, 31.9, 29.9, 30.9, 24.8, 24.2, 24.1, 24.0]) dates = range(1, len(march2017)+1) plt.plot(dates, march2017) plt.title('March Temperatures') plt.ylabel('Temperature') plt.xlabel('Date') plt.sho...
859ede03a3571d3b63ccdbf11830e96737de610a
r2dme/COMP-5005_FOP
/FOP/FOP/Prac01/growth.py
856
4.03125
4
# # growth.py - simulation of unconstrained growth # print ("\nSIMULATION - Unconstrained Growth\n") length = 10 population = 100 growth_rate = 0.1 time_step = 0.5 num_iter = length / time_step growth_step = growth_rate * time_step print("INITIAL VALUES:\n") print("Simulation Length (hours): ",length) print("Initial...
eb54fcd8f36e094f77bccdcebc0ae8230a2db34d
adneena/think-python
/Iteration/excercise1.py
1,142
4.25
4
import math def mysqrt(a): """Calculates square root using Newton's method: a - positive integer < 0; x - estimated value, in this case a/2 """ x = a/2 while True: estimated_root = (x + a/x) / 2 if estimated_root == x: return estimated_root break ...
3642cd6a682a9a05c2a5bc9c7597fd02af43a417
adneena/think-python
/Fruitiful-functions/excercise-3.py
856
4.34375
4
''' 1. Type these functions into a file named palindrome.py and test them out. What happens if you call middle with a string with two letters? One letter? What about the empty string, which is written '' and contains no letters? 2. Write a function called is_palindrome that takes a string argument and returns True if i...
5674ddd6d622dad21e14352332cdb85bf7adf9fc
adneena/think-python
/variables-expressions-statements/excercise1.py
520
4.375
4
''' Assume that we execute the following assignment statements: width = 17 height = 12.0 delimiter = '.' For each of the following expressions, write the value of the expression and the type (of the value of the expression). 1. width/2 2. width/2.0 3. height/3 4. 1 + 2 * 5 5. delimiter * 5 ''' width = 17 height = 12.0 ...
208aaeeeb7fa84f90beaaad29d48ec30d8015e93
adneena/think-python
/variables-expressions-statements/excercise-2.py
198
3.703125
4
''' The volume of a sphere with radius r is 4/3πr3.What is the volume of a sphere with radius 5? Hint: 392.7 is wrong! ''' radius = 5 pi = 3.14 vol_of_sphere = 4/3*pi*radius**3 print(vol_of_sphere)
6345749780da59b107c81c232a1ed3b826b0e3e7
tmguillem/game_theory_altruism
/agent.py
4,735
3.640625
4
import numpy as np import copy class Agent: def __init__(self, k, m, mu=0.1, x=None, alpha=None, mutable_variables=None): """ Initializes an agent object for the Genetic Algorithm simulation. :param k: externality parameter. Must fulfill: -1 < k < 1 :param m: self-utility paramete...
607502d6c39885a023f9fafbc64b8ffc14bae1c2
xwang146/cs109-airbnb-13
/Code/old_code/cleaning_exploration/count_categories.py
721
3.9375
4
#!/usr/bin/python import csv from collections import Counter filename = "listings.csv" #filename = "listings_clean.csv" columns = [ #"city", "bed_type", "property_type", "room_type", #"neighbourhood_cleansed", "zipcode" #"bedrooms", #"bathrooms" ] #initialize counter for each column counters = {} for...
b55ed9bed6db904a22988d3826d4c474db1f2866
kursawe/LECsegmenter
/LECSegmenter.py
52,456
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Nov 25 22:23:53 2019 @author: Thibaut Goldsborough, tg76@st-andrews.ac.uk """ #import tkinter as tk #from tkinter import * from tkinter import filedialog """ tkinter is an inbuilt Python module used to create graphical user interfaces and widgets such...
5e9ae4cb0b5334a314fff2c7860abb949df83c22
share020/dl
/assignments/mp2/src/layers.py
4,743
4.0625
4
""" HW2: Implement and train a convolution neural network from scratch in Python for the MNIST dataset (no PyTorch). The convolution network should have a single hidden layer with multiple channels. Due September 14 at 5:00 PM. @author: Zhenye Na @date: Sep 9 """ import numpy as np from utils import * class Conv...
5272bf8112c361cf7e64a978a875f73e8d593783
share020/dl
/assignments/mp2/src/utils.py
4,084
3.953125
4
""" HW2: Implement and train a convolution neural network from scratch in Python for the MNIST dataset (no PyTorch). The convolution network should have a single hidden layer with multiple channels. Due September 14 at 5:00 PM. @author: Zhenye Na @date: Sep 9 """ import h5py import numpy as np def mnist_loader(pa...
a6418418a1b4705cf65763bbdfd3d86161d14384
ruklakhani/leetcode_SPD
/leetcode-communication/two_sum.py
544
3.890625
4
def twoSum(nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ for i in range(len(nums)): for n in range(len(nums)): if nums[i] + nums[n] == target: if i != n: return [i, n] """ for each number in nums, we com...
b0a6c9cfccd1623492f55371f6639ea69fc4b470
anze3db/adventofcode2017
/src/day3.py
2,318
3.59375
4
"""Day 3: Spiral Memory.""" from collections import defaultdict import pytest def day3(arg): """Day 3.""" size = 1 while size ** 2 < arg: size += 2 current_value = size ** 2 square = size - 1 if (current_value == arg): return square offset = 0 while current_value != ar...
b610c05c6204bbd97dad293421212ecd6e7405c6
DentOneDev/MetodosNumericos
/Programa3_Graf.py
287
3.625
4
from numpy import arange import matplotlib.pyplot as plt import math fx="(((5*x)**2)-(math.e**x))" rango = arange(-10,10) valores = [] for x in rango: y = eval(fx) valores.append(y) print "x = %s y = %s" %(x, y) plt.plot(rango,valores) plt.grid(axis='both') plt.show()
76542110083e8161b587805da9a86b78f4d62837
cstpimentel/coursera
/Chapter-01/function.py
287
3.796875
4
def computepay(h,r): if h <= base : pay = h * r elif h > base : OT = h - base OTpay = OT * r * 1.5 pay = OTpay + base * r return pay hrs = raw_input("Enter Hours:") h = float(hrs) rph = raw_input("Enter rate per hour:") r = float(rph) base = 40 p = computepay(h,r) print p
5327e3c6d6563e1fe25572b838f7274c7524c7ba
09jhoward/Revison-exercies
/task 2 temprature.py
482
4.15625
4
#08/10/2014 #Jess Howard #development exercises #write a program that reads in the temperature of water in a container(in centigrade and displays a message stating whether the water os frozen,boiling or neither. temp= int(input(" Please enter the water temprature in the unit of centigrade:")) if temp<= 0: pr...
c8733e0709057f6d2688f82aaa866c37fa52ec81
agmghazi/arcpySamples
/python Tutorial/5.Python_Variables.py
334
3.90625
4
x = 4 # x is of type int x = "Ayman" # x is now of type str print x name = "Ahmed" # is the same as name = 'Gamal' print "Name: " + name x, y, z = "Ayman", "Eslam", "Mohamed" print(x) print(y) print(z) x = y = z = "Ali" print(x) print(y) print(z) x = 5 y = 10 print(x + y) # here will get error x = 5 y = "John"...
056182ab50cd45d941652e85d9758c6a2d24011c
agmghazi/arcpySamples
/python Tutorial/20.Python_If... Else.py
1,197
4.3125
4
# Python Conditions and If statements # Equals: a == b # Not Equals: a != b # Less than: a < b # Less than or equal to: a <= b # Greater than: a > b # Greater than or equal to: a >= b # a = 33 # b = 200 # if b > a: # print("b is greater than a") # a = 33 # b = 33 # if b > a: # print("b is greater than a") # eli...
feb1bf2a894405f052c561cf5ed291f6c43257bb
badgemkedgeree/sqlite_example
/read_games.py
296
3.90625
4
import sqlite3 con = sqlite3.connect('games.db') cur = con.cursor() # Insert a row of data for row in cur.execute("select * from games"): print(row) # We can also close the connection if we are done with it. # Just be sure any changes have been committed or they will be lost. con.close()
0b975c79d96e0f85d2e298b32aedafa7b337c1c2
diegoaraujocastro/AulasPythonIpea
/Lista1/Lista1_exer9.py
315
3.859375
4
#Exercício 9 def funcao (dic): for each in dic: if each in 'aeiou': dic[each] = dic[each] ** 2 else: dic[each] = 0 print (dic) #Agora vamos testar a função com um dicionário qualquer: print('Resultado final do loop:') dic_teste = {'u': 10, 'z':2,'p':5,'i':4} funcao (dic_teste)
b5b8637f83959f11e31ab49e5d0f5d20f6ed28ea
oecumene2018/Stepik_Selenium_Python_automation-
/Section_03/les_3.2_asserts_exceptions_step6-9.py
8,854
3.75
4
words = "Happy New Year!" assert "New" in words assert abs(-21354) == -21354 # Traceback (most recent call last): # File "<input>", line 1, in <module> # AssertionError assert 35 in [1, 45, 81, 64], "No value in the given list." # Traceback (most recent call last): # File "<input>", line 1, in <module> # Assertio...
25974294dcda1fbf5035e609cb1455c83831b534
yuannan/python
/yuannan/pizzashop/start.py
22,223
3.671875
4
#!/usr/bin/env python # # V0.1.0 Alpha, Functional, but missing some value checking ext. # "fully functional" # # Importing modules and defining essentails import csv import operator import sys from time import gmtime, strftime, sleep #debug=True # Defining all the functions def start(): print("Welcome to Big...
d5f394d688f2be6d5f6cff990567610f26700eae
Royalgenius/Learning-Python
/02_input_output.py
204
3.609375
4
# -*- coding: UTF-8 -*- print('The quick brown fox','jumps over','the lazy dog.') print(300) print(100+200) print('100+200=',100+200) name = input('please enter your name: ') print('hello,', name)
3bb0658eb13d9138ea08f29339c1f1a0733ffa89
Royalgenius/Learning-Python
/09_dict_set.py
613
3.65625
4
#dict name = ['Michael', 'Bob', 'Tracy'] scores = [95, 75, 85] d = {'Michael':95, 'Bob':75, 'Tracy':85} d['Michael'] d['Adam'] = 67 d['Adam'] d['Jack'] = 90 d['Jack'] d['Jack'] = 88 d['Jack'] 'Thomas' in d d.get('Thomas') d.get('Thomas', -1) d.pop('Bob') d #dict的key必须是不可变对象!! #set s = ...
28d857b506ad2296e34f6c4c4132f2a1ba3459ee
HerllonCardoso/python_solyd
/aula7-exercicios.py
402
3.796875
4
def maiorValor(colecao): maior_item = colecao[0] for item in colecao: if item > maior_item: maior_item = item return maior_item def menorValor(colecao): menor_item = colecao[0] for item in colecao: if item < menor_item: menor_item = item return menor_ite...
cffd2a6f68010176bb259f2288317c833db17ce7
PhilippeBui/FizzBuzzz
/fizzbuzz.py
312
4.03125
4
#fizzbuzz Sample x = 1 while x < 101: if x % 3==0 and x % 5 == 0: print("number is:" +str(x)) print("fizzbuzz") x= x+1 elif x % 3 == 0: print("number is:" +str(x)) print("fizz") x= x+1 elif x % 5== 0: print("number is:" +str(x)) print("buzz") x= x+1 else: x= x+1
38831d63d27a84ed15e97a262b5503c5dba905f9
funa1g/atcoder
/panasonic_2020/b.py
200
3.71875
4
val = input().split(' ') h = int(val[0]) w = int(val[1]) square_num = h * w result = square_num / 2 if h == 1 or w == 1: result = 1 elif square_num % 2 == 1: result += 0.5 print(int(result))
1a9bb9e269aba488d4265e06e06de6a80ad8e4a0
funa1g/atcoder
/panasonic_2020/c.py
269
3.765625
4
from math import sqrt val = input().split(' ') a = int(val[0]) b = int(val[1]) c = int(val[2]) # TODO このままだと、丸め桁数分間違いが発生する可能性がある diff = sqrt(c) - sqrt(a) - sqrt(b) result = 'Yes' if diff > 0 else 'No' print(result)
7b8b77525f6138e1d898b32cff05132c05610507
luisnhae/gitzens
/machine.py
431
3.78125
4
# -*- coding: utf-8 -*- print("") print("Quanto tempo de vida você tem?\n") g = int(input('How old? >>> ')) d = 24 y = 365 h = ((d*y)*g) ws = 3600 m = h*ws/60 dds = ws*d yys = y*dds s = yys*g print("") print("you're alive\n") print("hours: ",h) print("minutes: ",m) print("seconds: ",s) #existem formas de fazer isso ma...
69cb04444ad88ebb60625b7b8dcac7d7639590e4
Aivrie/eye-rest
/desk.py
1,421
3.765625
4
''' Desktop notification - This desktop notifier app runs on your system and sends you a piece of information after a fixed interval of time For this application we will remind user to look away from computer and automatically reduce the brightness of computer screen. To increase the brightness of your computer, us...
c303168550f0efffa98478b0702863552af395be
mooyeon-choi/algorithm
/python/linkedlist/class.py
330
3.890625
4
class List: def __init__(self): self.head = None self.tail = None self.size = 0 def printlist(self): if self.head is None: return cur = self.head while cur is not None: print(cur.data, end=' ') cur = cur.next print(']'...
4bcc11652cc2835a021f66949035fdc08aab8343
mooyeon-choi/algorithm
/python/naverhack/pro.4.py
130
3.703125
4
def Solution(A, B): answer = 0 num = A * B while num != 0: answer += num%2 num //= 2 return answer
d5f4c017dfb9fb66e5040df2e20da3a325663547
joselegarcia/curso_python
/condicionales/ejercicio1.py
108
3.765625
4
edad= int(input('cual es tu edad?')) if edad<18: print('menor de edad') else: print('mayor de edad')
cc0857d9dc85e7d4930af86c96ec55cb6b0b276f
joselegarcia/curso_python
/tipos de datos simples/ejercicio5.py
100
4
4
nombre= input('cual es tu nombre?') print(nombre.upper() + ' tiene '+ str(len(nombre)) + ' letras.')
5445b31179544af50a844b5653a952002a35086c
joselegarcia/curso_python
/condicionales/ejercicio4.py
190
3.734375
4
edad= int(input('cual es tu edad?')) ingresos= float(input('cuales son tus ingresos?')) if edad>16 & ingresos>1000: print('tienes que tributar') else: print('no tienes que tributar')
9707f465785188e1c767b7b82d16f65d687dd5e2
joselegarcia/curso_python
/diccionario/teoria2.py
315
4.09375
4
l1=[1,2,3] l2=l1 print(l2) l2.remove(2)#l1 tmabien se vera afectada, copia por referencia l1=[1,2,3] l2=list(l1) print(l2) l2.remove(2) print(l2) print(l1)#al elimanar en l2, l1 no se ve afectada, copia por valor d1={1:'a',2:'b',3:'c'} d2=dict(d1) print(d2) del d2(2) print(d1) #lo mismo pero para diccionarios
7aa43ddbb81ccbb9e8ad6fa74424dbe46fdeca35
Wambita/pythonwork
/converter.py
597
4.1875
4
#Program to convert pounds to kilograms #Prompt user to enter the first value in pounds print("Enter the first value in pounds you wish to convert into kilograms") pound1= float(input()) #prompt user to enter the second value in pounds print("Enter the second value in pounds you wish to convert into kilograms") pound...
0a1054b195d5ffe53bc14e92e6080edf6093d5f3
deodacodesage/data_science_program
/classes.py
1,154
4.21875
4
class Human (object): """ Class that defines human beings """ def __init__ (self, name, age, race, gender, religion): self.name = name self.age = age self.race = race self.gender = gender self.religion = religion def __person(self): profile = """ ...
2456ff3747cbd681f98055fe558af84eabd5d807
MrGoldPWD/pythonspacewars
/spacewars.py
2,095
3.8125
4
# SpaceWar by @TokyoEdTech / Written in Python 2.7 # Part II: Player Class / Moving the Player import pygame pygame.init() import os import random # Import the Turtle module import turtle joystick_count = pygame.joystick.get_count() if joystick_count == 0: # No joysticks! print("Error, I didn't find any joys...
bd0c280225197fd037c7b130a556cbb686217ada
amirofski/nafas
/test/test.py
3,301
3.953125
4
# -*- coding: utf-8 -*- """ >>> from nafas.functions import * >>> line(10,"*") ********** >>> description_print() Breathing gymnastics is a system of breathing exercises that focuses on the treatment of various diseases and general health promotion. Nafas is a collection of breathing gymnastics designed to redu...
1a669eaaaf8010e624d95832141cb373e4136894
Narvaal/analisador_sintatico
/generator.py
796
3.59375
4
import random import pandas as pd # Gera testes de entrada para o programa em .xlsx #Parametros para criação dos valores values = ['+', '-', '*', '/', '(', ')', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] #Caracteres usados numValuesList = 10000 #Numero de testes sizeMin = 3 ...
36d01f3e72a8212af3b35f2a76191258f256b0a9
drishabh/text-summarization
/pyGUI.py
3,218
3.671875
4
from tkinter import * from tkinter import scrolledtext from tkinter import messagebox from newspaper import * import nltk ''' SummarizerInterface class creates an interactive user interface that takes in an article from a user and verifies its length before passing it onto the system. ''' class SummarizerInterface(Fra...
5c5c7a313562bd51a45f423d5a659780027f2dfa
ObadiahBorms02/python
/code/example-ord.py
140
3.78125
4
# example-ord.py def main(): c = [' ','A','a','*','0'] # c list are characters for n in range (len(c)): print(n,c[n],ord(c[n])) main()
ccf8e6a9a557fabdc2cb0e7f145d05bbba4aa495
ObadiahBorms02/python
/set_1.py
416
3.671875
4
#set_1.py okb alpha = {"a", "bb", "ccc", "dddd", "eeeee", "ffffff" for x in alpha: #print(alpha[x]) #uncomment this line an try print(x) print(sorted(alpha)) """ Look at what is going on here. A set can not be indexed. for x in alpha looks at all the elements in the set and assigns one at a time to the x variabl...
d1dd64eb8d3fd92fc3e5615f506fe6b51955ada1
neurodsp-tools/neurodsp
/neurodsp/utils/norm.py
1,923
3.640625
4
"""Normalization related utility functions.""" import numpy as np ################################################################################################### ################################################################################################### def normalize_sig(sig, mean=None, variance=None): ...
3409636c46ec4db4f44dd05f41ddaab04462a5fa
neurodsp-tools/neurodsp
/tutorials/filt/plot_2_FIR.py
8,479
3.65625
4
""" FIR Filters =========== Design, apply, and evaluate FIR Filters. This tutorial covers the design and application of Finite Impulse Response (FIR) filters, available in ``neurodsp.filt.fir``. """ ################################################################################################### # sphinx_gallery_...
77d49030389985b8a77db9a3cc8839cf4a2dc4ca
clwater/lesson_python
/old/learn_old/test1.py
287
3.5625
4
# coding=utf-8 #首两行 表示可执行 utf-8解码 #!/usr/bin/env python3 # -*- coding: utf-8 -*- print "要不要这么难" print "100 + 200 =",100+200 #input输入可以带参数 #name = input('please enter your name: ') #print('hello,', name) print "1024 * 768 =" , 1024 * 768