blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
dc62cd339e4780024f77a2e7c44df00b6464699f
charromax/Ejercicios-en-codigo
/practica3ej7.py
507
4.03125
4
# Dados dos números A y B construir un algoritmo que permita # obtener A^B sin utilizar la operación de potencia. #------------------------------------------------------------------- base = int(input("ingrese la base: ")) potencia = int(input("ingrese la potencia: ")) resultado = 1 for indice in range(0, potencia): ...
6da0a636dc06782882f6c162abfc73884b6eb815
marijanedjalkova/Constraint-Problem-Solver
/solver.py
8,250
3.78125
4
from variable import * import sys class Solver: """ Class represents a general binary constraint problem solver. """ def __init__(self, problem, ordering, task_type): """ Class constructor. :param problem: what problem to solve :param ordering: a flag marking what order to use for variables, e.g. 0 for d...
c24491aeabf2094d80e32072b7e1eeaacd56de18
muffix/exercism-python
/isogram/isogram.py
181
3.8125
4
from collections import Counter def is_isogram(string: str): counter = Counter(c for c in string.lower() if 'a' <= c <= 'z') return sum(counter.values()) == len(counter)
2501adbb006645f5289218d4c3b1e07075cec96c
yannhyu/functional_programming
/decorator_02.py
332
3.609375
4
import time def factorial(n): return 1 if n==0 else n*factorial(n-1) def timer(func): def inner(arg): t0 = time.time() func(arg) t1 = time.time() return t1-t0 return inner @timer def timed_factorial(n): return 1 if n==0 else n*factorial(n-1) res = timed_factorial(500...
0c10e5c2f26bd52a21f011fe0a9b64e4b8723b98
yannhyu/functional_programming
/fp_higher_func_example_01.py
720
3.546875
4
l_factorial = lambda n: 1 if n == 0 else n*l_factorial(n-1) assert(l_factorial(3) == 6) # Timing implementations # (1) The procedural way going line by line import time t0 = time.time() l_factorial(900) t1 = time.time() print('Took: %.5f s' % (t1-t0)) # (2) The functional way with a wrapper function def timer(fnc,...
8fce38d7e680137a3ac364065e2645fe8078f400
GoldenCheetah/scikit-sports
/examples/power_profile/plot_activity_power_profile.py
2,048
3.75
4
""" ===================================== Compute Power-Profile for an Activity ===================================== This example shows how to compute the power-profile of a cyclist for a single activity. We will also show how to plot those information. """ # Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com> # L...
e8d0214846bf20e3a7f4ed36375b392f1813c717
oscar1234456/Leetcode
/March LeetCoding Challenge 2021/Average of Levels in Binary Tree.py
853
3.75
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right import queue class Solution: def averageOfLevels(self, root: TreeNode) -> List[float]: q = queue.Queue() res...
557048635a0fac321e9753772afb15fad2107e18
oscar1234456/Leetcode
/March LeetCoding Challenge 2021/Intersection of Two Linked Lists.py
1,032
3.53125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None # Solution 1 : Time limit exceed (O(M*N)) class Solution: def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode: nodeB = headB nodeA = headA ...
b2d9d61df9459cda6f13f6124770a76b40d1619c
oscar1234456/Leetcode
/April LeetCoding Challenge 2021/Palindrome Linked List.py
618
3.71875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def isPalindrome(self, head: ListNode) -> bool: myStack = list() now = head ori = "" while now: myStack.a...
ad5589c7c85fe70ab474af312ce857be598b2026
oscar1234456/Leetcode
/January LeetCoding Challenge 2021/Word Ladder.py
1,790
3.703125
4
import queue class Solution: def ladderLength(self, beginWord: str, endWord: str, wordList: List[str]) -> int: words = wordList visitedPool = set() q = queue.Queue() level = 0 size = 0 q.put(beginWord) #put first word -> beginWord visitedPool.add(begi...
ef199a3de8f0792753e372e0e276fe919bf49f67
josueal1/chord_transposer
/chord_transposer.py
4,358
3.71875
4
# Creator Josue Lopez # Mon Jul 16 2018 # Python 3.6 """ This source code is a program that helps transpose a list of the musical chords from one musical key to another key. Currently, the this program only supports # (sharp notes). When the script is run, the 'main' function handles the entire program. """ # Import...
56a50a9b6fa901e80983bb6635066e1fca9e1c02
mammykins/pyfund
/exceptional.py
1,066
3.90625
4
"""A module for demonstrating exceptions""" import sys from math import log def convert(s): """Convert to integer.""" x = -1 try: x = int(s) # print("Conversion succeeded! x =", x) except (ValueError, TypeError): # can accept tuple of types # print("Conversion fail...
34abbdd6e3ce202df892cf7879e4d026e8f8cae9
bengeos/TestHomeAutomation_Project
/SocketProgram/ServerClass.py
1,500
3.578125
4
import socket from threading import * class client(Thread): message_data = 'SERVER_DATA' def __init__(self, socket, address): Thread.__init__(self) self.sock = socket self.addr = address self.send_data = "PORT1ON" print address[0] self.start() def run(self): ...
73ef940c89c894776eeda5ee64e5fcad60666b11
fedorkolmykow/oughts-crosses
/o&c.py
4,122
4
4
FIRST_COLUMN = ["a", "b", "c", "d", "e", ] FIRST_ROW = ["1", "2", "3", "4", "5", ] PLAYERS = ["Mario", "Marta", ] def start(): if " " in PLAYERS: print("ALARM! MALICIOUS CODE!") print("Добро пожаловать в крестики нолики!") print("Выберите размерность поля: 3, 4 или 5") size = input() if ...
004c1965c3ccc6ef86edc5283323a29c7aabb033
AkileshRaoG/Python1.0
/python_learning/ex18/ex18.py
1,172
3.875
4
from sys import argv script, input_file = argv def print_all(f): print f.read() def rewind(f): f.seek(0) def print_a_line(line_count, f): print line_count, f.readline() current_file = open(input_file) print "First let's print the whole file: \n" print_all(current_file) print "Let's rewind." rewind(c...
ac20147702f5bb3c274ccbe981905bacb37746f6
kunalt4/ProblemSolvingDSandAlgo
/LeetCode/reorder_list.py
1,472
3.890625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def reorderList(self, head: ListNode) -> None: """ Do not return anything, modify head in-place instead. """ if head ...
6e64f1250c9fa8ad03dab5245da9e94caf2473f8
kunalt4/ProblemSolvingDSandAlgo
/GeeksForGeeks/morganString.py
1,302
3.90625
4
#!/bin/python3 import math import os import random import re import sys # Complete the morganAndString function below. def morganAndString(a, b): result = [] temp = [] list_a = list(a) list_b = list(b) list_a.reverse() list_b.reverse() print(list_b) print(list_a) i = 0 while(...
132a8426441a948a45b7ecc54137945612bc542e
kunalt4/ProblemSolvingDSandAlgo
/LeetCode/find_right_interval.py
530
3.53125
4
class Solution: def findRightInterval(self, intervals: List[List[int]]) -> List[int]: l = sorted((num[0], i) for i, num in enumerate(intervals)) res = [] for interval in intervals: re = bisect.bisect_left(l, (interval[1],)) if re < len(l): res.append(l...
8fb69154f825c8cd057ff8d8da1dd73670a447c6
kunalt4/ProblemSolvingDSandAlgo
/LeetCode/valid_paranthesis.py
474
3.5625
4
class Solution: def isValid(self, s: str) -> bool: paran_dict = {')':'(','}':'{',']':'['} stack_p = [] for c in s: if c in paran_dict.values(): stack_p.append(c) elif c in paran_dict.keys(): if stack_p == [] or paran_di...
83522b63fdcb1b7816cbaad79e71525fbe421c33
kunalt4/ProblemSolvingDSandAlgo
/LeetCode/power_of_four.py
162
3.625
4
class Solution: def isPowerOfFour(self, num: int) -> bool: num = bin(num) return num[2] == '1' and ('1' not in num[3:]) and len(num[3:])%2==0
83dfed6e5b6b0cc815bc3b15266a4620ea589c6f
bravocharliemike/100days
/19-21-itertools/bite17.py
613
4.03125
4
import itertools friends = 'Bob Dante Julian Martin'.split() def friends_teams(friends_list, team_size=2, order_does_matter=False): """The function takes a list of friends, a team size (2 by default) and an order does matter argument. It returns all possible teams. If order does matter is set to True the ...
3e2a1b30573662a4c0263a411a357a0aa7a158fe
JunchuangYang/PythonInterView
/Python剑指Offer/016_合并有序链表/016.py
1,629
3.796875
4
__author__ = 'lenovo' """ 合并有序链表,满足单调不递减规则 """ # 定义结点 class LinkNode(object): def __init__(self,value): self.val = value self.next = None # 定义链表 class Link(object): def __init__(self,values): self.node = self.__set_link(values) # 返回链表头结点 def get_link(self): ...
83767e17d7c6a0726cda96972de62388cb2a61a1
JunchuangYang/PythonInterView
/Python剑指Offer/035_数组中的逆序对/035.py
795
3.96875
4
__author__ = 'lenovo' count = 0 def merge_sort(alist): length = len(alist) if length == 1: return alist mid = length // 2 left = merge_sort(alist[:mid]) right = merge_sort(alist[mid:]) return sort(left,right) def sort(left,right): left_length = len(left) right_l...
3bf073379f65de02e96faa76d28bd8147f353362
JunchuangYang/PythonInterView
/Python剑指Offer/015_反转链表/015.py
1,264
3.875
4
__author__ = 'lenovo' # 定义结点 class LinkNode(object): def __init__(self,value): self.val = value self.next = None # 定义链表 class Link(object): def __init__(self,values): self.node = self.__set_link(values) # 返回链表头结点 def get_link(self): return self.node #...
c28985a5df39fdd55f44762a5505d0ff8b92244a
JunchuangYang/PythonInterView
/Python剑指Offer/013_调整数组顺序使奇数位于偶数前面/013.py
1,318
3.984375
4
__author__ = 'lenovo' """ 调整数组顺序使奇数位于偶数前面 使用两个指针,前后各一个,为了更好的扩展性,可以把判断奇偶部分抽取出来 """ def alist_order(alist): head = 0 tail = len(alist) - 1 while head<=tail: while not is_even(alist[head]): head += 1 while is_even(alist[tail]) : tail -= 1 if head < t...
5a66ebd6df0abbc1caab4570f91c3293355fe076
JunchuangYang/PythonInterView
/Python剑指Offer/019_顺时针打印矩阵/019.py
1,217
3.828125
4
__author__ = 'lenovo' def print_matrix(mat): rows = len(mat)#行 cols = len(mat[0]) if mat else 0#列 start = 0 ret = [] # 每次循环打印一圈 while start * 2 < rows and start * 2 < cols: circle_matrix(mat,start,rows,cols,ret) start += 1 return ret def circle_matrix(mat,start...
85e6d94e38462c03102b4fac3f0d34c4369d76bd
JunchuangYang/PythonInterView
/Python剑指Offer/005_重建二叉树/005.py
2,626
3.78125
4
#__author__ = 'lenovo' from collections import deque # 定义二叉树结点 class TreeNode(object): def __init__(self,x): self.val = x self.left = None self.right = None class Tree(object): ''' 二叉树 ''' def __init__(self): self.root = None #前序遍历 def p...
b7fe804fc7ed79ba77226721f43a3e65d82e237c
eaglesquads/ecc-scripts
/pointUtils.py
3,048
3.703125
4
from gmpy2 import invert EXAM_MODE = False # Set to true to show work # Special mod function to make sure x mod x = x, not x mod x = 0 def mod(int, p): if (int == p): return int elif ((int < p) and (int >= 0)): return int; else: return (int % p) # Function that assures s will be a...
955afd976c8ab9aebe3eaf98477faaf2574ebb2b
QingfengYang/demo-code
/python3/rb_sort/insort_sort.py
1,094
3.6875
4
#!/usr/bin/env python # encoding: utf-8 class RobertInsertSort: @staticmethod def flip_sort(arr: [], correct_pos: int, item_index: int): tmp: int = arr[item_index] for i in range(item_index, correct_pos, -1): arr[i] = arr[i - 1] arr[correct_pos] = tmp @staticmethod ...
53af82c2d4641411ef91c08e0e86d814a538c566
LukaszSikorski/Wzorce
/src/Student.py
1,273
3.546875
4
class Student: def __init__(self, name:str,surname:str,email:str,album:int,age:int): self._name:str = name self._surname:str = surname self._email:str = email self._album:int = album self._age:int = age def __repr__(self): result:str = "Imie {}\nNazwisko {}\nema...
07b07a33504a937d3e960ae4fd58e4e509ef91c6
nihal-wadhwa/Computer-Science-1
/Labs/Lab01/write_a_meme.py
5,785
4.4375
4
""" Author: Nihal Wadhwa Typography: This program's purpose is to create a phrase, "SPEEDY TOM," using turtle graphics to commemorate Tom's speed. """ import turtle as tt def init() : """ Moves the turtle 275 units to the left to set up for the beginning of the phrase. Precondition: turtle is ...
9ad2e6f1e44f976b5a34b08705420da4ee5598b5
nihal-wadhwa/Computer-Science-1
/Labs/Lab07/top_10_years.py
2,524
4.21875
4
""" CSCI-141 Week 9: Dictionaries & Dataclasses Lab: 07-BabyNames Author: RIT CS This is the third program that computes the top 10 female and top 10 male baby names over a range of years. The program requires two command line arguments, the start year, followed by the end year. Assuming the working directory is set...
937d2587540621a7443b4af857d53762763e9254
nihal-wadhwa/Computer-Science-1
/Homeworks/HW9/birthday.py
2,839
3.796875
4
""" Nihal Wadhwa Homework 9: Birthdays """ from dataclasses import dataclass @dataclass(frozen = True) class Birthday: month: str day: int year: int def build_dictionary(filename): """ Creates a dictionary from a file with birthdays. The dictionaries will have a Birthday object a...
6f2f3e98178a4d0f5eb4cd90bcf9d987ef723ea0
ArnabRC1710/Python-assignments
/Python assignment 1/simple message2.py
166
3.890625
4
# setting a string variable message = "Hello..!! this a text variable" print(message) # Asking for input message = input('Enter new message \n') print(message)
e3de3150d3939f77ac723f065646f201117531f0
ArnabRC1710/Python-assignments
/Python assignment 1/simple message9.py
187
4.28125
4
#Create a list of names name_list = ["Kankatika","Anirban","Santu","Sayan"] #Use a for loop to print the elemets of the list for name in name_list: { print(name) }
3eec25911833dbd8837b63692cace0a514ae3eef
FrancesFerrabee/Computer-Science-course-2018W
/a08q1.py
3,910
3.640625
4
import check #################################### ## Frances Ferrabee 20712523 ## CS 116 Winter 2018 ## Assignment 08 Problem 01 #################################### # Question 1 A ## common_letter(s): returns the maximum number of times a ## letter appears in s ## common_letter: Str-> Str def common_letter(s): ...
aa1b299dc936708e19562cf416b2012c1fa647ca
FrancesFerrabee/Computer-Science-course-2018W
/a06q2.py
1,138
3.71875
4
import check #################################### ## Frances Ferrabee 20712523 ## CS 116 Winter 2018 ## Assignment 06 Problem 02 #################################### ## find_bigger(ints): returns in order the numbers in ints that are bigger ## than all the numbers that came before in ints. ## find_bigger: (listof...
e1201d911955e5f267cdbcdb131b8179a6d97b43
guori12321/todo
/todo/models.py
1,417
3.671875
4
# coding=utf8 class Task(object): """ One task looks like 1. (x) Go shopping if this task not done, leave there blank. Attrributes id int content str done bool """ def __init__(self, id, content, done=False): self.id = id self.content =...
cf877447faaf5c5c1f6957650dd1c3267c47adc5
yaoqi/someprogram
/python/binary_search.py
1,759
3.8125
4
class Solution: def binary_search(self, arr, target): low = 0 high = len(arr) - 1 while low <= high: mid = (low + high) // 2 if arr[mid] == target: return mid elif arr[mid] > target: high = mid - 1 else: ...
6f2539ffb11dc17d1f277f6cbe7e7ed2b10377a1
loyti/GitHubRepoAssingment
/Python/pythonPlay/bikePlay.py
1,065
4.15625
4
class Bike(object): def __init__ (price,maxSpeed,miles): self.price = "$Really$ Expen$ive" self.maxSpeed = maxSpeed self.miles = 0 def displayInfo(self): print "A little about your Bike: $Price: {}, {} max kph & {} miles traveled".format(str(self.price), int(self.maxSpeed), str(s...
745bc218e8a0ace9fce26eb7b40e60a86eb910fb
AdiGarmendia/critters_and_croquettes
/animals/llama.py
417
3.921875
4
from .animal import Animal from movements import Walking class Llama(Animal, Walking): # Remove redundant properties from Llama's initialization, and set their values via Animal def __init__(self, name, species, shift, food, chip_num): Animal.__init__(self, name, species, food, chip_num) self....
fe989370660808dd4ecee78c545dcff8e25a1210
bimarakajati/Dasar-Pemrograman
/Praktikum/Praktikum 4/Kasus 5.py
271
3.6875
4
#input pjg = int(input('Panjang tanah: ')) lbr = int(input('Lebar tanah: ')) x = input('Apakah Pak Joni dan Pak Soni setuju? ') #output if 'setuju' in x : print(float(pjg * lbr), '\n', float((pjg * lbr) / 2)) else : print(float(pjg * lbr), '\n', float(pjg * lbr))
0ca2eb94a914dcd3629a0bc022603564a6ab46a1
bimarakajati/Dasar-Pemrograman
/Praktikum/Praktikum 6/Kasus 6.py
338
3.734375
4
#kamus saldo = int(input('Saldo awal: ')) sisa = saldo #algoritma while True: n = int(input('Pengeluaran soni hari ini (isikan -1 untuk keluar): ')) if n == -1: print('sisa saldo', sisa) break sisa = sisa - n if sisa < 0: print('saldo tidak cukup') print('sisa saldo', sis...
57ff46eb276c7a4181eb8488bd9a4561ebdeabf5
bimarakajati/Dasar-Pemrograman
/Tugas/coba/pustaka.py
764
3.609375
4
def BinarySearch(A,cari): idx = [] # list kosong found = False batasbawah = 0 # left batasatas = len(A)-1 # right # Algoritma while batasbawah <= batasatas and not found: mid = (batasatas+batasbawah)//2 # middle if A[mid] == cari: found = True else: ...
bc69ea610d69eb12ff3fa3c24d762c949f4c020e
bimarakajati/Dasar-Pemrograman
/UTS/#Latihan 2/backup/4 copy.py
298
3.78125
4
baris = int(input('Masukkan Jumlah Baris : ')) kolom = int(input('Masukkan Jumlah Kolom : ')) n=1 for b in range(0,baris) : for k in range(0,kolom) : print(n, end=" ") n+=1 print(" ") print('Nilai tertinggi kolom ganjil adalah = ') print('Nilai terendah kolom ganjil adalah = ')
92d2a769a908023a1ed7a5e1e7a76fde96c3ffe1
bimarakajati/Dasar-Pemrograman
/Random/tahun kabisat.py
707
3.703125
4
# Menentukan tahun kabisat tahun = int(input('Masukan tahun: ')) if (tahun % 4) == 0: # Jika angka tahun itu tidak habis dibagi 400, tidak habis dibagi 100 akan tetapi habis dibagi 4, maka tahun itu merupakan tahun kabisat. if (tahun % 100) == 0: # Jika angka tahun itu tidak habis dibagi 400 tetapi habis dibagi 1...
ad20ccffbf7205ba0b567e37b106cbd578cb3357
bimarakajati/Dasar-Pemrograman
/UTS/#Latihan 1/fix/soal 1.py
3,497
3.78125
4
# kamus nilai1 = int(input('Masukkan nilai 1 = ')) if nilai1 > 100: # jika nilai lebih dari 100 program akan keluar print('Input maksimal adalah 100! Program berhenti') quit() nilai2 = int(input('Masukkan nilai 2 = ')) if nilai2 > 100: # jika nilai lebih dari 100 program akan keluar print('Input maksimal a...
7a9c33c465afe93d69ada453f5f1a50d3cf7d517
bimarakajati/Dasar-Pemrograman
/Tugas Kelompok/1/bima2.py
1,298
3.90625
4
# Program kalkulator sederhana # Kamus jawab = 'ya' # Agar program bisa ke menu setelah selesai melakukan operasi while jawab == 'ya': print('\nSelamat datang di Program Kalkulator Sederhana\n') # Menu kalkulator print('Menu operasi') print('1. Penjumlahan') print('2. Pengurangan') print('3. ...
66bbc9235c582149d53a889ab361165c3cbf64c1
bimarakajati/Dasar-Pemrograman
/UAS/Latihan 1/naufal/3.py
259
3.796875
4
print('Masukkan 10 data bil bulat:') data = [] for i in range(1,11): data.append(int(input(f'bil {i} = '))) print(f'rata-rata = {sum(data)/len(data)}') print('daftar nilai diatas rata-rata') for i in data: if i >= sum(data)/len(data): print(i)
3ddc13ffa7d4bad42d8f10f23a1737dc1f972f0b
bimarakajati/Dasar-Pemrograman
/Tugas/List/LIST_A11.2020.13088_BIMA RAKAJATI_4114.py
1,495
3.703125
4
# Bima Rakajati # A11.2020.13088 # list fakultas fakultas = ['Ilmu Komputer', 'Teknik', 'Ekonomi'] fakultas.append('Kesehatan') # menambahkan kesehatan ke list fakultas print(fakultas) fakultas.remove('Teknik') # menghapus teknik dari list fakultas print(fakultas) print('Fakultas pertama adalah {} '.format(fakultas[0...
8f012c33026978c2d56e79314a84565dd04d5dc9
bimarakajati/Dasar-Pemrograman
/Random/kelompok umur.py
491
4.0625
4
# Kamus umur = 0 umur = int(input('Masukkan umur (1-55): ')) # Nilai bertipe integer #algoritma if umur <= 5: print('Anda mendapatkan kelompok balita') elif 5 < umur <= 13: print('Anda mendapatkan kelompok anak-anak') elif 13 < umur <= 25: print('Anda mendapatkan kelompok remaja') elif 25 < umur <= 35: ...
1f8a4ec9b98b1b3f13c1db4aeb6d69335c71b582
bimarakajati/Dasar-Pemrograman
/UTS/3.py
1,396
3.796875
4
nm = str(input("Masukkan Nama: ")) ipk = float(input("Masukkan IPK : ")) akredit = str(input("Akreditasi Universitas :")).casefold if ipk >= 3.0 : akademik = int(input("Nilai Akademik :")) ketrampilan = int(input("Nilai Keterampilan :")) psikologi = int(input("Nilai psikologikologi :")) ...
d23b1a83e89c0f1dd6c5095f83586a6ae790c844
noobcakes33/manage-dataset
/main.py
6,646
3.96875
4
# -*- coding: utf-8 -*- """ Created on Wed Feb 27 01:31:14 2019 @author: harsh """ import csv import unittest class Harsh: file_name = 'Quttinirpaaq_NP_Tundra_Plant_Phenology_2016-2017_data_1.csv' def __init__(self): # number of records to show self.n_records = 10 # making a range li...
00178d59307cf8873bf456313b566380c1d96f16
ericbollinger/AdventOfCode2017
/Day11/second.py
1,251
3.796875
4
import math def findWayBack(x,y): cur = 0 while (x != 0 or y != 0): if (x == y): return cur + x / 0.5 if (x == 0): return cur + math.fabs(x - y) if (y == 0): return cur + (math.fabs(x - y) * 2) if (x > 0): x -= 0.5 else: ...
c8dd7b1af2f083535fe3e753e7b4df2318a451d9
felipe2323/prueba-cuemby
/prueba_logica/prueba_logica.py
439
3.53125
4
def canBeSplitted(array_number): if len(array_number) <= 1: return 0 n = len(array_number) for i in range(n): left_part = sum(array_number[0:i]) right_part = sum(array_number[i:n]) if left_part == right_part: return 1 return -1 if __name__ == '__ma...
fb22c688c452c9c78503b0a6d125aef8ebaf9b56
taccisum/py_learning
/learning/property.py
820
3.890625
4
# -*- coding:utf8 -*- class Foo(object): bar = '0' class Foo1(object): def __init__(self): self.bar = '1' class Foo2(object): def __init__(self): self._bar = '2' self.__bar = '_2' class Foo3(Foo1): pass assert Foo().bar is '0' foo1 = Foo1() assert foo1.bar is '1' foo1...
7167bbd7499bf183ffb165c6e954455a6185ddf3
ETHELVECC/juego-del-ahorcado
/juego_ahorcado.py
2,495
3.59375
4
import random import os def run(): ## las image fueron las busqué como hangmanwordbank.py de chrishorton IMAGES = [ ''' + --- + | | | | | | ========= ''' ,''' + --- + | | O | | | | ========= ''' , ''' + --- + | | O | | | ...
b60a77b494f46203048a0cff57538e78bb0a0610
mercurium/discrete_optimization
/puzzle/queensSolver.py
869
3.71875
4
#!/usr/bin/python # -*- coding: utf-8 -*- def solveIt(n): sol = [0]*n for i in xrange(n//2): sol[i] = 1+2*i for i in xrange(n//2,n): sol[i] = (i-n//2) * 2 print checkIt(sol) outputData = str(n) + '\n' outputData += ' '.join(map(str, sol))+'\n' return outputData # checks if an assignment is feasible de...
1652bac2bdee972f1bbfc8f7fa5f303116329924
abderrahmaneMustapha/hackerank
/python/Nested Lists.py
760
3.734375
4
if __name__ == '__main__': arr = [] for _ in range(int(input())): name = input() score = float(input()) arr.append({'name': name, 'score': score}) def by_score(arr): return arr['score'] arr.sort(key=by_score) def min2(arr): result = [] low = arr[0...
51375d50d965718665f33a9def1ad74aa5fbec66
coding-and-trading/PracticeEveryDay
/ITCAPUP/ch3/practice_1.py
659
3.921875
4
# _*_ coding: utf-8 _*_ def calcNumbers(): number = int(input('Enter a number')) start, end = 0, 6 ans = calcRoot(number, 3) if start < ans and ans <end: print('root is ' + str()) else: print('No found.') def calcRoot(number, height): ans = 0 while ans ** height < abs(n...
d46c8d1c9045bde4a53b31cfea760e560862ec7f
maclxf/PythonPractice
/Bmi.py
424
3.921875
4
in_weight = input('您的体重KG') in_height = input('您的身高m') weight = float(in_weight) height = float(in_height) print(weight) print(height) bmi = weight / (height * height) if bmi <= 18.5 : print(bmi , '过轻') elif 18.5 < bmi <= 25 : print(bmi , '正常') elif 25 < bmi <= 28 : print(bmi , '过重') elif 28 <...
af909b212a216b5721b4505224426faae7621ce5
securepadawan/Coding-Projects
/Loops/while_for_loops.py
187
3.984375
4
wnumber = 11 while wnumber > 0: wnumber -= 1 print(wnumber) print('End of While Loop') for lnumber in range(10, -1, -1): print(lnumber) print('End of For Loop')
9bcc9a4088f6081d67388d517bc7d0ef80154e3e
securepadawan/Coding-Projects
/Converstation with a Computer/first_program_week2.py
2,283
4.125
4
print('Halt!! I am the Knight of First Python Program!. He or she who would open my program must answer these questions!') Ready = input('Are you ready?').lower() if Ready.startswith('y'): print('Great, what is your name?') # ask for their name else: print('Run me again when you are ready!') exit() m...
25cd5f699d5d7972d85140b3da94ef878545f524
shengqianfeng/deeplearning
/pystudy/deep_learning/fish_book/gradient_fish_book/gradient_descent.py
1,366
3.765625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @File : gradient_descent.py @Author : jeffsheng @Date : 2019/11/21 @Desc : 求函数对自变量数组梯度的计算 样本: np.array([3.0, 4.0, 5.0])) np.array([0.0, 2.0])) np.array([3.0, 0.0])) 梯度: 像(∂f/∂x0,∂f/∂x₁)这样的由全部变量的偏导数汇总而成的向量称为梯度(gradient) """ import numpy as np """ 求梯度:...
1db1d1dc10ac61814aec366310512d63798b8a19
shengqianfeng/deeplearning
/pystudy/deep_learning/fish_book/gradient_fish_book/gradient_method.py
2,205
3.859375
4
# coding: utf-8 import numpy as np import matplotlib.pylab as plt """ 测试:经过20次梯度下降后求得的[x0,x1]下降的轨迹图像 样本:np.array([-3.0, 4.0]) """ def numerical_gradient(f, x): # 0.0001 h = 1e-4 # 生成一个形状和x相同、所有元素都为0的数组 grad = np.zeros_like(x) for idx in range(x.size): tmp_val = x[idx] # f(x+h)的计算...
38f9013dbfd0e88e44f9cc4401c8a7bc5b6edb0d
shengqianfeng/deeplearning
/pystudy/io/file_dire_op.py
3,498
3.671875
4
""" Py操作文件和目录 其实操作系统提供的命令只是简单地调用了操作系统提供的接口函数,Python内置的os模块也可以直接调用操作系统提供的接口函数 """ import os print(os.name) # 操作系统类型 nt 如果是posix,说明系统是Linux、Unix或Mac OS X,如果是nt,就是Windows系统 # print(os.uname()) # windows不提供 """ 查看环境变量 在操作系统中定义的环境变量,全部保存在os.environ这个变量中,可以直接查看 """ print(os.environ) # 要获取某个环境变量的值,可以调用os.environ.get('key...
7d6d28eff2530406b7ec901d7ab112db53f7b9ef
shengqianfeng/deeplearning
/pystudy/oop/obj.py
7,837
4
4
class Student(object): def __init__(self, name, score): self.__name__ = name # 定义为public self.__score = score # 定义为privatee def print_score(self): print('%s: %s' % (self.__name, self.__score)) def get_name(self): return self.__name__ def get_score(self): ...
9555c60b519efaeff4dfd11469331305bdf42d96
shengqianfeng/deeplearning
/pystudy/probability_statistics/distribution/uniform_distribution.py
909
3.671875
4
""" 均匀分布 """ # from scipy.stats import uniform # import matplotlib.pyplot as plt # import numpy as np # import seaborn # seaborn.set() # # x = np.linspace(-1, 3.5, 1000) # uniform_rv_0 = uniform() # uniform_rv_1 = uniform(loc=0.5, scale=2) # # plt.plot(x, uniform_rv_0.pdf(x), color='r', lw=5, alpha=0.6, label='[0,1]') ...
d5953ed1077cc76957ad215add07a3f6ac720296
shengqianfeng/deeplearning
/pystudy/deep_learning/fish_book/gradient_descent/gradient_descent.py
1,628
3.734375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import pystudy.nn_study.d2lzh as d2l import numpy as np """ @File : gradient_descent.py @Author : jeffsheng @Date : 2019/11/29 @Desc : 《动手学深度学习》梯度下降法演示,观察学习率对自变量下降速度的影响 函数:f(x) = x * x 导数:f'(x) = 2 * x """ # 使用 x=10 作为初始值,并设学习率: η=0.2 def gd(eta): x = 10...
a576ed89e644ff4a8d77144c3bd66a514c8f9d64
shengqianfeng/deeplearning
/pystudy/deep_learning/fish_book/gradient_fish_book/loss_func.py
1,721
4.03125
4
""" 损失函数:均方差函数和交叉熵函数 """ import numpy as np """ 均方差函数 (参数 y和 t是NumPy数组.y表示神经网络输出结果,t表示正确标签结果) """ def mean_squared_error(y, t): return 0.5 * np.sum((y-t)**2) # 设“2”为正确解 t = [0, 0, 1, 0, 0, 0, 0, 0, 0, 0] # 例1: “2”的概率最高的情况(0.6) y = [0.1, 0.05, 0.6, 0.0, 0.05, 0.1, 0.0, 0.1, 0.0, 0.0] print(mean_squared_e...
b36815b151fff2d781ded43075b5cf6f5a4aa865
2015132021/drone_server
/options.py
1,233
3.671875
4
import sys ''' ## descript to this file ### 2021-05-12 by Artificial_Lua this file is for import file setup() -> load and split system arguments if you have incorrect option then python will exit correct option will split to tuple likes (True / False , argumentValue) get(opt) -> return correct option's valu...
7bd9a2afb634379476cf1d13b8535bf5f728344e
zyrest/data-science-lab
/lab6/13/MDS_Exhibit_13_2.py
1,297
3.609375
4
import numpy as np # arrays and math functions import pandas as pd # data frame operations import statsmodels.formula.api as smf # statistical models (including regression) # 读取饭店数据 csv 文件,创建 pandas data frame restdata = pd.read_csv('studenmunds_restaurants.csv') # print the first five rows of the data frame # pri...
f20895c861aaf4fa73521e255b6af629b89d9ff5
JinkaiGUAN/openCVLearning
/LaneLineDetection/lane_line_detection.py
7,811
3.625
4
# -*- coding: UTF-8 -*- """ @Project :openCVLearning @File :lane_line_detection.py @IDE :PyCharm @Author :Peter @Date :05/05/2021 08:22 """ import os import cv2 import matplotlib.pyplot as plt import configparser import numpy as np dir_name = os.path.dirname(os.path.abspath(__file__)) conf_path = os.path...
2d0d096139bcc0aa94c9c5b22d853928a4f6ea55
JinkaiGUAN/openCVLearning
/Chapter7_TargetDetection_Recognition/car_detector/sliding_window.py
819
3.890625
4
# -*- coding: UTF-8 -*- """ @Project :openCVLearning @File :sliding_window.py @IDE :PyCharm @Author :Peter @Date :29/04/2021 14:25 """ def slidingWindow(img, step_size, window_size): """Sliding window: This is used to detecting the same type objects in one figure, namely, the object number can be ...
22e6b858ccc8ae957d5ee0f599d075a2b32ea22a
ArthurSpillere/Exercicios_Bruno
/Exercicio1.py
3,005
3.8125
4
# Faça um Programa que pergunte quanto você ganha por hora # e o número de horas trabalhadas no mês. # Calcule e mostre o total do seu salário no referido mês, sabendo-se que são # descontados 11% para o Imposto de Renda, 8% para o INSS e 5% # para o sindicato, faça um programa que nos dê: # salário bruto. # q...
bc6d70816cce7f9cd3002ca49fa6b0489632f6af
letrongminh/Python
/Linked_List/Circular_linked_list.py
4,246
4.21875
4
#Circular Linked List class Node(object): """docstring for Node""" def __init__(self, value): self.value = value self.next = None class Circular_LinkedList(object): """docstring for Circular_LinkedList""" def __init__(self): self.head = None self.tail = None def create_Circular_LL(self, ...
1c39df1d9085f14a4c35e9117d4c2766a2446990
atantczak/Basic_Finance
/alter_data.py
2,492
3.8125
4
# This is the THIRD 'Python Programming for Finance' episode from sentdex. # The purpose is alter local data to view certain aspects of it. import datetime as dt import matplotlib.pyplot as plt from matplotlib import style from pandas.plotting import register_matplotlib_converters register_matplotlib_converters() im...
feb4c371dc61726d8914d2ba0a0e45800a602b74
imightbeamy/play-to-program
/student_model/experiments_for_paper.py
2,657
3.78125
4
""" Here are my ideas for axes of experimentation let the algorithms be LIN-MULT LIN-MEAN LIN-MIN BIN-MULT BIN-MULT BIN-MEAN LOG-MULT LOG-MULT LOG-MEAN Number of problems Number of concepts Number of concepts per problem We will: Generate a set of student results for each problem set ...using each of the 9 models?...
f4f8dfb4f59a722fd628f0634654aca2ba592a5e
NguyenLeVo/cs50
/Python/House_Roster/2020-04-27 import.py
1,569
4.1875
4
# Program to import data from a CSV spreadsheet from cs50 import SQL from csv import reader, DictReader from sys import argv # Create database open(f"students.db", "w").close() db = SQL("sqlite:///students.db") # Create tables db.execute("CREATE TABLE Students (first TEXT, middle TEXT, last TEXT, house TEXT, birth NU...
c9de7fdf28f4c7d0c44d9217c6cfcdaf4372877a
NguyenLeVo/cs50
/Python/2020-05-15 list.py
1,680
4.09375
4
# List ismutable, string is immutable # Pass by reference (pointers), not by value like a string spam = ['1a', '2b', '3c', '4d'] print(spam[0]) print(spam[-1]) # last index or 4d print(spam[-2]) # 2nd last index or 3c print(spam[1:3]) # slice (list of values) from 2nd to 3rd value or 2b 3c print() for i ...
5acb7d44c050fb3ff1b715aac895d8466f42e09a
kamaleshanantha/Array-4
/nextPermunation.py
1,052
3.609375
4
""" Time complexity: O(N) Space complexity: O(1) Compiled on leetcode?: Yes """ class Solution: def nextPermutation(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ # Find i by starting from the end and break if you find nums[i] < nums[i +...
851ef1a96a70d0a99c490acfddb6fc0239bf6dbe
JASTYN/30dayspyquiz
/tkinter/tk1.py
280
3.625
4
import tkinter from tkinter import* win=Tk() win.geometry("800x600") b = Button(win, text='button') #b.pack() b.grid(row=1, column=1) b2 = Button(win, text='buttoni', command=print('hi'),padx=20, pady=50,activeforeground='blue') #b2.pack() b2.place(x=100, y=200) win.mainloop()
e8bdd859a4119a8f0bbfb21a2eee44783c738370
JASTYN/30dayspyquiz
/exam/hey/case2final.py
270
3.859375
4
for i in range (97,98): # inner loop for jth columns for j in range(65,67): print(chr(i),end="") for i in range (122,123): # inner loop for jth columns print("\n") for j in range(88,90): print(chr(i),end="")
acc4f9191155ae867c8a0653c2176315ac250c11
JASTYN/30dayspyquiz
/finalbuzz.py
177
3.53125
4
#day one 30 days of codefor x in range (1,100): if x > 1: for i in range(2,x): if x%i == 0: break else: print(x)
65ea0731d0ac1331069f92332de574a517f1e08c
JASTYN/30dayspyquiz
/exam/sentinn.py
306
4.0625
4
total = 0 count = 0 data = input("Enter a score or just return to quit: ") while data != "": total += int(data) count += 1 data = input("Enter a score or just return to quit: ") if count == 0: print("No scores were entered.") else: print("The average is", total / count)
4a274ea9dc67a71de8e1b5dbef62568f4d8a21c5
JASTYN/30dayspyquiz
/exam/hey/lst.py
214
3.65625
4
from statistics import mean def Average(lst): return mean(lst) # Driver Code lst = [15, 9, 55, 41, 35, 20, 62, 49] average = Average(lst) # Printing average of the list print("Average of the list =", average)
0771f9c6a57d08e206fea288749870bfa9fdbc39
JASTYN/30dayspyquiz
/exam/hey/alpha.py
267
3.75
4
from string import ascii_letters def range_alpha(start_letter, end_letter): return ascii_letters[ ascii_letters.index(start_letter):ascii_letters.index(end_letter) + 1 ] print(range_alpha('a', 'z')) print(range_alpha('A', 'Z')) print(range_alpha('a', 'Z'))
7bab4b14a82a9e79dd6dd2ebc52f6a1c315d9176
JASTYN/30dayspyquiz
/exam/spaces.py
253
4.1875
4
""" Write a loop that counts the number of words in a string """ space = ' ' count = 0 sentence = input("Enter a sentence: ") for letter in sentence: if letter == space: count = count + 1 print(f'Your sentence has {count + 1} words')
d29b0a47e7fe7df6a7906e8c96e7e43492c8ccd9
JASTYN/30dayspyquiz
/exam/hey/finalav.py
980
4.1875
4
def getNumberList(filename): f = open(filename,'r') #opening the file line = f.readline() #reading the file line by line numbers = line.split(',') #The split() method splits a string into a list. numberList = [] #An array to store the list for i in numbers: numberL...
aacb7dedd632bfa2b7db83f4a55acf87b9f8b384
xizhang77/machine-learning-algorithm-tensorflow
/SVM/code/MulticlassSVM.py
5,328
3.625
4
# -*- coding: utf-8 -*- import tensorflow as tf import numpy as np from sklearn import datasets import matplotlib.pyplot as plt def GaussKernel( X1, X2, gamma ): ''' Generate the RBF kernel for X1 and X2. When X1 = X2 = Input Data, it generates the RBF(x, x) for training When X1 = Input Data and X2 = Predicted...
b07b07296e7d735ee2a1ba5e2933160ec20cf1d8
M-G-C-64/PROJECTS
/TIC-TAC-TOE.py
3,990
3.828125
4
#TIC-TAC-TOE import sys import random as rnd def board(lst): for i in range(3): print((' | ').join(str(j) for j in lst[i])) if i < 2: print('---------') print(' ') def inp(lst): k = -1 print('enter your prefered index: ') try: m,n = map(int, input...
2fe3e8385b812e06f90cd70661f4b5aec845b7c4
tonybnya/python-periodic-table-of-elements
/periodictable.py
3,712
4.15625
4
#!/usr/bin/env python3 """ The periodic table of the elements organizes all known chemical elements into a single table. periotictable.py - This program present this table and lets the user access additional information about each element. These informations has been compiled f...
43f8bc691425d137b99e777339986c01c06e790c
ConradMare890317/Python_bible
/slicer.py
338
3.953125
4
#get user e-mail adress email = input("What is your e-mail adress?:").strip() #slice out user name #johndoe@thingy.com user = email[:email.index("@")] #slice domain name domain = email[email.index("@")+1:] #format message output = "Your user name is {} and your domain name is {}".format(user, domain) #display o...
46ac774a76ca690190b605f1a60b2d73930c430e
ConradMare890317/Python_bible
/List_Comprehension2.py
459
3.875
4
Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> words = ["The", "fox", "jumps", "over", "the", "lazy", "dog"] >>> answer = [[w.upper(), w.lower(), len(w)] for w in words] >>> print(answer) [['THE'...
6a305b296485ecf29ac3571bde7740ce9c76666e
ConradMare890317/Python_bible
/string_methods2.py
500
3.625
4
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> x = "happy birthday" >>> x.index("birthday") 6 >>> x.find("birthday") 6 >>> y = "000happybirthday000" >>> y.strip("0") 'happybirthday' >>> y.lstrip(...
42e3813543a18bdfa92baa6c202ab64f513cae0c
Monalisha1996/PYSPARK
/RatingUsingDataframe.py
1,318
3.59375
4
from pyspark import SparkContext from pyspark.sql import Row,functions from pyspark.sql import SQLContext def movien(): movien1 = {} i=1 with open("C:/spark-3.0.0-preview2-bin-hadoop2.7/ml-100k/u.item") as f: for line in f: fields = line.split('|') #m...
e2715b52b2fcb68cbc0035014afd2657fe8777a4
Yosri-ctrl/holbertonschool-web_back_end
/0x03-caching/2-lifo_cache.py
1,135
3.578125
4
#!/usr/bin/python3 """ Creating a new class FIFOCache Inhereted from BaseCaching Basd on the LIFO algo (last in first out) If the chache pass the limit (MAX_ITEMS) It delete the last item created """ BaseCaching = __import__('base_caching').BaseCaching class LIFOCache(BaseCaching): """ LIFO (last in first out...
297a788c695fdbb68f2276b967b0fca0cff7b2e4
GarethMarriott/UVICCSC
/CSC106/Python/as4/as4/arrays.py
351
3.765625
4
# should return the number of even numbers # in the array A def countEven(A): sum = 0 for i in range(len(A)): if A[i]%2 == 0: sum = sum + A[i] return sum; # should return the sum of every Nth number, # starting with the elemenet at index 0 def sumEveryN(A, N): sum = 0 for i in range(len(A)): if i%N == 0: ...
1042d76363ecf300afd13b0e8407d7af0fe63a9f
Praneel-Rastogi/Daily-Programming-Practice
/DAY 2/Longest Common Prefix.py
783
3.921875
4
#Write a function to find the longest common prefix string amongst an array of strings. #If there is no common prefix, return an empty string "". #Example 1: #Input: strs = ["flower","flow","flight"] #Output: "fl" #Example 2: #Input: strs = ["dog","racecar","car"] #Output: "" #Explanation: There is no com...
25bde49c43261427aa3da3ff9643be2e340d2c1f
HarryHawkins/common-actors
/common-actors.py
2,583
3.734375
4
from imdb import IMDb def get_number_of_movies(): while True: try: num_movies = int(input("How many movies would you like to enter? ")) except ValueError: print("Please enter a number!") continue else: break return num_movies def get_mo...