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
b6105349fbed5d094f24c461803db87f70f1bfda
ymwondimu/LeetCode
/p43_multiply_strings.py
558
3.890625
4
def multiply(num1, num2): """ :type num1: str :type num2: str :rtype: str """ res = 0 x1 = convert_to_int(num1) num2 = num2[::-1] place = 0 for char in num2: y = ord(char) - ord('0') y_val = y * (10 ** place) res += x1 * y_val place += 1 ret...
91094417f2d8ce4c219648b15d49b9e7d8f3db71
ymwondimu/LeetCode
/p844_backspace_string_compare.py
451
3.734375
4
def backspaceCompare(S, T): """ :type S: str :type T: str :rtype: bool """ res1 = create_stack(S) res2 = create_stack(T) return res1 == res2 def create_stack(s): stack = [] for char in s: if char == "#": if len(stack) != 0: stack.pop() ...
9eeaeb736f8e80611a551357889bfd06085916ce
ymwondimu/LeetCode
/p138_copy_list_with_random_pointer.py
669
3.5625
4
# Definition for singly-linked list with a random pointer. class RandomListNode(object): def __init__(self, x): self.label = x self.next = None self.random = None from collections import defaultdict class Solution(object): def copyRandomList(self, head): """ :type ...
88d20d2aaaf55229657e145f2ee46e6a104dd9c6
ymwondimu/LeetCode
/p127_word_ladder.py
1,055
3.703125
4
from collections import deque from collections import Counter def ladderLength(beginWord, endWord, wordList): """ :type beginWord: str :type endWord: str :type wordList: List[str] :rtype: int """ counter = Counter(wordList) if len(beginWord) != len(endWord): return 0 q ...
157212ed1abd77424280ed2d68d61c0d5de5ed2b
ymwondimu/LeetCode
/p832_flipping_image.py
414
3.765625
4
def flipAndInvertImage(A): """ :type A: List[List[int]] :rtype: List[List[int]] """ if len(A) == 0: return A for i in range(len(A)): A[i] = A[i][::-1] row = A[i] for j in range(len(row)): A[i][j] = A[i][j] ^ 1 return A def main(): A = [[1,...
92ca069995b5b421a8a41856927aca0281f62b3f
ymwondimu/LeetCode
/p35_insert_position.py
428
3.984375
4
def searchInsert(nums, target): """ :type nums: List[int] :type target: int :rtype: int """ if len(nums) == 0: return 0 for i, num in enumerate(nums): if num >= target: return i return len(nums) def main(): input = [1,3,5,6] targets = [5,2,7,0] ...
b49a8155088c794799e763a3d43d12bd5fba57d6
alokjani/project-euler
/e4.py
845
4.3125
4
# A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99. # # Find the largest palindrome made from the product of two 3-digit numbers. def reverse(num): return int(str(num)[::-1]) def isPalindrome(num): if num == reverse(num): ...
645a8eb1574cafeee01305a552bf3612de23507e
nitesh31mishra/Sentiment-Analysis-of-tweets
/app.py
3,510
3.5
4
import streamlit as st import numpy as np import pandas as pd import plotly.express as px from wordcloud import WordCloud, STOPWORDS import matplotlib.pyplot as plt st.title("Sentiment Analysis of tweets") st.sidebar.title("Some of the options of US Airlines ") st.markdown("## Hey!, this is place where you can see ab...
b9e3143d0af29b741891cb1cf6cc4e9c1167210f
jwf-ai/algorithm
/qita/一维坐标的移动.py
1,086
3.609375
4
# encoding: utf-8 from queue import Queue def bfs(start,end,n): q = Queue() q.put((start,0)) visit = [0] * (n+1) visit[start] = 1 D = [0] * (n+1) P = [0] * (n+1) while q.empty() != True: dist, num = q.get() if dist == end: return num,D,P else: ...
dafc4704bf02978517b69473cb8f6db415938b34
NathanTan/Homework
/cs325/8 Queens Problem/8_queens_problem.py
618
3.984375
4
#!/bin/python3 # Program based off example provided here: # https://www.ploggingdev.com/2016/11/n-queens-solver-in-python-3/ def main(): print("In main") # Solve via backtracking def solve(board, col, size): # Base case if col >= size: return for i in range(size): if is_safe(boa...
e4feec5e5d97c4e3931707efe7bf2fa1246e2678
JFF-Bohdan/tamaku
/solver/solver_impl.py
743
3.78125
4
def find_best_step(v): """ Returns best solution for given value :param v: value :return: best solution or None when no any solutions available """ s = bin(v)[2:] r = s.find("0") l = len(s) - r if (r == -1) or ((l - 1) < 0): return None return 1 << (l - 1) def play_ga...
f03edb2cade4d7a1c9b532937dbd65d1e84dd56c
moribots/mlai
/hw_0/part_a.py
12,346
3.90625
4
#!/usr/bin/env python # use chmod +x file_name.py (+x grants executable permission) # use ./file_name.py to run """ Python 2.7 PEP8 Style Code submission for Homework 0 Part A Machine Learning & Artificial Intelligence for Robotics Data Set 0 Particle Filter (used in Part B) Data interpreted with Python's Pandas libra...
de3e8f3b215a976cc9c5f071b8f57e9459ec9607
nomihadar/Job-interviews-assignments
/Biolojic/biolojic_assignment.py
11,824
3.515625
4
''' Biolojic Assignment Submitted by Nomi Hadar March 2019 ''' import argparse import re import math from random import randrange # files names CODONS_FILE = "codon_frequence_table.txt" FASTA_FILE = "fasta_file.txt" RECOGNITION_SITES_FILE = "recognition_sites.txt" OUTPUT_NAME = "backtranslated_sequences.txt" CODON_SI...
de41c41c0747d2e77e5d09e0f67ead740c10b7ee
luizfernandolopes/pimoroni-pico
/micropython/examples/breakout_dotmatrix/bargraph.py
850
3.765625
4
import time import math import random from breakout_dotmatrix import BreakoutDotMatrix display = BreakoutDotMatrix() width = display.WIDTH height = display.HEIGHT values = [0, 0, 0, 0, 0] start_time = time.time() while True: # Add a new random value to our list and prune the list to visible values values.i...
749a5c4e9e8a731022a8f0e453bab6cca138151f
karvendhanm/MovieTweeting-Data
/recommender_tuning.py
5,739
3.515625
4
import numpy as np import pandas as pd data_dir = 'C:/Users/John/PycharmProjects/MovieTweeting-Data/data/' # Read in the datasets movies = pd.read_csv(data_dir + 'movies_clean.csv') reviews = pd.read_csv(data_dir + 'reviews_clean.csv') del movies['Unnamed: 0'] del reviews['Unnamed: 0'] def create_train_test(review...
31c26dbe36bddf05ed1a488f05bd98f41d90c097
pradoplucas/projectIA
/Scripts/dinoRedeNeural.py
5,807
3.671875
4
import random import numpy as np # Classe da rede neural em si class Neural(object): ''' e -> Camada de Entrada o -> Camada Oculta s -> Camada de Saida ''' def __init__(self, nos_e, nos_o, nos_s, data_pesos=None): self.nos_e = nos_e self.nos_o = nos_o self.nos_s = nos_s ...
bbe819ef32d7ac6249370ee268535aa01d9830b4
ameyvadnere/Fact-reader
/fact_reader.py
7,488
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' Created on: 25/4/21 15:16:30 (IST) @author: Ameya Vadnere @version: 1.0.0 Documentation: The following script reads randomly selected facts from a text file and speaks them out to the user. It uses Google's gTTS module to convert text to speech. The user can ...
0b836a2f75c8252798582cae0d151629a606d895
unnumsykar/Py-probs.
/guess_the_no_user.py
597
4.0625
4
import random def computer_guess(x): low = 1 high = x advice = "" while advice != 'c' and low != high: if low != high: guess = random.randint(low,high) else: guess = low #could be high also b/c low=high guess = random.randint(low, high) advic...
e3e1dc25059394a5f0051fec9e0c52d34a8f0f0e
aloneto/Hikvision-batch-configure
/teste incremento texto.py
1,185
3.609375
4
import threading from datetime import datetime, timedelta import time import threading msgnova1 = 'novamsg1' msgnova2 = 'novamsg2' msgnova3 = 'novamsg3' msgnova4 = 'novamsg4' msgnova5 = 'novamsg5' msgnova6 = 'novamsg6' ln1 = 'msg1' ln2 = 'msg2' ln3 = 'msg3' ln4 = 'msg4' ln5 = 'msg5' ln6 = 'msg6' lista = [ln1, ln2, l...
4cf60d5082d9268bd119d8dd54549aba4d681b34
Mohram13/mohram13.github.io
/loops.py
355
3.953125
4
name = "Mohammad Wasef Ramadan" for character in name: print(character) s = set() s.add(1) for i in s: print(i) setNames = {"Mohammad","wasef","Ramadan","Mohammad"} for i in setNames: print(i) print("") lstNames = ["Mohammad","wasef","Ramadan","Mohammad"] for i in lstNames: print(i) for i in [0,1,2,3...
b416b7dc3b46d91906541dece00c2f45a838c423
Mohram13/mohram13.github.io
/Flight.py
658
3.8125
4
class Flight(): def __init__(self, capacity): self.capacity = capacity self.passengers = [] def add_passenger(self,name): if not self.open_seats(): # same as if self.open_seats == 0 return False # more pythonic :) self.passengers.append(name) retur...
25a2d51b06bb968158b94562a37cab77c3a0313b
Neha-Nayak/Python_basics
/Basics/current_time.py
382
3.75
4
# -*- coding: utf-8 -*- """ Created on Thu Feb 4 22:13:59 2021 @author: Neha Nayak """ import datetime current_time= datetime.datetime.now().strftime("%H:%M:%S") print(current_time) # %H = Hour (24-hour clock) as a decimal number [00,23]. # %I = Hour (12-hour clock) as a decimal number [01,12]. # %M = Minute as a de...
4ef3d82ced24fa801d14987d4cf326df999456fc
Neha-Nayak/Python_basics
/Basics/n_numbers.py
485
4
4
# -*- coding: utf-8 -*- """ Created on Mon Feb 1 22:44:46 2021 @author: Neha Nayak """ # Python Program to Print Numbers from 1 to N n = int(input("Please Enter any Number: ")) i = 1 print("The List of Numbers from 1 to {0} are".format(n)) while ( i <= n): print (i, end = ' ') i = i + 1 #to check ...
18031f06f2808c1dd714f723015940b3e3adb840
Neha-Nayak/Python_basics
/Basics/formula_sq_sum.py
186
3.8125
4
# -*- coding: utf-8 -*- """ Created on Fri Feb 12 12:46:41 2021 @author: Neha Nayak """ import fun_sum_of_sqaures n=int(input("enter the number=")) print(fun_sum_of_sqaures.formula_sum(n))
91151e6b33e2f71934efabd7d8a1c6352d87908e
Neha-Nayak/Python_basics
/Basics/division.py
229
3.921875
4
# -*- coding: utf-8 -*- """ Created on Mon Feb 8 11:09:22 2021 @author: Neha Nayak """ import fun_division num=int(input("enter number:")) divisor=int(input("enter divisor:")) print("answer is=",fun_division.division(num,divisor))
b0b332d4796c8e4ba777d2c725bd2321f5123b06
Neha-Nayak/Python_basics
/Basics/iteration_sum.py
208
4.15625
4
# -*- coding: utf-8 -*- """ Created on Tue Feb 9 23:11:45 2021 @author: Neha Nayak """ import fun_sum_of_natural_numbers num=int(input("enter the number=")) print(fun_sum_of_natural_numbers.iteration_sum(num))
31c72932905c9e93a388a64317914221d294c7fe
miroli/temp_soc
/BaseScraper.py
1,685
3.515625
4
import json import requests from builtins import filter # python 2 class BaseScraper(): """ This scraper is messy, but serves the purpose of outlining the separation of concerns between the base scraper and the scraper implementations. """ def list(self): """ Lists all topics/d...
7901a55ad68abaaaafb016062afcf46ab8b2ae9d
SAddik13/Python-practice
/Operators.py
68
3.640625
4
x = 12 y = 3 print(x / y) print("And") x = 5 y = 3 print(x * y)
bd033b4bce41943a6cbc4430dfd4f4139a9e8a97
SAddik13/Python-practice
/Input.py
63
3.640625
4
username = input("Enter username:") print("Hello " + username)
cfe5e3b36c302083047f0d46d53dcac7d398a327
aman-berhe/Video-Scene-Segmentation
/codes/Subtitle.py
3,877
3.515625
4
""" Input: subtitle file start= end=endof(subtitle) functions--> get subtitlext (start,end) --> get subSentences (start, end, remove=otional) --> remove=binary: to remove texts that are not speech --> alignSub(bySeconds) --> to forward or backward the su...
f6a8da1bdb3d80fb5f9e254a75f94ebb19643a37
dtknowlove/LPython
/HelloWorld/TOOP2.py
474
3.84375
4
class Employee(): '员工基类' EmployeeCount=0 def __init__(self, name,salary): super(Employee, self).__init__() self.name = name self.salary = salary Employee.EmployeeCount+=1 def DisplayCount(self): print("Total employee count is:%d"%Employee.EmployeeCount) def ToString(self): print("Name:%s Salary:%d"%(se...
fe5e7451fde3ceeaae60af6cbb5c429786abe5a5
dtknowlove/LPython
/BasicTest/Grammar.py
1,468
4.09375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # print absolute value of integer # num = input('随意输入一个整数:') # num = int(num) # if num <= 0: # num=-num # print(num) # print('I\'m \"OK\"!') # print(r'''你是 # 一个 # 大SB # 哈哈 ''') # print(not(True or False)) # print(None) # a = 'ABC' # b = a # a = 'XYZ' # print(b) # PI ...
e5e66368e17b7c63a1a6f37e37e43664082b4e29
Centurywang/MyPythonCode
/Python初级/Python快速编程入门/Chapter 2/5_1.py
396
3.921875
4
''' 输入直角三角形的两个直角边的长度a、b,求斜边c的长度 ''' # 第一种 c = 根号下 a方 + b方 a = float(input('请输入边a长度:')) b = float(input('请输入边b长度:')) # 第三边长的平方等于两边平方和 c = (a*a + b*b) ** 0.5 print('斜边c的长度为:{}'.format(c)) # 第二种 c方 = a方 + b方 c = a*a + b*b c = c ** 0.5 print('%.2f'%c)
8cc6cd78cbf8369369928f30d83faf30fc4c1b6e
koonytrain/projects
/Python Sorting Data Project/detect_column_level_data_entry_errors.py
1,275
3.703125
4
# File: detect_column_level_data_entry_errors.py # The program will produce a diagnostic report that shows data entry errors that cause column # totals in the data to be out of balance. Will need to fix cleaned_data.txt until errors resolved. def main(): input_filename = input('Please enter the input filena...
0e2c76e856ee435dd7611bd9fb3d947e2105767f
akhilbommu/AlgoExpert.io
/FirstNonRepeatingCharacter.py
444
3.6875
4
def firstNonRepeatingCharacter(string): d = dict() for ch in string: if ch in d.keys(): d[ch] = d[ch]+1 else: d[ch] = 1 for key in d.keys(): if d[key] == 1: return string.index(key) return -1 print(firstNonRepeatingCharacter("abcdcaf")) print...
b7eaf0615b6cf10d8c888bff34bba57eee93d4cf
akhilbommu/AlgoExpert.io
/NodeDepths.py
700
3.796875
4
from binarytree import Node finalSum = 0 def nodeDepthHelper(node, currentSum): if node is None: return currentSum += 1 global finalSum finalSum += currentSum nodeDepthHelper(node.left, currentSum) nodeDepthHelper(node.right, currentSum) def nodeDepths(root): currentSum = 0 n...
88a887c81a1380bfc7babf1dc66ad9cc04b29890
akhilbommu/AlgoExpert.io
/BSTTraversal.py
1,057
3.8125
4
from binarytree import Node def inOrderTraverse(tree, array): if tree.left is not None: inOrderTraverse(tree.left, array) array.append(tree.value) if tree.right is not None: inOrderTraverse(tree.right, array) return array def preOrderTraverse(tree, array): array.append(tree.value...
ffa029530a275321a97bddacd41c41d67b131182
akhilbommu/AlgoExpert.io
/ThreeNumberSort.py
1,397
4.0625
4
def threeNumberSort(array, order): firstIndex,lastIndex = 0,len(array)-1 for i in range(len(array)): if array[i] == order[0]: array[firstIndex],array[i] = array[i],array[firstIndex] firstIndex += 1 #print(array,i) for i in range(len(array)-1,-1,-1): if array[...
e257472364600cd05a13e21af1ddb40d5b5a371e
akhilbommu/AlgoExpert.io
/Run-LengthEncoding.py
720
3.9375
4
def runLengthEncoding(string): chars = [] curr_char_length = 1 for i in range(1, len(string)): if string[i] != string[i - 1] or curr_char_length == 9: chars.append(str(curr_char_length)) chars.append(string[i - 1]) curr_char_length = 0 curr_char_length += ...
c5857455a28eba52326fbddc32fa34b6cb7500d1
waltersteven/patronesDiseno
/Practicando/singleton.py
528
3.5
4
class Alumno: #El uso de Singleton es para que una clase tenga una única instancia. instancia = None @classmethod #pasamos la clase como primer argumento en vez de la instancia de la clase (self) def get_instance(cls): if cls.instancia == None: cls.instancia = Alumno() return cl...
4933ef63776fd477b0a0df18538259124b40e61b
liupengzhouyi/LearnPython3
/刘心怡老师的练习/work1-2.py
727
4
4
# -*- coding: UTF-8 -*- # fileName:work1-1.py # author: liupeng # data : 2019-10-26 from _decimal import Decimal str1 = input("") strType = "" strValue = "" # 一个方法:分类字符串 def isChar(char): if char in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.']: return 1 else: return 0 for char in...
2f53bef302b93cea4f71960221b41e901e72fe46
liupengzhouyi/LearnPython3
/Python数据操作/️字符大小写转换/paly.py
424
3.84375
4
# 英文字符大小写 str = 'SdfrG qwkjb' str = str.lower() print(str) print(str.upper()) # 把所有字符中的小写字母转换成大写字母 print(str.lower()) # 把所有字符中的大写字母转换成小写字母 print(str.capitalize()) # 把第一个字母转化为大写字母,其余小写 print(str.title()) # 把每个单词的第一个字母转化为大写,其余小写
88620a9c680c7c15f61d3bfcbe0cf1fa20ab9977
liupengzhouyi/LearnPython3
/function/filter.py
278
3.765625
4
# filter L = [x + 3 for x in range(20)] def isCon(x): if x % 2 == 0: return True else: return False newL = filter(isCon, L) while True: try: print(next(newL)) except StopIteration: print(StopIteration.value) break
0d00db6a6b83d65dcc6fe03db6a6b87cbc15fb6a
liupengzhouyi/LearnPython3
/基础语法/Function/带参数的函数/index.py
131
3.828125
4
#!/usr/bin/python3.7 # 带参数的函数 def area(width, height): return width * height number = area(12, 2) print(number)
a5e7ca5b63cabd3e72600afd3b690c17b4a97425
liupengzhouyi/LearnPython3
/刘心怡老师的作业/work1-2.py
134
3.859375
4
# -*- coding: UTF-8 -*- # 文件名:work1-2.py radius = float(input()) area = 3.1415 * radius * radius print("{:.2f}".format(area))
fcb466bbc81e40d393ee4c94df635a75c5a62246
liupengzhouyi/LearnPython3
/基础语法/迭代器/生成器.py
297
3.734375
4
def fib(max): a, b = 0, 1 while max: r = b a, b = b, a + b max = max - 1 # print(b) yield r # yield有什么用? # 在这个程序中,返回r给print(i),执行万能之后,继续下一句 # using generrator for i in fib(5): print(i)
dc27eb49d70482adb11930e42a98447baec206d9
liupengzhouyi/LearnPython3
/OJ/test1003.py
1,465
3.828125
4
# -*- coding: UTF-8 -*- # -*- author: liupeng -*- # -*- fileName: test1003.py -*- # -*- data: 2019-11-19 -*- # -*- problem url: https://imustacm.cn/problem/getProblem/1003 import math as mh from decimal import Decimal # 导入math包 import math # 定义点的函数 class Point: def __init__(self, x=0, y=0): self.x = x ...
7693396b7897c724b53ce6ecb7df888efc5c1506
liupengzhouyi/LearnPython3
/刘心怡老师的作业/work2-1.py
1,663
3.6875
4
import turtle # 绘制太极图函数 def draw_TJT(R): turtle.screensize(800, 600, "blue") # 画布长、宽、背景色 长宽单位为像素 turtle.pensize(1) # 画笔宽度 turtle.pencolor('black') # 画笔颜色 turtle.speed(10) # 画笔移动速度 TJT_color = {1: 'white', -1: 'black'} # 太极图填充色 1 白色 -1 黑色 color_list = [1, -1] """ 先画半边,再画另一边 "...
406246afc5e09a1d685bd2a9c4efc8ffb098e7ff
jcobian/SmoothieMaker
/fruitdata.py
534
3.5625
4
''' Jonathan Cobian and Oliver Lamb Fruit Data class represents data that will be sent (and pickled) over the FruitConn ''' class FruitData(): def __init__(self,fruitInt=0,xpos=0,vspeed=0,foodType='fruit',fruitID=0,freezeDirection='',freezeID='',dataType='create'): self.dataType = dataType if dataType == 'create'...
f4b83ed552cc8a2d160107012e35620d547b5714
Ale08/Practicas-Keybot
/Prueba.py
327
3.515625
4
lista = ["Xime", "Nube","Abi", "Emi", "Isma"] lista_buena = [] def FRIENDS(x): for nombre in lista: if len(nombre) == 4: lista_buena.append(nombre) return lista_buena print FRIENDS(lista) def friend(x): lista = [] for nombre in x: if len(nombre) == 4: lista.append(nombre) retur...
3274598eb9be6f100b8ad76f67bbb7d127fc703c
ZAdamMac/python-enigma
/python_enigma/__main__.py
6,556
3.671875
4
"""An implementation of the Enigma Machine in Python. This is a toy project intending to implement the Enigma Machine as originally designed by Arthur Scherbius. Enigma was an electromechanical implementation of a polyalphabetic substitution cypher. It's no longer considered cryptographically secure, but the device it...
896e593db91bb5a4be781ab41aaf3a58b680d202
idanyamin/FromNandToTetris
/project 8/codeWriter.py
1,945
3.921875
4
from parser import * class CodeWriter: def __init__(self, file_name, parser): self.name = file_name self.parser = parser def file_to_list(self ,path): """ :param path: a string representation of file path :return: a list of lines from line 0 to line n-1 ...
7af68906d04bac1ddb9392fa054e2e61640dfde8
idanyamin/FromNandToTetris
/project 11/SymbolTable.py
2,305
3.609375
4
class SymbolTable: class Symbol: # constants ARGUMENT = 'argument' VAR = 'var' STATIC = 'static' FIELD = 'field' INT = 'int' CHAR = 'char' BOOLEAN = 'boolean' def __init__(self, type, kind,index): """ con...
f4478f9987432f3be398c644260a1bf774381cb1
5d5ng/Python_Study
/Quiz8.py
721
3.59375
4
class House: def __init__(self,location,house_type,deal_type,price,completion_year): self.location = location self.house_type = house_type self.deal_type = deal_type self.price = price self.completion_year = completion_year def show_detail(self): print...
74684a5f179ea3bfbee51841f386904bcd25ebfa
5d5ng/Python_Study
/클래스/스타크래프트 .py
4,733
3.59375
4
from random import * #일반 유닛 class Unit:#객체 def __init__(self,name,hp,speed): self.name = name self.hp = hp self.speed = speed print('{} 유닛이 생성되었습니다.'.format(name)) def move(self,location): print('[지상 유닛 이동]') print('{}:{}방향으로 이동합니다.[속도{}]'\ .format(se...
4ce1851b8e048daeb557c1a0fa8af7ea97d5c4f5
PlumpMath/SICPviaPython
/Chapter-2/2.2/Exercise-2.31.py
477
3.578125
4
# Scheme primitive procedures cons = lambda x, y: lambda m: m(x, y) car = lambda z: z(lambda p, q: p) cdr = lambda z: z(lambda p, q: q) makeList = lambda *items: None if items == () else cons(items[0], makeList(*items[1:])) mapList = lambda proc, items: None if items == None else cons(proc(car(items)), mapList(proc, cd...
30b6845a616383dd5d02bc9ae4b595967f7a8183
PlumpMath/SICPviaPython
/Chapter-3/3-3/3.3.1_mutable_list.py
2,876
3.859375
4
from scheme_primitive import * # Exercise 3.12 def last_pair(x): if cdr(x) == None: return x else: return last_pair(cdr(x)) def append_set(x, y): set_cdr(last_pair(x), y) return x x = scm_list("a", "b") y = scm_list("c", "d") z = append(x, y) scm_print(z) # (a, b, c, d) scm_print(cdr...
8d9e1297fb11b3ae96c6a17e34516c808c20d480
PlumpMath/SICPviaPython
/Chapter-2/2.3/Exercise-2.70.py
4,239
3.78125
4
# Scheme primitive procedures cons = lambda x, y: lambda m: m(x, y) car = lambda z: z(lambda p, q: p) cdr = lambda z: z(lambda p, q: q) cadr = lambda x: car(cdr(x)) cddr = lambda x: cdr(cdr(x)) caddr = lambda x: car(cdr(cdr(x))) cadddr = lambda x: car(cdr(cdr(cdr(x)))) makeList = lambda *items: None if items == () else...
7f960fc6c1c5bdacec540bedf386900f4bf6db5c
PlumpMath/SICPviaPython
/Chapter-2/2.3/Exercise-2.63.py
2,704
3.734375
4
# Scheme primitive procedures cons = lambda x, y: lambda m: m(x, y) car = lambda z: z(lambda p, q: p) cdr = lambda z: z(lambda p, q: q) cadr = lambda x: car(cdr(x)) caddr = lambda x: car(cdr(cdr(x))) makeList = lambda *items: None if items == () else cons(items[0], makeList(*items[1:])) appendList = lambda list1, list2...
5759376f52e7128fee2671376ba778b6260a8787
PlumpMath/SICPviaPython
/Chapter-3/3-1/3.1.1_local_state_variables.py
1,794
3.625
4
# Exercise 3.1 def make_accumulator(x): def new_func(y): nonlocal x x += y return x return new_func A = make_accumulator(5) print(A(10)) # 15 print(A(10)) # 25 # Exercise 3.2 from math import sqrt def make_monitored(f): def mf(x): if not hasattr(mf, "counter"): ...
1b4edd81b0998d416ddb734bab893c023f06024f
PlumpMath/SICPviaPython
/Chapter-1/1.2/Exercise-1.09.py
279
4.09375
4
def add1(a, b): if a == 0: return b else: return add1(a - 1, b) + 1 print(add1(4, 5)) # 9 # This is recursive def add2(a, b): if a == 0: return b else: return add2((a - 1), (b + 1)) print(add2(4, 5)) # 9 # This is iterative
b89649c11af1e0be26751722d67598274bddbca5
PlumpMath/SICPviaPython
/Chapter-3/3-3/3.3.4_a_simulator_for_digital_circuits.py
3,235
4.46875
4
# Exercise 3.28. # Define an or-gate as a primitive function box. Your or-gate constructor # should be similar to and-gate. def or_gate(a1, a2, output): def or_action_procedure(): if not hasattr(or_action_procedure, "new_value"): or_action_procedure.new_value = logical_or(get_signal(a1), ...
da7885baec19bd180ad0b347c56584f310a1d45c
qazx8855/study
/Untitled-1.py
665
3.5
4
from a1_support import * def compute_value_for_guess(word,start_index,end_index,guess)-> int: scores = 0 right_guess = word[start_index:end_index+1] print (right_guess) #test for i in range(0,len(right_guess)): if guess[i] == right_guess[i]: if guess[i] in VOWELS: ...
ba97da1250035109cb8ac052fe03dbdf93865cfc
Isaqb/Trab-TR1
/hammingtestes.py
4,772
3.640625
4
def autocompletar(cadena): ''' Buscamos las posiciones de los datos de paridad ''' # convertimos la cadena en lista cadena = list(cadena) x = posicion = 0 while posicion < len(cadena): posicion = 2 ** x # insertamos el valor de paridad if posicion < len(cadena): cadena.insert(posicion-1, "*") else: ...
261d43a661ff6f00d652a0e4220d6519fe8e7e71
yidezhangfei/pythonpractise
/com_pro.py
490
3.53125
4
# python3 # coding: utf-8 def comsumer(): r = "" while True: n = yield r if not n: return print ("[comsumer]: comsume %d" % n) r = "200 OK" def produce(comsumer, max): n = 1 comsumer.send(None) while n < max: print ("[produce] produce %d" % n) ...
cbe0bcc1ae3141ce29b23e759905466961df0066
danny-molnar/python-programming
/planets.py
204
3.59375
4
planets = "Jupiter" print(planets.upper()) print(planets.find('t')) print(planets.isalnum()) # some more examples of string object methods, see Intellisense for further info. # another line of comment
7902d520887cdf606a92a0e3f9cf093514c09f04
bijonguha/drishti
/class-agnostic-counting/src/onclick_cord2.py
643
3.609375
4
# -*- coding: utf-8 -*- """ Created on Wed Dec 18 16:51:06 2019 @author: IJR2KOR """ import numpy as np import matplotlib.pyplot as plt x = np.arange(-10,10) y = x**2 coords = [] def onclick(event): click = event.xdata, event.ydata if None not in click: # clicking outside the plot area produces a coordinate...
0b21b9b8961750384a6c8dc8c08bbdb311cf7451
dalalbhargav07/Coding-practice-test
/Question1/Solution1.py
824
3.875
4
# -*- coding: utf-8 -*- """ Created on Sun Feb 3 @author: dalalbhargav07 """ class Solution1(object): def replaceWords(self, leet, sentence): try: if (sentence == ''): return ('The input string was null.. Terminating the program') for x, y in leet.items(): ...
142a16964332e3ff918fad9ecdcaca110d6b089c
gjw199513/collections-module
/1-namedtuple.py
905
3.875
4
# -*- coding:utf-8 -*- __author__ = 'gjw' __time__ = '2018/1/17 0017 上午 9:44' from collections import namedtuple # 对于简单的数据,不需要对数据进行操作,可以不使用class,使用namedtuple User = namedtuple("User", ["name", "age", "height", "edu"]) # 可以直接对其赋值 user = User(name="bobby", age=29, height=175, edu="master") # 使用元组进行赋值 user_tuple = (...
a3d4aae0d7f045822492250c56244f50942de4de
AmanDubey10198/Max_sub_array
/Hiring_problem/in_place_random_hiring_problem.py
503
3.53125
4
# -*- coding: utf-8 -*- """ Created on Fri Jun 8 11:51:31 2018 @author: Aman Dubey """ def swap(x,y): return y,x import random x = [5,2,1,8,4,7,10,9,3,6] best = 0 m = len(x) for i in range(m): a = random.randint(0,m-1) x[i],x[a] = swap(x[i],x[a]) print(x) hiring_cost = 0 ind...
1789e3404dcb1d846ed98e87bd167b77ac61b025
DomfeLacre/zyBooksPython_CS200
/module4/TwoLetterDomainNames.py
554
3.890625
4
# print('Two-letter domain names:') # # letter1 = 'a' # letter2 = '?' # while letter1 <= 'z': # Outer loop # letter2 = 'a' # while letter2 <= 'z': # Inner loop # print('%s%s.com' % (letter1, letter2)) # letter2 = chr(ord(letter2) + 1) # letter2 = 0 # while letter2 <= 9: # print...
ae4af03c199d29518e50c2e5151b56cca30be250
DomfeLacre/zyBooksPython_CS200
/module6/module6Discussion_Temps.py
403
3.8125
4
temperatures = [ [32, 86, 212] , [0, 30, 100], [273, 303, 373]] # print(temperatures[1][1]) userInput = temperatures[0][1] for temp_row, row in enumerate(temperatures): for temp_index, temp in enumerate(row): print('Row: %d, Cell: %d, Temperature: %d' % (temp_row, temp_index, temp)) if userInput == tem...
ba45ec142bfa630c98d084d5c2b8439710ae2698
DomfeLacre/zyBooksPython_CS200
/module2/GradeCalculation.py
863
3.84375
4
# Calculates the overall grade for four equally-weighted programming assignments, # where each assignment is graded out of 50 points. # Hint: First calculate the percentage for each assignment (e.g., score / 50), # then calculate the overall grade percentage (be sure to multiply the result by 100). assignOne = float(i...
ee3f43d9120efc1037d5de4aefe93bcd4ea9fcad
DomfeLacre/zyBooksPython_CS200
/module3/AutoServiceInvoice/AutoServiceInvoice1_with_dict.py
2,232
4.25
4
# Output a menu of automotive services and the corresponding cost of each service. print('Davy\'s auto shop services') # Creat dict() to store services : prices servicePrices = { 'Oil change' : 35, 'Tire rotation' : 19, 'Car wash' : 7, 'Car wax' : 12 } print('Oil change -- $35') print('Tire rotation -...
0a17bfb11cdda597d527c25d658ee78bf727ad90
DomfeLacre/zyBooksPython_CS200
/module7/MasterPractice_List_Dicts.py
670
4.125
4
##### LISTS ##### # Accessing an Index of a List based on user input of a number: Enter 1 -5 ageList = [117, 115, 99, 88, 122] # Ways to to get INDEX value of a LIST: print(ageList.index(99)) # --> 2 # Use ENUMERATE to get INDEX and VALUE of LIST: for index, value in enumerate(ageList): print(index) print('...
c7ee4f852725ca7cd5683dc10cf9a12056ee7fc9
DomfeLacre/zyBooksPython_CS200
/module9/9_8_2_overloading.py
755
4.0625
4
class Time: def __init__(self, hours, minutes): self.hours = hours self.minutes = minutes def __str__(self): return '%d:%d' % (self.hours, self.minutes) def __lt__(self, other): if self.hours < other.hours: return True elif self.hours == other.hours: ...
0f258e95681f526eb76fd9123f927930e75c26df
DrDrei/Project-Ueler-Solutions
/python/Problem014.py
484
3.59375
4
import sys import math def value_return(n): if n % 2 == 0: return int(n/2) elif n % 2 == 1: return int(n*3+1) sequence = [13] count = 0 while sequence[-1] != 1: sequence.append(value_return(sequence[count])) count += 1 biggest = [0] for i in range(500001,1000000,2): sequence = [i] count = 0 while sequence[...
7d0c36b8c4f4a2fb1483ddc4e6c68838607a6197
ashishiit/workspace
/LovePython/FlattenMultilevelLinkedList.py
1,703
3.640625
4
''' Created on Dec 18, 2016 @author: S528358 ''' class Link: def __init__(self,data): self.data = data self.next = None self.down = None class FlattenLinkedList: def __init__(self): self.first = None def InsertFirst(self,data): NewLink = Link(data) NewLink.ne...
0a2dcbee5eb1549d8fae00df3c15ea0bfae51135
ashishiit/workspace
/LovePython/ListUnordered.py
3,076
3.578125
4
''' Created on Oct 27, 2016 @author: s528358 ''' # from nntplib import first class Link: def __init__(self, item): self.next = None self.data = item class UnOrdered: def __init__(self): self.first = None self.last = None def InsertFirst(self,item): NewLink = ...
eac0d2737765415de7746c5c8aed8891945c6b25
ashishiit/workspace
/LovePython/BalancedSymbol.py
1,489
3.8125
4
''' Created on Oct 22, 2016 @author: s528358 ''' class Balanced: def __init__(self): self.a = [] def Push(self,item): self.a.append(item) def Peek(self): return self.a[len(self.a)-1] def Pop(self): return self.a.pop() def IsEmpty(self): return self.a == [] ...
66c651d2f782baf10741722beac5667ed5d9549a
ashishiit/workspace
/LovePython/HackerRank_1.py
879
3.671875
4
''' Created on Nov 4, 2016 @author: s528358 ''' import math # from _ast import Num def Solution(num): return len(bin(num)[2:])-1 # test = int(math.sqrt(num)) # if test%2 == 0: # test = test - 2 # else: # test = test - 1 # return 2**test # num = num - 1 # while num...
eb242b6e9a6ae145fdb7e844df611a0da980a2e7
BlairWN/fkPyhon
/week13课后作业/地球三部曲词性分布统计/week13课后作业--地球三部曲统计.py
2,905
3.65625
4
#!/usr/bin/env python # coding: utf-8 # In[74]: #分别统计His_dark_meterials_full_en.zip和The_three_body_problem_full.zip 中所有不同类型词汇的分布比例。 #比如对于前者,统计其中英文单词中名词、形容词、副词等等占所有词汇的百分比; #对于后者,统计中文中各类词汇的占比。 import re import xlwt import csv import jieba import jieba.posseg as pseg from jieba import analyse from collections import Co...
9a0aed6ffe0ce4da7fa48ab17d166da40b14d352
rayga/n4rut0
/Downloads/uncompyle2-master/test/test_loops.py
674
3.5625
4
""" test_loops.py -- source test pattern for loops This source is part of the decompyle test suite. decompyle is a Python byte-code decompiler See http://www.crazy-compilers.com/decompyle/ for for further information """ for i in range(10): if i == 3: continue if i == 5: break print i, el...
9ef5490cd8428c7fb91f0ba9f29b161f3711bf82
nguyen-nhat-anh/clustering
/clustering_algorithm/sequential.py
7,141
3.5
4
import numpy as np from scipy.spatial.distance import pdist, squareform def bsas(data, threshold, max_n_clusters, metric='correlation', refine=False, merge_threshold=None): """ Clustering using Basic Sequential Algorithmic Scheme (BSAS) :param: data:numpy.array \n input data, array with shape (n_samp...
426c7006d7666c5be53b9c6f23807d3c79c5ba04
mfbalder/SQL_Exercise
/hackbright_app.py
2,956
3.59375
4
import sqlite3 DB = None CONN = None def get_student_by_github(github): query = """SELECT first_name, last_name, github FROM Students WHERE github = ?""" DB.execute(query, (github,)) row = DB.fetchone() return row def get_project_by_title(title): query = """SELECT title, description FROM Projects...
1bd3f4794221d794f7b681c0d84f657a5a3aec7f
JoraKaryan/Repository_600
/Home-01/ex-4a.py
137
3.671875
4
#ex-4a num = int(input("type a number")) num_change = list(str(num)) x = 0 for i in num_change: x = x + int(i) print(x)
a530473ca06eaf44b8cf4d400510366ddc31be78
JoraKaryan/Repository_600
/Home-01/ex-7.py
447
4.1875
4
#ex-7 bar = "What! is! this book about !this book! is about python coding" def foo(bar:str): for i in range(len(bar)): if 0 <= ord(bar[i]) <= 31 or 33<= ord(bar[i])<=64 or 91 <= ord(bar[i]) <= 96 or 123 <= ord(bar[i]) <= 127: bar= bar.replace(bar[i], "") return bar bar =...
0740e5b603ea23542d1f2ff4da6df5c0af686c9b
JoraKaryan/Repository_600
/Home-01/ex-3b.py
96
3.796875
4
#ex-3b string = input("type a word...") print(True if string == string[::-1] else False)
85ff739b4803ef3397d6e320b449e4ce232be955
HarshaniDil/HelloWorld_Python
/Dictonaries.py
605
4
4
customer = { "name": "Harshani Dilrukshi", "age": 30, "is_verified" : True } print(customer["name"]) print(customer['age']) print(customer.get("name")) print(customer.get("birthday","May 20 1996")) customer["name"] = "Imasha Madusani" print(customer["name"]) print("-------------------------------------...
da25f69f5c46bcf7169a6d863ff6bef7e99676cc
HarshaniDil/HelloWorld_Python
/exceptions.py
204
3.765625
4
try: age = int(input("Age: ")) income = 5000 results = income/age print(results) except ZeroDivisionError: print("age is not zero") except ValueError: print("Invalide input")
1c72f900cf9cc9675d27fdbe721f34d0d9607dd2
npc203/Random-programs
/binomial triangle(spacing problem).py
853
3.765625
4
from math import factorial n=int(input("Enter a number:")) a,b,j=1,1,0 k,x=n,1 u,v=0,0 def digits(n,r): q=int(factorial(n)/(factorial(n-r)*factorial(r))) return(q) for i in range(n): j=k-i-1 while j>0: print(end='\t') j-=1 ...
090c7cf97d6b162ed1330d705640eef9c5e5031f
npc203/Random-programs
/sum of digits.py
163
3.5
4
a=int(input("Enter a number:")) b=[] c=0 while a/10!=0: b.append(a%10) a=int(a/10) for i in range(len(b)): c=c+b[i] print("Sum of digits:",c)
e9d32e82c12f76e55293a34297c8259ca063855d
npc203/Random-programs
/designs/Word designs.py
465
3.84375
4
def ascend(a): n=len(a)-1 j,i=0,0 while i<=n: while j<=i: print(a[j],end=' ') j=j+1 print(end='\n') i=i+1 j=0 def descend(a): n=len(a)-1 j,i=0,0 x=0 while i<=n: while j<=n-x: print(a[j],end=' ')...
0157da23eacd83e3bf6ee9f7f4075c90e131798e
JoeCP17/algorithm-day-1-
/06_find_not_repeating_first_character.py
1,782
3.5625
4
#다음과 같이 영어로 되어 있는 문자열이 있을 때, # 이 문자열에서 반복되지 않는 첫번째 문자를 반환하시오. # 만약 그런 문자가 없다면 _ 를 반환하시오. (응용) input = "abadabac" def find_not_repeating_character(string): alphabet_array = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "...
3b3c1110fd920f34e35dbc55beb38d9b3ecb16cc
calvinjlzhai/Mini_quiz
/Mini_quiz.py
2,737
4.28125
4
#Setting score count score = 0 #Introducation for user taking the quiz print("Welcome to the quiz! Canadian Edition!\n") #First question with selected answers provided answer1 = input("Q1. What is the capital of Canada?" "\na. Toronto\nb. Ottawa\nc. Montreal\nd.Vancouver\nAnswer: ") # Account for...
e80c70e76564dea7c63f8231426b393f16dee17e
yanstolyarov/praktika
/old/button_script.py
773
3.546875
4
from RPi import GPIO import time import os #initialise a previous input variable to 0 (assume button not pressed last) prev_input = 0 #adjust for where your switch is connected GPIO.setmode(GPIO.BCM) GPIO.setup(17,GPIO.IN) GPIO.setup(10,GPIO.IN) prev1 = 1 prev2 = 1 curr1 = 1 curr2 = 2 def button1_status(pin): g...
ac5c1ded4d03d0f5f8cfc56a4e9aad5c6eb34c15
HaochenYang1996/algorithms
/5-LongestPalindromicSubstring.py
790
3.59375
4
class Solution(object): def longestPalindrome(self, s): """ :type s: str :rtype: str """ palindrome = "" lens = len(s) for i in range(lens): pOneCenter = self.findLongestPalindrome(s, i, i) pTwoCenters = self.findLongestPalindrome(s, i,...
2c9f81dc71833f3a882e1472e5df40c089ef82ae
jjyycy/Python-course-files
/Financial Computing Python/plot_rates.py
4,528
3.546875
4
from urllib.request import urlopen from bs4 import BeautifulSoup html = urlopen('https://www.treasury.gov/resource-center/' 'data-chart-center/interest-rates/Pages/' 'TextView.aspx?data=yieldYear&year=2017') # BeautifulSoup Yield Curve data bsyc = BeautifulSoup(html.read(), "lx...
4f94cdd8a26f822a90f17e40c9d3a30a04923e0f
kalmuzaki/Card-Classes
/Deck.py
749
3.640625
4
from Card import * from random import randrange class Deck: def __init__(self): self.cards = [] for s in Suit: for v in Value: self.cards.append(Card(s,v)) def shuffle(self): shuffledDeck = [] #Shuffle all but the last remaining car...
2f461affde47c989f1c8c474a31f959feea0baf7
DhruviJain15/Python-Programs
/sumofdigits.py
187
3.78125
4
''' logic: f(n)=(n%10)+f(n//10) ''' def sum_of_digits(n): if(n==0): return 0 else: return (n%10)+sum_of_digits(n//10) print(sum_of_digits(1234))