blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a6d40cc0cfd1a5e6d7cdc79a9891e0e8bbd7370d
dipeshwor/draw2codeOpenCV
/overlayOpenCV.py
1,760
3.5625
4
# import the necessary packages import imutils import numpy as np import cv2 # load the watermark image, making sure we retain the 4th channel # which contains the alpha transparency watermark = cv2.imread('images/colorOutline.png', cv2.IMREAD_UNCHANGED) watermark = imutils.resize(watermark,width=200) (wH, wW) = water...
2557da2c97f3f128391c06bca07d628ceab5fcb6
Hatlelol/ITGK
/Øving 2/Årstider.py
776
3.609375
4
dato = int(input("Skriv en dato")) month = input("Skriv inn måned") month = month.lower() aar = ["januar", "februar", "mars", "april", "mai", "juni", "juli", "august", "september", "oktober", "november", "desember"] for x in range(0, len(aar)): #lager en for løkke for å bestemme måneden med et tall i...
9979be936956b9d246dddb2d5a6c7edb0e11a073
danielmmetz/euler
/euler041.py
727
4.03125
4
""" We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime. What is the largest n-digit pandigital prime that exists? """ from prime import isprime from itertools import permutations from functools import red...
28b48d37c3ec17bf2fdedee4bebbd8d82ff5d710
zhongmb/suanfa
/leetcode/2.py
2,107
3.859375
4
''' 给出两个 非空 的链表用来表示两个非负的整数。其中,它们各自的位数是按照 逆序 的方式存储的,并且它们的每个节点只能存储 一位 数字。 如果,我们将这两个数相加起来,则会返回一个新的链表来表示它们的和。 您可以假设除了数字 0 之外,这两个数都不会以 0 开头。 示例: 输入:(2 -> 4 -> 3) + (5 -> 6 -> 4) 输出:7 -> 0 -> 8 原因:342 + 465 = 807 ''' # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x ...
50023b3a0576fb33bfb518fcc57d0155f2dd9c99
gabriellaec/desoft-analise-exercicios
/backup/user_029/ch99_2019_11_27_18_22_58_478287.py
208
3.515625
4
def login_disponivel(x,usuarios): for i in range(len(usuarios)): if x in usuarios: usuarios.append(x+'1') return usuarios if x not in usuarios: return x
067be42e51eb207eb9ac916be4468fc73bb0170e
Rutrle/algorithms
/recursions/string_reverse.py
251
3.921875
4
def recursice_reversal(rec_string: str) -> str: if len(rec_string) == 0: return '' last_letter = rec_string[-1] rec_string = rec_string[:-1] return last_letter+recursice_reversal(rec_string) print(recursice_reversal('tree'))
99cb3648b7b53d40e9eadf73cb90663ce99a57bb
ingenierodevops/Tic-Tac-Toe
/Problems/The farm/main.py
730
3.96875
4
precios = {'sheep': 6769, 'cow': 3848, 'pig': 1296, 'goat': 678, 'chicken': 23} def print_animals(dinero, animal_name): number = int(dinero / precios[animal_name]) if number > 1: if animal_name != "sheep": print(number, animal_name + "s") else: print(number, "sheep") ...
8480bdd55e1b116e30d18c390de607ca0ac291c1
rohan-khurana/Algorithms
/LeetCode_Monthly_Challenge/July/Python3/Week_4/Binary Tree Zigzag Level Order Traversal.py
1,086
3.90625
4
""" PROBLEM: Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). For example: Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 return its zigzag level order traversal a...
dae5b29394b1e73dc4feba996bf64e2b90f7ee29
pikriramdani/p7_labspy03
/latihan2.py
483
3.859375
4
#file tugas Latihan 2 - praktikum 3 print("Tugas Pertemuan 7 - Praktikum 3 - Latihan 2 ") angka=0 while True: bilangan = int(input("Masukan Bilangan : ")) if (angka < bilangan): angka=bilangan if (bilangan == 0): break print("Bilangan terbesar adalah: ",angka) print() print("============...
429f60d1a631df3b6169703f338cc582a821df50
stefifm/guia05
/ordenar nros.py
787
4.09375
4
print ("Ordenar 3 números") n1 = int(input("Ingrese N1: ")) n2 = int(input("Ingrese N2: ")) n3 = int(input("Ingrese N3: ")) if n1 >= n2 and n1 >= n3: mayor = n1 if n2 > n3: medio = n2 menor = n3 else: medio = n3 menor = n2 elif n2 >= n1 and n2 >= n3: mayor = n2 if n...
d6832a198421c41d1206719719f20877078bc29d
MadaooQuake/Pinko
/core/core.py
1,302
3.5625
4
# -*- coding: utf-8 -*- import pygame from collision import Collision from objects.cir import Circle from controls import Control class Screen: screen_width = 1024 screen_height = 576 move_available = True; def __init__(self): pygame.init control = Control() screen = py...
6a22e610d0bd1567be709a2af20d9dda84a15fe0
Marytem/UCU_Courses
/programming_basics/incertion sorting.py
410
3.640625
4
def insertion_sort(lst): for i in range(1, len(lst)): tmp = lst[i] j = i - 1 while tmp < lst[j] and j > -1: lst[j + 1] = lst[j] j -= 1 lst[j + 1] = tmp return lst import random import math print(100000*100000) print(int(100000*math.log(10...
180d9bf45fd0a73bf358af1ac8a0de031670430c
xiaotian1991/actual-10-homework
/04/tantianran/function_home_work.py
1,470
3.859375
4
#!/usr/bin/env python def menu(): print 'Registration: 1. Landing: 2' number = raw_input('Please select the operating:') return number def work(n): f = open('userpassword.txt') passwd = {} for i in f.readlines(): tmp = i.split(':') passwd[tmp[0]] = tmp[1] while T...
8233621e317efeb5c134e0c50a3b2bfb7985f6dd
BlazeBreaker-code/A.I.Exploration_Robots
/FinishedA.I.Project_Rooker/algo.py
9,945
3.859375
4
import sys, os, random os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide" import pygame pygame.init() BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREY = (211, 211, 211) GREEN = (0, 255, 0) RED = (255, 0, 0) WINDOW_HEIGHT = 1000 WINDOW_WIDTH = 1000 robots = [] spots = [] movement = ['N', 'NE', 'E', 'SE',...
e7bbd1f5bd55f8c5bd77fc5121432e30d10be53b
chethan-kt/Python-Exercises
/q44.py
467
3.984375
4
""" Question: Define a class named American which has a static method called printNationality. Hints: Use @staticmethod decorator to define class static method. """ class American: def __init__(self, name): self.name = name def printName(self): print self.name @staticmethod ...
47a5fd83a313fdf2c098e948bab0db783ef5bc8f
yibeihuang/LeetCode
/wordladder.py
1,155
3.671875
4
__author__ = 'yibeihuang' def construct_dict(word_list): d = {} for word in word_list: for i in range(len(word)): s = word[:i] + "_" + word[i+1:] # tmp = d.get(s, []) dict.get(key, default=None), # default is the Value t...
0f3273d0c46be8f11fc723b40e290d025ce41f11
Sakariyeyare/ZY-ZAKI
/cal.py
4,287
3.796875
4
from tkinter import * root=Tk() root.title("Calculator") #functions text_input = StringVar() operator='' def button_click(numbers): global operator operator = operator + str(numbers) text_input.set(operator) def button_clearDisplay(): global operator operator ='' text_input.se...
a2e8a459047b57a854e6e7513b204cdb96dd96f3
IgorProninP/Codewars
/range_extraction.py
1,395
4.65625
5
""" A format for expressing an ordered list of integers is to use a comma separated list of either individual integers or a range of integers denoted by the starting integer separated from the end integer in the range by a dash, '-'. The range includes all integers in the interval including both endpoints. It is not co...
a5db9fd26eb9545e406d36be36477fa52082e13b
chaksamu/python
/venv/dict.py
1,300
3.640625
4
Dict = {'Tim': 18,'Charlie':12,'Tiffany':22,'Robert':25} print (Dict['Tiffany']) Dict = {'Tim': 18,'Charlie':12,'Tiffany':22,'Robert':25} print((Dict['Tiffany'])) Dict = {'Tim': 18,'Charlie':12,'Tiffany':22,'Robert':25} Boys = {'Tim': 18,'Charlie':12,'Robert':25} Girls = {'Tiffany':22} studentX=Boys.copy() studentY=...
f17bfb2851d61d7fdd1acfabb07cb9e0a9730424
bema97/home_work
/ch2task_3.py
117
3.953125
4
number = int(input("Please, enter a number: ")) previous = number - 1 next = number + 1 print(previous, number, next)
5a696eb6bafe109af3ad7e2ba972fd2bdbc7ed1f
lordjuacs/ICC-Trabajos
/Ciclo 1/Examen 3/27busqueda_binaria_numero_comparaciones.py
910
3.75
4
def busquedaBinaria(Lista, item): low = 0 high = len(Lista) - 1 comparacion = 0 encontrado = False while (low <= high) and not encontrado: mid = low + (high - low) // 2 if Lista[mid] == item: comparacion += 1 encontrado = True else: if item...
1b264907d11eaa4f392456bb05f2f0bc7a4ec57d
brrgrr/LC101_Unit1
/chapters/chapter8_excercises.py
8,430
4.0625
4
#1 def print_triangular_numbers(n): sum=0 for i in range(n): sum += (i+1) print(sum) def main(): print_triangular_numbers(5) if __name__ == "__main__": main() #2 import random import turtle def is_in_screen(screen, t): left_bound = - screen.window_width() / 2 right_bound = sc...
a6a963b7e4503c9cdac63efdcd034483c383f325
TverskayN/The_invasion_of_the_cats
/spray.py
2,061
3.59375
4
import pygame from pygame.sprite import Sprite class Spray(Sprite): """Класс реализующий действия пульверизатора (пульвика).""" def __init__(self, ai_setting, screen): """Инициализирует пульвелизатор и задает его начальное положение.""" super(Spray, self).__init__() self.screen = scr...
878a14db796af689ae9e2fd8a71392427536d833
jianghan0001/python
/FishC/regist and login.py
1,430
4.0625
4
#用dict建立账号及登录系统 user_data={} def new_user(): promp = 'Please enter username' while True: username=input(promp) if username in user_data: print ('username has already been used.') continue else: break psw= input('Please set you password') user...
0121b869d89763148c8a92b7fb2806ff5d58cbd2
youngcadam/leetcode
/problem5.py
3,866
3.5
4
'''approach 1 class Solution: def longestPalindrome(self, s: str) -> str: max_len = 0 curr_len = 0 max_substr = "" length = len(s) if length == 0: return "" if length == 1: return s[0] elif length == 2: if...
362ee858aa13aa4ee9df941b5185a921badb555b
ramanenka/cormen
/foundations/test_merge_sort_with_insertion_sort.py
534
3.578125
4
from merge_sort import merge_sort from insertion_sort import insertion_sort from merge_sort_with_insertions_sort import merge_sort_with_insertions_sort import random import time a = [random.random() for i in range(100000)] a1 = a[:] start = time.time() merge_sort(a1, 0, len(a1) - 1, 0) print(time.time() - start) # a...
1e2ea827fe6273131dc841c3fcbe9a90de98404a
alvesdealmeida/Projeto_Python_TSC_UFF
/AD2Q2.py
1,887
3.71875
4
import struct def processarArquivo(nomeArquivo,resultadoSorteio): print("Conteúdo do Arquivo de Apostas",nomeArquivo+":") totalApostas = 0 acertos = dict() for qtdAcertos in range(3, 9): acertos[qtdAcertos] = set() with open(nomeArquivo, "r") as arquivo: for linha in ar...
2f5a967bd6e64ee5776fcc63f6db22bca2aadd53
jameschenmech/Deep_Learning_Keras
/keras_intro.py
6,506
3.828125
4
# -*- coding: utf-8 -*- """ Created on Wed Mar 14 09:36:08 2018 @author: junch """ # ============================================================================= # #Forward propagation with one hidden layer # ============================================================================= import numpy as np input_data ...
ff335cc32fa9d4af33b39e95c41fd9ddbc35555d
imgomez0127/daily-programming
/interview-questions/dip3.py
529
3.65625
4
class Solution: def longestPalindrome(self, s): cur_max = "" string_length = len(s) for i in range(string_length): for j in range(string_length): reversed_string = "".join(reversed(s[i:j])) if s[i:j] == reversed_string and len(reversed_string) > l...
381471abaa18c629ae53bbcfa3bbe52e66dd933c
Bryant6/deep-learning
/numpy_pandas/numpy_study.py
3,014
3.59375
4
import numpy as np # ==================================================== # numpy 的基本属性 # ==================================================== array = np.array([[1, 2, 3], [2, 3, 4]]) print(array) print("number of dim: ", array.ndim) print("shape: ", array.shape) print("size: ", array.size) # =======...
066099065c374b37028d76a785e7918f69139dae
jade0304/python-exercise
/34_same_frequency/same_frequency.py
1,122
3.65625
4
def same_frequency(num1, num2): """Do these nums have same frequencies of digits? >>> same_frequency(551122, 221515) True >>> same_frequency(321142, 3212215) False >>> same_frequency(1212, 2211) True """ # my own result: count = {} c...
07f80a37a99f83fdc2db51b6d2ca44c1666dec13
lillelarsen/python-crash-course
/dictionaries.py
810
4.03125
4
# A Dictionary is a collection which is unordered, changeable and indexed. No duplicate members. # Create dict person = { 'first_name': 'John', 'last_name': 'Doe', 'age': 30 } print(person, type(person)) # # Use constructor # person2 = dict(first_name='Sara', last_name='Williams') # Get value print(perso...
e03316571a6cea5ec355878c8e5183cbde76bfda
lumecre/tema_8
/8.1_unit_converter.py
468
3.84375
4
#programa realizado para una trasformacion de km a millas trans= int(raw_input("introduce los km: ")) miles= trans * 1.6 print str(trans) + " km son " + str(miles) + " millas " ask= int(raw_input("desea hacer otra conversion, si o no? : ")) if trans= int(raw_input("introduce los km: ")) miles= trans * 1.6 print...
ac4efbba9de2f9687a4668a5dad1c63459c490b6
parkourben99/SpeedOfPi
/lib/timer.py
502
3.609375
4
import time class Timer(object): def __init__(self): self.__start_time = 0 self.__end_time = 0 def start(self): self.__start_time = time.time() def stop(self): self.__end_time = time.time() total_time = self.__calc_total_time() self.__reset() ret...
8f29e973d0d2b7c57464f7dc9afe08607372d747
Xaaris/Hauptprojekt
/src/lp_validation/LPValidationNetWithDataAugmentation.py
3,000
3.84375
4
""" Trains a simple convnet on images to determine if they show a full license plate or not. To enhance the training effect on the relatively small data set, data augmentation is used Based on https://blog.keras.io/building-powerful-image-classification-models-using-very-little-data.html """ import os import keras imp...
9ddf7f4a9c468ea2b9c958f1fcf222cb213437dd
merimus/coding-bootcamp
/euler/merimus/21/21.py
425
3.515625
4
def divisors(n): # return list (numbers less than n which divide evenly into n) return [i for i in range(1, (n+1)/2+1) if n % i == 0] d_mem = dict() def d(n): if n in d_mem: return d_mem[n] d_mem[n] = sum(divisors(n)) return d_mem[n] def isAmicable(n): a = d(n) if a == n: ...
8cb0330f88caaf8c95f6889d02176ee68caf4dc4
SeanyDcode/codechallenges
/dailychallenge1014.py
735
3.6875
4
# from dailycodingproblem.com # # Daily Challenge #1014 # Given a start word, an end word, and a dictionary of valid words, find the shortest transformation sequence from start to end such # that only one letter is changed at each step of the sequence, and each transformed word exists in the dictionary. If there is no ...
b3562fd813f7a871b60aa1d8ddf876ff1a527cd2
gokou00/python_programming_challenges
/codesignal/extractMatrixColumn.py
296
3.65625
4
def extractMatrixColumn(matrix, column): arr = [] for i in range(len(matrix)): for j in range(len(matrix[i])): if j == column: arr.append(matrix[i][j]) return arr print(extractMatrixColumn([[1,1],[5,0],[2,3]] ,0))
55c8283ff65ffeabec04fba48efc62f111af535f
newfull5/Programmers
/다음에 올 숫자.py
147
3.53125
4
def solution(common): a,b,c = common[:3] if a-b == b-c: return common[-1] + (b-a) else: return common[-1] * (b/a)
4663c637185ad0717e840cde573f8b7ac251ef26
sikami/Python-3
/ass_85.py
433
3.984375
4
#open file and read #if name starts from 'From ', extract 2nd word #print words a = input() if len(a) < 1: a = "mbox-short.txt" fname = open(a) count = 0 emails = list() for line in fname: if line.startswith("From "): words = line.split() emails.append(words[1]) count += 1 for email ...
ba0846beebba9c04f8c767efc186ba695512500c
huantar/projet_algo_texte
/model/distancePage.py
1,231
3.578125
4
# Nous avons decide d'utiliser la distance de hamming, # car aprés plusieurs test c'etait l'algo le plus rapide ######## hamming ######## # Calcule la distance de hamming entre deux string et retourne sa valeur def dist_hamming(m1,m2): d = 0 for a,b in zip(m1,m2): if a != b : d += 1 ret...
1d66aff9f95c8381ab58ff8f583e85cf612a74f4
Aman-dev271/Pythonprograming
/33th_decoratorss.py
997
4.21875
4
""" def function(): print("subscribe now Tech Aman") fun1 = function del function fun1() def fun_returner(num): if num== 0: return print if num == 1: return sum a = fun_returner(0) print(a) # function as an argument we also can use def fun_as_argument(aman): ...
4783bf7e2627fad4b3b0852f9877ab8ab96ec5ad
alihusain120/InterviewProbs
/ParkingLot.py
2,467
3.890625
4
# Parking Lot program # # class ParkingLot: def __init__(self, maxCapacity): self.maxCapacity = maxCapacity self.currentCapacity = 0 self.spaces = [None] * maxCapacity def isFull(self): return self.maxCapacity == self.currentCapacity def park(self, Vehicle): ...
6512d38a8be8094b9efce349848918bd92af1bb9
h2r/slu_core
/tools/esdcs/python/esdcs/gui/esdc_utils.py
796
3.578125
4
def highlightTextLabel(label, esdc): """Change the label text to highlight a single esdc""" start, end = esdc.range labelText = (esdc.entireText[0:start]+ "<b>" + esdc.entireText[start:end] + "</b>" + esdc.entireText[end:]) label.setText(labelText) def highlightTextLa...
eeb0448fd4232fb7ae5c7e8f11c513cc63fec50b
khushboo1510/leetcode-solutions
/30-Day LeetCoding Challenge/April/Medium/201. Bitwise AND of Numbers Range.py
783
3.515625
4
""" https://leetcode.com/problems/bitwise-and-of-numbers-range/ Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive. """ class Solution: def rangeBitwiseAnd(self, m: int, n: int) -> int: if m == 0 or m == n: return m ...
afdeb97ad4e3df7ca77b3d757a25d368a72254d6
tehs0ap/Project-Euler-Python
/Solutions/Problems_20-29/Problem_25.py
825
3.78125
4
''' Created on 2012-12-06 @author: Marty ''' ''' The Fibonacci sequence is defined by the recurrence relation: Fn = Fn1 + Fn2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 F6 = 8 F7 = 13 F8 = 21 F9 = 34 F10 = 55 F11 = 89 F12 = 144 The 12th term,...
3d784eaf6f8682d78898a19a465577a831984109
mohit3wadhwa/2021
/speech_v3.py
2,121
3.953125
4
# #import library # import speech_recognition as sr # # Initialize recognizer class (for recognizing the speech) # r = sr.Recognizer() # # Reading Audio file as source # # listening the audio file and store in audio_text variable # with sr.AudioFile('audio.wav') as source: # audio_text = r.listen(source) ...
bbdf13926fa9271af0b089e21656964723700948
ninja0109/Project-Euler-Solutions
/Problem 5-Smallest multiple.py
387
3.65625
4
#2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. #What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? def lcm(m,n): if m>n: i=n while i%m!=0: i+=n print(i) else: i=m while i%n!=0: i+=m print...
16740fcfeda2464613cddd6f521bcf079c3b22e6
qingdongPeng/py_test
/test/object/create-class.py
431
4.0625
4
#!/usr/bin/env python # -*- coding:utf-8 -*- ##创建类 ## python 是动态语言, 对于每一个实例, 可以直接给他们的属性赋值 class Student(object): pass xiaoming = Student() xiaoming.name = "xiaoming" xiaohong = Student() xiaohong.name = "xiaohong" xiaoqiang = Student() xiaoqiang.name = "xiaoqiang" list = [xiaoming, xiaohong, xiaoqiang] for a...
149d3db8da0d885c86d43f10f375a5a85e81a65b
MuhammadHafizhRafi/Muhammad-Hafizh-Rafi-Susanto_I0320065_Abyan_Tugas7
/I0320065_Soal1_Tugas7.py
688
3.984375
4
#count print("==============count=================") str = "Selamat Idul Fitri" sub = "a" print ("str.count(sub, 4, 16) : ", str.count(sub, 4, 16)) sub = "an" print ("str.count(sub) : ", str.count(sub)) #center print("==============center=================") str = "Makan opor saat Idul Fitri" print ("str...
6c759be45095d8cb38dd44aeab624e4f388946d0
WalmsleyIsRad/prg1_homework
/practice_code/greet.py
621
3.875
4
''' def message(recipient,sender): print("Hello, "+recipient+ " How are you? What is up?") print("-"+sender) student = "Patrick Walmsley" teacher = "Mr. Gold" message(student,teacher) ''' #write a function that will tell you if a number is in the range of two other numbers def number_in_range(low,high,numb...
62da756cb87760c5f87ff54e1c902e0091a576dc
zabdulmanea/100DaysOfCode
/day11_saudidevorg.py
724
4.46875
4
# Python Operators - part 2 # Logical Operators x = 5 print("Logical Operators (x = 5):") print("(x < 6 or x > 7)?", x < 6 or x > 7) print("(x < 6 and x > 7)?", x < 6 and x > 7) print("not(x < 6)?", not(x < 6)) print("---------------------------------------------") # Identity & Membership Operators x = [1, 3] y = [1,...
14f9b252cc1f9e088ac47864017906c399d0945a
WoodyLuo/PYTHON
/Lecture08/ex03_printList.py
257
4.15625
4
''' Exercise03 - printList Functions. Chung Yuan Christian University written by Amy Zheng (the teaching assistant of Python Course_Summer Camp.) ''' def printList(lst): for element in lst: print(element) lst = [3, 1, 2, 6, 4, 2] printList(lst)
78c94454f1284ee2fe8c8ac0d8a0ebd3dd6e6f72
Dipen-Dedania/tensorflow-playground
/03_tensor_mul_2.py
1,017
3.703125
4
import tensorflow as tf # A feature that is convenient to use when we want to explore the data content of an object is # tf.InteractiveSession(). Using it and .eval() method, we can get a full look at the values # without the need to constantly refer to the session object # Initialize two constants x1 = tf.constant([...
934433148038ddb73f1b3b5049570cb279af84c1
marquesarthur/programming_problems
/interviewbit/interviewbit/math/grid_unique_paths.py
421
3.546875
4
class Solution: fact = {} def factorial(self, n): x = 1 for i in range(1, n + 1): x *= i return x # @param A : integer # @param B : integer # @return an integer def uniquePaths(self, A, B): x = A + B - 2 right = A - 1 down = B - 1 ...
f8e809c6922d4c4d835125d2a84ad150fbdb44a2
gaurihatode23/Assignment-1
/Task7.py
4,135
3.8125
4
#Question1 of Task 7 class calculate(): def __init__(self,C,H): self.C=C self.H=H def formula(self,D): return ((2*self.C*D)/self.H)**2 D=int(input("Enter the value of D")) obj1=calculate(50,30) Q = obj1.formula(D) print(Q) #Question2 of Task 7 class Shape(): def __init__(sel...
cef5e401880844bdfe6fa6fa80778f31554d8963
midephysco/midepython
/forloop004.py
251
4.1875
4
password = "" while password != "secret": password = input("Please enter your password: ") if password== "secret": print("Thank you. You have entered the correct password") else: print("Sorry the value entered is incorrect")
6413e198992dca44160d4a4e2cadf0d9f3e45326
Wiserlightning/Blackjack-game
/BlackJack in python.py
4,710
3.671875
4
import os import random the_deck = [2,3,4,5,6,7,8,9,10,11,12,13,14]*4 def deal(the_deck): hand = [] for i in range(2): random.shuffle(the_deck) card= the_deck.pop() if card==11: card1 = 'Jack' if car...
c9c139f363fa80c39b7291a15f031c7afa4048eb
qiaobilong/Python
/Learn_Python3_The_Hard_Way/ex34.py
161
3.734375
4
lists = [1,2,3,4,5] def my_list(lists): for i in range(len(lists)): print(f"index:{i} - ",end = "") print(lists[i]) pass my_list(lists)
85c28395bdce4329171677609ab6a0733a805d1d
fabiorfc/Exercicios-Python
/Python-Brasil/1-EstruturaSequencial/ex_15.py
1,413
4.125
4
# -*- coding: utf-8 -*- """ 15 - Faça um Programa que pergunte quanto você ganha por hora e o número de horas trabalhadas no mês. Calcule e mostre o total do seu salário no referido mês, sabendo-se que são descontados 11% para o Imposto de Renda, 8% para o INSS e 5% para o sindicato, faça um programa que nos dê...
ef851f6f1a17eacfe0489d9bc5954d39066588a1
GHIaayush/Phylogenetic-Tree
/phylo.py
8,180
3.671875
4
#importd the genome file from genome import* #imports the tree file from tree import* """ File:phylo.py Author: Aayush Ghimire, Date:05/2/2018, Purpose: To construct phylogenetic trees starting from the genome sequences of a set of organisms. """ """ This function ask the user for the input f...
9db91562129ba71e331a1e05bd4ccd25c04f6b4a
YasminLN12/Mision_02
/cuenta.py
382
3.8125
4
# Autor: Yasmín Landaverde Nava, A01745725 # Descripcion: Este programa calcula el costo total de la comida incluyendo la propina e iva. stotal = int(input("¿Cuánto fue el total de su cuenta?: ")) prop = stotal*.13 iva = stotal*.16 print("Costo de su comida: $", "%.2f" % stotal) print("Propina: $", "%.2f" % prop) prin...
efce3a47e104c82d46a23889b72e14f3ca0003aa
islami00/csc102
/class4/problem17/sumAgainClass.py
351
3.828125
4
# You ar presented with the scores of 4 students in your department. Among the task that is expected of you on the # student scores are as follows: #1. get score from students number = 4 scores = [int(input("Enter a number: ")) for x in range(number)] # 2. compute sum sum_Scores = sum(scores) # 3. compute average avg_...
4fde366610d69b95e54c0e7559212c87780270a2
jinwoov/hacktoberfest
/Scripts/random_print_of_helloworld.py
834
3.78125
4
# Aim: print each letter of 'hello world' in order and in random points in time # How: printing letter based on whether the ascii code of each letter appears in the milliseconds of the current time # get the characters of the phrase in ascii code and put them in a list helloworld = 'hello world' in_ascii = [] for i in...
f690a0c653395cfdf5aeecc8737fa231985e930e
adarshadrocks/pyhonActivities
/swapping.py
192
3.703125
4
#!/usr/bin/python '''swapping of two no.s''' x=raw_input("enter the first no.") y=raw_input("enter the second no.") x,y=y,x print "after swapping" print "first no. :"+x print "second no. :"+y
605318247bbd4eec3afff53be397ffd6a26227eb
MrNullPointer/Python-Basics
/fib.py
215
4.0625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Feb 2 16:25:20 2020 @author: parikshitdubey """ def fib(x): if x == 1 or x == 0: return 1 else: return fib(x-1) + fib(x-2)
6b2f7cc3221c0865b509c77efed9d59526efae3e
maroro0220/Rassberry_python_device
/calculator_per.py
666
3.75
4
class Calculator: def __init__(self,lis): self.tot=0 self.lis=lis def sum(self): self.tot=sum(self.lis) print(self.tot) def avg(self): if self.tot!=0: self.av=self.tot/len(self.lis) else: ...
72e7a94b85a4e57d00b106ddcaa8b61a579df1e9
pb0528/codelib
/Python/lesson/list.py
487
3.6875
4
def main(): fruits = ['grape', 'apple', 'strawbery', 'waxberry'] fruits += ['pitaya', 'pear'] # 循环遍历列表元素 for iterm in fruits: print(iterm.title(), end='') print() #列表切片 fruits1 = fruits[1:4] print(fruits1) def reduces(): #用range 生成列表 list1 = list(range(1,11)) print...
87ebd7a7fc2ebac23c005ac730a0fb82875f14e2
alanaalfeche/python-sandbox
/rosalind/python_village/INI3.py
598
3.84375
4
""" Given: A string s of length at most 200 letters and four integers a, b, c and d. Return: The slice of this string from indices a through b and c through d (with space in between), inclusively. In other words, we should include elements s[b] and s[d] in our slice. """ string = input("Provide a string to splice: ") ...
31d79608f17a4283452ecfee7a8673e3cd3519f4
CristianPabon/TrabajosPython
/py6_retos2/reto013.py
159
3.78125
4
a = int(input('Primer número en rango: ')) b = int(input('Segundo número en rango: ')) c = (a + b)/2 print('La media de los números', a,' y ', b,' es: ', c)
c0a7b47621f71f0522512b3e17e64de4eb2e06c5
Spookso/draughts
/min_max_sep.py
16,745
4
4
import pygame, math, movement, time, random # Initiates the pygame library pygame.init() # Sets up a window of size 800 x 800 pixels with the tag 'resizable' win = pygame.display.set_mode((800, 800), pygame.RESIZABLE) # Sets the caption for the window as "Draughts" pygame.display.set_caption("Draughts") # allows pyga...
bcecc78fb05e7d5177668ee21e866718de93812c
chenxu0602/LeetCode
/1338.reduce-array-size-to-the-half.py
2,613
3.765625
4
# # @lc app=leetcode id=1338 lang=python3 # # [1338] Reduce Array Size to The Half # # https://leetcode.com/problems/reduce-array-size-to-the-half/description/ # # algorithms # Medium (66.73%) # Likes: 311 # Dislikes: 32 # Total Accepted: 27.1K # Total Submissions: 40.6K # Testcase Example: '[3,3,3,3,5,5,5,2,2,7...
a0ceff07ec709c9c52bea130d2f7777421d78e42
lucasloo/leetcodepy
/solutions/137SingleNumberII.py
641
3.59375
4
# Given an array of integers, every element appears three times except for one, which appears exactly once. Find that single one. class Solution: def singleNumber(self, nums): """ :type nums: List[int] :rtype: int """ a = set() b = set() for i in nums: ...
4e0c2bed4caed5f14c87ff9928d3a591df1fcb82
bcostaaa01/history_of_lego_pandas_py
/lego_history_pandas.py
1,032
3.65625
4
# Import pandas import pandas as pd # Read colors data colors = pd.read_csv('datasets/colors.csv') # Print the first few rows print(colors.head()) # How many distinct colors are available? num_colors = colors.rgb.size # Print num_colors print(num_colors) # colors_summary: Distribution of colors based on transpar...
9870793f9fba335eecda48666048f1ed9f86938d
cxv8/CSE
/notes/semester 2 Notes - Kentzu Xiong.py
356
4
4
print("Hello World") # Single-line comment car = 5 driving = True print("I have %d cars" % car) print("I have " + str(car) + " car") age = input("How old are you? ") print("You are %s years old" % age) color = ['red', 'green', 'black', 'white', 'gold'] color.append('pink') color.pop(0) print(color) print (len(color...
6e50bbcb8c57fa9c3da30af68593571b5c0e54e7
Margarita89/AlgorithmsAndDataStructures
/Cracking the Coding Interview/8_Recursion and Dynamic Programming/8_3.py
627
4.125
4
# Magic Index: A magic index in an array A[ 1..n-1] is defined to be an index such that A[i] = i # Given a sorted array of distinct integers, write a method to find a magic index, if one exists, in array A. # Comment: talk about logic of returns def magic_index(arr, start, end): if start > end: return -1 ...
4b39550366db7fed2b378805ecad9ad03491c3ba
KVasilius/ALevel_Python_Project
/Tkinter.py
10,706
3.859375
4
from tkinter import * import sqlite3 # login window, checks user name & password with the db one. def loginwindow(): def loginget(): username, userpassword = userName.get(), userPassword.get() cursor.execute("""SELECT user_password FROM user_data WHERE user_name = :user_name""", {'user_name...
8aa130fe10776387d57d1fef930f38b1cff3ffbd
JRosadoDiaz/SimplePersistenceProject
/Employee.py
1,048
3.65625
4
class Employee: #Constructor def __init__(self, employee_id, first_name, last_name, hire_year): self.employee_id = employee_id self.first_name = first_name self.last_name = last_name self.hire_year = hire_year.replace("\n", "") def get_employee_id(self): return s...
48bf36a3d25f3603d62b7fb96362abde60fd0c92
kush96/ApiRateLimiter
/API5.py
783
3.546875
4
import json #json package import requests #requests package def api5(): print '#' * 40 print 'Welcome to API 5' curr_base = raw_input('enter base currency or q to quit: ') # Input Base currency name if curr_base =="q": print "END OF API 5" print '#' * 40 return ...
132ee7e4043f69ef7bb76158731ffc4e15d45124
ssavann/PY-POO
/constructeur_classe.py
662
3.96875
4
''' POO: Le constructeur de classe c'est une méthode qui porte un nom spécial __init__ self: représente l'instance "voiture1" et "voiture2" ''' class Vehicule: def __init__(self , marque_vehicule, couleur_vehicule): #Attributs (variable de classe) self.marque = marque_vehicule self.cou...
58c7ff693418bfb7734765fc69f13052defeb188
an4p/python_learning
/less07/less07_03.py
198
3.703125
4
try: file1 = open("file1.txt") for line in file1: int(line) except ValueError as e: print(e) else: print("I did it!") finally: file1.close() print("Closing file...")
ce6a8a6e242479b0bb4a472dba25327f7623e060
RenanBertolotti/Python
/Curso Udemy/Modulo 03 - Python Intermediário (Programação Procedural)/Aula 02 - Funçoes (def) (Parte 2)/Aula02.py
1,071
4.09375
4
""" Funçoes (def) - return """ def funcao(msg): #print(msg) #Em vez de print, usar: return msg variavel = funcao("ola mundo") print(variavel) #Retorna NULO , pois foi utilizado o print como retorno na funçao!,sendo o correto RETURN #quando acontecer isso,usar: if variavel is not None: ...
e1ea87a7047cc68b587d582f934a1a05516bdf52
kunalprompt/numpy
/numpyArraySlicing.py
879
4.40625
4
''' Hello World! http://kunalprompt.github.io ''' print __doc__ import numpy as np ''' Indexing, and Slicing in Python Numpy There are three kinds of indexing available: 1. record access, 2. basic slicing, 3. advanced indexing Which one occurs depends on obj. ''' # Record Access already done. # Slicing (start:...
14ff0a3cf377b11911822a8c07f7e405511e102a
leNEKO/exercism-solution
/python/word-count/word_count.py
681
3.828125
4
import re from collections import defaultdict def word_count(phrase): cleaning = phrase.lower() cleaning = re.sub(r"(\w+)'(\w+)", "\\1ˇˇˇ\\2", cleaning) # better hack, but ugly cleaning = re.sub(r"[\W_]+", " ", cleaning) clean = re.sub(r"ˇˇˇ", "'", cleaning) + " " words = d...
76c96afe8cb18eeb351367f109d00f24ac2c5503
gschen/sctu-ds-2020
/1906101033-唐超/Day0310/课堂作业1.py
703
3.9375
4
# 一、定义一个学生Student类。有下面的类属性: # 1姓名name; # 2年龄age # 3成绩score (语文,数学,英语) [每课成绩的类型为整数] # 类方法: # 1获取学生的姓名: get name() # 2获取学生的年龄: get age() # 3返回3门科目中最高的分数。get course() class Student(): def __init__(self,name,age,score): self.name=name self.age=age self.score=score def get_name(self): ...
fca26a5bc74983b3907eeebe765b9271b8cc2aa2
kmcginn/advent-of-code
/2019/day12/moons.py
10,421
4.03125
4
#! python3 """ from: https://adventofcode.com/2019/day/12 --- Day 12: The N-Body Problem --- The space near Jupiter is not a very safe place; you need to be careful of a big distracting red spot, extreme radiation, and a whole lot of moons swirling around. You decide to start by tracking the four largest moons: Io, Eu...
b04d4dc370e4c6e31585360424c00bea193ca5f0
IST256-Spring2018/demos
/Lesson-11/darksky.py
967
3.671875
4
""" https://darksky.net/dev 78b65883930875275cd338e25131cdee """ import requests def get_coords(address): api_key = "AIzaSyDFuKg19Z_gzuOnKYa0JusiWFJZ6avhwn8" url = "https://maps.googleapis.com/maps/api/geocode/json" response = requests.get(url, params={"address": address, "key": api_key}) if respon...
668ce4ec755cb8faf3c312b1e97c146194334858
kitconcept/robotframework-pageobjects
/robotpageobjects/sig.py
980
3.671875
4
""" Responsible for figuring out a method signature as a string. """ import inspect from collections import namedtuple DefaultArg = namedtuple('DefaultArg', 'is_valid value') def get_default_arg(args, defaults, i): if not defaults: return DefaultArg(False, None) args_with_no_defaults = len(args) - ...
eb2c961b584e956782fb3f738569a2c16463e348
XiaoqingWang/python_code
/python语法基础/02.if、while、for/15-剪刀石头布.py
526
3.78125
4
import random #1.提示并获取用户的输入 player = int(input("请输入 0剪刀 1石头 2布:")) #2.让电脑出一个 computer = random.randint(0,2) #3.判断用户的输入,然后显示对应的结果 #if 玩家获胜的条件 if(player == 0 and computer == 2) or (player == 1 and computer == 0) or (player == 2 and computer == 1): print("赢了。。。可以去买洗衣粉...") elif player == computer: print("平局了...洗洗手决战...
393e284fa55e060fb66c652212633fd6fd05685b
hdf2104/python_tests
/tuple_functions.py
1,088
4.375
4
''' Several useful functions(or methods) for doing things with tuples ''' def TVCKWA (a_tup=(2,3,4,5), an_int=6) : '''this returns the input with an_int as the first term''' print a_tup, an_int print a_tup[1:] print a_tup *2 print (an_int,) + a_tup[1:] #need oto create a new tuple that looks li...
fbcf48c6a92f26fdcc9b573421a32e40cb1250ac
jlzxian/Python
/tutorial/NumPy/Arithmetic Operations.py
727
4.125
4
"""Arithmetic Operations""" import numpy as np def test_run(): a = np.array([(1,2,3,4,5),(10,20,30,40,50)]) print("OG array a:\n",a) #Multiply a by 2 print("\nMultiply a by 2:\n", 2*a) #Divide a by 2 print("\nDivide a by 2:\n", a/2) b = np.array([(100,200,300,400,500),(1,2,3,4,5)]) ...
162871a2c13f83c96c4a08b890374a29d5ab90d7
nowacki69/Python
/Udemy/Python3Bootcamp/Modules/73_Built_In_Modules_Exercise.py
364
3.59375
4
# It's time to get some practice with built-in modules. Here's your mission: # - Import the math module # - use math.sqrt to find the square root of 15129 and save it in 'answer' # Import the math module: import math # Use math.sqrt to find the square root of 15129 and save it to variable # called answer: num = ...
c858740aca4412c22f714ae3e19d063c10383f54
AsgardRodent/MyPy
/arguments.py
1,143
4.1875
4
def print_name_age(name = "someone", age = "ancient"): print("hi my name is ", name ,"i am ", age, " years old") print_name_age("gaurav", 20) print_name_age("regigas") print_name_age("supahotfire", 28) print_name_age(age=32) # to solve the above error u can directly replace the line(4) with the follow...
1e30a99c62bcb5aa44be58891d8210b608794cfd
guam68/class_iguana
/Code/Richard/python/lab18-peaks-valleys.py
1,508
3.90625
4
""" author: Richard Sherman 2018-12-06 lab10-peaks-valleys.py, takes a list of ints and identifies elements greater than their immediate neighbors ('peaks') and elements less than their immediate neighbors ('valleys'). Tries to extend this logic beyond immediate neighbors to find the 'volume' of 'valleys' and the 'heig...
c0dbd7c99771debca7726a3d4a4536c7ec9b4d02
RSofiaC/LearningMachines
/assigment1_rle.py
1,126
3.890625
4
# rle assignment # by rsofiac # for patrick hebron's learning machines class # at nyu itp # fall 2017 # input can be any string with characters, no numbers # output will be an encoded string def coding(input): # initialize output output = '' # initialize counter of same character counter = 0 # c...
7828dddc6d776f5c29049e35fb796bb33aead500
AlexHolmes4/Python-Repository
/PY4E adaptations/13.4-adaptation_Simplified_xPath_and_List_Comprehension.py
1,108
3.859375
4
#This program will prompt for a URL, read the XML data from that URL using urllib #and then parse and extract the comment counts from the XML data, computing the sum of numbers in the file import urllib.request, urllib.parse, urllib.error import xml.etree.ElementTree as ET import ssl # Ignore SSL certificate errors c...
8e5eb4f80f779f67547de1fb1c3dd5fd250b7a3e
arun5061/Python
/Python_My/String count using dict.py
369
3.53125
4
word=input('Enter string:') d={} for k in word: d[k]=10 print(';;;',d) d[k]=d.get(k,0)+1 print('d:',d) for n,v in sorted(d.items()): print('{} occured {} times'.format(n,v)) d={} s={'a','e','i','o','u'} for k in word: if k in s: d[k]=d.get(k,0)+1 print('d:',d) for n,v in sorted(d.items(...
1f1efdffc23d9cc21e9075b6451cd8d78e59b9d1
SvetoslavGeorgiev/SoftUni
/Programming_Basics_Python/First_Steps_in_Coding_Lab/Pet_Shop/Pet_Shop.py
185
3.609375
4
food_for_dogs = int(input()) food_for_other_animals = int(input()) money_needed = (food_for_dogs * 2.50) + (food_for_other_animals * 4.00) print(f"{format(money_needed, '.2f')} lv.")
f802eb365b0e68b33c2fca91aeb89de067e65725
AmberBianco/Coding-and-Informatics-Projects
/matrices.py
3,278
4.15625
4
11 def add_row(matrix): """ >>> m = [[0, 0], [0, 0]] >>> add_row(m) [[0, 0], [0, 0], [0, 0]] >>> n = [[3, 2, 5], [1, 4, 7]] >>> add_row(n) [[3, 2, 5], [1, 4, 7], [0, 0, 0]] >>> n [[3, 2, 5], [1, 4, 7]] """ newmatrix = [] for row in matrix: ...
3f52cdc6e6a2cf532657871074563a052466b145
omiplekevin/bywave-python-training
/exer_002.py
354
3.953125
4
# -*- coding: utf-8 -*- """ Exercise #2 Write a program that prints all multiples of 7 that are below 100. Hints: check python’s range Function """ # your name and email address here __author__ = 'xXLXx <kevin@bywave.com.au>' if __name__ == '__main__': mods = [x for x in range(0,100) if x % 7 == 0] print(mods) ...