blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
6a940ab5e58f0989203e16f46eaf7b6d5424a567
ilikemonki/A.I-Assignment-8
/speech.py
2,133
3.546875
4
# Group 1: Meng Cha, Justin Terry # CECS 451 A.I. # 11/21/2019 import speech_recognition as sr import os import distance class Speech: def __init__(self): self.original = [] # original sentences self.recognized = [] # sentences from audio file self.similarity = [] ...
0516f0f36810aba374d67fb6b555f2ce328df6d4
yukiya727/pycharm
/Name and age.py
433
4
4
import datetime yy = input("What is your birth of year? :") mm = input("What is your birth of month? :") dd = input("What is your birth of day? :") print(isinstance(yy, int)) yy = int(yy) mm = int(mm) dd = int(dd) Time = datetime.datetime.now() if mm >= Time.month and dd >= Time.day: age = Time.year - yy - 1 e...
f514cccc21594b8c7378a12c7e6c57e04be34913
mbti-ilham/mysql
/sqlite.py
1,477
3.796875
4
import sqlite3 #conn = sqlite3.connect(':memory:') conn = sqlite3.connect('ma_base.db') cursor = conn.cursor() cursor.execute(""" CREATE TABLE IF NOT EXISTS users( id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, name TEXT, age INTEGER ) """) conn.commit() cursor.execute("""INSERT INTO users(name, age) VALUES(?, ?)""", ("o...
9d9ff3985df69f73021d76dc47bbf587a1bd54f3
elenaveltroni/DataMiningBackEnd
/app/excel_to_mongo/excel_date_to_datetime.py
434
3.5625
4
from datetime import datetime def floatHourToTime(fh): h, r = divmod(fh, 1) m, r = divmod(r*60, 1) return ( int(h), int(m), int(r*60), ) def excel_to_datetime(excel_date): dt = datetime.fromordinal(datetime(1900, 1, 1).toordinal() + int(excel_date) - 2) hour, minute, se...
b8660c0eff8b960795d4b69a57cb5414d1d33bed
Rage997/Numerical_methods
/assignment7/main.py
1,561
3.921875
4
import sympy as sym import numpy as np from computation import computeFD_coeff # ref: https://docs.sympy.org/latest/modules/functions/index.html x = sym.Symbol('x') fun = x**(1./3.) + x def finite_difference(p, h, stencil, points): ''' Evaluate derivative of f at point p given a FD stencil and points i.e....
41fef40c693af3e838186abd711ed763085a1bbd
ycpan1597/VocabGame
/run.py
506
3.671875
4
from wordBank import wordBank from utils import countScores if __name__ == '__main__': unitRange = input('Welcome to the vocab game! Which units do you want to practice? (ex. 12 - 15) ') unitRange = [x.strip() for x in unitRange.split('-')] random = input('Would you like to shuffle the words? (y/n)') wo...
e8b58532691ca631c923253c10b12b8afe0cbfcf
Stashy12399/Schoolwork
/singaporeproblemt5pg19.py
1,157
4.25
4
import math # needed module for rounding the km to 1 decimal place miles_to_singapore = int(7017.2) flight_cost = int(900) # needed variables print("Flight Problem by Stan- 24/09/21") # just the title print("Distance from PLC to Singapore City is : ", miles_to_singapore, "Miles") km_to_singapore = miles_to_singapore ...
cd6fb015791c44d43d397261e621c6523a66eaea
grebes15/cs220-Programming-Language-Concepts
/lab8/Python/lab8.py
2,176
4.4375
4
#Andreas Landgrebe #Lab 8 - I decided to do python #To run this program, open a terminal to the directory that this file is in and type the following: #python lab8.py #first color is already defined in the constructor so you are scanning this in #for the rest, please type in the first name when asked, second name when ...
08672ce9f7c2f86274f0fe7967b0446cf6932260
syeeuns/week1-5_algorithm
/exam/test.py
81
3.59375
4
arr = [1,2,3,4] for i in range(len(arr)-1, -1, -1): print(arr) arr.pop()
f92517ce9dff5c647cf25abf405437a6ab056e74
operation-lakshya/BackToPython
/MyOldCode-2008/JavaBat(now codingbat)/Strings3/CountYZ.py
192
3.953125
4
s=raw_input("\nEnter the string") i=0 count = 0 while(i<len(s)): if(s[i]=='y' or s[i]=='Y' or s[i]=='z' or s[i]=='Z'): if(i==len(s)-1 or s[i+1]==" "): count = count+1 i=i+1 print count
4da4ebf39e70219577064adbddef78a7e31cfea7
varamwar/python
/23-08/input_types.py
641
4.3125
4
name=input("enter your name:") age=int(input("enter your age:")) height=float(input("enter your height")) print(name,age,height) print("my name is",name,"my age is",age,"my height is",height) print("my name is "+name,"my age is",age,"my height is",height) print("my name is"+" "+name,"my age is",age,"my height i...
463483136e28b5323ab2e186ed7f2296ff9732c9
ShubhamGururani/CodeChef-practice
/Beginner/Chef and Two Strings.py
276
3.5
4
for _ in range(int(input())): a=input() b=input() qAny=0 qOne=0 for i in range(len(a)): if(a[i]==b[i] and a[i]=='?'): qAny=qAny+1 elif(a[i]!=b[i] and (a[i]=='?'or b[i]=='?')): qAny=qAny+1 elif(a[i]!=b[i]): qOne=qOne+1 print(qOne,qOne+qAny)
e52df30d920e8a2a1c9bc9d7195077edc5737778
leidyAguiar/exercicios-python-faculdade-modulo-1
/5 lista_vetor/exerc_001.py
638
4.125
4
""" 1. Faça um programa que calcule e apresente a média de idades de uma sala de 35 alunos.​​ """ print('Exemplo de leitura de vetor com o for') vetor_idade = [] # declarando a variável como vetor vazio - fora da estrutura de repetição soma_idade = 0 for i in range(5): vetor_idade.append(int(input('Informe a idad...
8e9950351dc10849a96eb9718f7955d3424dfd6d
Vulnerability-Detection/z3-study
/source/case/38-相反的符号.py
446
3.84375
4
from z3 import * if __name__ == "__main__": x = BitVec('x', 32) y = BitVec('y', 32) # Claim: (x ^ y) < 0 iff x and y have opposite signs # 要求:(x ^ y)<0,如果x和y具有相反的符号 trick = (x ^ y) < 0 # Naive way to check if x and y have opposite signs # 检查x和y是否有相反符号的简单方法 opposite = Or(And(x < 0, y >= ...
1c87c615502a5a8b4e9f4535605205753542e5d1
hfabris/AoC
/AoC2018/day13.py
2,802
3.75
4
import sys def turn(turn_option): if turn_option == 0: return "l" elif turn_option == 1: return "s" else: return "r" file = open(sys.argv[1],'r') input = file.readlines() file.close() oneLeft = False carts = [] last_pos = [] line_pos = 0 map = [] for line in input: sign_pos = 0 map.append(list(line)) ...
278dc1e8b246f07d378f1fc0c24534122e73dd7a
parkeraddison/flowpic-replication
/src/utils/decorators.py
1,076
3.515625
4
import functools # Works, but I just realized now that it's not what I need D: # # def fixed_arguments(**kwargs): # """ # A simple decorator to be used when we want to use multiprocessing -- we can # only pass one argument to each function call, but sometimes we need to pass # additional fixed argument...
18345e2c92c6bdc81c90728dc40b9b366e96a869
afzalupal/urduhack
/urduhack/normalization/space/util.py
1,198
4.25
4
# coding: utf8 """Space utils""" import regex as re from urduhack.urdu_characters import URDU_ALL_CHARACTERS, URDU_PUNCTUATIONS # Add spaces before|after numeric number and urdu words # 18سالہ , 20فیصد SPACE_BEFORE_DIGITS_RE = re.compile(r"(?<=[" + "".join(URDU_ALL_CHARACTERS) + "])(?=[0-9])", flags=re.U | re.M | re...
0c19574e333536f7a8c24bae9e43d12547589322
jamesshapiro/project-euler
/055.py
503
3.828125
4
#!/usr/bin/env python3 -tt def iterate(x): my_x = x while True: x = x + int(str(x)[::-1]) yield x def is_palindromic(x): return str(x) == str(x)[::-1] def is_pseudo_lychrel(x): """ g = iterate(x) print([next(g) for _ in range(50)]) g = iterate(x) print([is_palindromic(...
3f007882b3319ef0f23afefec419380c291f1fd3
kelvincaoyx/UTEA-PYTHON
/Week 4/richTask 4/staticEquilibrium.py
4,653
4.25
4
''' This program is used to help the user practice calculating net torque and estimating which direction the metre stick is going to tip ''' #importing the random library to get random number generator import random #function to help me create random digits. Less to type than random.randrange def randomDigit(start,st...
bfe85b8718eb7e2ec4ce300894f48e3cb06c8106
grifmang/droids
/game.py
3,459
3.765625
4
import random import os import numpy as np import keyboard def build_board(size, level, player_spot, enemy_spots): # Construct a 2D array for game board board = [] for x in range(size): board.append([' ' for y in range(size)]) # Set player icon player = chr(169) # Set killed enemy ic...
5a0f112e6c722cea2fe89be090dd113bec2a8a56
astera/tecc
/astera/2/euler2yield.py
256
3.703125
4
def fibSequ(): a, b = 1, 2 while 1: yield b a, b = b, a + b def main(n): sum = 0 for i in fibSequ(): if i % 2 == 0: sum += i if i >= n: print sum break main(4000000)
0941075ce21b53b18659ba23f61aeff80495f45c
klaus2015/py_base
/code/day04/continue.py
443
3.890625
4
""" 累加10~50之间个位不是2/5/9的整数 """ sum_value = 0 # 我的代码 for item in range(10, 51): if (item % 10) % 2 == 0 or (item % 10) % 5 == 0 or (item % 10) % 9 == 0:# 忽略了2和5的倍数 continue sum_value += item print(sum_value) #老师代码 # for item in range(10, 51): # unit = item % 10 # if unit == 2 or unit == 5 or u...
430a6e90d0280510567a0449555ce807467e43c6
chengming-1/python-turtle
/W12/studio-13/CA.py
1,396
4.0625
4
import random while True: name = input("What is your full name?") print ("Hello " + name, "welcome to Ally") answer1=['good','not bad','cool','fine'] answer2=['bad','not good','sad'] prompt=input("how's going today? Good or bad?") if (prompt.lower() in answer1): options=["What...
266e3195e1c8fcadee45bfe63c2632d23371c833
MaRTeKs-prog/Self-Taught
/Ch 6/chall9.py
86
3.828125
4
str1 = 'три' + 'три' + 'три' print(str1) str2 = 'три' * 3 print(str2)
d999305326b27c060a5f379fb5bde51979cbfd8d
jossotriv/Cool_Stuff
/Desktop/Cool_Stuff/Coding/Misc/Euler Math Problems/SquareSum&SumSquareDiff.py
168
3.671875
4
def find_sum_square_difference(n): sum_of_squares = n*(n+1)*(2*n+1)/6 square_of_sum = ((n**4)+(2*n**3)+(n**2))/4 return abs(square_of_sum - sum_of_squares)
6838e405f60ae81ea2905682fca3d36a73925f42
michealcannon/pands-problem-set
/primes.py
858
4.125
4
# Micheál Cannon - question 6 # a program that asks the user to input a positive integer and tells the user whether or not the number is a prime. # ask for user to input a positive integer; convert to int value and assign to variable i i = int(input("Please enter a positive integer: ")) # if user inputs 1, print "T...
53fec32dd14613a101b3844c0e42838d9e3355c8
k-harada/AtCoder
/ABC/ABC101-150/ABC144/D.py
642
3.5
4
import math def solve_d(a, b, x): if 2 * x == a * a * b: return math.atan(b / a) * 180 / math.pi elif 2 * x > a * a * b: return math.atan((b - x / (a ** 2)) * 2 / a) * 180 / math.pi else: return 90 - math.atan((x / (a * b)) * 2 / b) * 180 / math.pi def main(): # input a, ...
5ee92f7acda3b33b4784b0da5d6c3b13098c33f1
RobinsonF/Taller1
/co/edu/unbosque/model/Metodos.py
1,129
3.75
4
import random class Metodos: def casoPromedio(self, longitud): ''' Esta función se encarga de llenar una lista de manera aleatoria :param longitud: Es el rango en el cual estaran los números aleatorios, y el tamaño de la lista :return: Lista llena ''' ...
4f9745e6ca8d3cb7c78702a06d2ba7a8b23e35aa
borislavstoychev/Soft_Uni
/soft_uni_fundamentals/Lists Basics/exercises/06_survival_of_the_biggest.py
268
3.734375
4
list_of_integer = input().split() n_removed = int(input()) list_of_num = [] for list_of_integer in list_of_integer: list_of_num.append(int(list_of_integer)) for removed in range(n_removed): list_of_num.remove(min(list_of_num)) print(list_of_num)
8f5535d33816a775dd0d48d7e81d535778f9a142
smith-erik/project-euler
/1-10/p6.py
405
3.78125
4
#!/usr/bin/python3 ceil = int(input("Please enter range ceiling (inclusive)\n")) summ, sum_of_square = 0, 0 for n in range(1, ceil + 1): summ += n sum_of_square += n**2 square_of_sum = summ**2 diff = abs(sum_of_square - square_of_sum) print("Sum of squares is %d and square of sum is %d." ...
4941eebf4d148270ab05229593527a48ccdda5d9
FatemehRabie/python_class
/Ex 10.py
676
3.859375
4
#%% print('_____________________ Ex 10 __________________________ \n') class coordinate: x=0 y=0 def Distance(p1,p2): dist = ((p2.x - p1.x)**2 + (p2.y - p1.y)**2)**0.5 return dist p1=coordinate() p2=coordinate() p1.x=int(input ('lotfan x noghte aval ra vared konid')) p1.y=...
51213cc67a22fd53a586e1924d31b03adc45f588
CivilizedWork/-Mr.boring
/day_11/11-4.py
202
3.796875
4
def has_duplicates(t): d = {} for x in t: if x in d: return True d[x] = True return False t=[1,2,3] print(has_duplicates(t)) t.append(1) print(has_duplicates(t))
ba997d32efe54eb145885ef5aed080be27c2515c
cjreynol/willsmith
/tests/games/havannah/test_hex_node.py
2,137
3.578125
4
from unittest import TestCase from games.havannah.color import Color from games.havannah.hex_node import HexNode class TestHexNode(TestCase): def setUp(self): self.board_size = 4 self.node = HexNode(Color.BLUE, (0, 0, 0), self.board_size) def test_new_node_is_root(self): self.as...
b3c358434ba74f6ef11e6be5e8f35a2438030ec0
unfit-raven/yolo-octo
/CST100 Object Oriented Software Development/Random Programs/wordgame.py
736
4.15625
4
# Word Game # Get name name = input("What is your name? ") # Get age age = input("What is your age? ") # Get city city = input("Where did you live when you went to college? ") # Get college college = input("What college did you go to? ") # Get profession profession = input("What do you do for work? ") # Get a pet type...
6d7e82e3178f442b531e5b90fde8be4b87499aa4
nguyenhoangvannha/30-day-of-python
/templates/mycsv.py
265
3.75
4
import csv with open('data.csv', 'w+') as csvfile: writer = csv.writer(csvfile) writer.writerow(['Title','Description']) writer.writerow(['Row 1', 'Some desc']) with open('data.csv', 'r') as csvfile: reader = csv.reader(csvfile) for row in reader: print(row)
982ba7f474535d1a87f0531195932e73343aabe0
shyamkrishnan1999/python-projects
/designer mat/design.py
577
3.71875
4
def mid_pat(x): for i in range(0, x): print(".|.", end="") def side_pat(x): for i in range(0, x): print("-", end="") data = input().split() n = int(data[0]) m = int(data[1]) val = (m - 3) // 2 mid = 1 for i in range(0, n // 2): side_pat(val) mid_pat(mid) side_pat(val) val = ...
ab8a2e00ca61724d99814b0436cfe9eb62bb22d9
Sunliangtai/CS241_Assignment
/assignment3_LiangtaiSun_Windows/Assignment_3_plot.py
528
3.640625
4
import matplotlib.pyplot as plt import numpy as np file = open("D://Visual_code//Cpp//BisectionMethod.txt") Bisection = np.asfarray((file.read()).split('\n')) file = open("D://Visual_code//Cpp//NewtonsMethod.txt") Newtons = np.asfarray((file.read()).split('\n')) iteration = np.array(range(1, len(Bisection)+...
08f0907389b158bd4896db7c2239c13b1c670c51
yugin96/cpy5python
/practical03/q5_compute_series.py
656
3.90625
4
#name: q5_compute_series.py #author: YuGin, 5C23 #created: 21/02/13 #modified: 22/02/13 #objective: Write a function that computes the following series: 4( 1 - 1/3 # + 1/5 - 1/7 + 1/9 - 1/11 + 1/13... + 1 / (2i - 1) - 1 / (2i + 1) # where i is an integer entered by the user. #main #function def co...
e90eb985dae4da776fde72e546043365373d6d34
cdanh-aptech/Python-Learning
/NhapLieu.py
92
3.953125
4
name = input("Please enter your name: ") print("Hello, {0}! Have a nice day!". format(name))
481031357dd02729893444f210fa8cd4faf6392e
Jishasudheer/phytoncourse
/oops/inheritence/person.py
364
3.578125
4
#......single inheritence..... class Person: #Parent class/Base class/super class def walk(self): print("Person is walking") def read(self): print("Person is reading") class Student(Person): #derived class/sub class/child class def exam(self): print("Student is attending exam....")...
7c41d76931a37f81035a2f17fdaa6db7745c8153
stuian/leetcode
/backtrack/337_rob3.py
794
3.765625
4
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def __init__(self): self.memo = {} def rob(self, root: TreeNode) -> int: if not root: return 0 if (root) i...
0eb9efdfc9a980413b811142e270ba2e3434760e
SonBui24/Python
/Lesson02/Bai01.py
158
3.65625
4
age = int(input("Nhập tuổi của khách hàng:")) income = int(input("Thu nhập của khách hàng/năm(USD):")) print((age >= 18) and (income >= 2500))
60abd3c4544952e316d8162c47b5d6501bc25a80
Monty42/DS_and_Python_courses
/GeekBrains/les_9/Првоерка.py
192
3.828125
4
x = 1 y = 2 for i in range(0, y, 1): # Для счетчика i в диапозоне от начала до конца не включая с шагом x += 10 # x = x + 10 print(x)
9d89e1a0927a9d2861536884e78fe99c16c9a0ea
xenron/sandbox-github-clone
/yubinbai/pcuva-problems/UVa 592 - Island of Logic/main.py
2,022
3.640625
4
from itertools import product, combinations import re import sys def judge(role, p, s, it): if s[1] == 'It': return (s[-1] == it) if s[1] == 'I': currP = p else: currP = person[s[1]] if s[3] == 'not': if s[-1] == 'lying': return role[currP] == 'divine' or (...
bb7b47e67610664c935cf18fc8bdd4c2895c3c30
ZL4746/Basic-Python-Programming-Skill
/Second_Part/Concept Learning/03_Abstract_Data_Type&Recurssion/PostFix.py
1,811
4.0625
4
class Stack(): # # Stack methods as defined in class # def __init__(self): self.items = [] def isEmpty(self): return (self.items == []) def size(self): return(len(self.items)) def push(self,item): self.items.append(item) def pop(self): return(self....
37156b90da73b365a099bdf542f13feedd7f7f8e
prabhupant/python-ds
/data_structures/array/intersection_sorted_array.py
379
3.703125
4
def intersection(arr1, arr2): res = [] i, j = 0, 0 while i < len(arr1) and j < len(arr2): if arr1[i] < arr2[j]: i += 1 elif arr2[j] < arr1[i]: j += 1 else: res.append(arr1[i]) i += 1 j += 1 return res arr1 = [1,2,3,4,5...
2fd5bfe1eb4694012589baf201777f4089acc3ab
nukarajusundeep/myhackerrank
/Forked_Solutions/Pythonist_3/alphabet_rangoli.py
2,829
3.703125
4
""" You are given an integer, N. Your task is to print an alphabet rangoli of size N. (Rangoli is a form of Indian folk art based on creation of patterns.) Different sizes of alphabet rangoli are shown below: #size 3 ----c---- --c-b-c-- c-b-a-b-c --c-b-c-- ----c---- #size 5 --------e-------- ------e-d-e------ ---...
a33acb3226d1f1b6a3fa7db5587be3777727ee75
CS-CooJ/Python_Crash_Course
/ch_10/pi_string.py
532
3.734375
4
filename = 'pi_digits.txt' with open(filename) as file_object: lines = file_object.readlines() pi_string = '' for line in lines: pi_string += line.rstrip() print(pi_string) print(len(pi_string)) """if we had 1 million digits of pi and only wanted to print the first 50:""" filename = 'pi_million...
9afdfdf901f4af11fca1f47d47ece2590651526a
chrissiedesemberg/code_college-python
/chap9/tiy229_9_3.py
1,228
3.578125
4
class User: """User input capturing""" def __init__(self, first_name, last_name, email, mobile, user_name): """Initialize name and type attributes.""" self.first_name = first_name self.last_name = last_name self.email = email self.mobile = mobile self.user_name =...
93c529a725f1daffaa761951d2f40b94ca41894f
prijindal/Interactivepython-Solutions
/recursion/intToString.py
252
3.796875
4
def intToString(number, base=10): convertString = '0123456789ABCDEF' if number/base == 0: return convertString[number%base] else: return intToString(number/base, base) + convertString[number%base] print(intToString(10, 2))
97c4e10ec50db3c14e54aa6bd8892e85ad6bdc41
sunitskm/Python
/edureka_old/module2/Assignment/Question8.py
81
3.65625
4
l = ['a','b','c','d'] e = enumerate(l) dict1 = {j:i+1 for i,j in e} print(dict1)
e430b9fe1a4da3e61338859660ea75add141c9c6
wallee3535/AdventOfCode2019
/day1.py
684
3.640625
4
def solve1(): fuel = 0 with open('./inputs/input1.txt', 'r') as fp: for line in fp: mass = int(line) fuel += mass//3 - 2 return fuel print('part 1 solution:', solve1()) def getFuel(mass): return mass//3 -2 def solve2(): totalFuel = 0 with open('./inputs/inpu...
4cd338ff0bcd67cca46b285be1c73560ce856dcc
Kartavya-verma/Python-Programming
/35.py
123
3.921875
4
#35.Write a python program to create an union of sets. s1={1,2,3,4,5,6} s2={5,6,7,8,9,10} union_set=s1|s2 print(union_set)
564cf4cd28a018788b291168ede5aa1c74dcf071
MichealGarcia/code
/py3hardway/Main.py
3,016
4.3125
4
# This is using PEP 8 guidelines to create habit in skills to program efficiently # This practice script will take objects and have them interact. Specifically, the main class is a meeting between you, and a stranger. # when people meet they interact, or they ignore. # Attributes of meeting include -> greetings like ...
8adf345def689ca214d6950eb30bce00764a5fde
shen-huang/selfteaching-python-camp
/exercises/1901010060/1001S02E04_control_flow.py
957
3.609375
4
#使⽤ for...in 循环打印九九乘法表 '''for i in range(1,10): for j in range(1,i+1): #内层循环 print("{}*{}={}".format(i,j,i*j),end=" ") print(" ") ''' #使用for循环打印九九乘法表并把偶数行去掉 '''for i in range(1,10): for j in range(1,i+1): if i %...
59d48c5864d1d36ea1920702852e5f2cd868c5a8
Pearltsai/lesson4HW
/lesson4HW_2_input.py
115
3.921875
4
x=input('number?') x=int(x) for x in range(1,x+1): print('*'*x) for x in range(x-1,0,-1): print('*'*x)
8432973ae14013cdbf97181a94e17d2bcfa8ebd9
rafhaeldeandrade/learning-python
/2 - Variáveis e tipos de dados em Python/Exercicios/ex20.py
324
3.671875
4
""" 20. Leia um valor de massa em quilogramas e apresente-o convertido em libras. A fórmula de conversão é: L = K / 0.45, sendo K a massa em quilogramas e L a massa em libras. """ quilogramas = float(input('Digite a massa em quilogramas: ')) libras = quilogramas / 0.45 print(f'{quilogramas}kg corresponde a {libras}lb')...
70db54066e5d0ae12683ba009273366317299f3d
oliveiralecca/cursoemvideo-python3
/arquivos-py/CursoEmVideo_Python3_DESAFIOS/desafio112/utilidadescev/dado/__init__.py
308
3.5625
4
def leiaDinheiro(msg): valido = False while not valido: ler = str(input(msg)).replace(',', '.').strip() if ler.isalpha() or ler == '': print(f'\033[31mERRO: "{ler}" não é um preço inválido!\033[m') else: valido = True return float(ler)
0e32610c1d85c5b9282b231a6863b7f550a69a08
Murilloalves/estudos-python
/mundo-2/estruturas-de-repeticao/for/tabuada_v2.py
148
3.96875
4
n = int(input('Digite um número para ver sua tabuada: ')) for i in range(1, 11): resul = i * n print('{} x {:2} = {}'.format(n, i, resul))
6f0cd3c8e28db4ea1684fed8a883a1491a408a06
lingxd/mypy01
/mypy09.py
385
3.921875
4
# while语句练习 numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] even = [] odd = [] while len(numbers) > 0: number = numbers.pop() if number % 2 == 0: even.append(number) else: odd.append(number) # sorted([字符]) : 排序 print("偶数:{0}\n奇数:{1}".format(sorted(even), sorted(odd))) print("偶数:", sorted(even),...
07a2afca44b7841751917e54cc774175f94a2ef4
changediyasunny/Challenges
/leetcode_2018/215_kth_largest_element.py
1,166
4.03125
4
""" 215. Kth Largest Element in an Array Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Example 1: Input: [3,2,1,5,6,4] and k = 2 Output: 5 Example 2: Input: [3,2,3,1,2,4,5,5,6] and k = 4 Output: 4 Running time: (N) for ...
9954103a84ab53b2bd94fa7dba60929c0013923a
muzudho/collatz
/lifegame_lj.py
2,011
4.15625
4
""" 左寄せ表記(Left justified) """ import os import numpy as np # 環境変数 RADIX = int(os.getenv("RADIX", 2)) # 桁揃えに利用。10進数27 を指定したときの見やすさをデフォルトにするぜ(^~^) count_width = 3 count_str = "" dec_width = 4 dec_str = "" radix_str = "" # 表示した数の個数 count = 0 def update_print_number(dec): """表示するテキストの更新""" global count_width ...
b8ddaea143b7434b8c7bbf4269e5b65087a3efa7
Shree1108/sttp
/python_code/fileio.py
983
4.25
4
#The open Function # Example 1 write mode fo = open("gen.txt", "w") print ("Name of the file: ", fo.name) print ("Closed or not : ", fo.closed) print ("Opening mode : ", fo.mode) fo.write( "Python is a great language.\nYeah its great!!\n") fo.close() # Exmaple 2 - read write mode fo = open("gen.txt", "r+") str = fo...
559bbc8974dc92655138c8759889fcc33a2ead17
leastweasel/ProjectEuler
/Problem25.py
229
3.53125
4
fibA = 1 fibB = 1 term = 3 while True: fibC = fibA + fibB if len(str(fibC)) >= 1000: print(fibC) print("Term:", term) break else: fibA = fibB fibB = fibC term += 1
1e90111cac49e20275cd824b016d07f61ec8028a
cloudsecuritylabs/learningpython3
/ch1/argv_and_input.py
915
4.28125
4
# this program combines input from the commandline and also from user from sys import argv script, user_name = argv # from the commad line, you can pass one variable prompt = '>' print(f'Hello {user_name}, you are running this script: {script}') # use f- formatter age = input(f"How old are you? {prompt} ") height = i...
3e4c6b67d74dd9518cab9043f8707ee7e8185dea
vizeit/Leetcode
/SplitStrInBalStr.py
384
3.640625
4
def balancedStringSplit(s: str) -> int: su = 0 cnt = 0 for c in s: su = su + 1 if c == 'R' else su - 1 if su == 0: cnt += 1 return cnt if __name__ == "__main__": print(balancedStringSplit("RLRRLLRLRL")) print(balancedStringSplit("RLLLLRRRLR")) print(balancedStrin...
091df8021a7aefc4e82ee59844e89e232a859dac
yangyuxiang1996/leetcode
/剑指 Offer II 009. 乘积小于 K 的子数组.py
1,731
3.828125
4
#!/usr/bin/env python # coding=utf-8 ''' Author: Yuxiang Yang Date: 2021-08-25 23:26:12 LastEditors: Yuxiang Yang LastEditTime: 2021-08-25 23:55:32 FilePath: /leetcode/剑指 Offer II 009. 乘积小于 K 的子数组.py Description: 给定一个正整数数组 nums和整数 k ,请找出该数组内乘积小于 k 的连续的子数组的个数。 输入: nums = [10,5,2,6], k = 100 输出: 8 解释: 8 个乘积小于 100 的子数组分别...
81cbeb38a1c0212e4baa1eac9a6fa4c249fdec46
aljoharrakh/100DaysOfCode
/Day8.py
519
3.875
4
s=" Hello everyone , today is the seventh day of the Saudi Programmers Initiative . " print(s) print("********** use Strip method **********") print(s.strip()) print("********** use len method **********") print("length os string is ", len(s)) print("********** use lower method **********") print(s.lower()) print("****...
6316eea41eb89ce76e99e6fd913a62325b183b65
ChrisLiu95/Leetcode
/Medium/Group_Anagrams.py
828
4
4
""" Given an array of strings, group anagrams together. For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return: [ ["ate", "eat","tea"], ["nat","tan"], ["bat"] ] """ import collections class Solution(object): def groupAnagrams(self, strs): dic = collections.defaultdict(list) ...
4f9bd6c30ded26e0baf438ec89e5f6179a3cb405
som-shahlab/fairness_benchmark
/prediction_utils/extraction_utils/util.py
324
3.875
4
import random def random_string(num_characters=5): """ Generates a random string of length N. See https://pythonexamples.org/python-generate-random-string-of-specific-length/ """ return "".join( random.choice(string.ascii_lowercase + string.digits) for _ in range(num_characters) ...
faa52ede0fdec5c82801e56f6838da4c4962efd5
hbharmal/CS303E-CS313E
/Poker.py
7,956
3.671875
4
import random class Card (object): # 14 different cards RANKS = (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14) # Clubs, Diamond, Hears, Spades SUITS = ('C', 'D', 'H', 'S') def __init__ (self, rank = 12, suit = 'S'): if (rank in Card.RANKS): self.rank = rank else: self.rank = 12 if (suit in Card.SU...
71814f7f4ea08882f275c453282d48fb3aefb1b8
bapi24/python_crash_course
/exceptions/addition.py
388
4.09375
4
''' input two values write a function which adds two numbers include try except for value errors ''' def sum(num1,num2): try: sum = int(num1) + int(num2) except ValueError: print("Check input you have entered!!") else: print("result: " + str(sum)) num1 = input("Enter number1: \n>")...
69f2230b83dc9752b8161f48e80d9f85802e67eb
infinite-Joy/programming-languages
/python-projects/algo_and_ds/1536_Minimum_Swaps_to_Arrange_a_Binary_Grid.py
671
3.703125
4
""" we can probably use backtraking in this for each backtracking we will need to create an array out of this """ """ we can implement kind of a backtracking approach with a dfs based on pruning to check if the earlier configuration has been checked dont look at it again """ from typing import List def convert_t...
2f3551cb07e06cd7134014b003becd74c7618bc6
Aasthaengg/IBMdataset
/Python_codes/p02411/s254642345.py
323
3.59375
4
while True : a, b, c = [int(temp) for temp in input().split()] if a == b == c == -1 : break if (a == -1) or (b == -1) or (a + b < 30) : print('F') elif (80 <= a + b) : print('A') elif (65 <= a + b) : print('B') elif (50 <= a + b) or ((30 <= a + b) and (50 <= c)) : print('C') else : print('...
fcc5b6eafef8920cbcabb5948606430d1a8bc5c1
QMHTMY/DataStructurePy
/sort/bubbleSort.py
1,648
3.875
4
#!/usr/bin/python3 """冒泡排序 优点:维持项的稳定,缺点:费时 每轮循环不断交换元素,最后将最大值放在最后 """ def bubbleSort1(alist): if alist is None: return alist for passnum in range(len(alist)-1, 0, -1): for i in range(passnum): if alist[i] > alist[i+1]: alist[i], alist[i+1] = alist[i+1], alist[i] ...
9e48f7a2a998b5f94bd86a4dc8d720dc3466f1b9
Cediba/Learning_Python
/powertable.py
440
4.125
4
#This programm prints a table of powers of x. NMAX = 4 XMAX = 10 #print table header for n in range (1, NMAX + 1 ) : print ("%10d" % n, end="") for n in range (1, NMAX + 1) : print ("%10s" % "x", end="") print ("\n", " ", "-" * 35) #print table body print() for x in range (1, XMAX + 1) : #print ...
e3dce8b9f4a69d5414536d0238f30d19ab4f0c93
xia-lao/gbai
/l5.py
7,255
3.65625
4
def task_1(): """1. Создать программно файл в текстовом формате, записать в него построчно данные, вводимые пользователем. Об окончании ввода данных свидетельствует пустая строка.""" with open ("somefilename", "w") as sfl: var = input('Write something') while True: sfl.write(var+"\n") var ...
ceffbb2e9951e056e51e7f9c33ef27ae5dcb918e
iamhimmat89/pyspark
/sql_explain.py
303
3.515625
4
from pyspark.sql import SparkSession spark = SparkSession.builder.appName("sql explain").getOrCreate() parquetFile = spark.read.parquet("data.parquet") parquetFile.createOrReplaceTempView("parquetFile") teens = spark.sql("select * from parquetFile where age >= 13 and age <= 19") teens.explain(True)
f2dad620e303a4f4d070232c088265b5b325bb94
NVZGUL/din_p
/sol.py
1,405
3.65625
4
#ТАБЛИЦА ИЗ УСЛОВИЯ ЗАДАЧИ data = [{"electorate": 3100, "Money": 1050000}, {"electorate": 2600, "Money": 750000}, {"electorate": 3500, "Money": 1200000}, {"electorate": 2800, "Money": 900000}, {"electorate": 2400, "Money": 600000}] #МЕТОД НАХОЖДЕНИЯ МИНИМАЛЬНОЙ СУММЫ НАШИХ ДАННЫХ def my...
94ce942b32ff25a690881f134ccabda42aeea534
durgaprasad1997/missionrnd_python_course
/mocktest2_problem1.py
2,346
4.125
4
max_marks = 20 problem_notes = ''' Given a sentence in which words are separated by spaces. Re-arrange it so that words are reordered according to the following criteria. - longer words come before shorter words - if two words have same length, the one with smaller vowel occurance count comes first (feeel co...
31e1397d08022156ebf6e17ec4ab43e82fc9434c
WilliamBlack99/Moonshot
/setup.py
3,681
4
4
from math import sin, cos, radians import pygame pygame.init() # find the locations of planets and the angles of their moons from a .txt file # the .txt file should be formatted like this: # # planet 1,2 90 120 # # the first word is a keyword as to what type of object to load # for planets, the second val...
65b0dd4064a38a1c4a7055d4ec9c323c8515a6f1
Goto15/HackerRankCode
/nestedLists.py
479
3.734375
4
def second_lowest(gradebook): temp_students = [] temp_second = None gradebook.sort(key=lambda i: i[1]) lowest_grade = gradebook[0][1] for i in gradebook: if i[1] > lowest_grade: temp_second = i[1] break for i in gradebook: if i[1] == temp_second: ...
510a2288a4fb2fa5b90af857a56661ae846c36da
qsctr/language-guess
/guess-language.py
714
3.6875
4
#!/usr/bin/env python3 def guess_language(filename): with open(filename, encoding='utf-8') as textfile, open('data.csv', encoding='utf-8') as data: (_, *letters), *rows = zip(*[line.split(',') for line in data.read().splitlines()]) text = ''.join(filter(letters.__contains__, textfile.read().casefol...
33cdeb3d76bb186b6280ca1ae1462c349ac773e8
ppcrong/TestPython
/TestPython/set_test.py
371
3.796875
4
a = (1, 2, 2, 3, 3, 3, 'a', 'b', 'c', 'c') print(a.count(2)) print(a.count(3)) print(a.index(1)) print(a.index('a')) a = set(a) b = set([1, 3, 5, 'a', 'c', 'e']) print(a) print(b) c = a.copy() print(c) c.clear() print(c) c.add(1) c.add(2) print(c) c.remove(1) print(c) print('交集:', a.intersection(b)) print('聯集:', a....
0c92b0458fc4d36ddaf7471e96bbafa93038ebdf
Annihilation7/Leetcode-Love
/2020-04/4-18/560和为k的连续子数组/560.py
909
3.546875
4
# -*- coding:utf-8 -*- # Editor : Pycharm # File : 560.py # Author : ZhenyuMa # Created : 2020/4/18 下午11:16 # Description : 由于是连续区间,从某一个位置开始一段数字的和与target相等, # 所以类似积分图的思想,建立record, 从头开始记录_sum,然后找_sum-target是否 # 在record中,不在就添加进record,在的话就是找到了,即加上前面_sum-target # ...
e030788fd8385a479748b6889746df9018f0952c
udwivedi394/python
/bottomView.py
1,271
4
4
class Node: def __init__(self,data): self.data = data self.left = None self.right = None #Prints the Level Order traversal of binary Tree #Prints the Bottom View of Binary Tree def bottomView(root): temp = root #Lookup, {pos: NodeData} hashmap = {} #Node in queue is of form, [Node, horizontal position wrt ...
7836081e9322dcfe3d616ce58027993772a9f69a
bobyaaa/Competitive-Programming
/Other/Next Prime.py
589
3.640625
4
//Use xrange() if you ever have break. range() pre-creates the list and that can be memory inefficieint. //The code below is a bit ugly because I used some measures to optimize it. //Solution by Andrew Xing n = input() breaker = False if n == 1 or n == 2: print 2 elif n == 3: print 3 elif n == 5 or n == 4: prin...
4684a0323e93eabd5e23bb9d89ae0e36e9b8c5d4
josephcardillo/lpthw
/ex16.py
1,204
4.375
4
# from the sys module, import the argv object from sys import argv # just ask for the filename when running the script script, filename = argv print(f"We're going to erase {filename}.") print("If you don't want that, hit CTRL-C (^C).") # Shows a ? on the screen, and if you hit any key it continues. It's not set to any...
ed63ce7cb8cdfba359456697abfacd23111242bf
crawler4o/UpWork
/Person_classes/person_class.py
1,980
4.53125
5
### I've tried everything and I need help with the following in Python ### ### ### Create a Person class that has the following attributes. Make sure that these attributes are private: ### Name ### Age ### Date of Birth ### ### Create an __init__ method that takes these three attributes to create a Person class. ### ##...
c83288fc950199864dc02f6c63806315ec27db57
gunjany/hangman
/hangman.py
1,106
3.796875
4
import secrets def hangman(word): wrong = 0 stages = ["", "_____________ ", "| ", "| | ", "| O ", "| /|\\ ", "| / \\ ", "| " ] rletters = list(word) board = ["__"] * len(word) chance = l...
4411f79469645f5d5331080ed1336dd41a7b1911
VelcroFly/Python-Algorithms
/practice_2/7.py
584
4.03125
4
"""Напишите программу, доказывающую или проверяющую, что для множества натуральных чисел выполняется равенство: 1+2+...+n = n(n+1)/2, где n — любое натуральное число.""" def count_sum(n): if n == 1: return n res = n + count_sum(n-1) return res n = int(input('Введите любое натуральное число')) le...
e7329bd376e03f295bdbdd14c7582e1d79ecf39e
pedro-eduardo-garcia-leyva-2019630556/-Compiladores2021B
/Practicas/Gramaticas con ASDR/gramatica2.py
953
3.84375
4
import sys """ Gramatica: A->BCDEa B->bCD B->a C->cA C->f D->d E->e """ string = "afdea" index = 0 def consumir(simbolo): global index if index >= len(string): sys.exit("No pertenece") elif string[index] == simbolo: index += 1...
487b76abbd9a314d830f67a5ae8f151ec78d08a8
cobbman/PirateBattleship
/start.py
3,804
3.953125
4
from __future__ import print_function import player import gameboard import boat import game import displayArt """ How this will work: start.py gathers information such as player name and how many boats they want to sink. Then creates a Game object which runs the game. Then the user is shown the gameboard and is as...
5858bb1c18910e8fe1fafd1a9f392793532cbb7a
Olamyy/abstract-datatypes
/fractions.py
2,234
3.875
4
class Fraction(object): def __init__(self, numerator=None, denominator=None, decimal=None): self.numerator = numerator self.denominator = denominator self.decimal = (self.numerator / self.denominator) if not decimal else float(decimal) if isinstance(self.decimal, int): se...
28c8aefff47be8a7718f8e6536ead58e052cfdcc
kjnh10/pcw
/work/atcoder/abc/abc082/B/answers/874730_iyauchi.py
94
3.875
4
val = sorted(input()) val2 = sorted(input(),reverse=True) print("Yes" if val2 > val else "No")
49fe45b673858776b647956d1a5326ebe09d3514
anantprakash17/leetcodeSolutions
/CountPrimes.py
504
3.78125
4
class Solution: def countPrimes(self, n: int) -> int: # We will use Sieve of Eratosthenes to calculate number of primes up to n. if n < 2: return 0 arr = [True] * n primes = 0 arr[0] = False arr[1] = False for i in range(2, n): if arr[...
9d1af3b632d232a2351129059d782684f1a56c60
PacktPublishing/Python-Data-Science-with-AI-for-Beginners
/Chapter02/get_first_n_elements.py
150
3.75
4
array = [55, 12, 37, 831, 57, 16, 93, 44, 22] print("Array: ", array) n = int(input("Number of elements to fetch from array: ")) print(array[0: n])
0b68b088eaaf44518d6f0d0c149276997027118b
wentingsu/Su_Wenting_spring2017
/Final/codePY/Analysis4.py
3,718
3.65625
4
# coding: utf-8 # # Analysis 4 # # * analyse the variable # * from previous analyses we can find out that the happiness scores difference between Western Europe and Central and Eastern Europe is large. In this analysis, let's find out each how variables influence the outcomes. # In[3]: import pandas as pd # from ...
75df475d367bea04942d1e6f02c2def55c92343c
marioleonardo/informatica_1_lab
/laib8/es1.py
785
3.59375
4
import random as rd import time rd.seed(time.time()) def main(): lista1 = [rd.randint(1, 100) for i in range(13)] lista2 = [rd.randint(1, 100) for i in range(10)] print(lista1) print(lista2) print(merge(lista1, lista2)) def merge(lista1, lista2): lista3 = list() listFinished = False ...
c6fb83d06732e724b7a1550e10e038328caa0e96
ChrisViral/AdventOfCode
/2018/Python/Challenges/Day2.py
1,668
3.859375
4
import sys from typing import List, Set from collections import Counter def main(args: List[str]) -> None: """ Application entry point :param args: Argument list, should contain the file to load at index 1 """ twos: int = 0 threes: int = 0 ids: List[str] = [] # Read file with ope...