blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
cd74d849dd959601502a3b67a4ea6ad1a2838601
jaynwauche/Pytask2
/starttask.py
1,545
4.03125
4
#User Data Validation user_data_container = [] while True: first_name = input("Enter First name: ") last_name = input("Enter Last name: ") e_mail = input("Enter E-mail: ") names = (first_name + ' ' + last_name) import random import string random_strings = "" ...
ee40adf42c99ff53f087a69222d4ef80ca357cfa
leonardogandrade/quicksort
/sorting_algorithms.py
3,298
3.75
4
import random class Sorting: def partition_lomuto(A:list, lb:int, hb:int): """ This method is responsible for split the sets """ pivot = hb i = lb for j in range(lb, hb): if A[j] <= A[pivot]: A[j], A[i] = A[i], A[j] ...
0aae8414029c96160321e9e0ec55a59878955738
ausaki/data_structures_and_algorithms
/leetcode/add-and-search-word---data-structure-design/283108440.py
1,734
3.609375
4
# title: add-and-search-word---data-structure-design # detail: https://leetcode.com/submissions/detail/283108440/ # datetime: Mon Dec 2 12:04:32 2019 # runtime: 296 ms # memory: 23.7 MB class Trie: def __init__(self): self.root = {} def add(self, word): node = self.root for char i...
72b88d043dcb25838e0f634dc90110fb675c7f0e
mljarman/DS-Unit-3-Sprint-2-SQL-and-Databases
/module1-introduction-to-sql/rpg_queries.py
2,916
3.5
4
import sqlite3 conn = sqlite3.connect('rpg_db.sqlite3') curs = conn.cursor() #How many total Characters are there? query1 = 'SELECT COUNT(*) FROM charactercreator_character'; print('Total number of characters:', curs.execute(query1).fetchone()) # How many of each specific sublcass? query2 = 'SELECT COUNT(*) FROM cha...
c2dafea0f2a18c0b313b0b4296bee978bb6c4811
Jayaprakash1998/simple-python-codes
/candy machine.py
171
3.828125
4
av = 3 x=int(input("enter no of candies you want :")) i=1 while i<=x: if i>av: print("out of stock") break print("candy") i=i+1 print("Bye")
e2a9b570061b4c083308395483a54a1966ec6109
dkuldeep11/Python-Tutorial
/Data-Structures/trees/avl/avl_tree_node.py
907
3.90625
4
class Node: """This is Binary Tree Node class""" def __init__(self, item=None): self.data = item self.left = None self.right = None self.height = 0 def setData(self, item): """This is setter for data""" self.data = item def getData(self): """This is getter for data""" return self.data def setLe...
ea050ec390ee4c20921d0e924de3bb1de8bcfb8e
alezanper/python-notes
/POO/hasattr.py
254
3.796875
4
class my_Class: a = 1 def __init__(self): self.b = 2 my_Class_1 = my_Class() print(hasattr(my_Class_1, 'b')) #True print(hasattr(my_Class_1, 'a')) #True print(hasattr(my_Class, 'b')) #False print(hasattr(my_Class, 'a')) #True
a5d598f6e3a84da1a455fe7ee3c2cb31490ca01d
dhlife09/Python
/20200523.py
526
3.734375
4
print ("M: I like Spanish. So, I decided to learn Spanish.") print ("W: Hey! And") print ("M: So, I learn Spanish by myself, but it is too hard to learn it") print ("I really want to play minecraft every day!!") print ('나는 원숭이다.') a=2 b=3 c=5 d=-2 e=-3 f=-5 g=7 h=11 i=13 j=-7 k=-11 l=-13 m=17 n=19 o=23 p=-17 q=-19 r=...
0a523eb05692d732300a99c4254d26426eb33b02
MyloTuT/IntroToPython
/Excercise/Ex5/ex5.2.py
147
4.03125
4
#!/usr/bin/python3 mylist = ['Hey', 'there', 'I', 'am', 'amazing!'] mydict = {} for word in mylist: mydict[word] = len(word) print(mydict)
4912bdcc9035cd579cce01d2ccf9891188f39689
IMakeBotsForYou/tictactoe
/main.py
7,267
3.625
4
''' Code by https://github.com/IMakeBotsForYou/ ''' import tkinter as tk from tkinter import messagebox import random ROWS = 3 COLUMNS = 3 # Creates an empty board board = {} corners = ["00", "02", "20", "22"] middles = ["01", "10", "21", "12"] already_countered = False def initialize_board(): for i in range(RO...
e7f24c886b267e893375ed43b09ef517ad29257b
666sempron999/Abramyan-tasks-
/Begin(40)/40.py
873
3.8125
4
''' Begin40 ◦ . Найти решение системы линейных уравнений вида A 1 ·x + B 1 ·y = C 1 , A 2 ·x + B 2 ·y = C 2 , заданной своими коэффициентами A 1 , B 1 , C 1 , A 2 , B 2 , C 2 , если известно, что данная система имеет единственное решение. Воспользоваться фор- мулами x = (C 1 ·B 2 − C 2 ·B 1 )/D, y = (A 1 ·C 2 − ...
c45fba69dea9506683fc0254878ffb6cdb2bf080
jdsuarez/task_01_python
/Retos/reto1.py
785
3.6875
4
print('Bienvenido al sistema de ubicación para zonas públicas WIFI') # n1 = int(str(usuario)[2:]) # ultimos 3 digitos del usuario // captcha usuario = input('Por favor ingrese su usuario: ') contraseña = [] # cod usuario 51743 reverso 34715 if usuario != '51743' or len(usuario) == 0: print('Error') usuario = []...
8881c4861df6d8bae61d7b0467d8cad71f995a4a
sunt727/Data-Analysis-by-Python
/ps1_final/ps1backup.py
9,479
3.96875
4
########################### # 6.0002 Problem Set 1: Space Cows # Name: Tuo Sun # Collaborators: None # Time: 2:30 # Difficult sections / topics: Problem #2 from ps1_partition import get_partitions import time import copy # ================================ # Part A: Transporting Space Cows # =========================...
084d4b09d35e0a1ec25adc5c3769c12665d06b74
gustavocrod/python_compiler
/token.py
1,097
3.5
4
import enum class Token: def __init__(self, token_text, token_type): self.text = token_text # texto atual do token. Usado para ids, strings e numeros self.kind = token_type # o tipo do token que ele esta sendo classificado como @staticmethod def is_keyword(token_text): for kind ...
9afe1424aa08603a4f5804c4abf4a0ae47866fea
vakhnin/geekbrains-algorithms
/lesson02/les02task08.py
1,568
4.28125
4
# lesson 02 task 08 # # Посчитать, сколько раз встречается определенная цифра # в введенной последовательности чисел. # Количество вводимых чисел и цифра, которую необходимо посчитать, # задаются вводом с клавиатуры. # Ввод количества чисел и подсчитываемую цифру while True: try: n = input('Введите количес...
9fd45e513b53f36614a69be54764ee70a2908706
Young-Jo-Choi/data_analysis
/OOP/7_Inheritance.py
2,916
3.640625
4
""" [클래스 상속] 1. 부모 클래스가 갖는 모든 메서드와 속성이 자식 클래스에 그대로 상속된다. 2. 자식 클래스에서 별도의 메서드나 속성을 추가할 수 있다. 3. 메서드 오버라이딩 4. super() 5. Python의 모든 클래스는 object 클래스를 상속한다. : 모든 것이 객체임 MyClass.mro() --> 상속관계를 보여준다. (아래에 해당하는 주석에 번호를 매겨 예시를 삼음) """ # 지난 번과 같은 클래스(부모가 됨) class Robot: """ __doc__을 확인하기 위한 주석임 저자 : 최 직...
466be91f590edde449659cadc641be8a0c1e0ef8
Nilesh-Thote/College_Database_Management
/College_Database_Management.py
9,836
4.78125
5
#importing sqlite3 so that we can use database import sqlite3 #conn object we are creating by using connect method of sqlite3 to connect to our database file conn = sqlite3.connect('College_database.db') #college_database.db is file name you can use your file path location there to access that file. cursor = conn.curso...
ac3debe33750eb7610b0a72125f0c95f09983007
kaladhar-mummadi/hackerrank
/Algorithms/implementation/Between Two Sets.py
608
3.546875
4
#!/bin/python3 import sys def gcd(a,b): while b > 0: temp = b b = a % b a = temp return a def lcmTwo(a,b): return ((a * b) // gcd(a,b)) n,m = input().strip().split(' ') n,m = [int(n),int(m)] a = [int(a_temp) for a_temp in input().strip().split(' ')] b = [int(b_temp) for b_temp in i...
548f05310f378bd4ca05acaee46c94a3a2e70b5c
bella458/GitApi567
/GitApi567.py
1,503
3.90625
4
"""Bella Manoim Git API assignment Requirements: Write a function that will take as input a GitHub user ID. The output from the function will be a list of the names of the repositories that the user has, along with the number of commits that are in each of the listed repositories. C...
3590e3eedb406aed63e8f0fe8378acf0239c3576
ivan-yosifov88/python_basics
/While Loop-Lab/04. Sequence 2k + 1.py
80
3.59375
4
number = int(input()) k = 1 while number >= k: print(k) k = k * 2 + 1
06903a62558cdf1a13e9cad651cb5d6d08454dd2
NishKoder/Python-Repo
/Chapter 5/intro.py
277
3.90625
4
# data structure # list # lits store int,float,string number = [1, 2, 3, 4, 5, 6] print(number) words = ["ewerw", "weffe", "erer"] print(words) mixed = [3, "wew", 3.4, "wew", None, 11] print(mixed) print(number[1]) print(number[-1:-3:-1]) mixed[1:] = "sad" print(mixed)
197052fa8a7bbe780105bb07fae107f7608517b2
Shiv2157k/leet_code
/data_structures/three_sum.py
3,317
3.875
4
from typing import List, Set class ThreeSum: def get_list(self, nums: List[int]) -> Set[Set[int]]: """ Approach: Two Pointers Time Complexity: O(n^2) Space Complexity: O(n^2) :param nums: :return: """ if not nums: return [] nums....
1bcd07604ecd42ca4b5c3b3dcfb80e4751be55e2
panpan31415/wzr
/exercise2.py
1,415
4.34375
4
import random # write a function to ask user to type a number. # 1. this function should generate a random number between 0 and 100 # 2. it should save the number that user typed and check if the number is a real number. # 2.1 if the number is not a valid number # it should tell user that the number is ille...
aa253f6c1a49fec28f499c0c3c149f2f44dae71b
mister-one/python
/nodes.py
5,584
4.21875
4
Nodes Introduction Nodes are the fundamental building block of many computer science data structures. They form the basis for linked lists, stacks, queues, trees, and more. The data contained within a node can be a variety of types, depending on the language you are using. It can be an integer (the number 5), but it...
80366446a75d69fbfa7874b223e346bf022914ff
udhayprakash/PythonMaterial
/python3/13_OOP/d_magicmethods/08_slots.py
1,725
3.71875
4
""" Purpose: __slots__ importance pip install pympler --user """ import sys from pympler.asizeof import asizeof class OrdinaryClass: """ Generally, all class instances are mutable """ def __init__(self): self.foo = None self.bar = None o = OrdinaryClass() print(vars(o)) # Dyna...
23606d8b32a3364ee13c5239a9c41657ce71349e
harshil2493/TF-Tut
/mnist_deep_learning.py
941
3.796875
4
from deep_learning_network import train_neural_network from tensorflow.examples.tutorials.mnist import input_data ''' input > weights > hidden l1 (activation) > weights > hidden l2 (activation) > weights > output compare output with intended output > cost or loss function Optimization function optimizer > minimizeco...
a0de9d75f9410af9f5f1d64184138dab7575c243
MidAutumn10100101/leetcode_everyday
/6-23-剑指05-替换空格/replaceSpace.py
359
3.53125
4
#直接遍历,遇见空格就将其替换为%20 class Solution: def replaceSpace(self, s: str) -> str: out = "" for i in range(0, len(s)): if s[i] != ' ': out = out + s[i] else: out = out + '%20' return out obj = Solution() s = "We are happy." print(obj.replaceSp...
ec09e28c6f754c4f7249307305817a28eb325766
aphymi/advent-of-code
/util/utils.py
1,614
3.734375
4
from collections import deque import itertools from typing import Generator, Iterable, Tuple, TypeVar X = TypeVar("X") def sliding_window( iterable: Iterable[X], window_size: int = 2 ) -> Generator[Tuple[X], None, None]: last_n = deque() iterator = iter(iterable) for item in iterator: last_n.append(item) i...
2b94ad1939f2f47a172fc31ed935db76424627c3
jambellops/hRank
/StringCapitalize.py
200
3.90625
4
''' stringCapitalize ''' # Complete the solve function below. def solve(s): stringlist = list(s.split(' ')) Printout = ' '.join(word.capitalize() for word in stringlist) return Printout
53b5fd712d53845458c0da973f5254fc64819815
lliguimilton94/python-bootkamp
/Week_1/Day1/sum.py
482
4.21875
4
# the goal of this script is to sum up all the numbers between # N and M (inclusively), where N and M are both user inputs. N = int(input("Enter lower limit: ")) M = int(input("Enter upper limit: ")) # Use a for loop sum = 0 for number in range(N,M+1): sum += number print("The total sum is: ", sum) # print("T...
dd3b903504d299a569bd773a5fd132215eb51677
tf302/2020-holidays-python
/class.py
579
3.96875
4
# 创建类 class Calculator: #私有属性 name = "Calculator" price = "200$" #类方法 def __init__(self,name,age,sex): self.n=name self.a=age self.s=sex #实例方法 def add(self,a,b): result = a + b print("Add is ") print(result) def minus(self,a,b): ...
696d4b4a74c039746f46106d11edc48b9f9b1287
feliciah6/Back_end_development
/range2.py
115
3.96875
4
students = ["irene","judith","laureen"] for i in range(3): print("student number {}" .format(i , students[i]))
4c3285655927fba62e55739bf24bb091d944958d
gsaukov/python-machine
/core/algos/2_fibo.py
349
3.671875
4
def count(num, old): if num == 0: return 1, 0 res = num + old old = num return res, old def fibo(end): num = 0 old = 0 res_list = [] for i in range (0, end): num, old = count(num, old) res_list.append([old, num]) return res_list print('Enter int:') end = ...
bbdfc40ff3d5aae59ce3a9b9b8fb22281cc1decb
agarod/Programacion_Cientifica
/ejercicios_libro/tema11/ej1.py
786
3.84375
4
#!/usr/bin/python # encoding: utf-8 import sys '''Nombre: Ardiel Apellidos: Garcia Rodriguez Ejercicio:Write a function that reads the words in words.txt and stores them as keys in a dictionary. It doesn’t matter what the values are. Then you can use the in operator as a fast way to check whether a string is in...
e354e69842051c5231b0e235ca01c0819ed3fa97
AlexTyl/Python-learning
/Taskes/Task1.22.py
888
4.09375
4
# Натуральное число N разложить на простые множители print("Enter the number: ") def check_prime_number(number): if number < 2: return False current_number = number - 1 while current_number != 1: if number % current_number == 0: return False current_number -= 1 ret...
00f296c7403ba0fca4def96b4b01f0d56157109e
ThejasR/Python_Programs
/regular_expressions/re14.py
251
4.28125
4
import re text = 'abbaaabbbbaaaaa' pattern = 'ab' for match in re.findall(pattern, text): print ('Found "%s"' % match) #The findall() function returns all of the #substrings of the input that match the pattern without overlapping.
3423aeb751f2fddc7beae3628dbf55ce789af2b4
lauramoon/TicTacToe-python
/TicTacToe.py
1,815
3.96875
4
from board import Board from playsmart import play_smart from playrandom import play_random from playcasual import play_casual def play_game(): """ One play-through of a game of tic-tac-toe. :return: """ # Player picks game mode print("Select the game mode:") print("1 - Random") print(...
ac47730fa21b4da1ffb3b9227907e1a558bfe266
Ezi4Zy/leetcode
/824.山羊拉丁文.py
980
3.671875
4
# # @lc app=leetcode.cn id=824 lang=python # # [824] 山羊拉丁文 # # @lc code=start class Solution(object): def toGoatLatin(self, S): """ :type S: str :rtype: str """ VOWEL = 'aeiouAEIOU' ret = '' not_vowel = '' space = 0 first_char = True ...
4691f31be0222fa5def3dde3a61b8a854290f01d
uiandwe/TIL
/algorithm/함수이름바꾸기.py
1,200
3.515625
4
# -*- coding: utf-8 -*- def checkUnderbar(temp_str: str, func_name: str) -> list: first, *others = temp_str.split("_") first = getattr(first[0], func_name)() + first[1:] return ''.join([first, *map(str.title, others)]) def camelCase(name:str) -> str: """ camelCase """ return checkUnderbar(...
7f1fc7f3930cb9aee35f33a240d5a7763dc6c348
brad-h/expy
/ExPy/ExPy/module14.py
613
3.9375
4
""" Tax Calculator """ import decimal WI_SALES_TAX_RATE = decimal.Decimal('0.055') def ex14(): """ Prompt the user for an amount and a state Apply sales tax of 5.5% for Wisconsin residents Display the amount owed """ amount = decimal.Decimal(input('What is the order amount? ')) state = input...
46fef35a7da9a2f8243c16dbe9721b9f3a1ec8c0
olgahnat/Python_for_QA
/HW2-1.4_Level2.py
161
3.9375
4
txt = input('Enter a text containing \'hi\': ') txt_ch = txt.replace('hi', 'bye') ct = 'bye' count_ct = txt_ch.count(ct) print (txt_ch, "\nCount: ", count_ct)
fec85616be03896fae2e85b9523106f502743963
lucascv/Python
/PycharmProjects/guppe/sec7_p1_ex36.py
129
3.796875
4
a = [] qtd = 10 while len(a) < qtd: a.append(float(input('Digite um número: '))) print(a) a = sorted(a) print(a)
bd700ed8d22ffa53d4050d009bab72ef60aacfa5
fgmacedo/problems_ads
/problems/uri_1442_desvio_rua/uri_1442_desvio_rua.py
5,704
3.640625
4
#!/usr/bin/env python3 import sys from collections import defaultdict, deque from copy import deepcopy """ Este exercício foi bem desafiador. Não consegui encontrar uma solução por conta própria e recorri a um algorítmo para resolver. Passei mais de 10 horas trabalhando neste problema, o que é meio frustrante/desconf...
ac383a8c0ac163945824242d2cfabdc944c757a4
yuehongxia/lala
/0517/test3.py
631
3.578125
4
#!/usr/bin/python # -*- coding: UTF-8 -*- from tkinter import * # 导入工具包 __author__ = 'fyby' class App: def __init__(self,master):# 构造函数里传入一个父组件(master),创建一个Frame组件并显示 frame = Frame(master) frame.pack() #创建两个button,并作为frame的一部分 self.button = Button(frame,text='QUIT',fg="red",command=frame.quit) self...
bcddce2f417c4322a951b5e8e30eb5fe15e525d8
he44/Practice
/leetcode/2020_08_challenge/0806_find_all_duplicates_in_an_array.py
794
3.5625
4
from typing import * class Solution: def findDuplicates(self, nums: List[int]) -> List[int]: ans = [] for num in nums: if nums[abs(num) - 1] < 0: ans.append(abs(num)) # might be better to put this in else, but won't matter for this problem nums[ab...
70b72494500da595127db3cf60978aa7d9c40a39
marcobelo/HackerRank
/Algorithms/Warmup/Plus_Minus.py
477
3.703125
4
#!/bin/python3 import math import os import random import re import sys # Complete the plusMinus function below. def plusMinus(arr): p, n, z = 0, 0, 0 for i in arr: if i == 0: z += 1 elif i > 0: p += 1 else: n += 1 return p, n, z if __name__ == ...
34abdc84dc35384b7930ab2b703de5bb210b4eac
CaptainChuenthavorn/DATA-STRUCTURE-AND-AlGORITHM
/lab6_recursive/tempCodeRunnerFile.py
1,989
3.859375
4
''' หอคอยแห่งฮานอย Enter Input : 3 | | | 1 | | 2 | | 3 | | move 1 from A to C | | | | | | 2 | | 3 | 1 move 2 from A to B | | | | | | | | | 3 2 1 move 1 from C to B | | | | | | | 1 | 3 2 | move 3 from A to C | | | | | | | 1 | | 2 3 move 1 from B t...
cc585bc71de8e298b0d9c014db66a55d909c2a5c
Cor-J/TP_ISP
/Exercice 1/Exercice_material/Exercise3Example.py
758
3.546875
4
# -*- coding: utf-8 -*- # Load the required libraries/modules from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes # TODO open the key file using the python open() function. Hint: use 'rb' as a parameter to read the file in binary # TOD...
464fdfaa9320f6368c460b138bfce0b60b8b7bb6
DanielKolodziej/Python
/Pythonstuff/lab2/dkolodz1_Lab2_413.py
694
4.0625
4
#Daniel Kolodziej #1/24/2018 #Lab 2 ITMD-413 import time #local variable declaration bmi = 0.0 #Gather user input for weight and height weight = float(input('please enter your weight ( in pounds U.S. ): ')) height = float(input('please enter your height ( in inches U.S. ): ')) #calculate bmi bmi = ((...
dc43ab54fdbc4e270935d21771c01edf5448ecdd
9838dev/coding
/arrays/roman_int.py
433
3.890625
4
# given a roman number to integer # problem link: https://leetcode.com/problems/roman-to-integer/ def roman_int(s): d={'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000} carry = 0 total_sum = 0 for i in range(len(s)-1): if d[s[i]] < d[s[i+1]]: carry = d[s[i]] else: ...
bdd4deb0ce1be27f096ea7e21d147e55ebe294c1
catalinamusalem/Catalina
/Actividades/AF01/cargar.py
1,207
3.5625
4
from collections import namedtuple, deque def cargar_animes(path): animes= namedtuple("animes", ["nombre", "rating", "estudio", "genero"]) diccionario1=dict() # Abrimos el archivo de animes with open(path, 'r', encoding="utf-8") as file: # Leemos las lineas for line in file.readlines()...
009ec37cff688edaf88fc56bdc663b42bd35a4f8
banashish/DS-Algo
/coding Ninjas/DS/Recursion/checkSorted.py
649
3.703125
4
# [15, 2, 8, 9, 10, 11, 16] sa = true bit it return false # [2, 8, 9, 10, 11, 16] sa = true # [8, 9, 10, 11, 16] sa = true # [9, 10, 11, 16] sa = true # [10, 11, 16] sa = true # [11, 16] sa = true # [16] arr = [15,2,8,9,10,11,16] def checkSorted(arr): print(arr) if(len(arr) <= 1): return...
48efb643aa1b85a0fb70c77e27b8229e569c0989
Reemomar/new-project
/day12.py
136
3.75
4
x=5 y=7 R = "please , I want{} sandwishes and {} donutes" print(R.replace("I" ,"We")) print(R.format(x ,y)) print(R.upper("a"))
60940676255c0b43f9017dab9ce26ddfe8d60350
odehabuzaid/math-series
/math_series/series.py
1,464
4.15625
4
def fibonacci(n: int): """ takes n as integer and Returns the nth number in the Fibonacci sequence. if the number is less than or equal to 1, return the number. if the number is greater than 1, return the nth number in the Fibonacci sequence. """ return n if n <= 1 else fibonacci(n - 1) + fibona...
f7fa8783683b370edfcf6e7373b2ca2bc820d194
guanfuchen/CodeTrain
/SwordOffer/Algorithm/Python/fibonacci_array.py
719
3.984375
4
#!/usr/bin/python # -*- coding:utf-8 -*- # 递归方法 # class Solution: # def Fibonacci(self, n): # # write code here # if n==0 or n==1: # return 1 # else: # return self.Fibonacci(n-2)+self.Fibonacci(n-1) # 动态规划方法 class Solution: def Fibonacci(self, n): # writ...
4c38f72352ddc4bb30aa92beec16b36057396ee2
esalaverria/CodeWars
/regex_validate_pin.py
294
3.65625
4
import re def validate_pin(pin): is_valid4 = re.search(r'^[0-9]{4}$', pin) is_valid6 = re.search(r'^[0-9]{6}$', pin) if is_valid4 or is_valid6: return True else: return False # int(pin).isnumeric() and isinstance(pin, int) and print(validate_pin("11023"))
b8ed0c065e8af87cfee5e5d8bbc735cc0e50cc43
Qiaomengyu/i-want-offer
/7.斐波那契数列(递归和循环).py
1,267
3.71875
4
# -*- coding: utf-8 -*- """ Created on Tue Apr 16 17:15:53 2019 @author: ASUS """ ''' 把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。 输入一个非递减排序的数组的一个旋转,输出旋转数组的最小元素。 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数组的最小值为1。 NOTE:给出的所有元素都大于0,若数组大小为0,请返回0 思路:使用二分查找 1、设置一个首部指针low,一个尾部指针high,以及一个最小值初始值minVal 2、求出中间坐标middle, 二分法核心: ...
5bba3528fd27cc78e03241aaffa4a4a7670e3b6d
gyogeshchandra/design_pattern
/singleton.py
571
3.703125
4
class Singleton: __instance = None @staticmethod def get_instance(): if Singleton.__instance == None: Singleton() else: return Singleton.__instance def __new__(cls): if Singleton.__instance != None: raise Exception("This class is singleton") ...
1cfbe4253326676948d5cbb837d4be8aade9fc7f
MoNaX667/PythonCourses
/Lesson_08/Task_05.py
3,794
3.984375
4
# Продолжить работу над первым заданием. Разработать методы, отвечающие за приём оргтехники на склад и передачу в # определенное подразделение компании. Для хранения данных о наименовании и количестве единиц оргтехники, # а также других данных, можно использовать любую подходящую структуру, например словарь. class Sto...
70d71120b7bcb739cb1e89cc295981225ac8bf6e
albertfougy/problem_solving_python_ds_algo
/algorithm_analysis/what_is_algo_analysis/benchmark_analysis.py
934
4.21875
4
""" In the time module there is a function called time that will return the current system clock time in seconds since some arbitrary starting point. By calling this function twice, at the beginning and at the end, and then computing the difference, we can get an exact number of seconds (fractions in most cases) for ex...
083f93ab706211122b13e17d9f83f42696b00c98
sdpython/td3a_cpp
/examples/plot_benchmark_associative.py
1,983
3.828125
4
""" .. _l-example-associativity: Associativity and matrix multiplication ======================================= The matrix multiplication `m1 @ m2 @ m3` can be done in two different ways: `(m1 @ m2) @ m3` or `m1 @ (m2 @ m3)`. Are these two orders equivalent or is there a better order? .. contents:: :local: """...
383373936f56852081d4ab16747a565237c59469
N-eeraj/code_website
/Code/py/rectangle.py
153
4.1875
4
length = float(input("Enter Length: ")) width = float(input("Enter Width: ")) print("Area: ", length * width) print("Perimeter: ", 2 * (length + width))
3ddb94406f76e308b6eaf8dc7bfcb3d6b4a3d1f6
rafhaeldeandrade/learning-python
/2 - Variáveis e tipos de dados em Python/Exercicios/ex22.py
317
3.828125
4
""" 22. Leia um valor de comprimento em jardas e apresente-o convertido em metros. A fórmula de conversão é: M = 0,91 * J, sendo J o comprimento em jardas e M o comprimento em metros. """ jardas = float(input('Digite o comprimento em jardas: ')) metros = 0.91 * jardas print(f'{jardas}yd corresponde a {metros}m')
d380b41ca1ce5d42f534eeb3254557b5455491ce
priyansh-19/Personalized_file_password_cracker
/crack.py
3,908
3.765625
4
import zipfile import itertools from tqdm import tqdm found = False file_name = input("Enter the name of the file to be cracked : ") file_inside = file_name + '.txt' file_name = file_name + '.zip' z = zipfile.ZipFile(file_name) print("Choose The Type of Attack : ") print("1 : Brute Force Passwords of Lengt...
b83fea303b648cac6e2361f0f080d6328554bba6
zirus23/Shadow-of-the-Ninja
/Ninja Side-Scroller/Code/pathfinding.py
7,641
3.75
4
class Graph(object): def __init__(self, board): self.board = board self.width = len(board[0]) self.height = len(board) self.walls = set() self.spikes = set() for row in range(len(board)): for col in range(len(board[0])): if board...
1f6ac3482a52649fcf7f31a7d1f2d09f17248993
AmnesiaWu/NN
/sources/QS.py
731
3.65625
4
from datetime import datetime import numpy as np def partition(arr, low, high): i = (low - 1) # 最小元素索引 pivot = arr[high] for j in range(low, high): # 当前元素小于或等于 pivot if arr[j] <= pivot: i = i + 1 arr[i], arr[j] = arr[j], arr[i] arr[i + 1], arr[high] = arr[high]...
231c730c8e8a3d06274986a23a53da1d81e018bc
venkatesh123456779/Wipro-PJP-Python
/TM-2/List/8.py
380
4.09375
4
list1=[] n = int(input("enter number of elements: ")) for i in range(n): list1.append(input("Enter number: ")) print(list1) item = input("Enter the element to be removed :") while(True): if item in list1: list1.remove(item) print(list1) break else: print("Item does not exist"...
6dd1b71be95c813d7fd7b798856e46146a1a2de5
Iverance/leetcode
/687.longest-univalue-path.py
1,742
4.03125
4
# # [687] Longest Univalue Path # # https://leetcode.com/problems/longest-univalue-path # # algorithms # Easy (33.03%) # Total Accepted: 8.3K # Total Submissions: 25.1K # Testcase Example: '[5,4,5,1,1,5]' # # Given a binary tree, find the length of the longest path where each node in # the path has the same value. ...
8c9bf47c28b0143e474536c8af927b03c11babc5
ZMbiubiubiu/For_Test
/file_os_path.py
546
3.71875
4
""" 将文件夹下的txt文件编程csv文件,通过改后缀的方式 """ import os import sys DIRECTOR = 'csvs' def unify_ext_with_os_path(dir: str): """ :param dir: 一个文件夹 :return: None """ for file in os.listdir(dir): # file{str} : '1.csv' basename, ext = os.path.splitext(file) # basename{str} : '1' , ext{str} : '.csv' ...
88f3944faa0cad18c2b6d0b84d8570fac111e654
tshiu/PETraining
/ex31.py
3,501
4.4375
4
#print the below string that should prompt user to either enter in 1 or 2; should note #that if they enter in #1 or #2, that will lead them to the last else statement print "You enter a dark room with two doors. Do you go through door #1 or door #2?" #prompting user to set door as the input door = raw_input("> ") #if...
34ce49d795d84293cb833d22985cb680f8afa8f5
r3mas/python_tutorial
/codecademy/lesson7.py
802
3.953125
4
def print_list(x): for i in range(0, len(x)): print x[i] def double_list(x): for i in range(0, len(x)): x[i] = x[i] * 2 return x def total(numbers): result = 0 for i in range(len(numbers)): result = numbers[i] + result return result # Add your function here def join_s...
ae99ba05dfed268a96cf36014ece74a6dc8ad58c
yash1th/hackerrank
/python/strings/Capitalize!.py
418
4.125
4
def capitalize(string): return ' '.join([i.capitalize() for i in string.split(' ')]) if __name__ == '__main__': string = input() capitalized_string = capitalize(string) print(capitalized_string) # s = input().split(" ") #if i use default .split() it will strip the whitespace otherwise it will only co...
1cdfbbe36b0daee9d7fc77ba41740406506004ad
AuGom/Python-Studies
/College/augusto_fibonacci.py
296
3.921875
4
n = int(input('Digite quantos valores voce deseja na sequencia: ')) n1 = int(0) n2 = int(1) if n < 0: print('Valor invalido.') elif n < 2: print('Necessario no minimo dois valores.') else: for i in range(n): print(n1) temp = n1 + n2 n1 = n2 n2 = temp
3951eab0cc0734f062370f1176c2492edbce2c0b
Ryan-Gordon/Project-Euler-Solutions
/1000-DigitFibNumber-Problem25.py
842
3.96875
4
""" The Fibonacci sequence is defined by the recurrence relation: Fn = Fn-1 + Fn-2, where F1 = 1 and F2 = 1 The 12th term , F12 is the first term to contain three digits What is the index of the first term in the Fibonacci Squence to contain 1000 digits. Ryan Gordon """ def fib(): a, b = 0, 1 terms=1 # Used t...
725c24c602859fabef4f4f104022b0c07c36cc17
AishwaryaJadhav9850/GeeksforGeeks-Mathematical-
/GeeksForGeek_GCD of Array.py
1,142
3.5625
4
# -*- coding: utf-8 -*- """ Created on Tue Dec 1 20:49:25 2020 @author: aishw """ #User function Template for python3 class Solution: def gcd(self, n, arr): # code here if n==1: return arr[0] gcd=arr[0] arr.sort() for i in range(1,n)...
2e19159b15993b6806936e549c455bfb74424eb2
Osaroigb/Typing-Speed-Test
/main.py
3,057
4
4
# importing all libraries from tkinter import * from timeit import default_timer as timer import random x = 0 type_speed = 0 type_time = 0 def speed_test(): """A function that displays a random sentence to test a user's typing speed""" global x, type_time, type_speed type_speed = 0 type_time = 0 ...
3676c56b6f339f36daa8f3722e1f5e7170a0d438
lbenke/tictactoe
/src/test/test_minimax.py
2,761
3.65625
4
""" This module contains tests for the minimax agent. """ from unittest import TestCase from tictactoe import TicTacToe import numpy as np from players import WinBlockRandomCellAgent from agents.minimax import MiniMaxAgent class TestMinimax(TestCase): def setUp(self): pass def test_win_single_move(s...
bf577ee1c88324be498ca8fd9b70a90f70391c95
saijagadeesh02/python-practice
/py/test.py
1,343
4.125
4
class Stack(object): def __init__(self): self.stack = [] def isEmpty(self): return self.stack == [] def push(self, item): self.stack.append(item) def pop(self): return self.stack.pop() def peek(self): return self.stack[len(self.stack)-1] ...
8c3f3344262e633e8f13d0fac808e668b203f9e1
qmnguyenw/python_py4e
/geeksforgeeks/python/python_all/2_14.py
3,674
3.859375
4
Python – Consecutive Ranges of K greater than N Given a list of elements, the task is to write a Python program to get all ranges of K greater than N. > **Input :** [2, 6, 6, 6, 6, 5, 4, 6, 6, 8, 4, 6, 6, 6, 2, 6], K = 6, N = 3 > > **Output :** [(1, 4), (11, 13)] > > **Explanation :** 6 is consecutive...
515c00d63cbcc9f1ece7a7459895b253ce094669
FeliBlanco/TP1
/1.py
364
3.890625
4
#Leer un número e imprimirlo junto con sus primeros múltiplos, ejemplifique para los primeros #4 múltiplos del número ingresado numero = int(input("Ingresa un numero: ")) multiplo1 = numero * 1 multiplo2 = numero * 2 multiplo3 = numero * 3 multiplo4 = numero * 4 print(str(multiplo1) + " - " + str(multiplo2) + " - " ...
bf52972dd30604f7197908882cc07b29f65cc338
erofes/python_learn
/CribLibrary/functions/functions_main.py
536
3.921875
4
# Named functions 'def' def add(x, y): return x + y # Return value print(add(1, 4), add('abc', 'def')) # 5 abcdef # Function can return ANY object, even another function def choose_function(choose): if choose: def added(x, y): return x + y return added else: def con...
b51b475c9d7496fe7ea50d1b43195e3f4c0d2ca7
joshuawinter/python
/twitter/python-twitter-examples-master/twitter-stream-responder.py
1,751
3.609375
4
#!/usr/bin/python #----------------------------------------------------------------------- # twitter-stream-responder # - will respond to any tweet that mentions me. #----------------------------------------------------------------------- from twitter import * import time # this is the tag we're matching username =...
99dd8c29849ea3ed3ec7e5d372a27a261f0d0872
shivangi-prog/Basic-Python
/Day 2/string.py
759
4.125
4
print('Hello World!') print("Hello Python") print('Hello Again') print('I like typing this.') print('This is fun.') print('Yay! Printing.') print("I'd much rather you 'not'.") print('I "said" do not touch this.') name = 'Ashish' city = 'Delhi' print(name + ' ' + city) # take input from console greeting = "Hello " ...
8e02a29577ade9fdc90668e4154cf6c14dfb5e71
aluisq/Python
/estruturas_logicas_condicionais/ex41.py
458
3.609375
4
dado_imc = round(float(input("Informe qual é o seu IMC: ")), 2) if dado_imc <= 18.5: print("Abaixo do Peso") elif 18.6 <= dado_imc <= 24.9: print("Saudável") elif 25 <= dado_imc <= 29.9: print("Peso em Excesso") elif 30 <= dado_imc <= 34.9: print("Obesidade Grau I") elif 35 <= dado_imc <= 39.9: ...
2a4343565795b8c8ee52347a957d51e209459869
tdavchev/algorithms
/recursion/all_types.py
452
3.703125
4
def all_the_ways(target, count, start, output, arr): if count == target: print(output) if count < target: for i in range(start, len(arr)): temp_count = count + arr[i] output.append(arr[i]) all_the_ways(target, temp_count, start, output, arr) ...
07e5a661e27651433441ccc485811f7b29b1f0a3
dezhili/My_learnings
/ML_note/BuildingMLwithTensorflow/Chapter2/clustering.py
4,020
3.5625
4
''' In this process, we will also gain two new tools: the ability to generate synthetic sample sets from a collection of representative data structures via the scikit-learn library,and the ability to graphically plot our data and model results k-means and knn ''' ''' Learning from data-- unsupervised learnin...
c36decdafb8744f2b5f4e3d30b2065f4d8774a96
amyn96/Individu-project
/ftpclient.py
1,696
3.78125
4
import socket def Main() : host = "192.168.43.50" port = 8080 s = socket.socket() s.connect((host,port)) print ("Connecting to server...") print ("Server Connected!") option = input("What action do you wish to do? (d->download/u->upload) : ") s.send(str.e...
3085f3fe9bf4dc067cf4b4af4ab1cfdc47859f74
devpaulosouza/redes-socket-server
/server.py
1,527
3.59375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ################################################### # File name: server.py # ################################################### # author: Lauro Milagres Oliveira # # author: Paulo Souza # #############...
f30d99927ecdebdf48814d1377f76d1202c74c08
easauceda/EX-54
/classes/Background.py
875
3.671875
4
__author__ = 'Erick' class Background: """ Class Background is the container for all elements in the background of the game. This class utilizes two lists, one for stars, and one for trees. Each list is then traversed through by the function move_bg in order to create the illusion of movement. """...
55f82a26bc58d3056336523a19c939370eb8c266
brahim024/python-exc
/ch03/ex03.py
581
4.3125
4
# Exercise 3: Write a program to prompt for a score between 0.0 and 1.0. If the # score is out of range, print an error message. If the score is between 0.0 and 1.0, # print a grade using the following table: # Run the program repeatedly as shown above to test the various different values for # input. while True: sco...
0321969a08911060be6209c097585e399766d57e
sinhasaroj/Python_programs
/Multithreading/first_ex.py
348
3.5625
4
import threading print("Current Executing Thread:",threading.current_thread().getName()) # Output: Current Executing Thread: MainThread # Note: threading module contains function current_thread() which returns the current # executing Thread object. On this object if we call getName() method then we will get # cu...
c7f2af0099305b37690213e3a41c85f14affa6aa
Uniminutoarduino/SBCReview
/Scripts/Years.py
2,095
3.578125
4
#Script of Publications per year #Script designed in Python (V3.8) #Please see the included packages and install them before to run the script import operator import matplotlib.pyplot as plt; plt.rcdefaults() import numpy as np import matplotlib.pyplot as plt #This block is used to plot the publications by y...
e9fd0553dd72ac45f0b29fe78f2e9932711c7eda
bojika/CSCentre_Python
/lecture10/magic__new__.py
965
3.78125
4
# 1. # __init__ is not a constructor # __new__ takes class and arguments and create a class instance # __init__ takes an instance and initializes it class Noop: def __new__(cls, *args, **kwargs): # is in face a static method print("Creating instance with {} and {}".format(args, kwargs)) instance ...
01411c4088387401e53a9256a9a395c8ec91f069
KeaganKen/LoginApplication
/login.py
4,450
3.875
4
# JOIN MY DISCORD! discord.gg/dVSVGgqv2Q from tkinter import * import mysql.connector #Connects to the database db = mysql.connector.connect(user="root", host="127.0.0.1", database="passwords") mycursor = db.cursor(buffered=True) #Fetches rows (Username and password)from the database so it can later compare them...
52d9858a141da70c93e77caa6a762793ddb7e3d1
rithienatan/PUCMG-CC
/5º Semestre/Linguagens de Programação/TP1/lista.py
230
3.53125
4
lista = ["Linguagem de Programação", 2021, True] lista[0] = "Linguagem de Programação" lista[-1] = True lista.append([10, 15, 20]) # uma casa só lista.extend(["Henrique", "passei"]) # duas casas lista[2] = False print(lista)
2a5c364b92f49c9ef25e63ab504b505cd7ebbaf8
gritsp/detect_geometry
/v1/draft1.py
5,800
3.578125
4
import cv2 import numpy as np def isColor(color): # color[0] = color[0]*2 if 0<=color[0]<=180 and 0<=color[1]<255 and color[2]<25: return 'Black' elif 0<=color[0]<=180 and color[1]<50 and 180<=color[2]: return 'White' elif 0<=color[0]<=180 and color[1]<50 and 50<=color[2]<=180: ...
6cc4fdf619daec7c0c5b382f448fbe4176c087b5
michaelsilverstein/HackerRank-with-Kevin
/Game of Stones.py
831
3.765625
4
##https://www.hackerrank.com/challenges/game-of-stones-1 #Michael so far: def gos(stones): for game in stones: if game <= 1: return 'Second' turn = 0 while game > 1: if game % 5 == 0: game -= 5 turn += 1 if game % 3 == 0: ...
bfef39195ec4c4a17817bfe0c7788348fcc7baa8
YuliiaAntonova/leetcode
/if_pangram.py
618
3.90625
4
# A pangram is a sentence where every letter of the English alphabet appears at least once. # Given a string sentence containing only lowercase English letters, return true if sentence is a pangram, or false otherwise. class Solution: def checkIfPangram(self, sentence): alphabet = "abcdefghijklmnopqrstuvw...
a1c28c2f63c7e43130b06caeee6497f7c7dbd604
rafaelperazzo/programacao-web
/moodledata/vpl_data/12/usersdata/72/5334/submittedfiles/impedimento.py
282
3.765625
4
# -*- coding: utf-8 -*- from __future__ import division import math #ENTRADA l=input ('digite a posição do jogador l:') r=input ('digite a posição do jogador r:') d=input ('digite a posição do jogador d:') #SAIDA if r>50 and l<r and r>d: print ('S') else: print ('N')
93b97aa5f9e0754a54b9bd5e7ad8d12676b9569a
RichardSForsterRGU/Assessment1
/hello_world.py
189
4.0625
4
# Assessment 1 part 2 - amend print hello world to accept a name and print hello name. #Accept name name=input("Enter a name ") # Print hell and the variable 'name'. print(f"hello {name}")