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
28b8c6db607fff1b97db43775fc77fdf0c992f4c
PreetiLo/loop
/factorial loop.py
730
3.9375
4
# n=5 # f=1 # if n<0: # print("hoga") # elif n==0: # print("thoda hoga") # else: # for i in range(f,n+1): # f=f*i # print("kya kru yrr") # m=int(input("enter number")) # i=m # sum=0 # while i<=m: # sum=sum+(i%10)*(i%10)*(i%10) # i=i//10 # i=i+1 # if m==sum: # print...
5d528070f96e75a5a0e12d3cd4009203621d1796
PreetiLo/loop
/multiplicationloop.py
1,115
3.671875
4
# n=int(input("enter any number")) # i=1 # while i<24: # if i%n==2: # print(n,"*",i,'=',n*i) # # break # i=i+1 # n=int(input("enter any number")) # i=1 # while (i-j<10,50): # print(n,"*",i,'=',n*i) #{n=int(input("enter any number")) # i=1 # for i in range(i<=1,21): # pri...
7555e15f4df7ffc2e9202deb37a6f9d453f140e6
langa23/ESWII
/decisao.py
119
3.65625
4
x = 5 if (x < 100) and (x>7): print("positivo") print(x*x) print("1") else: print("negativo")
804a2678c53ca099282608bcf53a3d71c1254164
duyixian1234/algorithms
/python-algorithms/algorithms/sorting/radix_sort.py
830
3.625
4
from typing import List import math def radix_sort(arr: List[int]): max_base = get_max_base(arr) base = 1 buckets = [arr] while base <= max_base: buckets = _radix_sort(buckets, base) base *= 10 # At last run, negative numbers will be put in bucket 9, beacuse a negative number `//` ...
ebf68744a03082f66aa48589ca4c54d6eddbde2d
duyixian1234/algorithms
/python-algorithms/algorithms/sorting/merge_sort.py
1,796
3.765625
4
from typing import List, TypeVar DataT = TypeVar("DataT") def inplace_merge_sort(arr: List[DataT]): length = len(arr) _inplace_merge_sort(arr, 0, length - 1) def _inplace_merge_sort(arr: List[DataT], low: int, high: int): if low < high: mid = (low + high) // 2 _inplace_merge_sort(arr, l...
98cfbcf9b135a4851035453a1182acfbb389545f
samicd/coding-challenges
/duplicate_encode.py
738
4.1875
4
""" The goal of this exercise is to convert a string to a new string where each character in the new string is "(" if that character appears only once in the original string, or ")" if that character appears more than once in the original string. Ignore capitalization when determining if a character is a duplicate. ...
04b535818a9d961610d409f4ba74f9d27d0a0c6a
Lesi-N/Sorting_alg_comparison
/timing.py
2,627
3.90625
4
""" Module for timing the execution of each sorting algorithm and running all algorithms through the same lists """ from insertion import insertion_sort from merge import merge_sort from selection import selection_sort from shell import shell_sort import time import copy def time_shell(lst): """ Times executi...
1cc5768ad24a2dca2b0d706ad2ed2d783513345a
IvLee/Class_Assignments
/Celsius and Fahrenheit.py
308
3.78125
4
import time def main() : print("Here's a chart of Celsius and Fahrenheit in increments of 5") print("Celsius Fahrenheit") print("______________________________") for i in range (0,101,5) : print(i, " ", ((i*(9/5)+32))) time.sleep(0.5) main()
225c30c44fb9eeb380d635e4f7d2b25fa9d20d7b
IvLee/Class_Assignments
/Even odd numbers.py
191
3.859375
4
num = int(input("give me your number ")) def number (a) : mod = a % 2 if mod > 0: print("you oddball, get a life!") else: print("time to get even") number (num)
7915a60123b2e0760646f2c0c51474666f0fd9cf
omarchehab98/open.kattis.com-problems
/lost/lost.py
890
3.625
4
n, m = map(int, input().split()) languages = set(input().split()) translators = [input().split() for i in range(m)] translators = [(source, target, int(cost)) for (source, target, cost) in translators] adjacency_list = {"English": set()} for language in languages: adjacency_list[language] = set() for (source, targe...
16fa1848398eb640b56e354d3603c848b404b81f
omarchehab98/open.kattis.com-problems
/diagonalcut/diagonalcut.py
199
3.625
4
def gcd(a, b): while b != 0: a, b = b, a % b return a [a, b] = list(map(int, input().split(' '))) d = gcd(a, b) if(((a // d) % 2 == 1) and ((b // d) % 2 == 1) ): print(d) else: print(0)
e0d6665cb2184da03b921992ea5cbbe64d3fb048
Ritella/ProjectEuler
/Euler039.py
863
3.78125
4
# If p is the perimeter of a right angle triangle with integral length sides, # {a,b,c}, there are exactly three solutions for p = 120. # {20,48,52}, {24,45,51}, {30,40,50} # For which value of p ≤ 1000, is the number of solutions maximised? def find_pythagorean_solns(max_num): num_solns = [0] * (max_num + 1) ...
2e8c06453cf39c1abd71bfcf755e5b211ad13893
Ritella/ProjectEuler
/Euler010c.py
470
3.90625
4
# The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. # Find the sum of all the primes below two million. def find_primes(max_num): all_nums = range(3,max_num,2) all_nums_bool = True * (max_num - 3 + 1)/2 for i, num in enumerate(all_nums): all_nums_bool = [False for x in all_nums_bool if x in ran...
f52079869f41ba7c7ac004521b99586c6b235dad
Ritella/ProjectEuler
/Euler030.py
955
4.125
4
# Surprisingly there are only three numbers that can be # written as the sum of fourth powers of their digits: # 1634 = 1^4 + 6^4 + 3^4 + 4^4 # 8208 = 8^4 + 2^4 + 0^4 + 8^4 # 9474 = 9^4 + 4^4 + 7^4 + 4^4 # As 1 = 1^4 is not a sum it is not included. # The sum of these numbers is 1634 + 8208 + 9474 = 19316. # Find th...
83571a887f9f89107aa9d621c0c2ebcac139fd2e
Ritella/ProjectEuler
/Euler019.py
1,836
4.15625
4
# You are given the following information, # but you may prefer to do some research for yourself. # 1 Jan 1900 was a Monday. # Thirty days has September, # April, June and November. # All the rest have thirty-one, # Saving February alone, # Which has twenty-eight, rain or shine. # And on leap years, twenty-nine. # A l...
d7f9271aa9b098b13c6ac7872924458be2a39b72
Ritella/ProjectEuler
/Euler021a.py
748
3.609375
4
# Let d(n) be defined as the sum of proper divisors of n # (numbers less than n which divide evenly into n). # If d(a) = b and d(b) = a, where a ≠ b, then a and b # are an amicable pair and each of a and b are called amicable numbers. # For example, the proper divisors of 220 are # 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 a...
5ec5e48a1f3101d98c2250031858c7b6aa060c63
Ritella/ProjectEuler
/Euler017a.py
2,161
3.671875
4
## If the numbers 1 to 5 are written out in words: one, two, three, four, five, # then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. # If all the numbers from 1 to 1000 (one thousand) inclusive were written out # in words, how many letters would be used? # Note: Do not count spaces or hyphens. # For example,...
146af7c28e0698203d3a45ff3e9494f44d17f13f
Unclerojelio/python_playground
/drawcircle.py
479
4.1875
4
""" drawcircle.py A python program that draws a circle From the book, "Python Playground" Author: Mahesh Venkitachalam Website: electronut.in Modified by: Roger Banks (roger_banks@mac.com) """ import math import turtle # draw the circle using turtle def drawCircleTurtle(x, y, r): turtle.up() turtle.setpos(x + r, y)...
ac494fd2cac6f8a217dbd1291424775ef364ace4
chimtrangbu/DoorToDoor
/node.py
428
3.953125
4
from math import sqrt class Node(): ''' each Node object holding each city's coordinates cal_distance: calculating distance between this Node and another Node ''' def __init__(self, name, x, y): self.name = name self.x = x self.y = y def cal_distance(self, another_node...
b467f2dd10dff0dca56cc305d9d5f692c6ab7d97
Toooolik/Devops
/lab-2a/lab-2a.py
564
3.9375
4
print("Перша константа", None) a1 = 2 print(a1.__eq__(2)) print("a1 equale {a}".format(a=a1)) a1 = 3 a2 = 6 if a1 == a2: print("{}={}".format(a1,a2)) elif a1 > a2: print("{}>{}".format(a1,a2)) else: print("{}<{}".format(a1,a2)) a = [9,8,7,6,5,4,3,2,1,0] for i in a: print(-i) try: print("Що буде я...
ccfa84552ea43e436483040cb9ed8c83a1e55772
prabhatse/ds-algo-practice
/data_structure/stack.py
2,665
3.796875
4
from linkedlist import LinkedList """ Array LinkedList Space O(n) O(n) Push O(1) O(1) Pop O(1) O(1) Size O(1) O(1) Top O(1) O(1) Pop O(1) O(1) """...
bb1bc3265b4d352ff4f2a7d303189ee172a777ba
frameworkdartboard/ComeOnFeelTheExercism
/python/matrix/matrix.py
929
3.59375
4
class Matrix: def __init__(self, matrix_string): self.thematrix=[] matrix_lines = matrix_string.splitlines() for line in matrix_lines: row=map(int,line.split(' ')) self.thematrix.append(list(row)) def row(self, index): return(self.thematrix[index-1]...
f9af5455a8cc22155a9239499f59fa1c9d8e6d14
vtanguturi/foobar
/level1.py
194
3.671875
4
def answer(x, y): # This is the one where you had to find an extra number in the other list # Check whichever is longer, if that number does not exist in the other list then you return that one
baaa4c9f5e80c0a176aece50bd0ed829b25e53a7
qiongsiwu/cs212
/more_pour.py
5,091
4.0625
4
# ----------------- # User Instructions # # In this problem, you will solve the pouring problem for an arbitrary # number of glasses. Write a function, more_pour_problem, that takes # as input capacities, goal, and (optionally) start. This function should # return a path of states and actions. # # Capacities is a tuple...
90d05c7f5b8b5deff4df9fecec397f4ebc0a2a7a
Newtoto/AutomatedTaskboardDigitisation
/slider.py
4,378
3.59375
4
'''All classes which pertain to the slider control at the bottom of the page''' from __future__ import division import math import pygame class SliderContainer: '''Contains all parts of the slider''' def __init__(self, screen, height_percentage, images): self.height_percentage = height_percentage ...
f456f4e06cd9f8206f9b5f2c98732f22f913e614
msheshank1997/Binary-Search-2
/find-first-and-last-position-of-element-in-sorted-array.py
1,287
3.65625
4
#Time Complexity: O(N) #Space Complexity: O(1) #Did this code successfully run on Leetcode: Yes class Solution(object): def searchRange(self, nums, target): lis = [] left = self.binarysearchleft(nums, target, 0, len(nums) - 1) right = self.binarysearchright(nums, target, 0, len(nums) - 1)...
012b3bd66519f7baae212eb41e2148e050231433
nickwiper/python.mipt.ch
/черепуха 7.py
135
3.59375
4
import turtle turtle.shape('turtle') a = 10 for j in range(50): turtle.right(90) turtle.forward(a) a += 10 input()
5a675980a7ab9906c24f6b82300612b968d0bc08
RRRaymond/Ransac-AdaBoost
/classifier.py
1,262
3.6875
4
""" @author: raymondchen @date: 2018/5/8 Description: This is the class of weak classifier for AdaBoost. They are only vertical or horizontal lines. """ class WeakClassifier(object): def __init__(self, direction="vertical", positive=True, position=0): """ :type direction:str :type...
70fd00614f8b9f9794a2c5339af7d47a24815436
pjayadeep/Python
/80-20-cointoss-a.py
5,825
3.984375
4
# Simulation of Jordan Henderson's analogy of natural classification # #Probllem: # # Let us say the the probability of a head or tail during a coin toss is # equal (50 percent). # # Let us also start a game in which every one has 100 rupees. If they all # trade with each other for a long time based on c...
b5d5259d39574d4abc45bf40152c3934f9ecd978
Nilelor/Lab_Python_04
/datastruc.py
888
4.03125
4
groceries=['bananas','strawberries','apples','bread'] groceries.append('champagne') for grocery_list in groceries: print grocery_list print'-----------------' groceries.remove('bread') for grocery_list in groceries: print grocery_list print'------------------' aisles={'apple':'a','banana':'b','champagne':'c','s...
ff6d8a6d2cbe1e03a761e345c397a573aabd73d1
vardaanbhalla/Hackerrank-Solutions
/svalid.py
222
3.609375
4
s = input() print(any([i.isalnum() for i in string])) print(any([i.isalpha() for i in string])) print(any([i.isdigit() for i in string])) print(any([i.islower() for i in string])) print(any([i.isupper() for i in string]))
6c8a6f9c3b50b284a67d5b2fb14129c6bca97513
ho-kyle/python_portfolio
/071.py
161
3.640625
4
x = eval(input('Please enter x: ')) guess = x / 2 while guess**2 - x > 10**(-12) or x - guess**2 > 10**(-12): guess = (guess + x / guess)/ 2 print(guess)
6c34c6d26b9a19d04722710599558fb81681cdae
ho-kyle/python_portfolio
/056.py
759
3.5625
4
a = eval(input('Please enter the number of minutes\ used in a month: ')) b = eval(input('Please enter the number of text messages\ used in a month: ')) baseCharge = 15.00 addMinutesCharge = (a - 50) * 0.25 addTextMessageCharge = (b - 50) * 0.15 the911Fee = 0.44 tax = (baseCharge + addMinutesCharge +\ addTex...
73c06c6a62a235f11fd93e1dcd57a41c38ab0b29
ho-kyle/python_portfolio
/068.py
330
4
4
a = input('Please enter 8 bits: ') while a != '': if a.count('0') + a.count('1') != 8 or len(a) != 8: print('error') else: if a.count('1') % 2 == 0: print('the parity bit should be 0') else: print('the parity bit should be 1') a = input('Please enter ...
6d59dfea2b5e39da67c3182a2c29315a1a610861
ho-kyle/python_portfolio
/猜數字.py
617
3.734375
4
ans = 0 print('猜數字遊戲,請心中想一個 0 - 7 之間的數字,然後回答問題') print('有沒有看到心中的數字:') print('1, 3, 5, 7') a = input('輸入y或Y代表有,其他代表無:') if a == 'y' or a == 'Y': ans += 1 print('有沒有看到心中的數字:') print('2, 3, 6, 7') a = input('輸入y或Y代表有,其他代表無:') if a == 'y' or a == 'Y': ans += 2 print('有沒有看到心中的數字:') print('4, 5, 6, 7') ...
56fe151e5003de0eb403024e4e96fc7b8d4bab08
ho-kyle/python_portfolio
/021.py
160
3.953125
4
b = eval(input('Please enter the value of b: ')) h = eval(input('Please enter the value of h: ')) area = b * h / 2 print(f'The area of a triangle is {area}')
2f241cbeab2b922daa82419bc7dcd79a0156c63a
ho-kyle/python_portfolio
/018.py
179
4.0625
4
from math import pi a = eval(input('Please enter the value of radius: ')) b = eval(input('Please enter the value of height: ')) c = pi * a * 2 * b print(f'The volume is {c}.')
b284b148982d4c0607e0e0c15ac07641aea81011
ho-kyle/python_portfolio
/081.py
229
4.21875
4
def hypotenuse(): a, b = eval(input('Please enter the lengths of the two shorter sides \ of a right triangle: ')) square_c = a**2 + b**2 c = square_c**0.5 print(f'The length of hypotenuse: {c}') hypotenuse()
f004263525930a751bccd56401fa0d596992f615
ho-kyle/python_portfolio
/110.py
397
3.53125
4
import properDivisor def perfectNumber(n): l = properDivisor.properDivisor(str(n)) Sum = 0 for i in l: Sum += i if n == Sum: return True else: return False def main(): Limit = 10000 print('All of th perfect numbers between 1 and 10000') for i in ran...
30b86ff8c73987f155718ac01fdffb9c3fcaa360
ho-kyle/python_portfolio
/055.py
390
3.875
4
a = eval(input('Please enter the frequency of the radiation: ')) b = [3 * 10**9, 3 * 10**12, 4.3 * 10**14, 7.5 * 10**14, 3 * 10**17, 3 * 10**19] c = ['radio waves', 'microwaves', 'infrared light', 'visible light', 'ultraviolet light', 'x-rays', 'gamma rays'] if a >= 3 * 10**19: d = 'gamma rays' for i in range(...
920343b6a2580b51365e849fd878c64c60067109
ho-kyle/python_portfolio
/039.py
470
3.875
4
a = eval(input('Please enter the sound level in decibels: ')) b = [130, 106, 70, 40] c = ['Jackhammer', 'Gas lawnmower', 'Alarm clock', 'Quiet room'] for i in range(4): if a == b[i]: print(f'The sound level in decibel is {c[i]}') for i in range(3): if a < b[i] and a > b[i + 1]: print(f'T...
b2dcb34b6cdf6735d6b531441b982e8a9cd3bc50
ho-kyle/python_portfolio
/075.py
196
3.765625
4
a = eval(input('Please enter an integer: ')) b = eval(input('Please enter an integer: ')) c = min(a, b) while a % c != 0 or b % c != 0: c -= 1 print(f'The greatest common divisor is {c}')
d41f1dfcbb65bd308f53ce3fe92ab7dc5e6f429e
ho-kyle/python_portfolio
/072.py
230
3.890625
4
a = input('Please enter a string: ') for i in range(len(a) // 2): b = len(a) - 1 - i if a[i] != a[b]: print('It is not a palindrome.') break else: print('It is a palindrome.')
509078fda4a261955535869d41b72cbeff4de24c
Helo88/Udacity_bikeShare_Project
/bikeshare.py
8,917
3.875
4
import time import pandas as pd import numpy as np import datetime import collections CITY_DATA = {'chicago': 'chicago.csv', 'new_york_city': 'new_york_city.csv', 'washington': 'washington.csv'} months = ["january", "february", "march", "april", "may", "june"] days = ["saturday", ...
4ec7d7c142192cb51a6c618adeca55b5a4f21855
rodrigots98/Lista-Exercicios-Python3
/ex112/utilidadecev/dados/__init__.py
323
3.609375
4
def leiaDinheiro(x): vali = False while not vali: entra = str(input(x)).replace(',','.').strip() if entra.isalpha() or entra == '': print(f'\33[1;31mERRO: \"{entra}\" é um preço inválido!\33[m') else: vali = True return float(entra)
d3d1b3a90773fdea356f0bc12659372a729b4127
sligocki/hanabi
/hanabi.py
11,829
3.609375
4
import csv import random import sys class Object: def __repr__(self): return repr(self.__dict__) DEBUG = False COLOR = "COLOR" NUMBER = "NUMBER" def OtherAttribute(x): if x == COLOR: return NUMBER else: assert x == NUMBER return COLOR class Card(Object): def __init__(self, color, num): # No...
e19c086f3dbe4cfa716b4cbf54392b91f82027d3
humeinstein/holbertonschool-interview
/0x03-minimum_operations/0-minoperations.py
235
3.640625
4
#!/usr/bin/python3 """ function: return min op """ def minOperations(n): """ return min op """ end = 0 for iter in range(2, n): while n % iter == 0: end += iter n = n / iter return end
77aa61b7197362b176fa76a32654bb75d603ecd2
mukul297/CpiStack
/2. Script /2.linearmodel.py
2,521
3.515625
4
import numpy as np import matplotlib.pyplot as plt import pandas as pd from sklearn import preprocessing #Reading csv file. dataset = pd.read_csv('benchmark.csv') colm = list(dataset.columns) colm = colm[2:] rem = ['instructions','cycles'] for r in rem: colm.remove(r) #separating dependent variable (y) and indep...
9e01f921fd396c89c39570ccea4f8b41aae98ad8
kaubu/python-menu
/menu.py
897
3.609375
4
from os import system def qmenu(menu_obj): Menu(menu_obj).start() # Quick Menu. Initializes a menu in one line. class Menu: def __init__(self, menu_obj): self.menu_obj = self.parent_obj = menu_obj # Change self.parent_obj if you want to do nested menus def start(self): valid_input = False system("cl...
f76c16c5763dc21b00bcf155024553916446e350
lelilia/supermarket_simulation
/supermarket_simulation/video_gen.py
2,451
3.78125
4
""" Implement a customer that is moving around between the sections of a supermarket """ import numpy as np import cv2 import random img = cv2.imread('images/market.png') PURPLE = (255, 0, 255) # (blue, green, red) GREEN = (0, 128, 0) BLUE = (255, 0, 0) COLORS = [PURPLE, GREEN, BLUE] AISLES = [100, 300, 550, 800]...
0c32b4d5f05bb0ab23dc6e82a93f161314366edf
sbasu7241/cryptopals
/Set1/Challenge6.py
4,637
3.90625
4
#!/usr/bin/env/python import base64 import string cipheredtext = '' str1 = "this is a test".encode() str2 = "wokka wokka!!!".encode() def get_english_score(input_bytes): """Compares each input byte to a character frequency chart and returns the score of a message based on the relative frequency the characters oc...
02a62a86ade142b99b024e60d06ef404a76c158d
sbasu7241/cryptopals
/Set1/Challenge1.py
352
3.59375
4
#!/usr/bin/env/python import base64 import codecs def main(): str = input("[+] Enter hex string > ") str = codecs.decode(str,'hex_codec') # hex to string convert decoded = base64.b64encode(str) # encode string with base64 and convert to bytearray print("[+] Your Base64 encoded string is > "+decoded.decode()) if...
4716efa6ab49a5e4c4f7a3cfe0f6c9e5f2efaf2f
stones-zone/Leetcode
/Python/233-number-of-digit-one/number-of-digit-one.py
530
3.875
4
# Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n. # # # For example: # Given n = 13, # Return 6, because digit 1 occurred in the following numbers: 1, 10, 11, 12, 13. # class Solution: def countDigitOne(self, n): """ :type ...
994bf3f82e827b7135dd4221ee0fb639fe52bb2c
stones-zone/Leetcode
/Python/119-pascals-triangle-ii/pascals-triangle-ii.py
977
3.90625
4
# -*- coding:utf-8 -*- # Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle. # # Note that the row index starts from 0. # # # In Pascal's triangle, each number is the sum of the two numbers directly above it. # # Example: # # # Input: 3 # Output: [1,3,3,1] # # # Follow ...
336964f78b01e5a4a87a83f852d6b01f4e281324
stones-zone/Leetcode
/Python/003-longest-substring-without-repeating-characters/longest-substring-without-repeating-characters.py
1,653
4
4
# -*- coding:utf-8 -*- # Given a string, find the length of the longest substring without repeating characters. # # Examples: # # Given "abcabcbb", the answer is "abc", which the length is 3. # # Given "bbbbb", the answer is "b", with the length of 1. # # Given "pwwkew", the answer is "wke", with the length of 3....
47ae0ac86855d62d37124a108f60c58fc568fa6e
stones-zone/Leetcode
/Python/118-pascals-triangle/pascals-triangle.py
1,036
3.953125
4
# -*- coding:utf-8 -*- # Given a non-negative integer numRows, generate the first numRows of Pascal's triangle. # # # In Pascal's triangle, each number is the sum of the two numbers directly above it. # # Example: # # # Input: 5 # Output: # [ # [1], # [1,1], # [1,2,1], # [1,3,3,1], # [1,4,6,4...
8cfed91d7cb798e76eba53ed83050aa620c97ec6
DamoM73/2020-Class-Examples
/Unit 3/sql_movies_2.py
462
3.765625
4
import sqlite3 DATABASEFILE = "movies.db" def sql_query(db_file, query): with sqlite3.connect(db_file) as database: cursor = database.cursor() cursor.execute(query) return cursor.fetchall() # ---- MAIN PROGRAM ---- query_command = """ SELECT DISTINCT year ...
a53e511d310011a9292b00840d974b2b71239a92
DamoM73/2020-Class-Examples
/Unit 3/api_db.py
4,538
3.703125
4
import requests import json import sqlite3 DB_FILE = "food_trucks.db" def jprint(obj): # Display formatted data only if retrieval is successful if obj.status_code == 200: print(json.dumps(obj.json(), indent=4)) # If retieval not successful, display error number else: print(obj.status_c...
3323876b14e712a307da98b9c83aa3a189fa168c
Jarvis1217/Python
/Excel列编码.py
388
3.65625
4
def encode(num): ans = [] while num > 0: num -= 1 ans.append(chr(num % 26 + ord("A"))) num //= 26 return "".join(ans[::-1]) def decode(word): word, ans = word[::-1], 0 for i in range(len(word)): tmp = ord(word[i]) - ord("A") ans += (tmp + 1) * (...
397c220ace1fe47e07396d1f40e37061481af062
Jarvis1217/Python
/Python/point.py
345
3.953125
4
class Point(): '''构造''' def _init_(self,x,y): self.x=x self.y=y '''获取坐标''' def get_point(self): return self.x,self.y point=Point() point.x=int(input("please input x:")) point.y=int(input("please input y:")) print("你输入的坐标为:",point.get_point())
f36e08950dc4c92a0179674579f984839d545e3b
samcabano/python_fundamentals
/Module 3 - Conditionals and Lists/Rock_Paper_Scissor.py
1,701
3.9375
4
import random print ("Rock, paper, scissors, shoot!") player1 = input('Player 1 - Enter your choice: ') # prompts user input of rock, paper or scissors # For 2 player games, while loop to hide player 1's response, then requests response from player 2: # n = 1 # while n < 50: # print ('\n') # n = n + 1 # pl...
706cd2152aa1b6a194c4d0d6eb181a65ed5d96d1
YuSawan/nlp100knock
/chapter1/knock_08.py
312
4.09375
4
#!/usr/bin/env python # coding: utf-8 # In[1]: import sys def cipher(t): new_text = '' for char in t: if char.islower(): char = chr(219-ord(char)) new_text += char return new_text if __name__ in '__main__': my_text = input() print (cipher(my_text))
bf770b45c63579209ec4695b70e816d7b6d4bf8d
YuSawan/nlp100knock
/chapter1/knock_05.py
512
3.78125
4
#!/usr/bin/env python # coding: utf-8 # In[3]: def word_ngram(t,n): words = t.split() bi_list = [] for i in range(len(words)-n+1): bi_list.append(words[i:i+n]) return bi_list def char_ngram(t,n): bi_list = [] for i in range(len(t)-n+1): if t[i] == ' ' or t[i] == '.': ...
3772193a081cf37cc7bbe384d99fe24db1ac0917
chunshengding/Fluency-Python
/2.9.3 NumPy和SciPy_示例2-22 对numpy.ndarray的列和行的基本操作.py
339
3.59375
4
import numpy # 新建一维数组,0-11的整数 a = numpy.arange(12) print(a) type(a) # 查看数组的维度,这里是一维的 print(a.shape) # 把数组变成二维的 a.shape=3,4 print(a) # 查看第二行 print(a[2]) # 查看第二行,第一列 print(a[2,1]) # 打印第一列 print(a[:,1]) # 把行和列交换 print(a.transpose())
757f372215a2766a0681bf358c16ffe90426fd4d
chunshengding/Fluency-Python
/2.4.4 给切片赋值.py
463
3.578125
4
l=list(range(10)) # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] print(l) l[2:5]=[20,30] # [0, 1, 20, 30, 5, 6, 7, 8, 9] print(l) del l[5:7] # [0, 1, 20, 30, 5, 8, 9] print(l) l[3::2]=[11,12] # [0, 1, 20, 11, 5, 12, 9] print(l) # 错误用法,如果是赋值的对象是一个切片,那么赋值语句的右侧必须是一个可迭代对象; # 即使只有一个单独值,也要转换为可迭代的序列 # l[2:5]=100 # print(l) l[2:5]=[100...
9aa293a22aa5a13515746f2b669bf095b21cb84e
sreekanthramisetty/Python
/Scope.py
1,198
4.25
4
# s = 10 # def f(): # print(s) # # print(s) # f() # print(s) # # # # # # # # # # # # # # # # # # # # # # s = 20 # def f(): # s = 30 # print(s) # print(s) # f() # print(s) # # # # # # # # # # # # # # # # # # # # # # We cannot print global variable directly inside the functions if we are assigning a va...
0442a5aba5e5264757e45a664e06118f922292c1
sreekanthramisetty/Python
/Class.py
634
3.90625
4
# class MyClass: # x = 5 # print(MyClass) # # Object Creation # p1 = MyClass() # print(p1.x) # # int class Computer: school = "Telusko" def __init__(self,m1,m2,m3): self.m1 = m1 self.m2 = m2 self.m3 = m3 def config(self): print("This is my computer:") @staticmetho...
24aa5b382b7e3b35fa2be60eac7cb34350b5c8a9
sreekanthramisetty/Python
/Inheritance.py
1,516
3.953125
4
#SINGLE INHERITANCE #MULTI LEVEL INHERITANCE #MULTIPLE INHERITANCE # class A: # def feature1(self): # print("Feature 1 working") # # def feature2(self): # print("Feature 2 working") # #---------------------------------------------SINGLE LEVEL INHERITANCE------------------------------------A <- ...
daad09a0030023fe7683afcd13f3f3fa300e8ec8
chilperic/Python-session-coding
/trapezoid.py
324
3.90625
4
#!/usr/bin/env python #This program use the trapezoid method to compute the integral of the function f from numpy import sin def trap(a,b,f,n): h=(b-a)/float(n) z=0 for i in range(n): z=z+(f(a+i*h)+f(a+(i+1)*h))/2 return h*z #example of function def f(x): return sin(x**2+x)+x**4+4 print trap(-1,2,f,...
817a57ad576fcc602e6de0a8daa1a0811f5a6657
chilperic/Python-session-coding
/mutiple.py
868
4.28125
4
#!/usr/bin/env python #This function is using for find the common multiple of two numbers within a certain range def multiple(x,y,m,t): #x is the lower bound the range and y higher bound from sys import argv x, y, m, t= input("Enter the the lower bound of your range: "), input("Enter the the higher bound of your r...
198bdc2e7736f8fcd3234a673a3e8fc6907d5f90
HOOTITANIC/who-does-what
/1.py
180
3.734375
4
print('开始') temp=input("how old am I ?") answer=int(temp); if answer==22: print("对") print("聪明!") else: print("不对,再猜!")
ab7787f529cc428e231472dc1dee6046be989d6c
solderguy/Data_Analysis_Hmwk
/Python_Web_Intel_class/PA3_Mincemeat/example.py
730
3.53125
4
#!/usr/bin/env python # importing module import mincemeat # List with 4 elements data = ["Humpty Dumpty sat on a wall", "Humpty Dumpty had a great fall", "All the King's horses and all the King's men", "Couldn't put Humpty together again", ] # The data source can be any dictionary-like...
12a636e16d43a247e21244a9df05ce170d569528
Liketh/program
/railfence.py
655
3.859375
4
plain = input("Enter plaintext: ").replace(" ", "") ciphertext = input("Enter ciphertext: ") def cipher_encrypt(plain, key): result = "" matrix = [["" for x in range(len(plain))] for y in range(key)] increment = 1 row = 0 col = 0 for c in plain: if row + increment < 0 or row ...
a103e6f71651d9f2a8255391b7cabbca31af12ab
Liketh/program
/multi.py
82
3.78125
4
a=int(input("Enter a number")) b=int(input("Enter another number")) c=a*b print(c)
0c30187b15a528c0e43c711b109135740abd94d5
Chuset21/Learning-Python
/basics/chapter-two/is_vs_==.py
364
3.59375
4
def main(): print(True == 1) print('' == 1) print([] == 1) print(10 == 10.0) print(str([] == []) + '\n') # "is" compares memory location print([] is []) # Produces warning: "SyntaxWarning: "is" with a literal" print(True is 1) print('' is 1) print([] is 1) print(10 is 10...
ca6f42224e4a803faaf806c854a69eb50055f3d8
Chuset21/Learning-Python
/regular-expressions/password_validator.py
611
3.703125
4
import re # Password requirements: # - Minimum 8 characters long # - Contain at least one letter, one number and one symbol class PasswordValidator: _PATTERN = re.compile(r"^(?=.*[A-Za-z])(?=.*\d)(?=.*\W)[A-Za-z\d\W]{8,}$") @staticmethod def validate_password(password): return PasswordValidator._...
eab2f6b2bc990fc05d88c2767e1f1d72440a80f1
Chuset21/Learning-Python
/basics/chapter-one/tuples.py
338
3.71875
4
def main(): # immutable my_tuple = (1, 2, 3, 4, 5) print(my_tuple) print(5 in my_tuple) new_tuple = my_tuple[1:2] print(new_tuple) x, y, z, *other = my_tuple print(x, y, z, other) print(my_tuple.count(5)) print(my_tuple.index(5)) print(len(my_tuple)) if __name__ == '__ma...
16667daba920697643ae07db66be9a39e6cd54ef
TheSlientnight/Algorithms-and-Data-Structures
/Recursion/SierpinskiTriangle.py
1,324
3.75
4
import turtle def draw_triangle(points, color, mt): mt.fillcolor(color) mt.up() mt.goto(points[0][0], points[0][1]) mt.down() mt.begin_fill() mt.goto(points[1][0], points[1][1]) mt.goto(points[2][0], points[2][1]) mt.goto(points[0][0], points[0][1]) mt.end_fill() def get_midpoint...
b73ab6cfc37499e39b97864f4e486dbb59fd9c8f
TheSlientnight/Algorithms-and-Data-Structures
/Queue/JosephusPermutation.py
430
3.71875
4
from Queue import Queue def permutation(namelist, num): q = Queue() for name in namelist: q.enqueue(name) while q.size() > 1: for i in range(num - 1): q.enqueue(q.dequeue()) q.dequeue() return q.dequeue() print(permutation([num for num in range(1, 6)], 11)) prin...
9addfd53e9887334ada12704c10903d5bf6c9252
TheSlientnight/Algorithms-and-Data-Structures
/Searching/binarySearch.py
456
3.75
4
def binary_search(l, item): if len(l) == 0: return False else: midpoint = len(l) // 2 if l[midpoint] == item: return True elif l[midpoint] < item: return binary_search(l[midpoint + 1:], item) else: return binary_search(l[:midpoint], ite...
d1f0010c2db6a36517ba6c5ec70b537fffa159d9
TheSlientnight/Algorithms-and-Data-Structures
/Graph/KnightTour.py
2,141
3.53125
4
from KnightGraph import knight_graph def knight_tour(depth, path, vertex, limit): vertex.set_color('gray') path.append(vertex) if depth < limit: neighbors = order_by_available_moves(vertex) i = 0 done = False while i < len(neighbors) and not done: if neighbors[i...
3f08a352c34e194edb18abec48a17a9eb6a9558c
AndChen153/AP-Stat-scripts
/TwitterFollowerCounter/FollowerCounter.py
3,950
3.75
4
# https://www.geeksforgeeks.org/python-status-object-in-tweepy/ ''' Code to find tweets from memphis area and to count the follower counts for all unique accounts found. ''' import tweepy import time class TwitterClient(object): ''' twitter class for finding tweets from memphis area and counting the follwer c...
71d5c8ed0a18bf237a71d34c2930695c70f52755
NyasakiAT/PythonKata
/Kata_2.py
436
3.859375
4
""" Day 2 In this little assignment you are given a string of space separated numbers, and have to return the highest and lowest number. """ # My Solution def high_and_low(numbers): list = [int(x) for x in numbers.split()] list.sort() return f"{list[-1]} {list[0]}" # Highest rated solution on CodeWars ...
5dd663e6bdab750a4555aaa5c8ef3596900d31d6
NyasakiAT/PythonKata
/Kata_8.py
849
4.0625
4
""" Day 7 - Format a string of names like 'Bart, Lisa & Maggie'. Given: an array containing hashes of names Return: a string formatted as a list of names separated by commas except for the last two names, which should be separated by an ampersand. """ # My Solution def namelist(names): names = [n["name"] for n ...
89162ad764e901d52dc7b2c98094a6c345c9021f
HediBenMohand/PythonBoot
/maxOfThree.py
204
3.6875
4
def maxofthree(arg1, arg2, arg3): if arg1 > arg2 and arg1 > arg3: print(arg1) elif arg2 > arg1 and arg2 > arg3: print(arg2) else: print(arg3) maxofthree(4,2,3)
6c608ae98cf9e866ea721d4cc18566b18e4b4d59
VirusPC/learnTensorflow
/Pandas/practice2.py
757
3.875
4
import pandas as pd """ reindex 方法允许使用未包含在原始 DataFrame 索引值中的索引值。 请试一下,看看如果使用此类值会发生什么!您认为允许此类值的原因是什么? """ city_names = pd.Series(['San Francisco', 'San Jose', 'Sacramento']) population = pd.Series([852469, 1015785, 485199]) cities = pd.DataFrame({'City name': city_names, 'Population': population}) print(cities) print(...
1c1e1d3ca844047190d26f076966f03d6e2d896c
VirusPC/learnTensorflow
/Pandas/index.py
1,515
3.640625
4
import pandas as pd import numpy as np """Series 和 DataFrame 对象也定义了 index 属性, 该属性会向每个 Series 项或 DataFrame 行赋一个标识符值。 默认情况下,在构造时,pandas 会赋可反映源数据顺序的索引值。 索引值在创建后是稳定的;也就是说,它们不会因为数据重新排序而发生改变。""" city_names = pd.Series(['San Francisco', 'San Jose', 'Sacramento']) population = pd.Series([852469, 1015785, 485199]) cities = pd...
3581f3e2dab7ac8477880b588b50c43007dd46a8
Isaac3N/regexes
/pipecharacter.py
276
3.8125
4
#using the pipe character to match possible groups in regex import re manRegex = re.compile(r'Man(kind|hood|ly|chester|y)') match_object = manRegex.search('My Mankind was taken away from me from Manchester city. Now I do not Feel Manly anymore') print(match_object.group(0))
c9f73c82ff0a3b4efd5955a1056e4788ad5307ed
faisalmaqsood786/python-calculator
/Calculator.py
481
3.796875
4
class Calculator: def sum(self, nums): val = 0 for n in nums: val += n result = val return result def multiply(self, nums): val = 1 for n in nums: val *= n result = val return result def average(self, nums): val = 0 l = len(nums) nums_sum = self.sum(nums) ...
6c2da15181734c49ca67160ae301ab9e21f0d5c9
Janesh98/neural-networks-from-scratch-to-predict-stock-prices
/code/NeuralNetworks/FeedForward.py
3,063
3.65625
4
import numpy as np class FeedForward: def __init__(self, input = 2, hidden = 3, output = 1, learning_rate = 0.3): # number of nodes for each layer self.input_nodes = input self.hidden_nodes = hidden self.output_nodes = output # weight matrices # wih = weigh...
4197789c3784870cfad4b16ed75f5dda355d150f
matsumon/NP-Complete-Puzzle
/bulb.py
4,411
3.65625
4
import sys import time from random import seed from random import randint # generates random numbers def generateRandom(z): seed(1) i = 0 intArray = [[],[]] while i<z: intArray[0].append(randint(0,m-1)) intArray[1].append(randint(0,n-1)) i = i+1 return intArray # prints the board in a pretty ...
c11f77e76acd1aa9203487053dcf6c79c3ab32c6
beansrowning/PythonTings
/Tensorflow/MNIST.py
1,359
3.78125
4
#! Python 3.6 # softmax MNIST Classifier # Load MNIST from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets('MNIST_data', one_hot = True) # Import tensorflow import tensorflow as tf sess = tf.InteractiveSession() # Placeholders for images to be analyzed x = tf.placeholder(tf.fl...
6c821628ec464bf8db20b70caef9e25ae9e7b46f
joeyPark8/Hackman
/hackMan.py
1,517
3.5625
4
import random as r wordList = [ 'apple', 'iguana', 'hospital', 'argorithm', 'nullpointerexeption' ] word = wordList[r.randint(0, len(wordList) - 1)] wordLength = len(word) hintText = '-'*wordLength prize = 100000 * wordLength def returnIndexes(word, char): #알파벳 위치들을 리턴하는 함수 indexs = [] ind...
930aecf049feb7936e3d4755c3ec3c73bae6367c
AlgorithmWarriors/5dae700
/src/main/python/Chunghee/Level1/YearOf2016.py
249
3.609375
4
def solution(a, b): Dayoftheweek = ["THU","FRI","SAT","SUN","MON","TUE","WED"] DatofMonth = [31,29,31,30,31,30,31,31,30,31,30,31] date = 0; for i in range(1,a): date +=int(DatofMonth[i-1]) return Dayoftheweek[(date+b)%7]
642a7ebc017241a4720de63cb9c5d15a24dc91ba
TeknikhogskolanGothenburg/PGBPYH21_Programmering
/okt 6/oop_textadventure/player.py
2,379
4
4
from terminal_color import color_print class Player: def __init__(self, position): self.position = position self.inventory = [] def go(self, direction): """ Moves a player to a different room Parameters: direction: str, the direction the player should move....
c540a11bbd1a6c573363e7c64f5f2044d7a5f986
TeknikhogskolanGothenburg/PGBPYH21_Programmering
/okt 8/doubleeven1.py
217
3.78125
4
def main(): arr = [1, 2, 3, 4, 5, 6] new_arr = [] for value in arr: if value % 2 == 0: value *= 2 new_arr.append(value) print(arr) if __name__ == '__main__': main()
1f19f0d9c95005b7caaafa8ca9d74a95b1c4d6ab
TeknikhogskolanGothenburg/PGBPYH21_Programmering
/sep 15/func2.py
857
3.703125
4
def func(a, b, c, d=10, e=11): print(a, b, c, d, e) def func3(a, b, c, d=10, *, e=11): print(a, b, c, d, e) def func2(*args, **kwargs): print(type(args)) print(type(kwargs)) for key, value in kwargs.items(): print(key, value) def my_print(*args, sep=' ', end='\n'): # str_to_print =...
5a87b191c730a112b70a7e97eb3a3de0c9797746
TeknikhogskolanGothenburg/PGBPYH21_Programmering
/sep 17/crypto.py
454
3.703125
4
def main(): line = "Alice was beginning to get very tired of sitting by her sister on the" password = "s3cr37" encrypted = "" for i, c in enumerate(line): encrypted += chr(ord(c) ^ ord(password[i % len(password)])) print(encrypted) clear_text = "" for i, c in enumerate(encrypted): ...
883733d9c355f4f118b1f08e9b4d8d6b31036880
TeknikhogskolanGothenburg/PGBPYH21_Programmering
/sep 24/inheritance.py
862
3.765625
4
class Person: def __init__(self, name, email, phone): self.name = name self.email = email self.phone = phone def __str__(self): return f"{self.name} has email {self.email} and phone number {self.phone}!" class Teacher(Person): def __init__(self, name, email, phone, subject...
228e5e3c7ca9ae56d0b6e0874f592c58cbaadc24
TeknikhogskolanGothenburg/PGBPYH21_Programmering
/sep9/textadventure/game.py
2,467
4.3125
4
from map import the_map from terminal_color import color_print def go(row, col, direction): if direction in the_map[row][col]['exits']: if direction == "north": row -= 1 elif direction == "south": row += 1 elif direction == "east": col += 1 elif ...