blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
c86e34daca94c4d8b7c3e0e9971710a2ba5bc5f7
Aasthaengg/IBMdataset
/Python_codes/p03711/s271420531.py
209
3.671875
4
x,y=map(int,input().split()) g1 = {1,3,5,7,8,10,12} g2 = {4,6,9,11} g3 = {2} def group(z): if z in g1:return 1 elif z in g2:return 2 else: return 3 if group(x)==group(y):print('Yes') else:print('No')
104ccabb5ae5183e8c047999655f3b5ffa03ad97
zhangruochi/leetcode
/849/Solution.py
2,419
4.09375
4
""" In a row of seats, 1 represents a person sitting in that seat, and 0 represents that the seat is empty. There is at least one empty seat, and at least one person sitting. Alex wants to sit in the seat such that the distance between him and the closest person to him is maximized. Return that maximum distance to...
7fd524b4291d74dbc539e0f5dd5a8115932bd33c
lromang/hackerRank
/strings/commonChild.py
583
3.640625
4
import sys def remc(string, c): return ''.join(v for v in string if not v in c) def counts(string): count = dict() for c in string: if c in count: count[c] = count[c] + 1 else: count[c] = 1 return count def child(name1, name2): ## Counts of chars. ch1 =...
d008fa30d7ee975ab26c9e71871e8c23918eaf19
EiT-Computer-Vision/velocity-estimation
/velocity_estimation.py
1,187
3.625
4
""" Main module containing the program loop. Serves as an entry point to the program. """ import display import glob import cv2 VIDEO_PATH = "Video data/2011_09_26/2011_09_26_drive_0001_sync/image_00/data" def get_video_sequence(path): """ Returns a list of the pahts of all frames in the video. Input: ...
b4f6fe67f9fe462f5406bfe745f1fbe69a9a792a
seancrawford-engineer/python_bootcamp
/coding_challanges/10_adv_python/02_regex.py
561
3.609375
4
import re """ Our definition of a secure filename is: - The filename must start with an English letters or a number (a-zA-Z0-9). - The filename can **only** contain English letters, numbers and symbols among these four: `-_()`. - The filename must end with a proper file extension among `.jpg`, `.jpeg`, `.png` and ...
7ab72cff2902a6d7e90312710ab84dc0b2e49425
ausaki/data_structures_and_algorithms
/leetcode/find-numbers-with-even-number-of-digits/392835292.py
324
3.65625
4
# title: find-numbers-with-even-number-of-digits # detail: https://leetcode.com/submissions/detail/392835292/ # datetime: Tue Sep 8 22:50:53 2020 # runtime: 44 ms # memory: 14 MB class Solution: def findNumbers(self, nums: List[int]) -> int: return sum((len(str(num)) % 2 + 1) % 2 for num in nums) ...
2e0b8f069f09a7ac01b09fbf1aa3401061ac79a7
ZacharyBriggs/EquationConverter
/Equation.py
2,285
3.5625
4
from Clause import Clause class Equation(): def __init__(self, eqString): self.string = eqString self.LiteralDictionary = [] self.ClauseArray = [] self.findClauses() self.findUniques() '''Takes in a list of tuples and then assigns those tuples to the literal dictionary''...
548cd345ee005be8e0111a81d2afebbcd6158791
lbingbing/leetcode
/Algorithms/p104_Maximum_Depth_of_Binary_Tree/p104_Maximum_Depth_of_Binary_Tree_1.py
645
3.84375
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def maxDepth(self, root): """ :type root: TreeNode :rtype: int """ self.max_depth...
3c16dd21248b052c54c930624a618d27452b073c
rishabhjaiswaliit/python_dsalgo
/recur/recur2_bug.py
485
3.953125
4
def count_up(n): # Step0: how can I break this problem into smaller parts of the same problem # Step1: oh yeah count_up(12) is just first count_up(11) then print(12) # Step2: base case: in which case do I dont need to do anywork; its simple; its trivial. HERE WE HAVE RESTRICTED DOMANI n starts from 1 if...
cee440e78c88909129d2303ae77a991d2068527e
zhinan18/Python3
/code/base/lesson10/10-6.py
1,389
4.15625
4
class HotDog: def __init__(self): self.cooked_level = 0 self.cooked_string = "Raw" self.condiments = [] # Define the new __str__() method, which # displays hot dog, including condiments def __str__(self): msg = "hot dog" if len(self.condiments) > 0: ...
c47a77e889ec185582d59d53c01ee359219e641a
persianovin/Rectangular-Cube-Class
/Rectangular-Cube-Class.py
635
4.09375
4
class Rectangle: def __init__(self, l, w): self.l = l self.w = w def area(self): return self.l * self.w def circumference(self): return 2*(self.l + self.w) def cube_volume(self, h): return self.area()*h def cube_surface(self, h): return 2*(self.l*...
9b2b147971e5fe4f5fc11074e218a45132ebd370
Okimani/Oscarpy
/getinitials.py
808
4.34375
4
# You can create a function to perform the operation below. #first_name =input('Enter your first name ') #first_name_initial = first_name[0:1] #last_name = input('Enter your last name ') #last_name_initial = last_name[0:1] #print('Your initials are: ' + first_name_initial + last_name_initial) #print(first_name) #print...
6228c529905e11162d19d3965431da2a564c388a
thomblr/Blackjack
/CardSet.py
1,556
3.859375
4
from Card import Card from random import shuffle, randint class CardSet(object): def __init__(self): self.card_set = [] for i in range(1, 14): for n in range(4): card = Card(i, n) self.card_set.append(card) def shuffle_set(self): """ ...
1b071c8e0f0a91e4e673680795b06f23db807915
Aasthaengg/IBMdataset
/Python_codes/p02422/s736756292.py
363
3.71875
4
str = raw_input() q = input() for i in range(q): a = raw_input().split() if(a[0] == "print"): print(str[int(a[1]):int(a[2]) + 1]) elif(a[0] == "reverse"): str = str[0:int(a[1])] + str[int(a[2]):int(a[1]):-1] + str[int(a[1])] + str[int(a[2]) + 1:] elif(a[0] == "replace"): str = st...
0c1abf5a0d75a0219b0ffe8f0f042758ce7abdef
fayhe/jupyter
/quick_sort.py
1,825
3.828125
4
# coding: utf-8 # In[20]: def quick_sort(a, low, high): key = a[low] i,j = low,high while(i<=j ): while(i<=high and a[i] < key ): i = i+1 print("j value:",j) while(j>=low and a[j] > key ): j = j-1 if(i<=j): a[i],a[j] = a[j],a[i]...
ea226f1474a59a15a0ba548caac3bdd8826b6244
rafaelperazzo/programacao-web
/moodledata/vpl_data/106/usersdata/158/52199/submittedfiles/questao2.py
823
3.515625
4
# -*- coding: utf-8 -*- y1=int(input('digite y1:')) y2=int(input('digite y2:')) y3=int(input('digite y3:')) y4=int(input('digite y4:')) y5=int(input('digite y5:')) y6=int(input('digite y6:')) v1=int(input('digite v1:')) v2=int(input('digite v2:')) v3=int(input('digite v3:')) v4=int(input('digite v4:')) v5=int(input('di...
9449f5036183f5a0efea900ef522c366fc8f0279
johnzhao96/johnzhao_projects
/ode_solver/main.py
1,451
4.21875
4
""" main.py Runs the solver to simulate the falling marble. """ from solver import solve from math import sqrt, log, pi from numvec import NumVec # Radius of Earth R = 2e7/pi CIN = 9.8/R def fmarble(time, Y): """ Differential function for the motion of the marble. Since we are given the function for the second de...
152cb671503d4cafd29cd62e753463ff8b267a5d
syurskyi/Algorithms_and_Data_Structure
/_algorithms_challenges/codingbat/codingbat-master/string-1/combo_string.py
357
3.9375
4
''' Given 2 strings, a and b, return a string of the form short+long+short, with the shorter string on the outside and the longer string on the inside. The strings will not be the same length, but they may be empty (length 0). ''' def combo_string(a, b): if len(b) > len(a): return '{0}{1}{0}'.format(a, b)...
3538a064735c51464ecdc07a424e5fb45c97adab
skyjan0428/WorkSpace
/count_emma.py
272
3.890625
4
# https://pynative.com/python-basic-exercise-for-beginners/ def count_emma(statement): count = 0 for i in range(len(statement)-1): if statement[i:i+4] == 'Emma': count += 1 # Cannot handle the # count += statement[i:i+4] == 'Emma' return count
84f61ea7565432d519b80d00475da397384ccd37
adamkoy/Learning_Python
/Python_Learning/Python_fundementals/17_abstraction.py
636
3.609375
4
from Abstraction_17 import Reptiles class Snake(Reptiles): def __init__(self, age, weight, species,name,region_found, num_fangs,length): super().__init__(age,weight,species,name, region_found) self.num_fangs = num_fangs self.length = length def can_constrict(self, bool_value): ...
3786fb8124fdfcd3e5a8096c8e977455d4f6ede2
daniel-reich/turbo-robot
/WpRhk6tKJFmvJA6cq_10.py
1,588
3.8125
4
""" _Due to unforseen circumstances in Suburbia, the trains will be delayed by a further 10 minutes._ Create a function that will help to plan out and manage these delays! Create a function called `manage_delays` that does the following: * Parameters will be the train object, a destination and number of minutes...
0b8d20ef9012d33f4cb4d59c155746d615467f50
sandshaw/algorithm004-04
/Week 08/id_259/LeetCode_387_259.py
2,690
3.6875
4
''' 387. 字符串中的第一个唯一字符 给定一个字符串,找到它的第一个不重复的字符,并返回它的索引。如果不存在,则返回 -1。 案例: s = "leetcode" 返回 0. s = "loveleetcode", 返回 2. 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/first-unique-character-in-a-string 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 ''' ''' class Solution: def firstUniqChar(self, s): if len(s) == 0:...
8ab5635437bf7530bef9c2fdc6c99ef36ef5fe99
FT-Labs/BaslangictanIleriSeviyeyePythonUdemy
/Bolum5/MapFonksiyonu.py
258
3.734375
4
""" Author : Arda Date : 4/25/2020 """ sayilar = [1 , 3 , 5 ,7] meyveler = ["portakal" , "elma" , "armut" , "çilek"] sayilar1 = [2 , 1 , 3 , 1] # print(list(map(lambda x : x+x , sayilar))) print(dict(map(lambda x , y : (x , y) , meyveler , sayilar1)))
58c1dd0c56bc31f98e3005b6915b2224b448f354
mattshirtliffe/exercises-for-programmers-57-challenges-python
/karvonen_heart_rate/app.py
1,677
4.15625
4
def print_header(): """ Print header """ header_text = '' TEXT = f' Karvonen heart rate \n' line = '-' * len(TEXT) line += '\n' header_text += line header_text += TEXT header_text += line print(header_text) def print_headings(): """ Print header """ header_text...
d2fbb50523d4027f33e55ed1723da0c67ba5ff5c
sasakishun/atcoder
/ABC/ABC075/B.py
956
3.546875
4
def listToString(_list, split=""): maped_list = map(str, _list) # mapで要素すべてを文字列に mojiretu = split.join(maped_list) return mojiretu h, w = [int(i) for i in input().split()] s = [[0 for _ in range(w + 2)] for _ in range(h + 2)] table = [[0 for _ in range(w + 2)] for _ in range(h + 2)] for i in range(h): ...
56e305d2ae13a87252d49389f315aefcd5da17f3
SvetlanaIvanova10/python_netoogy
/2.7 Stack/stack.py
2,513
3.953125
4
# Необходимо реализовать класс Stack со следующими методами: # isEmpty - проверка стека на пустоту. Метод возвращает True или False. # push - добавляет новый элемент на вершину стека. Метод ничего не возвращает. # pop - удаляет верхний элемент стека. Стек изменяется. Метод возвращает верхний элемент стека # peek - возв...
7c12a45cfd101fa319d69d60bc521916339c7bc9
jcasarru/coding-challenges
/python/16.py
1,671
4.28125
4
''' Write a password generator in Python. Be creative with how you generate passwords - strong passwords have a mix of lowercase letters, uppercase letters, numbers, and symbols. The passwords should be random, generating a new password every time the user asks for a new password. Include your run-time code in a ...
317228985a714948b47e22e87b208721b3a2cafe
Gchesta/bootcamp_projects
/shirley/tables.py
1,198
3.65625
4
import os import sys from sqlalchemy import * from sqlalchemy.ext.declarative import declarative_base #declarations engine = create_engine('sqlite:///todo.db', echo = False) metadata = MetaData(engine) Base = declarative_base() Base.metadata.bind = engine class TodoList(Base): """ The class TodoList will be used...
ab6d1bb43cc02c30a562bc1d743f1596e7fb9282
ibrahimGuilherme/Exercicio_Guilherme
/exercicio45.py
419
3.875
4
import random sorteio = random.randint(0, 10) valor = int(input('Qual o valor sorteado (entre 0 e 10)? ')) tentativas = 0 while valor != sorteio: if valor != sorteio: print('Incorreto.') valor = int(input('Qual o valor sorteado (entre 0 e 10)? ')) tentativas += 1 else: tentativas += 1 ...
25784f16d3c7a1e33df56235e285a5eea0a43b6a
lkfo415579/GOD.util
/util_token/Remove_Line.py
546
3.8125
4
# -*- coding:utf-8 -*- ''' Created on 2016年3月28日 @author: Peter Hao Zong ''' import codecs import sys def remove_line(filename): source_file = codecs.open(filename, 'r', 'utf8') lines = source_file.read().split('\n') outfile = codecs.open(filename + '.without_external_line', 'w', 'utf8') ...
e543212f9ce9a59886f70b6104387cb2b63e38cb
GeneralLobster/Probability-and-Stats-Computing
/conditionalProbabilityNoisyChannel.py
4,568
3.8125
4
# -*- coding: utf-8 -*- import random as r #parameters given p0=0.6 e0=0.05 p1=0.4#this was 1-p0 e1=0.03 N=100000 def roll(valProb):#this will determine whether or not the probability of valProb fails/success num=r.random()#generates random float from 0 to 1 if num<valProb:##if the random number is less than ...
a24c622b9a539ca60df9a7c4b76c43b4d60ba4f5
NixRaven/weather_scrape
/bin/scraper.py
3,897
3.6875
4
#!/usr/bin/python3.6 # a script to scrape weather info about the weather in paris and portland and compare weather data over time #imports import requests import json from lxml import html import re import time import os # a file update function def update_json(path, info): #check if file has been updated today la...
7c1b23b78e1a0b23c06f3df248dc96365de72bcf
gitonga123/Learning-Python
/dictonary.py
1,224
4.375
4
#A dictonary is an object that stores a collection of data. Each element #in a dictonary has tow parts: A Key and a Value. You use a key to locate # a specific value #Key-Value pairs are often referred to as mappings because each key #is mapped to a value. #A KeyError exception is raised if you try to retrieve a value ...
45f3bc2af47888853a3a119bc3e38607c5027bcf
tianyunzqs/LeetCodePractise
/leetcode_21_40/33_search.py
604
3.9375
4
# -*- coding: utf-8 -*- # @Time : 2019/6/18 17:16 # @Author : tianyunzqs # @Description : def search(nums, target: int) -> int: # # solution1 # try: # return nums.index(target) # except: # return -1 # solution2 if not nums: return -1 if target <= nums[-1]:...
2aa6888e86f87d0721c995118ed2aad4de1fe36d
dongpin/AlgorithmProblems
/Python/BasicAlgorithm/LinkedList.py
554
3.75
4
# Node for linked list # class SinglyNode: def __init__(self, data): self.data = data self.next = None def __str__(self): return str(self.data) class DoublyNode: def __init__(self, data): self.data = data self.prev = None self.next = None def __str...
2aca8c150acb5c7cc3b4fcc6942d59ffd654fa13
JunYinghu/selenium-website-test-automation
/Backup/Assignment_junying/airbookb/airbook/utils/promogenverify.py
2,339
3.71875
4
import random import re import string from random import randint def prom_cod_gent(): # prom_cod = '' prom_cod_arr = [] letter_1 = random.choice(string.ascii_letters) prom_cod_arr.append(letter_1) letter_2 = random.choice(string.ascii_letters) prom_cod_arr.append(letter_2) prom_cod_arr.app...
c7578b895ee493f8aec44d464b36a8ca3112706a
Snehal2605/Technical-Interview-Preparation
/ProblemSolving/450DSA/Python/src/dynamicprogramming/LongestCommonSubstring.py
836
3.921875
4
""" @author Anirudh Sharma Given two strings ‘X’ and ‘Y’, find the length of the longest common substring. """ def findLCS(X, Y): # Special cases if X is None or len(X) == 0 or Y is None or len(Y) == 0: return 0 # Lengths of the two strings m, n = len(X), len(Y) # Lookup table to store t...
f73f2bc11cb48a0b2ab0bc99ab16d84de248e450
phy0813/phy
/phy01.py
891
3.953125
4
# print("hello world!")# 字符串 # print (2333)# 整数 # print (2.33)# 小数 # print (True)# 布尔值 # print (())#元组 # print([])#数组 # print({})#字典 # """ # 锄禾日当午 # 汗滴禾下土 # """ # print("皮蛋",123) # print("嘻嘻"+"哈哈")# 字符串的拼接 # print("嘻嘻哈哈"*3)# 字符串相乘 # print(98*(15+16)-2/9) # print(1>2) # print(1<2) # a = float(input("请输入:")) # b = floa...
0d1ed00aaf4e9450dddc4cef544922450366d7b8
fosuoy/project_euler
/python/problem_023.py
1,839
4.21875
4
#!/usr/bin/env python3 import time def blurb(): print(""" A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number. A number n is called defici...
6cfad1e3972ff99860359866b77a3129f9b0343a
sarful/Raspberry-pi4-Workshop
/L298.py
972
3.765625
4
import RPi.GPIO as GPIO from time import sleep # Pins for Motor Driver Inputs Motor1A = 21 Motor1B = 20 Motor1E = 16 def setup(): GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) # GPIO Numbering GPIO.setup(Motor1A,GPIO.OUT) # All pins as Outputs GPIO.setup(Motor1B,GPIO.OUT) GPIO.set...
a5c6b4ddddff4f61bf5a95e52ba84309b2f1123d
Satyamkumarai/hardwareprojects
/mapping/mapping_using_serial/main/helpers/cmd_interface.py
2,127
3.5625
4
import argparse epilog =''' Usage Examples: Read from COM4 using baudrate 9600 : python main.py -f 'com4' -s -b 9600 Read from COM4 using baudrate 9600 and save to file data/output.csv: python main.py -f 'com4' -s -b 9600 -o data/output.csv Read from a file: pyth...
a0c79a8e6352f1175f0ed11b52a8dd9c0faba1a1
prasannanm/Python
/DNA/dna.py
2,822
4.09375
4
# DNA DioxyriboNucleic Acid # A, C, G, T - four nucleotides to construct DNA # A - adenine # C - cytosine # G - guanine # T - thymine # DNA -> RNA -> Protein # one amino acid = nucleotide triplet # sequence of amino acid = protein - comprised of 20 amino acids # dictionary of life inputfile = "dna.txt" # r for reading...
b37d4c6f6f3dad18efed9de4b47bae2a139413c6
Theasianmushroom/Roman_numeral_calculator_GUI
/RomanNumeralGui.py
2,073
3.625
4
from tkinter import * window = Tk() window.title("NUMERAL CALCULATOR.") window.geometry("350x125") window.config(bg = "grey") Values_List = [] RNT = IntVar() def Calculations(): Roman_Numeral_Values = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000} Values_List.clear() R...
11b74d6ccf5e2be5cfbc2195354b28ead5994d1a
weincoder/algoritmos202101
/clases/algoritmos/ordenamiento_insercion.py
448
3.671875
4
def ordenamientoInsercion(lista): ''' Se ordena una lista utilizando el méto de inserción ''' for indice in range (1, len(lista)): valorActual = lista[indice] posicionActual = indice while (posicionActual>0 and lista[posicionActual-1]> valorActual): lista[posicionAc...
0e920fffdf28b1ea2721f62fad75cc3392515223
vivek3141/RandomProblems
/Python Projects/GUI/String_Handling.py
1,949
3.609375
4
#String Handling a = "hi" for i in a: print(i) def has_no_e(word): word = str(word) for i in word: if i == "e": return False return True def avoids(word, forbidden): word = str(word) for i in word: if i in forbidden: ret...
725c9dcdb5a83dddeb3e5118b721f03d28a18239
Stanislav-Dusiak/Stanislav-Dusiak
/Tasks. Indie course for beginners in Python from Artem Egorov ./Code_Forces_228_Is your horseshoe on the other hoof?.py
1,403
3.734375
4
""""Valera the Horse is going to the party with friends. He has been following the fashion trends for a while, and he knows that it is very popular to wear all horseshoes of different color. Valera has got four horseshoes left from the last year, but maybe some of them have the same color. In this case he needs to go t...
5b23a7c30cce36b7628ae50ca82505eae1c17d31
someOne404/Python
/pre-exam1/get.py
160
3.53125
4
def integer(prompt='Type an integer: '): #name of the parameter is arbitrary #default value of parameter s = input(prompt) i = int(s) return i
2fe2ecdb2da900f9f0db8d03bef23c06dae9a8b5
rohitmadrileno15/Python-Questions
/prime_number.py
464
4.15625
4
import math def number_is_prime(n): if n <= 1: return False elif n == 2: return True elif n > 2 and n % 2 == 0: return False else: for i in range(3, int(math.sqrt(n)) + 1, 2): if n % i == 0: return False return True if __name__ == "__main__": ...
cd2ae708b13c6359cbbcefa0b957fa58d304f722
okazkayasi/03_CodeWars
/14_write_in_expanded_form.py
682
4.375
4
# Write Number in Expanded Form # # You will be given a number and you will need to return it as a string in Expanded Form. For example: # # expanded_form(12) # Should return '10 + 2' # expanded_form(42) # Should return '40 + 2' # expanded_form(70304) # Should return '70000 + 300 + 4' # # NOTE: All numbers will be whol...
c9d0acc24439283a9a9c43f946cf3bfd46b98cde
IsraelCavalcante58/Python
/Aprendendo Python/exercicios/ex025.py
206
4.15625
4
'''Crie um programa que leia o nome de uma pessoa e diga se ela tem "Silva" no nome''' nome = str(input('Qual o seu nome?')).strip() print(f'Essa pessoa tem Silva no nome? {"SILVA" in nome.upper() }' )
a32f9b345a8ffa7086a4a0ba6437f38f2e17d293
wangtao090620/LeetCode
/wangtao/leetcode/0005.py
1,243
3.5
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- # @Author : wangtao # @Contact : wangtao090620@gmail.com # @Time : 2019-11-14 17:04 # 给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。 # # 示例 1: # # 输入: "babad" # 输出: "bab" # 注意: "aba" 也是一个有效答案。 class Solution: def longestPalindrome(self, s: str) -> str: ...
f0cca99612990019f47fe9aa5448f525a910c1d8
kschlough/interview-prep
/sieve_of_eratosthenes.py
1,648
3.875
4
# from ctci # find all primes smaller than or equal to int n # exponential time complexity, o(n) linear space complexity def sieve_of_eratosthenes(n): # list of consecutive integers from 2 up through n value # but list of boolean values instead of #s # each index location if true signifies we have a prime ...
56dc748393b106cbae02878de7d7517be18e56de
Sens3ii/PP2-2020
/!Quiz/final/Final_A_1.py
489
3.609375
4
h = int(input()) # height w = int(input()) # width k = int(input()) # how much possible = False # default for i in range(1, h+1): # cheking by height for j in range(1, w+1): # cheking by width if k == w*i or k == h*j: # if our byte can be so, possible = True # possible = True ...
516087a97f3f936ebdbdc21b305809f3a5aa2466
vinit-ww/Assignments
/python/GUESS_15JULY2016.py
375
4.125
4
import random guess_made = 0 number = random.randint(1,20) print "%d"%(number) while guess_made < 3: guess = int(raw_input("Take a guess between 1 and 20 :")) guess_made=guess_made+1 if guess == number: print "Congrats! The number Guessed is Right" break if guess < number: print "The Guess is too low" ...
6d3e442e63683a27eafb146d34407b7aa20fc987
dcampoc/iterators-generators
/iteratorSimple.py
492
3.875
4
# -*- coding: utf-8 -*- """ Created on Mon Sep 2 14:04:32 2019 @author: damian.campo """ # Create a list of strings: flash flash = ['jay garrick', 'barry allen', 'wally west', 'bart allen'] # Print each list item in flash using a for loop for item in flash: print(item) # Create an iterator for fl...
8b10ee5d8c09b5bf63d27235ce398c6d64d44c44
pavlamilata/czechitas_python1
/DC04_RC.py
418
3.703125
4
#DC04 #Měsíc narození rc = int(input("Zadej své rodné číslo (bez lomítka): ")) def monthOfBirth(rc): rc_str = str(rc) mesic = int(rc_str[2:4]) hlaska = "Rodné číslo bylo zadáno chybně." if mesic <= 12: return mesic elif mesic <= 50: return hlaska elif mesic <= 62: re...
7f509f287c8b1fb0c0ae7326fc49b284fd01ef5e
RomaMol/MFTI
/DirOPP/Lec17/slots.py
1,148
4.03125
4
#!/usr/bin/python # -*- coding: utf-8 -*- # https://www.youtube.com/watch?v=P0uvWDpqB8I&list=PLA0M1Bcd0w8zo9ND-7yEFjoHBg_fzaQ-B&index=17 # 17. ООП Python 3: коллекция __slots__ для классов import timeit class Point: """ в экземпляр класс можно добавить ещё координату """ def __init__(self, x, y): ...
5f390f453ae819120df0a5d749509bff34c1fedd
wanggalex/leetcode
/DepthFirstSearch/130_SurroundedRegions.py
1,614
3.796875
4
# coding: utf8 """ 题目链接: https://leetcode.com/problems/surrounded-regions/description. 题目描述: Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'. A region is captured by flipping all 'O's into 'X's in that surrounded region. For example, X X X X...
4cc8e02ab608984244042f7757cc82554ef0e587
DeepthiPalaniKumar/wired-brain-recipes
/inheritance.py
749
3.78125
4
students=[] class Student: school_name="Springfield Elementary" def __init__(self,name, student_id=332): self.name=name self.student_id=student_id students.append(self) def __str__(self): return "Student" + self.name def gt_namecapitalize(self): return self.n...
c8c280a877b6c56a9d65ef5793557f15f2761bb7
khsien/cp2019
/p01/q4_sum_digits.py
182
4.0625
4
integer = int(input("Enter Integer:")) a = integer % 10 b = integer // 10 c = b // 10 d = b % 10 e = c // 10 f = c % 10 print("The sum of the digits are " + str( a + d + e + f) )
2d0774b5beb5f9664a16dcfc7472475b3020f710
a1864754/python
/大二一些代码/实验7/递归删除指定文件夹中指定类型的文件.py
519
3.65625
4
import os import os.path import stat # 获取文件后缀名 def get_file_extension(filename): return os.path.splitext(filename)[1] a = input("指定类型") rootdir = r"liurui" # 指明被遍历的文件夹 for parent, dirnames, filenames in os.walk(rootdir): for filename in filenames: real_path = os.path.join(parent, filename) ...
b89947f7caa940115fd34ed5a52e6d794e54dc86
taktak1/tdmelodic
/nn/lang/japanese/kana/hyphen2romaji.py
1,500
3.5
4
# ----------------------------------------------------------------------------- # Copyright (c) 2019-, PKSHA Technology Inc. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. # --------------------------------------...
fd0ba54e26713623b46d48b41ec84b3c17bab2eb
LRenascence/LeetCode
/Python/easy/345. Reverse Vowels of a String.py
748
4.03125
4
""" Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Input: "hello" Output: "holle" Example 2: Input: "leetcode" Output: "leotcede" Note: The vowels does not include the letter "y". """ class Solution: def reverseVowels(self, s: str) -> str: vowels = ['a',...
8ee559d9e7e090b38f20783e6196c4c6168919db
daebr/python-fp
/fp/foldable.py
1,039
4.09375
4
class Foldable: """ A foldable is a data structure that can be collapsed into a single value. """ def fold(self, f, z): """ Apply a two-parameter function `f` to each element of the foldable structure `t a`, passing the result onto the next element. An initial ...
12c46a56fee9e43deb107305fd249f86cb504d34
ariadnecs/python_3_mundo_1
/exercicio_028_v2.py
773
4.1875
4
# Escreva um programa que faça o computador “pensar” em um número inteiro entre 0 e 5 # e peça para o usuário tentar descobrir qual foi o número escolhido pelo computador. # O programa deverá escrever na tela se o usuário venceu ou perdeu. from random import randint from time import sleep print('-=-' * 20) print(' V...
776073026f36f2d6841cd659191dfeef17139155
vivekanand-mathapati/python
/generators.py
115
3.734375
4
def squeres(lst): for x in lst: yield x ** 2 lst = [1,2,3,4] sqr_lst = squeres(lst) for x in sqr_lst: print(x)
273d7a4c0754146d115514ae62cedd1c9a957019
sneha8296/python_projects
/calculator.py
425
3.828125
4
# number1=list (input("enter the 1st value --> ")) # number2=int(input("enter the 2nd value --> ")) # ans=number1+number2 # print("your final ans is --> "+str(ans)) # print(type(number1)) def add(x,y): return(x+y) def sub(x,y): return(x-y) def div(x,y): return(x//y) def...
4fb6e04291490d010cec47a0535ff23ae2d997f8
naphelly24/euler
/p16.py
310
3.625
4
# method 1: #import math #num = int(math.pow(2,1000)) #target = 0 #while num != 0: #target += num%10 #num = int(num/10) #method 2: #print sum(int(digit) for digit in str(2**1000)) #method 3: #reduce(lambda x, y: x + y, [int(i) for i in str(2 ** 1000)]) #method 4: print sum(map(int, str(2**1000)))
85e1b431109c6e6f5a8c8bf4376a32fec3298fbf
aashishravindran/interview_prep
/puthon_files/sorting.py
2,568
3.8125
4
#QUick Sort # Algorithm : # 1) pick a pivot element and partition the array such taht alll elements to the left of the # pivot are less than all elements to the right of the pivot # 2) call quicksort on the segemnt start to p-1 # 3) call quick sort on the elemnt p+1 to end # 4) Base cases: end the recursion if ...
91db937f20dac03ffff92daf0ba5a14b996244cc
MrYee4/Farkle
/farkle.py
3,416
3.53125
4
# Spencer Nettles # Farkle Game import random def printTable(d): print("DIE | ROLL") print("D1 | ", " | "*d[0][1], d[0][0]) print("D2 | ", " | "*d[1][1], d[1][0]) print("D3 | ", " | "*d[2][1], d[2][0]) print("D4 | ", " | "*d[3][1], d[3][0]) print("D5 | ", " | "*...
3c64f349427011273fddd90a2b28a1667ca0ca73
rupeq/python-algo
/sort-algorithms/merge.py
631
3.90625
4
items = [4, 1, 5, 3, 2] # Time Complexity O(nlogN) # Space Complexity O(n) def merge(data): result = [] if len(data) < 2: return data l_left = len(data) // 2 l_right = len(data) - l_left left = merge(data[:l_left]) right = merge(data[l_left:]) i = j = 0 while i < l_...
8045c1d155eddd641518a5bb24a6e1aa58bab9df
xiewenwenxie/168206
/168206108/04.py
293
3.796875
4
def qsort_(list): if len(list) <= 1: return list else: mid = list[0] L = [i for i in list[1:len(list)] if i <= mid] H = [i for i in list[1:len(list)] if i > mid] return qsort_(L) + [mid] + qsort_(H) list = [5,8,3,2,98,32,1] print (qsort_(list))
691c18f64a0c5773126aa41c42a677ea4f70a5a4
mx419/assignment7
/mx419/select_array_elements.py
1,061
3.921875
4
"""This module contain a class to solve Question 3. The class contain the random 2-Darray and a method to generate an array with selected elements""" import numpy as np #author: Muhe Xie #netID: mx419 #date: 11/01/2015 class Select_Elements: """The class contain the 10*3 2-Darray in Question3 and a method to ge...
6172f6ec0ae937701e9c56006b6935b205b2fc46
tursunovJr/bmstu-python
/1 course/Lab6(массивы)/другие задачи/lr6zadacha1.py
4,163
3.625
4
#Даны 2 одномерных упорядоченных массива #Сформировать новый упорядоченный массив #Унтилова Арина ИУ7-16 n1=(input('Введите размер массива №1: ')) # Ввод размерв массива №1 while True : k=0 for i in range(len(n1)): if ('0' < n1[i] <= '9')...
16e3153874bcce3d9608c839abfe220a30c297c3
nameera0408/Practical-introduction-to-python_Brainheinold
/ch4_4sol.py
353
3.984375
4
credits_taken = eval(input("Emter the number of credit taken: ")) if credits_taken <= 23: print("You are a fresh man") elif credits_taken >= 24 and credits_taken <= 53: print("You are a sophormore") elif credits_taken >= 54 and credits_taken <= 83: print("You are a Junior") elif credits_taken >= 84: pr...
9cfe256c67a20071768ee7026ec7d5b87eb582f3
Ahd-kabeer/python-practices
/assignments/forloop_perfect_square.py
87
3.703125
4
import math root=math.sqrt(i) for i in range(1,51): if int(root+.5)**2==i print(i)
37238eb1a843fb3a7d5e1d36364bf3f0b1bbd7ee
kylehovey/kylehovey.github.io
/spel3o/files/geohash.py
2,354
3.8125
4
import webbrowser import math ImTheMap = input("would you like a map site to look up your coordinates? ") if ImTheMap == "yes": print('look up your current location on this website') webbrowser.open("https://csel.cs.colorado.edu/~nishimot/point.html") else: print('''okay then, let's continue''') Lat = input...
a9ed4e981b7f97d5b1a70b3bf0584d50134977d2
filipjenis/Python-old
/kniha.py
180
3.53125
4
for i in range(1,1001): cifsucet = sum(int(digit) for digit in str(i)) cifsucet2 = sum(int(digit) for digit in str(i*i)) if(cifsucet == cifsucet2): print(i)
0dfdc9d1b241dd8b1a03545dd938084e3fc52b27
MrChoclate/projecteuler
/python/6.py
757
3.9375
4
""" Sum square difference Problem 6 The sum of the squares of the first ten natural numbers is, 1 ** 2 + 2 ** 2 + ... + 10 ** 2 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10) ** 2 = 55 ** 2 = 3025 Hence the difference between the sum of the squares of the first ten natural number...
8e61b3e0b173f1f19bcdba729fe1e9a0b303fb40
iamieht/intro-scripting-in-python-specialization
/Python-Programming-Essentials/Week1/Ex21_AreaTriangle.py
1,746
4
4
""" Compute the area of a triangle (using Heron's formula), given its side lengths. """ ################################################### # Tests # Student should uncomment ONLY ONE of the following at a time. # Test 1 - Select the following lines and use ctrl+shift+k to uncomment. # x_0, y_0 = 0, 0 # x_1, y...
ffe8c88c151e11e07d98ee33937d81bb792ddd68
talhasayyed/PythonProj
/python basics/ForNumNotDivBy3or5.py
171
4.25
4
# python program for number not divisible by 3 or 5 # continue for num in range(1, 50): if num % 3 == 0 or num % 5 == 0: continue else: print(num)
5903c19cb62ee3c0b91d55171ad46ef1107ef38c
sunflower12125/Learn-Share-Hacktoberfest2021
/Python Program/30.check whether the brackets are correctly balanced or not.py
416
4.21875
4
# getting the sequence from the user s = input("Enter sequence: ") is_valid = True count = 0 # iterating over each character for ch in s: if ch == '(': count += 1 elif ch == ')': if count == 0: is_valid = False else: count -= 1 # displaing the result ...
bee1e5c9d89d59731da5af86042f1aa5829a7a2d
suryansh4537/projects
/venv/oreo1.1.py
598
3.859375
4
# ALL VARIABLES ARE REFERENCE VARIABLES AND POINT TO A CONTAINER HAVING THE VALUE johnsAge=30 print(johnsAge,hex(id(johnsAge))) # davidAge=30 # Same as johnsAge print(davidAge,hex(id(davidAge))) # Memory already contains 30 in a Container so both will use single 30 del johnsAge print...
b5b43db23b14f1485ac254bc14196686fc924787
zooonique/Coding-Test
/14954.py
266
3.5
4
n = input() data = [] while True: res=0 for i in n: res+=int(i)**2 if res==1: print("HAPPY") break elif res in data: print("UNHAPPY") break else: data.append(res) n=str(res)
d02403d0cda42cb33e179bb7e255b2d510e2faa7
MarkBrocklebank/Yahtzee
/main.py
15,334
4.125
4
import random ######################################################################## #Classes #rolls a random value from 1-6 #accessed by dice.value class Dice: def __init__(self): self.value = random.randint(1,6) def __str__(self): return "Dice value: " + str(self.value) #popu...
7ce1ed962e5d811fe22024a255c86d0f787c9f63
ShVA010864/Lessons-ShVA
/task_02.2.py
979
3.9375
4
# Поменять местами соседние элементы списка. Если количество элементов нечетноея, то последний # остается без изменений. # data_n = input("Введите несколько любых элементов: >>> ") # print(data_n) list_n = ['a', 'b', 'c', 'd', 'e'] # list_n = tuple(data_n) print(list_n) i = 0 for i in range(int(len(list_n) / 2)): ...
f6f754b88123f3988a0ec017e91cdac43395caac
liu-zhenhua-hua/Play-With-Python
/Python-Learning-01/library/re/regular_third.py
516
3.671875
4
#!/Users/tony/anaconda3/bin/python3 import re """ \w word characters, 这里的word characters 指的是这些(a-z, A-Z,0-9,_) \W 大写的W, 通常是小写w的反义, """ my_search_text = """[]AW""" pattern = re.compile(r'\W') matches = pattern.finditer(my_search_text) for items in matches: print(items) print("=" * 40 + " next regular expre...
a0044767c24ba9c496239632b10182f83cb50ae0
Py-Lerning/python-learn
/lxy/oop/super_and_mro.py
2,909
3.78125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 文章:[Python面向对象中super用法与MRO机制](https://www.cnblogs.com/chenhuabin/p/10058594.html) class A(object): def fun(self): print('A.fun') class B(object): def fun(self): print('B.fun') class C(object): def fun(self): print('C.fun') class D(...
6f2117c21550a0b21c2a733af32cc8f8619c3ca2
okipriyadi/NewSamplePython
/SamplePython/samplePython/internet/_04_BaseHTTPServer_HTTP_GET.py
2,634
3.625
4
""" Purpose BaseHTTPServer includes classes that can form the basis of a web server. To create a custom web server with Python, without requiring any external frame- works, use BaseHTTPServer as a starting point. It handles the HTTP protocol, so the only customization needed is the application code for responding to t...
14ac24b28f570fc122f3308db6468e771a9940a0
VikingJames/MyPythonLearning
/3.py
2,372
3.6875
4
#!/usr/bin/python #coding:utf-8 from string import Template #3-1 print '#3-1' #3-2 print '#3-2' format = "Hello, %s, %s enough for ya?" values = ('world','Hot') print format % values format = "Pi with three decimals: %.3f" from math import pi print format % pi s = Template('$x, glorious $x!') print s.substitute(x='...
26a3abf5eb0f3d84bc23f489d65e2fa5c2875058
rifatmondol/Python-Exercises
/239 - [Functions] Police Interrogation.py
1,772
4.09375
4
#244 - Faça um programa que faça 5 perguntas para uma pessoa sobre um crime. As perguntas são: #a. "Telefonou para a vítima?" #b. "Esteve no local do crime?" #c. "Mora perto da vítima?" #d. "Devia para a vítima?" #e. "Já trabalhou com a vítima?" O programa deve no final emitir uma classificação sobre a #participação #d...
94cf4f6bfac508ab3c4dfc6dcc149d9b95546e3a
pluwum/slc
/tdd/primes/primenumbers.py
667
3.9375
4
# #The function can be represented with O(N2) # # #check if number is a prime def isPrime(number): if number <= 1: return False for x in range(2, number): if number % x == 0: return False else: return True #return list of primes from 0 to Number def primes(number): ...
280c742b64cce1f204fb8de4d6045304bc078e79
dani-fn/Projetinhos_Python
/projetinhos/ex#50 - soma dos pares.py
227
3.90625
4
soma = 0 cont = 0 for c in range(0, 6): n = int(input('Digite um número: ')) if n % 2 == 0: soma += n cont += 1 print('Você informou {} números pares e a soma deles é {}'.format(cont, soma))
f8dc06f832b1366c607b5d6a7053c766f889b496
cynobill/awesome-theme
/BarGraph.py
6,866
3.90625
4
from random import randint import cairo NONE = 0 TOP = 1 BOTTOM = 2 BOTH = 3 class BarGraph(): ############################################################# #args: # (int) x: x coord of the top left of the widget, default = 0 # (int) y: y coord of the top left of the widget, default = 0 # (int) w: width of t...
f700503e66c0863b525e16def06f09ce0aa45e73
danielsilvalima1996/curso-python-udemy
/programacao_funcional/map.py
544
4.09375
4
#!/usr/bin/python3 lista_1 = [1, 2, 3] dobro = map(lambda x: x * 2, lista_1) print(list(dobro)) lista_2 = [ {'nome': 'João', 'idade': 31}, {'nome': 'Maria', 'idade': 37}, {'nome': 'José', 'idade': 26} ] so_nomes = map(lambda p: p['nome'], lista_2) print(list(so_nomes)) so_idades = map(lambda p: p['idad...
eb39c3d06ef30c2e07ed186af74cd2514c652b65
jcattanach/helloPython
/arrayscw.py
1,082
4.0625
4
#name = "John" # #names = ["Alex", "John", "Mary", "Steve"] # #print(names[0]) #loops #while # def prompt_user_for_input(): # first_number = int(input("Enter first number: ")) # second_number = int(input("Enter second number: ")) # return (first_number, second_number) #tuple # # # while True: # # ...
e45be00ccd222b17b67b8e1bbd3154bdfdab01b3
solka-git/Python-Orion-basic-
/lectures/async/observer_test.py
697
3.75
4
class Observer: def __init__(self, cb): self.cb = cb def update(self): self.cb() class Notificator: def __init__(self, id_): self.id = id_ self.observers = [] def add_observer(self, observer): self.observers.append(observer) def notify(self): for...
9a2bdcf1f2606560de23030dbb67c36bdac90119
TomMCallingham/SpaggetiAstro
/Masters/KCollisions/norbit.py
387
3.515625
4
import numpy as np def n(N): n = np.zeros((2, N+1)) # number in row, total number # n[0:3]=[20, 11, 24] BETTER METHOD n[0, 0] = 2 n[0, 1] = 1 n[0, 2] = 2 n[1, 0] = 2 n[1, 1] = 3 n[1, 2] = 5 for i in range(3, N+1): n[0, i] = n[0, i - 1] * n[1, i - 2]+((n[0,i-1]*(n[0,i-1]-1))/...
1bc084835493435cf6d98f0859cdd474f84661d7
Washirican/pcc_2e
/chapter_03/tiy_3_10_every_function.py
1,093
4.4375
4
# --------------------------------------------------------------------------- # # D. Rodriguez, 2019-11-24 # --------------------------------------------------------------------------- # places = ['croatia', 'portugal', 'argentina', 'australia', ''] print('Hey pals, I can only invite two people for dinner!') # for na...
04d62f45dae1b5cf5ce005212f0bbce1a18cc491
fainle/nd256
/utils/linked_list.py
3,013
3.984375
4
class Node: def __init__(self, value): self.value = value self.next = None def __repr__(self): return str(self.value) class LinkedList: def __init__(self, init=None): self.head = None if init: for v in init: self.append(v) def appen...