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
4ed4abfa725430645930e22b4c58cc547f318d87
ejsimley/OpenOA
/operational_analysis/toolkits/power_curve/parametric_forms.py
2,024
3.96875
4
import numpy as np """ Power Curves These curve functions are written in the style of Scipy.optimize: fun : callable The objective function to be minimized. fun(x, *args) -> float where x is an 1-D array with shape (n,) and args is a tuple of the fixed parameters needed to completely specify the function. ref: http...
3a3aa72bb5e666eec3dc5393e5e78f31518c0c38
txazo/txazodevelop
/python/test/21.py
560
4.03125
4
# -*- coding: utf-8 -*- # 词典dict:元素没有顺序 dic = {'tom' : 12, 'sam' : 32} print dic, type(dic) print dic['tom'] dic['sam'] = 30 print dic print len(dic) print '----------' dic = {} print type(dic) dic['lili'] = 90 print dic print '----------' dic = {'tom' : 12, 'sam' : 32, 'lili' : 50} for key in dic : print key...
fc9ae2f27b799e6c605421e2c01cff6989be0fd5
txazo/txazodevelop
/python/lession/Python-列表.py
1,018
4.3125
4
# ********************< 列表 >******************** list = [1, 2, 3, 4] print type(list), list # <type 'list'> [1, 2, 3, 4] # ********************< list函数 >******************** list = list("1234") print type(list), list # <type 'list'> [1, 2, 3, 4] # ********************< 列表元素赋值 >******************** list[0] = 1 # *...
6a7802f24104283c5a407d7a03eda1e6141ce964
xiaozuo7/algorithm_python
/normally_sort/bubbleSort.py
1,613
3.96875
4
# -*- coding: utf-8 -*- """ 冒泡排序(Bubble Sort)也是一种简单直观的排序算法。 它重复地走访过要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来。 走访数列的工作是重复地进行直到没有再需要交换,也就是说该数列已经排序完成。这个算法的名字由来是因为越小的元素会经由交换慢慢"浮"到数列的顶端。 作为最简单的排序算法之一,冒泡排序给我的感觉就像Abandon在单词书里出现的感觉一样,每次都在第一页第一位,所以最熟悉。 冒泡排序还有一种优化算法,就是立一个 flag,当在一趟序列遍历中元素没有发生交换,则证明该序列已经有序。 但这种改进对于提升性能来说并没有什么太大作用。 最快:当...
6c0cfebf5346b303f5e4bb467576a79e33c60b2a
xiaozuo7/algorithm_python
/leetcode_回文数.py
731
3.953125
4
# -*- coding: utf-8 -*- """ 判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。 示例 1: 输入: 121 输出: true 示例 2: 输入: -121 输出: false 解释: 从左向右读, 为 -121 。 从右向左读, 为 121- 。因此它不是一个回文数。 示例 3: 输入: 10 输出: false 解释: 从右向左读, 为 01 。因此它不是一个回文数。 解题思路:转字符串判断 @author: xiaozuo """ class Solution: def isPalindrome(self, x:int) -> bool: ...
d516c3ff37b037571c10baad8039618c8ba6aebc
xiaozuo7/algorithm_python
/normally_sort/insertionSort.py
1,021
4.0625
4
# -*- coding: utf-8 -*- """ 插入排序是一种最简单直观的排序算法。 插入排序的代码实现虽然没有冒泡排序和选择排序那么简单粗暴,但它的原理应该是最容易理解的了,因为只要打过扑克牌的人都应该能够秒懂。 它的工作原理是通过构建有序序列,对于未排序数据,在已排序序列中从后向前扫描,找到相应位置并插入。 插入排序和冒泡排序一样,也有一种优化算法,叫做拆半插入。 --------------------- 复杂度分析: O(n^2) @author: xiaozuo """ def insertionSort(arr): n = len(arr) for i in range(n): ...
55dd4ea7ae100bf2ecfcdd2d50fe37e7eed76e4f
xiaozuo7/algorithm_python
/leetcode_删除链表倒数第n个节点.py
1,031
3.734375
4
# -*- coding: utf-8 -*- """ 给定一个链表,删除链表的倒数第 n 个节点,并且返回链表的头结点。 示例: 给定一个链表: 1->2->3->4->5, 和 n = 2. 当删除了倒数第二个节点后,链表变为 1->2->3->5. 思路:使用快慢指针,快指针先移 n 个节点,接下来,快慢指针一起移动,两指针之间一直保持 n 个节点,当快指针到链表底了,操作慢指针,删除要删除的元素! 时间复杂度:O(n) @author: xiaozuo """ #Definition for singly-linked list. class ListNode: def __init__(self, x): ...
0b6a2f6351cdec7a7e399a9e99b43aeb075909bc
xiaozuo7/algorithm_python
/offer/FindContinuousSequence.py
1,160
3.578125
4
#!/usr/local/anaconda3/bin/python3 # -*- coding: utf-8 -*- """ 题目描述 小明很喜欢数学,有一天他在做数学作业时,要求计算出9~16的和,他马上就写出了正确答案是100。 但是他并不满足于此,他在想究竟有多少种连续的正数序列的和为100(至少包括两个数)。 没多久,他就得到另一组连续正数和为100的序列:18,19,20,21,22。现在把问题交给你, 你能不能也很快的找出所有和为S的连续正数序列? Good Luck! 输出描述: 输出所有和为S的连续正数序列。序列内按照从小至大的顺序,序列间按照开始数字从小到大的顺序 思路:滑动窗口 @author: xiaozu...
6274f7cd8ef8da48495b24611b6f73766e3d6ec8
xiaozuo7/algorithm_python
/leetcode_分割回文串.py
667
3.5625
4
# -*- coding: utf-8 -*- """ 给定一个字符串 s,将 s 分割成一些子串,使每个子串都是回文串。 返回 s 所有可能的分割方案。 示例: 输入: "aab" 输出: [ ["aa","b"], ["a","a","b"] ] 思路:回溯递归 @author: xiaozuo """ class Solution: def partition(self, s: str): if not s:return [[]] n = len(s) res = [] for i in range(n): tmp...
87587bc09dbb09495fe85c0ff2f478d7c59ef241
xiaozuo7/algorithm_python
/leetcode_括号生成.py
913
3.796875
4
# -*- coding: utf-8 -*- """ 给出 n 代表生成括号的对数,请你写出一个函数,使其能够生成所有可能的并且有效的括号组合。 例如,给出 n = 3,生成结果为: [ "((()))", "(()())", "(())()", "()(())", "()()()" ] 思路: 回溯 如果有位置放左括号就放,如果放有括号的剩余位置大于左括号,就放右括号。 @author: xiaozuo """ class Solution: def generateParenthesis(self, n): res = [] self.backtrack(...
ac617426780e675ccf960c3a2b4bf49999910f75
xiaozuo7/algorithm_python
/offer/GetNumberOfK.py
391
3.53125
4
#!/usr/local/anaconda3/bin/python3 # -*- coding: utf-8 -*- """ 统计一个数字在排序数组中出现的次数。 @author: xiaozuo """ class Solution: def GetNumberOfK(self, data, k): # write code here import collections d = collections.Counter(data) for key, value in d.items(): if key == k: ...
1538f6a95422dd94d224ad8d23b9bb875f5ac5c6
xiaozuo7/algorithm_python
/leetcode_验证回文串.py
852
3.84375
4
# -*- coding: utf-8 -*- """ 给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写。 说明:本题中,我们将空字符串定义为有效的回文串。 示例 1: 输入: "A man, a plan, a canal: Panama" 输出: true 示例 2: 输入: "race a car" 输出: false 正常思路: 双指针 py人的思路 filter过滤 也可用re @author: xiaozuo """ import re class Solution: def isPalindrome(self, s: str) -> bool: res...
69e2bc5f868b1ea550b41f3ef82822f35a339c79
xiaozuo7/algorithm_python
/company/bilibili_niudanji.py
1,207
3.84375
4
#!/usr/local/anaconda3/bin/python3 # -*- coding: utf-8 -*- """ 22娘和33娘接到了小电视君的扭蛋任务: 一共有两台扭蛋机,编号分别为扭蛋机2号和扭蛋机3号,22娘使用扭蛋机2号,33娘使用扭蛋机3号。 扭蛋机都不需要投币,但有一项特殊能力: 扭蛋机2号:如果塞x(x范围为>=0正整数)个扭蛋进去,然后就可以扭到2x+1个 扭蛋机3号:如果塞x(x范围为>=0正整数)个扭蛋进去,然后就可以扭到2x+2个 22娘和33娘手中没有扭蛋,需要你帮她们设计一个方案,两人“轮流扭”(谁先开始不限,扭到的蛋可以交给对方使用), 用“最少”的次数,使她们能够最后恰好扭到N个交给小电视君...
c104fe48cf4f956b93ca1438a75dab691ba0e787
xiaozuo7/algorithm_python
/offer/Find.py
1,112
3.703125
4
# -*- coding: utf-8 -*- """ 在一个二维数组中(每个一维数组的长度相同), 每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。 请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。 @author: xiaozuo """ class Solution: """二维数组查找target""" def Find(self, target, array): # write code here if len(array)<1 or len(array[0])<1:return False n = len...
c5d4f4577e577bc1be422eb4e72c2c6b1f0363e1
xiaozuo7/algorithm_python
/normally_sort/selectionSort.py
575
4
4
# -*- coding: utf-8 -*- """ @author: xiaozuo """ def findSmallest(arr): """存储最小的值""" smallest = arr[0] smallest_index = 0 for i in range(1, len(arr)): if arr[i] < smallest: smallest = arr[i] smallest_index = i return smallest_index def selectionSort(arr): """选择...
bf9eecfa947baf88c11a9d00795793ed0312f088
Teclanat/Curso_Python
/03_Calcular_Raio_Circulo.py
213
3.921875
4
__author__ = 'Natanael' #Calcular a área de um círculo raio = int(input("Informar o raio do círculo a ser calculado: ")) area = 3.1415926 * raio * raio print("A area de um círculo de raio ",raio,"é",area)
c1f4f21c908dd6c8862868a096e012b77301831e
Teclanat/Curso_Python
/21_Vetores.py
346
4.125
4
__author__ = 'Natanael' #Trabalhando com Vetores #Inicializando o vetor vetor = [] n = int(input('Digite a quantidade de elementos a ser adicionada: ')) i = 0 while i < n: temp = input('Digite o elemento a ser adicionado: ') #Uso de append = adiciona um elemento no vetor vetor.append(temp) i = i + 1 ...
aab9a8aa79957ed352052c247880a05054c0f7ee
Teclanat/Curso_Python
/10_Equacao_2_Grau.py
745
3.96875
4
__author__ = 'Natanael' #Calcular uma Equação de 2º Grau import math #Entrada de Dados a = int(input('Informe o valor para o termo a: ')) b = int(input('Informe o valor para o termo b: ')) c = int(input('Informe o valor para o termo c: ')) #Calculo do Delta delta = b * b - 4 * a * c #Caso o Delta seja menor que 0 i...
ba71b7a9e222886161eba3f31fe6db67e1f5fe4e
Teclanat/Curso_Python
/44_Grafos - AGM.py
7,479
3.53125
4
__author__ = 'Natanael' """ Trabalhando com Grafos - Busca em Largura """ class Vertice: def __init__(self, rotulo): self.rotulo = rotulo self.visitado = False def igualA(self,r): return r == self.rotulo def foiVisitado(self): return self.visitado def regVisitado...
ba89d73f04b7467b8f857c78fb78ad464fbeb176
Teclanat/Curso_Python
/30_Tabuada_Usando_Laços.py
243
3.625
4
__author__ = 'Natanael' i = 1 print('Tabuada de Multiplicar') while i < 10: j = 1 print('-------- Tabuada do ',i,'-----------') while j <= 10: print(i,"*",j," = ", i * j) j = j + 1 i = i + 1 #Fim do programa
e383e92e91646a1c50dbf7a9ab86912c274bbfab
samikhalildev/DSA
/DataStructures/Graph/Graph.py
7,472
3.59375
4
''' A graph is a collection of nodes, where each node can link to another node containing edges. - It can either directed a->b or undirected a-b. - Edges can carry weights. When to use: - When you want to represent data and its relationship e.g. a social network where alex is a frien...
5c5625cca2c934141df40410f1496302c699da06
brasqo/pyp-w1-gw-language-detector
/language_detector/main.py
846
4.125
4
#!/usr/bin/python # -*- coding: utf-8 -*- from collections import defaultdict import operator """This is the entry point of the program.""" def detect_language(text, languages): """Returns the detected language of given text.""" # implement your solution here # create dictionary with same keys as l...
4c2781eff792d435938154f3b497800b106f15ee
dan-zeman/udapi-python
/udapi/block/ud/joinasmwt.py
913
3.53125
4
"""Block ud.JoinAsMwt for creating multi-word tokens if multiple neighboring words are not separated by a space and the boundaries between the word forms are alphabetical. """ from udapi.core.block import Block class JoinAsMwt(Block): """Create MWTs if words are not separated by a space..""" def process_nod...
8c5669b43658f4eaa2abf85e6f6b1fb6e4844c48
cciprianmihai/CS231n-Stanford-University
/01_Classification_KNN.py
883
3.546875
4
from cs231n.data_utils import load_CIFAR10 from KNearestNeighbors import * # Load CIFAR10 dataset Xtr, Ytr, Xte, Yte = load_CIFAR10('cs231n/data/cifar10') # Take only first 10 images to train the model Xtr = Xtr[0:10] Ytr = Ytr[0:10] # Flatten out all images to be one-dimensional array of 32 * 32 * 3 = 3072 Xtr_rows = ...
29d9dd8146e1fd5215e38106d80f7d694cae9712
okorach/excel-tools
/bourso_cb.py
1,608
3.53125
4
#!python3 import sys months = {"janvier": 1, "février": 2, "mars": 3, "avril": 4, "mai": 5, "juin": 6, "juillet": 7, "août": 8, "septembre": 9, "octobre": 10, "novembre": 11, "décembre": 12} jour = r"(0?\d|[12]\d|3[01])" year = r"202\d" no_cb, nom_cb = "CB Débit différé Elodie", "CB Débit différé Elodie" step...
2d0c85fd0668f330f21d0049447902600027e588
lodeous/gencon-nlp
/data_processing/topic.py
3,177
3.5625
4
import requests import os from bs4 import BeautifulSoup import re from matplotlib import pyplot as plt import numpy as np import re import pandas as pd def get_title(filename="test.html"): """Read the specified file and load it into BeautifulSoup. Return the title tag """ with open(filename, "r") as my_fi...
461a1c190da31c9a9254ccd71f0515bcf6fde723
huzecong/nnlib
/nnlib/utils/string.py
1,028
3.625
4
from typing import List __all__ = ['ordinal', 'to_camelcase', 'to_underscore', 'to_capitalized'] def ordinal(x: int) -> str: suffix = 'th' if 10 <= x % 100 < 19 else {1: 'st', 2: 'nd', 3: 'rd'}.get(x % 10, 'th') return str(x) + suffix def _get_name_pieces(name: str) -> List[str]: if '_' in name: ...
7868799302bd5cf0fd6ef1b24d504fa1dff64a40
huzecong/nnlib
/nnlib/utils/functional.py
4,597
3.578125
4
from functools import reduce from typing import Any, Callable, Iterable, Iterator, List, Optional, Sequence, TypeVar, overload __all__ = ['scanl', 'scanr', 'is_none', 'not_none', 'filter_none', 'split_according_to', 'split_by'] A = TypeVar('A') B = TypeVar('B') # This is what happens when you don't have the Haskell...
cbc55987804632dbc05b38141bb943c22ecb3979
marydCodes/jetbrains_loancalculator
/dreamworld.py
1,062
4
4
from math import ceil principal = float(input("Enter the loan principal: ")) print(""" What do you want to calculate? Enter 'm' to know how many months it will take to pay off the loan. Enter 'p' to know how much you should pay per month. """) selection = input() if selection == "m": mthly_pay_amt = int(input("En...
7065a79513e068afaca2b397a7b550893341fc8c
JaneyJiang/PythonTools
/algorithm_test.py
565
3.609375
4
import unittest from algorithm import QuickSort class AcronymTest(unittest.TestCase): def test_basic_inorder(self): self.assertEqual(QuickSort([1,2,3,4,5,6]).Sort(), [1,2,3,4,5,6]) def test_basic_reverse(self): self.assertEqual(QuickSort([6,5,4,3,2,1]).Sort(), [1,2,3,4,5,6]) def test_basic_...
6ac1c2a64542f19f216e7bf00b3ba014eb21c3b8
ajitabhkalta/Python-Training
/loops/char_count.py
213
3.875
4
str1=input("Enter string:") str2=input("Enter character to search:") index=-1 num_times=str1.count(str2) for _ in range(num_times): index=str1.find(str2,index+1) print(f"{str1} found at {index+1} postion")
a499f51f43c0346d4f9c62380094e177a7240fa2
ajitabhkalta/Python-Training
/bitwise.py
526
4.0625
4
num=int(input("Enter any number:")) pos = int(input("Enter bit position:")) print(f"Bin equivalent of given number {num} is",bin(num)) x= num| (1<<(pos-1)) print(f"Val after setting bit at position {pos} in number {num} is",x ) print(f"Bin equivalent is",bin(x)) x =num & (~(1<<(pos-1))) print(f"Val after clearing bit a...
4ab9acb1f915fff7ff3e6973badaeacc511ac002
ajitabhkalta/Python-Training
/patterns/patterns3.py
562
3.96875
4
no_of_rows=eval(input("Enter no of rows:")) print_char = input("Enter char to print in pattern:") curr_row=1 for row_num in range(no_of_rows,0,-1): for _ in range(row_num,0,-1): print(print_char,end="") for _ in range(1,2*curr_row-1): print(" ",end="") curr_row+=1 for _ in range(row_num,...
ce81839ed6ad8f2922d7f0292702e2a8adde3b69
ajitabhkalta/Python-Training
/patterns/patterns4.py
179
4.09375
4
rows = int(input("Enter no of rows:")) x=input("Enter char to print in pattern:") for i in range(1,rows+1): for _ in range(1,rows): print(x,end=" ") print("")
03c1c69c3abfd27a02516f1b7cf79c20e539129a
ajitabhkalta/Python-Training
/loops/while.py
90
3.921875
4
num = abs(int(input("Enter a number:"))) while num: print(f"{num}",end=" ") num-=1
f32231edd69b63f86cdef154325a5a89c0568ecd
ajitabhkalta/Python-Training
/input.py
587
4
4
inp1=input("Enter your name:") print(type(inp1)) inp2=input("Enter your age:") print(type(inp2)) print("Hi",inp1,"Your age in days is:",(inp2*365)) #To avoid having input as always string #Type conversion #Using eval #Using type conversion inp1=input("Enter your name:") print(type(inp1)) inp2=int(input("...
6a942037dd82ad4ab67f436f21c6d22a8b4400a5
Terencetang11/Sudoku_Puzzle
/Sudoku.py
7,570
3.90625
4
# Author: Terence Tang # Class: CS325 Analysis of Algorithms # Assignment: Portfolio Project - Sudoku Puzzle Game # Date: 3/8/2021 # Description: Program for running a sudoku game through command line interface. Contains a class for the Sudoku # puzzle game which will generate a random game from a give...
465fda8d9d7d058940ddf606d7b4a67865bcb964
ngthao/123
/calcthetemp.py
110
3.625
4
c = input("Enter temperature in Centigrade:") f = (9*(int(c))/5)+32 print ("Tempurature in Fahrenheit is: ",f)
2770bcf0df0cccb976c538157432ed4c8782bc25
MariamBilal/TitanicSurvival_Kaggle
/Titanic_project/titanic_survival.py
4,418
3.71875
4
""" Titanic Survival Prediction """ """ ---------------------- Training ----------------------- """ # ------- importing liabraries import pandas as pd from sklearn.preprocessing import LabelEncoder from sklearn import tree # --------- importing training dataset train_dataset =...
f150ef7bcddbc507f2337f622e8892dcd384f5e4
cristnascimento/spark-project
/champions/counter.py
576
3.59375
4
from pyspark import SparkContext, SparkConf if __name__ == "__main__": conf = SparkConf().setAppName("champions counter").setMaster("local") sc = SparkContext(conf = conf) rdd = sc.textFile("champions.txt") # Team name teams = rdd.map(lambda line: line.split(",")[2]) # How many years it ...
6e64148d4253db15fa459a1ad16cecf615d3e931
ossuaryy/0511
/DNA.py
630
3.78125
4
def comp(seq): comp_dict={'A':'T', 'T':'A', 'G':'C', 'C':'G'} seq_comp= "" for char in seq: seq_comp += comp_dict[char] return seq_comp def rev(src): seq_rev = "".join(reversed(src)) return seq_rev def comp_rev(src): tmp = comp(src) return rev(tmp) src = input("...
17b94d748e67b9883831c7b2327825de9daa4885
rosejb/ScratchProblems
/CaseInsenEditDistComp.py
1,850
3.578125
4
def case_insen_compare(s1, s2, tol): if abs(len(s1) - len(s2)) > tol: return False init_work = {'words': sorted([s1, s2], key=len), 'mismatches': 0} work_items = [init_work] for work_dict in work_items: s1 = work_dict['words'][0] s2 = work_dict['words'][1] mismatch_coun...
21385cd64f82ada4dfc0673ec925d4810189669f
pesaventofilippo/sudokuSolver
/exceptions.py
641
3.546875
4
# Board Exceptions class InvalidSizeBoardError(Exception): def __init__(self): self.message = "Cannot create a board of this size. Size must be either 4, 9, or 16." class InvalidCharactersError(Exception): def __init__(self): self.message = "The board contains invalid characters. They must be...
3e18f60351aff902db492324de7edd60ed0ec6e0
priyanka1706/Machine-Learning-Codes
/k_near_neighbors.py
1,495
4
4
# K Nearest Neighbors is a simple and effective machine learning classification algorithm overall. # K is a number you can choose, and then neighbors are the data points from known data. # We're looking for any number of the "nearest" neighbors. # Let's say K = 3, so then we're looking for the two closest neighborin...
87fd46bf4e9acd79d5070eaf2456e2f6da7b23a7
simona-boop/esposito
/stringa 2.py
298
3.671875
4
s=str(input("Inserisci una stringa: ")) ripetizioni=0 for i in range(0, len(s)): r=l x=s[i] for j in range(i+l, len(s)): if s[i] == s[j]: r = r + l if r > ripetizioni: carattere = x ripetizioni = r print(carattere) print(ripetizioni)
f8fef728afa55e7a26ebb97e601f1c96a16c3460
pranoothatwar/assessment
/day_2/2.py
193
3.78125
4
inp = (raw_input("give temp of form 23C or 23F: ")) unit = inp[-1] temp = int(inp[:-1]) if unit=='F' or unit =='f' : print inp, "is ",(temp-32)/1.8,"C" else: print inp, "is ",(temp*1.8)+32
78a7a61bcdebb3dec33860d7bbf0f897cdf7768a
CodesterBoi/My-complete-works
/Other loop work.py
623
3.90625
4
#for i in range(0,1001): # pass #print(i) #count = 3 #while count < 10: # print(count) # count=count+2 #sum = 0 #for i in range(1,6): # sum=sum+i # print(sum) #a = 2 #b = [1, 5, 7, 10, 11] #for i in b: # c = a*i # print(c) #for i in range(1,3): # for j in range(1,4): # ...
3fc7be04eded0032ba316ba1ce65c1330b675335
CodesterBoi/My-complete-works
/Overall work.py
1,291
3.84375
4
#1 Z1 = [995, 896, 797, 698, 599] def Average(Z1): return sum(Z1)/len(Z1) average = Average(Z1) print("Average of the list =", round(average, 2)) #2 LA = ["a", "b", "a", "c", "d", "b", "c", "e"] LA = list(dict.fromkeys(LA)) print(LA) #3 def upperlower(string): upper = 0 lower = 0 ...
3f115dc4d77c49f3827e26674bac162ae8613b57
CodesterBoi/My-complete-works
/File Handling.py
2,273
4.125
4
''' #Reading from a file: car_name = input("Which car's stats do you want to display?") t = open("Car_stats.txt","r") end_of_file = False print(car_name) car_name = True while True: car_name = t.readline().strip() speed = t.readline().strip() acceleration = t.readline().strip() handling =...
4bc15431f2d1f20323350a536e2ba1bd12bd2c62
ericphamhung/sudoku_solver
/sudoku_solver.py
1,589
3.53125
4
import numpy as np def matricize(string): r1 = [int(n) for n in string[0:9]] r2 = [int(n) for n in string[9:18]] r3 = [int(n) for n in string[18:27]] r4 = [int(n) for n in string[27:36]] r5 = [int(n) for n in string[36:45]] r6 = [int(n) for n in string[45:54]] r7 = [int(n) for n in string[...
7f7458d6f512151d42016b238216abaa60a88ef0
russ-hensel/AdvDataLogging
/moving_average.py
2,047
3.90625
4
# -*- coding: utf-8 -*- # pretty much taken from: # http://rosettacode.org/wiki/Averages/Simple_moving_average from collections import deque """ Computes moving or running averages, averages are always floats MovingAverage in moving_average.py """ class MovingAverage(): def __init__(self, period): """ ...
024625e6c23b1ecaf1516d53f421d1162e238e73
ksilin/py4e
/ch7.1.py
438
3.671875
4
fhand = open('mbox.txt') print(fhand) # the for loop reads the file linewise, # meaning it can read huge files without RAM pressure # hande.read() would read the entire file in memory # calls to read exhaust the source lcount = 0 for line in fhand: lcount = lcount + 1 # print(len(fhand.lines)) - there is no lines...
0e5ee4b1c26612a8b7bbfc04bfbab779b9a99d1f
KBPsystem777/Python
/WOSplit.py
1,814
3.6875
4
#Variables Declaration budget = int(input("Enter Budget for 715: ")) w1 = int(input("Enter WO1 715 budget: ")) w2 = int(input("Enter WO2 715 budget: ")) w3 = int(input("Enter WO3 715 budget: ")) w4 = int(input("Enter WO4 715 budget: ")) w5 = int(input("Enter WO5 715 budget: ")) w6 = int(input("Enter WO6 715 bu...
6bfc8301268fb682559723ec78c7d774a2383576
Ramages/Python-MiscProject
/Caesar-Cipher/Caesar_cipher.py
2,014
3.8125
4
def encrypt(message, key): message.upper() alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"] crypted = [] msg = "" translator = message.upper() for i in range(len(translator)): if translator[i] in alphabet: ...
99fb1baa9d2eed047624cc551241429757f0f93f
lylflows/webdev2019
/week10/arrays/354.py
316
3.6875
4
from __future__ import print_function n = int(input()) a = [] for i in range(0, n): a.append([]) for j in range(0, n): if i+j == n - 1: a[i].append(1) elif i+j < n-1: a[i].append(0) else: a[i].append(2) for i in range(0, n): for j in range(0, n): print(a[i][j], end =" ") print()
af5ae9d9dd92a10923545f5ba43c0fb7eba955cd
DaranV/python
/maths_mod_Python/huffman.py
1,817
3.546875
4
from heapq import heappush, heappop, heapify from collections import defaultdict class Huffman: # Nombre d'apparition du caractère def comptage(txt): symb2weight = defaultdict(int) for ch in txt: symb2weight[ch] += 1 return symb2weight def codehuffman(symb2weight): ...
1f11e73230e0e96d48439552fec4cb9130c396f7
zhujiahao111/rsa
/dnn.py
9,467
3.546875
4
# -*- coding: utf-8 -*- """ Created on Thu Mar 21 10:26:38 2019 @author: yujiaoliang """ # -*- coding: utf-8 -*- """ Created on Thu Feb 21 12:26:08 2019 @author: yujiaoliang """ """ Neural Network with Eager API. A 2-Hidden Layers Fully Connected Neural Network (a.k.a Multilayer Perceptron) implementa...
3fdc8da3a327c1d8081ca0741348e6d6c31b54ac
GivaldoEc/deadlands--seletor-de-fichas
/sorteio_de_fichas.py
1,326
3.984375
4
from random import choice, choices #the single import that moves the application #variaveis importantes lista_de_fichas = [] fichas_brancas = int(input("Numero de fichas brancas: ")) fichas_vermelhas = int(input("Numero de fichas vermelhas: ")) fichas_azuis = int(input("Numero de fichas azuis: ")) def ma...
067dc51bc622e4e7514fc72c0b8b4626db950da5
amitp29/Python-Assignments
/Python Assignments/Assignment 3/question12.py
1,237
4.34375
4
''' Read 10 numbers from user and find the average of all. a) Use comparison operator to check how many numbers are less than average and print them b) Check how many numbers are more than average. c) How many are equal to average. ''' num_list = [] sum_of_num = 0 for i in range(10): while True: try: ...
45bcaf8e7ddb54e50dc916ee8ae1604345c27072
amitp29/Python-Assignments
/Python Assignments/Assignment 3/question20.py
835
4.34375
4
''' Write a program to generate Fibonacci series of numbers. Starting numbers are 0 and 1, new number in the series is generated by adding previous two numbers in the series. Example : 0, 1, 1, 2, 3, 5, 8,13,21,..... a) Number of elements printed in the series should be N numbers, Where N is any +ve integer. ...
874f3d5621af8a3cd128bd2d06e30cfe6bb3f0c5
amitp29/Python-Assignments
/Python Assignments/Assignment 3/question7.py
430
4.21875
4
''' Create a list with at least 10 elements in it :- print all elements perform slicing perform repetition with * operator Perform concatenation wiht other list. ''' #perform repetition with * operator list1 = [1]*7 list2 = [4,5,6] #Perform concatenation with other list list3 = list1+list2...
5904868535c5d42443159af4f6371007e5830b9b
amitp29/Python-Assignments
/Python Assignments/Assignment 5/ex3.py
650
3.890625
4
def isListOfInts(lst,ret=False): try: lst.append('') except: print 'ValueError: ',lst,'- arg not of <list> type' else: lst.pop() temp = 0 if not (lst==[]): for num in...
7545be7a5decce69dd33717fc7a77ca5848e6a3d
amitp29/Python-Assignments
/Python Assignments/Assignment 2/question3.py
942
4.15625
4
''' 4. Given a list of strings, return a list with the strings in sorted order, except group all the strings that begin with 'x' first. e.g. ['mix', 'xyz', 'apple', 'xanadu', 'aardvark'] yields ['xanadu', 'xyz', 'aardvark', 'apple', 'mix']. Hint: this can be done by m...
1dca7820586525dcd22cebeb2d851eb1d2bf8c42
SJasonHumphrey/DigitalCrafts
/Python/Homework004/word_histogram.py
958
4.3125
4
# 2. Word Summary # Write a word_histogram program that asks the user for a sentence as its input, and prints a dictionary containing # the tally of how many times each word in the alphabet was used in the text. wordDict = {} sentence = input('Please enter a sentence: ') def wordHistogram(sentence): for word in s...
dbbc0610e4f5b3f5885358fa792a0ac9cfcb45c8
SJasonHumphrey/DigitalCrafts
/Python/homework 001/tip_calc.py
592
4
4
# 1. Tip Calculator amount = float(input('Total bill amount? ')) service = (input('Level of service? Good, Bad or Fair: ')) good = 0.20 * amount fair = 0.15 * amount bad = 0.10 * amount if service.lower() == 'good': total = amount + good print('Tip amount: $ %.2f' % good) print('Total amount: ...
51f18a3da4b647afd53b70aba31ee389e2f94435
Tonka96/python
/lesson_5/funkcije.py
705
3.640625
4
import racunske_operacije as kalkulator # from racunske_operacije import * # kalkulator prvi_broj = int(input("Unesite prvi broj: ")) drugi_broj = int(input("Unesite drugi broj: ")) operacija = input("Unesite operaciju (+, -, *, /)") # klasičan način if operacija == "+": print(kalkulator.zbroji(prvi_broj, drugi...
868ddc543bcdc9803a24353b985fce1e375bf7b6
pkrucz00/algGeom
/cw2/generatePoints.py
2,393
3.59375
4
from random import uniform from math import cos, sin, pi, sqrt #1st set def pointsInInterval(s, t, n): return [(uniform(s, t), uniform(s, t)) for _ in range(n)] #2nd set def pointsInCircle(c, r, n): # c - center, r - radius, n - number of points result = [] for _ in range(n): fi = uniform(0, 2 * ...
394151911913d3bc37eaac866a60b4facd5a400d
heiblue/algorithm
/sort/python/insertsort.py
283
3.71875
4
#!/usr/local/bin/python3 #list = [3,5,7,4,2,8,9,1,6] list = [55,4,5,665,4,34,64,4,2,6,77,556,7765,8,534,5,63,5345,6] for i in range(1, len(list)): j = i temp = list[j] while (j > 0) and (temp < list[j-1]): list[j] = list[j-1] j -= 1 list[j] = temp print(list)
e6a4ba3ddd827c2998aa4eb33222772a25aef8b0
Neology92/cdv-programowanie-strukturalne
/class1/zad1.py
569
3.953125
4
print("-----------------") print("User1") print("-----------------") u1_name = input("Enter your name: ") u1_surname = input("Enter your surname: ") u1_age = int( input("Enter your age: ") ) print("-----------------") print("User2") print("-----------------") u2_name = input("Enter your name: ") u2_surname = input("E...
e80d0adc1a94156d8367e825709a63abaf39ed16
Neology92/cdv-programowanie-strukturalne
/class2/5_list.py
631
3.515625
4
prog = ['Python', 'C#', 'JS', 'PHP'] print(prog) print(type(prog)) first = prog[0] print(first) threeElements = prog[0:3] print(threeElements) last = prog[-1] print(last) secondFromEnd = prog[-2] print(secondFromEnd) # prog.append('R') prog.append('Python') print(prog) # countElem = prog.count('Python') print(coun...
48003388d0b5acc5358fceef00047bc5f23435b9
sohamde/inertia-aamas
/structured/network_agent.py
2,053
3.828125
4
""" Agent class for specifying the nodes of the network Agent types: Game Phase A: plays action A B: plays action B """ import random as rnd rnd.seed() class NetworkAgent: """ NetworkAgent class defines the agents on the nodes of the network """ def __init__(self, game_phase_action): """ Creates c...
5a87a1695d949a68019469a23dedf09bd7311313
kbrinton/epi-collect
/epi_collect/api/tokens.py
1,773
4.03125
4
""" Generate human readable tokens. Main idea is that we uniformly randomly select 6 characters, then randomly pick a word that starts with that character for each character, where we have a list of the 128 most common English words for each character. (if there are less than 128 common English words in our list for a...
3cfe7584a38532f6e05e3bba23fba852760468f0
PulseRoot/Baekjoon_Tier_Silver
/bj1181.py
544
3.8125
4
# 알파벳 소문자로 이루어진 N개의 단어가 들어오면 # 아래와 같은 조건에 따라 정렬하는 프로그램을 작성하시오. # 길이가 짧은 것부터 # 길이가 같으면 사전 순으로 print("input words number ") num = int(input()) arr = [""] * num for i in range(0, num): arr[i] = str(input()) set_arr = set(arr) #중복제거 arr = list(set_arr) #다시 arr에 저장 arr.sort() #사전순 arr.sort(key=len) ...
ab2011282e074d38c0fddb3990e66c7bd67889b9
Rajeshyd0308/DeepQLearning
/model.py
1,012
3.65625
4
import torch import torch.nn as nn import torch.nn.functional as F class network(nn.Module): def __init__(self, input_size, output_size, hidden_layers, drop_p=0.5): super().__init__() self.hidden_layers = nn.ModuleList([nn.Linear(input_size, hidden_layers[0])]) # Add a variable num...
ef39ff6ff91f53552745c39b529d6bc6ebcbc3cc
bterwijn/Python_fun
/goal/goal.py
10,553
3.625
4
# Goal game import tkinter import random import math print("Two player game, bump balls in your goal to score. Keys:") print(" player 1: 'z' turn left") print(" : 'x' turn right") print(" : 'f' move forward") print(" : 'x' brake") print(" : 'f' shoot")...
9e64f9da43c132193c3dfee9b7d543ddebdef203
franksalas/python_jumpstart
/02_guest_number_game/program.py
440
3.859375
4
import random print('---------------------------') print(' guest the number game') print('---------------------------') print() the_number = random.randint(0, 100) guess = -1 while guess !=the_number: guest_text = input('guest a number between 0 and 100: ') guess = int(guest_text) if guess < the_numb...
65d60bf6ab9f205305e1bd0de09ff3ef0ced0534
eabl/College-Organizer
/friendslist.py
1,701
4.03125
4
import os.path friendsLogs = "C:\\Users\\jayde\\Desktop\\10pi Hackathon\\FriendsList.txt" class friend: def __init__(self, name, points, friendsList): self.name = name self.points = int(points) self.friendsList = list(friendsList) def add_points(self, points): sel...
615c76f289b017a1c7a9b8a9f956a594f17ab727
LucianoBartomioli/-EDU-IRESM_AEDI_2020
/clase_7_clases_busqueda/clases.py
1,042
4.21875
4
class Empleado: def __init__(self, nombre, apellido, dni, legajo, puesto, salario_por_hora, cantidad_hs_trabajadas): self.nombre = input("Ingrese el nombre") self.apellido = input("Ingrese el apellido") self.dni = input("Ingrese el DNI") self.legajo = input("Ingrese el N° de legajo")...
560be92107e4f5b23903e58229788a441409a2b0
LucianoBartomioli/-EDU-IRESM_AEDI_2020
/clase_7_clases_busqueda/principal.py
662
3.734375
4
from clase_7_clases_busqueda.clases import Empleado def opciones_menu(): print("Ingrese 1 para cargar un empleado") print("Ingrese 2 para mostrar la lista de empleados") print("Ingrese 3 para buscar un empleado por legajo y mostrar todos sus datos") print("Ingrese 4 para buscar un empleado por nombre y ...
96fe74522ad7e3b67a81205003202f4224d5f4fb
Mariya74/homework
/less1.py
1,451
3.921875
4
class Fauna(): def __init__(self, name, size, paws): self.name = name self.size = size self.paws = paws def __str__(self): return str({ 'name': self.name, 'size': self.size, 'paws': self.paws, }) class Birds(Fauna): ...
dc75bce82a976ec9107735bd3f43d89d0aa7b607
bpankaj/Programs
/python_program/searching/linear_search.py
308
3.828125
4
def unordered_linear_search(numberlist, value): for i in range(len(numberlist)): if numberlist[i] == value: return i return -1 def ordered_linear_search(numberlist, value): for i in range(len(numberlist)): if numberlist[i] == value: return i elif numberlist[i] > value: return -1
8ff79e6ec95f001c6532a309af8d045f1419cc12
12520054/taco-training
/TranDanh_PyGame_3/TranDanh_PyGame_3.py
3,815
3.5625
4
class Student(): def __init__(self): self.m_Name = "" self.m_Dob = "" self.m_ID = "" self.m_Faculty = "" pass def InputInfo(self): s = raw_input() values = s.split("\" \"") self.m_Name = values[0][1:len(values[0])] self.m_Dob = v...
a9575ba12f07b8db1cdc50e6b628daadf8d27e53
hvijaycse/Data-Structures-and-Algorithms-Coursera
/Algorithmic Toolbox/week4/2_majority_element.py
951
3.53125
4
def get_majority_element(a, left, right): if left == right: return a[left] mid = ( left + right )//2 left_majority = get_majority_element( a, left, mid ) right_majority = get_majority_element(a, mid + 1, right) if left_majority == right_majority : return left_majority else: ...
91a84bbe9d6b4fc403544e004b7bfb81fb80c483
hvijaycse/Data-Structures-and-Algorithms-Coursera
/Algorithmic Toolbox/week2/8_fibonacci_sum_squares.py
827
3.90625
4
# Uses python3 def get_fibonacci_huge_naive(): m = 10 previous = 0 current = 1 sequense = [0, 1] while True: previous, current = current, previous + current s = current % m if s == 0: previous, current = current, previous + current s2 = current % m ...
d03fc78a9a3536675a8f9dd3359810cffe510744
jpeinado/structure
/Win32/ManagerWindows.py
1,113
3.5625
4
''' Title: Manejo de interfaz grafica en python Autor: Juan Carlos Peinado Pereira Date : 05/09/19 ''' #import tk #from tk import * import tkinter # Libreria que maneja el entorno grafico en python from tkinter import * class main(Frame):# Definicion de la clase frame para la creacion del entorno visual def __init_...
6a710dc9595e3829725879fc1623050a5ca85285
matt-pharr/advent-of-code-2020
/d13/day13.py
2,288
3.546875
4
# Matthew Pharr # Advent of Code 2020 # Rensselaer Polytechnic Institute import os import re day = '13' inp = os.path.dirname(os.path.realpath(__file__)) + '/day' + day + 'input.txt' # Reading function goes here def readin(puzzle_input): a = puzzle_input.splitlines() time = int(a[0]) l = [] for x in ...
798f08f649dbf077d14faa71f647dc4cddf735e9
avass90/Python
/python_projects/step_92.py
406
3.984375
4
fname = "Daniel" lname= "Christie" print("Hello {} {}, welcome to Python".format(fname,lname)) x="Monday" y="Friday" print("{} is my least favorite day of the week, and {} is my favorite day of the week".format(x,y)) x = format( 14, 'x') print(x) def getSum(num1,num2): answer = num1 + num2 ...
8bf6de65d990e8c67db6851468b856ae4678a726
ajaykommaraju/coursera_track2
/file_examples1.py
952
3.90625
4
#synatx for opening a file '''file = open('c:/Users/kkumar19/Documents/coursera_python_track2/network.py') print(file.read()) file.close()''' #syntax for opening a file with section '''with open('c:/Users/kkumar19/Documents/coursera_python_track2/network.py') as file: for line in file: print(line.upper().st...
f37f41087fd970146217e4b32a16f0d3af7d9b5e
naolwakoya/python
/factorial.py
685
4.125
4
import math x = int(input("Please Enter a Number: ")) #recursion def factorial (x): if x < 2: return 1 else: return (x * factorial(x-1)) #iteration def fact(n, total=1): while True: if n == 1: return total n, total = n - 1, total * n def factorial(p): if p ==...
6b92a421d201ae784dd90639c5e99c99762d1163
CCallahanIV/tedc-wishlist-manager
/src/wishlist/app/models/__init__.py
7,157
3.546875
4
import uuid from sqlalchemy import UniqueConstraint from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.exc import IntegrityError from sqlalchemy.sql import text from app import bcrypt, db from app.models.exceptions import ( BookNotFound, UserNotFound, WishlistNotFound, WishlistEntryAlread...
53b838d4dc23f7d1fd419a072cb7be7f5a499acc
ztaira/souper_trawler
/souper_trawler.py
2,900
3.8125
4
"""A script to pull down files from my professor's class website""" import sys import os import re import bs4 import urllib.request # A function to create a list of all the links on the class webpage def pull_possible_links(url, recursion_level): """soup_pul(string url, int recursion_level)""" # set the new r...
6b5b364b633c8cac0bea58a767395ad9d07e4b06
rachelhyeh/Python-Structure-Practice
/9_Polymorphism_Pet.py
657
3.890625
4
# -*- coding: utf-8 -*- """ Created on Sun Mar 8 17:51:13 2020 @author: rache """ from abc import ABCMeta, abstractmethod class Pet(object, metaclass=ABCMeta): def __init__(self, nickname): self._nickname = nickname @abstractmethod def make_voice(self): pass class ...
7927186f45cb023948cb83c8a2baad6bd5d50753
jscabraWork/Lab3Infracom
/python/appservidor/mainserver.py
2,484
3.515625
4
import socket import threading IP = socket.gethostbyname(socket.gethostname()) PORT = 9999 ADDR = (IP,PORT) SIZE = 1024 FORMAT = "utf-8" DISCONNECT_MSG = "!DISCONNECT" TOTAL_CONNECTIONS = 25 connections = [] requiredCons = 10 barrier = threading.Barrier(requiredCons) def handle_client(conn, addr): print(f"[NEW ...
3abaf1030354b1315fa8fbb234dea09d6e6cfaee
ericklui678/python_callCenter
/callCenter.py
2,291
3.53125
4
from itertools import count class Call(object): _ids = count(0) # start count at 1 def __init__(self, name, number, time, reason): self.id = self._ids.next() # increment id for every call instance self.name = name self.number = number self.time = time self.reason = ...
89d72ad5268895e5f11d58094f6f2a5e733bc281
kavithagowdabs/python-programs
/add.py
73
3.640625
4
a=int(input("enter A")) b=int(input("enter B")) c=a+b print("sum",c)
54ffa868bf4a5f18925f9e98f0d084933c40c56a
ianfrossi0/demo-blackjack
/classes/card.py
1,460
3.71875
4
class Card: def __init__(self, number, icon): self.number = number self.icon = icon self.visible = True # Soft refers to value for an ace # A soft ace is valued 11, a hard ace is valued 1 self.soft = False # Returns whether this card is an ace or not...
3fa80764eb89ff9c92eb03866a213e3a7c4be38d
yksdy/yksdy
/Python/pythonDemo/Learn_Python_The_Hard_Way/11.py
126
3.90625
4
print ("How old are you",), age = input() print ("you old are %r" %age) name = input("what is your name?") print ("%s" %name)
d54cf0b509e862b6d45b8d7d2c470c03bb530680
quocvuong12345979797/baitap2
/bai13.py
485
3.640625
4
a=int(input('Nhap a:')) b=int(input('Nhap b:')) c=int(input('Nhap c:')) import math deltha = b ** 2 - 4 * a * c if deltha < 0: print(" Phuong trinh vo nghiem ") elif deltha == 0: x = -b / (2 * a) print('Phuong trinh có nghiệm kép x1=x2=',x) else: print('Phuong trình có 2 nghiệm phân biệt:') ...
0aa17f5d77b78dbb4c530840b0597f30ef0bdbe0
dillonhuff/mma_cmp
/fight.py
1,173
3.6875
4
class Date: def __init__(self, month, day, year): self.month = month self.day = day self.year = year def month_num(self): return month_to_num(self.month) def to_string(self): return self.month + '-' + str(self.day) + '-' + str(self.year) class Fighter: def __in...
ba9bef7c1f28de6fdb49a5fc93ce9a331f6087b1
milton96/practicas
/unimodal-tutorial.py
506
3.703125
4
# encuentra el valor maximo de una funcion dados un rango de valores def f(x): return (2*x**2 - 12*x + 7) def ternary_search(start, end, interval): l = start r = end while r-l < interval: l1 = (l*2+r)/3 l2 = (l+2*r)/3 # print(l1,l2) if f(l1) < f(l2): r = l2 ...