blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
efbc69732c249969b406b3a7071010c998d59297
SandyHoffmann/ListasPythonAlgoritmos
/Lista 3/SH-PCRG-AER-Alg-03-Ex-05.py
1,054
4.15625
4
#Pedindo mês e fazendo com q ele sempre fique no formato minusculo. mes = input("Qual o mês? ").lower() #Checando os meses para printar o tanto de dias. if mes == "janeiro": print(f'O mês de {mes} tem 31 dias.') elif mes == "fevereiro": print(f'O mês de {mes} tem 28 ou 29 dias.') elif mes == "março": print(...
7433e710d398968cc3bbc54ba5536ebdc8ee5f95
SandyHoffmann/ListasPythonAlgoritmos
/Lista 4/SH-PCRG-AER-Alg-04-Ex-08.PY
333
3.796875
4
#pedindo variaveis msg = input("Me de sua frase: ") distancia = int(input("Me dê a distancia de deslocamento: ")) msgletras = list(msg) novafrase = "" #percorrendo lista de letras for letra in msgletras: ordem = ord(letra) novaletra = chr(ordem+distancia) novafrase+=novaletra #mostrando mensagem final prin...
4d98e253f5b9c0f8f5484082ac4e484d54cc4a0c
SandyHoffmann/ListasPythonAlgoritmos
/Lista 3/SH-PCRG-AER-Alg-03-Ex-02.py
511
3.859375
4
#Pedindo os anos do cachorro idade = int(input("Quantos anos tem o seu dog? ")) #Se idade for numero negativo n pode ser considerado. if idade<0: print(f'Dados inválidos!') #Se idade menor ou igual a dois calcularemos conforme foi dito pelo enunciado elif idade<=2: print(f'A idade do cachorro é de {idade*10.5} ...
e77df3fa282c64fc6721db45a43eaecee7bc2b82
SandyHoffmann/ListasPythonAlgoritmos
/Lista 6/SH-PCRG-AER-Alg-06-Ex-11.py
694
3.59375
4
import random def mega(): lista_num = [] for x in range(0,60): bilhete = [] for y in range(6): numero = random.randint(0,100) bilhete.append(numero) if len(lista_num)>0: contador = 0 for i in lista_num: contador = 0 ...
ee8c46f387e0e1a8aef58a961722d854137268cb
SandyHoffmann/ListasPythonAlgoritmos
/Lista 8/SH-PCRG-AER-Alg-08-Ex-01.py
278
3.953125
4
def fatorial(numero): if numero == 1: return numero else: novo_numero = numero * fatorial(numero-1) return novo_numero def main(): num = int(input("Fatorial de que numero? ")) print(fatorial(num)) if __name__ == "__main__": main()
6be57375f838fc4f6016c4b83f89c858d5704448
SandyHoffmann/ListasPythonAlgoritmos
/Lista 5/SH-PCRG-AER-Alg-05-Ex-10.py
458
3.84375
4
def isPrimo(primo): for x in range(2,primo): if primo%x== 0: return False return True def main(): numero = int(input("Qual é o número? ")) ehpri = isPrimo(numero) if numero<0: print("Digite valor válido!") elif ehpri == True: print(f'{isPrimo(numero)} : {num...
e1fee8409b276d86e50760a38560b93dce9bab00
brontosaurrus/Algorithms
/binary_search.py
372
3.921875
4
def binary_search(list, item): low, high = 0, len(list) - 1 while low <= high: mid = (low + high) // 2 if item > list[mid]: low = mid + 1 elif item < list[mid]: high = mid - 1 else: return mid raise ValueError("{} not in list".format(item))...
aad51f4a8ff3e6efba70a5a483af179daeb65a5a
avkor66/CS50
/python/credit.py
677
3.734375
4
card = '' while card.isdigit() == False or len(card) < 13 or len(card) == 14 or len(card) > 16: card = str(input("Введите номер карты: ")) ss = [] summ = [] g = 0 for i in card[-2::-2]: summ.append(int(i)*2) for s in str(summ): ss += s for f in ss: if f.isdigit(): g += int(f) for i in card[-1:...
e8b4301a7f0b130c3dfd052b72d1fd77a751b76b
award28/Diabetic_Retinopathy_Detection
/activations.py
626
3.515625
4
import math import numpy as np def relu(pixel_vals, bias=0): '''Takes tuple (r,g,b) and returns the relu transformation. For use within each individual node in a dense layer before being passed onto the next layer bias 0'ed out by default ''' return (pixel_vals * (pixel_vals > 0) + bias,) def sigm...
d48ad30cbe27665c8e550e17e739e4a195479e16
JeanTak/UTEK-project
/genetics.py
1,729
3.796875
4
import random POPULATION = 3; def select_Pair(prob_of_sur, generation): #prob_of_sur ->[0.234, 0.6543 ...] #generation ->[[1,2,3], [4,2,7]...] Sum = float(sum(prob_of_sur)) factor = 1 / Sum #these two steps is to make teh sum of probability is 1 for i in range(POPULATION): #here ...
fc59e4161c202bd663c0b46059ff43ee2a58a44e
uldash/CS50x
/week06/pset6/mario/more/mario.py
271
3.984375
4
while True: try: h = int(input("Height: ")) if h >= 1 and h <= 8: break except: continue for i in range(h): print(" " * (h - i - 1), end="") print("#" * (i + 1), end="") print(" ", end="") print("#" * (i + 1))
5cd2193a2b4ba570d4fffa5c69527043eaec1662
uldash/CS50x
/week06/lecture/examples/06_for.py
67
3.59375
4
# for i in [0, 1, 2]: for i in range(3): print("hello, world")
e2194a3e0e351d030a07543a8a3b2c8655f9f8c0
CodeCarrots/warsztaty
/na_zywo/20141029_knp.py
1,158
3.6875
4
import random keep_playing = True while keep_playing: bad_choice = True while bad_choice: player_choice = input("Podaj swój ruch: [k]amień, [n]ożyczki, [p]apier? ") if player_choice == "k": bad_choice = False elif player_choice == "n": bad_choice = False ...
a868413c6192ce0e92a15c3ca3ffc1f9a5a7c5c6
guoweikuang/leetcode-py
/python/018_four_sum.py
3,920
3.5
4
# -*- coding: utf-8 -*- """ 18. 4Sum 给定一个包含 n 个整数的数组 nums 和一个目标值 target,判断 nums 中是否存在四个元素 a,b,c 和 d , 使得 a + b + c + d 的值与 target 相等?找出所有满足条件且不重复的四元组。 注意: 答案中不可以包含重复的四元组。 示例: 给定数组 nums = [1, 0, -1, 0, -2, 2],和 target = 0。 满足要求的四元组集合为: [ [-1, 0, 0, 1], [-2, -1, 1, 2], [-2, 0, 0, 2] ] 解题思路 类似于3Sum 的解法,先确定...
6a9980954beb1a423130f6eb65c83a2a4ec8a1b7
lekakeny/Python-for-Dummies
/file_operations.py
1,762
4.46875
4
""" File operation involves 1. opening the file 2. read or write the file 3. close file Here we are learning how to read and write files. I learnt how to read and write long time ago! How could I be learning now? Anyway, kwani ni kesho? """ f = open('text.txt', 'w', encoding='utf8') # open the file called...
ed5cb135e00272635753e85b0a7d8d859dea1e0d
lekakeny/Python-for-Dummies
/generator_and_decorators.py
2,132
4.59375
5
""" Generators are functions that return a lazy iterator lazy iterators do not store their contents in memory, unlike lists generators generate elements/values when you iterate over it It is lazy because it will not calculate the element until when we want to use the element """ "Use isinstance function to check if an ...
69fc2af0f0bd5a34fdaf2f63fbebea5dd18e4efd
paulomitch/formation_python
/Exercices_deuxieme_partie/mise_en_forme.py
405
4
4
#mettre en forme une chaine de caractères chaine = "une chaine en minuscules. deuxièmemorceau" print (chaine.upper()) print (chaine.capitalize()) espace = " une chaine avec des espaces " print (espace) print (espace.strip()) titre = "introduction" print (titre.upper().center(20)) titre1 = titre.center(45) p...
e2bb2d063737bd3fd5aaa3f3b994b0d319969a36
paulomitch/formation_python
/Exercices_premiere_partie/lambda.py
120
3.5625
4
diametre = float(input("diametre = ")) f = lambda circonference: diametre * 3.14 print (diametre) print (f(diametre))
d61b858d541c4b336062fa8d53f2499ada553840
aadilkhhan/List-and-Tuples
/04_tuple.py
317
4.09375
4
# Creating a tuple using () t = (1 , 2 , 3 , 4) # t1 = () --> Empty tuple # t1 = (1) Wrong way to declare a tuple with single element t1 = (1,) #Tuple with single element print(t1) # Printing the elements of a tuple. # print(t[0]) # Cannot update the values of a tuple # t[0] = 7 --> Throws an error
8497ca0305260d8b25b902fbcc3bbca1e6bf3a45
azpoliak/ai_homework4
/decision_tree.py
14,071
4.125
4
""" Class for Decision Tree algorithm. Design for decision tree based off of the algorithm outlined in Ch 3 of "Machine Learning in Action" by Peter Harrington. """ import numpy as np import pdb import math import operator #import scipy.stats class Decision_Tree: def __init__(self, classifier_type, **kwargs): """...
8488ee8f09498521c1cc3054147370b793a35fe1
xs2tariqrasheed/python_exercises
/integer_float.py
722
4.1875
4
_ = print # NOTE: don't compare floating number with == # A better way to compare floating point numbers is to assume that two # numbers are equal if the difference between them is less than ε , where ε is a # small number. # In practice, the numbers can be compared as follows ( ε = 10 − 9 ) # if abs(a - b) < 1e-9: # ...
9f953de4f01c84f44af00d6bb351af6e47e4ff92
rahul9852-dot/Data-Structure-and-Algorithms
/DSA/discussion.py
1,346
3.5625
4
''' Q.1 for i in range(n): for j in range(n): k=k+2 O(n^2) Q.2 for i in range(n): k=k+2 O(n) Q.3 i=n while i>0: k=k+2 i=i//2 O(logn) Q.4 for i in range(n): for j in range(n): ...
2df56bec3d441cd6ff399823c748975da2b12668
rahul9852-dot/Data-Structure-and-Algorithms
/DSA/complexity.py
3,016
3.84375
4
import time from random import randrange '''def sumofn(n): start=time.time thesum=0 for i in range(1,n+1): thesum+=i end=time.time() return thesum,end-start for i in range(5): print("Sum is %d required %10.7f seconds"%sumofn(1000))''' '''import time def sumOfN2(n): ...
38735d82e2606f2683b5bf7e2479610332815b5c
denamid/bugaenko
/my_code/Lessons/Lesson_8/1.py
1,266
3.8125
4
import random random_1 = [] random_2 = [] random_3 = [] for i in range(0, 10): n = random.randint(1, 20) random_1.append(n) print(f"первая строка случайных чисел = {random_1}") for i in range(0, 10): n = random.randint(15, 25) random_2.append(n) print(f"вторая строка случайных чисел = {random_2}") random_3 = r...
13f1acd92213147bcd9b9592a53e58a650f45498
aitorperezzz/steganography-lab
/lab/encode.py
6,135
3.515625
4
import os import math import utils # Reads an image from imgFilename and a text from msgFilename and encodes # the text inside the image using Least Significant Bit Steganography. # The output image is called outputFilename. def encodeAlgorithm(imgFilename, msgFilename, outputFilename): # If the image is not JPEG o...
36a287b3ec491ddcb174cf3969a1dc478d8bc5f6
AbbasMustafa/DataStructure-Algorithm
/Day 3/nextDay.py
266
3.953125
4
# Assume Each month have 30 days def nextDay(year, month, day): if day < 30: return year, month, day + 1 else: if month == 12: return year + 1, 1, 1 else: return year, month + 1, 1 print(nextDay(2012,12,30))
469954cdb68a6729bd5bb9b81cd64f3383f26510
ramizmammadli/Music-Console-App
/Music_Project/musicProjectTrial.py
2,008
3.84375
4
from Music_Project.musicProject import * print(""" Welcome to Music Application: 1. Show all the musics 2. Add Music 3. Delete Music 4. Search Music 5. Search Singer 6. Show total Duration 7. Play music Randomly Press 'q' to quit """) library = MusicLibrary() while True: op = input("\nEnte...
a51204dc2fb8457408159250fa3ff4cc6065a142
sabiqbiqsa/magicalcalc
/main.py
1,056
3.875
4
import re <<<<<<< Updated upstream print("our magical calculator") run=True remain=0 while run: check = str(input("type your equation")) check= re.sub('[A-Za-pr-z,.?/><#@!()]','',check) if check=="q": run=False print("Thanks for using our app") else: while check!="q": ...
1f9ad58eb8a4241bfe575f2d6e644671a173c32c
Rulstar/Python-intermedio
/Segundodia.py
239
3.9375
4
#-*-coding:utf-8-*- ''' #Ejemplo 1.- Clase y objeto class Curso: #Atributos nombre="Python intermedio" duracion=5 c=Curso() print("Curso de " + c.nombre); print("La duración del curso es de " + str(c.duracion) + " días.") '''
dbfc326463e7a3b8712c8dfc6272e609cbfb570b
Rulstar/Python-intermedio
/Ejercicio5.py
1,145
3.953125
4
# -*- coding:utf-8 -*- #EJEMPLO DE HERENCIA #Creación de clase Animal class Animal(): #Abstracción de datos #Constructor def __init__(self, nombre, num_patas): self.__num_patas=num_patas #Encapsulamiento self.__nombre=nombre self.alimento=0 #Abstracción Funcional def comer(se...
e74ca516cbe4a537c86e3482c4a22de037eac10d
Qomal16019/thecodevillage
/day1/hello.py
194
3.828125
4
# this is my first python program firstname='jane' secondname='doe' middlename="smith" address="nairobi" print(firstname,secondname,middlename) print(address) a=100 b=300 sum=a+b print(sum)
bb7a67e313c47640698e9acacebb30d986e54274
tazbingor/learning-python3.5
/py-basics/chapter-03-list/py011_list_CRUD_exercise.py
3,100
3.703125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 17/10/24 上午2:22 # @Author : Aries # @Site : # @File : py011_list_CRUD_exercise.py # @Software: PyCharm # List 增删改的练习 # 3-4 嘉宾名单:如果你可以邀请任何人一起共进晚餐(无论是在世的还是故去的), # 你会邀请哪些人?请创建一个列表,其中包含至少 3 个你想邀请的人;然后, # 使用这个 列表打印消息,邀请这些人来与你共进晚餐。 banquet = ['风清扬', '岳不群', ...
61918f3c9cc14fa88d8d706dd371abc5f916cd4d
tazbingor/learning-python3.5
/py-basics/chapter-01/py001_hello_python.py
138
3.5
4
# print("python切换版本") # 变量 # num = 15 # num +=15 # print(num) # # str = "python" # print(str) print('\n') print("hello world")
fd0795023b117b544ea861bf90791ace2f1fb9f1
liucong3/DQN
/buffer.py
6,148
3.515625
4
#coding=utf-8 import numpy as np class Queue: def __init__(self, size=1): self.data = [0] * size self.size = self.head = self.tail = 0 def __len__(self): return self.size def __getindex(self, index): if index < 0: index = self.size + index assert index < self.size, 'index:%d < self.size:%d' % (index, ...
db67870022cc920a00dd7005fa13aa5825ab0262
DiegoFernandesQA/Python-Codes
/CriptografiaProject/Criptografia_Projeto.py
1,144
3.625
4
import random p = random.randrange(0, 1000) while p % 5 and p % 7 == 0: break import random q = random.randrange(0, 1000) while q % 5 and q % 7 == 0 and q != p: break chave = p * q def cifra(mensagem, chave, p, q): global listacifra scale = len(mensagem) listacifra = [] ...
bd8ca17b9c17ed209837fac5f4aae0525c1758b9
DiegoFernandesQA/Python-Codes
/Conceitos/Tipos de dados.py
2,068
4.09375
4
# -*- coding: utf-8 -*- # isso é um teste var1 = ("olá mundo") #var string var2 =(22) #var num inteiro var3 =(11.1) #var num flutuante float var4 = False #booleana falso var5 = True #booleane verdadeiro print (var1, var2, var3, var4, var5) x = 100000 y = 10000 if x > y: #o comando if é atribuição de uma c...
b38115687ced7e2148ce9b58c53f3513138d30c8
Monalisha188/python-projects
/loopanddecisionmaking.py
142
3.984375
4
#find the fibonacci series n = int(input("enter a number:")) a = 0 b = 1 for i in range(n): print(a, end=" ") temp=a a=b b=temp+b
c5eefc7b2d5292e8fde1cfbe50405aead054b724
razzaqim/Phyton-HLT
/FizzBuzz.py
233
3.96875
4
for number in range (1,101): if ((number)%5 == 0) and ((number)%3 == 0): print("FizzBuzz") elif (number)%3 == 0: print ("Fizz") elif (number)%5 == 0: print ("Buzz") else: print(number)
6af88b90a7d58c79ee0e192212d0893c168bf45e
BinYuOnCa/DS-Algo
/CH2/stevenli/HW1/pycode/NumpyDemo.py
1,454
4.25
4
import numpy as np # Generate some random data data = np.random.randn(2, 3) print("first random data: ", data) # data * 10 data = data * 10 print("Data times 10: ", data) # try np shape print("Data shape: ", data.shape) # Print data value's type print("Data types:", data.dtype) # Create a new ndarray data_forarray...
e1e8129343fd223af1e16f9cd0c6bcb42c153c19
jkredz/pyNeuralNetwork
/RBM/RBM.py
3,218
3.71875
4
import numpy as np import random class RBM: """ """ def __init__(self, num_visible, num_hidden): """ """ self.num_visible = num_visible self.num_hidden = num_hidden # Weights is a matrix representing the weights between visible units # (rows) and hidden unit (columns) ...
cc642842fce703599ebfe88428aa7f9dc4751e09
vsinha/cai
/src/vector.py
8,206
3.78125
4
import math from math import cos, sin import numpy as np # np.seterr(all="raise") def dist_sq(p0, p1): return (p1[0] - p0[0]) ** 2 + (p1[1] - p0[1]) ** 2 def dist(p0, p1): return math.sqrt(dist_sq(p0, p1)) def magnitude(vector): return np.sqrt(np.dot(np.array(vector), np.array(vector))) def norm(v...
0b86c6dfca854b23e28b2b5ef609970c04723b08
cozynye/python-study
/control_1week.py
1,666
3.71875
4
# 기본 if문 구조 ->바로 아래 문장부터 if문에 속하는 모든 문장에 들여쓰기를 해주어야 한다(다른 언어와의 차이점) # if 조건문: # 수행할 문장1 # 수행할 문장2 # ... # else: # 수행할 문장A # 수행할 문장B # ... a=int(input()) if a==1 : print('일입니다') # print('이건 안될걸') else : print('1이 아니다') # elif : 다양한 조건을 판단하는 함수이며, 조건, 개수 제한 없이 사용할수 있다. # pass : if문에 아무런...
d87d511c02dc32436b80fb54f9e88993c6b49e5f
harish-chellaboyina/Study
/PythonPrograms/threeColorSorting.py
480
3.546875
4
def nextNonTwoIndex(t): while t >= 0 and s[t] =='2': t -= 1 return t s = raw_input().strip().split() i = 0 j = nextNonTwoIndex(len(s) - 1) moving = 0 while moving <= j: if s[moving] == '2': temp = s[j] s[j] = '2' if temp == '0': s[i] = '0' i += 1 ...
b8843a479dccf090d488c18d6e98be9df1a81d13
harish-chellaboyina/Study
/PythonPrograms/sortings.py
900
3.9375
4
__author__ = 'kh1911' def bubbleSort(numbers): flag=0 for j in range(len(numbers) - 1): for i in range(len(numbers)-j-1): if numbers[i]>numbers[i+1]: temp=numbers[i] numbers[i]=numbers[i+1] numbers[i+1]=temp flag=1 if ...
7462736889e7820fa55be2663ab0002f4f3e3260
harish-chellaboyina/Study
/PythonPrograms/temp.py
2,710
3.578125
4
__author__ = 'kh1911' import time import decimal """ This function takes list of numbers as input and returns the maximum element of the list """ """" from itertools import permutations perms = [''.join(p) for p in permutations('aab')] print list(set(perms)) def findGreatest(numbers): greatest=numbers[0] fo...
ea4dd28662cd52fb13147661624fa28381cd0433
dery96/challenges
/zero_name_generator.py
909
4.21875
4
from random import randint as RANDOM ''' Generates Words it meant to be character name generator ''' letters = 'abcdefghijklmnoprstuvwyz' len_letters = len(letters) - 1 syllabes = ['mon', 'fay', 'shi', 'fag', 'blarg', 'rash', 'izen'] def Generate_Word(word_len=15, word=''): '''This function generate Words (Rand...
8ddf8406cb8fa5eb02462f096a6ca7f25b1e2d75
gp-learning/Python_educative_assignment
/LC119 Pascal's Triangle II.py
496
3.625
4
def getRow(rowIndex): """ :type rowIndex: int :rtype: List[int] """ result = [[] for i in range(rowIndex+1)] for i in range(rowIndex+1): for j in range(i+1): if j < i: if j == 0: result[i].append(1) else: ...
37852bdbb99a22f882c68f50abf11e5c11ee1434
gp-learning/Python_educative_assignment
/s_in_missisippi.py
154
3.546875
4
def find_s(str): cnt = 0 for char in str: if char == 's': cnt+=1 return None if len(str)== 0 else cnt print(find_s(''))
438104b5458402dde2c0fb97816e3a2ba2d1227a
dhanuja97/SLLAB
/assignment9.py
1,543
4.0625
4
Skip to content Pull requests Issues Marketplace Explore @dhanuja97 1 0 2 sach999/ScriptingLab Code Issues 0 Pull requests 0 Actions Projects 0 Wiki Security Insights ScriptingLab/ScriptingLab/PyCol/AssignmentQ9.py / @sach999 sach999 Update AssignmentQ9.py 11f7ce8 on Sep 6 48 lines (33 sloc) 1.01 KB You're usin...
f906a4689d26ff6171d73e977b3ab9234835edd9
Harshasharihar/Sentimental_Analysis
/gui_evenodd.py
600
3.828125
4
import tkinter as tk def check(): try: number = int(num.get()) if number % 2 == 0: lbl.config(text=f"Even number",fg = 'white',bg='green') else: lbl.config(text=f"Odd number",fg = 'white',bg = 'red') except Exception as e: lbl.config(text="You enter the fl...
f21af3fd88fb1ef0b0f41cb3556d979f214807be
kgodfrey24/advent-of-code-2017
/day3/day3a.py
943
3.78125
4
import math def find_middle(min, max): return (min + max) / 2 x = 361527 root = math.sqrt(x) print "root of x:",root round_root = math.ceil(root) if round_root % 2 == 0: round_root = round_root + 1 print "rounded root number:",round_root width = round_root - 1 bottom_right = round_r...
add6f77e35a8cfc7e28d7813bfa8c56a3914aec2
w5688414/JobInterviewInAction
/zijietiaodong/lcs.py
1,060
3.59375
4
def LCS(str1,str2): ''' 不连续的公共子序列(不要求连续) ''' m=len(str1) n=len(str2) dp=[[0]*(n+1) for _ in range(m+1)] for i in range(m+1): for j in range(n+1): if(i==0 or j==0): continue elif(str1[i-1]==str2[j-1]): dp[i][j]=dp[i-1][j-1]+1 ...
75e80d0ca0e3acf6c77d1d3a7d338e18172e9e59
harkevich/testgithub
/Lesson/Lesson11СтрокиФорматирование.py
441
3.890625
4
name = 'John' age = 30 print("My name is " + name + '. ' 'I\'m ' + str(age)) print('My name is %(name)s. I\'m %(age)d' %{'name' : name, 'age' : age}) print('My name is %s. I\'m %d' %(name, age)) # -----------print("Title: %s,") # ----------Format--------- print('My {1} name is {0}. I\'m {1}'.format(name, age)) pri...
d543394af1ca619112df27e54f1068d50909ca3c
harkevich/testgithub
/Lesson/Lesson42Декоратор.py
1,247
3.734375
4
# def hello(): # return 'Hello, I am func "hello' # # # def super_func(func): # print('Hello, I am func "super_hello') # print(func()) # # super_func(hello) #----------------------------------------------------- # # def hello(): # return 'Hello, I am func "hello' # # test = hello # # print(test()) #---...
b36269eb19b5e00e57b5398e42ec7b45523496a3
harkevich/testgithub
/Lesson/Lesson8Строки.py
948
3.71875
4
# # #words = "Hello, \"test\" 'words'!!" # # words = "Hello, \t \t 333 \n test\" 'words'!!" # # print(words) # # # verse = 'И труд нелеп, и бестолкова праздность,\n\ # # И с плеч долой всё та же голова,\n\ # # Когда приходит бешеная ясность,\n\ # # Насилуя притихшие слова.' # verse = ('И труд нелеп, и бестолкова праздн...
edfe32f389ce49212ed22d24d64572abc26fdd73
harkevich/testgithub
/Lesson/Lesson36ООП_и_Классы.py
460
3.59375
4
class A: property1 = ['Property' '1'] property2 = ['Property' '2'] name = 'gust' def say_hi(self, name=''): # return 'Hi, ' + name if name: return 'Hi, ' + name else: return 'Hello, ' + self.name a = A() b = A() # a.property1 = ['Property' '1'] # a.prop...
b48f1b35d448294d3f92d82a44827bb7dda3e020
harkevich/testgithub
/Lesson/Lesson12ОператорIF(оператор условия).py
758
4.0625
4
# x = 2 # if x: # print("Переменная х вернула истину") # else: # print("Переменная х вернула ложь") # # light = input("Введите какой сейчас свет сфетафора - ") # # if light == "red": # print("Stop!") # elif light == "yellow": # print("Wait!") # elif light == "green": # print('Go!') # else: # pr...
57022b1d3fd687f3b9f9850a5ba0e08db7d94f96
harkevich/testgithub
/Lesson/Lesson9ОперацииСтрок.py
1,111
3.8125
4
# s = r'C:\python\new.txt' # объявить данную строку сырой строкой(raw string) можно с помощбю r (редактор не обрабатывает управляющие последовательности ) # print(s) # -------- сложение строк ------- # s = 'Py' 'ton' # print(s) # # s1 = 'Hello, ' # s2 = 'world!' # s3 = s1 + s2 # объеденить две строки можно с помощью + ...
5fbed5caa20119478362b6f861b17b41a5d5f874
deepthianivala/python-files
/ss.py
118
3.796875
4
base=int(input("enter 1st no.")) height=int(input("enter 2nd no.")) area=0.5*base*height print(area) print(type(area))
608b212a6263d1f338b360d79adcd67237103f73
deepthianivala/python-files
/deepthi.py
146
3.765625
4
n=int(input("give a number")) m=int(input("give another number")) k=n+m t=n-m u=n*m print(n,"+",m,"=",k) print(n,"-",m,"=",t) print(n,"*",m,"=",u)
26e011a03ae7a8e63eae628c8c704230b8a9a996
EDAII/lista-03-sort
/insertion.py
332
3.890625
4
def insertion_sort(vector): i = 1 # i go to end of the vector while i < len(vector): temporaria = vector[i] swap = False j = i - 1 #element to compair while j >= 0 and vector[j] > temporaria: vector[j+1] = vector[j] swap = True #swap j = j - 1 if swap: vector[j+1] = temporaria i = i + 1 yi...
da0eff1dba763ef1adde544ad38fa58484f27d72
myleszhu/geekbang
/125.验证回文串.py
729
3.578125
4
# # @lc app=leetcode.cn id=125 lang=python3 # # [125] 验证回文串 # # import re # @lc code=start class Solution: def isPalindrome(self, s: str) -> bool: # 先把标点都去除,改为小写 # onlycharnumS = ''.join(re.findall(r'[A-Za-z0-9]', s)).lower() s = ''.join(filter(str.isalnum, s)).lower() # print(onlych...
8e6b4f3bfbc95e36c8608eb541f5fb4e9012be9e
trmasse/Tic-Tac-Toe
/ttt_func.py
2,109
3.859375
4
#functions for tic tac toe def print_grid(grid): print("".join(grid[0:11])) print("".join(grid[11:22])) print("".join(grid[22:33])) print("".join(grid[33:44])) print("".join(grid[44:55])) def get_choice(): print("Player - Make Your Choice: ", end = '') choice = 0 try: choice...
76c8df5e1d5cd8bec5c91375c3059b2967a9ea1d
cs-richardson/isbn-khanhnguyen21
/ISBN.py
669
3.875
4
isbn = int(input('ISBN:')) total = 0 #Taking the last number tenth = int(isbn % 10) isbn = int(isbn / 10) #This part is for finding the sum of the first 9 numbers for x in range(9): numIs = int(isbn % 10) multiply = numIs * (9-x) total = total + multiply isbn = isbn / 10 #Finding the last number through...
9666b5a1a5345f47477812f252af081a19688185
danpatrickoneill/Data-Structures
/queue_and_stack/singly_linked_list.py
1,038
3.8125
4
class ListNode: def __init__(self, value, prev=None, next=None): self.value = value self.next = next def insert_after(self, value): temp = self.next self.next = ListNode(value, self, temp) def delete(self): pass class SinglyLinkedList: def __init__(self, node=None): self.head = node ...
e26c7038eced5c12daecff3aa0c19c93eefb6ad9
Vbrendan42/BadName
/badname.py
111
3.734375
4
name = input("Enter Your Name: ") print("Bruh imagine being named " + name + ", you autistic little snake. ")
416500cec0887721d8eb35ace2b89bc8d208a247
qasimriaz002/LeranOOPFall2020
/qasim.py
555
4.34375
4
from typing import List def count_evens(values: List[List[int]]) -> List[int]: """Return a list of counts of even numbers in each of the inner lists of values. # >>> count_evens([[10, 20, 30]]) [3] # >>> count_evens([[1, 2], [3], [4, 5, 6]]) [1, 0, 2] """ evenList = [] for sublist...
8916aa0a01c2b7b8d701f7d0c2ac67c834e89c69
qasimriaz002/LeranOOPFall2020
/Lectures/Mid4/definations.py
239
3.609375
4
class student: name = "" age = 0 def intro(self): print(self.name) print(self.age) class teacher: name = "" sub = "" def intro(self): print(self.name) print(self.sub) s1 = student()
14ce57750b102df8402fa926924df3c4ff3f13e4
qasimriaz002/LeranOOPFall2020
/Lectures/mid1.py
457
3.75
4
# Constructors in Python class operatingSystem: OS_NAME = "" def __init__(self,osName): print("Desktop Icons are shown at " + osName) self.OS_NAME = osName def playMusic(self): print("OS is playing Music in " + self.OS_NAME) def __del__(self): print("Object of " + sel...
ad3a6c22485fece625f45f894962d548960b00b0
qasimriaz002/LeranOOPFall2020
/Labs/Lab_1/Lab_1_part_3.py
1,323
4.53125
5
# Here we will use the dictionaries with the list # We will create the record of 5 students in the different 5 dictionaries # Then we will add all of the these three dictionaries in the list containing the record of all student # Creating the dictionaries stdDict_1 = {"name": "Bilal", "age": 21, "rollno": "BSDS-001-20...
4548dddcd1d80483f89139dba2836766abdb47a6
xtracko/spectre
/spectre/sparse/indexing.py
5,805
3.59375
4
from typing import Tuple import numpy as np from numba import njit, prange @njit def is_csr_indexing(rows: np.ndarray, cols: np.ndarray) -> bool: """Check whether a set of arrays satisfies the requirements for CSR indexing. The requirements for CSR (compressed sparse row) indexing are: * :code:`row...
032290328f8beae53d1db6936854906818d456ba
Kuhnhee/chatbot-python
/day03/dynamic/lotto.py
1,450
3.6875
4
# lotto api를 통해 최신 당첨번호를 가져온다. import requests import random url = "https://www.dhlottery.co.kr/common.do?method=getLottoNumber&drwNo=866" res = requests.get(url) #json file을 dict 구조로 바꿔줘야함. json_lotto = res.text #json file이 string으로 들어온 것. (이렇게 하면 안돼) dict_lotto = res.json() #json file이 dict 구조로 들어온 것. ...
c2bf6604b053c51f040365c80ccdb95d3dae9fba
domsqas-git/Python
/vscode/myGame.py
1,044
4.21875
4
print("Bim Bum Bam!!") name = input("What's your name? ").upper() age = int(input("What's your age? ")) print("Hello", name, "you are", age, "years hold.") points = 10 if age >= 18: print("Hooray!! You can play!!") wants_to_play = input("Do you want to play? ").lower() if wants_to_play == "yes": ...
4f169240516423d8d51a7c631e07c6430d390325
BJWiley233/Practical-Computer-Concepts-Files
/Python/disjoint_forest_21.py
4,616
3.546875
4
# -*- coding: utf-8 -*- """ Created on Wed Oct 16 09:55:56 2019 @author: bjwil """ from string import ascii_lowercase class Node(): def __init__(self, x): self.p = x self.value = x self.rank = 0 # for cicular linked list implementation # see https://gi...
936978c6a7fa55c7f71c1b9c307401bdd6c20dd3
BJWiley233/Practical-Computer-Concepts-Files
/Python/quicksort.py
1,910
3.53125
4
# -*- coding: utf-8 -*- """ Created on Tue Aug 6 18:57:09 2019 @author: bjwil """ import random def partition(A, p, r): x = A[r] i = p - 1 for j in range(p, r): if A[j] <= x: i += 1 A[i], A[j] = A[j], A[i] A[i + 1], A[r] = A[r], A[i + 1] ret...
127be50acd2dca5de0735e881470040a4d7a471f
BJWiley233/Practical-Computer-Concepts-Files
/Python/binary_search.py
524
3.625
4
# -*- coding: utf-8 -*- """ Created on Fri Aug 30 13:55:38 2019 @author: bjwil """ A = [1,2,3,4,5,6,7,8] v = 1 def binary_search_it(A, v, high, low): while low <= high: mid = int((low+high)/2) # second round this would be int(0+2/2) or 1 print(mid) if v == A[mid]: ...
1d2f1ba5941bd4f4736a065a34d720128df5518b
Nilutpal-Gogoi/LeetCode-Python-Solutions
/Binary_Search/Easy/167_TwoSumII.py
1,222
4.0625
4
# Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a # specific target number. # The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be # less than index2. # # Note: # Your returned answers (bo...
f277884f457cbdc35fc1c64cb2f466f26a96d80a
Nilutpal-Gogoi/LeetCode-Python-Solutions
/Array/Medium/54_SpiralMatrix.py
1,002
3.640625
4
# https://leetcode.com/problems/spiral-matrix/ def spiralOrder(matrix): left = 0 top = 0 bottom = len(matrix)-1 m = bottom+1 right = len(matrix[0])-1 n = right+1 index = 0 result = [0] * (m*n) while m*n > index: if left > right: break for i in range(lef...
4d7f7050ace9a1bc162e2419b2c664d519c58a3e
Nilutpal-Gogoi/LeetCode-Python-Solutions
/Array/Medium/15_3Sum.py
1,999
3.703125
4
# Given an array nums of n integers, are there elements a, b, c in nums such that # a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. # Note: # The solution set must not contain duplicate triplets. # Example: # Given array nums = [-1, 0, 1, 2, -1, -4], # A solution set is: # ...
04c9bfd9367c43b47f01ba345ba94a7a9ac61129
Nilutpal-Gogoi/LeetCode-Python-Solutions
/Array/Easy/674_LongestContinuousIncreasingSubsequence.py
856
4.21875
4
# Given an unsorted array of integers, find the length of longest continuous # increasing subsequence(Subarray). # Example 1: # Input: [1,3,5,4,7] # Output: 3 # Explanation: The longest continuous increasing subsequence is [1,3,5], its length # is 3. Even though [1,3,5,7] is also an increasing subseque...
05365bc5a7afac8cb90b1078393aec87ec1867b4
Nilutpal-Gogoi/LeetCode-Python-Solutions
/Array/Easy/349_IntersectionOfTwoArrays.py
986
4.21875
4
# Given two arrays, write a function to compute their intersection. # Example 1: # Input: nums1 = [1,2,2,1], nums2 = [2,2] # Output: [2] # Example 2: # Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] # Output: [9,4] # Note: # Each element in the result must be unique. # The result can be in any order. # -----...
f10f167a2657cb3ca8ec03151877f16d5256a194
Nilutpal-Gogoi/LeetCode-Python-Solutions
/LinkedList/Easy/1290_ConvertBinaryNumberInALinkedListToInteger.py
586
3.96875
4
# Given head which is a reference node to a singly-linked list. The value of each node # in the linked list is either 0 or 1. The linked list holds the binary representation # of a number. # Return the decimal value of the number in the linked list. def getDecimalValue(self, head): result = 0 length = 0 c...
8b9c0aac40b97452fc35f19f49f191bc161e90b9
Nilutpal-Gogoi/LeetCode-Python-Solutions
/LinkedList/Easy/21_MergeTwoSortedLists.py
1,184
4.21875
4
# Merge two sorted linked lists and return it as a new sorted list. The new list should # be made by splicing together the nodes of the first two lists. # Example: # Input: 1->2->4, 1->3->4 # Output: 1->1->2->3->4->4 # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None)...
aec3367438c1a074f51701bd2addd48ab71c858b
Nilutpal-Gogoi/LeetCode-Python-Solutions
/LinkedList/Easy/876_MiddleOfTheLinkedList.py
1,879
4.09375
4
# Given a non-empty, singly linked list with head node head, return a middle node # of linked list. If there are two middle nodes, return the second middle node. # Example 1: # Input: [1,2,3,4,5] # Output: Node 3 from this list (Serialization: [3,4,5]) # The returned node has value 3. (The judge's serialization ...
77caf5d286697c0963b9bd915176616639ff5282
lreissmueller/CECS-229
/rsa.py
785
4
4
''' This program generates valid keys (e, n) for the RSA cryptosystem where n = p(prime) * q(prime) and e = (p-1)*(q-1) which is co-prime to n. @ author Luke, Reissmueller @ 10/21/2020 @ rsa.py ''' def rsa(p, q): p = int(p) q = int(q) n = p * q e = (p - 1) * (q - 1) if gcd(n...
0bbe5c027de59aedb637b8b3775177e7b50d04e1
ZettZet/RomanNumbers
/romannumbers/__main__.py
351
3.921875
4
from romannumbers import arabic_to_roman, is_roman, roman_to_arabic if __name__ == '__main__': input_str: str = input('Roman or arabic number: ') try: out = roman_to_arabic(input_str) if is_roman( input_str) else arabic_to_roman(int(input_str)) except ValueError as ve: print(v...
e181d3d7a831bf7f80673b1bf12a9b613d5cbb46
H2Yo/AjgarMini
/regex_basic.py
161
3.59375
4
import re Input = ''' •Put In your String here ''' regexExpression = r'Put your regex here' ro =re.compile(regexExpression) fo =ro.findall(Input) print(fo)
c9544f1b91da059e14db51ece6cb5f4c40c4b1c7
jianghuakun/app
/test_6_mock1.py
783
3.703125
4
import unittest from unittest import mock class SubClass(object): def add(self, a, b): "两个数相加" pass class test_add(unittest.TestCase): "测试两个数相加用例,功能函数未开发完成,使用打桩写死" def test_add_1(self): # 创建一个mock对象 return_value代表mock一个数据 list1={"key":"value"} mock_add=mock.Mock(ret...
312d4f51cb83df08fa1cfe136c4a548b3285e82b
Stipane/LWP-Python3
/Chapter 11/C11Ex6 - FileEditor.py
2,209
3.5625
4
from tkinter import * from tkinter.filedialog import askopenfilename from tkinter.filedialog import asksaveasfilename class FileEditor: def __init__(self): window = Tk() window.title("Simple Text Editor") # Create a menu bar menubar = Menu(window) window.config(m...
2489ff85f02897be1fbd63eac903955e17f0a2c1
Stipane/LWP-Python3
/Chapter 9/Chapter 9 - Lists.py
1,389
3.90625
4
a = [] print(type(a)) myList = [1, 2, 3,4,5] print(myList[0]) print(myList[4]) print(len(myList)) print(myList[1:3]) print(myList[:3]) print(myList[1:]) newList = ['dog', 2, 10.5, True, 'a'] print(newList) print(newList[0]) newList[1] = 'cat' print(newList) newList.append(5) print(newList) n...
14e28eb677d53cd4e5b6931b2036c0de647f68a3
pol9111/algorithms
/二叉树/二叉树_建树.py
2,117
4.15625
4
from collections import deque import unittest class Node: """二叉树的节点类""" def __init__(self, elem=-1, lchild=None, rchild=None): # 一个节点实例具有三个属性: 值, 左子节点, 右子节点 self.elem = elem # 准备存入的数据 self.lchild = lchild self.rchild = rchild class Tree: """二叉树类""" def __init__(self): ...
d0d6140645fbcd46bf30c4f9592ad8a18d4cede2
pol9111/algorithms
/排序/希尔排序.py
1,020
3.625
4
import random l = list(range(100)) random.shuffle(l) print(l) def shell_sort(lst): gap = len(lst) // 2 while gap > 0: # 一直到gap等于1, gap != 1的话少排一次 for i in range(gap, len(lst)): # 把1变成gap j = i while j >= gap and lst[j-gap] > lst[j]: lst[j-gap], lst[j] = lst[j],...
16807bf74758d1da9b00f2a26a4f50e6ccde4b6a
dnovik/py-homework-advanced
/2.5.Data_analysis1/homework.py
1,189
3.8125
4
import pandas as pd def get_data_by_year(year_list): df_list = list() for year in year_list: file_path = f'names\yob{year}.txt' df = pd.read_csv(file_path, names=['Name', 'Gender', 'Qty']) df['Year'] = year df_list.append(df) return pd.concat(df_list) def count_top...
83d48486751e108f9f98076257f34c07b30332f6
tchennech/NextPlease
/snake.py
3,314
3.703125
4
import math,random, pygame import abc from setting import Setting class Snake: def __init__(self,screen): self.screen = screen self.num = 8 self.degree = 0 self.bodyX = [] self.bodyY = [] self.r = 10 self.power = 1.5 self.invincibleTime = 4...
2ba66c1df0bf0c6c44a7d4ef9dbcc0e6140f05b8
l4zyg33k/softeer_ai_practice
/지우는_소수를_좋아해.py
874
3.53125
4
import sys import queue def main(): N, M = list(map(int, input().split()[:2])) global E E = [[-1 for i in range(N)] for j in range(N)] for i in range(M): A, B, C = list(map(int, input().split()[:3])) if E[A - 1][B - 1] == -1 or E[A - 1][B - 1] > C: E[A - 1][B - 1]...
3b48c9c406bf16ca9839a796d584eecb3db23fb9
aliceseaborn/udemy-flask-bootcamp
/project/ch1-basics/sec3_dynamic_routing.py
640
3.78125
4
# Chapter 1: Flask Basics # Section 3: Dynamic Routing # # Consider a website with multiple users. You don't want # users to collide with other users. Ergo, you can # dynamically route users to their page, e.g. # # site.com/user/unique_user_name # from flask import Flask app = Flask(__name__) # localhost:5000/ @app...
05639dd40d623e4719620cb121b671cc2e5b0be9
GameTL/Class-of-2021-CIE-A-Level
/Pre-released Material A2 Exams - May-June 2021/Task3.py
1,630
3.6875
4
import random class Tools: # Task 3.2 def __init__(self, name, cost, image_file_name): self.name = name # string self.cost = cost # reals self.image_file_name = image_file_name # string class Shelves: def __init__(self, array): self.position = random.randint(0,4) # only 0-4 ...
d3bbccd3eda54ee35a28f0ba6b6f535915cc7c89
GameTL/Class-of-2021-CIE-A-Level
/0. Invent with Python - Excercise/ch6_dragongame.py
528
3.609375
4
def DisplayIntro(): print('Hello Fellow Traveller') print('Are you are ready to feel Maximum Pain?') print('(y for Yes), Anything or No') MyYesOrNo = input() if MyYesOrNo == 'y': print('OK Then then Boi-yo, let\'s go') else: print('Fine Boi-yo, Go back to your country Gringo')...
35a6e2d968b2f35337c30758d2d87158dfec61b0
GameTL/Class-of-2021-CIE-A-Level
/4. Queue Data Type Example - Python/Past_paper, example.py
1,489
3.578125
4
# 9608 42 s18 https://paper.sc/doc/5b80ea0b06bb3922177454b0/ BinaryTree = [] class TreeNode: def __init__(self, value, nextNodeL="-1", nextNodeR="-1"): self.value = value self.nextNodeL = nextNodeL self.nextNodeR = nextNodeR def CreateRoot(value): root = TreeNode(value) BinaryT...
f6a7f1a54a701ef5224acf2fd675991e39c50806
GameTL/Class-of-2021-CIE-A-Level
/4. Queue Data Type Example - Python/Tree - Binary Search.py
3,435
4.09375
4
import os import platform platform = platform.system() if platform == 'Darwin': clear = "clear" elif platform == 'Windows': clear = 'cls' class Node: # 60% from geeksforgeeks/binary-search-tree-set-1-search-and-insertion def __init__(self, data): self.value = data self.left = None ...