blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a470ac5acd7f2ea443fdfcddd699a6f7066af71d
Kitxyn/BrLanguage
/Brlanguage264bits.py
6,120
3.765625
4
import sys import time print('a linguagem br é uma linguagem feita para aprendizado ela não é apropriado para projetos grandes') start = '' #INT IntValor = 0 nameInt = '&' #STRING nameString = '&' StringValor = 0 #STRING REP nameString2 = '&' stringvalorrep = '&' rep1 = '&' rep2 = '&' #FLOAT ...
06312aa389dedcebc461766fdd5a841920349f15
haorenxwx/Cousera_Python_Note
/CouseraPythonDataStructure/Week6/Week6_tuples.py
732
4.03125
4
#Week6_tuples.py #looks like x = ('aa','bb','cc') for i in x: print(i) # immutable like string # more efficient than list # Assignment: (x,y) = (4,'fred') # With dictionary #item() method returns a list of (key, value) Week6_tuples d = dict() d['csev'] = 2 d['cwen'] = 3 for (k,v) in d.items(): print(k,v) # Com...
160fbc9596e0d85c545a8214b9aaaab155be27b1
davidbarbosa23/MisionTic
/Python/Tasks/1_01_Lab/index.py
328
3.65625
4
name = input() unit_price = int(input()) sell_price = int(input()) units = int(input()) def profit(): benefit = sell_price - unit_price return benefit * units print(f"Producto: {name}") print(f"CU: ${unit_price}") print(f"PVP: ${sell_price}") print(f"Unidades Disponibles: ${units}") print(f"Ganancia: ${prof...
522db1bb4440c186306b7404a2b0d9e0dc1bce59
frederico-prog/python
/exerciciospython/EstruturaDeRepeticao/atividade8.py
401
4.0625
4
''' 8 - Faça um programa que leia 5 números e informe a soma e a média dos números. ''' print('Insira 5 números:') lista = [] qtde = 0 for i in range(1, 6): num = int(input(f'Informe o {i}º número: ')) lista.append(num) qtde += 1 soma_numeros = sum(lista) media = soma_numeros / qtde print(f'Números digit...
16d48561ed45e3958d573d2a135e8d0463d6386c
wshota66/OpenCV2-Simple-Blob-Detector
/BlobCounter.py
4,231
3.859375
4
# https://www.learnopencv.com/blob-detection-using-opencv-python-c/ # Standard imports import cv2 import numpy as np; from tkinter import filedialog # GUI library from tkinter import * root = Tk() # Prompt user to choose HTML file with GUI open_dir = "C:\\" save_dir = "C:\\" root.filename = filedialog.a...
3e3aeb916d843ec1805b87171bcf8797b9e4c920
zNine0414/SCU-CS-LearningMaterials
/Python程序设计/作业六/6.py
807
4.0625
4
def encrypt(): text = input("请输入需要加密的文本(任意大小写字母组合):") cipher_text = ' ' for i in text: if 'a' <= i <= 'z': cipher_text += chr(ord('a') + ((ord(i) - ord('a')) + 4) % 26) if 'A' <= i <= 'Z': cipher_text += chr(ord('A') + ((ord(i) - ord('A')) + 4) % 26) pri...
ae275c2d1c87780cf962673b478897ca0392a4f7
mahimadubey/leetcode-python
/maximum_subarray/solution3.py
1,014
4
4
# -*- coding: utf-8 -*- """ Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [−2,1,−3,4,−1,2,1,−5,4], the contiguous subarray [4,−1,2,1] has the largest sum = 6. """ class Solution(object): def maxSubArray(self, nums): "...
922d489f88f0a9a52909686ba67d3b15dd79a884
IGG01/PYTHON
/tcp/server.py
2,074
3.5625
4
# TCP server import socket import threading bind_ip = "10.10.10.10" bind_port = 80 server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server.bind((bind_ip,bind_port)) server.listen(5) print("████████╗ ██████╗ ██████╗ ███████╗███████╗██████╗ ██╗ ██╗███████╗██████╗") print("╚══██╔══╝██╔════╝ ██╔══██╗...
4a998ed032b06867811b41d2a4ae40203b026e6e
pythohshop/pythonintro
/dictionary/dictionary.py
310
4.09375
4
# Dictionary demonstration my_dict = { 'a': 'appel', 'b': 'ball', 'c': 'cat', 'd': 'dog', 'e': 'etc' } # Adding a key value pair to a dict my_dict['f'] = 'frog' # Changing value of a key my_dict['b'] = 'no more ball. Is it now?' # deleting a key value pair in a dict del my_dict['a']
6b862100babdf3fb1416e2b1559fb675736a3c1e
carnad37/python_edu
/190111/ex04.py
1,470
4.03125
4
#append는 리스트안에 요소 추가 a=[1,2,3] a.append(4) print(a) a=[] one=1 a.append(one) a.append(2) a.append(3) a.append(4) print(a) #sort()리스트의 요소들을 정렬 #정순 (), 역순(reverse=True)를 넣어준다. a=[1,4,3,2] a.sort() print(a) a=['a','c','b'] a.sort(reverse=True) print(a) #reverse()는 요소들을 역순으로 뒤집는다. 걍 뒤집기만함. a.reverse() print(a) #inser...
6bc60f11cffdf2c1d88a676832c0ff7ce561f7a1
JasonGluck/python_practice
/avg.py
454
3.96875
4
# computes the avg of two user input scores # def avg(): # score1 = eval(raw_input("Please enter first exam score: ")) # score2 = eval(raw_input("Please enter second exam score: ")) # average = (score1 + score2) / 2 # print "The average is: ", average def avg(): score1, score2 = eval(raw_input("Pl...
81ee500ed18324a5c8152bd0dc2fe0c5b10d2600
melodrivemusic/CodeOfAI
/04 - Markov I/python/04_markov_example.py
821
3.8125
4
from probability import sample if __name__ == "__main__": # the initial distribution - to decide what happens first initialDistribution = { "A": 1, "E": 1 } # the transition matrix - to decide what happens next transitionMatrix = { "A": { "A": 0.6, ...
346cc49b76d39c4bb036b3caa62032a1185eea77
VishnuK11/Computer_Vision
/5 Transform.py
1,073
3.546875
4
''' Image Transformations 1 Translate 2 Rotate 3 Resize 4 Flip ''' import os import cv2 as cv import numpy as np dir_path = os.getcwd() + '/data/images/' img=cv.imread(dir_path+'cat.jpeg') cv.imshow('Original cat',img) # x -->right # y -->down # -x -->left # -y -->up # Translation def translate(img,x,y): transMa...
4a5eb325adf37d603ec45b348ec350ad1a319b8e
maruichen2004/LeetCode
/Clone_Graph.py
918
3.625
4
# Definition for a undirected graph node # class UndirectedGraphNode: # def __init__(self, x): # self.label = x # self.neighbors = [] class Solution: # @param node, a undirected graph node # @return a undirected graph node def cloneGraph(self, node): if node is None: return None...
c268341ea34e52705f8f1e59038109436f60ad17
DanielMalheiros/geekuniversity_programacao_em_python_essencial
/Exercicios/secao04_variaveis_e_tipos_de_dados/exercicio24.py
316
3.703125
4
"""24- Leia um valor de área em metros quadrados e apresente-o convertido em acres. A fórmula de conversão é A = M * 0,000247, sendo M a área em metros quadrados e A a área em acres.""" m = float(input("Defina um valor em metros quadrados: ")) print(f"{m} metros quadrados equivalem a {m * 0.000247} acres.")
123d7f1c392b7abe425ee50afda3b86971a828f0
max-philip/ProjectEuler-Programs
/1-20/p_euler07.py
370
3.75
4
from math import sqrt num = 3 i=0 prime_no = 10001 while True: is_prime = 0 for j in range(2, 1+int(sqrt(num+1))): if (num%j == 0): is_prime = 0 break else: is_prime = 1 if is_prime: i += 1 if (i == prime_no-1): ...
e7444b1d401960edcd43fb7aa2219dfa4a256606
VitaliiRomaniukKS/python_course
/Lesson9/Lesson09_hw01.py
254
3.6875
4
def ost(a): if a % 3 == 0: print(f'Число {a} кратно 3') else: print(f'Число {a}  не кратно 3') print ('До свидания!') return None a = int(input('Введите число:')) ost(a)
dd49a83ba2da5b5698558ddf676798ea49a5484d
doulgeo/project-euler-python
/palindromes.py
722
4.0625
4
"""PROBLEM 4: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. """ c = [] d = [] for x in range(111,1000): for y in range(111,1000): prod...
ad50d897e6328aa7541796cf23984fa6fcfb7cdf
sodua/tpop
/322/regular.py
241
3.640625
4
#!/usr/bin/python import re import sys text2=sys.argv[1] regex_num=re.compile('^[+-]?[1-9]+[0-9]+$') s = regex_num.search(text2) print('Starting position: ', s.start()) print('Ending position: ', s.end()) print(text2[s.start():s.end()])
6b7a5aed00c0411c645ab6980b2907bb01b3521f
johnguolex/tonyg_freechips
/pokerbot/gamestate/opponent.py
333
3.5625
4
class Opponent: """ Class representing an opponent in WSOP online poker. Attributes ---------- id : str an id representing the opponent chips : int represents the amount of chips the opponent has left """ def __init__(self, id, chips): self.id = id self.c...
9e87e606750a8110c930084a69c2386e5a7ad8cd
AdamZhouSE/pythonHomework
/Code/CodeRecords/2497/61048/299682.py
589
3.515625
4
def sort7(): target=int(input()) str1=input() str2=input() position=[int(x) for x in str1[1:len(str1)-1].split(',')] speed=[int(x) for x in str2[1:len(str2)-1].split(',')] lst = sorted(zip(position, speed)) set=[] for p, s in lst: set.append((target-p)/s) res = 0 head=0 ...
56ee316d2cf25e7a6078885aa51aea5765e53afb
izhang05/Project-Euler
/22 - Names scores ✓.py
1,662
3.859375
4
"""Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obtain a name score. For exampl...
8d9c1b4b53430e5f57b113bd5a75767fd035af71
pavankumar-win/meeting-scheduler
/utils/datetime_utils.py
1,291
4.3125
4
import datetime class datetimeUtils: def __init__(self) : pass def get_date() : """Gets Date from the user""" while True : try : date = input("Enter Meeting Date in dd/mm/yyyy Format :") dd,mm,yyyy = map(int, date.split('/')) date = datetime.date(yyyy,mm,dd) now = datetime.date.today() ...
cbca007466171f6c2e73e189d4b1da52ea6cf92e
wurde/Sorting
/src/recursive_sorting/recursive_sorting.py
1,107
4.15625
4
# # Define methods # def merge(left, right): elements = len(left) + len(right) merged_arr = [0] * elements return merged_arr def merge_sort(arr): if len(arr) > 1: left = arr[:int(len(arr)/2)] right = arr[int(len(arr)/2):] merge_sort(left) merge_sort(right) i = j = k = 0 while i < l...
bd04b4c528104d80c7a79b41e7b59f8b167c638f
Wattyyy/LeetCode
/submissions/swap-nodes-in-pairs/solution.py
564
3.890625
4
# https://leetcode.com/problems/swap-nodes-in-pairs # https://leetcode.com/problems/swap-nodes-in-pairs/ # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def swapPairs(self, head): if head is None: ...
fe5a38e5f2498fdf340da169121e1db04e7a2a99
Ricocotam/GridSearch-Server
/src/gridsearch.py
1,713
3.921875
4
"""Different parameter searching functions. This module aims to have multiple functions to do parameters search. The functions defined here are only used to get parameters. When possible, generators are preferred. """ import itertools from typing import Dict, Sequence, Any import utils ParameterSet = Dict[str, An...
5e3269e80379f193943d14c50bdc253230d88d2c
bhyun/daily-algorithm
/2022/2022.02/BOJ1991_트리 순회.py
678
3.765625
4
def preorder(node): if node == ".": return print(node, end="") left, right = tree[node][0], tree[node][1] preorder(left) preorder(right) def inorder(node): if node == ".": return left, right = tree[node][0], tree[node][1] inorder(left) print(node, end="") inorder...
a266a3ff3e68e94d7a32b59f9023782292a37ede
glmagalhaes/PrionersWorld
/PrisionersWorld.py
11,445
3.5
4
import pygame from pygame import gfxdraw from pygame.locals import * import numpy class Rectangle(pygame.sprite.Sprite): def __init__(self, x, y, width, height,color): pygame.sprite.Sprite.__init__(self) # Make the Rect self.image = pygame.Surfac...
31bb4569c465d716923eb9c307e8dbf82572766b
cnfang/BinaryTree
/src/traversal.py
2,377
3.65625
4
''' Traversal class includes seversal traversal methods: inorder, preorder, postorder ''' from src.node import Node from typing import List class Traversal: """ Recursive method """ def InOrderTraversal_Recursive(self, root: Node) -> List: ans = [] def innerecursion(root, ans): ...
5c5436708f1c1f92aa04feab4663d428c5e8a840
lapisanlangit/belajarpython
/17_fungsi.py
937
3.546875
4
def tampil(): print("tampil data") tampil() def harga(kg): harga=1000 print("harganya ",harga * kg) harga(20) def guru(nama,pelajaran): print("nama guru",nama) print("mengajar",pelajaran) # setting paramter bisa dibalik guru(pelajaran="Fisika",nama="andi") # paramateter dengan nilai default d...
68f1241691b66f967b880880bbd470a9d1685ad4
hakcsim/Tutorials-Repo
/set_operations.py
1,235
3.640625
4
s0 = set() for i in range(10): s0.add(i) s0.add(i) print(s0) s1 = set([*range(1,6)]) print(s1) s1.update([6,7,8]) print(s1) s2 = {7,8,9} s1.update([6,7,8], s2) print(s1) s1.remove(5) print(s1) try: s1.remove(10) print(s1) except KeyError: print('set remove throw KeyError if item does not exis...
1a8df4585fc7e30053c16fe68b5bc6062e78686a
Artem-Efremov/CodeWars
/Strings/Format/7kyu_The Owls Are Not What They Seem.py
2,114
3.875
4
""" To pass the series of gates guarded by the owls, Kenneth needs to present them each with a highly realistic portrait of one. Unfortunately, he is absolutely rubbish at drawing, and needs some code to return a brand new portrait with a moment's notice. All owl heads look like this: ''0v0'' Such beautiful eyes! H...
7a34a68ae0051a708c7e4d90b8b7f4a3d75cf662
gabriellaec/desoft-analise-exercicios
/backup/user_107/ch22_2020_09_16_10_50_14_782276.py
193
3.625
4
count = int(input("Quantos cigarros você fuma por dia?")) time = int(input("Há quantos anos você fuma?")) days_per_cigarrette = 10 / 60 / 24 lost_time = count * days_per_cigarrette * time
e51411673217222eb64e19cdd9fff47d12ffbc71
AlqoholUni/CountdownSolver
/Countdown Solver/main.py
1,620
3.765625
4
from random import randint import itertools import ctypes def load_words(): with open('words.txt') as word_file: valid_words = list(word_file.read().split()) return valid_words def load_consonants(): with open('consonants.txt') as consonants_file: valid_consonants = list(consonants_file.re...
c3429862a5256d48f70fd00a69656fdbf7414219
Jane-Zhai/LeetCode
/easy_linkList_83_deleteDuplicates.py
1,209
3.953125
4
class ListNode: def __init__(self,node=None): self.val = node self.next = None class Solution: def deleteDuplicates(self, head: ListNode) -> ListNode: """ 给定一个排序链表,删除所有重复的元素,使得每个元素只出现一次。 """ cur = head while cur: while cur.next and cur.next...
9aa015b862cd1df9cda076eab5f38d1287082d8e
cesarco/MisionTic
/s16/funciones_cesar.py
516
3.578125
4
def valor_absoluto(numero): """Esta funcion retorna el valor absoluto paramentros: numero-> int return: numero -> int """ if numero >= 0: return numero else: return - numero def es_par(numero_validar): """Esta funcion reto...
83894755d38544776b2111f981def280e95cfe97
Groookie/pythonBasicKnowledge
/015_04_func_closure.py
1,872
4.5625
5
#!/usr/bin/python3 # -*- coding:utf-8 -*- # author: https://blog.csdn.net/zhongqi2513 # ==================================================== # 内容描述: 闭包 # 1、闭包无法修改外部函数的局部变量 # 2、闭包无法直接访问外部函数的局部变量 # ==================================================== # python中闭包从表现形式上看,如果在一个内部函数里, # 对在外部作用域(但不是在全局作用域)的变量进行引用,那么内部函数就被认为...
b201411959e17c1c8dd82468532427df7029c21d
ariiardana/kalkulator
/kalkulator.py
1,644
3.515625
4
print ('###########################################') print ('# Kalkulator #') print ('# Author : Ari Ardana #') print ('# https://facebook.com/arie.ganz.96 #') print ('# https://github.com/Ryuzu23 #') print ('#####################################...
66990978e1fd949df1b815988e57bba5ff3d27c9
gaojk/Python_Automated_Testing_Class20
/Python_0708_job/python_0708_homework.py
2,846
3.53125
4
# 一、必做题 # 1.什么是类?什么是对象? # 类:一群具有相同特征和行为的事物的统称,类是抽象的 # 对象:具体的事物,具有类的特征和行为 # 2.类由哪几部分构成? # 类名,类的初始化方法,类的属性,类的方法 # 3.列举几个生活中类和对象的例子 # 汽车属于类,货车、轿车、三轮车都是对象 # 类的属性比如都有1个刹车 # 类的方法:都会刮雨刮器,都会亮车灯 # 货车对象的属性:车牌123,轮子4个,拖拉机对象的属性:车牌456,轮子3个 # # 4.类的设计原则 # 请从类的命名、类中属性和方法来阐述 # 类的命名:小驼峰 # 类的属性:类下面定义的变量叫类的属性,每个对象都有类的属性 # 类的方法:类的方法中的se...
e9d24e699450ffc26a13ef11fd11bde65b97576d
macloo/python_notes
/builtin_functions.py
2,783
4.4375
4
# Python built-in functions # Python for Kids, Briggs, chapter 9 # python builtin_functions.py # abs returns absolute value of a number - no negatives print "abs() applied to 10 and to -10" print "10:", abs(10) print "-10:", abs(-10) print # bool returns False for 0 and True for all other numbers print "bool() appli...
aa46466e2274547cf61130fde1fa791fd956cf64
AdamZhouSE/pythonHomework
/Code/CodeRecords/2065/60833/274491.py
596
3.53125
4
str1=str(input()) str1=str1.strip() if((str1[0]!="-")&(str1[0]!="+")&(str1.isdigit()==False)): print(0) else: xishu=1 if(str1[0]=="-"): xishu=-1 str1=str1[1:] elif(str1[0]=="+"): str1=str1[1:] i=0 result="" while(i>=0): if str1[i].isdigit(): result...
b9160feb89bf9c9df955b6e068e5b56bba6ff3f9
woozu99/python_practice
/day3/list_search.py
1,193
3.703125
4
''' 리스트의 탐색과 정렬 1. index(): 리스트에서 특정 값이 저장된 인덱스를 반환한다. 2. count(): 리스트 내부에 저장된 특정 요소의 개수를 반환. 3. sort(): 리스트를 오름차 정렬 4. reverse(): 리스트를 역순으로 배치 ''' points = [99, 14, 87, 100, 55, 100, 99, 100, 22] perfect = points.count(100) print(f'만점자는 {perfect}명') print(f'87점을 획득한 학생은 {points.index(87) + 1}번째입니다.') # 내장함수 len(...
4fe0ea1b1285925b7aac613468f48043e8cb2ae5
StevenMitchell29/Work_Code
/test/test2.py
1,953
3.5
4
#from pandas import DataFrame, read_excel # Import libraries import pandas as pd import matplotlib.pyplot as plt import numpy.random as np import sys import matplotlib #%matplotlib inline print('Python version ' + sys.version) print('Pandas version: ' + pd.__version__) print('Matplotlib version ' + matplotlib.__vers...
ac96143453e5ef236644d910e2950d3a6ff2a8aa
austinjwhite/ProjectEuler
/Problems/Problem001.py
1,406
4.09375
4
#If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. #Find the sum of all the multiples of 3 or 5 below 1000. #variables for counting mulitples of 3 t = 0 #total for set of 3s n = 1 #nth root while n in range(1, 1000): #iterator k = (3...
c92eff50cf33499c7c773f9c39acf549b6305b7a
blavson/ProjectEuler
/project_14.py
462
3.703125
4
starting_number = 0 max_chain = 0 def chain(number): global starting_number global max_chain s_number = number train = 1 while( number != 1): if (number % 2 == 0): number //= 2 else: number = 3 * number + 1 train +=1 if (train > max_chain): max_chain = tra...
1fee07b5e0903a5a67e9972ed357a1b9c7bdf44c
rishipro12/hacktoberfest-2021-practice
/np_finding_k_smallest_values.py
379
4.15625
4
# Finding the k smallest values of a NumPy array # importing the module import numpy as np # creating the array arr = np.array([23, 12, 1, 3, 4, 5, 6]) print("The Original Array Content") print(arr) # value of k k = 4 # using np.argpartition() result = np.argpartition(arr, k) # k smallest number of array print(k...
543f38d5496ceec7fa5ed8adbebf28aa53194444
micheal-oreilly/Simple-Chatty-Bot
/Topics/Program with numbers/The sum of digits/main.py
72
3.515625
4
n = str(input()) total = 0 for x in n: total += int(x) print(total)
ef328cbfb46dbee5401e5e6dfda4d918a9281cb2
mimaburao/moviebrowser
/put_togarther_images.py
4,209
3.5
4
#サムネイルをまとめて読み書きできるようにする #2019-05-15 #巳摩 import zipfile from collections import OrderedDict import traceback import base64 from io import BytesIO from pathlib import Path #画像置き場 image_path_dir = '/home/mima/work/moviebrowser/static/' def put_togarther_images(filename): """thumnail.zipファイルに書き込む""" with zipfile...
f7d4f5e9c94ced66bfbc75bc474d1905150bf8ea
SethMiller1000/Portfolio
/Foundations of Computer Science/Lab 6- Swapped Letters.py
441
4.125
4
# Lab 6- Swapped Letters Program (CIS 1033) # Swaps letters in a word # Author: Seth Miller # Input: enter the word and the letters that will be swapped myString = "marmalade" l1 = "a" l2 = "e" # Process: swap the letters l1 and l2 myStringSwap1 = myString.replace( l1, "*" ) myStringSwap2 = myStringSwap1.r...
ecd45dad98886c1da5368a7af853fc97898f3227
MrHamdulay/csc3-capstone
/examples/data/Assignment_8/hrsgin001/question3.py
749
4.34375
4
#Gina Horscroft #Question 3 #convert all lowercase letters to next character (z -> a) def encrypt(s): if len(s) < 1: return "" else: #check if character is in lowercase if (s[0].islower()): #if character is z, encrypt to equal a if (s[0] == "z"): ...
b8268988e52c7275f44db1bc1c57437d98878361
Kawser-nerd/CLCDSA
/Source Codes/AtCoder/arc035/B/3126189.py
278
3.515625
4
from math import factorial from collections import Counter from itertools import accumulate n = int(input()) t = [int(input()) for i in range(n)] dic = Counter(t) cnt=1 for i in dic.values(): cnt*=factorial(i) print(sum(accumulate(sorted(t)))) print(cnt%(10**9+7))
883a412ff7e1c4f1a3089c48732df35fb46fd165
PFZ86/LeetcodePractice
/Design/0348_DesignTicTacToe_M.py
1,498
3.578125
4
# https://www.cnblogs.com/lightwindy/p/9649759.html # Solution 1: keep row_sums, col_sums, maindiag_sum, antidiag_sum; O(n) time; O(n) space class TicTacToe(object): def __init__(self, n): """ Initialize your data structure here. :type n: int """ self.n = n self.row_...
8f16732d5072c3ccf666e2ed793592208265738a
camclark/CP1401
/testing008.py
6,206
3.859375
4
def completeOrder(userName, otherUser, tripType, destinationTypes, fareType, seatType, passengerAge): if tripType == "o": print("Fare: One way") else: print("Fare : round trip") if destinationType == "c": print("Destination: Cairns") elif destinationType == "s": print("D...
81e2f89c3fb7cd16d2234bba7f588442422f268e
phibzy/InterviewQPractice
/Solutions/AToI/atoi.py
742
3.65625
4
#!/usr/bin/python3 """ Takes a string and converts it to an integer First discards all leading whitespace chars Each string can have optional first char of '+' or '-' followed by numerical digits If first char is not a digit, return 0 All chars after digits are ignored If value is greater than max/minimum int val...
646ce1b519c7c3475bd99ce5b8601c7197ba2328
karandeep-singh100/Automated_Trading_System
/database_part_system.py
2,288
3.640625
4
import pandas import requests import csv import psycopg2 from psycopg2 import extensions #access alphavantage API and print out the data line by line. with requests.Session() as s: download = s.get("https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=MSFT&interval=5min&apikey=***&datatype=csv...
eaa25677d48fa8805603767071bb829bcf863797
mesarvagya/Algorithms
/others/max_num_recursion.py
293
3.75
4
import math def max_num(A, left, right): if left == right: return A[left] else: mid = int(math.floor((left + right)/2)) lmax = max_num(A, left, mid) rmax = max_num(A, mid+1, right) if lmax > rmax: return lmax else: return rmax print max_num([-2,3,4,-8,19,5,67, 33], 0, 7)
865c7278e727fb9a84893c68bca7087e2a7d6e39
mgyarmathy/advent-of-code-2015
/python/day_07_tests.py
1,445
3.640625
4
import unittest from day_07_1 import Circuit # For example, here is a simple circuit: # 123 -> x # 456 -> y # x AND y -> d # x OR y -> e # x LSHIFT 2 -> f # y RSHIFT 2 -> g # NOT x -> h # NOT y -> i # After it is run, these are the signals on the wires: # d: 72 # e: 507 # f: 492 # g: 114 # h: 65412 # i: 65079 # x: ...
48e56969974150226a7eff35f3938856da121b2a
deanlai/automate
/collatz.py
371
4.28125
4
def collatz(number): if number%2 == 0: print(number/2) return number/2 else: print(number*3 + 1) return(number*3 + 1) while True: try: intInput = int(input('Please enter an integer: ')) break except ValueError: print('That is not an integer!') whi...
4bfc244c11eb5be3abd2512b387f6b373abaefc2
sage-ihealth/diff-cover
/my_sum/__init__.py
160
3.734375
4
def sum(arg): total = 0 for val in arg: total += val if total == 1: return 4 elif total == 2: return 5 return total
de936832205e690d33740fec1c9bdf2fd74f032e
VictorBellens/CocktailWebsite
/Cocktail Webiste/CocktailWebsite/CocktailWebsite/security.py
1,649
3.546875
4
from cryptography.fernet import Fernet new_password = {} bucket0 = [] bucket1 = [] bucket2 = [] bucket3 = [] bucket4 = [] bucket5 = [] bucket6 = [] bucket7 = [] bucket8 = [] bucket9 = [] bucket10 = [] bucket11 = [] bucket12 = [] bucket13 = [] bucket14 = [] bucket15 = [] bucket16 = [] def find_bucket_value(username,...
150251e2022a839207506e69447244117505296f
ONSBigData/precon
/precon/helpers.py
5,353
3.703125
4
# -*- coding: utf-8 -*- from typing import Optional, Callable, Union import numpy as np import pandas as pd from pandas._typing import Level def reindex_and_fill(df, other, first='ffill', axis=0): """Reindex and fill the DataFrame or Series by given index and axis. Parameters ---------- df : DataFra...
acda578578e79b84ac2c2c716d4205177d675258
haibincoder/PythonNotes
/leetcode/766.py
1,080
3.859375
4
""" 给你一个 m x n 的矩阵 matrix 。如果这个矩阵是托普利茨矩阵,返回 true ;否则,返回 false 。 如果矩阵上每一条由左上到右下的对角线上的元素都相同,那么这个矩阵是 托普利茨矩阵 。 输入:matrix = [[1,2],[2,2]] 输出:false 解释: 对角线 "[1, 2]" 上的元素不同。 """ from typing import List class Solution: def isToeplitzMatrix(self, matrix: List[List[int]]) -> bool: if len(matrix[0]) == 1: ...
d7c84539a8af5ca30dced47203570c86c3d346a9
mouroboros/python_exercises
/Prime_Factors/primefactors_singlefile_complete.py
738
3.5
4
import unittest def prime_factors_of(value) : if value < 2 : return [] factor = 2 while value % factor != 0 : factor += 1 factors = [factor] factors.extend(prime_factors_of(value/factor)) return factors class TestPrimeFactors(unittest.TestCase): def setUp(self) : self.datas = [...
e54523ce4dca08e0a889e4ee6eacfd40cbb340b2
FarzanAkhtar/Intro-to-Webd
/Week 1 Practice Problems/4.py
455
4.03125
4
#Commas in number def addcommas(a): for element in a: b=insertCommas(element) print(b) def insertCommas(a): a=a[::-1] b=[] for i in range(len(a)): b.insert(0,a[i]) if (i+1)%3 == 0: b.insert(0,",") if b[0] == ",": b.pop(0) return ("".join(b))...
1bf1d0861a73a3edfd37b16d8f330c827d5fd3e6
pranavdave893/Leetcode
/Trie/add_search_trie.py
3,903
4.0625
4
# class TrieNode(object): # def __init__(self): # self.children = {} # self.is_word = False # class Trie(object): # def __init__(self): # self.root = TrieNode() # def insert(self, word): # curr = self.root # for ch in word: # if ch not in curr.childr...
13256d65493cae1d1ca7302450edad65d42b7f4a
Italoko/Perceptron-de-Rosenblatt
/Perceptron.py
2,082
3.546875
4
import numpy as np import copy class Perceptron: def __init__(self): self.weights = [] self.bias = 1 #Soma Ponderada def net_activation(self,input): return np.sum(np.multiply(input,self.weights)) #Função Sinal def net_propagation(self,y): if y > 0 : ...
7ae849f28bd684e9cab3944a325f962698fd1b34
fjucs/107-VideoProcessing
/w1/guess.py
463
3.9375
4
import random, os def main(): random.seed('I\'m a random seed') cnt = 0 guess = int(random.randint(1, 100)) while True: cnt += 1 n = int(input('Please input a number: ')) if n > guess: print('Your number is greater than the secret number') elif n < guess: print('Your number is lesser than the secret...
4172b1a02c4f724230ce23c264cfac275cddeda3
TingeOGinge/UoP_Python_InClassTests
/Practical_1.py
2,404
4.28125
4
# Practical Worksheet 1: Getting started with Python # A kilgroams to pounds conversion program # Dillon O'Shea, up887062 # September 2018 #Displays "Hello, world" on the screen def sayHello(): print("Hello, world") #Displays integers from 1 - 10 def count(): for i in range(10): print(i+1) #Converts ...
c8a66620658f646aef29fdd821fec1466db23946
EdwinJUGomez/CDA_2021_EdwinJUGomez
/02-python/q03/question.py
805
3.703125
4
## ## Programación en Python ## =========================================================================== ## ## Para el archivo `data.csv`, imprima la suma de la columna 2 por cada letra ## de la primera columna, ordneados alfabeticamente. ## ## Rta/ ## A,37 ## B,36 ## C,27 ## D,23 ## E,67 ## ## >>> Escri...
2812f887cd5087a3c8cc274128a87fd72e1acfee
tyedge/holberton-system_engineering-devops
/0x16-api_advanced/1-top_ten.py
615
3.625
4
#!/usr/bin/python3 """ This module queries the Reddit API and prints the titles of the first 10 hot posts listed for a given subreddit """ import requests def top_ten(subreddit): """ This function returns the top 10 titles """ header = {'User-Agent': 'Agenty'} red = 'https://www.reddit.com/r/{}/hot.json?...
39d028123792a4ec5a551c930af69a6e2e53b706
nikhilbedi/BayesNetworkProject
/assign3.py
9,433
4.0625
4
# Objects: # Word (tuple): # - key: string word # - value: int count (3 or greater is treated the same) # WordProbability: # - string name # - Zero-Probability # - One-Probability # - Two-Probability # - Lots-Probability # Data Structures: # Spam email dictionary: # - filename of email as key # - list of Wo...
06c48e38506403a764b8c523c3133a3a462a3ec1
Giorc93/PythonCourse
/ExternalFiles/TextFiles/externalText.py
1,508
4.15625
4
# Obj: Data persistance # Opt1: External files # Opt2: DB # Procedure: # Create the external file. # Open the file # Manipulate the file # Close the file from io import open # First parameter file name, second parameter mode to open (read, write) textFile = open('file.txt', 'w') line = 'Great day to code Python \n...
1dbb395b81fadd952e0c1304cd5026714d4e6d21
chiderlin/Python_certification_practice
/1-9類練習/a508_最大公因數.py
229
3.9375
4
# -*- coding: utf-8 -*- """ Created on Mon Aug 17 21:01:46 2020 @author: user """ def compute(x,y): for i in range(1,y+1): if x%i==0 and y%i==0: sum=i return sum x,y=eval(input()) print(compute(x,y))
a22624f7db08088c66d10925d568c21bad036961
rafaelponte89/secure_python_dio
/class_13_generator_hash.py
819
3.703125
4
import hashlib import sys string = input('Text to code: ') menu = {'MD5':1,'SHA1':2,'SHA256':3,'SHA512':4} print('#'*20,'MENU GENERATOR HASH', 20 * '#') for key, values in menu.items(): print(values,')', key) string = string.encode() option = int(input('Choice algorithm hash: ')) hash = list(menu.keys()) menu = l...
8c5af5eb9b65dab1d15a84769a38a07c49b00b08
dattnguyen/Leetcode_exercises
/387. First Unique Character in a String.py
699
4.09375
4
# Given a string, find the first non-repeating character in it and return its index. # If it doesn't exist, return -1. #intuition is: you want a hashmap to keep track of the index, and a seen set #to keep track if the character already appears. def firstUniqchar(s): hmap = {} seen = set() #Unordered collection...
aa319f7c12f0dd5fecfb351d259a41ab6e1778f6
D-Katt/Coding-examples
/Advent_of_Code_2021/day_4_puzzle_2.py
2,707
3.796875
4
"""Advent of code: https://adventofcode.com/2021/day/4 Day 4 Puzzle 2 Bingo is played on a set of boards each consisting of a 5x5 grid of numbers. Numbers are chosen at random, and the chosen number is marked on all boards on which it appears. (Numbers may not appear on all boards.) If all numbers in any row or an...
4c7d36c53d981e41b878c99af9e161176d5fd295
raysmith619/Introduction-To-Programming
/exercises/turtle/onkey_up_down.py
525
3.59375
4
#onkey_up_down.py 12Dec2020 crs """ Simple turtle onkey example """ side = 100 from turtle import * def move(heading, dist): """ Move in heading direction :heading: heading in degrees :dist: distance to move """ setheading(heading) forward(dist) def up_key_pressed(): p...
4102eb978ee9a5f87747fe5ae3c142c1f641af73
victorsibanda/python-basics
/exercises/exercise_113_functions.py
806
3.796875
4
import math def add_fun(x,y): return x+y def subtract_fun(x,y): return x-y def multiply_fun(x,y): return x * y def divide_fun(x,y): return x/y def power(x,y): return x**y def area_of_circle(r) : result = math.pi * r**2 return result def area_of_square(x): result = x**2 r...
367627e89526357aaeea8d30f4e947db83a4a21d
LucasOJacintho/Curso_em_video_python
/Exercícios/ex34.py
340
3.75
4
sal = float(input('Digite o valor do seu sálario: ')) if sal > 1250: newsal1 = sal * 1.1 print('Seu salario de R$ {:.2f} teve o reajuste de 10 % e passa a ser R$ {:.2f}.'.format(sal, newsal1)) else: newsal2 = sal * 1.15 print('Seu salario de R$ {:.2f} teve o reajsute de 15 % e passa a ser R$ {:.2f}.'.fo...
fb871f810701bc7a889a5517f0a8010887f1d24f
PauloLima87/CEVP_Desafios
/Desafio 63 - Fibonacci 1.0.py
286
3.75
4
print(f'{"-"*30}\n{"Sequencia de Fibonacci":^30}\n{"-"*30}') n = int(input('Quantos termos deseja mostrar? ')) t1 = 0 t2 = 1 cont = 2 print(f'{0} - {1}', end='') while cont < n: aux = t1 + t2 print(f"\033[m - {aux}", end="") t1 = t2 t2 = aux cont += 1 print('- FIM')
0ba3e36988e3f95053d669a6dd13b7fffae5b7d8
DidiMilikina/DataCamp
/Machine Learning Scientist with Python/16. Introduction to Deep Learning with Keras/03. Improving Your Model Performance/07. Batch normalizing a familiar model.py
1,446
4.28125
4
''' Batch normalizing a familiar model Remember the digits dataset you trained in the first exercise of this chapter? A multi-class classification problem that you solved using softmax and 10 neurons in your output layer. You will now build a new deeper model consisting of 3 hidden layers of 50 neurons each, using ba...
34716166eeba34e93d76280c3c52ab6aad8510fe
WUST-FOG/gnlse-python
/examples/plot_input_pulse.py
1,426
3.53125
4
"""Calculates envelopes of various pulses and plots them. Based on the chosen envelopes pulse, the aplitude envelope is calculated and shown on the graph. There are three available envelopes pulses models: hyperbolic secant, gaussian and lorentzian. """ import numpy as np import matplotlib.pyplot as plt import gnlse ...
69c6ed5215bcdf961d5e1f0e14de569a46556c12
nextco/sha1-bruteforce
/SHA1.py
1,886
3.65625
4
# Python 2.7 x86 # Simple SHA1 Bruteforce work with dictionary of numbers, the length of the password is known # by @rextco from functools import reduce import hashlib import itertools TARGET_HASH = "42d0815e3262dcfec1756092959bb4b0f2ac118b" # SHA1 to broke TARGET_LENGTH = 6 ...
b86a5f418f38abbb8d5d9d76dc3ee4df08311b1a
ramkodgreat/python1
/literals.py
425
4.0625
4
#String Literals # String literals are used to inject variables into our statements #Referencing strings and integer variables using modulus symbol # %d for referencing intigers # %s for strings # %s can be used for both strings and integers % # %f for integers and adding additional decimals to the integer age = 70 p...
e96be1b48ce8e1c9c8ecc2df9e28ce498e790aab
thisismsp78/PythonCodsLearn
/p1/LoopDemo/LoopDemo.py
72
3.5625
4
number=0 while number<=100: print(number) number=number+1
24e38aeb6582bc3aa0ba8e3eafd48320d036cfae
yanboyang713/crossLanguageSentimentAnalysis
/heatmap/test.py
108
3.53125
4
import math num = -0.8 print ("return = ", math.floor((num + 1) * 10) - 1) print ("= ", (num + 1) * 10 - 1)
f736333686094e5138dcb1fc19de065524b54d8c
mosdef-hub/foyer
/foyer/element.py
1,589
3.78125
4
"""Element support in foyer.""" import openmm.app.element as elem class Element(elem.Element): """An Element represents a chemical element. The openmm.app.element module contains objects for all the standard chemical elements, such as element.hydrogen or element.carbon. You can also call the static meth...
c5cb92e78e2a43e0cd18df63e6b68c32066d2015
tejasphirke/Visualizing-World-Cup-data-
/Visualizing World Cup Data With Seaborn.py
1,838
3.53125
4
# Visualizing World Cup Data With Seaborn ''' Visualizing World Cup Data With Seaborn For this project you will be exploring data from the Fifa World Cup from 1930-2014 to analyze trends and discover insights about the world’s game, fútbol! This Fifa World Cup data is from Kaggle. Kaggle is a platform for data sc...
884f7101692047f1c255bffd63e69e2b6460579a
jorjishasan/Python-for-Fun
/Calender_by_python.py
118
3.875
4
import calendar as clnd year=int(input('Enter year: ')) month=int(input('Month: ')) print(clnd.month(year,month))
effb302160b122d8dc0a34e6d1303fa5dc866e0d
sgh8539/TIL
/01_python 0102/ex.py
431
3.515625
4
# def printer_error(s): # k = 'abcdefghijklm' # b = len(s) # a = len([i for i in range(len(s)) if i not in k]) # return f'{a}/{b}' # printer_error("aaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbmmmmmmmmmmmmmmmmmmmxyz") k = 'abcdefghijklm' s = 'aaaxxx' print ([i for i in s if i not in k]) b = s.count('a...
047010a194cfc57c10b69b835eb5c5485757a66a
Maarico/python_stuff
/primechecker.py
536
4.03125
4
import math def divisible(sus, div): sec=1 while sec*div<sus: sec+=1 if sec*div==sus: return(True) else: return(False) def checkprime(susp): divisor=2 while divisor<=math.sqrt(susp): if divisible(susp,divisor): return False else...
22127c6184a66b8cc58f87817763183b3d6ce6c4
Jsato-eng/tutorialPython
/test.py
167
3.609375
4
import sys print(sys.version) #print('hello world!') num = [] for i in range(3): num.append(i) tap = (0, 1, 2) dic = {"a": 0, "b": 1, "c": 2} print(type(tap))
f0c8e8c2b2406dec031914bf3c0ff202c73e3e6c
andremenezees/CursoPython
/Aulas/2_Meio/Len, Sun, Abs_e_Round.py
1,063
4.125
4
""" Len, Abs, Sum, Round #Len len() -> Retorna o tamanho (ou seja, o numero de itens) de um iteravel. abs() -> Retorna o valor absoluto de um numero inteiro ou real. Ou seja o modulo somente o numero independente do sinal. sum() -> Retornar a soma dos valores. É possivel receber um valor inicial com sum. round() -...
80d10bafcc5ce8569214d026e88569e00f9b21c5
dominicwllmsn/thinkpython
/exercises/chapter7/ex72.py
205
4.1875
4
def eval_loop(): result = None while True: string = input('Please input the expression: ') if string == 'done': print('Done!') return result result = eval(string) print(result) eval_loop()
44fe0adc4e51d42421a190296e43b18c5d141011
Ordauq/Learning_PyNEng
/completed_exercises/06_control_structures/task_6_2a.py
1,698
3.640625
4
# -*- coding: utf-8 -*- ''' Задание 6.2a Сделать копию скрипта задания 6.2. Добавить проверку введенного IP-адреса. Адрес считается корректно заданным, если он: - состоит из 4 чисел разделенных точкой, - каждое число в диапазоне от 0 до 255. Если адрес задан неправильно, выводить сообщение: 'Неправильный IP-ад...
f434820066acf916ea1103eab64966acecafb943
landonmatak/Lab5
/Activity2.py
2,415
3.921875
4
# By submitting this assignment, I agree to the following: # "Aggies do not lie, cheat, or steal, or tolerate those who do" # "I have not given or received any unauthorized aid on this assignment" # # Name: Nathaniel Michaud, Luca Maddaleni, Landon Matak, Anthony Matl # Group: 8 # Section: 2...
14c6e553c221acddd20aff25266ac6a3e180dc63
mfrankmore/oop-mfrankmore
/finalProj/container.py
967
3.859375
4
class Container: containerTypes = {"Small Box" : [4, 4, 4], "Medium Box" : [8,4,4], "Large Box" : [8,8,4]} DEFAULT_CONTAINER_TYPE : str = "Medium Box" def __init__(self, containerType : str = DEFAULT_CONTAINER_TYPE): self._containerType = containerType @property def containerType(self) -> ...
3fbcfc2703cb69d348e12d28a2dfdfc9ef6d12f8
qhahd78/Programming_Basic
/W6/menu.py
182
3.671875
4
def menu_list(item): option = 1 for choice in item: print(str(option)+". "+ choice) option = option + 1 print(str(option)+ ". Quit") return option
1d19b35cf8a2bf61c0618721a147635c7a44e33c
EduardoArgenti/Python
/CursoEmVideo/aula06.py
201
4.03125
4
# is.numeric() verifica se o conteúdo da string pode ser convertido para número num = '3' palavra = 'Olá' decimal = '5.2a' print(num.isnumeric()) print(palavra.isnumeric()) print(palavra.isalpha())
1d4eda8ce23bcd54bf0b55df87da83fa82e2cf12
nd9dy/Algorithmic-Toolbox
/Algorithm Toolbox/Week 2 Code/Fibonacci Last Digit Sum.py
559
4.03125
4
# Uses python3 import sys def fibonacci_sum_naive(n): list = [0, 1, 1] if n < 2: return n else: i = 3 while True: if list[i - 1] == 1 and list[i - 2] == 0: break new = (list[i - 1] % 10) + (list[i - 2] % 10) real = new % 10 ...