blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
9e8363fe82992276dbd217f45a601c179904713e
diego-guisosi/python-norsk
/02-beyond-the-basics/07-iterables-and-iteration/06-filter-function.py
583
4.28125
4
# filter can be used to remove elements of iterables that does not match the predicate function provided # filters accept only a single input sequence positives = filter(lambda x: x > 0, [1, -5, 0, 6, -2, 8]) print(list(positives)) # passing None to the predicate function will cause filter to remove all iterable elem...
a4f7bc698cb260b439bccca2a2abb9ba2fa01b2a
diego-guisosi/python-norsk
/02-beyond-the-basics/07-iterables-and-iteration/13-real-world-example.py
579
3.953125
4
# Iterables - Reading data from a sensor # Often sensors produce stream of data or can simply provide a value whenever queried import random import datetime import itertools import time class Sensor: """ Simulates a physical sensor """ def __iter__(self): return self def __next__(self): ...
61a04e077b04645a7c64fc60f883733d8e90d933
diego-guisosi/python-norsk
/01-fundamentals/chapter07/exceptional.py
1,281
3.53125
4
import sys def convert(x): converted_int = -1 try: converted_int = int(x) print("Conversion of {} succeed: {}".format(x, converted_int)) except (ValueError, TypeError): print("Conversion of {} failed: {}".format(x, converted_int)) return converted_int def convert_2(x): co...
206f2b2acf524de770369f4e36893de1926183ef
diego-guisosi/python-norsk
/02-beyond-the-basics/11-context-manager/03-sample-context-managers.py
1,211
3.734375
4
class TestAssignmentContextManagement: def __enter__(self): return "You are in a with-block" def __exit__(self, exc_type, exc_val, exc_tb): return class LoggingContextManager: def __enter__(self): print("LoggingContextManager.__enter__()") # Although we can return any va...
8ace99f889e4ab9ad5e896b030fc5538c209fc30
diego-guisosi/python-norsk
/02-beyond-the-basics/07-iterables-and-iteration/10-protocols-together.py
1,033
4.15625
4
class ExampleIterator: def __init__(self, data): self.index = 0 self.data = data def __iter__(self): """ Iterators must implement __iter__ protocol, which is responsible for returning an iterator for the given object The most common __iter__ implementation for an iterat...
87172cddef11c9e440263a0a9212582955c968c2
diego-guisosi/python-norsk
/02-beyond-the-basics/02-functions/transposing_tables.py
389
3.796875
4
from pprint import pprint as pp # transposing tables with zip # zip combines two iterable per position # day temperatures sunday = [12, 14, 15, 15, 17, 21, 22, 23] monday = [13, 14, 14, 14, 16, 20, 21, 22] for item in zip(sunday, monday): print(item) print() daily = [sunday, monday] for item in zip(*daily): ...
acd5f063c991da6edc97cec83eaef2bba2a804d3
diego-guisosi/python-norsk
/02-beyond-the-basics/07-iterables-and-iteration/05-maps-vs-comprehensions.py
179
3.625
4
# maps and comprehensions can produce the same results # the which one to choose is up to you i = (str(i) for i in range(5)) print(list(i)) i = map(str, range(5)) print(list(i))
4382abf70fcf279abae9e7310dcc3d958af90c1a
diego-guisosi/python-norsk
/02-beyond-the-basics/02-functions/lambdas.py
488
3.703125
4
# lambdas are annonymous callables scientists = [ 'Marie Curie', 'Albert Einstein', 'Niels Bohr', 'Isaac Newton', 'Dmitri Mendelev', 'Antoine Lavoisier', 'Carl Linnaeus', 'Alfred Wegener', 'Charles Darwin' ] sorted_scientists = sorted(scientists, key=lambda name: name.split()[-1]) print(sorted_scientists) # ...
4cb9121d8a45f64f624fe30c6fe7bd1a2e56a434
diego-guisosi/python-norsk
/01-fundamentals/chapter08/generator_comprehensions.py
592
3.96875
4
# generator comprehensions can be declared with parentheses million_squares = (x*x for x in range(1, 1000001)) print(next(million_squares)) print(next(million_squares)) # to retrieve a new generator from the previous comprehension, it's necessary to declare it again other_million_squares = (x*x for x in range(1, 1000...
f3bc3552e9d5099d3d8cb53d8dc59c4cc4f691b0
diego-guisosi/python-norsk
/03-advanced/01-flow-control/04-try-else.py
429
4.125
4
# else clause will be executed if no exception is raised # this structure is used when we want to separate functions that can raise the same exception, because we are interested # in handling only a specific one try: f = open("example_file.txt", 'r') except OSError: print("File could not be opened for read") e...
cc4eaa4cd68719e078ce09796fbb2c2a221c1a6c
imperialhopfield/hopfield
/scripts/parseExp.py
669
3.546875
4
import sys import string def format(filename): with open(filename, 'r') as f: entire_file = f.read() no_whitespace = "".join(entire_file.strip()) no_brakets = no_whitespace.translate(None, "[]~()") return no_brakets.replace(",", " ") def chunks(l, n): return [l[i:i+n] for i in range(0, len(l), ...
8f52016f7816e8751eb268923755d91f9d3c1521
jongfeel/ProjectEuler
/Problems/Problem2/Problem2.py
243
3.71875
4
def Fibonacci(untilNumber): a,b = 1,2 while True: if a > untilNumber: break yield a a, b = b, a + b print(sum(fibonicciNumber for fibonicciNumber in Fibonacci(4000000) if fibonicciNumber % 2 == 0))
3ffbde9dc71b6f3442cbb1c363b20c3edca17e09
jihye1996/Algorithm
/programmers/오픈채팅방.py
444
3.828125
4
def solution(record): dict = {'Enter': '님이 들어왔습니다.', 'Leave':'님이 나갔습니다.'} answer = [] for r in record: str = r.split(' ') if str[0] != 'Leave': dict[str[1]] = str[2] #print(dict) for r in record: str = r.split(' ') if str[0] != 'Change...
883893a2695ea19997d1b6777fc408eae40880f1
jihye1996/Algorithm
/baekjoon/2252.py
733
3.671875
4
import sys from collections import deque def topoloy_sort(graph, degree): answer = [] q = deque() for i in range(1, N+1): if 0 == degree[i]: q.append(i) while q: t = q.popleft() answer.append(t) for E in graph[t]: d...
25528c49256fb9ffd2ea01c42cd69e84b3a3f18d
pitonC/ejercicios
/calucarPropina.py
553
4.0625
4
sub1: float = 0 sub2: float = 0 sub3: float = 0 print("-----------------------------------------------------") print("Restaurante la flor") sub = float(input("Cuanto es el valor a pagar: ")) sub1 = sub*.18 sub2 = sub*.20 sub3 = sub*.25 subT1 = sub + sub1 subT2 = sub + sub2 subT3 = sub + sub3 print("propina con 18%: ", ...
9136416174c2d11a7c9c727d5a610e063da268c0
11xdev-coder/windows_1_0
/Notepad.py
3,234
3.625
4
from tkinter import * from tkinter import filedialog class text_editor: current_open_file = 'no_file' def open_file(self): open_return = filedialog.askopenfile(initialdir='/',title='Выберите файл для открытия',filetypes=(('Text file','*.txt'),('All Files','*.*'))) if (open_return != None): ...
f0d929905b64b3945a4d8079095d00b580803d12
11xdev-coder/windows_1_0
/Calculator v2.py
727
3.671875
4
from tkinter import * root = Tk() root.title("Калькулятор") root.geometry('380x550+200+100') def enterNumber(x): if entry_box.get() == '0': entry_box.delete(0,'end') entry_box.insert(0,str(x)) else: length = len(entry_box.get()) entry_box.insert(length,str(x)) entry_box = Entr...
0863de7429ee018a8d1bda312b64f9cfce5596dc
noibar/pose_analysis
/camera.py
430
3.625
4
from enum import Enum class Camera(Enum): TOP = 'top' LEFT = 'left' RIGHT = 'right' BACK = 'back' def file_to_camera(file): if file.find(Camera.TOP.value) != -1: return Camera.TOP elif file.find(Camera.BACK.value) != -1: return Camera.BACK elif file.find(Camera.LEFT.value...
b212b06fa94dd309ce0fe3e6936ebef3e26804c7
isakura313/third_project
/slover.py
615
4.03125
4
slovar = {'book': 'книга', 'table': 'стол', 'mouse': 'мышка' } slovo = input("Введите слово, попробуем перевести") if slovo in slovar.keys(): print(slovar[slovo]) else: print("Не может быть! Видимо архивы пусты") user = { 'name': "semen", 'surname': 'semenov', 'age':...
27e7c90630463098bca064a765beee9808f2cd82
AndrewDeCHamplain/AdventofCode
/day1_2.py
742
4
4
""" --- Part Two --- Now, given the same instructions, find the position of the first character that causes him to enter the basement (floor -1). The first character in the instructions has position 1, the second character has position 2, and so on. For example: ) causes him to enter the basement at character positi...
d7738f74f74980195755d0828cbf87621a6c62f4
andramavropol/my-first-blog
/miau.py
86
3.578125
4
for i in range(1, 6): print(i) print("-"*10) for i in range(6, 10): print(i)
7ec0e636b830efb2365fb333bffcd32520130a5c
hattwick/PySA
/scratch.py
599
3.578125
4
""" Problem: Print out user-provided text Target Users: testers Interface: Command line Functional Requirements: Prompt for user input Process input and respond Testing: Editor test and then execute separately Maintainer: philhatt@mac.com """ # Text string above is initial Python docstring team # Welcome ...
9d0df9bb88f0de178a1816afe3617f73f46aa613
hattwick/PySA
/word/test2.py
542
4.03125
4
# Short palindrome finder import string import scrabble print(string.ascii_lowercase) # test long palindrome word = "rotavator" print('\nIs rotavator a palindrom?\n') print(word == word[::-1]) # Now the full check longest = "" for word in scrabble.wordlist: if word == word[::-1] and len(word) > len(longest): ...
17729b3e7dd5c3a81e50f2e7442c364a629532b8
hattwick/PySA
/word/buffered_read.py
1,089
3.609375
4
# Python3 module for various file reads # Based on exercise files from Python3 Essential Training # Goal is to evolve this to a reusable module def unbuffered(): file_in = open('file.txt', 'r') file_out = open('newfile.txt', 'w') for line in file_in: print(line, file = file_out, end ='') print(...
d3d91fd1f465812ef28956aa5c382a1be6c7bdcd
chyu/Python-practice
/circle7.py
1,309
4.53125
5
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Oct 3 21:41:58 2018 @author: chakyu """ #---- Start Program ---- import math #---- Start diameter function ---- def calcDiameter(radius): diameter = radius*2 return diameter #---- End diameter function ---- #----Start circumference functi...
399f14c82e772f1c49c090103fa24f9134a336aa
chyu/Python-practice
/fileFixedWrite.py
712
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Oct 13 14:45:34 2018 @author: chakyu """ #---- Creating files ---- fileHandle = open('namesfixed.csv', 'w') print('Welcome to the phone number program') name = input('Please enter person\'s name: ') while True: if name == '': print() ...
a1920fd36f85a7b7d3fa72f6fb0814dd57c3b6be
chyu/Python-practice
/average3.py
413
4.3125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Sep 22 16:50:20 2018 @author: chakyu """ # --- Start Program --- num1 = input('Please enter the first number: ') num2 = input('Please enter the second number: ') num3 = input('Please enter the third number: ') average = (float(num1)+float(num2)+flo...
142524299f84e2fd01b506a9601f3cfdfef92935
chyu/Python-practice
/ageMsg.py
614
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Sep 22 16:59:45 2018 @author: chakyu """ #--- Start Program --- name = input('Please enter your name: ') age = input('Please enter your age: ') if name == 'Chak': print('Hello Master %s' % name) if int(age) >= 45: print('My you mus...
f5d2155ceeb45ba7d825d7b62d29fb76051dde46
chyu/Python-practice
/friendsNewFriend.py
1,068
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Sep 28 09:46:19 2018 @author: chakyu """ #---- Start Program ---- friend = input('Enter the name of a friend: ') friendlist = [] friendlist.append(friend) while True: if friend == '': friendlist.pop() break else: ...
23e01b65220c5e7527f9070d7a816798c00492c9
chyu/Python-practice
/divisors2.py
4,306
4.4375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Sep 22 22:56:03 2018 @author: chakyu """ #---- Start Program ---- import re import math number = input('Please enter a number: ') #---- check integer ---- while True: #loops continu...
bd5428d69e6940b99891503ee2e38d003547e33a
chyu/Python-practice
/re_Hi.py
371
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Sep 29 19:11:06 2018 @author: chakyu """ import re # --- Start Program --- someinput = input('Enter your meaningless sentence here: ') keyword = 'hi' if re.match(keyword, someinput, re.IGNORECASE): print('awwww... you said %s :)' % keyword) else...
257c6809a284a1d6ab3e8a2ec333d638a0221812
Deep-Learning-study-group/Image-Classifier
/code/preprocess_batch.py
4,536
3.515625
4
""" map the class ID to the image ID and resize the images to corresponding files automatically process in batches, easy for the following steps """ import pandas as pd import os from PIL import Image # df as dataframe # get the classes we wanted to classify def get_class(df, column_ID, cls_num): # get the top #cl...
3f4a41809432a76514ddd5482341debda0ab5bb3
jf-2020/unit2
/day1/cipher_exercises.py
8,248
3.609375
4
# cipher_exercises.py - this prgm will implement the problem from 4/22 AM's # discussion. namely, the user will attempt to guess # the stored password. the password itself will be encoded # via a simple ceasar cipher (i.e. ROT13). the user will # ...
fce5dbb65be41c50ffe91078ef4d7bbf136c6d3f
sfeir-open-source/sfeir-school-python
/steps/step-01-solution/main.py
419
3.75
4
# -*- coding: utf-8 -*- """ To-Do application """ def concat(input_1, input_2): if type(input_1) != type(input_2): raise Exception("Concat is not possible") print(input_1 + input_2) def main(): """ Main function """ concat("input_1", "input_2") try: concat(1, "input_2") ...
214bd3b80fd2f3be541f23d152972a23eaa6744b
sfeir-open-source/sfeir-school-python
/steps/step-02-solution/main.py
748
3.6875
4
import sys def main(): input_file_path = "folder/input.txt" output_file_path = "folder/output.txt" if len(sys.argv) > 1: # Open files input_file = open(input_file_path, mode='r') output_file = open(output_file_path, mode='a') txt_found_in_file = False # Input Args ...
40be849d4738d5ccf27349400b11294d6f1fa427
lovepurple/PythonStudy
/Study/Tuple.py
1,118
4.25
4
from collections import Iterable,Iterator #不包括:后面的索引 #List结构 L = ['Michael','Sarah','Tracy','Bob','Jack'] #从第0个取到第三个(不包括索引3) E = L[0:3] print(E) #从第1个取到第三个 S=L[1:3] print(S) #从倒数第三个取到倒致第一个 A=L[-3:-1] print(A) #隔一个取一个 B=L[::2] print(B) #复制 C=L[:] print(C) print("-----------------------Tuple Operation----------...
2adcb1ff789619473ce53fe7249cb0c534104a12
google/eclipse2017
/src/solar_eclipse_renderer/coords.py
1,117
3.609375
4
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
9b297d7868753bc2fe7220b0b3a9fe1ba1c70004
mudouasenha/python-exercises
/ex27.py
184
3.9375
4
def concatenate_list_into_string(list): new_str = "" for item in list: new_str += str(item) return new_str print(concatenate_list_into_string([3, "a", "b", "c"]))
2b0782df7aa5b25064f7fadc2aa39d2c51be8659
mudouasenha/python-exercises
/ex65.py
404
4.25
4
def convert_seconds(): seconds = int(input("Type seconds: ")) days = round(seconds / (24 * 3600)) seconds = seconds % (24 * 3600) hours = round(seconds / 3600) seconds = seconds % 3600 minutes = round(seconds / 60) seconds = seconds % 60 print("Days: ", days) print("Hours", hours) ...
2470f10fc8169b97ca8a6be36b0b4994d48f9d96
mudouasenha/python-exercises
/ex60.py
141
3.65625
4
import math def calc_hypotenuse(a, b): hypotenuse = math.sqrt((a ** 2) + (b ** 2)) return hypotenuse print(calc_hypotenuse(4, 3))
4def0e865e0d041eff50c91494d8108bf9a0aa04
mudouasenha/python-exercises
/ex7.py
127
4.03125
4
filename = input("type a filename with extension: ") extension = filename.split(".") print("file extension: ", extension[-1])
14a3a1dc102152eaa07ae19ab3321a250fbf6c92
hemin1003/python-study
/hello.py
686
4.09375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #name=input('请输入你的名字: ') #print('hello ', name) #age=10 #if age>5: # print('boy') #else: # print('man') a='abc' b=a a='xyz' print(b) PI=3.14 print(PI); print('中文字符测试') s = 'Python 中文' print(s) b = s.encode('utf-8') print(b) print(b.decode('utf-8')) L = [ [...
b4b1af90509166488ee71744ddc372a9ec644872
hemin1003/python-study
/PycharmProjects/pachong_test.py
715
3.546875
4
# 网络请求案例 from urllib import request from urllib import parse # url = 'http://www.baidu.com'; # response = request.urlopen(url, timeout=1) # print(response.read().decode('utf-8')) # post请求 data = bytes(parse.urlencode({'word':'hello'}), encoding='utf8') response3 = request.urlopen('http://httpbin.org/post', data=data)...
f4bbce04d181033633c0d53330554175bcec7890
hemin1003/python-study
/PycharmProjects/func_test2.py
426
4.1875
4
# 函数的迭代器和生成器 # list1 = [1, 2, 3] # it = iter(list1) # print(next(it)) # print(next(it)) # print((nextit)) # print(next(it)) # except # 迭代器 # for i in range(10, 20, 2): # print(i) # yield关键字,生成器,每次都记录当前位置返回 def frange(start, stop, step): x = start while x < stop: yield float(x) x += step ...
7f7aee6fd7cce9b768a52c6dd06ded323b040445
Jmaihuire/wqu
/MScFE640/CRT/CRT4/CRT4.py
6,795
3.515625
4
#%% # Collaborative Review Task 4 # In this module, you are required to complete a collaborative review task, which is designed to test your ability to apply and analayze # the knowledge you have learned during the week # Question: # 1. Download 1-2 years of SPY. Find two other ETF that track it. # 2. Compute the retu...
8c873fdafff048813b088516114d237bc2b48ada
ashishpatel26/swarm
/simulated_annealing/anneal.py
4,360
4.21875
4
### Implementation of the simulated annealing algorithm # Author: Alexander Haegele # References: # - Wikipedia https://en.wikipedia.org/wiki/Simulated_annealing # - Lilian Besson: https://github.com/Naereen/notebooks/blob/master/Simulated_annealing_in_Python.ipynb # - Paul Leuchtmann, Slides and Script to the course...
f38192918cdc23f46ef0d6caff70a5faa5cbbfb9
bateternal/tweeter
/base64/Base64.py
512
3.6875
4
class change: @staticmethod def encrypt(string): encrypt = "" for i in range(len(string)): integer1 = int(string[i]) * 2 + 65 integer2 = int(string[i]) * 2 + 70 encrypt = encrypt + chr(integer1) + chr(integer2) return encrypt @staticmethod def...
4f7ccd7da99c111691f01017c1bc4d30ff0f8074
nowgnas/pandas
/chapter10/sec_02_simple.py
577
3.65625
4
import pandas as pd from importFile import * df = pd.DataFrame({'a': [10, 20, 30], 'b': [20, 30, 40]}) # print(df) # print(df['a'] ** 2) def my_sq(x, n): return x ** n sq = df['a'].apply(my_sq, n=2) # print(sq) def print_me(x): print(x) # print(df.apply(print_me, axis=1)) # print('-----------') # pri...
44cf0449ed7cd74ecebdbf8d514e0031a840997f
nizhnichenkov/log-file-analysis
/assign5_17712081.py
9,700
3.78125
4
# @author Svetoslav Nizhnichenkov # @email svetoslav.nizhnichenkov@ucdconnect.ie # @ID 17712081 ''' Program to analyse access log files. What it does: 1. Given a log file - outputs the number of unique IP addresses 2. Lists the top N IP addresses ( the ones with the most requests ) ...
588b1e0d8a5739b256fc8bf35e1fe9fde4a18c18
LauraHoffmann-DataScience/DSC510
/LHoffmann_11.1.py
3,130
4.25
4
# Course: DSC 510 # Assignment: 11.1 # Date: 5/22/2020 # Name: Laura Hoffmann # Description: Cash register program to demonstrate use of object oriented programming with classes # Must have a welcome message. # Create one class called CashRegister. # Have one instance method (addItem) with one parameter for pr...
6f68319baf9bb68404db83c3be4ba508e0507327
huixiaojie001/python101
/hello.py
5,623
3.875
4
''' #基础 + - * / 算法 print(1+2) print (1+2+3) print (3-1) print(3-1-1) print (3*7) print (3*7*3) print (21//7) print(2+4*2/4) print((2+4)*2/4) print () #变量(不能用数字开头)=值 box_width=3 BOX_WIDTH=33 box_heigth=4 s=box_width*box_heigth S=BOX_WIDTH*box_heigth print (s) print (S) print () #python 流程控制 if-else 语句 age=18 if age>16...
6724246574196d56f977b5a0262ee5405e50e4f8
salcedopolo/Ejemplo02
/POO.py
818
4.15625
4
# Defina una clase con variables para **name** y **country**. # Luego defina un método que pertenece a la clase. El método # propósito es imprimir una frase que usa las variables. # COMMIT INICIAL class Location: def __init__(self, name, country): self.name = name self.country = country d...
6b66543c394c7e77a5b1e5c75a0b4e83ddefbc54
dkulemin/HSE_course
/Week 4/Inverse sequence/inverse_sequence.py
113
3.5625
4
def f(): a = int(input()) if a != 0: f() print(a) return None print(a) f()
c58ec6f71bd1913e27a8d775f4c254789ca66079
dkulemin/HSE_course
/Week 2/Second max/second_max.py
299
3.765625
4
n = -1 maxNum = 0 maxSecNum = 0 while n != 0: if n == -1: n = int(input()) maxNum = n else: n = int(input()) if n > maxNum: maxSecNum = maxNum maxNum = n elif maxSecNum < n <= maxNum: maxSecNum = n print(maxSecNum)
f5b9bdb1a4793e7a8f5f6fa5378536fbe2ab0677
dkulemin/HSE_course
/Week 4/Is in Area/is_in_area.py
347
3.78125
4
def IsPointInArea(x, y): """ (x+1)^2 + (y-1)^2 = 4 y = -x y = 2x + 2 """ sqrR = (x + 1)**2 + (y - 1)**2 bool1 = -x <= y and 2*x + 2 <= y and sqrR <= 4 bool2 = -x >= y and 2*x + 2 >= y and sqrR >= 4 return bool1 or bool2 if IsPointInArea(float(input()), float(input())): print('Y...
755513bc0b31749e2e56ee2d8b5c00e84d3284e0
dkulemin/HSE_course
/Week 2/Num of MAX/num_of_max.py
183
3.625
4
n = int(input()) count = 1 maxNum = n while n != 0: n = int(input()) if n > maxNum: maxNum = n count = 1 elif n == maxNum: count += 1 print(count)
45236102eac38b9c75d2f91b4ee0f50116c62098
dkulemin/HSE_course
/Week 5/Sum of factorials/sum_of_fact.py
98
3.703125
4
import math summ = 0 for i in range(1, int(input())+1): summ += math.factorial(i) print(summ)
d60f2d5969db4705c81c9596548d6b64ac5fc9f9
dkulemin/HSE_course
/Week 4/Triangle/triangle.py
440
3.890625
4
def distance(x1, y1, x2, y2): sumSquares = (x2 - x1)**2 + (y2 - y1)**2 return sumSquares**(1/2) def perimeter(x1, y1, x2, y2, x3, y3): a = distance(x1, y1, x2, y2) b = distance(x2, y2, x3, y3) c = distance(x3, y3, x1, y1) return a + b + c sum = perimeter(float(input()), float(input()), ...
c51675c7e086cf6b8fa30d9a4a34f2dfb08be7de
nlenhertscholer/Advent_of_Code
/2020/Day 2/day2.py
781
3.625
4
with open("passwords.txt") as f: correct = 0 while True: line = f.readline() if not line: print(correct) exit(0) data = line.split(" ") min = int(data[0].split('-')[0]) max = int(data[0].split('-')[1]) target_char = data[1][0] ...
7a8f9e8329038ff7096a0da7178512a9f8764d1e
Goodir/my_solution
/BinaryGap.py
653
4
4
""" Write a function: def solution(N) that, given a positive integer N, returns the length of its longest binary gap. The function should return 0 if N doesn't contain a binary gap. For example, given N = 1041 the function should return 5, because N has binary representation 10000010001 and so its longest binary gap...
8beeecde6fe9cbe4ff31908a2f7593232a7ca7aa
akjanik/Project-Euler
/problem-010.py
1,581
3.59375
4
""" The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. """ import math import time limit = 2000000 t0 = time.time() # initial listof13 primes = [2] # find all prime numbers below 2 000 000 (not included upper bound) for number in range(3, 2000000, 2): if a...
9c3f2da9803a379632fa2bb42d68ecedec69d157
yosepnurawan/python-basic-learn
/piramid.py
538
4.15625
4
# a = 1 # while a < 10: # b = 0 # while b < a: # print("*", end = '') # b = b + 1 # print() # a = a + 1 # a = 10 # while a > 1: # b = 0 # while b < a: # print("*", end = '') # b = b + 1 # print() # a = a - 1 # 10 is the total number to print for num in r...
fb778678036a5531f4b37c956c36e730399d1023
maxy0524/0828
/else.py
204
4.03125
4
#!/usr/bin/python for var in [1,2,3,4,5]: if var == 3: break; print var else: print "ok" for var in [1,2,3,4,5]: #if var == 3: # break; print var else: print "ok"
4ed006d008ba167b23f0f4749ecee7ffec4d11d8
bitemouth/learn-python
/helloworld.py
4,125
4.03125
4
#setup of Editor, Python, Package-Run ################################################## #printing print('number') print("###################") ################################################## #types example number = 2 real = 2.2 word = "word" nochar = 'c' #int print(type(number)) #float print(type(real)) #string pri...
ec6003cb42b6be0e5b670bf2254e6c5b224687af
tlarnold10/algorithms-test
/python/3-largest-prime-factor.py
590
3.765625
4
# first I want to get all the prime numbers into a list num = 13195 prime_numbers = [] for x in range(2,1000): devisible_list = [] for y in range(2,x+1): if(x==y): if(len(devisible_list) == 0): prime_numbers.append(x) elif(x%y == 0): devisible_list.append(...
75dfa2acebe42e13ba8116a18e03a39217dbb47e
tlarnold10/algorithms-test
/python/1-multiples-of-3-and-5.py
107
3.9375
4
sum = 0 for x in range(1, 1000): if x%3==0 or x%5==0: print(x) sum = sum + x print(sum)
e414b682356032950ac7f3409d47dcd5834091bd
euzivamjunior/studies
/100 Days of Code - The Complete Python Pro Bootcamp for 2021/day_8/project/caesar-cipher-my-solution/main.py
2,978
4.25
4
from art import logo alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', ] print(logo) def paramns(): print("########################################################") direction = input("\nType 'encode' to encrypt, type 'de...
35e1158341f3afca8b02f7ff257a2d2018b51aff
euzivamjunior/studies
/100 Days of Code - The Complete Python Pro Bootcamp for 2021/day_4/exercises/day-4-start/main.py
277
3.828125
4
import random # generate an int number between 1 and 10 random_integer = random.randint(1, 10) print(random_integer) # float between 0 and 1 random_float = random.random() print(random_float) # float between 0 and 5 random_float_5 = random.random() * 5 print(random_float_5)
875a2dddf30e4dab36368ce60e7f3f13d39a9cd7
jkchandalia/codingdojo
/python_stack/python/OOP/linkedlist.py
4,317
4.0625
4
class SList: def __init__(self): self.head = None def add_to_front(self, val): new_node = SLNode(val) if self.head is not None: current_head = self.head new_node.next = current_head self.head = new_node # SET the list's head TO the node we created in the...
471fe7b9c83edaf324a60ba7e6e9e6e2c891aff9
alxwrd/coinhandler
/examples/interactive_example.py
970
3.921875
4
from coinhandler import CoinHandler, NotEnoughTransaction if __name__ == "__main__": handler = CoinHandler( starting_float=(2.00, 1.00, 0.50, 0.20, 0.10, 0.05, 0.02, 0.01) ) while True: coin = input("Insert a coin: ") if not coin: break try: hand...
d99aec5e63b1da57c8b1c6e508d7b9c618402985
Atrolantra/reddit-dailyprogrammer-problems
/237 [Easy] Broken Keyboard/broken_keyboard.py
502
3.78125
4
# https://www.reddit.com/r/dailyprogrammer/comments/3pcb3i/20151019_challenge_237_easy_broken_keyboard/ dictWordList = open('enable1.txt').read().splitlines() inputs = ["edcf", "bnik", "poil", "vybu"] def check(keyString): longest = max(len(entry) for entry in dictWordList if (set(entry).issubset(set(keyString))...
510ee0505ade7f92a3d31197090330572769d8c2
salmanfazal01/210CT
/question 10.py
864
3.5625
4
def question10(myList): all_sequences = [] #empty list (2 dimension list) temp = [] #a sub-sequence for x,y in enumerate(myList): #index, value if(x == 0): temp.append(y) #append first value to temp else: if(myList[x] > myList...
1e3be0b9f026b20d9d0f2a29122e88432765d90e
salmanfazal01/210CT
/question 1.py
598
4.125
4
import random def question1(userList): print("\nEntered List: " + str(userList)) #original list newList = [] #empty list to append random numbers for i in range( len(userList) ): random_number = random.choice(userList) #select random original list newList.append(random_...
7dfb3fd4580b4d45cfeea1323f8ce1949a388d5b
decodingjourney/BeginnerToExpertInPython
/createdb/contacts.py
740
4.03125
4
import sqlite3 db = sqlite3.connect("contacts.sqlite") db.execute("create table if not exists contacts (name text, phone integer, email text)") db.execute("insert into contacts(name, phone, email) values ('anand', 8088908090, 'vikramanand.jha@gmail.com')") db.execute("insert into contacts values ('sonam', 9087998676,...
9d9ceb8b2f613ad0f4959c4fb03b7bb61c671022
decodingjourney/BeginnerToExpertInPython
/FileIO/writing.py
615
3.703125
4
# cities = ["Bangalore", "Delhi", "Chennai", "Mumbai", "Patna", "Hydrabad", "You are such a basturd"] # # with open("cities.txt", 'w') as city_name: # for city in cities: # print(city, file=city_name) # # cities = [] # # with open("cities.txt",'r') as city_name: # for city in city_name: # cities...
be7a3215fcb044c903bdfa50e15f2fcde8fc9e86
decodingjourney/BeginnerToExpertInPython
/HelloWorld/HelloWorld.py
2,837
4.1875
4
# print("Hello World!") # print(3+5) # print() # print(3 * 6) # greeting = "Good Morning!" # name = "Anand" # print(greeting+name) # print(greeting+' '+name) # print('Hello Git') # #nameOfPerson = input("Please enter your name") # #print(greeting+' '+nameOfPerson) # splitString = 'This string is\nsplit over\nmany diff...
2d90f2b0d4adcac23b9ab1e6708709ac9d6e3599
decodingjourney/BeginnerToExpertInPython
/createdb/checkdb.py
401
4.21875
4
import sqlite3 conn = sqlite3.connect("contacts.sqlite") for row in conn.execute("select * from contacts"): print(row) name = input("please enter the name") sql_statement = "select * from contacts where name = ?" sql_cursor = conn.cursor() for name, phone, email in sql_cursor.execute(sql_statement, (name,)): ...
8f324a87e7233ce26caeb31021c4b00805377e88
deanflood/DiceRoll
/DiceRoll.py
181
3.578125
4
import random print("Dice Mean: 3.5") mean = 0.0 for x in range(1, 1000000): mean += random.randint(1,6) print("Mean after 1,000,000 rolls: " + str(mean / 1000000)) mean = 0.0
96c59d337f8280f97eed6e993b9dff80bc970368
eunhyeP/Studying-Python-in-eclipse
/test4.py
2,868
3.515625
4
# 집합형 자료형 중 list type : 순서가 있고 요쇼값 수정이 가능, 중복 가능 a= [1,2,3] print(a,type(a)) # [1, 2, 3] <class 'list'> # 리스트안에 리스트를 넣을수있다. b = [10, a, 30.5, True, '컴퓨터'] print(b, type(b)) # [10, [1, 2, 3], 30.5, True, '컴퓨터'] <class 'list'> #진정한 배열은 numpy에서.. 아디오스 print() family = ['엄마','아빠','나','여동생'] ...
a88896c77035ff15ac6c8f81a7a0ba34a6a5aa22
mateoxan/kompilatory
/lab2/AST.py
1,869
3.78125
4
class Node(object): def __str__(self): return self.printTree() class Program(Node): def __init__(self, blocks): self.blocks = blocks class Block(Node): def __init__(self, content): block_content = [] if type(content) == list: for c in content: ...
43e7a79efb891b703ed01d5e0fe0c6773e4b4d53
sepulenie/codewars
/codewars_5.py
140
3.5
4
def solution(string, ending): print( ending in string and string[len(string)-1]==ending[len(ending)-1]) pass solution('lol', 'oy')
1e28f71e74ae3df6a1a85b9250ee1de63dc104f7
blackdoor-specialteams/Data-Mining
/hw4/tree.py
947
3.71875
4
class Tree: def __init__(self, node_label, node_value): self.node_label = node_label self.node_value = node_value self.subtrees = [] def append(self, subtree): self.subtrees.append(subtree) def __str__(self): result = '(Node ' result += '<...
0cdc7e0e35f07ecfbcc0de46be50395c7cec8e83
sketchychen/whiteboarding
/arrays_and_strings.py
3,661
4.03125
4
from collections import defaultdict import re def assert_equals(test_result, expected_result): if test_result == expected_result: return "Test passed." else: return "Test failed." # Is Unique: # Implement an algorithm to determine if a string has all unique characters. # What if you cannot use...
14d557bbc1692e57f12be4f6658b1667dd79350c
VladaDidko/Machine-Learning
/lab1-param-regression/trial.py
3,247
3.515625
4
from numpy import * import matplotlib.pyplot as plt from scipy.stats import * from scipy.interpolate import * l = 10 x_learn = array([4*((i-1)/(l-1))-2 for i in range(1,l+1,1)]) print("LEARN VALUES") y_learn = array([1/(1+25*i*i) for i in x_learn]) for x, y in zip(x_learn,y_learn): print(x, ' - ', y) def lagran...
24ed1c34bdab2df15fc38c7b70b74f85b3f42264
ozkancondek/clarusway_python
/clarusway/my_module.py
1,562
4.375
4
# -*- coding: utf-8 -*- """ Created on Sat Aug 14 23:55:58 2021 @author: admin """ #Python Modules #Consider a module to be the same as a code library. #A file containing a set of functions you want to include in your application. #Save this code in a file named mymodule.py def greeting(name): print("Hello, " + na...
0cd83a9cec2a7d3671f74ae51a51e24e6a98b712
ozkancondek/clarusway_python
/my_projects/hangman/word_output_function.py
271
3.6875
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 16 01:24:35 2021 @author: admin """ def wor(word,ch): ls = list(word) c = 0 while c < len(ls): if ls[c] != ch: ls[c] = "_" c += 1 return "".join(ls)
420fdeb87a8a73275075697e033018f8c9553211
ozkancondek/clarusway_python
/clarusway/list_Comprehension.py
710
3.671875
4
# -*- coding: utf-8 -*- """ Created on Thu Jul 29 15:59:29 2021 @author: admin """ #if body - if - condition - else - else body condition = False print("ozkan" if condition else "OZKAN") #newlist = [expression for item in iterable if condition == True] ls = [1,2,3,4,5,6,7,8,9,10] a = [i**2 for i in ls if i%2]#al...
6cf67d4687d34103ec843498997fba9305b5e32e
ozkancondek/clarusway_python
/my_projects/root_finder.py
493
3.796875
4
# -*- coding: utf-8 -*- """ Created on Tue Aug 17 13:58:18 2021 @author: admin """ #Roots of a quadratic equation def root_finder(a,b,c): delta = b**2-4*a*c if delta < 0: return "no root" else: x_1 = (-1*b+(delta**0.5))/(2*a) x_2 = (-1*b-(delta**0...
84bb9790d668145eb9a2ff70b205d171d9e4399f
ozkancondek/clarusway_python
/my_projects/reqursive.py
295
4.125
4
# -*- coding: utf-8 -*- """ Created on Wed Jul 28 23:59:58 2021 @author: admin """ a = int(input("Give me a number: ")) def factoriel(x): if x == 0: return 1 else: return x * factoriel(x-1) print("The factorial of the {} is equal to {}.".format(a,factoriel(a)))
45d6538ea2d12d9ef89ffcb0a2287ba9fb2c1aa9
ozkancondek/clarusway_python
/my_projects/duplicate_encoder.py
623
4.21875
4
# -*- coding: utf-8 -*- """ Created on Mon Aug 23 13:51:35 2021 @author: admin """ #The goal of this exercise is to convert a string to a new string # where each character in the new string is # "(" if that character appears only once in the original string, or ")" # if that character appears more than once in the or...
82fb78501315fb4387bc7fd3aad2c97f1c0f548b
ozkancondek/clarusway_python
/my_projects/polybius_square.py
1,427
3.546875
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 2 19:38:10 2021 @author: admin """ #https://edabit.com/challenge/2C3gtb4treAFyWJMg from string import ascii_uppercase ls= list(ascii_uppercase) ls.remove("J") ls[ls.index("I")] = "I/J" letter_dic = {} for i in range(1,6): for j in range(1,6): letter_dic[i...
c69b495a7b90f7144a996fd420ab8c6835f8daef
ozkancondek/clarusway_python
/clarusway/corona_exemple.py
556
3.578125
4
# -*- coding: utf-8 -*- """ Created on Tue Jun 22 13:13:48 2021 @author: admin """ print("Please answer the questions to know corona risk.\n") print(" Press direct to ENTER key if say no. Otherwise write somethink to say yes\n") age = bool (input("Are you a cigarette addict older than 75 years old? ")) chronic = bool ...
292479cee6dfdae6e0bb45a5ac6617172e1a5bf0
ozkancondek/clarusway_python
/clarusway/armstrong-numbers-2.py
645
3.890625
4
# -*- coding: utf-8 -*- """ Created on Mon Aug 2 19:11:53 2021 @author: admin """ #armstrong number example. Invalid Value pert is different while True: number = input("Enter a positive integer number: ") digit = len(number) result = 0 if not number.isdigit(): print(number, " is invalid e...
46f2c2c8f07016858c6ca121307cdcad266e4af0
ozkancondek/clarusway_python
/my_projects/scrablies.py
433
4.0625
4
# -*- coding: utf-8 -*- """ Created on Mon Aug 23 13:51:35 2021 @author: admin """ #Complete the function scramble(str1, str2) that returns true # if a portion of str1 characters can be rearranged to match str2, #otherwise returns false. a = 'rkqodl' b = 'world' def scramble(a,b): for i in b: if i not i...
9a3d9db40eadc98a9ef368d84620c4b2e526eed6
ozkancondek/clarusway_python
/clarusway/prime-number-assigment.py
657
4.0625
4
# -*- coding: utf-8 -*- """ Created on Sat Jul 24 14:59:31 2021 @author: admin """ print("This program will check if your integer input is prime.") num = int(input("Enter a integer number first: ")) ls =[] if num < 2: print("The number can not be smaller than 2.") elif num == 2: print(f"{num} is a prime num...
8d4823ce7b6b53e75f6c43e5bcc7ff66db7b3953
ozkancondek/clarusway_python
/clarusway/perfect_number.py
313
3.640625
4
# -*- coding: utf-8 -*- """ Created on Thu Aug 5 16:53:59 2021 @author: admin """ def perfect(num): result = 0 a = [i for i in range(1,num) if num%i == 0] for j in a: result = result + j print( "Perfect number." if result == num else "It`s not a perfect number.") perfect()
bcd06b23186c68dcc25bef57f960d80c6bcce29e
ozkancondek/clarusway_python
/my_projects/make_a_guess.py
870
3.671875
4
# -*- coding: utf-8 -*- """ Created on Thu Jun 17 22:23:36 2021 @author: admin """ import random print("\tWelcome to GuessMyNumber game\n") print("I will make a guess in every try a number between 2 and 8\n") print("And i will also say to you is it lower or higher\n") print("You have 5 attempts\n") print("****Lets st...
739946880824d61886b0abab868d85bd1b5210ca
ozkancondek/clarusway_python
/my_projects/pyramit.py
559
3.984375
4
# -*- coding: utf-8 -*- """ Created on Thu Jul 29 20:26:56 2021 @author: admin """ #draw a pyramit with entered variables. #get building material from the user #get base width for pyramid #base width has to be odd number otherwise send user a massage that it has to be odd number. a = input("Choose the building materi...
5d69ec0d02c9ef3e416a4bc4a08d26b5dbd0c03d
kaushikdas/InterestingCodes
/Python/timeinwords.py
2,614
4
4
# https://www.hackerrank.com/challenges/the-time-in-words/problem def numToWord(n): numDict = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', ...
9893261f8ab9f35c7ad52831f917c9d6ed7746f7
SiddheshKhedekar/Python-Foundations
/2.Turtle, messaging and Profanity checker/twoTurtles.py
592
3.9375
4
""" The program that allows user to make two separate turtles draw at the same time. """ import turtle background = turtle.Screen() meow=turtle.Turtle() meow.shape("turtle") meow.color("red") woof = turtle.Turtle() woof.shape("turtle") woof.color("blue") meow.speed(1) meow.right(90) meow.forward(200) woof.speed(1)...