blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
8d12fdf11f17b95ce032459aa3f543b359d42ac2
ramyasutraye/pythonprogram-1
/beginner level/2smallest.py
140
3.8125
4
a=[] no=int(input("enter the total number of elements")) for i in range(no): a.append(int(input("Enter next no :"))) a.sort() print(a[1])
5790d961d40d18031708732e6d05fa4c13e02a02
Hayliiel/_Python_
/Abstract Data Types/Container.py
2,971
4.375
4
# -*- code: utf-8 -*- """ The class that i made is a simple container, it has the basic functions of most of container type class. It can store elements, you can use the insert function to add multiple elements at time or one by one and, you can manipulate the existing elements inside of it, by using see function...
cf5cfddb3d941ef40db811fd205f5bb807199c64
makeitwayne17/ECE-Casino
/BLACKJACK.py
3,240
3.984375
4
#Victor's Casino (for now, we just have Blackjack) import random def enter_casino(): #lets player input name and choose game print("Welcome to the ECE Casino!") print("What is you name?") user_name = raw_input(">") print("Hi %s, what game do you want to play today?")%user_name.capitalize() user_game = raw_input(...
625f59c9c724dae8851fef5bb3f6a9c517407136
Dharani-18/CODEKATA
/pgm/sumofdigits.py
84
3.546875
4
a=int(input()) sum=0 while a>0: r=a%10 sum=sum+r a=a//10 print(sum)
2de31586b0e3fccfeeec2d4927eab50206c0deb1
affaau/myexamples
/regex_example/clean_file.py
743
3.828125
4
'''Remove all non-alphanumberic character(s) in file name - replace with underscore '_' ''' import re import os def clean_filename(name): '''Replace non-alphanumberic character(s) with an underscore "_" ''' return re.sub(r'[\-\.,_ ]+', '_', name) def check_cleaned_filenames(ls): '''Pass in list of file names - p...
0796539c4bfc0d5fcb403f01cbfeabd1cf0b6e92
0x0all/coding-challenge-practices
/python-good-questions/frequency_str.py
2,161
4.125
4
import string import collections input_text = """In bed we concocted our plans for the morrow. But to my surprise and no small concern, Queequeg now gave me to understand, that he had been diligently consulting Yojo, the name of his black little god, and Yojo had told him two or three times over, and strongly insisted...
a84fa1de2dd0718e341dd832b8016ba401833f3d
aksenof/infotecs
/algorithm.py
513
3.953125
4
def factorization(n): # функция для разложения числа на простые множители r = n i = 2 result_list = [] while i*i <= n: while n % i == 0: result_list.append(int(i)) n = n/i i = i+1 if n > 1: result_list.append(int(n)) # print(result_list) if len(result_list) == 1: result = "{} = 1 * {}...
4aa712c5ba2fc9e8431ee181c850df1078fa8078
bensenberner/ctci
/dynamic_recursive/minCoins.py
479
3.71875
4
def minCoins(coinArr, n): # trying to make n cents using the coin denominations in coinArr table = [float('inf') for x in range(n+1)] table[0] = 0 for i in range(len(table)): for coin in coinArr: if coin <= i: if table[i-coin] != float('inf') and table[i-coin]+1 < tab...
999fe101ac3ab6c15bea9e1233dbf31e990cb060
maturivinay/python_lee
/ICP_5/linear_expression.py
1,038
3.9375
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt print(pd._version) # x = np.array([0,1,2,3,4,5,6,7,8,9]) # y = np.array([1,3,2,5,7,8,8,9,10,12]) dataframe = pd.read_excel('C:\\Users\matur\Desktop\\UMKC\python_lee\ICP_5\SimpleLinear Regression.xls') # print(dataframe.head[14]) x=dataframe.X y...
bd50d87e7693f9ccdd461849b2875df146ba02e3
mohrtw/algorithms
/algorithms/tests/test_graph.py
2,880
3.78125
4
import unittest from unittest import TestCase # from unittest import skip from algorithms.dataStructures.graph import graph class graphTest(TestCase): def setUp(self): arcList = [[1, 2], [1, 3], [1, 4], [2, 1], [3, 2], [3, 5], [5, 1]] self...
9bb4900d5f2fc16065e75343f70741f8631b5360
HectorGarciaPY/primer1.py
/IA9.3.py
281
3.796875
4
def comptarLletra(adn,lletra): cops=0 for i in adn: if i==lletra: cops=cops+1 return cops adn=["A","A","A","G","A","A","A","G","T","C","T","G","A","C","T","C","T","G","A","C"] lletra = input("Entra la lletra que vols comptar: ").upper() print(comptarLletra(adn,lletra))
2485e2980db6bb4b693b11459c76c67b33c18af1
ftorob/MisionTICS120210639-G09
/Ciclo 1/S120210503.py
4,881
4
4
# Declaramos la variable de tipo ENTERO var_int = 50 # Declaramos la variable de tipo FLOAT | DOBLE | Flotante o número decimal var_pi = 3.1416 # Declaramos la variable de tipo CADENA DE TEXTO | STRING var_str = "Grupo 39" # Declaramos a variable de tipo buleano FALSO | VERDADERO | 1 | 0 var_boo = False # corchete ...
c1ccf5bdf2a6dcb35136f858270f398d8244c0e8
ABalanuta/challenges
/bus-station/solutions/bus-station-python-solution.py
900
3.734375
4
import os import sys import sys def fit(array, bus_length): pos = 0 bucket = 0 while pos < len(array): if array[pos]+bucket == bus_length: pos += 1 bucket = 0 elif array[pos]+bucket > bus_length: return False else: bucket += array[pos] pos += 1 if bucket == 0: return True else: retu...
95462e1db82382fbd37b421a7c20083bf20edb2f
adviksinghania/cfc-assignments-pyboot
/assignment-1/q7_e.py
243
3.53125
4
#!/usr/bin/env python3 # q7_e.py # 1 # 1 1 # 1 2 1 # 1 3 3 1 # 1 4 6 4 1 n = int(input('Enter a number: ')) for i in range(1, n + 1): c = 1 for j in range(1, i + 1): print(c, end=' ') c = c * (i - j) // j print()
894644a0e14cd3d95b3b2480bb2452cd8a3c362f
deepakmarathe/whirlwindtourofpython
/controlflow/for.py
316
4.25
4
# Control flow statements : for loop for i in [1, 2, 3]: print i print "---------done-----------" # range is a sequence/iterator for i in range(10): print i print "------ done -----" for i in range(5, 10): print i print "------ done ------" for i in range(5, 15, 2): print i print "------ done -------"
6e883828ed5f7900b04dfd3d521f3139b30f3a03
xiaohaiz1/PythonStudy
/Python编程思想/4.控制结构/控制流/while语句.py
617
3.625
4
''' while语句: 格式: while 表达式: 语句 逻辑:当程序执行到while语句时,首先计算“表达式”的值, 如果“表达式”的值为假,那么结束整个while语句, 如果表达式的值为真,则执行语句,再执行表达式,并判断真假,同理往上 直到为假跳出循环 ''' ''' 计算1+2+3+...+100 ''' sum = 0 num = 1 while num<=100: sum += num num +=1 print("sum =", sum) ''' 逐个打印字符串中的字符 ''' str = "lxr is a good man" index = 0 while index < ...
c9e2dcbe9ecbc147bcf16c057241384c2d093a10
sandymnascimento/Curso-de-Python
/Aula 15/ex070.py
714
3.546875
4
soma = contP = cont = p = 0 mbarato = '' while True: print('\033[1m=' * 25) print(' ' * 8, 'PY STORE') print('\033[1m=\033[m' * 25) nome = str(input('Digite o nome do produto: ')) preco = float(input('Digite o preço do produto: ')) while res not in 'sn': res = input('Deseja comprar outro...
36edf3841eb0b09cbb67c9041f8b18d4e4cdd381
bphillab/Five_Thirty_Eight_Riddler
/Riddler_20_02_21/Riddler_Express_20_02_21.py
1,106
4.125
4
""" From Nick Harper comes a question of tempered temperatures: On a warm, sunny day, Nick glanced at a thermometer, and noticed something quite interesting. When he toggled between the Fahrenheit and Celsius scales, the digits of the temperature — when rounded to the nearest degree — had switched. For example, this w...
7ad2fe4066ba0fc0c3dfa03d182dcf73d043e0c6
deesaw/PythonD-06
/Object Oriented Programming/classes1.py
1,425
3.953125
4
class Employee(object): company="Synechron" def __init__(self,eid,name,mobile): # constructor self.eid=eid self.name=name self.mobile=mobile def getmobile(self): print self.mobile def setmobile(self,mobile): self.mobile=mobile ramesh=Employee('223','Ramesh Sannareddy','9885970033') print type(ramesh) ram...
b96d8a11194a0d67febbd8bb256d288be2eb9a72
yaoshunqing/Python-fluent
/5/function.py
497
3.796875
4
# encoding= utf-8 # @Time : 2020/5/14 18:55 # @Author : Yao # @File : function.py # @Software: PyCharm def factorial(n): return 1 if n < 2 else n * factorial(n - 1) print(type(factorial)) def reverse(word): return word[::-1] print(reverse('Hello')) print(list(map(factorial, range(6)))) print(list(map(f...
af7835a8e563627d173153e9a3e0fb9bdde6768b
digipodium/string-and-string-functions-StutiLall12
/q23.py
185
4.3125
4
#ask user to enter a string and check if the string contains fyi str=input("enter a string") if str.__contains__('fyi'): print("fyi present") else: print("fyi not present")
6a032782f56d0390d8f0ce11044c867cc8637f15
snail15/AlgorithmPractice
/LeetCode/Python/countPrimes.py
476
3.5625
4
class Solution(object): def countPrimes(self, n): """ :type n: int :rtype: int """ prime = [True for x in range(n)] primeCount = 0 for i in range(2, n): if prime[i] == True: primeCount += 1 current = i ...
38fc6d3695fbc09120dcb064e7bae234d8536f8b
derekjhunt/pygame_example_for_darren
/game.py
1,623
3.625
4
#!python # Let's import libraries import pygame from pygame.locals import * #import cars #import weapons #import land # Let's startthe game engine pygame.init() width, height = 900, 507 player_position = [220,180] keys = [False, False, False, False] # initalize the screen screen=pygame.display.set_mode((width, height...
db5a403100b82ecce2cbc2f057dfe88bacfe2103
dineshbalachandran/mypython
/src/study/iterators.py
1,355
3.984375
4
''' Created on 20Jul.,2017 @author: DINESHKB ''' class Node(object): def __init__(self, value, left, right): self._value = value self._left = left self._right = right @property def value(self): return self._value @property def left(sel...
8cfee98c50a7548f5bb639028dd4677dc6959393
LegionAnkit/Gist_Of_Python
/Basics(conditional,iteration etc.)/LengthConverter1.py
203
4.15625
4
print("Enter the length in metre") metre=input() kms=float(metre)/1000 miles=kms/1.609 roundkms=round(kms,2) roundmiles=round(miles,2) print(f"{metre}m is equal to {roundkms}km and {roundmiles}mi")
0a6b8d0f2c4417082e3f307896a4093827ecfaf2
nikitabisht/AA6
/assign6.py
1,043
3.890625
4
#question1 for i in range(10): a=int(input("enter the values:")) print(i) #end #question2 while(True): print("nikita") #end #question3 l=[] a=int(input("enter the input")) b=int(input("enter the input")) l.append(a) l.append(b) for i in l: print(i**2) #question4 l=(([1,2],("string"),[1.2,1.3])...
b9c9195c039b8ccb1ec17cf6215e5cd87f9105b7
gitzym/practice_code
/nowcoder_offer/29-minknum.py
1,887
3.640625
4
class Solution: def GetLeastNumbers_Solution(self, tinput, k): # write code here if len(tinput) < k: return [] tinput.sort() return tinput[:k] class Solution_heap: def GetLeastNumbers_Solution(self, tinput, k): # write code here if len(tinput) < k: ...
96f5857a2f9b326cc07402e06668da4ba3721306
Aasthaengg/IBMdataset
/Python_codes/p03289/s759699659.py
144
3.8125
4
S = input() if S[0] == 'A' and S.count('C', 2, -1) == 1 and S.replace('A', '').replace('C', '').islower(): print('AC') else: print('WA')
f54b3c57ce611577318e3aaa547613485cfc1047
cyrilvincent/pollen
/18-2-xor.py
342
3.6875
4
import numpy as np X=np.array([[0,0],[0,1],[1,0],[1,1]],dtype=float) y=np.array([0,1,1,0],dtype=float) from sklearn.neural_network import MLPClassifier mlp = MLPClassifier(hidden_layer_sizes=(3,3,3), activation="tanh", learning_rate="adaptive", alpha=1e-5) mlp.fit(X,y) print(mlp.score(X, y)) predictions = mlp.predict...
65b066eb78832b754c47d319faa7522a7875c976
HidoCan/Programlama_dilleri_yaz_okulu
/2018/b2018.py
353
3.78125
4
a = int(input("Mevcut Sicaklik : ")) while True: b = int(input("Tahmin Degeri 1: ")) c = int(input("Tahmin Degeri 2 : ")) if b >= c: continue else: min = a + b max = a + c print("Sicakligin alabilecegi min deger : ",min) print("Sicakligin alabilecegi m...
3b98123c0fd6003ce099fb3d6471bf47830d79e8
sanjayait/core-python
/04-Chapter 4/funtion_in_func.py
159
3.578125
4
def greater(a,b): if a>b: return a return b def greatest(a,b,c): return greater(greater(a,b),c) print(greatest(106,105,25))
547bb53fbbe4d68c2ab59cf07cfe728e4b95921b
ekurpie/ekurpie.github.io
/Hashing and Nth Largest/tenthOrder.py
1,384
3.859375
4
import math import statistics import random def tenthOrder(A, ith = 10): """ This function returns the tenth order statistic from a list. It was created with the idea that a linear time median function could be used instead of the statistics.median as statistics.median creates substantial problems. :pa...
f63674cef603fd6f462791733ed1566100dc0f56
cnlong/everyday_python
/19_chat-room/asyncio/test2.py
1,518
3.921875
4
""" 阻塞和await 1.使用async可以定义协程对象,使用await可以针对耗时的操作进行挂起,就像生成器里的yield一样,函数让出控制权。协程遇到await,事件循环将会挂起该协程,执行别的协程,直到其他的协程也挂起或者执行完毕,再进行下一个协程的执行 2.耗时的操作一般是一些IO操作,例如网络请求,文件读取等。我们使用asyncio.sleep函数来模拟IO操作。协程的目的也是让这些IO操作异步化。 3.遇到sleep,模拟阻塞或者耗时动作,让出控制权。即当遇到阻塞调用的函数时候,使用await方法将协程的控制权让出,以便loop调用其他的协程 """ import time import asyncio # 定义...
7ae8e249de284b7f828fc4711fe379649920e003
deepubansal/books-python-wrappers
/books/model/InvoiceCreditedList.py
673
3.53125
4
#$Id$# class InvoiceCreditedList: """This class is used to create object for invoice credited list.""" def __init__(self): """Initialize parameters for invoice credited list object.""" self.invoices_credited = [] def set_invoices_credited(self, invoice_credited): """Set invoi...
9fa85870b0fe4835f01c668eef7be4acef15ece2
dhsong95/programmers-algorithm-challenges
/2019 카카오 개발자 겨울 인턴십/징검다리 건너기.py
584
3.671875
4
def possible_to_cross(stones, k, n): jump = 0 for stone in stones: if stone < n: jump += 1 else: jump = 0 if jump >= k: return False return True def solution(stones, k): left = min(stones) right = max(stones) while left < right: ...
390e32caea8271bfef1394f1a9242332371ff4e7
m04kA/my_work_sckool
/pycharm/Для школы/tkinter/Snacke.py
7,011
3.5
4
from tkinter import * from random import randint import time row = int(input('Введите кол. строк: ')) col = int(input('Введите кол. колонок: ')) tk = Tk() tk.title('Game') canvas = Canvas(tk, width=600, height=600) canvas.pack() tk.wm_attributes('-topmost', 1) Snake = [[8, 4], [7, 4], [6, 4], [5, 4], [4, 4], [3, 4]] ...
81942a30e602c2b06f25bb851e6e9c4829dced09
MangeshSodnar123/python-practice-programs
/calculator.py
397
4.15625
4
import math num1 = int(input("enter first number \n")) num2 = int(input("enter second number \n")) operation = input("choose +, -, *, / \n") try: if "+" in operation: print(num1+num2) elif "-" in operation: print(num1-num2) elif "*" in operation: print(num1*num2) elif "/" in ope...
75815a363f4bf46fac741fbdc622579622caa8c8
rohinrohin/python-lecture
/Day 1/Lecture/12_classify.py
325
3.96875
4
all = input("enter 3 sides of a triangle separated by space : ") #print(all.split()) (a, b, c) = all.split() a = int(a); b = int(b); c = int(c) equi = a == b == c iso = (a == b || b == c || c == a) and not equi scalene = not equi and not iso if equi : print ('equi') if iso : print('iso') if scalene: print('scalene'...
9e987bb0fb94b5b850eba909cd4a749cffc91e02
michael-ritter/assignments-ma4502-S2019
/tsplib95/tsplib95/matrix.py
4,489
4.28125
4
# -*- coding: utf-8 -*- from . import utils class Matrix: """A square matrix created from a list of numbers. Elements are accessible using matrix notation. Negative indexing is not allowed. :param list numbers: the elements of the matrix :param int size: the width (also height) of the matrix ...
042a1049ded83b8ca2d6955ff365d76ebc525f8a
sowmenappd/ds_algo_practice
/arrays_strings/rearrange_array.py
728
4.15625
4
print("Array rearrange such that arr[i] = i\n"); def rearrange(array): for i in range(len(array)): elem = array[i] if elem == -1: continue else: if elem == i: continue else: diffElem = array[elem] # array[...
5aa42d7de882d624cf63cf7f82d343c79bf5a472
Big-Belphegor/python-stu
/Day04/Homework.py
7,320
3.75
4
__author__ = "Alien" class School(object): # 学校级别 def __init__(self,addr,course): self.addr = addr self.course = course self.students_Shanghai = [] self.students_Beijing = [] self.teachers_Shanghai = [] self.teachers_Beijing = [] def hire(self,obj_teacher): ...
9cf05d67336075d7806c3ca5284390168c5e478f
tbremm/Hacker_Rank_Python
/minimum_swaps__2.py
1,614
3.71875
4
# https://www.hackerrank.com/challenges/minimum-swaps-2/problem?h_l=interview&h_r=next-challenge&h_v=zen&isFullScreen=true&playlist_slugs%5B%5D%5B%5D%5B%5D%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D%5B%5D%5B%5D%5B%5D=arrays&h_r=next-challenge&h_v=zen def minimumSwaps(arr): swaps = 0 arr = [x - 1 fo...
092a14a8089bf6f0e87c08651954ea723ecf26c6
EibboR-dev/AppDev-tRepository
/Personal-Info.py
361
3.859375
4
firstName = str( input("Input Your First Name: ")) lastName = str( input("Input Your Last Name: ")) strLocation = str( input ("Input Your Location: ")) intAge = int ( input("Input Your Age: ")) varSpace = " " print("You are " + firstName + varSpace + lastName + varSpace + ". You are from " + strLocation + ". Y...
6a06efd4bc02089a3af52821bfa3ad049a994ddc
Nilesh-Devda/PythonCode
/Operators.py
139
4
4
a = 10 b = 5 if a > b: print("Correct") else: print("Incorrect") if a % 2 == 0: print("Even") else: print("Odd") print("Done")
f01229864b82be4df35567c0086ac45e9deee806
ganhan999/ForLeetcode
/中等61. 旋转链表.py
2,039
3.796875
4
""" 给定一个链表,旋转链表,将链表每个节点向右移动k个位置,其中k是非负数。 示例1: 输入: 1->2->3->4->5->NULL, k = 2 输出: 4->5->1->2->3->NULL 解释: 向右旋转 1 步: 5->1->2->3->4->NULL 向右旋转 2 步: 4->5->1->2->3->NULL 示例2: 输入: 0->1->2->NULL, k = 4 输出: 2->0->1->NULL 解释: 向右旋转 1 步: 2->0->1->NULL 向右旋转 2 步: 1->2->0->NULL 向右旋转 3 步:0->1->2->NULL 向右旋转 4 步:2->0->1->NULL """ ...
f1dd731b7ffff1026d2396d54b162bba7866a7d7
wonntann/skulpt
/test/run/t519.py
829
3.9375
4
l = ['h','e','l','l','o'] print l.index('l') print l.index('l', 2) print l.index('l', 3) print l.index('l', 2, 3) print l.index('l', 3, 4) print l.index('l', 2, -1) print l.index('l', 2, -2) print l.index('l', 3, -1) try: print l.index('l', 4) except ValueError as e: print repr(e) try: print l.index('l',...
e22f9bdf28b108dba31547473b7e91daa4be9809
devinupreti/coding-problems
/longestSubstringDistinct.py
1,058
3.71875
4
# PROBLEM : Given an integer k and a string s, # find the length of the longest substring # that contains at most k distinct characters. # For example, given s = "abcba" and k = 2, the longest substring # with k distinct characters is "bcb". # Leetcode - Question 340 | DCP - #13 # Brute Force - O...
88878af75245f8251638c5d4015c4a74905aa2fc
eetuhietanen/KOODIT
/GUI.py
15,587
4.46875
4
# TIE-02100 Johdatus ohjelmointiin # Ilari Hildén, ilari.hilden@tuni.fi, opiskelijanumero: 282680 # Eetu Hietanen, eetu.hietanen@tuni.fi, opiskelijanumero: 284956 # GUI_ristinolla # TicTacToe with a graphical user interface. from tkinter import * NUMBER_OF_PLAYERS = 2 INFOTEXT = "This is TicTacToe. The rules...
cfd395d54bbb977b0cd7eb0a2dbfe6c4ffb47ae0
shuaaa/Markovs
/LinkedList.py
1,810
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Oct 9 07:56:00 2020 @author: olamijojo """ # prints out the namespace dictionary called locals print(locals()) # prints memory location of the stored varibles d & j d = 'Dave' j = d # j = d implies we just copy d's reference over to j's namespace e...
c70b83e5fadac95d54ad67811b337b65b8924e15
yvlian/algorithm
/python/设计模式/单例模式.py
3,853
3.859375
4
#装饰器实现 def Singleton(cls): _instance = {} def _singleton(*args, **kargs): if cls not in _instance: _instance[cls] = cls(*args, **kargs) return _instance[cls] return _singleton @Singleton class A(object): a = 1 def __init__(self, x=0): self.x = x a1 = A(2) a2...
c5444ab476405a8c06a722979cf61c97388d2489
gridl/Mcr_CodeFirst_Python
/session4/styled_app/styled_app.py
1,424
3.640625
4
from flask import Flask, render_template, request app = Flask("StyledDemoApp") @app.route("/") def say_hello(): """Example showing how to return an HTML template with a form, which sends data back to this Flask app using a POST request.""" return render_template("index.html", title="Home page") @app.ro...
82d087f35cd12a8eaf67408e783511d43e1203d7
ckallum/Daily-Coding-Problem
/solutions/#101.py
872
3.90625
4
from cmath import inf def is_prime(i, j): i_count = 0 for x in range(1, i // 2): if i % x == 0: i_count += 1 if i_count > 1: return False j_count = 0 for x in range(1, j // 2): if j % x == 0: j_count += 1 if j_count > 1: ...
6bc0b2f921168afcd520543538d8f6037f0e136a
cdave1/experiments
/python/genprime.py
384
3.75
4
def genPrimes(n): primes = [2] for i in range(3,n,2): addprime = 1 for prime in primes: if (i % prime == 0): addprime = 0 break if addprime == 1: primes.append(i) for i in primes: print i genPrimes(100) genPrimes(1000)...
f20a1077a543af9579d9380c12df9985c07b3cc7
ravisrhyme/CTCI
/sorting_algorithms/insertion_sort.py
1,158
4.375
4
""" Implementation of insertion sort Time Complexity : O(n^2) Space Complexity : O(1) """ __author__ = "Ravi Kiran Chadalawada" __email__ = "rchadala@usc.edu" __credits__ = ["Algorithm Design Manual","mycodeschool channel"] __status__ = "Prototype" def insertion_sort(element_list): """ Sorts by using insertion...
87bbf52f05f0ef4f6c8d0679e97b9986c84b1ef4
alefnula/tea
/tea/dsa/singleton.py
2,639
4.09375
4
import threading class SingletonMetaclass(type): """Singleton Metaclass. This metaclass is used for creating singletons. It changes the class __new__ method to maintain only one instance of the class, and tweaks the __init__ method to be executed only once (when the first instance of the class is...
fbe24d1dee0bb04113e7589f338c0349c0c4c34a
shaguntyagi28/Game-
/project1.py
12,674
4.1875
4
print("\n\n\nWelcome to the most interesting quiz, The ShinChan Quiz\n") #questions with their respective options, choosing the correct option will lead you to another question. print(''' Q1 - what is the full name of shinchan? a - suzuki Nohara b - Shin Chan Nohara c - Shinnosuke Nohara ''') answer = input().l...
a64d96aead9f592b6165302b22889ca9e99aaee6
altonelli/interview-cake
/problems/python/reverse_string_inplace.py
493
4.125
4
# If not allowed to use the swap, use a temp variable def reverse_string_inplace(string): string_list = list(string) for idx in range(len(string_list) / 2): print(string_list[idx]) string_list[idx], string_list[len(string_list) - 1 - idx] = string_list[len(string_list) - 1 - idx], string_list[...
0f60ef56cec0ff15c0b95d2df0af2a739e58f17d
Jeroen263/AdvancedSim_A2
/Customer.py
316
3.53125
4
class Customer: def __init__(self, arr, arrq, queue, arrqueue): self.arrivalTime = arr self.queueJoinTime = arrq self.queue = queue self.arrivalQueue = arrqueue def __str__(self): return "Customer arrived at " + str(self.arrivalTime) + " at queue " + str(self.queue)
2d44aa6b1dddb37df079a59ba5bf5fff7017b31c
hsadler/zentype2
/app/server/service/keyboard.py
9,045
3.84375
4
# Keyboard Service from service.language import Language class Keyboard(): """ Keyboard Service. Provides a keyboard model and methods based on key layout and language configurations. """ # fingers LEFT_PINKY = 'LP' LEFT_RING = 'LR' LEFT_MIDDLE = 'LM' LEFT_INDEX = 'LI' LEFT_THUMB = 'LT' THUMB = 'T'...
78e5d17062d97389de59285b909a7ecf86a7d553
westgate458/LeetCode
/P0442.py
1,148
3.6875
4
# -*- coding: utf-8 -*- """ Created on Sun Feb 9 21:19:49 2020 @author: Tianqi Guo """ class Solution(object): def findDuplicates(self, nums): """ :type nums: List[int] :rtype: List[int] """ # Solution 1 beats 99.83%: mark all visited with extra space visited = [0]...
90a042b1f1aabb64821ea5f385564e0a76a67a18
Aasthaengg/IBMdataset
/Python_codes/p02624/s003755111.py
77
3.5
4
N=int(input());a=0 for i in range(1,N + 1):b=N//i;a+=(b*(b+1)*i//2) print(a)
9ee48eb065112f15deade4bd8ae46c6c19bedc01
ce-sabo/python_trainning2
/make_datecolumns_and_split.py
588
3.765625
4
#必要なライブラリのimport import pickle import pandas as pd import datetime #CSVファイルを読み込みDataFrameにする df = pd.read_csv(rf"C:\Users\satoryo\Desktop\date_2020.csv", encoding="utf-8") #DateFrameのobjectの列からdatetime型の列を作成して追加する df["datetime"] = pd.to_datetime(df["date"]) #dateの列から年:Year、月:Month、日:Dayそれぞれの列を作成 df["Year"] = df["dat...
a7692e246e0e9f6f36ff7fd9101d60b12458e2c0
everbird/leetcode-py
/2015/DeleteNodeInALinkedList_v0.py
855
4
4
#!/usr/bin/env python # encoding: utf-8 # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None def printl(root): if root: print root.val, printl(root.next) else: print class Solution: # @param {ListNode} nod...
a21e4aa2d0d2dfb008fba16eeec717bc156916e2
jizhi/jizhipy
/Math/DecomInt.py
398
3.578125
4
def DecomInt( cls, n ) : ''' n = int1 x int2 find int1 and int2 return: [int1, int2], .shape=(2, N) ''' import numpy as np n = int(round(n)) sign = 1 if(n>=0)else -1 if (n in [-1, 0, 1]) : return np.array([[1], [n]]) n = abs(n) a = np.arange(1, n) b = n / a m = a * b c = n - m a, b = a[c==0], b[...
9a5f6c18e3c6385b1cd3ee0259ff2286bc3884a7
Dymon-Klyn/Sanitation-App
/main.py
2,845
3.671875
4
# Tool to reenter society after COVID-19 # Make a GUI # Make a nice GUI a very nice GUI # We need a JSON File to keep track of the lists import json import tkinter as tk from tkinter import simpledialog # Look of the GUI """ | Welcome Back | ------------------------- | upcoming .... | | events c...
ab9705ac4f29e3782187d551d12479ac9ab0c133
Satriyahgpj27/SATRIYA-HENDRALOKA
/praktikum 5/praktikum 1/praktikum 05 no 1 dan 2.py
980
3.765625
4
#import library import time import math #scoring nilaiBahasaIndonesia = int(input("masukkan nilai bahasa indonesia anda disini")) time.sleep(1) if(nilaiBahasaIndonesia>0) and (nilaiBahasaIndonesia<100): if(nilaiBahasaIndonesia < 60): print("anda tidak lulus") elif(nilaiBahasaIndonesia >= 60): ...
b44210e974c01df066929568ecca6871b38e8c31
Habibur-Rahman0927/1_months_Python_Crouse
/Python All Day Work/04-05-2021 Days Work/Task_3_Directory_.py
702
3.75
4
import os # dir_1 = os.getcwd() # print('directory : ',dir_1) # dir_2 = os.getcwdb() # print(dir_2) # current Directory directory = os.getcwd() print("current Dir : ", directory) # # changing dircetory # os.chdir('E:\\Computer all Subject Study\\Python\\Python Crouse') # print('Current dir after change : ', os....
6d47164a532d256b475ffdcb96839375d88c11b4
thecodevillageorg/intro-to-python
/Python Day 9/exercise3.py
895
4.03125
4
subject1 = int(input("Enter the marks for the first subject: ")) subject2 = int(input("Enter the marks for the second subject: ")) subject3 = int(input("Enter the marks for the third subject: ")) subject4 = int(input("Enter the marks for the fourth subject: ")) # def function_name(parameters or arguments): """ sand...
00f4d068468d3f0609a4e352d481416db981fa91
jspahn/Python-Code
/Project-Euler/Finished Problems 1-25/21-AmicableNumbers.py
1,942
3.640625
4
# Project Euler # Problem 21: Amicable numbers # Let d(n) be defined as the sum of proper divisors of n # (numbers less that n which divide evenly into n). # If d(a) = b and d(b) = a, where a != b, then a and b # are an amicable pair and each of a and b are called amicable # ...
5b7e89b5355c631d4472b9647a2fd70c5847161a
rmwillow/WorkoutDatabase
/database.py
9,315
4.0625
4
# from .exercisesApi import exerciseList import sqlite3 from exercisesApi import exerciseApiResults import SqlQueries import os """ Class — A blueprint created by a programmer for an object. This defines a set of attributes that will characterize any object that is instantiated from this class. An object is created...
0bdcb681b9c0f22b858525391b3224c946a16bd8
fredy-glz/Ejercicios-de-Programacion-con-Python---Aprende-con-Alf
/02_Condicionales/04_CondicionalesPython.py
341
3.96875
4
# JOSE ALFREDO ROMERO GONZALEZ # 12/10/2020 num = int(input("Ingrese un numero: \n")) if(num % 2 == 0): print("Es par.") else: print("Es impar") # SOLUCION DE https://aprendeconalf.es/ n = int(input("Introduce un número entero: ")) if n % 2 == 0: print("El número " + str(n) + " es par") else: pri...
fa3404e643730448011f1f4aa261431f8d2360c4
chdlkl/python
/function/func1.py
8,231
4.25
4
# 函数规则: # 函数代码块以def关键词开头,后接函数标识符名称(函数名)和圆括号() # 任何传入参数和自变量必须放在圆括号中间 # 函数内容以冒号起始,并且缩进 # return [表达式]结束函数。不代表达式的return相当于返回none # python1 def hello(): print ( " hello, world! " ) hello ( ) # 自定义函数用于输出信息 # python2 import math def area( r ): s = math.pi * r * r return s print ( " area = ", area(1.0) ) def print_...
8da058b66d21f7c037e5a6d451ecbf9f6296a60b
manali027/Vocab_Building_App
/check.py
393
3.671875
4
'''file=open("data.txt",mode='r') with open("data.txt",mode='r') as file: for line in file: print(line)''' '''import linecache line_number=3 line=linecache.getline("data.txt",line_number) print(f"line number is {line_number} and the line is: {line}")''' with open("data.txt",mode='r') as file: f=file.r...
7fd6ee9b4abac69f33322ca2014abc2f4973f026
sivaneshl/python_data_analysis
/applied_machine_learning/supervised_machine_learning/ridge_regression_regularization.py
1,094
3.875
4
# Ridge regression with regularization parameter: alpha import numpy as np from applied_machine_learning.fundamentals_of_machine_learning.adspy_shared_utilities import load_crime_dataset from sklearn.preprocessing import MinMaxScaler from sklearn.linear_model import Ridge from sklearn.model_selection import train_test...
f133019735fca2370628d2196bfaee4b018224ad
syn7hgg/ejercicios-python
/11_5/3.py
513
3.71875
4
def es_primo(num): if num > 1: for i in range(2, int(num / 2) + 1): if (num % i) == 0: return False else: return True else: return False while True: try: num = int(input("Ingrese número (0 para salir): ")) if num == 0: ...
4f387941ce630f1da2ccc653f9d8a1783fa7f5bf
hobbitsyfeet/PDR
/Stopwords/create_csv.py
1,035
3.625
4
import sys import csv import os # print 'Number of arguments:', len(sys.argv), 'arguments.' # print 'Argument List:', str(sys.argv) word_file = sys.argv[1] new_file = sys.argv[2] #populates file [argv 2] with a list of words from [argv 1] def populate_file(file): with open(file, 'w') as csv_file: writer =...
84b3ff61e0be43222eca0548af7dacd58d8620f2
szymon5816/test_name
/demo.py
1,055
3.859375
4
import unittest class TestDemo(unittest.TestCase): @classmethod def setUpClass(cls): print("#" * 30) print("Przed testem") print("#"*30) def setUp(self): print("Wykonanae przed każdym testem") def test_A(self): print("test A") def test_B(self): ...
1548be67abd038234f2af95e9aa96f0a27c9b2c7
dabinc/MoreLoopsWithinLoops
/src/m2_more_nested_loops_in_graphics.py
2,600
4.5
4
""" This project demonstrates NESTED LOOPS (i.e., loops within loops) in the context of TWO-DIMENSIONAL GRAPHICS. Authors: David Mutchler, Valerie Galluzzi, Mark Hays, Amanda Stouder, their colleagues and Dabin Choi """ # T ODO: 1. PUT YOUR NAME IN THE ABOVE LINE. import rosegraphics as rg def main(): ...
f737817e550f2fdd593f511ab4485088700a420b
SuSFCTV/RaifhackDS
/feature_extractors/floor.py
3,244
3.5
4
from statistics import mean from typing import Optional import pandas as pd import numpy as np def floor_preprocess(df: pd.DataFrame) -> pd.DataFrame: preprocess_floor = df['floor'].apply(parse_floor) floor = 1.93 preprocess_floor = preprocess_floor.apply(lambda x: floor if pd.isna(x) else x) return p...
d2dce500f9e3ec8c0347d43461a99a9439cd972d
MarinaFirefly/Python_homeworks
/5/at_lesson/square.py
975
4.125
4
#find squres of the simple numbers using map list_numers = [1,2,3,45,6,8,9,12,8,8,17,29,90,77,113] #function that calculates squares def sqrt_num(num): return num**2 #function that return new list consisting of simple numbers def dividers(list_num): new_list = [] for num in list_num: i = 2 cnt = 1 if num == 1 e...
85999b8cd57ff165560c5174a03539a34f6fcc0b
aultimus/project_euler
/14_longest_collatz_seq.py
1,176
3.859375
4
# http://projecteuler.net/problem=14 # The following iterative sequence is defined for the set of positive integers: # # n -> n/2 (n is even) # n -> 3n + 1 (n is odd) # # Using the rule above and starting with 13, we generate the following sequence: # 13 -> 40 -> 20 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1 # # It can be se...
9fbc247356aee27bc9a05249975047cd48db259a
zaimeali/Data-Structure-and-Algorithms
/Coding Interview/Google/problem3.py
1,324
3.8125
4
# Google Video https://www.youtube.com/watch?v=XKu_SEDAykw # [1, 2, 3, 9] no pair equal to 8 # [1, 2, 4, 4] => 4, 4 = 8 def solution1(arr, result): # Complexity: O(n) because it is linear # arr.sort() # if sorting then complexity will be O(N*logN) low = 0 high = len(arr) - 1 while low < high: ...
5616ce6d5141b2379c4baa5a20fdb362039065e4
sandeepkp07/updates
/nov6-7/18.2.py
996
3.828125
4
import random class Cards(object): suit_names = ["Clubs", "Diamonds", "Hearts", "Spades"] rank_names = [None, "Ace", "2", "3", "4", "5", "6", "7","8", "9", "10", "Jack", "Queen", "King"] def __init__(self,suit=0,rank=2): self.suit = suit self.rank = rank def __str__(self): return ('%s of %s' % (Cards.ra...
1e7a98a75bbc1b0815f1db9f54589e2f70007c18
brentholmes317/Fire_Department
/fire_department/fire_department/fire_department.py
3,254
4.09375
4
from sys import exit import math """ The idea behind the fire_department function is to answer the following: If a town wishes to place a fire department so that the time for the firetrucks to get to any location in the town is minimized, where should they put the fire station? I wish to add to this problem that unocc...
f7c7c14716bd01e4d91f2ac87c628f72def1e824
lkuszal/licencjat
/caesar.py
2,737
4.03125
4
"""simple monoalphabetic rotation cipher with integer as key, and optional reference alphabet (by default full upperlatin) if reference alphabet is full lower/upper, ciphering will convert them both to same letter, but will keep capitalization""" # Written by Lukasz Cholodecki as part of 2021 thesis from pattern import...
1e25805145d0ac4ae4c43b245ddf9d1ee372133e
Ahamed-Sakir/NSL_AI_Training_Materials
/Python_Basic/Week1/Syntax.py
624
4.3125
4
# Basic String syntax name = "Sakir Ahamed" print(name) # We can use single quote also name1 = 'Bangladesh is my country' print(name1) # If we use single quote in a sentence then use '\' single_quote = 'This is Anannyar\'s property' print(single_quote) # User input user_input = input('Give your name:') print('This i...
d6097be507fe05e514deb7a51877dda47aa6fd13
ash/amazing_python3
/279-list-diff.py
287
3.890625
4
# Get the "difference" between the # two lists data1 = [10, 20, 30, 40, 50] data2 = [5, 10, 15, 20, 25] diff = list( set(data1).symmetric_difference( set(data2) ) ) print(diff) # only elements which are either in # the first or in the second lists, # but not in both
45a44d4554cf3c7f8d6a300c2e32324ec1d02679
MrHamdulay/csc3-capstone
/examples/data/Assignment_4/crrlen001/piglatin.py
1,797
3.953125
4
def toPigLatin(s): return (translate(s)) def findFirstVowel(given_word): '''Returns the location of the first vowel in the given word.''' for i in range(len(given_word)): if checkVowel(given_word[i]) == True: return i def translateWord(input_string): '''Translates the word and returns the translation to...
372f84a17af618f4ae1778e031134bee09e2f8b3
2082033549/FCXPYN
/homework4/xiaoli_1.py
882
3.890625
4
# 2 定义一个函数,判断一个输入的日期,是当年的第几周,周几? 将程序改写一下,能针对我们学校的校历时间进行计算(校历第1周,2月17-2月23;校历第27周,8月17-8月23;); # from datetime import datetime # import time # dt= datetime.date(2019, 5, 9) # 用指定日期时间创建datetime # a=dt.isocalender() # print(a) # import datetime # a=datetime.date(2017, 12, 31).isocalendar() # print(a) import datetime def ...
367978048089e595c36faa9cdd793a0a0f79fdba
Afsarsoft/python
/06_03_tuple.py
1,033
3.875
4
# pyright: strict from typing import List, Tuple # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # You can have tuples inside list to not be changed coordinates: List[Tuple[int, int]] = [(4, 5), (6, 7), (80, 34)] print(coordinates) print(coordinates[1]) for item in coordinates: print(item) # +++++++...
f46df9325e6e2165adf3a10cfa6b73901c2442dc
skulshreshtha/Data-Structures-and-Algorithms
/Algorithms/symmetric_tree_BT.py
613
3.796875
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 class Solution: def _isMirror(self, t1: TreeNode, t2: TreeNode) -> bool: if(t1 is None and t2 is None): ...
c360132df92aaecad287cf1757b006dd8a7e65d4
JitinKansal/My-DS-code
/linkedlist_implementation.py
2,613
4.3125
4
# To create the new node. class Node: def __init__(self, data=None): self.data = data self.next = None # To perform the operation on the linked list. class Linkedlist: def _init__(self): self.head = None # A function to print the linked list. def printlist(self...
ec0a1ca0957abd633447f9a167f0e9b103ef122e
zhangyebai/LeetCode
/Python/palindrome_number.py
1,408
4
4
#!/usr/bin/env python # _*_ coding:utf-8 _*_ """ @Author 张夜白 At LeetCode Title: Palindrome Number Determine whether an integer is a palindrome. Do this without extra space.(Note this, no extra space) Could negative integers be palindromes? (ie, -1) If you are thinking of converting the integer ...
2f071d61549ca8f7dde19610cba6f2c873325a78
pradeepreddybodha/MyPythonCodes
/LinearSearch.py
464
3.515625
4
from random import * def linear_search(nums): for j in li: globals()['pos'] += 1 if j == nums: return True break nums = int(input("Enter the number to search in the list: ")) li = [29, 53, 94, 54, 48, 52, 88, 58, 7] pos = 0 for i in range(1, 10): k = ra...
ebd25b693eb1501cb54f0a2fe3418e97b52a37ff
SimonFans/LeetCode
/String/L65_Valid Number.py
2,181
3.984375
4
Validate if a given string can be interpreted as a decimal number. Some examples: "0" => true " 0.1 " => true "abc" => false "1 a" => false "2e10" => true " -90e3 " => true " 1e" => false "e3" => false " 6e-1" => true " 99e2.5 " => false "53.5e93" => true " --6 " => false "-+3" => false "95a54e53" => false Note: It...
7d09070dc69b850da6a4a6512cd2fd3df057b776
Srinivas-Rao-au27/Accomplish_classes-
/coding-challenges/week12/day04/week12-day04-cc.py
3,821
4.09375
4
""" Q-1 ) Kth Largest Element in an Array https://leetcode.com/problems/kth-largest-element-in-an-array/ (5 marks) (Medium) Given an integer array nums and an integer k, return the kth largest element in the array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Example 1: I...
2ba01b9d6e7912ff67601acb1f17c86fbbcd0c9c
spak9/WICRPI
/CH4/sp.py
1,351
3.75
4
# From Reis's Writing Compilers 2nd Edition # Grammer: # S -> AC # A -> ab # C -> cC # C -> d import sys tokenindex = -1 token = '' def main(): try: parser() except RuntimeError as emsg: print(emsg) def advance(): global tokenindex, token tokenindex += 1 # increment index # chec...
53a1384c779d76a1c39ef8ccccf59a07db7243a1
hilings/leetcode
/python/070.py
494
3.640625
4
# 070 # Climbing Stairs # 2015-12-23 ##################################################### class Solution(object): def climbStairs(self, n): """ :type n: int :rtype: int """ if n == 0: return 0 last2, last1 = 1, 1 for i in range(2, n+1): ...
ae65996d6e1a8bdff4b39fd35ac44ad98289ab12
techgymjp/techgym_python_en
/Ef3z.py
1,419
3.890625
4
import random hands = ['rock', 'scissors', 'paper'] results = {'win': 'win', 'lose': 'lose', 'draw': 'draw try again'} def start_message(): print('Start \'rock-paper-scissors\'') def is_hand(number): if number >= 0 and number <= 2: return True else: return False def get_player(): ...
3a52c48f7761bcb9833b1c90c7f7fd3fa0659226
sky-tanaka/GitVsc
/if_sample3-6.py
299
4
4
#キーボードから数値を入力 a=int(input("a=")) if a==1: #aが1だった場合の処理 print("aは1です!") elif a==2: #aが2だった場合の処理 print("aは2です!") else: #aが1でも2でもなかった場合の処理 print("aは1,2以外の数")