blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a2f57cd856753655ccab498255f391aa1dc33829
GlenHaber/euler
/problem86.py
1,617
4.15625
4
""" Cuboid route A spider, S, sits in one corner of a cuboid room, measuring 6 by 5 by 3, and a fly, F, sits in the opposite corner. By travelling on the surfaces of the room the shortest "straight line" distance from S to F is 10. The path is a diagonal along the 6x5 floor, then a diagonal up the 6x3 wall However, ...
2fda2c86022e48152f5fd06e5036147fdb10b2d0
manelbenaissa/learning
/roboc/map.py
3,107
4.25
4
# !usr/bin/python # -*-coding: utf-8 -*- """Define map class.""" class Map: """ Create a Map object. It should be easy to: - Add a new map - Delete a map - Modify a map """ def __init__(self, name): """ Methode constructeur. Create a map with a text file. ...
a189e8d149c87bcabb8efe662683acbb5a2cfecd
coolafabbe/UdemyPythonSandbox
/25_csv/us-states-game-start/main.py
1,122
3.671875
4
import turtle import pandas from pandas._libs import missing # create screen screen = turtle.Screen() screen.title("U.S. states game") image = "blank_states_img.gif" screen.addshape(image) turtle.shape(image) my_turtle = turtle.Turtle() my_turtle.penup() my_turtle.hideturtle() data = pandas.read_csv("./50_states.csv...
e0b7f7489ce80b4807e0aea43135c1875c7c3eb7
ArloZ/pythonOSC
/data/dataConvert.py
843
3.53125
4
#-*- coding = UTF8 -*- ''' file : dataConvert.py date : 2013-3-12 author : qlzhangtju@gmail.com note : convert the value the display available ''' class DataConvert(): ''' brief 将数值转换成电压表示形式,转换后单位为 V(伏特) bits 量化精度 posV 正向电压 negV 反向电压 ''' def __init__(self,bits...
d00aaf70080c6b3541e343066aa526bb3126bb4e
Nermin-Ghith/ihme-modeling
/mortality_code/fataldiscontinuities/gbd_2016_shocks/00_dataCollection/WHO_epidemic_scrape.py
4,695
3.53125
4
''' Author:NAME Date: 11/18/16 Purpose: Scrapes data from WHO emergency preparedness and response pages. Problem: Data are tabluated by conflict and year, but selecting multiple conflicts only allows the user to select overlapping years. Furthermore, data are returned as HTML tables; they are jus...
97df7c807321fbdca614f9d4bde7df5bb235ae20
ojenksdev/dataquest
/python-for-data-science-fundamentals/Conditional Statements-313.py
4,057
3.625
4
## 1. If Statements ## opened_file = open('AppleStore.csv') from csv import reader read_file = reader(opened_file) apps_data = list(read_file) free_apps_ratings = [] for row in apps_data[1:]: rating = float(row[7]) # Complete the code from here price = float(row[4]) if price == 0.0: free_apps_...
d2f3a57e360698e5accfe0c86500d01eda9a6948
thisiswei/udacity-self-driving-car
/tmp.py
7,789
3.6875
4
import math import os import matplotlib.pyplot as plt import matplotlib.image as mpimg import numpy as np import cv2 _Y_HEIGHT = 320 def grayscale(img): """Applies the Grayscale transform This will return an image with only one color channel but NOTE: to see the returned image as grayscale (assuming...
a45f83ab331a1438df86a746e7aa12d383fc5fbf
anoubhav/30-Day-SDE-Challenge
/Day_23/1_clone_graph.py
1,594
3.671875
4
# Q: https://leetcode.com/problems/clone-graph/ # Ref: https://leetcode.com/problems/clone-graph/discuss/42314/Python-solutions-(BFS-DFS-iteratively-DFS-recursively)./420527 # Definition for a Node. class Node: def __init__(self, val = 0, neighbors = None): self.val = val self.neighbors = ...
7b617c0e5b2ae908f38fba4c7a22701a39275d2c
danilglinianiy/Python
/LAB1/lab1_task_2.py
286
3.828125
4
from random import randint userNum = input('Enter your number:') a = int(userNum) n = randint(0, 100) if(a>n): print('Your number is higher') if(a<n): print('Your number lower') if(a==n): print('Thats fantastic, you guessed the number!') print('\nRand number is: ', n1)
8d1faf1d194b170da71fa9224e49bfa9fe018590
RhythmG/Unit-6
/lenofcurve.py
760
3.984375
4
#Stephen Wang + Maia Reynolds #Calculus Programming Week #Length of a Curve from math import * nInterval = 10000 def f(x): return sin(x) def derivative(x): h = 1.0/nInterval rise = (f(x+h)-f(x-h))*0.5 run = h slope = rise/run #definition of derivative return slope def lenf(x): df = ...
18020c4f50b78b0fe35baf22dc529ee9e07fd7a4
citlalygonzale/TC1014
/e.py
208
3.71875
4
def calculate_e(c): x = c ce = (1+1/x)**x return float(ce) r = int(input("Number of decimal points of accuracy: ")) resulte = calculate_e(r) print("The estimate of the constant e is:",resulte)
99f4446ae78945dd72fd230fb629837e0c561623
ConnorCairns/New-Summer-Assignment
/Database Creation.py
740
3.75
4
#This only needs to be run once import sqlite3 conn = sqlite3.connect("users.db") c = conn.cursor() c.execute("""CREATE TABLE student (ID INTEGER NOT NULL, name TEXT NOT NULL, userName TEXT NOT NULL, PRIMARY KEY(ID))""") conn.commit() c.execute("""CREATE TABLE res...
7997868a33ce0b76b9fe914d73ee6d1b0929dbb4
Jovamih/PythonProyectos
/class/People.py
346
3.65625
4
# /usr/bin/env python3 class People(object): def __init__(self,name,edad,dni,region): self.name=name self.edad=edad self.dni=dni self.region=region def crecer(self): self.edad=self.edad+1 def __str__(self): return "{}, {} años con DNI {}".format(self...
8af6d1baec693e15e7eba6afda965f35d4791950
syamsss6/imagepuzzle
/.code/1.py
336
3.828125
4
#!/usr/bin/python def print_urls(file): #Each line is of the form: GET /foo/bar/a.jpg #remove the GET and print only /foo/bar/a.jpg #use a for-loop to iterate through each line of `file' #split the line and print second part for line in f: print line.split()[1] f = open('1.txt') print_u...
ba11ffb81fa5610c04fe3cb4c1a15d42ef72174b
karanshah743/Fibonacci-Numbers
/Fibonacci Numbers.py
414
4.375
4
terms = int(input("Enter a number up to how many terms you want the Fibonacci Numbers : ")) def fibonacci(n): if n <= 1: return n else: return fibonacci(n - 1) + fibonacci(n - 2) if terms <= 0: print("Please enter a positive number rather than 0.") else: print("The Fibon...
07fd9e8378a29ac83090db23146ba1fd52b944c2
notsoseamless/python_training
/principles_of_computing/1_4_Yahtzee/gen_all_sequences.py
1,991
4.0625
4
""" Functions to enumerate sequences of outcomes Repetition of outcomes is allowed """ def gen_all_sequences(outcomes, length): """ Iterative function that enumerates the set of all sequences of outcomes of given length """ ans = set([()]) for _ in range(length): temp = se...
b7514da5593ab0f35bee6e003a0f6cfbc32f156b
Ojenge/python-sandbox
/loop_tuples.py
282
3.859375
4
test_tuple = ('I', 'am', 'a', 'test', 'tuple') new_tuple = () size = len(test_tuple) new_size = size + 1 #new_tuple = new_tuple + (test_tuple[2],) #print(new_tuple) for i in range(size): if i % 2 == 0: new_tuple = new_tuple + (test_tuple[i],) print(new_tuple)
c02faeb8fa488f2b0f482f079271a823bd01bc17
zhenyzha/envtool
/base/base_vmt.py
1,126
3.65625
4
#-*-coding:utf-8-*- class Base(object): pass class Color(object): def __init__(self): self._red = '\033[31m' self._green = '\033[32m' self._yellow = '\033[33m' self._blue = '\033[34m' self._fuchsia = '\033[35m' self._cyan = '\033[36m' self._white = '\033...
9e3ca114c564d7dbd48b76c7d177105aaef2810c
RuiwenP2018/hwcpg2018
/hw5/p2.py
229
4
4
currentNumber = float (raw_input ("Pleace enter a random number? ")) if (currentNumber%2 == 0): finalNumber = 3 * (currentNumber + 1) print (finalNumber) else: finalNumber = currentNumber / 2 print (finalNumber)
0ea6339a7b9e08e70630607e8a21c06de0013851
Hunter-Dinan/cp1404practicals
/prac_01/menus.py
375
3.96875
4
name = str(input("Enter name: ")) menu = """(H)ello (G)oodbye (Q)uit""" print(menu) menu_input = str(input()) while menu_input != "Q": if menu_input == "H": print("Hello {}".format(name)) elif menu_input == "G": print("Goodbye {}".format(name)) else: print("Invalid input") print...
0c722d71ae87ad6b1ca5fb803daaeaefe3f3483e
anniechannon/h07-pypt-submission
/capitalizer.py
71
3.671875
4
word = input("Enter the word:") word_cap = word.upper() print(word_cap)
6ec2e21e277acd0b18a98c0bb6b120301b71838f
millu94/joshuas_weekend_hw_01
/src/pet_shop.py
2,182
3.6875
4
# WRITE YOUR FUNCTIONS HERE import pdb #1 find the name of the pet shop def get_pet_shop_name(pet_shop_info): name = pet_shop_info["name"] return name #2 find the total cash def get_total_cash(pet_shop_info): total_cash = pet_shop_info["admin"]["total_cash"] return total_cash #3 + #4 add or remove ca...
1ae968ac2d42a6a6d79d16a6ab97e1d08c813365
imscs21/myuniv
/1학기/programming/basic/파이썬/파이썬 과제/homework/hw1.py
4,622
3.65625
4
Grade_A = [int(90),int(100)] Grade_B = [int(80),int(89)] Grade_C = [int(70),int(79)] Grade_D = [int(60),int(69)] Grade_F = [int(0),int(59)] def GetGrade(score): if(score>=Grade_A[0] and score <= Grade_A[1]): return "A" elif(score<Grade_A[0] and score >= Grade_B[0]): return "B" elif(sc...
be0a5ffdea0ad26392950b25c7f99975b7122ceb
JoshKarpel/euler-python
/problems/033.py
1,070
3.65625
4
import itertools from math import ceil from problems import mymath def solve(): numerators = range(10, 100) denominators = range(10, 100) fractions = [] for numerator in numerators: for denominator in denominators: if denominator > numerator: fractions.append([num...
40a50773bc32105e2ccb62cbfc8436be741b57d9
jonahswift/pythonStudy1
/firstDay/studyGames.py
833
4.09375
4
''' 需求:游戏 石头剪刀 布 分析: 玩家:a 电脑:b 剪子:1 布:2 石头3 输赢 玩家:剪子 电脑 布 a==1 and b==2 ''' import random #随机数 #num = random.randint(1,3) #print(num) puit = str(input('请猜拳,你出了:')) num = random.randint(1,3) #print(f'电脑出的是{num}') if num ==1: num1 = '石头' elif num ==2: num1 = '剪子' else: num1 ='布' print(f'电脑出的是{num1}'...
abc69507fac7e69a2624958f1ffb0e6aedfbf83e
DavidBlazek18/Python-Projects
/Web_Generator_Assignment/webConstructorWithGUI,II.py
3,940
4.0625
4
# Python: Ver. 3.7 # Author: David Blazek # Program: Web Page Generator (Python Course Assignment Page 250, The Tech Academy) import webbrowser # imports the module which allows the display of Web-based documents to us...
5ca8a7ae523847c564707606057c43dbc34883c1
nishantchaudhary12/Starting-with-Python
/Chapter 5/loan_payment_calculator.py
501
4.3125
4
#loan payment calculator def payment_calculator(rate, amount, months): payment_per_month = (rate * amount)/(1 - (1 + rate)**-months) print('The month payment amount will be $',format(payment_per_month, '.2f')) def main(): rate = float(input('Enter the rate of interest as a decimal (e.g. 2.5% 5 0.025): '...
f66cef37ef09bf9df6c2f031ae189a21ae0d386d
liuminzhao/eulerproject
/euler69.py
1,001
3.59375
4
__author__ = 'liuminzhao' import math prime= [x for x in range(2,50) if not [t for t in range(2,int(math.sqrt(x))+1) if not x%t]] def isprime(x): return not [t for t in range(2,int(math.sqrt(x))+1) if not x%t] def isrprime(a, b): minab = min(a, b) maxab = max(a, b) for i in range(2, minab + 1): ...
af454bbdbcef95b21a70c16068a542b6bdb8cd02
brenonorberto/Cursos
/Curso em Vídeo/Python/Desafio39_aula12_alistamento militar.py
685
3.828125
4
print('='*12, 'Desafio 39', '='*12) print() from datetime import date atual = date.today().year nasc = int(input('Digite o seu ANO de nascimento: ')) idade = atual - nasc print() print('Quem nasceu em {}, tem {} anos em {}'.format(nasc, idade, atual )) if idade == 18: print('Esse ano você deve se ALISTAR') elif ...
f749d84b97d5bcd6feeb2a083fc49ef8e15c546c
Lackman-coder/backup
/python.py
92
3.71875
4
a = input("Enter the firstname: ") b = input("Enter the secondname: ") c = a + b print(c)
a005b83c3c7cefd95627f75c36c03dee0421e383
maxnoodles/data_strcuture
/algorithm(2020-01-24)/back_tracking/search_word.py
1,797
3.5
4
class WordSearch: def __init__(self): self.d = [ [-1, 0], [0, 1], [1, 0], [0, -1] ] self.m = 0 self.n = 0 self.visited = [] # board 搜索的二维数组, word 搜索词 def exist(self, board, word): self.m = len(board) a...
e9f9ebfe7b5c0df1b63cb31c5e968d0bfd2b2be6
GLucky31/py2020
/guitictactoe.py
4,151
3.5625
4
from tkinter import * from tkinter import messagebox #(1, 2, 3), (4, 5, 6), (7, 8, 9), (1, 4, 7), (2, 5, 8), (3, 6, 9), (1, 5, 9), (3, 5, 7) Zmagovalne kombinacije root = Tk() poteza = True a= 0 stevec=0 zmaga=False root.title("Tic Tac Toe") root.config(background='Dark gray') root.resizable(0,0) l...
265f87c7e95f9fe66bcffaf61fb1fbcd710664b6
Cohiba3310/Ask-Name
/name.py
171
3.859375
4
while True: name = input('請輸入這台電腦主人名字: ') if name == '楊育哲': print('正確無誤') break else: print('請回去使用自己的電腦!')
430c16e2db754d9cb9d4c5a4a1808a6022bf6164
statco19/doit_pyalgo
/ch6/merge.py
597
3.625
4
from typing import Sequence, MutableSequence import heapq def merge_sorted_list(a: Sequence,b: Sequence, c: MutableSequence): pa, pb, pc = 0, 0, 0 na, nb, nc = len(a), len(b), len(c) while pa<na and pb<nb: if a[pa] <= b[pb]: c[pc] = a[pa] pa += 1 else: c[pc] = b[pb] pb += 1 pc += 1 whil...
8a04f48141364aeb2ac90848ecfea99d022e610c
sera0506/PythonKerasTensorflowPractice
/demo2.py
335
3.890625
4
import matplotlib.pyplot as plt import numpy as np # y = ax + b b = 5 a = 3 x = np.arange(-10, 10, 0.1) print(x) y = a * x + b plt.plot(x, y, label=f"y = {a}x + {b}") plt.legend(loc=2) plt.axhline(0, color='black') plt.axvline(0, color='black') plt.title("demo2 figure") plt.xlabel("label for x") plt.ylabel("label for ...
25d53f62abcac9fe151df4b1cc30a6a66cac7ad5
TarasKindrat/SoftServe_Python-online-marathon
/5_sprint/6_task.py
1,635
4.53125
5
""" Write the function solve_quadric_equation(a, b, c) the three input parameters of which are numbers. The function should return the solution of quadratic equation ax2+bx+c=0, where coefficients a, b, c are input parameters of the function solve_quadric_equation: in case of correct data the function should d...
c3a0e58d4f9186028304bed0a5bca61f62c23cec
jrcapriles/armSimulator
/Point.py
1,122
3.9375
4
# -*- coding: utf-8 -*- """ Created on Fri May 2 01:17:09 2014 @author: Jose Capriles """ from math import sqrt class Point( object ): def __init__( self, x, y, z): self.x, self.y, self.z = x, y, z def distFrom( self, x, y, z ): return sqrt( (self.x-x)**2 + (self.y-y)**2 + (self.z-z...
b3478accf7f1a173832d3cbf8c063b626286981c
S-samira2020/New-python-code2
/program7.py
634
3.890625
4
#MATH fUNCTION PRACTICE '''x = 2.9 print(round(x)) print() x = 3.8 print(abs(-3.8)) print() ''' import math print(math.ceil(2.1)) # it will show 3 bcz ceil means it is up 2.0 print(math.floor(2.9)) # it will show 2 bcz floor means under 3 print(math.comb(6,3)) # it will show 20 bcz n!/k!+(n-k)! here n...
60e0d4c655bb755f43000c20fc15b416a618e2d3
myamullaciencia/Bayesian-statistics
/_build/jupyter_execute/09_predict_soln.py
14,147
3.78125
4
# Bite Size Bayes Copyright 2020 Allen B. Downey License: [Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)](https://creativecommons.org/licenses/by-nc-sa/4.0/) import numpy as np import pandas as pd import matplotlib.pyplot as plt ## Review [In the previous notebook](https://colab.research...
ff2ea3db5b146e015fef770715b5c09357af237d
pkostereva/ES_Python
/LSN_7/DZ_7.1.py
823
3.75
4
from pprint import pprint n=0 z=0 task=dict() while True: print('\n1. Добавить задачу.\n2. Вывести список задач.\n3. Выход.') n=input('Выберете пункт: ') if n.isnumeric(): if int(n) == 1: print('\n') a=input('Задача: ') b=input('Категория: ') c=input('...
5a0aa1de444c94123abfa5d734e5c6a3a660705c
AceMouty/Python
/2.Variables_and_Strings/milage_converter.py
329
3.96875
4
def main(): MILE = 1.60934 distance_ran = input("How many kilometers did you run?\n") print(f"Ok you said {distance_ran}") miles = float(distance_ran) // MILE # round(thing to round, how many decimal places) print("So you ran " + str(round(miles, 2)) + " miles") if __name__ == "__main__": ...
a634e6838cbb60be7ae229fda3494ece0fd7fd87
pscx142857/python
/上课代码/Python基础第七天/练习.py
173
3.671875
4
# 全局变量定义在调用函数下面,是否能使用,不能 def show(): print(name) # name = "丫丫" show() name = "丫丫" # NameError: name 'name' is not defined
26022934bf205b2d2d517c52dfb36326e1145097
sandeepm96/cormen-algos
/Alice/Sorting/radix_sort.py
759
3.578125
4
class RadixSort: def __init__(self,array): self.array = array def sort(self,exp): count = [0]*(10) sorted_array = [0]*(len(self.array)) for i in range(len(self.array)): index = int(self.array[i]/exp) count[index%10] += 1 for j in range(1,10): ...
7878dd86bd9357823444f5f1e10eba84af79a50e
yash0423/attack-the-castle-AI-Based-Game-
/model/rune.py
1,192
3.734375
4
import random class Rune: """ A model class used to represent the rune. """ def __init__(self,atk_plus=2,hp_plus=2,step_plus=2): self.atk_plus = atk_plus #random.randrange(1,4) self.hp_plus = hp_plus #random.randrange(1,4) self.step_plus = step_plus #random.randrange(1,2) ...
b4a2a2ad36fd7184ac03a7704528c1903418acfc
IsraMejia/AnalisisNumerico
/c19-Simpson38.py
842
3.515625
4
import numpy as np print('\n\tMetodo Simpson 3/8 ') a= 0 #Limite inferior b= 2 #Limite superior n=3 #Numero de intervalos , Se tiene que verificar si es valido con el numero de puntos que hay (5) #puntos = n+1 # x en funcion de intervalos x = np.zeros(n+1) # f(x) en funcion anonima f = lambda x: x**5 def sim...
544ae5147b4eef8c08142a0b79339533bddec5f4
ar1vit0r/Numerical_Calculus_Methods
/Algoritmo Matemática Intervalar.py
5,973
3.8125
4
a = [] b = [] c = [] # define the function blocks def intersec_(): a.append(float(input("\nInsira o x do conjunto A: "))) a.append(float(input("\nInsira o y do conjunto A: "))) b.append(float(input("\nInsira o x do conjunto B: "))) b.append(float(input("\nInsira o y do conjunto B: "))) if( a[0] > ...
568abdf43f6da9ee630c48bf089553864379a71b
raghunadraju/Practise
/Loops.py
434
4.125
4
# There are only two main loops in Python (FOR, WHILE) Names = ["RAGHU", 'SRINI', '', 1, 'SHREYA', 'SURYA'] for Names in Names: if Names == "SHREYA": print("Found him "+Names) break # for loop stops after the condition satisfied print('Student Name is {0}'.format(Names)) # Printing all the o...
2357536524cba763e93b22075004f59567fe8ad2
csany2020c/Demo
/a_kocka.py
571
3.78125
4
from turtle import Turtle from turtle import Screen class TurtleOOP: def __init__(self): screen = Screen() turtle = Turtle() a = 45 turtle.width(3) for i in range(4): turtle.forward(250) turtle.left(a) turtle.forward(88) turtl...
4d6e7fa3efd4a6e2d1b00eaad09ab7edd8d487ba
Ling-Cheng-Nan/Python_programming_practice
/python_practice/Json.py
660
3.96875
4
import json # some JSON format string x = '{ "name":"John", "age":30, "city":"New York"}' # parse jason into python object y = json.loads(x) # the result is a Python dictionary: print(y["age"]) # a Python object (dict): p = { "name": "John", "age": 30, "city": "New York" } # convert python...
4f314144fa3951444193cda5739966e7927911b6
kunpengku/learn_python
/build_in/max_test.py
120
3.84375
4
print max([1,2,3,4]) def f(x): if x==2: return 2 else: return 1 print max([1,2,3,4], key=f)
2dcf2de6358dd160a02a34dfa038cdcd2835e4dc
MatheusOldAccount/Exerc-cios-de-Python-do-Curso-em-Video
/exercicios/ex004.py
704
4.03125
4
#valor = input('Digite algo: ') #print('O tipo primitivo do que foi digitado é {0}'.format(type(valor))) #print('O que foi digitado é letra? ', valor.isalpha()) #print('O que foi digitado é número? ', valor.isnumeric()) #print('O que foi digitado é letra e ou número? ', valor.isalnum()) valor = input('Digite algo: ') ...
8a6c878b22e4e2a166274760e9d2ee3a02f89dee
MayurSaxena/Ciphers
/CaesarCipher.py
10,107
4.25
4
""" Mayur Saxena 2013-09-31 To perform a Caesar cipher """ import random def encode(inputString,shiftValue): #if the user inputs r or R for random, change shiftValue to a random number if shiftValue == "R" or shiftValue == "r": # the random number should be between 1 and 25 shiftValue = random....
b9a3f5e9264993776168662d45ab821a83466014
pwnmeow/Basic-Python-Exercise-Files
/ex/guessingv2.py
495
4.03125
4
import random random_number = random.randint(1,10) num = None while True: num = int(input("guess the number bw 1 - 10 ")) if num == random_number: print("you guessed it right!") elif num < random_number: print("you guessed too low") else: print("thats too high") play_again = input("Do you wan...
66ff889ab7a5e4d283cc83b06e9aceb6b4f5933a
OndrejHudecek/PythonAcademy
/Exercises/Task034_MinMax.py
615
3.640625
4
# Tvým úkolem je vytvořit dvě funkce: # Funkce my_min(), která imituje built-in funkci min(). # Funkce by měla přijmout jakoukoli sekvenci a vrátit položku s nejmenší hodnotou. seq = [43,45,87,21,23] def main(sequence): my_max(seq) my_min(seq) def my_min(sequence): minimum = seq[0] for num in seq[1...
ffaa25a66686d7f7956f40ba5beee9e9907c1a9b
Dinowa/Ormuco_test
/Q2/compareVersion.py
539
3.609375
4
def compareVersion(version1: str, version2: str) -> str: v1, v2 = version1.split('.'), version2.split('.') d1, d2 = {}, {} for i in range(len(v1)): d1[i] = int(v1[i]) for i in range(len(v2)): d2[i] = int(v2[i]) for i in range(max(len(d1), len(d2))): tmp = d1.get(i, 0) - d2.ge...
35a0e66776f0e7f42cfa6baeacb32312056f81bc
bksahu/dsa
/dsa/patterns/two_pointers/triplet_with_smaller_sum.py
1,146
4.25
4
""" Given an array arr of unsorted numbers and a target sum, count all triplets in it such that arr[i] + arr[j] + arr[k] < target where i, j, and k are three different indices. Write a function to return the count of such triplets. Example 1: Input: [-1, 0, 2, 3], target=3 Output: 2 Explanation: There are two tripl...
2416803bed860770c1524fa5be29b761c85a141e
antonpetkoff/Programming101
/Programming101/week0/is_prime.py
397
4.03125
4
def is_prime(n): if n < 2: return False elif n == 2: return True elif n % 2 == 0: return False for i in range(3, n, 2): if n % i == 0: return False return True def main(): print(is_prime(1)) print(is_prime(2)) print(is_prime(8)) print(is...
943a69e69e964c101794fa514f934df56fe09323
baozi1110/python-100-learn
/07/string/string1.py
429
3.8125
4
s1 = 'hello, world!' s2 = "hello, world!" # 以三个双引号或单引号开头的字符串可以折行 s3 = """ hello, world! """ print(s1, s2, s3, end='') print('\n', end='') s1 = '\'hello, world!\'' s2 = '\n\\hello, world!\\\n' print(s1, s2, end='') print() s1 = '\141\142\143\x61\x62\x63\n' s2 = '\u9a86\u660a' print(s1, s2) print() s1 = r'\'hello, wor...
f4cbcbd1bb77b397966893e2c5e4d2d5cfdcf330
anoobishnoob/Least-Common-Multiple
/LeastCommonMultiple.py
474
3.96875
4
#Title: Lab #3 Least Common Multiple, Samme Qandil #input: two positive ints a and b #output: prints the least common multiple import math print ("please put two ints above zero please and thank you") a = int(input()) b = int(input()) lcm = a * b / math.gcd(a, b) print (lcm) ''' so the lcm in number the...
78cbaaea56931a4bc413f9f3cc8acb056a9bbe1e
minseunghwang/YouthAcademy-Python-Mysql
/작업폴더/34_실습문제4/main.py
403
3.765625
4
# 사용자가 종료할 때까지 입력받은 문자열을 "c:/새파일.txt' 파일에 계속 추가하는 코드를 작성하시오 # C드라이브는 권한문제있어서 D드라이브나 현재위치에 ㄱㄱ while True : data = input('입력 : ') if not data: break with open('D:\새파일.txt', 'at', encoding='utf-8') as fp : fp.write(data+' ') print(data)
6d8f61da3fc7bf2a3f3be617795600fde0da2a98
gdfelt/competition
/euler/python3/euler035.py
876
3.859375
4
#!/usr/bin/env python3 """ Project Euler Problem 35 ======================== The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime. There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97. How many circular prime...
adb9c91d4560f45727e5ad8da97334eccd1e58a9
wrr123/Python-100-Days
/Day01-15/code/Day04/for1.py
170
3.859375
4
""" 用for循环实现1~100求和 Version: 0.1 Author: 骆昊 Date: 2018-03-01 """ sum1 = 0 for x in range(1, 101): sum1 += x print(sum1) print(sum(range(1, 101)))
0aba1816d2bde4e3f5bbcd589d8ed702fd608769
gitktlee88/MPS-project
/tests_mytest/primes.py
1,083
4.28125
4
""" A prime number is a whole number greater than 1 whose only factors are 1 and itself. If a number n is not a prime, it can be factored into two factors a and b: n = a * b If both a and b were greater than the square root of n, then a * b would be greater than n. So at least one of those factors must be less th...
329172870569340508b553f94e9db1ca44737a56
jdelacruz9/CODE2040-API-Challenge
/stage1.py
1,174
3.5625
4
#author: Julio de la Cruz #email: jjcnatera@gmail.com import requests import json #my identifying token token = 'jcUHJ3Axst' #this is the JSON dictionary, with my token, that I will use to get the string data = { 'token': token } #this is the response of the request that will contain the json with the string. I ...
62e753a5521c62b372aa1a302bb95adcc1c00ad6
imaheshaher/Python-OOP
/oop2.py
483
3.71875
4
class Rectangle: def __init__(self,length,breadth): self.length=length self.breadth=breadth def square(self): return "hello" return self.length*self.breadth class Calculate(Rectangle): def __init__(self,id,list): self.id=id self.list=list def calcsq(self): for i in self.list: # super().__init_...
f1bf57f85f372848a950b45fbaecc3ad7e67395c
naveensiwas/python
/7.python_operators.py
837
4.34375
4
#Example 1: Arithmetic operators in Python x = 15 y = 4 print('x + y =',x+y) print('x - y =',x-y) print('x * y =',x*y) print('x / y =',x/y) print('x // y =',x//y) print('x ** y =',x**y) #Example 2: Comparison operators in Python x = 10 y = 12 print('x > y is',x>y) print('x < y is',x<y) print('x == y is',x==y) print(...
2ed9d90841a988a85b02517975ad33fb6017cf33
DOG-BREAD/hackdfwProj
/proj.py
1,574
3.734375
4
# -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ def main(): with open("writes.txt", "w+") as file: with open('reads.txt', "r+") as reads: contents = reads.read() while True: # writes a string to a file file.w...
b2e46834a41d67e2872ceb067c8201090a55cedf
virajs/codeeval
/1-moderate/overlapping-rectangles/main.py
2,178
3.71875
4
import sys class Rectangle: def __init__(self, upper_left_x, upper_left_y, lower_right_x, lower_right_y): self.upper_left_x = upper_left_x self.upper_left_y = upper_left_y self.lower_right_x = lower_right_x self.lower_right_y = lower_right_y de...
3bbe3dc72196c7ce8b6b9a5cce31d5de65a7c393
Fariddeniro/Python-for-everybody
/8.5. Lists and Strings 2 (L2-W4).py
277
3.90625
4
fname = input("Enter file name: ") fh = open(fname) count = 0 lst=list() for line in fh: if line.startswith('From '): lst=line.rstrip().split() print(lst[1]) count=count+1 print("There were", count, "lines in the file with From as the first word")
526105de5fe98691b2179c2131243e9c0a2ee90b
ashwini1025/KurzBot
/process.py
7,438
3.5625
4
def get_sentences(file_name): # Extract sentences from a text file. reader = open(file_name) sentences = reader.read() reader.close() sentences = sentences.replace("\n", "") sentences = convert_abbreviations(sentences) sentences = sentences.replace("?", ".") sentences = sentences.replace...
ff54beafcbdddd43323e27a9fe801a9c5c7ebef8
maddygohan/madhan
/python24.py
103
3.546875
4
n = int(input("")) li=list(map(int, input("").split())) for i in range(n): li.sort() print("",*li)
ff9caac14fbe4f24c62fd9a8814302fc26d80e31
Dizzie42/MegaProjects-Solutions
/MortgageCalc.py
1,041
4.3125
4
#Mortgage Calculator - Calculate the monthly payments of a fixed term mortgage over given Nth terms at a given interest rate. #Also figure out how long it will take the user to pay back the loan. For added complexity, add an option for users to select the #compounding interval (Monthly, Weekly, Daily, Continually)....
e30dc755fcfa3cf0ef3cf564c09c188c170acf14
cadebaker/343-Project3
/neighborhood.py
3,299
3.515625
4
from observer import Observer from player import * from home import * """****************************************************** *A class that represents the entire neighborhood of the *Zork game ******************************************************""" class Neighborhood(Observer): #constructor def __in...
962175eca64f513e8c9fa87aa927c70ccc84f8ba
IronE-G-G/algorithm
/leetcode/前100题/019removeNthNode.py
1,338
3.5625
4
""" 思路1:维护一个n+1长的队列,按顺序压入结点,遍历完第一个结点就是倒数n+1个结点。 思路2:双指针;让快指针先走n+1步,这样遍历完慢指针就能指在倒是n+1个结点(如果n不等于链表长度的话) """ # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode: ...
87ac345667c0c7d255f34cbe4199135968952d35
MartySalamea/CS50x
/ProblemSet7/houses/roster.py
802
3.890625
4
# TODO from cs50 import SQL from sys import argv # check that we launched the code with proper arguments, otherwise it exits the program if len(argv) < 2: print("usage error, roster.py houseName") exit() # open the database in a variable and then execute a query that list all the people from a particular hous...
e0c41605ffe00deb308db273d6fb6cc7a9da1ef0
Spas52/Python_Fundamentals
/Exams/final_exam_2.03.py
2,097
3.640625
4
number_of_heroes = int(input()) party = {} # {'Solmyr': ['85' hp, '120' mana], 'Kyrre': ['99', '50']} for _ in range(number_of_heroes): hero = input().split() party[hero[0]] = [int(hero[1]), int(hero[2])] data = input() while not data == "End": command = data.split(" - ") action = command[0] ...
6b202b219144d4488c5102e11fb08c35b346bcfc
brcmst/python-tutorials
/iterator/iterator-kumanda-class.py
651
4.03125
4
#iter sınıfı olusturma #__iter()__ ve __next()__ metodlarını tanımlamak gerek class Kumanda(): def __init__(self, kanallar): self.kanallar = kanallar self.index = -1 def __iter__(self): return self def __next__(self): self.index += 1 if (self.index < len...
536064e7d26750d78fac6bacb2a0c608792be95b
IMDCGP105-1819/portfolio-louisvagner
/why.py
746
4.15625
4
month_counter = 0 portion_deposit = 0.20 current_savings = 0 r = 0.04 annual_salary = input ("Please enter your current annual salary: ") portion_saved = input ("Please enter how much you would like to be saved, as a decimal: ") total_cost = input ("Please enter the cost of your dream home: ") annual_salary = int(an...
b15da753d086c729faaddad779ae7d38c6c9d664
hs634/algorithms
/python/misc/OrderedDict.py
1,842
3.5625
4
__author__ = 'hs634' #from collections import OrderedDict # d = OrderedDict() # d['a'] = 1 # d['b'] = 2 # d['c'] = 3 # d['a'] = 5 # for k, v in d.iteritems(): # print k, v # __setitem__, __getitem__, pop, popitem # self.map = {'key': 'value, next'} class Node: def __init__(self, key, val): self.k...
d9726a7d26b8b58f437f6333d7ffae08e943938c
RicardoVeronica/python-little-projects
/projects/phonebook_dir/phonebook-modules/functions.py
1,949
4.03125
4
contacts = {} def add_contact(): name = input('\nGive a name for you new contact: ') name = name.upper() try: phone = int(input('Give a number for you new contact: ')) contacts[name] = phone print('\nContact: {}\nPhone number: {}\nAdded'.format(name, phone)) except ValueErro...
7c308618eb27cb32087bbdb477cbf49bf0886e62
RossCZ/PythonLearning
/topics/3_loops/1_for_loops.py
278
3.640625
4
# for cyklus (smycka) for i in range(5): print(f"Apple {i}") # priklad: suma i pro range(5) sum = 0 for i in range(5): # tady se to secte sum += i # sum = sum + i print(sum) # 10 print("") # range(od, do, krok) for cislo in range(3, 15, 2): print(cislo)
4922d04faaf85d49fbe90e385d90633f0e8b4897
Aasthaengg/IBMdataset
/Python_codes/p02675/s747790578.py
135
3.71875
4
g = str(input()) x = g[-1] p = ["0", "1", "6", "8"] if x == "3": print("bon") elif x in p: print("pon") else: print("hon")
c2fe3d064c23649196b29de76dc664c5b8018193
lordjuacs/ICC-Trabajos
/Ciclo 1/MRUV/velocidad final2.py
253
3.65625
4
v_inicial = float(input("Ingrese velocidad inicial: ")) aceleracion = float(input("Ingrese aceleracion: ")) distancia = float(input("Ingrese distancia: ")) v_final = ((v_inicial**2)+2*aceleracion*distancia)**(0.5) print("Velocidad final:",v_final,"m/s")
812a30a0750240fba4365dc1183c73388c33d612
Chavi99/set-4
/8.py
116
3.8125
4
def swap_n(x,y): x=x^y y=x^y x=x^y print(x,y) n=list(map(int,input().split(' '))) swap_n(n[0],n[1])
c2845e4ac0ebd952dc3319a2dd1afe379bdbfbc5
alexangupe/clasesCiclo1
/P45/Clase10/clasificarEmpleados.py
3,055
4.3125
4
#Requerimiento: Se requiere una función que recoja la información #de una cantidad determinada de empleados (nombre y salario). #Se espera recibir el nombre del empleado y el salario del empleado (dólares). # Retornar cuáles empleados deben pagar impuestos #(salario superior a 10.000) en una lista. Retornar otra list...
991a10f2f37ccfac7670a22fa2ada19a05c1895c
Sahith-8055/XYZ
/CSPP1-ASSIGNMENTS/M10/p1/assignment1.py
890
3.921875
4
''' Exercise : Assignment-1 implement the function get_available_letters that takes in one parameter a list of letters, letters_guessed. ''' def get_available_letters(letters_guessed): ''' :param letters_guessed: list, what letters have been guessed so far returns: string, comprised of letters that represen...
18f1aeb03c0d397a18607b0b9ce5ba6b2ef4792b
ValtteriV/freetime_Notify
/main/domain/notifications.py
809
3.515625
4
class Notifications: def __init__(self): self.notificationlist = [] def add_notification(self, name, timer): new_notification = Notification(name,timer) self.notificationlist.append(new_notification) self.sort_notifications() print("notification added, timer is ...
3f3407d3773c27b348848e34aa27d8adc03fa136
mayanksha/CS251
/a3/160392_a3/1.py
1,891
3.625
4
#!/usr/bin/env python3 import re import sys import string minus_flag = 0 values = (string.digits + string.ascii_lowercase) valid_reg = re.compile('^\-{0,1}[0-9a-zA-Z]+(\.{0,1}[0-9a-zA-Z]+)?$') def base_n(x, base): if base == "10" : base = 10 temp = 0 x = x[::-1] for i in range(len(...
f19afb58e3749fc41f3117c99bab2caab4bb389c
estraviz/codewars
/7_kyu/Finding length of the sequence/length_of_sequence.py
244
3.984375
4
""" Finding length of the sequence """ def length_of_sequence(arr, n): if arr.count(n) != 2: return 0 else: gen = (i for i, c in enumerate(arr) if c == n) first = next(gen) return next(gen) - first + 1
7c6feac6c2deadc353f3a0a9fdce26f09da66417
onkar2612/Python
/Recurrsion_programs/1_Fibonacci_Using_recurssion.py
273
3.78125
4
def febonacci(n): if n<=1: return n else: return febonacci(n-1)+febonacci(n-2) Terms = int(input("Enter a terms: ")) if(Terms<=0): print("Please enter positive number") else: for i in range(Terms): print(febonacci(i))
04476c853ee5351c551ee3313d9e369386aa452b
chelseazhao/Leetcode-for-fun
/61-Rotate-List/Solution.py
836
3.78125
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def rotateRight(self, head, k): """ :type head: ListNode :type k: int :rtype: ListNode """ if head is...
19b9054f704d916c6d35b6500919397476111ab2
paul0920/leetcode
/question_leetcode/215_2.py
548
3.796875
4
# Bubble sort algorithm # Time complexity: O( k(n - (k+1)/2) ); if k = n, O( n(n-1)/2 ) # Best case: O(n) # Worst case: O(n^2) # Space complexity: O(1) # If j+1 > j, just swap and so on # nums = [3, 2, 1, 5, 6, 4] # k = 2 nums = [3, 2, 3, 1, 2, 4, 5, 5, 6] k = 4 for i in range(k): for j in range(len(nums) ...
663d6a372dcd7978a3adeea6f7a6c4a92645931b
azatsatklichov/z-Py
/py3/sahet/g_Join.py
962
3.90625
4
s = "-"; seq = ("a", "b", "c"); # This is sequence of strings. print (s.join( seq )) seq = ("a", "b", "c"); # This is sequence of strings. print (s.join( seq)) _str = "this is string example....wow!!!"; print (_str.ljust(50, '0')) print (_str.rjust(100, '0')) _str = " this is string example....wow!!! "; p...
6ca11dcc66d2a057caba351c5fb038f22a958c13
henriquecl/Aprendendo_Python
/Exercícios/Lista 4.1 - Seção 7 - Matrizes/Questão 23 - Elevar matriz ao quadrado.py
448
4.21875
4
""" Questão 23 - Faça um programa que leia uma matriz A de tamanho 3x3 e calcule B = A² """ a = [[], [], []] b = [[], [], []] for i in range(3): for j in range(3): numero = float(input(f'Digite o valor equivalente a posição [{i}][{j}]da primeira matriz ')) a[i].append(numero) for i1 in range(3): ...
783536c5b7332f15c52b3a05ce9445903a481c89
kaminskyalexander/tkinter-jet-fighter
/vector.py
1,711
4.3125
4
from math import sqrt class Vector2: """ Two dimensional vector. Supports adding, subtracting, multiplying, dividing, comparisons, etc. """ def __init__(self, x, y): self.x = x self.y = y @property def normalized(self): """ Normalizes the vector (sets it to a length of 1) """ length = sqrt(self.x*...
b07ebb58dc8af5994581361e262ffc0130b7a535
amleigh/SI206
/HW3-StudentCopy/twitterhw3b.py
907
3.671875
4
import tweepy from textblob import TextBlob # In this assignment you must do a Twitter search on any term # of your choice. # Deliverables: # 1) Print each tweet # 2) Print the average subjectivity of the results # 3) Print the average polarity of the results # Be prepared to change the search term during demo. a...
3089fc459ced5b4b1c97513f938e50c3376c1ad6
paulomachadof/lab_metodos
/raiz/newton.py
1,325
3.84375
4
# coding: utf-8 ''' Created on Nov 9, 2015 @author: ''' from math import * def newton(f, df, x0, epsilon, maxIter = 50): """Executa o método de Newton a para achar o zero de f com precisão epsilon. O método executa no máximo maxIter Retorna uma tupla (houveErro, raiz), onde houveErro é booleano. ...
5e300c1a4a7a4d88eceebccf1cf90e34205d646c
hessifer/Python
/ProgrammingExpert/method_overloading/dunder_methods/vector_class_test.py
1,208
3.8125
4
import unittest import math from vector_class import Vector class TestProgram(unittest.TestCase): def test_case_1(self): self.assertTrue(hasattr(Vector, '__repr__')) self.assertNotEqual(repr(Vector(1, 2)), repr(Vector(2, 1))) self.assertNotEqual(repr(Vector(1, 2)), repr(Vector(1, 3))) ...
23723f1611f05855133747fb62caae21b94827de
caim03/PythonEcm
/Curve.py
1,397
4.40625
4
""" This class defines an elliptic curve """ from random import randint class Curve: """ This method is the constructor of the Curve class @:param n The number that must be factorized @:return Nothing """ def __init__(self, n, point): self.a = randint(0, n - 1) self.b = (p...
e6dfc2042be615951a190fc57dcd1fadd15dfdb7
grizzly-ops/python-crash-corse
/chap02/TryItOut.py
775
4.03125
4
#2.1 message = "hi human" print (message) #2.2 message = "hello mars" print (message) #2.3 name = "jhon" message = f"hello, {name} would you like to go to the movies" print (message) #2.4 name = "ruth" print (name.title()) print (name.upper()) print (name.lower()) #2.5 message = f'albert instine once said "a person...