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
72a4d9f5fb66459f407577dcebd0568c248b14d9
phandinhvu98/vu
/main.py
1,485
3.59375
4
# from tkinter import * # # window = Tk() # # btn_add = Button(text = 'Add Two Number') # btn_add.pack() # # window.mainloop() from nhan_vien_demo import Nhan_Vien #Gán thông tin dữ liệu cho 1 đối tượng nv1 nv1 = Nhan_Vien(ma_nv= "NV01", ten_nv= "Tran Van A", luong_nv= 2000) #tạo đối tượng # nv1.ma_nhan_vi...
427efa417b198d521bf9cdb7760fac3910b5b62d
andrewHolsaeter/RaspberryPi-MaggicMirror
/led.py
899
3.546875
4
import time import RPi.GPIO as GPIO GPIO.setwarnings(False) # Ignore warning for now GPIO.setmode(GPIO.BOARD) # Use physical pin numberi$ class LED(): def __init__(self, pin, name="unknown"): GPIO.setup(pin, GPIO.OUT) self.pin = pin self.name = name GPIO.output(self.pin, GPIO.LOW) self.previous_state = GPIO...
1bd1aa6aed573691819da14a5caf87e1b1048ff6
gigi-c/python-dev
/Lambda Function.py
541
3.875
4
# LAMBDA FUNCTION # essentially anonymous function that can take multiple parameters but return only one expression # normal way to declare a function: def add(num1, num2): return num1 + num2 print(add(23, 45)) # lamda function: addition = lambda num1, num2: num1 + num2 print(addition(23, 45)) savings = [234, 56...
8a8f08c0ac347bc7f17376d789cbe8b85f68d494
gigi-c/python-dev
/test_unittest_simplecalc.py
718
3.765625
4
from simple_calc import SimpleCalc import unittest class Calctests(unittest.TestCase): cal = SimpleCalc() # create an object def test_add(self): self.assertEqual(self.cal.add(2, 4), 6) # assertEqual means does LHS [add(2,4)] equal to RHS [6] def test_substract(self): self.assertEqual(self...
f879f0ecff2adbb0aade57b530d2a3a3f02b7fd4
gigi-c/python-dev
/python_excel/new_excel.py
1,078
3.828125
4
# write a program in python to copy data from data9 file to new file called data9_copied import openpyxl import xlsxwriter data9_copied = xlsxwriter.Workbook("data9_copied.xlsx") worksheet = data9_copied.add_worksheet("Trainees") data9_copied.close() # opening the source excel file path = "data9.xlsx" data9_workbook...
98c93d8bd6809aeaa698ccf72abb46f77b12c2c2
yousioph25/GlobalAIHubPythonCourse
/homework day2 first.py
165
3.59375
4
list = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000] list1 = list[:5] list2 = list[5:] list3 = list2 + list1 print(list1) print(list2) print(list3)
5e5e7df63660f904a45f4350df321e9ce8d600c0
tbeaux18/rosalind
/point_mutation.py
1,127
4.34375
4
#!/usr/bin/env python3 """ @author: Timothy Baker @version: 01/15/2019 Counting Point Mutations Rosalind Input: Standard Input Output: Console """ import sys def hamming_distance(sequence_one, sequence_two): """ Calculates hamming distance between 2 strings Args: sequence_one (str) ...
52938fee6fc808c41e1ebffbda4c8b619535034a
tbeaux18/rosalind
/rna_translation.py
2,280
3.921875
4
#!/usr/bin/env python3 """ @author: Timothy Baker @version: 11/10/2018 Translating RNA into Protein Rosalind Problem 9 """ import sys def construct_aa_dict(file_name): """ Takes a file in the format CODON\tAMINO ACID ABBREV and converts this curated file to a dictionary. Not reproducible without file i...
949c4efe69dd2cddcc3ea73bd3b23aa41b758e40
yellowflashninja/pyproj
/m319/twitterHelloWorld.py
9,448
3.8125
4
#!/usr/bin/env python # coding: utf-8 # # Social Media, Bots and APIs # # ## Part \#1: Create Your First Twitter Bot # # In this notebook, you will create your first Twitter Bot. Here are some guidelines you will have to follow throughout this chapter: # # ### Classroom Expectations and Ethical Bot Usage # # * An...
781b4ad36a04c8208745633d49694c58a4e03e8d
rookieygl/LeetCode
/leet_code/lt_tiku/09.isPalindrome.py
1,372
3.984375
4
""" 9.回文数 给你一个整数 x ,如果 x 是一个回文整数,返回 true ;否则,返回 false 。 回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。例如,121 是回文,而 123 不是。 """ class Solution(object): # 本人的 觉得好垃圾啊 def isPalindrome_me(self, x): if x < 0 or (x % 10 == 0 and x != 0): return False if x < 10: return True pali = 0...
6e1c757fda76b8d6d1cd22173dd21e8778b55b77
rookieygl/LeetCode
/leet_code/lt_tiku/171.titleToNumber.py
582
3.640625
4
""" 171. Excel表列序号 给定一个Excel表格中的列名称,返回其相应的列序号。 A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ... """ class Solution(object): def titleToNumber(self, columnTitle): ans, multiple = 0, 1 for i in range(len(columnTitle) - 1, -1, -1): tmp = ord(columnTitl...
4ec28e57ceea447855065a4fb5959dcb353259ed
rookieygl/LeetCode
/leet_code/lt_tiku/153.findMin.py
1,217
3.890625
4
""" 153. 寻找旋转排序数组中的最小值 已知一个长度为 n 的数组,预先按照升序排列,经由 1 到 n 次 旋转 后,得到输入数组。例如,原数组 nums = [0,1,2,4,5,6,7] 在变化后可能得到: 若旋转 4 次,则可以得到 [4,5,6,7,0,1,2] 若旋转 7 次,则可以得到 [0,1,2,4,5,6,7] 注意,数组 [a[0], a[1], a[2], ..., a[n-1]] 旋转一次 的结果为数组 [a[n-1], a[0], a[1], a[2], ..., a[n-2]] 。 给你一个元素值 互不相同 的数组 nums ,它原来是一个升序排列的数组,并按上述情形进行了多次旋转。请你找出并返回...
c2362a8c792b4d32d29e0b464194d52d1087d9bc
rookieygl/LeetCode
/leet_code/sword_offerII/52.getIntersectionNode.py
1,260
3.734375
4
""" 剑指 Offer 52. 两个链表的第一个公共节点 输入两个链表,找出它们的第一个公共节点。 """ class ListNode(object): def __init__(self, val=0, next=None): self.val = val self.next = next class Solution(object): # 双指针 def getIntersectionNode_doblePoint(self, headA, headB): if not headA or not headB: return...
45d08ba62f18eac11410a16a3ad6b1fdee12c3a1
rookieygl/LeetCode
/leet_code/lt_tiku/1104.pathInZigZagTree.py
1,404
4
4
""" 863. 二叉树中所有距离为 K 的结点 给定一个二叉树(具有根结点 root), 一个目标结点 target ,和一个整数值 K 。 返回到目标结点 target 距离为 K 的所有结点的值的列表。 答案可以以任何顺序返回。 """ class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution(object): def pathInZigZagTree...
2ad5998ea1d0f942ba7748ca4c1c8d7c3a268b0b
rookieygl/LeetCode
/leet_code/lt_tiku/274.hIndex.py
1,607
4
4
""" 274. H 指数 给定一位研究者论文被引用次数的数组(被引用次数是非负整数)。编写一个方法,计算出研究者的 h 指数。 h 指数的定义:h 代表“高引用次数”(high citations),一名科研人员的 h 指数是指他(她)的 (N 篇论文中)总共有 h 篇论文分别被引用了至少 h 次。 且其余的 N - h 篇论文每篇被引用次数 不超过 h 次。 例如:某人的 h 指数是 20,这表示他已发表的论文中,每篇被引用了至少 20 次的论文总共有 20 篇。 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 """ class Solution(object): # 计数排序 d...
783cca3167acfa9a3505d0f1a63b445ce773ea43
rookieygl/LeetCode
/leet_code/lt_tiku/930.numSubarraysWithSum.py
793
3.578125
4
""" 930. 和相同的二元子数组 给你一个二元数组 nums ,和一个整数 goal ,请你统计并返回有多少个和为 goal 的 非空 子数组。 子数组 是数组的一段连续部分。 """ from collections import defaultdict class Solution(object): # hash+前缀和 def numSubarraysWithSum(self, nums, goal): sumSet = defaultdict(int) numSum = 0 ans = 0 for i, num in enumerate...
94273f9d9a23a6b64d86fc9dc7cce7af7b096abf
rookieygl/LeetCode
/leet_code/lt_tiku/189.rotate.py
1,060
4
4
""" 189. 旋转数组 给定一个数组,将数组中的元素向右移动 k 个位置,其中 k 是非负数。 进阶: 尽可能想出更多的解决方案,至少有三种不同的方法可以解决这个问题。 你可以使用空间复杂度为 O(1) 的 原地 算法解决这个问题吗? """ class Solution(object): # 插入 insert 会将坐标后的元素后移 def rotate_insert(self, nums, k): n = len(nums) k %= n for _ in range(k): nums.insert(0, nums.pop()) ...
b6fa08b6f1206ff045545f479371b6b2682c80a7
rookieygl/LeetCode
/offer_interview/algorithm/2021/0716.滴滴出行后端.py
983
4.03125
4
""" 1、写个单例 2、合并有序链表 """ class ListNode(object): def __init__(self, val=0, next=None): self.val = val self.next = next class Solution(object): def mergeList(self, node1, node2): mergeNode = ListNode(-1) temNode = mergeNode while node1 and node2: if node1.va...
d43579002cc21b9104fa25d4d7a10e0380b61e36
rookieygl/LeetCode
/leet_code/lt_tiku/322.coinChange.py
881
3.609375
4
""" 322. 零钱兑换 给定不同面额的硬币 coins 和一个总金额 amount。编写一个函数来计算可以凑成总金额所需的最少的硬币个数。 如果没有任何一种硬币组合能组成总金额,返回 -1。 你可以认为每种硬币的数量是无限的。 """ class Solution(object): # 先填充最小的硬币,依次填入较大硬币,就能减少硬币的个数 def coinChange(self, amount, coins): dp = [float('inf')] * (amount + 1) dp[0] = 0 for coin in coins: ...
b33a5c7897aff2c95731cbb0b07982d06c36b92c
rookieygl/LeetCode
/leet_code/lt_tiku/981.TimeMap.py
1,678
3.59375
4
""" 981. 基于时间的键值存储 创建一个基于时间的键值存储类 TimeMap,它支持下面两个操作: 1. set(string key, string value, int timestamp) 存储键 key、值 value,以及给定的时间戳 timestamp。 2. get(string key, int timestamp) 返回先前调用 set(key, value, timestamp_prev) 所存储的值,其中 timestamp_prev <= timestamp。 如果有多个这样的值,则返回对应最大的 timestamp_prev 的那个值。 如果没有值,则返回空字符串("")。 """ from ...
56d99a0318fdc0cb041e03bb8cb19407465d459f
maxVeremchuk/kotlin_code_formatter
/formatter/analyzer.py
1,111
3.546875
4
class Analyzer: init_content = list() bracket_stack = [] open_list = ["[","{","(","<"] close_list = ["]","}",")",">"] last_bracket = [] def __init__(self, filename): with open(filename, "r") as file: self.init_content = file.readlines() def analyze(self): for i, line in enumerate(self.init_content): ...
22cfe29daf5a9adca5e908e8c4fda15132536133
sapalamut/homework
/ClassWork_4.py
1,764
4.25
4
# FUNCTIONS # Ex:1 def add_two_numbers(num1, num2): return num1 + num2 result = add_two_numbers(1, 2) print(result) print(add_two_numbers(1, 2)) first = 1 second = 2 third = 3 print(add_two_numbers(first, second), add_two_numbers(second, third)) print('\n') # Ex:2 def print_hello_world(): print("Hello Wolrd") print...
9cd3830f593562c9f3e38cd61edf3436249a1af5
sapalamut/homework
/HomeWork_12.py
849
3.734375
4
# Ex1 class GetString: def __init__(self): self.str_one = " " def set(self): self.str_one = input('Enter something: ') def get(self): print("The entered data is: ") return self.str_one final_result = GetString() final_result.set() print(final_result.get().upper()) # Ex2 ...
81d2a59b6819f65f92c8aa0fc2499cf018c1e78b
sapalamut/homework
/HomeWork_15.py
4,844
3.859375
4
import random class Card: def __init__(self, value, name, suit): self.suit = suit self.value = value self.name = name def card_face(self): print(f"{self.name} {self.suit}") class Player: def __init__(self, name, wallet): self.name = name self.card_deck = []...
dae1dd1d525f415a495d7138b04c6fcd9654e4eb
khel-kim/SWExpertAcademy
/ProgrammingAdvanced/04DivideAndConquer/08BinarySearch.py
771
3.640625
4
def binary_search(number, a): if len(a) == 1: if a[0] == number: return 1 else: return 0 elif len(a) == 0: return 0 n = len(a) middle = n // 2 if a[middle] == number: return 1 elif a[middle] >= number: return binary_search(number, a...
c74dfe47c7e2e2192d621b3ebb3404885e416bb8
mhutch2b87/Python-PreWork
/Question_3.py
374
4.0625
4
""" Question 3 Please write a Python function, max_num_in_list to return the max number of a given list. The first line of the code has been defined as below. def max_num_in_list(a_list): """ def max_num_in_list(a_list): max_num = max(a_list) return max_num digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] highest...
5800ee24c3821f96afa4a1c5ff35bc39e920bd4e
damunza/Automations
/order.py
797
4
4
import re def arrange(sentence): ''' arrange sorts a sentence eg Th1is i2s th3e s4mple in correct order depending on the numbers in each word ''' # checking if the s entence is empty try: if len(sentence) == 0: return sentence finally: sentencelist = sentence.split(' '...
ca6f5f7bb7fc627f7278170fecbb630e5a00ec7c
RRRustik/Algorithms
/alg_lesson_1.8.py
567
4.21875
4
"""8. Вводятся три разных числа. Найти, какое из них является средним (больше одного, но меньше другого).""" n1 = int(input("Введите первое число: ")) n2 = int(input("Введите второе число: ")) n3 = int(input("Введите третье число: ")) if n1 > n2 and n1 < n3: print(f'{n1} - среднее число') elif n2 > n1 and n2 < n3...
f663bff3ef41f0954ea2934983ac6d05d7410361
b-tima/Codewars-Solutions
/Python/Count the smiley faces!.py
295
3.640625
4
def count_smileys(arr): smileys = 0 for dec in arr: if dec[0] not in [':', ';']: continue if dec[1] in ['~', '-']: if dec[2] in [')', 'D']: smileys += 1 elif dec[1] in [')', 'D']: smileys += 1 return smileys
e4b98eb4a46eccd90342daa1b61903c814f61083
b-tima/Codewars-Solutions
/Python/Primes in numbers.py
525
3.5
4
def primeFactors(n): factors = [] found_all = False while not found_all: found_all = True for num in range(2, int(n)): if (n/num).is_integer(): n /= num factors.append(num) found_all = False break factors.append(int(...
2066aee125ca630fc26189f0862f500760d061f2
b-tima/Codewars-Solutions
/Python/Remove String Spaces.py
233
3.609375
4
def no_space(x): returnVal = "" currentStr = "" for i in x: if(i == " "): returnVal += currentStr currentStr = "" else: currentStr += i return returnVal + currentStr
067270c2c0cae8474eafdb9641a455be2f917393
b-tima/Codewars-Solutions
/Python/Sudoku Solution Validator.py
679
3.625
4
def valid_container(container): numbers = [x for x in range(1, 10)] for n in container: if n not in numbers: return False numbers.remove(n) return len(numbers) == 0 def valid_solution(board): # Horizontal for h in board: if not valid_container(h): ret...
0b3675f14d66bea44db317f106cfb60ac429446c
b-tima/Codewars-Solutions
/Python/Simple Pig Latin.py
304
3.671875
4
def pig_it(text): words = text.split(' ') result = "" for word in words: if word in ['.', ',', '!', '?']: result += word + " " continue cap = word[0] rem = word[1:len(word)] result += "{}{}ay ".format(rem, cap) return result.strip()
a9fe99bf401b93305bfd0824099827cadba24dad
b-tima/Codewars-Solutions
/Python/Does my number look big in this.py
181
3.59375
4
def narcissistic( value ): sum = 0 for character in str(value): sum += pow(int(character), len(str(value))) if sum == value: return True return False
4739fe0ecc951138473c2dd99675aea63f317d2e
Shikkic/exercism.io.python
/pangram/pangram.py
825
4.09375
4
# is_pangram returns if a string uses every character of the alphabet # atlest once. Returns true if is_pangram, flase if not (or empty). def is_pangram(input): # If input is empty, or less than num of lettes in alphabet # return false if len(input) < 1 or len(input) < 26: return False # Creat...
a344a82d5dbdc7ba0c1df579d7f9461fe79d228c
sanchit-ahuja/cppcode
/ey1.py
1,198
3.65625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2020-09-12 15:09:19 # @Author : Sanchit Ahuja (you@example.org) # @Link : link # @Version : 1.0.0 import os def isub(s, t) : t = iter(t) return all(c in t for c in s) def solve(wordtosyn, wordtoant) : cnt = 0 syn_set = set() ant_set...
21e3a40f854bfabb37bf5b0afd6c773977035888
DmitryLitvintsev/scripts
/python/tests/stack_with_min.py
1,735
3.8125
4
""" Various stack problems. Stack - LIFO Stack that has pop(), push(), min() methods that are O(1) in time """ from __future__ import print_function import sys _BIG_NUMBER = 1<<64-1 class Node: def __init__(self, data, min): self.next = None self.data = data self.min = min de...
95bca10796b39303a0553209a73c8d832df7e8f5
DmitryLitvintsev/scripts
/python/tests/permutations.py
1,132
3.9375
4
""" 1.3 Given two strings, write a method to decide if one string is permutation of the other """ from __future__ import print_function import itertools import sys def is_permutation(s1, s2): if s1 in ["".join(i) for i in list(itertools.permutations(s2))]: return True else: return False de...
e7364e9ae72c294f53cd127f095d73029c3bd1ef
DmitryLitvintsev/scripts
/python/tests/all_unique_characters.py
692
4
4
""" return False if input string has all unique characters """ from __future__ import print_function import sys def is_all_unique_characters(txt): checker = set() for i in txt.upper(): if i not in checker: checker.add(i) else: return False return True def is_all_...
03dc0d0eba8c7e63a08848a8155012dd16034550
DmitryLitvintsev/scripts
/python/tests/first_recurring.py
400
3.765625
4
""" print first recurring character in string """ from __future__ import print_function import sys def first_recurring(s): checker = 0 base = ord('A') for i in s.upper(): val = ord(i) - base if checker & (1<<val) != 0: return i else: checker |= (1<<val) ...
78b5ab020bee45c0e505ce328ac9982201f5b537
DmitryLitvintsev/scripts
/python/tests/chairs.py
459
3.671875
4
""" Guests arrive at the folloging hours s = [1, 2, 6, 5, 3] and leave at e = [5, 5, 7, 6, 8]. Find minimum number of chairs required """ if __name__ == "__main__": starts = [1, 2, 6, 5, 3] ends = [5, 5, 7, 6, 8] all = [(s, 1) for s in starts] + [(e, -1) for e in ends] all.sort() chairs = 0 ...
44d2fe6c8ff90183d9826fdb89850085071f2f32
darrenrs/ica-projects
/ICA Creative Applications/Python/Python Turtle/main.py
1,766
4.1875
4
import turtle import math ''' void drawLine(int x, int y): draws a single line ''' def drawLine(x, y): turtle.penup() turtle.setposition(x, y) turtle.pendown() turtle.forward(math.sqrt(50**2+50**2)) ''' void drawSquare(int x, int y, int d): draws a square ''' def drawSquare(x, y, d): turtle.setp...
067bd5ed1dbcfcdcb1e6daea2341192a50b74562
Funk66/officehours
/officehours/__init__.py
11,512
3.921875
4
#!/usr/bin/python # -*- coding: utf-8 -*- import re from datetime import date from datetime import datetime from datetime import timedelta from typing import List, Tuple, Set, Union __author__ = 'Guillermo Guirao Aguilar' __email__ = 'contact@guillermoguiraoaguilar.com' __version__ = '0.2.0' Date = date Time = Union...
d35cf209b7e8612e3cf44f4a006f1c1e13443768
CorySpitzer/tron-engine
/bots/loganbot.py
1,587
3.703125
4
#!/usr/bin/python """ Logan Davis Python 2.7.5 Programming workshop VERY SIMPLE BOT a very simple bot that is supposed to be able to run a certian length then turn in an order that is simple, but also effectively uses space. I am currently having problems with the line that defines 'decision' it is returning a ...
3193a28f44ae0973ed72d135dcba5cfa74b3cf68
CorySpitzer/tron-engine
/bots/randlog.py
1,679
3.625
4
#!/usr/bin/env python """ randlog.py An example Tron bot which moves in a random direction ... and logs what it does to log.txt. None of these bots can use "print" to show you what it's doing, since that's how it communicates with the engine that runs it. So the simplest way to debug it is to send messages to a log...
6dae33ef62ccf0edec9394997ef4c680b50ae04d
NightOaks/Week-Two-Assignment
/convert.py
459
3.84375
4
__author__ = 'Devin Simoneaux' # CIS-125 # Input Fahrenheit & Get Celsius Temperatures # # This program gets a temp in F from the user, and it converts and outputs the temp in C. # Declare Magic Numbers and Constants # LOOPCOUNTER = 2 # name = "bob" # Write program code here # Input F = eval(input("Please enter ...
c55650ec56c1bc6033fb784161e6c8cde5edbd13
arpit2604/DS-Algo
/quick-sort.py
978
4.09375
4
def quickSort(array): quickSortHelper(array,0,len(array)-1) return array def quickSortHelper(array,start_index,end_index): if start_index >= end_index: return pivot_index = start_index left_index = start_index + 1 right_index = end_index while left_index<=right_index: if array[left_index] > array[pivot_inde...
ba175a27e27d799f8f759ea0c83574c858159ffc
HCKYJOC/git_practice
/Jimmys_jenky_games_of_chance.py
3,045
4
4
import random total = 100 print("Your Total is $" + str(total)) print("************") #Write your game of chance functions here def coin_flip(bet, guess, total): if bet <= 0: print("You must bet more than $0") return 0 if bet > total: print("You don't have enough money to make that bet!") return 0...
08f440ac02c23fdd8d63631a48c3744b921d59b5
simonbilskyrollins/nyc-subway-finder
/nyc-subway-finder.py
4,413
3.609375
4
from google.transit import gtfs_realtime_pb2 import urllib import re from train import * from interfaces import * def main(): keepGoing = True stops = createStopsDict() trains = getData(stops) interface = TextInterface(trains) while keepGoing == True: direction, station_query = interface.ge...
3cde64dbfef855818d8417897dfe9d4d53879bbf
lauramcgugan/Project-A-orbits-
/vector3D.py
2,031
3.890625
4
""" Project 2A: Collection of functions for various vector manipulations. Authors: E. Zaid and L. McGugan Version: 20/02/2017 """ import math import numpy as np def normSq(v): """ Return the square of the magnitude of the vector :param v: the vector :return: sum of the squared vecto...
9af1956029939df831005af4d10043e2bd97da98
gordon801/NLH-poker-odds
/Card.py
2,146
3.890625
4
# Defining classes and functions class Card: def __init__(self, index, suit): self.index = index self.suit = suit def __eq__(self, other): return self.index == other.index and self.suit == other.suit def getIndex(self): return self.index def getSuit(self): retu...
e1e6bac47d64e74810218f2592678c4bdd7060bd
andreferreira4/Programa-o1
/ficha 1 entregar/Ex4.py
478
3.75
4
#Exercício4 nota1 = float(input("Escreva a primeira nota: ")) nota2 = float(input("Escreva a segunda nota: ")) nota3 = float(input("Escreva a terceira nota: ")) media =float((nota1 * 25 + nota2 * 35 + nota3 * 40) /100) media_inteira = int((nota1 * 25 + nota2 * 35 + nota3 * 40) //100) media_modulo = int((nota1 * 25 + ...
b5f08663abaaa102e0fa677f32bb701f9c19d164
andreferreira4/Programa-o1
/ficha 2 entregar/ex1.py
732
3.734375
4
#Exercicio 1 percnota1= .25 percnota2= .35 percnota3= .40 #Nota1 nota1 = float(input("Escreva a primeira nota: ")) while nota1 < 0.0 or nota1 > 20.0: nota1 = float(input("Escreva a primeira nota: ")) #Nota2 nota2 = float(input("Escreva a segunda nota: ")) while nota2 < 0.0 or nota2 > 20.0: nota2 = float(inpu...
7dd17ad1a08aa1fe100a432bdb76f3fea11b371c
andreferreira4/Programa-o1
/ficha 2 entregar/ex2.py
799
4.21875
4
#Exercício2 Numero1 = int(input("Escreva o primeiro número ")) Numero2 = int(input("Escreva o segundo número ")) Numero3 = int(input("Escreva o terceiro número ")) if Numero1 > Numero2 and Numero2 > Numero3 : print("{} > {} > {}".format(Numero1,Numero2,Numero3)) elif Numero1 > Numero2 and Numero1 > Numero3 : ...
2ee2674661fc8ab25649b41d09ef1e87d9e58047
dwibagus154/TUBES-TPB-ITB
/F02-login_user.py
1,257
3.671875
4
#prosedur login import csv def login(): #Login dapat dilakukan baik oleh pemain maupun oleh admin. #Login hanya dapat dilakukan jika pengguna belum login. #KAMUS LOKAL # f : file of str # reader = hasil pembacaan data csv # username, password, cekrole : str # name, uname, pw, role : array of str # cek : bool #ALGORI...
ee69f1045a7c993d7651b4550704ac60913fc51e
kevine11/RPG_Game
/HeroRPGclassNotes.py
2,465
4.09375
4
##### #!/usr/bin/env python # In this simple RPG game, the hero fights the goblin. He has the options to: # 1. fight goblin # 2. do nothing - in which case the goblin will attack him anyway # 3. flee ###### SELF NOTES: add crit chance, add defense power, add block # class Hero(object): # def __init__ (self, heroH...
35135d8a40f97875e9e612968987a6a8929f608b
CodecoolGlobal/pair-programming-exercises-python-walnut5588
/palindrome/palindrome_module.py
528
4
4
def palindrome(str): text = [] text2 = [] for i in str: if i != " ": text.append(i.lower()) print(text) for i in range(len(text), 0, -1): text2.append(text[i - 1]) if text == text2: return True else: return False print(text2) def main():...
421674bdb030ac1dcc7957b3a9ab3c8ef1570077
qodzero/silverviewr
/aspects.py
667
3.734375
4
def aspect_ratio(val, lim): lower = [0, 1] upper = [1, 0] while True: mediant = [lower[0] + upper[0], lower[1] + upper[1]] if val * mediant[1] > mediant[0]: if lim < mediant[1]: return upper lower = mediant elif val * mediant[1]...
f08aadfbc30f05c7e2cba20d5c76321c5b8035f8
ncf-ds/algorithms-project-01
/collective/quicksort.py
913
4.0625
4
import numpy as np def partition(A, p, r): """Returns a partition point. """ i = p - 1 for j in range(p, r): if A[j] < A[r]: i += 1 A[i], A[j] = A[j], A[i] A[i + 1], A[r] = A[r], A[i + 1] return i + 1 def quicksort(A, p = 0, r = None, randomize=True): """S...
fb75fdaad78af4abe0a5f5ec495a3c9ed9284448
JoShuaBartkoske/ASTR-6410
/LSP_withLSIdata.py
4,199
3.640625
4
""" Example of Lomb-Scargle Algorithm --------------------------------- Figure 10.15 Example of a Lomb-Scargle periodogram. The data include 30 points drawn from the function y(t|P) = 10 + sin(2pi t/P) with P = 0.3. Heteroscedastic Gaussian noise is added to the observations, with a width drawn from a uniform di...
b48219201085b4fb0c0f996be93f879aef1262a8
kumar-roheit/Data-Engineer-with-Python
/Writing Efficient Python Code/Numpy.py
1,057
3.921875
4
# Numpy arrays are Homogeneous - they must contain elements of the same type # if we create the element with mixed types like int and float ... numpy will convert the numpy arrays to float. --------------------------------------------------------------------------------------------------------------------------- # Num...
a32f45ba161e7619f2b425947ee0861652c1af19
rahulverma7788/coursera-natural-language-processing-specialization-2-3650
/1 - Natural Language Processing with Classification and Vector Spaces/week-1/Visualizing word freq.ipynb
10,490
4.28125
4
#!/usr/bin/env python # coding: utf-8 # # Building and Visualizing word frequencies # # # In this lab, we will focus on the `build_freqs()` helper function and visualizing a dataset fed into it. In our goal of tweet sentiment analysis, this function will build a dictionary where we can lookup how many times a word a...
1926fb4ddc20b9bc90e77962b6311915b13553e6
mpss2019fn1/embedding-testing
/src/Testing/Result/case_result.py
869
3.53125
4
class CaseResult: PASSED_PREFIX = "✔" NOT_PASSED_PREFIX = "✖" ACTUAL_OUTPUT_PREFIX = "➔" EXPECTED_OUTPUT_PREFIX = "⚡" def __init__(self, test_input, expected_output, actual_output, passed): self.test_input = test_input self.expected_output = expected_output self.actual_outp...
5a615327932b10ac7b86fcc5e3725acaf478acc0
qsLI/image-demo
/insert_data.py
812
3.515625
4
import sqlite3 from datetime import datetime DATABASE = 'C:\Users\KL\PycharmProjects\untitled\database.db' # must be full path def connect_db(): try: sqlite_conn = sqlite3.connect(DATABASE) return sqlite_conn except sqlite3.Error, e: print "connection error: ", "\n", e.args[0] if __...
2228105a1e3530b69109804aa25254e8eea8f3e0
esauvisky/arch-install
/config/nautilus-scripts/Scripts Examples/System Configuration/pynautilus
669
3.5
4
#!/usr/bin/env python """ This function extracts Nautilus variables from the environment, splits them on newlines and puts results in dictionary. Example: ala = parse_nautilus_environment() for tmp in ala['NAUTILUS_SCRIPT_SELECTED_FILE_PATHS']: print tmp """ def parse_nautilus_environment(): import os re...
a66dd6119d39e654f8479d0ac212da3b8eefd5a0
av5350/nitzanim_lesson_5
/date_difference.py
481
3.78125
4
import random import datetime MIN_MONTH = 1 MAX_MONTH = 12 MIN_YEAR = 1980 MAX_YEAR = 2020 NUMBER_OF_MONTHS = 12 month = random.randint(MIN_MONTH, MAX_MONTH) year = random.randint(MIN_YEAR, MAX_YEAR) difference_month = datetime.date.today().month - month difference_year = datetime.date.today().year - ye...
483c9eeebfc68800f02b11ad3f78ca260cb99aa6
RHARO-DATA/DataStructure--Algorithms
/Fibo.py
648
3.90625
4
def fibo(i): if i == 0: return 0 elif i ==1: return 1 else: return fibo(i-2) + fibo(i-1) for x in range(10): print(fibo(x)) # Memorization fibonacci_cache = {} def fibonacci(n): # if we have the cached value, then return it if n in fibonacci_cache: ret...
6f149eaf17b08425f22b7cb0350996eef25458ae
RHARO-DATA/DataStructure--Algorithms
/Stocks.py
252
3.546875
4
""" Sell stock input [7,1,5,3,6,4] output[5] """" def max_profit(prices): if prices ==[]: return 0 res = 0 min = prices [0] for p in prices: if min > p: min = p res = max(res,p-min)s return res
c8c4b7acbfbf0843f6a6923d1d92128034b79a48
haxorsprogramming/DQLAB-DATA-SCIENCE-Sertification
/Fundamental/Graphic_7/title_bar.py
516
3.59375
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt table = pd.read_csv("https://storage.googleapis.com/dqlab-dataset/penduduk_gender_head.csv") table.head() x_label = table['NAMA KELURAHAN'] plt.bar(x=np.arange(len(x_label)),height=table['LAKI-LAKI WNI']) plt.xticks(np.arange(len(x_label)), table...
c3e86a952b5a0047dba176db73e6b48979e95568
JNDX1/PyCanal
/pycanal/utils.py
1,753
3.578125
4
""" Utility functions for analyses """ import pandas as pd def read_fasta(fasta): """ Read the protein sequences in a fasta file Parameters ----------- fasta : str Filename of fasta file containing protein sequences Returns ---------- (list_of_headers, list_of_sequ...
52109e538ddbddc8edc7c5d246c8eee978bd1d79
shou1018/ZM
/quicksort3.py
955
3.75
4
def quickSort(arr): less = [] pivotList = [] more = [] arr_length = len(arr) if arr_length <= 1: return arr else: pivot = arr[0] # Change this line for i in arr: if i < pivot: less.append(i) elif i > pivot: more.appe...
84cf68a40e950e1703a4c9ba7bf81416e1425138
longvhdeveloper/prework
/checkpoint2.py
729
3.5625
4
class Solution: def print_matrix(self, n): ans = [] row_len = 2 * n - 1 col_len = 2 * n - 1 template = [0 for _ in range(col_len)] number = n start = 0 end = col_len direc = 1 for row in range(row_len): ...
5766534c0e915f055d9fdfe3d2451303ddfbc1d7
zs18034pn/ORS-PA-18-Homework07
/task2.py
727
4.375
4
""" =================== TASK 2 ==================== * Name: Recursive Sum * * Write a recursive function that will sum given * list of integer numbers. * * Note: Please describe in details possible cases * in which your solution might not work. * * Use main() function to test your solution. ========================...
34ecb144838a2744942295310a83169109d41cf8
serendia95/Ujian_Himpunan
/Ujian_Himpunan.py
1,712
3.953125
4
# A = himpunan (set) bilangan genap antara 1 dan 20. # B = himpunan (set) bilangan ganjil antara 1 dan 20. # C = himpunan (set) bilangan negatif lebih dari -10. # D = himpunan (set) bilangan prima antara 1 dan 20. # E = himpunan (set) bilangan komposit antara 1 dan 20. # Buatlah sebuah file python (.py) yang dap...
f535b34b42c1907791cbf1509d36ae09781abca9
Adjective-Object/csc321
/a1/csv_analysis.py
1,053
3.65625
4
import sys def analyzecsv(fpath): count = 0 personMatches = 0 genderMatches = 0 for line in open(fpath).readlines(): line = [s.strip() for s in line.split(",")] if int(line[-2]): personMatches += 1 if int(line[-1]): genderMatches += 1 count += 1 return (float(genderMatches) / count, float(pers...
54bf5f231b3b93ce08e5e393d25470bb5bd51fc4
CS-rjp/Intro-Python-II
/src/adv.py
2,792
3.890625
4
from player import Player from room import Room from item import Item # Declare all the rooms room_outside = Room("Forest Outside the Cave Entrance", "North of you, the cave mount beckons."), room_foyer = Room("Foyer", """Dim light filters in from the south. Dusty passages run north and east."""...
47820d633d1153bbce2cf95569085c46c1bd7013
BorisovDm/SBT_Autumn_2017
/Python/lectures/6_scripts/lesson1/example3_good_step1.py
1,187
3.578125
4
#coding=utf-8 # импортируем специальную библиотеку import pandas # Глобальные константы обычно в верхнем регистре называют FILENAME = 'sells3.csv' DATE_FIELD = 'date' GOODS_COUNT_FIELD = 'goods_number' TOTAL_MONEY_FIELD = 'total_money' START_DATE = '05.01.2017' FINISH_DATE = '10.01.2017' # теперь мы читаем файл с на...
72b58e70ea09ac0bb883e9d4068a67a8e643c1ad
manlaig/euler
/15/main.py
555
3.78125
4
from math import factorial """ Starting in the top-left corner of a M x N grid, and only being able to move to the right and down, how many routes are there to the bottom-right corner? We can come up with a O(1) solution if we use combinatorics """ # m choose n (mCn) def choose(n, m): return factorial(n) // (facto...
c5fed1aea371d66e4c9e1bd4fb1ea1f489066a33
RnLe/AP1920-AJRM
/PeP Workshop/exercises-toolbox-1/1-python/7-wordcount/loesung1.py
358
3.546875
4
with open('text.txt') as f: words = f.read().split() counts = dict() for word in words: if word in counts: counts[word] += 1 else: counts[word] = 1 def get_count(x): return x[1] result = sorted(counts.items(), key=get_count, reverse=True) for key, count in result...
807cf933b75d2f1cf3c1f559e28e91f3ec976ba9
foohyfooh/Competitive-Programming
/LeetCode/152 - Maximum Product Subarray.py
512
3.578125
4
# Need to keep track of the current running min and max since a negation could make that the next min or max class Solution: def maxProduct(self, nums: List[int]) -> int: max_product = temp_min = temp_max = nums[0] for num in nums[1:]: num_by_min = num * temp_min num_by_max = num * temp_...
7e109e6d7ceb4e3a55a688bdc9c0607fd255e710
sana-malik/ProjectEuler
/P006.py
390
3.796875
4
from math import pow def diff(n): square_of_sum = pow(n*(n+1)/2, 2) sum_of_squares = sum([pow(i, 2) for i in range(1, n+1)]) return int(square_of_sum - sum_of_squares) #### closed-er form def closed(n): square_of_sum = pow(n*(n+1)/2, 2) sum_of_squares = n*(n+1)*(2*n+1)/6 return int(square_of_sum - sum_of_square...
11b4802171e6f421ac68633c9e45da48c63993b8
sana-malik/ProjectEuler
/P010.py
325
3.953125
4
from math import sqrt def is_prime(n): for i in range(2, int(sqrt(n)+1)): if n % i == 0: return False return True def sum_of_primes(n): if n < 2: return 0 sum = 2 if n % 2 == 0: n = n - 1 for i in range(3, n, 2): if is_prime(i): sum += i return sum print sum_of_primes(10) print sum_of_primes(200...
e42ea7453fb8b1e7b7dc18ba1a332c95a1a1761c
Nolan111/Lesson1
/ld.py
208
3.65625
4
numbers = [3, 5, 7, 9, 10.5] print(numbers) numbers.append('Python') print(numbers) print(len(numbers)) print(numbers[0]) print(numbers[5]) print(numbers[1:5]) numbers.remove('Python') print(numbers)
39061872b5d5acb8e45ca32f105dd271c2b91ffe
joeherold/wcc_fh_wkw_python
/Challenge_1/members/martin.py
3,505
3.609375
4
# gegebene Liste myNumberList = [25, 45, 25, 78, 21, 14, 87, 32, 57, 54] # gewünschtes Ergebnis # mySortedNumberList = [14, 21, 25, 25, 32, 45, 54, 57, 78, 87] # Bonusaufgabe # gewünschtes Ergebnis ist das Auffüllen der leeren Stellen zwischen den Zahlen mit 0 myFancySortedNumberList = [14, 0, 0, 0, 0, 0, 0, 21, 0, 0,...
9561581f1d4b2d1d89625ebacb253f06b854c91c
gjredondo/REPOSITORIODBGUSTAVOREDONDO
/tarea041.py
619
3.71875
4
def funexpo(fbase,fexpo): res=fbase for i in range(1,fexpo): res=res*fbase return res def leerdatos(): numero = int (input("Digite un numero para realizar la operacion: ")) formula(numero) def factorial (*n): for x in n: fac=1 for y in range(1,x+1): fac...
d93b00c503f7cf24933359240b330423efc511e2
Chris-uche/Pythonbasics
/Work/loops.py
670
4.15625
4
for x in range(0,10,2): #start,stop,step print(x) #The While Loop section uche = True while uche: name = input("insert something here: ") if name == "stop": uche = False break Fredschoolname = True while Fredschoolname: nameOfschool =input("insert Fred's schoool name: ") if nam...
5b265ed76942220cd51cdf18758b53467c84ee99
chetali58/practice-code
/python/powerof2.py
172
3.84375
4
#code def power(y): if((y>0) and (y&(y-1)==0)): print('YES') else: print('NO') x= int(input()) for i in range (0,x): power(int(input()))
9912d7f185e43743a2bcfc4bfbb40524e3e70e6c
fengbingchun/NN_Test
/demo/Python/KNN/test_knn_classification.py
1,206
3.90625
4
# reference: https://docs.opencv.org/3.1.0/d5/d26/tutorial_py_knn_understanding.html # opencv-3.3.0/doc/py_tutorials/py_ml/py_knn/py_knn_opencv import cv2 import numpy as np import matplotlib.pyplot as plt # Blog: http://blog.csdn.net/fengbingchun/article/details/78465497 # Feature set containing (x,y) val...
e5cdc19f5a5ea5366e0965b49cc15c7c8eb7dcbc
harryseo1992/BookManager
/books.py
29,706
3.78125
4
# Constant value def SEARCH_CATEGORIES() -> list: """ Create constant list of values for search categories. :return: A list of search categories defined by the text_file. # """ library_tuple = get_info() return list(library_tuple[0].keys()) def SHELF_SET() -> set: # Constant value """ ...
495d883105ed0445dd735e09c8c81d7ffcb47e3b
atayigit/Alistirmalar-3
/stupidsort.py
836
3.859375
4
def stupidsort(): liste=[] a=int(input("liste uzunluğu girin:")) for i in range(0,a): l=int(input("listeye eleman girin:")) liste.append(l) #kullanıcadan alınacak bilgilerle liste oluşturdum # şimdi sıralıyorum print(liste) k=0 #bir değişken tanımlayarak liste i...
66c18b5084ff0371e754614d9a93bdff0c233830
CodeBall/Learn-Python-The-Hard-Way
/yanzilu/ex37.py
2,618
3.703125
4
# -*- coding:utf-8 -*- #Exercise 37:Symbol Review print """ ONE Keywords: KEYWORD EXAMPLE and True and False == False as with X as Y:pass assert assert False,"Error!" break while True:break class class Person(object) continue while True:continue def def x(): elif if: X;elif:Y;else:...
3c84becfe37e4edfbef8f25fc6548af779c570f0
CodeBall/Learn-Python-The-Hard-Way
/yanzilu/ex18.py
564
4.03125
4
#Names,Variables,Code,Functions #This one is like your script with argv def print_two(*args): arg1,arg2 = args print"arg1:%r,arg2:%r" %(arg1,arg2) #ok,thst *args is actually pointless,we can just do this def print_two_again(arg1,arg2): print"arg1:%r,arg2:%r" %(arg1,arg2) #this jua=st takes one argument d...
bbf65e88dffba753cd3ae13fef8d76c2e6439692
CodeBall/Learn-Python-The-Hard-Way
/yanzilu/ex32.py
2,647
4.4375
4
# -*- coding: utf-8 -*- #Exercise 32:Loops and List the_count = [1,2,3,4,5] fruits = ['apples','oranges','pears','banana'] change = [1,'pennies',2,'dimes',3,'quarters'] print "change[0]: ", change[0] print "change[2:5]: ", change[2:5] #this first kind of for-loop goes through a list for number in the_count: print "...
3e0a8595bf293a99865648cf0e586be540b0df16
kmehran1106/HackerRank-Python
/Medium/Magic Square/code_magic_square_forming.py
3,534
4.09375
4
import pytest from typing import List from copy import deepcopy def print_matrix(m: List[List[int]]): s = "" for i in m: k = str(i) k = k[1:-1] s += f"{k}\n" print(s) def generate_magic_square() -> List[List[int]]: """ [ The algorithm here is to move to the upper...
aea946fc73ceb3e352d77803e6c4ca292fd10330
Felipe-Ferreira-Lopes/Provas
/prova PO/prova.py
643
3.53125
4
def cal_megabytes (bytes): megabytes = bytes / 1000 return megabytes with open ('usuarios.txt', 'r') as fonte: texto = fonte.readlines() with open ('relatorio.txt', 'w') as relatorio: print('ACME Inc. Uso do espaco em disco pelos usuarios') print('-------------------------...
135d939d4ed6f3a24d45e7a0cbb884be8f005bdd
cvva/RepasoPython
/ClasePythonPOO/ejem05.py
2,442
3.953125
4
class Agenda: def __init__(self): self.contactos = [] def menu(self): print() menu = [ ['Agenda de Contactos'], ['==================='], ['1. Agregar contacto'], ['2. Listar contacto'], ['3. Buscar contacto'], ...
2390bec603d50c46d441c4ede628b9de137cff4b
putsala/python-learning
/for_loop.py
4,036
3.9375
4
def sum_of_n(n): """ Sum of all numbers until n. """ if n < 1: return 0 s = 0 for i in range(1, n + 1): s += i return s def sum_of_list(l): """ Sum of all numbers in list l. """ s = 0 for k in l: s = s + k return s def find_element(l, a): ...
cbc543826ce765792a851e62e3ac7f08ed6eb94d
Amit2016-17/tg-brew-anomaly
/processors/example/example.py
203
3.65625
4
# A simple processor. It reads stdin and writes it to stdout. import sys def main(): for line in sys.stdin: print(line.rstrip()) sys.stdout.flush() if __name__ == '__main__': main()
c2c6a61d9581fe7b6d4caeb50bff65f3670e35fe
kamath7/Automate-The-Boring-Stuff-Al
/Logging/app.py
1,170
3.734375
4
#Starting logging # raise Exception('Random error message') def boxPrint(symbol,width,height): if len(symbol) != 1: raise Exception('Symbol needs to be a string of length 1') if (width < 2) or (height < 2): raise Exception('Width and height must be greater than 2') print(symbol * width) ...
945be4970aa3bfbee252c7198e5a46a8e0c235db
kamath7/Automate-The-Boring-Stuff-Al
/Regex/app3.py
492
3.515625
4
import re phoneRegex = re.compile(r'\d\d\d-\d\d\d-\d\d\d\d') print(phoneRegex.findall('my number is 910-789-2910 and my alternate number 890-238-1290')) search_string = '2 onions, 3 green grams, 15 sodas, 11 packets lays' items_regex = re.compile(r'\d+\s\w+') print(items_regex.findall(search_string)) vowelRegex = r...