blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
d102f2726a361dc4fcd14fff34e0c7b7edf9cfe6
DionEngels/PLASMON
/test codes/test_plot.py
1,866
3.53125
4
# -*- coding: utf-8 -*- """ Created on Sun Jun 7 13:13:07 2020 @author: s150127 """ import numpy as np from scipy import optimize import matplotlib.pyplot as plt def gaussian(height, center_x, center_y, width_x, width_y): """Returns a gaussian function with the given parameters""" width_x = float(width_x) ...
41a30f28f4204c0b546d49c6b0d6f8a05c7a9ef2
Arjun-Pinpoint/Code-Book
/Python/Composite.py
224
3.671875
4
# -*- coding: utf-8 -*- """ Created on Tue May 21 16:32:29 2019 @author: Arjun """ n=int(input()) f=0 for i in range(2,n): if n%i==0: f=1 break if f==0: print("no") else: print("yes")
c2774c7df38827415fbae9e51b9402143bf23350
MarloDelatorre/leetcode
/0103_Binary_Tree_Zigzag_Level_Order_Traversal.py
1,335
3.84375
4
from collections import deque from typing import List from unittest import main from datastructures.binarytree import TreeNode, binarytree from testutil import ListOfListsTestCase def zigzagLevelOrder(root: TreeNode) -> List[List[int]]: if not root: return [] left_to_right = True queue = deque(...
2e53bd9ed404aac01f18dfd8540ce76552922649
emilianoNM/Clase2018Tecnicas
/palindromo.py
641
4.09375
4
print ("Palindromo\n") print ("Tecnicas de programacion\n") print ("Este programa le dice si una secuencia de numeros, frase o palabra\n") print ("es palindroma o no, osea, que significa lo mismo si se lee de\n ") print ("derecha a izquierda y viceversa\n") palabra1 = raw_input("Ingrese la palabra\n\n") #.lower hace ...
f6bbc3ec567514089f5035ed4236f5c088b36ade
here0009/LeetCode
/Python/FrogPositionAfterTSeconds.py
3,346
3.640625
4
""" Given an undirected tree consisting of n vertices numbered from 1 to n. A frog starts jumping from the vertex 1. In one second, the frog jumps from its current vertex to another unvisited vertex if they are directly connected. The frog can not jump back to a visited vertex. In case the frog can jump to several vert...
6e5ed24b487825aa39827078b726d6d8e8b4a5b4
stoyaneft/HackBulgariaProgramming-101
/week5/1-sqlite-starter/create_company.py
1,211
3.5625
4
import sqlite3 db = sqlite3.connect('company.db') db.row_factory = sqlite3.Row cursor = db.cursor() cursor.execute(''' CREATE TABLE IF NOT EXISTS employees(id INTEGER PRIMARY KEY, name TEXT, monthly_salary INTEGER, yearly_bonus INTEGER, position TEXT) ''') emloyee_Ivan = ("Ivan Ivanov", 5000, 10000, "Softw...
729a22cfc797c8bbc2a6aa8016e01e1a82dcaab8
aaroncymor/codefights
/solved/sorted_by_guide.py
1,162
3.515625
4
def SortByGuide(a,guide): sort_a = [] sort_guide = [] index = [] for i in range(len(a)): if guide[i] != -1: sort_a.append(a[i]) sort_guide.append(guide[i]) index.append(i) restart = False i = 0 while True: if (i + 1) < len(sort_guide): if sort_guide[i] > sort_guide[i + 1]: tem...
b1386980559e04a15c06adb7a75bb2d6c5d3dfc4
kabaliisa/levelup
/multiple.py
204
3.765625
4
def multiple(): numbers = range(2000, 3201) num = [] for number in numbers: if number % 7 == 0 and number % 5 != 0: num.append(number) return num print(multiple())
3a9b328593cf6fc91376ee5bcad559c990c6c1d3
meryreddoor/Bitcoins_Scraping
/src/main.py
1,692
3.515625
4
import funciones import argparse import pandas as pd import matplotlib import matplotlib.pyplot as plt def parser(): parser = argparse.ArgumentParser(description='Selecciona los datos que quieres ver') parser.add_argument('x', type=str, help='Moneda Seleccionada') parser.add_argument('y', type=str,help='Fe...
32b348fdd07dc5913a7f82e0910686f359f64c4f
Sultan1007/Homeworks.py
/Homework2.py
1,296
3.8125
4
# Complex # 1) magic method (+, -, /, *) # 2) return Complex -> # complex2 = Complex(2, 5) # complex3 = complex1 + complex2 # 3) __str__ class Complex: def __init__(self, real=0, imag=0): self.real = real self.imag = imag def __add__(self, other): return Complex(self.real + other.real...
42fd2a28378fb6341f6d443aa07e77df5278f1f7
kangyongxin/Backup
/MuscleMemory/run.py
5,414
3.671875
4
""" 复现Dyna-Q算法, 环境是之前的maze 参考 : https://github.com/thomas861205/RL-HW3 1.实现基本 的 one step q learning 2. 实现一个记录状态动作对儿的模型 3. planning 引入到 q表的 更新中 """ """ Qlearning 的基本步骤: 1 初始化 q表 2 观测值 3 用 greedy方法采样 动作 4 实施动作 得到 反馈 5 用反馈值 和状态动作一起 更新q表 6 循环 """ """ 需要外加的部分: model 要初始化 model 每次有新的值就要更新一下,(这里其实只是把见到的状态记录一下而已,并没有训练什么函...
4584a37ca2e60108fa95b50215978964311f66ba
fank-cd/python_leetcode
/Problemset/swap-nodes-in-pairs/swap-nodes-in-pairs.py
599
3.8125
4
# @Title: 两两交换链表中的节点 (Swap Nodes in Pairs) # @Author: 2464512446@qq.com # @Date: 2020-11-23 15:08:45 # @Runtime: 40 ms # @Memory: 13.5 MB # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def swapPairs(self, head:...
cf6eaad8b31dc7ec3b4213568efa629b44176c97
SB1996/Python
/Object Otiented/Polymorphism/OperatorOverloading.py
2,030
4.1875
4
# Operator Overloading in Python ...! # Behind the seen in Python # print(f"Addition : {10+20}") # # --or-- # print(f"Addition : {int.__add__(10, 20)}") # # print(f"Result : {'Santanu' + ' Banik'}") # # --or-- # print(f"Result : {str.__add__('Santanu', ' Banik')}") class OverloadOperator: def __init__...
4c3894a2a989d04478bb721661c455a7051f7350
GaborVarga/Exercises_in_Python
/46_exercises/4.py
820
4.3125
4
#!/usr/bin/env python ####################### # Author: Gabor Varga # ####################### # Exercise description : # # Write a function that takes a character (i.e. a string of length 1) # and returns True if it is a vowel, False otherwise. # # http://www.ling.gu.se/~lager/python_exercises.html from pip._vend...
ce2d1c23c1a1855fe73b2d766d3525a4b18868f5
Yinlianlei/Work
/AI-Learn/test-5_1.py
2,270
3.984375
4
# Let's do that again. # We will repeat what we did in step 3, but change the decision boundary. import warnings warnings.filterwarnings("ignore") import matplotlib.pyplot as graph # %matplotlib inline graph.rcParams['figure.figsize'] = (15,5) graph.rcParams["font.family"] = 'DejaVu Sans' graph.rcParams["font.size"] = ...
c16a18effe2adfa7fddf29c5007a96a4d646c0d0
hero5512/leetcode
/problem179.py
1,096
3.546875
4
# -*- coding: utf-8 -*- """ Created on Wed Apr 05 16:44:54 2017 @author: Crystal 思路:1、依次选择首位最大的元素放在第一位 2、如果首位相同就比较第二位,第二位大的依次排列,依次类推 [3, 30, 34, 5, 9]=9534330 1、python两个字符串居然可以比较大小 2、交换两个变量有个简便的形式 3、除此之外注意sort还可以自定义比较函数 4、判断字符串全为0的方法int("".join(num)) """ class Solution: # @param {integer[]} nums ...
dc989ac64b6544e2fcc0e56b7b9a689a52362568
Pizzabakerz/codingsuperstar
/python-codes/codes/15.lambda_map_example/lamba.py
346
4.09375
4
# lambda function # regular expression # maps # normal funtiion def multi(mul): # replace this with lambda return mul*5 print(multi(2)) multi = lambda a:a*5 # lambda function print(multi(2)) # example for lambda funtion as filter mylist = [1,2,3,4,5,6,7,8,9,0] list2 = list(filter(lambda x:(x%2 ==...
4995806e6824eb0a3c390112117ea8e319734b90
rohernandezz/Serifas
/Scripts/SandwichTorneo_3.py
534
3.796875
4
upper = "AÁBCDEFGHIJKLMNÑOPQRSTUÜV&" lower = "aábcdefghijklmnñopqrstuüv" nums = "0136" punct = ".," def letterSandwicher(letters, bread): sandwich = bread for letter in letters: sandwich += letter + bread return sandwich print(letterSandwicher(upper,"H")) print(letterSandwicher(upper,"O")) p...
9b0af5952d6b8bba8df4a039c968a066a9fb4e95
adam-xiao/PythonMasterclass
/Sequences/number_lists.py
652
4.09375
4
even = [2, 4, 6, 8] odd = [1, 3, 5, 7, 9] # print(min(even)) # print(max(even)) # print(min(odd)) # print(max(odd)) # # print() # # print(len(even)) # print(len(odd)) # # print() # # print("mississippi".count("s")) # print("mississippi".count("iss")) # print("mississippi".count("issi")) # the count is not 2 since let...
72b769b627b8360650eb76c555419d7c3f8b16b8
mayurigaikwad1724/function.py
/largest num.py
213
3.875
4
def function_largest(): num=[50,40,23,70,56,12,5,10,7] largest=num[0] i=0 while i<len(num): if num[i]>largest: largest=num[i] i=i+1 print(largest) function_largest()
f88d04bae0336838335507261a8cb1a8e666bff0
jonm/prep-mint-txns
/prep-mint-txns.py
745
3.625
4
#!/usr/bin/env python # Copyright (C) 2018 Jonathan T. Moore import csv import datetime import sys def excerpt_month(in_f, out_f, month, year): reader = csv.reader(in_f) writer = csv.writer(out_f) first = True for row in reader: if first: writer.writerow(row) first = Fa...
27fde534c776279cbb37b0b5f0937922410537a5
alu-rwa-dsa/Data-Structures-and-Algorithms-Python
/implementation_5/test_dLinkedList.py
2,496
3.640625
4
import unittest # import the unittest module to test the class methods from implementation_5.doubly_linked_list import DLinkedList from implementation_5.doubly_linked_list import Node class TestSLinkedList(unittest.TestCase): def test_prepend(self): myObj = DLinkedList() # initialize a new obje...
dcabe4e7395062c7a0982da34d05b7ed748a3d89
mj-hd/lab_pre
/first/2.py
538
3.9375
4
#!/usr/bin/python def gcd(m, n): if n == 0: return m else: return gcd(n, m % n) def is_prime(n): MAX_A = 10 # attempt a up to prime = lambda a, n: a**(n-1) % n == 1 # prime condition for a in range(2, MAX_A): if gcd(a, n) != 1: # not disjoint continue ...
b4d1d11a094028c621368cd8a8c2d1729d0bda88
Wictor-dev/ifpi-ads-algoritmos2020
/iteração/24_salario_numero_filhos.py
800
3.78125
4
def main(): hab = int(input('Digite o numero de habitantes: ')) media = media_filhos = salario_ate_mil = 0 count = 1 while count <= hab: print(f'### funcionario {count} ###') salario = int(input('Digite o salário: ')) filhos = int(input('Digite o numero de filhos: ')) ...
994c5c68a025812d29ad20ffa34de19aa8c4146d
kentronnes/datacamp
/Python_Data_Science_Toolbox_Part_2/List_comprehensions_and_generators/List_comprehensions_vs_generators.py
1,715
4.34375
4
# List comprehensions vs generators # You've seen from the videos that list comprehensions and generator # expressions look very similar in their syntax, except for the use # of parentheses () in generator expressions and brackets [] in list # comprehensions. # In this exercise, you will recall the difference betw...
674f8bff466a3bf1287ecd185cec3729244d1327
AkshayKumar-n/Project
/bookmenudriven.py
1,185
3.9375
4
bookslist=[] class bookDetails: def AddBook(self,title,description,price,publisher,distributor): dict2={"title":title,"description":description,"price":price,"publisher":publisher,"distributor":distributor} bookslist.append(dict2) obj1=bookDetails() while(True): print("1. add book ") pri...
614b3db91c471455c67ba2cbaf2a74a3afa8e2fc
jianhui-ben/leetcode_python
/Snap_523. Continuous Subarray Sum.py
1,989
3.796875
4
#523. Continuous Subarray Sum #Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to a multiple of k, that is, sums up to n*k where n is also an integer. #Example 1: #Input: [23, 2, 4, 6, 7], k=6 #Output: Tr...
94ace1f6fbabc9721c11d8bfa1f5f22c3218334a
millmill/scrabblegame
/Board.py
5,220
3.765625
4
from Square import Square from Tile import Tile from random import randint class Board(Square): def __init__(self, size=15): super().__init__() self._size = size self._square_array = [[Square() for i in range(self._size)] for j in range(self._size)] for row in range(self._size): ...
0fe67a243b28f5e44ed8a2b6e1120324d6e4431e
oxhead/CodingYourWay
/src/lt_740.py
1,846
3.734375
4
""" https://leetcode.com/problems/delete-and-earn Related: - lt_198_house-robber """ """ Given an array nums of integers, you can perform operations on the array. In each operation, you pick any nums[i] and delete it to earn nums[i] points. After, you must delete every element equal to nums[i] - 1 or nums[i] + 1. ...
661dd9aa780fd701fdcc15f8d6fe290ece284a90
uvula6921/algorithm_prac
/week_4/07_get_all_ways_of_theater_seat.py
612
3.65625
4
seat_count = 10 vip_seat_array = [2, 6, 9] dict = { 1: 1, 2: 2 } def fibo(n, memo): if n in memo: return memo[n] memo[n] = fibo(n-1, memo) + fibo(n-2, memo) return fibo(n-1, memo) + fibo(n-2, memo) def get_all_ways_of_theater_seat(total_count, fixed_seat_array): multi = 1 for i in range(len(fixed_s...
0864af14ed0d49dcda394e790915c00be5d850c7
StasNovikov/simple-games-on-Python
/OOP/GUI/movie_chooser2.py
2,438
3.875
4
# киноман-2 # Демонстрирует переключатель from tkinter import * class Application(Frame): """ GUI-приложение, позволяющее выбрать один любимый жанр кино """ def __init__(self, master): super(Application, self).__init__(master) self.grid() self.create_widgets() def create_widgets(se...
f3d29d2e7b0f37f6fce94c60602e9a7e5354cbad
mattyr3200/python
/week 5.py
324
4.0625
4
def week5(): name = str(input("hello, whats your name?\n")) if not name: print("hello world") elif name[:4].capitalize() == "Sir ": print("hello, Sir", name[4:].capitalize() + ". it is good to meet you.") else: print("hello, ", name.capitalize() + ". it is good to meet you.") wee...
2dcc303ec37f129ca91e7b53c47accd217b724c4
apromessi/interviewprep
/ariana_prep/oct_practice/HR_binary_tree_problems.py
943
4.0625
4
''' class Node: def __init__(self,info): self.info = info self.left = None self.right = None ''' # The height of a binary tree is the number of edges between the # tree's root and its furthest leaf. def height(root): if root.left and root.right: return 1 + max(hei...
3f45254a597fd55e1739e8e0995a97f20466d1c1
v1ktos/Python_RTU_08_20
/Diena_6_lists/uzd1_2_g2.py
1,872
4.0625
4
my_list = [] while True: my_input = input("ievadiet skaitli vai Q lai beigtu: ") if my_input.lower().startswith('q'): break my_input = float(my_input) my_list.append(my_input) my_list_sorted = sorted(my_list, reverse=True) print(f"3 lielākās un 3 mazākās vērtības no {len(my_list)} ievadītajām:...
2ec0bb2408c51f314e4fd36702ce2280c568e807
tanman13/oopljpl
/myExercises/Collatz.py
707
3.828125
4
#!/usr/bin/env python3 from sys import stdin def cycle_length (n) : assert n > 0 c = 1 while n > 1 : if (n % 2) == 0 : n = (n / 2) else : n = (3 * n) + 1 c += 1 assert c > 0 return c def max_cycle_length (i, j) : s = 0 for v in range (i, j+...
4143f5c5491d632ce2681c7cb16e52f66bc72084
Chandler-Song/sample
/python/oopap/multi_inherit.py
2,520
3.6875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- '多重继承' # 首先,主要的类层次仍按照哺乳类和鸟类设计 class Animal(object): pass # 大类 class Mammal(Animal): pass class Bird(Animal): pass # 现在,我们要给动物再加上Runnable和Flyable的功能,只需要先定义好Runnable和Flyable的类: class Runnable(object): def run(self): print('Running...') class Flyable...
5e3fe09f9273bdfd88e7563bcf9e6c68698e1dcd
mjwestcott/priorityqueue
/priorityqueue.py
11,467
3.78125
4
""" priorityqueue.py Priority Queue Implementation with a O(log n) Remove Method This file implements min- amd max-oriented priority queues based on binary heaps. I found the need for a priority queue with a O(log n) remove method. This can't be achieved with any of Python's built in collections including the heapq m...
2f1624bc1d9a184e0041dac8f9dcd20414e5ff71
Divyakennady/AI-based-health-club-management-system
/main.py
437
3.859375
4
import pandas as pd homeno=int(input("enter the home no:")) homename=input("enter home name:") place=input("enter place:") sqfeet=int(input("enter square feet:")) price=int(input("enter the price:")) d={"homeno":[homeno,1,2],"homename":[homename,"sh","jk"],"place":[place,"chakkai","soul"],"squarefeet":[sqfeet,7,8...
2916739dc626b54562056b54d4cf82c4261378a2
pabnguyen/nguyenphuonganh-fundamentals-c4e13
/Session 1/example.py
143
4.03125
4
n = int(input("Enter a number: ")) for i in range(n): if (i % 2) == 0: print("Fizz") elif (i % 3) == 0: print("Buzz")
b5174e0b5e5c716b8d1ea136f627a6f67512a0aa
welchbj/almanac
/almanac/types/comparisons.py
1,129
3.625
4
from typing import Any, Type from typing_inspect import is_union_type, get_args def is_matching_type( _type: Type, annotation: Any ) -> bool: """Return whether a specified type matches an annotation. This function does a bit more than a simple comparison, and performs the following extra checks:...
d7d327a0ddeec0ba044583207d815ccaf93fa896
gincheong/leetcode
/Top Interview Questions/src/101.symmetric-tree.py
1,678
4.09375
4
# # @lc app=leetcode id=101 lang=python3 # # [101] Symmetric Tree # from typing import List # @lc code=start # 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 class Solution: def isSym...
010da5f282b5330c736da473b3abdf09f387cb84
gautamits/hackerrank
/algorithms/greedy/largest-permutation.py
991
3.625
4
#!/bin/python import sys def largestPermutation(arr, n, k): # Auxiliary array of storing the position of elements pos = {} for i in range(n): pos[arr[i]] = i for i in range(n): # If K is exhausted then break the loop if k == 0: break # If element is ...
cdfef7939864a3b2a2b876bb872117628b71a3bf
Ryccass/Old-Python-Code-
/Python_Test_2/main.py
349
3.875
4
def front_back(str): list_str = list(str) first_char = str[0] last_char = str[len(str) - 1] str_length = len(str) list_str[0] = "" list_str[len(list_str)-1] = "" list_str.insert(0, last_char) list_str.insert(str_length-1, first_char) normal_str = ''.join(list_str) print(normal_s...
3b169fc528f50767ce2d3bacaf058f92827f62c3
UtkarshS20/Practice_code_with_harry
/pythonProject1/oops45cwh.py
971
3.96875
4
#dunder methods-methods which start and end with __ . class Employee: no_of_leaves=8 def __init__(self,aname,asalary,arole): self.name=aname self.salary=asalary self.role=arole def printdetails(self): return f"name is {self.name} salary is {self.salary} role is {self.role}" ...
96e30986176a407eab1606edf04884711fef94d9
Rhysj125/tensorflow
/src/neural-net.py
1,900
3.84375
4
import tensorflow as tf import numpy as np import math import matplotlib.pyplot as plt import matplotlib.animation as animation from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("MNIST_Data/", one_hot=True) # Number of inputs x = tf.placeholder(tf.float32, shape=[None, 784])...
9d3adfb5be96ff8362121be2a14ce921dcaf063c
aashnagarg/My-Coding-Practice
/subtractLists.py
644
4
4
def subtractLists(arr1,arr2): ''' for elem in arr2: Time complexity O(len(arr1)*len(arr2)) if elem in arr1: arr1.remove(elem) return arr1 ''' #return list(set(arr1)-set(arr2)) #Time complexity O(len(arr1)) ptr1=0 ptr2=0 while arr1[ptr1] and arr2[ptr2]:...
7fccae498043dddc8074438c444d57dbe1d8863b
tankan63/randomprojects
/print.py
706
3.9375
4
# this is a simple text analyser that displays tthe frequency of each letter in a string def count_char(text,char): count=0 for c in text: if c==char: count +=1 return count file=open("new1.txt","w") file.write("""The quick brown fox jumps over the lazy dog""") #enter any text here file.close() #executing thi...
b4a2b712fff7cef2ecc5a1fb43699ba476b24cac
ug2057pz/Tic_Tac_Teo
/SoccerTeam.py
1,294
3.8125
4
class FootballPlayer: name = "Chris Smalling" team = "Man United" years_in_leage = 0 def printPlayer(self): print(self.name + " playing for the "+ self.team) def isGood(self): print("Error ! is Good is not defined !") return False #Quarterback is the child of FootballPlayer...
21cabce19f3a7dd0d39107c4fa93742c4e2d5acc
wzgdavid/python_kecheng
/samples/history/BDA2/day2/func.py
710
3.53125
4
#def add(*arg,**kwarg): # print(arg, kwarg) #add(3,4,5,key=1, reverse=False, name='cat') #print(type(foo)) #add(1,2,3,4,5,5,5,5,5,5,5) #print(a) #b, *c,a,d = 1,2,3,4,5,5,5,5,5,5,55 #print(b, a) class ArgExcetiopn(Exception): pass def add(a, b): if not isinstance(a, int) or not isinstance(b, int): ...
ae76397afe89f3716a182eb0f108b7ccd3c4f0b9
yang-XH/coursera---machine-learning
/_1_ML_linear_regression/ex1_multi.py
1,567
3.875
4
import numpy as np import pandas as pd # 数据标准化的包 from sklearn import preprocessing import matplotlib.pyplot as plt from _1_ML_linear_regression import ex1 #TODO # 为啥运行或者debug会把ex1再运行一遍??????????????????? def gradientDescentMulti(X_, y_, theta_, alpha_, num_iters_): theta_, J_history_ = ex1.gradientDescent(X_, y_...
77387e4b9e9eff0ee33874aa618215ed114f7165
GenryEden/kpolyakovName
/2272.py
274
3.5625
4
from functools import lru_cache @lru_cache def f(n): if n <= 3: return n elif n % 2 == 0: return n + 3 + f(n-1) else: return n*n + f(n-2) cnt = 0 for x in range(1, 1000+1): res = f(x) if res % 7 == 0: cnt += 1 print(cnt)
8f6cb8fd8de1fa4f5e76907743d501b266ad4405
dsardelic/Battleships
/battleships/board.py
22,379
4.09375
4
"""This module contains data structures for managing board data.""" import functools import itertools from typing import Any, DefaultDict, Dict, Iterable, List, Set from battleships.grid import FieldType, FieldTypeGrid, Position, Series from battleships.ship import Ship class Board: """Represents a puzzle board...
89ad6ef8776b049047b8c4e899825e665994ecd3
sralloza/aes
/aes/text.py
1,414
3.921875
4
"""Manages text encription.""" from typing import Union from cryptography.fernet import InvalidToken from .exceptions import IncorrectPasswordError from .utils import get_fernet StrOrBytes = Union[str, bytes] def encrypt_text(text: StrOrBytes, password: str = None) -> bytes: """Encrypts text. Args: ...
3e1a9cf7b7fdfa77375331dfd403f905d77f00b9
yl123168/Hello_world
/05Lecture练习8字符in字符串递归.py
415
3.765625
4
def isIn(char, aStr): i = len(aStr) if aStr == '': return False elif len(aStr) == 1 and char == aStr: return True elif char == aStr[i/2]: return True elif char < aStr[i/2]: print(aStr) return isIn(char,aStr[:i/2]) elif char > aStr[i/2]: ...
bd59bf34da6ef34cea0c2eb47969da798e5fff4e
smvemula/MasterPython
/TakeABreak.py
326
3.609375
4
import webbrowser import time print("Program is start at" + time.ctime()) #creating a for loop to run 3 times for index in range(3): #print("Program is running for #" + (index + 1)) #sleep for 10 seconds time.sleep(10) #open youtube app at the end of timer webbrowser.open('https://www.youtube.com/watch?v=tAGnKpE...
c36970acd2e1aa67c4a1d1150e3962ab9963dc83
Kohdz/Algorithms
/DataStructures/Trees/DFS_preOrder.py
2,444
4.25
4
class Stack(): def __init__(self): self.items = [] def push(self, item): self.items.append(item) def pop(self): return self.items.pop() class Node: def __init__(self, value=None): self.value = value self.left = None self. right = None def get_valu...
bf595b009dd982212f2de1bdf7a9623b0d00faf0
vishnuchauhan107/pythonBasicToAdvance
/python_notes_by_vishnu/vch/file_handling/file_handling.py
8,141
4.40625
4
''' File Handling As the part of programming requirement, we have to store our data permanently for future purpose. For this requirement we should go for files. Types of Files: There are 2 types of files 1. Text Files: Usually we can use text files to store character data eg: abc.txt 2. Binary Files: Usually we can use...
4054ba3596551d61d35079079727c337cdd29ffd
fagan2888/Leetcode-Solutions-1
/first_missing_positive/solution.py
2,085
3.53125
4
from typing import List, Tuple class Solution: def firstMissingPositive(self, nums: List[int]) -> int: num_positives = 0 the_min = len(nums) the_max = 0 the_sum = 0 for i in range(len(nums)): if nums[i] > 0: num_positives += 1 the...
c0c09032615a22cf2ebd3ea437372ecdef541f95
NatheZIm/nguyensontung-homework-c4e14
/Lab3/turtle_ex_5_6.py
390
3.953125
4
from turtle import * speed(-1) color("blue") def draw_star(x,y,z): count = 0 penup() setx(x) sety(y) pendown() while count <= 5: forward(z) right(144) count += 1 for i in range(100): import random x = random.randint(-300, 300) y = random.randint(-300, 300) ...
b099a4a9db22f087e41e7946df76019510354beb
mojianhua/python
/newStudyPython/day11/wraper.py
4,529
3.953125
4
import time # 时间截 print(time.time()) # 休眠 # time.sleep(5) print('123') # def b(): # time.sleep(0.01) # print('jim123') # # def a(f): # start = time.time() # f() # end = time.time() # return end - start # # print(a(b)) # 装饰器函数 # def timer(f): # def inner(): # start = time.time() # ...
0aa5e76b97e8688b3ebfae55bf539b8ca7e3ef98
mananiac/Codeforces
/Young Physicist.py
249
3.640625
4
countx,county,countz = 0,0,0 for _ in range(int(input())): x,y,z = map(int,input().split()) countx,county,countz = countx+x,county+y,countz+z #print(x,y,z) if(countz==0 and county==0 and countx==0) : print("YES") else: print("NO")
e300e3a6056503ca551632ef0d446fd1c3798d6b
larsgroeber/prg1
/PRG1/sheet11/graph_generator.py
3,758
4.09375
4
class GraphGenerator: def __init__(self): self.graph: {[]} = dict() self.length = 0 def setup_vertexes(self): num_vertexes = input( "Please enter the number of vertexes in your graph (integer).\n>>> ") if not num_vertexes.isdigit() or int(num_vertexes) < 2: ...
6014a277d9810adb2d0c8099753761d8eed8cd4c
ViAugusto/Logica-de-programacao-python
/ordenacao.py
222
4
4
a = int(input("Digite um valor: ")) b = int(input("Digite outro valor: ")) c = int(input("Digite mais um valor: ")) if a < b and b < c: { print("crescente") } else: { print("não está em ordem crescente") }
ee2d27fda5751ef479b840bfdab135285f3b703f
AnTznimalz/python_prepro
/Prepro2019/guess_game.py
290
4
4
"""Guess Game""" def main(): """Main Func.""" goal = int(input()) num = int(input()) while num != goal: if num < goal: print("Too low.") else: print("Too high.") num = int(input()) print("Correct ! It's %d." %goal) main()
73b4fed971b3a1dabbf0aa017c95fa30e26b3f86
sakti2k6/DS_Algorithms_Specialization_Coursera
/Algorithmic_Toolbox/week2_algorithmic_warmup/1_fibonacci_number/fibonacci.py
372
3.703125
4
# Uses python3 def calc_fib(n): if (n <= 1): return n return calc_fib(n - 1) + calc_fib(n - 2) n = int(input()) #print(calc_fib(n)) def calc_fib_fast(n): array = []; i = 0 array.append(0) array.append(1) for i in range(2,n+1): array.append(array[i-1] + array[i-2]); ...
c5aeb162bcee60648f71d9642d23a679d12ceced
nirmalrajkumar/python_training
/Day_6/classrecshape.py~
253
3.84375
4
class shape: def __init__(self): print "shape" class rec(shape): def __init__(self,a,b): self.a=a self.b=b def rect(self): return self.a*self.b def __str__(self): return str(self.a)+str(self.b) def pe(self): return 2* self.a+ self.b
f35781b80debfd9055a5516ce81744ab6fb8b7a9
zjzjgxw/leetcode
/py/maxPathSum.py
759
3.703125
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None import sys class Solution(object): maxSum = -sys.maxsize-1 def maxPathSum(self, root): """ :type root: TreeNode :rty...
717cf9611ab1ff2414075d3276fa7502847adac5
Ekeopara-Praise/python-challenge-solutions
/Ekeopara_Praise/Phase 2/FILE I & O/Day84 Tasks/Task2.py
311
4.28125
4
'''2. Write a Python program to generate 26 text files named A.txt, B.txt, and so on up to Z.txt. ''' import string, os if not os.path.exists("letters"): os.makedirs("letters") for letter in string.ascii_uppercase: with open(letter + ".txt", "w") as f: f.writelines(letter) #Reference: w3resource
8160cee21f66f52b23caccc17d3d520df3f0994c
adagio/advent-of-code
/source/day01/tests/test_addition.py
483
3.6875
4
from unittest import TestCase from modules.addition import process class AdditionTestCase(TestCase): def test_process_example_1(self): input_ = "+1, +1, +1".split(', ') self.assertEqual(process(input_), 3) def test_process_example_2(self): input_ = "+1, +1, -2".split(', ') s...
7a471cba10bce3ac31d051d99bd970d68d35d5f2
ninoude/leetcode
/problems/0025-reverse-nodes-in-k-group/sample.py
1,175
3.78125
4
from typing import List from typing import Optional # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def reverseKGroup(self, head: Optional[ListNode], k: int) -> Optional[ListNode]: arr = ...
95d4f76bfaf8e24570e6c8685261e4fdd60ba37c
shreeharshas/LeetCode
/easy/9_PalindromeNumber/9.py
433
3.5625
4
# https://leetcode.com/problems/palindrome-number/ class Solution: def isPalindrome(self, x: int) -> bool: if x <= 0: return False s = [] while x > 0: r = x % 10 x = int(x/10) s.append(r) for i in range(len(s)): if s[i] !=...
456f4f23b321fae09d01102e4aff8765a6c14afa
BronsonLotty/SelfProjects
/mystudy/mytree.py
2,538
3.6875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Jun 15 19:55:25 2018 @author: xutingxi """ #学习树和图 ''' 跟据前序遍历创建二叉树链表。 输入为list,表示从list中的i点为根结点,访问visit点,并创建where树 eg list=['A','B','#','D','#','#','C','#','#'] ''' Trees={} visit=0 global Trees global visit def CreateTree(l,index=0,visit=0,where='left'...
ed98ecb5631f2a24cb134ee2d6ce45dcc68d562a
devbaj/python_oop
/zoo.py
1,677
3.828125
4
class Animal: def __init__(self, name, age): self.name = name self.age = age self.health = 100 self.happiness = 100 def display_info(self): print(f"Animal: {self.name}, Age: {self.age}, Health Index {self.health}, Happiness Index: {self.health}") return self d...
16b2756a229c792332043b619c5220e918517e2f
cholsi20/Python
/Python Files/StopWatch.py
475
3.5625
4
import time class StopWatch: def __init__(self): self.__startTime = time.time() #get methods for start and end def getStartTime(self): return self.__startTime def getEndTime(self): return self.__endTime #define start and stop def start(self): self.__startTime = time.time() def stop(self): self....
3d97c97345d6d48de7b69e908f1a396f9ffb7d22
fjimenez81/test_pyhton
/inversa.py
140
3.625
4
def inversa(x): cont="" for i in x: cont=i+cont return cont print(inversa(input("Ingresa algo para darlo la vuelta: ")))
2789db209e4e19a3412a46278875f6eb8f090cc4
gambxxxx/scripts
/practice-stuff/python-stuff/Tic_Tac_Toe.py
3,628
3.71875
4
import random the_board = [' '] * 10 def display_board(board): def display_board(a,b): print(f'Available TIC-TAC-TOE\n moves\n\n {a[7]}|{a[8]}|{a[9]} {b[7]}|{b[8]}|{b[9]}\n ----- -----\n {a[4]}|{a[5]}|{a[6]} {b[4]}|{b[5]}|{b[6]}\n ----- -----\n {a[1]}|{a[2]}|{a[3]} {b...
cc8812ea32486b8d784c884fe39e93a5fb35f069
KistVictor/exercicios
/exercicios de python/Mundo Python/032.py
431
3.875
4
'''ano = int(input('Digite um ano: ')) anob = ano/4 if anob%1 == 0: print('O ano é bissexto') else: print('O ano não é bissexto')''' from datetime import date ano = int(input('Digite um ano ("0" para o ano atual): ')) if ano == 0: ano = date.today().year if ano%4 == 0 and ano % 100 != 0 or ano % 400 == 0: ...
9e0cd1cdce22f645c9a9c4b75b7d40a063b2ed8e
amatyas2084/AndrewMatyas
/Python files/codes5.py
6,361
3.8125
4
''' Author: Andrew Matyas Date: 2/5 Description: This program does stuff with binary ''' class Binary(): def __init__(self, arg='0'): """ Each Binary object has one instance variable, a list called num_list. num_list has integers 0 or 1 in the same order as the corresponding charact...
af8fdedbb354bdae31163aedd47c0fd5e16928ee
kefitaib/holbertonschool-higher_level_programming
/0x0B-python-input_output/4-append_write.py
179
3.59375
4
#!/usr/bin/python3 """ Module """ def append_write(filename="", text=""): """ function """ with open(filename, 'a', encoding='utf8') as f: return f.write(text)
ab8bec632c541d62b600f0c80119dfdfb333041f
benbryson789/JWT-Auth
/readme/public_key_cryptography.py
1,696
3.796875
4
import random class Key: def __init__(self, public_key_base, public_key_modulus): self.public_key_base = public_key_base self.public_key_modulus = public_key_modulus self.private_key = random.randint(1,100) def generate_public_key(self): return pow(self.public_key_base, self.p...
c4dc7497a4106e5b75930302dc6e3bb2b5a6dea3
redashu/shubhredhat
/function_sample2.py
283
3.75
4
#!/usr/bin/python2 import time,commands def sum(x,y): print x+y ###### now adding two numbers if __name__ == '__main__' : a=int(raw_input("type first number : ")) b=int(raw_input("type second number : ")) sum(a,b) else : print "not in mood"
2735b492eec33ec89163721785010d4c349084cc
riadhassan/numericalAnalysisLab
/NewtonsBackwardInterpolution/backword formula.py
1,260
3.6875
4
import math #read input value from file file_name = input("Enter file name with extension: ") #code and input file should be in same folder f = open(file_name, "r") data = f.read() print(data) data = data.split() x, y = [], [] for i,j in zip(data[0::2], data[1::2]): x.append(float(i)) y.append(float(j)) inp = ...
e3cacf99737ef490191d3501930bffce97c1b699
HANXU2018/HBU2019programingtext
/信安作业jpg/3kaisa.py
228
3.546875
4
s=input('凯撒加密字符串') n=eval(input('偏移量(这道题是13)')) for i in s: if(ord(i)< 97 or ord(i)> 122): print(i,end='') else: d=(ord(i)-97+26-n)%26 print(chr(d+97),end='')
6f74495598ce1f25550f5f7e8e6ef3bc8e3a4744
xiangcao/Leetcode
/python_leetcode_2020/Python_Leetcode_2020/261_graph_valid_tree.py
2,635
4.1875
4
""" Given n nodes labeled from 0 to n-1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree. Example 1: Input: n = 5, and edges = [[0,1], [0,2], [0,3], [1,4]] Output: true Example 2: Input: n = 5, and edges = [[0,1], [1,2], [2,3], [1,3], [...
ec45d25f887b7553b69fea998c5e866c13628b91
amriteshs/comp9021-codes
/Exams/Mid-Sem Practice/2017/exercise06.py
3,969
3.984375
4
import sys def f(a, b): ''' Finds all numbers i and j with a <= i <= j <= b such that: - i + j is even; - when read from left to right, the digits in i are strictly increasing - when read from left to right, the digits in j are strictly decreasing - when read from left to ri...
20ee546460536192ca557381a6ace716e63d8ee8
charliedmiller/coding_challenges
/insertion_sort_list.py
2,553
3.890625
4
# Charlie Miller # Leetcode - 147. Insertion Sort List # https://leetcode.com/problems/insertion-sort-list/ """ This implementation sorts in-place, and swaps nodes, not values maintain 4 pointers: 1 for the insert node - the node we are "inserting" for the sort, and 1 for what we're comparing, and both's resp...
04cfd5ad30fbf9ee1b5f59a7702d408c9457fcf6
Vagacoder/Codesignal
/python/Arcade/Core/C94BeautifulText.py
3,069
4.21875
4
# # * Core 94. Beautiful Text # * Medium # * Consider a string containing only letters and whitespaces. It is allowed to # * replace some (possibly, none) whitespaces with newline symbols to obtain a # * multiline text. Call a multiline text beautiful if and only if each of its # * lines (i.e. substrings delimited ...
efbc091632f2335377d4e549f699037184102ffb
Matieljimenez/Algoritmos_y_programacion
/Taller_estruturas_de_control_secuenciales/Python_yere/Ejercicio_11.py
1,176
4.15625
4
""" Entradas nombre del trabajador-->str-->a Sueldo base del trabajador-->float-->b precio por hora normal del trabajador-->c horas normales de trabajo realizadas-->int-->d horas extra de trabajo realizadas-->int-->e número de actualización academica del trabajador-->int-->f número de hijos del trabajador-->int-->g Sal...
53603c74512a52a6adaeabe98265c11c9c0ee848
suribhatt/chatbot
/logger/logger.py
1,089
3.640625
4
from datetime import datetime import sqlite3 class Log: def __init__(self): pass def write_log(self, sessionID, log_message): self.file_object = open("conversationLogs/"+sessionID+".txt", 'a+') self.now = datetime.now() self.date = self.now.date() self.current_time = self...
7caa948b5b07817ea9517eea861d46b7c806e829
Raihan9797/Python-Crash-Course
/chapter_11/test_v2_survey.py
1,366
4.0625
4
## setUp() method ## MAKE SURE THE 'U' IS IN CAPS ''' when you include setup() method in a testclass case, python runs the setup() method before running each method starting with test_. Any objects created in the setup() method are then available in each test method you write ''' import unittest from chapter_11.sur...
6012ec6c72c9976ede543601dd8da2e8b7334d02
yuanguLeo/yuanguPython
/CodeDemo/shangxuetang/一期/面向对象/静态方法.py
919
3.71875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019/9/26 9:25 ''' 与“类对象”无关的方法,称为“静态方法” “静态方法”和在模块中定义普通函数没有区别,只不过“静态方法”放到了“类的名字空间里面”,需要通过“类调用” 静态方法格式: @staticmethod def 静态方法名([形参列表]): 函数体 重点如下: 1、@staticmathod 必须位于方法上面一行 2、调用静态方法格式:“类名.静态方法名(参数列表)” 3、静态方法中访问实例属性和实例方法会导致错误 ''' class Studen: ...
eb8bd757131ffbc194a85c5b8852ddc923a70777
SandraTang/Encryptors-and-Cryptology-Practice
/affine-encryptor-spanish.py
1,251
3.9375
4
#Affine Cipher Encryptor (Spanish) #by Sandra Tang from random import randint # (ax + b) % m #intro print "Affine Cipher Encryptor (Spanish)" #value of a a = raw_input("Value of a: ") a_int = True try: val = int(a) except ValueError: a_int = False while a_int == False: print "That's not an int. Try aga...
eb46653bb495ba43e14807012a79c6cfb0019dbc
Venkatraman9214/python-coding-challenges
/challenges/4.D.Min_Value/main.py
130
3.59375
4
numbers = [8, 2, 4, 3, 6, 5, 9, 1] ### Modify the code below ### lowest = numbers ### Modify the code above ### print(lowest)
fd54ae168dd10301ff09ab6e08f976873814b559
MaRTeKs-prog/Self-Taught
/Ch 9/csvreader_work.py
185
3.59375
4
import csv with open('E:\\Programming\\Literature\\The Self-Taught Programmer\\Ch 9\\t.csv', 'r') as f: r = csv.reader(f, delimiter = ',') for row in r: print(','.join(row))
11c883d9575da3171a9f22777b006e893dd8bbf8
Empythy/Algorithms-and-data-structures
/队列实现栈.py
1,048
3.921875
4
from collections import deque class MyStack(): """ push(x) -- 元素 x 入栈 pop() -- 移除栈顶元素 top() -- 获取栈顶元素 empty() -- 返回栈是否为空 """ def __init__(self): # 用两个队列实现 self.data_q = deque() self.t_q = deque() def push(self, item): self.t_q.append(item) while len(self.data_q) > 0: self.t_q.append(self.data_q...
c178380ac694613cb77996274db70bbabfe61df1
schnip/thesis
/scrap/test.py
247
3.578125
4
def gcd(a, b): if (b == 0): return a if (b > a): return gcd(b, a) a = a % b return gcd(b, a) import sys a = int(sys.argv[1]) b = int(sys.argv[2]) print(gcd(a,b)) from deap import tools print(tools.cxTwoPoint([1,1,1,1,1,1],[2,2,2,2,2,2]))
770917bb4424d8c67c335704f82d8412f152e86a
itsjw/python_exercise
/python_20740628/chapter_one/1.py
102
3.734375
4
def max(num1, num2): if num1 > num2: return num1 elif num2 > num1: return num2 print(max(8,4))
e021706231b8d9364b81f619a59f8b6e906f333a
AnDa-creator/John-hunt-chapterwise-solutions-self-made
/Exercise_ch_22.py
1,506
4.03125
4
class Distance: def __init__(self, value): self.value = value def __str__(self): return "Distance[{}]".format(self.value) def __add__(self, other): new_value = self.value + other.value return Distance(new_value) def __sub__(self, other): new_value = self.value ...
52653780f29f19fc64fe8c2f96c716f897275d5b
mipt-m06-803/PuchkovaDasha
/hw4/ex6_2.py
238
3.640625
4
L1 = [elem for elem in input().split()] L2 = [elem for elem in input().split()] L2_reverse = L2[::-1] s2_reverse = ' '.join(L2_reverse) s1 = ' '.join(L1) s2 = ' '.join(L2) if s2 in s1: s1 = s1.replace(s2, s2_reverse, 1) print(s1)
bbc6043027187202b5fe057400af97ba8dd6c208
huynhtuan17ti/Generate-testcase-for-cp
/GenerativeFunction.py
4,952
3.640625
4
import numpy as np import random def split_array(arr, num_parts): #split an array into several parts assert num_parts > 1, "number of splited part must greater than 1" split_arr = np.array_split(np.array(arr), num_parts) return split_arr def generate_permutation(len, base = 0): #generate a ...