blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
56de40137f64efa756d563f2ee92c4beb2a9257a
navill/study_tkinter
/gui_test/monitor_gui.py
959
3.734375
4
import tkinter as tk from tkinter.ttk import Combobox window = tk.Tk() window.title("ECG monitor") # label label_1 = tk.Label(window, text='test monitor label', font=("Arial Bold", 20)) label_1.grid(column=0, row=0) # label_2 = tk.Label(window, text='input value') # label_2.grid(column=0, row=1) # label_3 = tk.Label(...
3a689c4a6d25dbcf35a04e155ffff0fa8578362d
mishajw/projecteuler
/src/p017_number_letter_counts.py
1,063
3.671875
4
known = { 1: "one", 2: "two", 3: "three", 4: "four", 5: "five", 6: "six", 7: "seven", 8: "eight", 9: "nine", 10: "ten", 11: "eleven", 12: "twelve", 13: "thirteen", 14: "fourteen", 15: "fifteen", 16: "sixteen", 17: "seventeen", 18: "eighteen", 1...
fcf0229b045789d7e4819f5e1d2884c7159a1202
dudals1069/python
/리스트 상호곱셈 .py
219
3.796875
4
list1 = ["아스날","에메리"] list2 = ["리그우승","FA컵우승","유로파우승"] list3=[] for i in range(len(list1)): for j in range(len(list2)): list3.append([list1[i],list2[j]]) print(list3)
460ec4a56c5d7d0ac166c87ae468026b11875751
KatieFizzy/Algorithms
/stock_prices/stock_prices.py
727
3.796875
4
#!/usr/bin/python import math import argparse def find_max_profit(prices): max = -math.inf for i in range(len(prices) - 1): for j in range(i, len(prices)): difference = prices[j] - prices[i] if difference > max and i != j: max = difference return max if __name__ == '__main__': # T...
03d19cf620451f9f7d2da74b76cacb689846bdad
holmanapril/Assessment_Quiz
/how_many_questions_v1.py
456
4.1875
4
# Asks how many questions user would like to play question_amount = int(input("How many questions would you like to play? 10, 15 or 20?")) # If questions_amount is equal to 10, 15 or 20 it print it if question_amount == 10 or question_amount == 15 or question_amount == 20: print("You chose {} rounds".format(questio...
55e822144603c6b4a0dad1b98d2e1e22cb188a42
txnuj/Python-Basics.
/Basics/Day6.py
2,305
4.0625
4
#Keyword Arguements def greet_user(first_name, last_name): print(f"Hi {first_name} {last_name}!") print("Welcome Aboard") print("Start") greet_user(last_name="John",first_name="Smith") #Even though John takes the first_name, after using keyword arguements they can be sorted. print("Finish!") #R...
5c4e35cc40030d343bc1cd5504da985827569aa7
XUMO-97/lpthw
/ex15/ex15.py
1,610
4.375
4
# use argv to get a filename from sys import argv # defines script and filename to argv script, filename = argv # get the contents of the txt file txt = open(filename) # print a string with format characters print "Here's your file %r:" % filename # print the contents of the txt file print txt.read() tx...
0291b11d9a4d17323dc83b243c879418cb446e8d
dvalp/coding-practice
/hackerrank/strings.py
1,158
4
4
from collections import Counter def print_formatted(number): ''' The challenege was to print each number up to (including) the given integer in several number formats, with padding to match the length of the largest binary version of the number. The interesting point here is that you can insert ...
6d37099c9a02eef6addcc594f8b31d6f6f68f55c
adityagoyal222/Aditya_Goyal_ewallet
/interface/account_int.py
12,019
3.5
4
from classes.connection import Connection from classes.Account import Account from classes.Service import Service from tkinter import * import tkinter.ttk as ttk from tkinter import messagebox class AccountInterface: """Class to show Account Window""" def __init__(self, username): self.window = Tk() self.usern...
b467a7a15bf0dcd523a7de566ed85f0db1c76a9e
kuzin2006/codewars
/encrypt.py
332
3.890625
4
def encrypt_this(text): return " ".join(filter(None, [''.join([str(ord(word[0])) if len(word) else '', word[-1] if len(word) > 1 else '', ''.join([word[2:-1], word[1]]) if len(word) > 2 else '']) for word in text.split(" ")])) \ if text else '' print(encrypt_this...
af6269d80dff9bc4e52e144c51474332b5447669
kuzin2006/codewars
/snail.py
349
3.765625
4
# https://www.codewars.com/kata/snail/train/python import itertools def top_row_transpose(arr): while arr: yield arr[0] arr = list(reversed(list(zip(*arr[1:])))) def snail(snail_map): return list(itertools.chain(*top_row_transpose(snail_map))) array = [[1,2,3], [4,5,6], [...
dddf559a284bb818ff20b9d62c5dc23cbf486e5f
pilosus/pili
/pili/jinja_filters.py
1,069
3.6875
4
def permissions2str(n): """Convert permission representation into a string representation. Used as a Jinja2 custom filter. """ perms = {0: 'a', 1: 's', 2: 'm', 3: 'u', 4: 'c', 5: 'w', 6: 'f', 7: 'r'} perm_str = "{0:0>8}".format(bin(n).lstrip('0b')) result = '' for k in perms.keys(): ...
d3f7f364560067952e53db1b72a5d261d4402b5a
parthanand-in/Face-Detection-in-Python-using-OPEN-CV
/Face detection with OpenCV.py
2,549
3.640625
4
# Import the necessary libraries import numpy as np import cv2 import matplotlib.pyplot as plt get_ipython().magic('matplotlib inline') # Loading the image to be tested test_image = cv2.imread('baby1.jpg') # Converting to grayscale as opencv expects detector takes in input gray scale images test_image_gray = cv2....
fa80f81b931101b46e657750fd28167e9f4f33a9
DuTogira/HackerRank
/Practice/Python/Math/TriangleQuest.py
207
3.515625
4
# problem: https://www.hackerrank.com/challenges/python-quest-1/problem for i in range(1, int(input())): # More than 2 lines will result in 0 score. Do not leave a blank line also print((10**i//9)*i)
524e7d39f161ac9ecaa8c292efff06264be5368d
DuTogira/HackerRank
/Practice/Problem Solving/Implementation/BetweenTwoSets.py
1,120
3.5625
4
# problem: https://www.hackerrank.com/challenges/between-two-sets/problem #!/bin/python3 import math import os import random import re import sys def getTotalX(a, b): largest = b[0] smallest = a[0] total = 0 for num in a: if num > smallest: smallest = num for num in b: ...
f7aaf8d2c34c776f474dadceac4d899d7e86cc52
mahendrark/Python-MOOC
/week3/hangman_game/testing.py
386
3.953125
4
def ifAnyGuessed(lettersGuessed, secretWord): ''' Reads in the guessed letter and if its part of the letters, prints appropriate statement and function call ''' for char in lettersGuessed: if char in list(secretWord) and not in : return print("Good guess: ", getGuessedWord(se...
aa00e7624f46738b5ba149f9150241cea681727b
mahendrark/Python-MOOC
/old_midterm_challenges/prog11.py
452
3.59375
4
# https://github.com/samarth1402/MITx-6.00.1x/blob/master/midterm_exam/problem_3.py def jumpAndBackpedal(isMyNumber): ''' isMyNumber: Procedure that hides a secret number. It takes as a parameter one number and returns: * -1 if the number is less than the secret number * 0 if the number is equ...
3900265717cb64a9d7ebe0c5da002a1ed3cf5c68
mahendrark/Python-MOOC
/old_midterm_challenges/prog5.py
636
3.859375
4
# Problem 4 # 15/15 points (graded) # Write a Python function that returns the sublist of strings in aList that contain fewer than 4 characters. # For example, if aList = ["apple", "cat", "dog", "banana"], your function should return: ["cat", "dog"] #This function takes in a list of strings and returns a list of stri...
3264716a74a25ccdf03262db91828bdca43aa999
grassriver/Zhidao
/CONN_UI_DB/user_info.py
1,458
4.0625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Mar 17 14:39:59 2018 @author: xichenjin """ import sqlite3 as sql #%% #create a database def create_sql(conn): c=conn.cursor() c.execute( """create table if not exists %s( %s integer primary key autoincrement, %s ...
d775dd8eda04066ac8da701a898983f17e505256
grassriver/Zhidao
/stock_screener.py
15,635
3.703125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Mar 7 17:12:13 2018 @author: zifandeng """ import numpy as np import pandas as pd import sqlite3 as sql import math def date_freq_transfer(date,freq): """ Transfer the date input information to corresponding frequency Parameters -...
6a3d645930c42339df73d681bdc64801da6f9f3b
liuguoxu/my_leetcode
/python/add_binary.py
1,373
3.8125
4
''' Given two binary strings, return their sum (also a binary string). The input strings are both non-empty and contains only characters 1 or 0. Example 1: Input: a = "11", b = "1" Output: "100" Example 2: Input: a = "1010", b = "1011" Output: "10101" ''' class Solution: # return result and remainder @sta...
75b4e20c521ad924384a02f60ec4be692f0ffe36
axelri/fluffy_spheres
/testing/physics.py
6,885
3.53125
4
import vectors import collisions import shapes import numbers import games GRAVITY = vectors.Vector([0.0, -10.0, 0.0]) dt = 0.0005 # (1+e)(relv.norm) #j =------------------------------------------------------------------------------ # norm.norm(1/Mass0 + 1/Mass1) + (sqr(r0 x norm) / ...
70316521ddedf268be49f3e134ae90d8f097facf
adilbey/simple_dice
/simple_dice.py
469
4
4
import random question = input('Would you like to roll the dice?\n') while question != 'no': if question == 'yes': die1 = random.randint(1, 6) die2 = random.randint(1, 6) print(die1, die2) question = input('Would you like to roll the dice again?\n') else: print('Invalid...
e411ec8d9b60de0bd4b5c5ca3b97f96e8c99586c
dharshavardhan/python
/h3.py
81
3.671875
4
#finding even numbers for x in range (1,1000): if x%2==0: print(x)
2cb99255533d9970d7cc83d3675842ea873866e8
shawnd29/machine-learing-fundamentals
/logistic_descent.py
3,021
3.671875
4
''' This assignment optimizes using the logistic discrimination gradient descent algorithm. To run the program use python logistic_descent.py <dataset_name> <test_label_name> Shawn Rahul D'Souza ''' import sys import math from random import random #Find the dot product def dot_prod(w, k): dp = 0 refw = w...
457605325a3338e41c9e802600e7b1788b26d476
ketkiambekar/data-structures-from-scratch
/BFS.py
728
4.3125
4
# Using a Python dictionary to act as an adjacency list graph = { '5' : ['3','7'], '3' : ['2', '4'], '7' : ['8'], '2' : [], '4' : ['8'], '8' : [] } visited = set() # Set to keep track of visited nodes of graph. queue=[] def bfs(visited, graph, node): visited.add(node) queue.append(node) w...
b9f2d95e038c026264781d7f814d0e93faf438da
sangavimeenu123/siva
/power.py
126
3.53125
4
a=int(input()) n=a count=0 while (n!=1): n=n//2 count=count+1 b=2**count if (a==b): print("yes") else:print("no")
42c8911eb4e509f4d901017affd843e6f025f89e
sangavimeenu123/siva
/diffodddeve.py
103
3.640625
4
n,m=(input().split()) n=int(n) m=int(m) sub=n-m if sub%2==0: print ("even") else: print("odd")
ef6dd49ace36a6c02e6b28dd0f569f3a664797ce
Comp-Sci-Principles-2018-19/chapter-2-exercises-Lilithv
/time.py
271
3.625
4
time=int(input('what time is it')) long=int(input('how long do you want your alarm to be for?')) longmodulo=long%24 alarmt=time+longmodulo alarmt=alarmt%24 #dont go past 24 k thnks print('I will set off at',str(alarmt)+', Doctor Luigi') #x=5100 % 1400 #y=x+1400 #print(y)
8510f62684e6016b1fa86128650d38e8f99d0518
LunaL0veg00d/helloWorld
/shopping_list2.py
1,156
4
4
import os def clear(): if os.name == 'nt': os.system('cls') else: os.system('clear') # to make a list of entered items shopping_list = [] empty_line = """ """ def show_help(): # print out instructions on how to use the app print("What should we buy at Auchan?") print(""" Enter 'DONE' to stop adding items...
849eb946ae0665e51381e933dc4eaa71731b1865
unswbei/UNSW-COMP9900-Project
/9900/capstone-project-salted-fish-master/backend/users/util.py
276
3.609375
4
#!/usr/bin/python3 import hashlib def sha256(hash_string): """sha256 hash encrypt Param: hash_string -- string to encrypt Return: hex digest of encrypted string """ m = hashlib.sha256() m.update(hash_string.encode()) return m.hexdigest()
c3706c9aecc0c746e4cc052fda82e23fc8481509
portillosc/deep-crimson
/weather_report_etl/weather_sun_etl/test_test.py
127
3.625
4
from datetime import date import datetime today = date.today() tomorrow = today + datetime.timedelta(days=9) print(str(today))
3da0adf2d54966f86b228625d51827c3f6be8e64
bryoncodes/aoc
/2022/4/part1.py
728
3.734375
4
#!/usr/local/bin/python3 def range_compare(sections): section1 = set() section2 = set() s1 = sections[0].split("-") s2 = sections[1].split for i in range(int(s1[0]),int(s1[1])+1): section1.add(i) for i in range(int(s2[0]),int(s2[1])+1): section2.add(i) if section1.is...
60c749cae73b6911db54fb0024c48c6743a63988
bryoncodes/aoc
/2022/10/part2.py
1,264
3.5
4
#!/usr/local/bin/python3 def drawpixel(x,cycle): if cycle == 0: cycle = 40 cycle -= 1 if cycle >= x-1 and cycle <= x+1: return "#" return " " def aoc(): commands = [] cycle = 0 x = 1 with open("./input.txt") as infile: line = infile.readline().strip().split()...
079b3eb3691775997ae749eb39d0100d338bde0c
houmie/iqvia
/iqvia/contacts/services.py
1,144
3.515625
4
from sqlalchemy import func from .models import Contact import re def validate_username(username: str) -> bool: """ Checking that the username is valid (length and characters) :param str username: the username to be validated. e.g: 'we9fdoie023kd' :return bool: True if valid username. """ ...
f34850df3844f8282144cc8e7c906f79a2d93b45
syedfaisalsaleeem/test_codes_python
/test3.py
173
3.671875
4
print("Time Temperature".split()) x="Time Temperature" y=x.split() print(len(y)) temp_list=[] for t in y: print(t) # temp_list.append(t) print(temp_list) # print(type(x))
86647536cd33d8f7e17b9731f5d5118618ac3fd6
syedfaisalsaleeem/test_codes_python
/decorator_example_2.py
235
3.78125
4
### calculate the function time exectuion import time def timer(func): def wrapper(): before = time.time() func() print("Function took:", time.time()- before,"seconds") return wrapper @timer def run(): time.sleep(2) run()
0933e5e505112664bc9c914bf03a5cba2ac7def4
needscroll/UTD
/cs3377/a11.py
806
3.890625
4
import random def rand(a, b): return random.randint(a, b) rand_num = rand(-100, 100) print(rand_num) guess = 200 guess_num = 0 guess_left = 7 name = raw_input("enter your name\n") while rand_num != guess and guess_left > 0: print "enter a number. you have ", guess_left, "guesses left" guess = input() ...
f079c9a1d19d8c2af2455fad63f2031d0c64e66d
adoval12/tamidPracticeExercise
/answers.py
843
3.8125
4
import pandas as pd # Question 1 def read_file(file_path): df = pd.read_csv(file_path) return df df = read_file('myBoys.csv') print(df) print() #Question 2 print(df["Age"]) print() #Question 3 def increase_age_by_five(age): return age + 5 df["Age"] = df["Age"].apply(increase_age_by_five) print(df) #Qu...
5354695d73f094e4de4c44f110a01c3ea89bc1e8
stevenbustos/frubana-test
/median.py
2,144
3.765625
4
__author__ = 'Steven Bustos' import sys def num_format(m): # Format the result without trailing zeros format = "%d" if m.is_integer() else "%s" print(format % m) def median(limin, limax): # Calculing the media if( len(limin) > len(limax) ): m = limin[-1] print m elif( len(...
b65041397cf52c1398ae8ea0c2656a507e5e3de0
kchennaf/CCLab2
/WordCountTensorFlow_3.py
1,152
3.65625
4
import nltk # nltk.download('punkt') # nltk.download('stopwords') import re from collections import Counter counter = 0 from nltk.corpus import stopwords def get_tokens(): with open('C:\\Users\Chennaf\Downloads\FirstContactWithTensorFlow.txt', 'r') as tf: text = tf.read() lowers = text.lowe...
e358ecfabb655068f2fb70954677d220ad1104cd
cwalker4/youtube-recommendations
/youtube_follower/db_utils.py
2,024
4.15625
4
import sqlite3 from sqlite3 import Error def create_connection(db_path): """ Creates the sqlite3 connection INTPUT: db_path: (str) relative path to sqlite db OUTPUT: conn: sqlite3 connection """ try: conn = sqlite3.connect(db_path) except Error as e: print(e) return conn def create_record(conn, tabl...
da771205e1fb973fc83a8b4a650401435059604b
Watson2016/entitas-python
/entitas/entity.py
5,136
3.765625
4
""" entitas.entity ~~~~~~~~~~~~~~ An entity is a container holding data to represent certain objects in your application. You can add, replace or remove data from entities. Those containers are called 'components'. They are represented by namedtuples for readability. """ from .utils import Event from .exceptions impo...
9b58c385f84ba9352e8e052e8bf3716c80cde322
tumorbox/python
/grammar/12_OOP_basic.py
649
3.71875
4
class Person: # 클래스 객체 생성 name = '이름이란 , 사람이 공통적으로 가지는 속성' age = '나이란, 내가 태어나서 죽을 때 까지의 기간' def greeting(self): return f'{self.name}이 인사합니다. 안녕하세요!' def aging(self): return f'{self.name}은 {self.age}살 입니다.' @classmethod def age_means(cls): return f'{cls.name}은 나라마다 다르다.'...
f7d0bb7b735aab0ff4c988492890fe4e71e717c2
uchicago-library/digital_collection_validators
/proj1.py
2,301
3.703125
4
import argparse import os """ checkRoot evaluates there are 3 subdirs (ALTO, JPEG, TIFF) and 5 files (xml, pdf, txt) checkRoot throws an error if there are not 3 subdirs and 5 files""" def checkRoot(r): dirNum = 0 fileNum = 0 for n_item in os.scandir(r): if n_item.is_dir(): dirNum += 1 elif n_item.is_file(...
141c126d056720b099055311582040a85ad6f8f4
GiveMeTheReason/algorithms
/prefix_pi_function.py
903
3.78125
4
def prefix_pi_function(s): ''' Returns the list of PI-function of string PI-function - max prefix length that can be own suffix (own suffix excludes full string) See also Knuth–Morris–Pratt algorithm ''' l = [0]*(len(s)) for i in range(1, len(s)): w = l[i-1] whi...
b2db4b4d18061530262cf04bc160be103b5fb0f8
GiveMeTheReason/algorithms
/merge_sort.py
909
3.75
4
from datetime import datetime start_time = datetime.now() def merge_sort(list): ''' Merge sort (recursive) ''' if len(list) < 2: return list first_part = merge_sort(list[:len(list)//2]) last_part = merge_sort(list[len(list)//2:]) i = j = 0 res = [] while i < l...
4c0094b01def72bff17bc3402724451a341821fc
GiveMeTheReason/algorithms
/levenstein.py
557
3.65625
4
def levenstein(a, b): ''' Returns the distance between two strings ''' F = [[i+j if i*j == 0 else 0 for j in range(len(b)+1)] for i in range(len(a)+1)] for i in range(1, len(a)+1): for j in range(1, len(b)+1): if a[i-1] == b[j-1]: F[i][j] = F[i-1][j-1] ...
ac9beb1386d1413a9b2d86b9e5fd8b9aff24f622
HidanZZ/MihoyoAccountGenerator
/app/service/passwordutil.py
917
3.546875
4
import random length = 15 def get_pass(): password = [] count = 0 word = '' while count < length: rand = random.randint(0, 3) if rand == 0: b = int(random.randint(97, 123)) password.append(b) elif rand == 1: b = random.randint(65, 91) ...
647f0c8c48b953c6a1ba55b5174f1d843882a378
Rain0Ash/Programming_University
/Practice/04/Python/4.py
1,031
3.84375
4
def read(): while True: try: return map(int, input("Введите первое и второе число, разделив их пробелом: ").split()) except ValueError: print("Ошибка парсинга значения. Попробуйте повторить ввод.") while True: try: print("Первый метод") a, b = read() ...
b61990b49dd81622ef3f4e92d5eda25284024cef
FelixDavidson/MyPythonPrograms
/ThinkPython/ch6.py
957
4.03125
4
import math # 6.1 def area(radius): return math.pi * radius**2 # 6.2 def distance(x1, y1, x2, y2): dx = x2 - x1 dy = y2 - y1 dsquared = dx**2 + dy**2 result = math.sqrt(dsqared) return result # 6.3 def circle_area(xc, yc, xp, yp): return area(distance(xc, yc, xp, yp)) # 6.4 def is_di...
b4c8d0e48aec80b9d6382024e2e255cbff2060af
FelixDavidson/MyPythonPrograms
/CodingBat/Warmup-1/front_back.py
644
3.828125
4
def front_back(str): splitted = list(str) if len(str) <= 1: return str container = splitted.pop(0), splitted.pop(-1) splitted.insert(0, container[-1]) splitted.append(container[0]) return ''.join(splitted) """ Overall pretty good for me. The solution was a bit smaller. def front_back(...
90e45ef6f21d4bb7bf8a749f09ba3032dc6a4307
FelixDavidson/MyPythonPrograms
/CodingBat/Logic-2/no_teen_sum.py
485
3.609375
4
def no_teen_sum(a, b, c): if 13 <= a <= 19 and a != 15 and a != 16: a = 0 if 13 <= b <= 19 and b != 15 and b != 16: b = 0 if 13 <= c <= 19 and c != 15 and c != 16: c = 0 return a + b + c # No need for extra function mainly because #I didn't understand that part of the question ''...
9c4c4f629884f3eff4b73f2f3164836c876afabd
FelixDavidson/MyPythonPrograms
/ThinkPython/8_4.py
126
3.90625
4
def find(word, letter, start): for char in word[start:]: if char == letter: return char return -1
4d0e3db9f6e369402031cd1c93caca53589333ac
rafaelgarcia094/AdventOfCode2020
/scripts/day10_pt1.py
368
3.546875
4
adapters = sorted([int(input()) for _ in range(104)]) diff_1 = 0 diff_3 = 1 curr_voltage = 0 for next_voltage in adapters: diff = next_voltage - curr_voltage if diff == 1: diff_1 += 1 elif diff == 3: diff_3 += 1 else: raise Exception(f'{curr_voltage}, {next_voltage}') cur...
9880b66f7cf022c0757637b9e165cdd955858ad1
ArthurCisotto/insper.dessoft
/Aula 11. Classe/circulo.py
323
3.703125
4
class Circulo: def __init__(self, centro, raio): self.centro = centro self.raio = raio def contem(self, ponto): distancia = ((ponto.x - self.centro.x)**2 + (ponto.y - self.centro.y)**2)**(1/2) if distancia <= self.raio: return True else: return Fal...
df850c75c459718f59352a54907a0318aa5a0b36
ArthurCisotto/insper.dessoft
/Aula 04. If/multa.py
191
3.71875
4
vel = float(input('Qual é a velocidade do carro?')) multa = 5 * (vel-80) if vel > 80: print('Você foi multado em {0:.2f} reais'.format(multa)) else: print('Não foi multado')
601137d2cb6b7fb13973e427da0f1be518f3ea16
ArthurCisotto/insper.dessoft
/Aula 06. Lista/subtracao_de_listas.py
125
3.671875
4
def subtracao_de_listas(lista1, lista2): lista_dif = [i for i in lista1 + lista2 if i not in lista2] return lista_dif
8a53b0d02f3c3c99bede98e96e67431a7fa12344
ArthurCisotto/insper.dessoft
/Aula 08. Dicionário/primeiras_ocorrencias.py
172
3.59375
4
def primeiras_ocorrencias(string): dic = {} for letra in string: if letra not in dic.keys(): dic[letra] = string.find(letra) return dic
6e5bd8b77b0d6d688573705cb2862636153bbce9
ArthurCisotto/insper.dessoft
/Aula 03. Input/total_segundos.py
315
3.71875
4
dias = int(input('Qual é a quantidade de dias?')) horas = int(input('Qual é a quantidade de horas?')) minutos = int(input('Qual é a quantidade de minutos?')) segundos = int(input('Qual é a quantidade de segundos?')) total_segundos = segundos + 60 * minutos + 3600 * horas + 86400 * dias print(total_segundos)
79cc3350735b4fa849f7b9d48a10d7f02f24b057
ArthurCisotto/insper.dessoft
/Aula 05. Laço/calcula_soma.py
267
4.125
4
soma = 0 num = float(input('Digite o número que você deseja somar ou digite 0 para concluir a soma')) while num != 0: soma = soma + num num = float(input('Digite o número que você deseja somar ou digite 0 para concluir a soma')) print('A soma é:', soma)
04adfc8647395c6c9d451d1677a3e8dbe078f03b
ArthurCisotto/insper.dessoft
/Aula 05. Laço/decimal_para_binario.py
268
3.609375
4
def decimal_para_binario(decimal): binario = '' if decimal < 0: return 'Negativo' else: while decimal > 0: resto = decimal%2 decimal = decimal//2 binario = str(resto) + binario return binario
2c410cd419d738871549b365542ca838a5e8bb01
FrauBoes/PythonMITx
/longest str alphabet.py
462
3.96875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jun 7 15:23:38 2017 @author: thelma """ s = 'afhduakdhsjdhe' current_String = s[0] longest_String = s[0] for i in range (len(s)-1): if s[i] <= s[i+1]: current_String += s[i+1] if len(current_String) > len(longest_String): ...
e37406cab1e981fa6fac68b16cdd9dba407020dd
FrauBoes/PythonMITx
/midterm/midterm str without vowels.py
621
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jun 7 14:30:50 2017 @author: thelma """ def print_without_vowels(s): ''' s: the string to convert Finds a version of s without vowels and whose characters appear in the same order they appear in s. Prints this version of s. Does n...
9888442f8b0c95a2076f5da795ca2e9773a55bd5
FrauBoes/PythonMITx
/list largest int odd times.py
583
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jul 26 15:42:29 2017 @author: thelma """ def largest_odd_times(L): """ Assumes L is a non-empty list of ints Returns the largest element of L that occurs an odd number of times in L. If no such element exists, returns None """ ...
213c8884c28e68a3786eecb730f0d4672b031a32
FrauBoes/PythonMITx
/max value tuple.py
662
4.34375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jul 31 10:12:33 2017 @author: thelma """ def max_val(t): """ t, tuple or list Each element of t is either an int, a tuple, or a list No tuple or list is empty Returns the maximum int in t or (recursively) in an element of t...
a9f106c227b7f0b54492d96ccff6a2ffa0464f8b
AndrzejWojciechowski0/start_python
/write_my_name.py
279
3.5
4
import argparse parser = argparse.ArgumentParser(description='Powiedz: Witam serdecznie pana --name') parser.add_argument('--name', type=str, help='Pańskie imię proszę Pana!') args = parser.parse_args() with open("my_name.txt", "w") as my_file: my_file.write(args.name)
175237c04be50ae77ee033f0814b96c3a7a01427
brolam/tensorFlow
/pythonTutorial/operators.py
295
3.734375
4
5 // 2 # division whith result in number integers. 2 ** 4 # multiplication of powers 10 % 3 # division module print('navin \'s "laptop"') # slash special meaning 10 * 'navin' # print navin treen times print(r'c:\docs\navin') # Raw string x=4 # short express x +=2 x *=2 x a,b = 5,6 a b a = -a a
655825df88d9253eefa12b90e0c25e5a00e840d4
shovals/PythonExercises
/Triangle Area.py
149
3.71875
4
Hight = float(raw_input('Enter the triangle Hight:')) Base = float(raw_input('Enter the triangle base:')) print 'Triangle area is: ', Hight*0.5*Base
e8a102a0235064af87a103fd8c1bbcf39898f11d
shovals/PythonExercises
/Finding string length.py
193
4.125
4
Count = 0 StringInput = raw_input('Please enter the string: ') print 'Built in length show:', len(StringInput) for letter in StringInput: Count = Count + 1 print 'Measured length:', Count
72c6daa68b20bbc30f50096060c053a0714db81c
shovals/PythonExercises
/password check.py
1,736
4.0625
4
# At least 1 letter between [a-z] and 1 letter between [A-Z]. # At least 1 number between [0-9]. # At least 1 character from [$#@]. # Minimum length 6 characters. # Maximum length 16 characters. symbols = '~`;:!@#$%^&*()_-+|"?/<>*.' def a_to_z(password): small_letters, cap_letters = False, False for letter ...
6d64ee00e2a2e8466a6df9eca571b530a1ce8f37
shovals/PythonExercises
/Temp Converter.py
347
3.59375
4
import sys def Fer2Cel(value): return (value-32)/1.8 def Cel2Fer(value): return value*1.8+32 UserInput = input('Enter a temperature: ') Convert = raw_input('Convert to Cell (C) or Fer (F) ?') if Convert == 'F': print UserInput, 'C is ', Fer2Cel(UserInput), 'in Fer' else: print UserInput, 'F is ', Ce...
8bd6ed86b4ea0f992b531f5b229b7026525125c4
shovals/PythonExercises
/max of 3.py
307
4.34375
4
# max of 3 show the largest number from 3 numbers One = input('Enter first number: ') Two = input('Enter second number: ') Third = input('Enter third number: ') if One > Third and One > Two: print 'Max is ', One elif Two > One and Two > Third: print 'Max is ', Two else: print 'Max is', Third
5580edc64f1e56a761a553c361f1ef65819cf404
andr6369/github1
/cookie/hej.py
929
3.6875
4
from Tkinter import * import tkFont import picamera import P3picam import RPi.GPIO as GPIO GPIO.setmode (GPIO.BCM) GPIO.setup (16,GPIO.OUT) win = Tk() myFont = tkFont.Font(family = 'Helvetica', size = 36, weight = 'bold') motionState = False def ledON(): print("LED button pressed") GPIO.output(16,1) while True...
e328009f3ab20940c7ffb83334d145f6ba45e7c4
TeamAnonyme69/MinecraftInPython
/terrainGen.py
1,755
3.609375
4
class Model(object): def _initialize(self): """ Initialize the world by placing all the blocks. """ n = 80 # 1/2 width and height of world s = 1 # step size y = 0 # initial y height for x in xrange(-n, n + 1, s): for z in xrange(-n, n + 1, s):...
49f50933be228862e6c3b5f295a68ce9bcf80c6b
aclneves/curso_python_udemy
/PythonBasico/aula21/listas.py
445
4.03125
4
""" Listas em python fatiamento append, insert, pop, del, clear, extend, + min, max range """ lista = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'] print(lista[0]) print(lista[-5]) # Os dois comandos imprimem a mesma coisa, pois também existe o índice negativo print(lista) # Imprime toda a lista # Modificando um ...
f9b3a74de7b22e37942946390349324d90bba619
aclneves/curso_python_udemy
/PythonBasico/aula15/string.py
451
3.671875
4
""" Formatando valores com modificadores :s - Texto (strings) :d - Inteiros (int) :f - Números de ponto flutuante (float) :.(NÚMERO)f - Quantidade de casas decimais (float) :(CARACTERE)(> ou < ou ^)(QUANTIDADE)(TIPO - s, d ou f) > - Esquerda < - Direita ^ - Centro """ nome = "Antonio Neves" print(f'{nome:#^50}') nom...
1c0d9e95366271a9f9cdfa849f87dd5039664dcc
aclneves/curso_python_udemy
/PythonBasico/aula15/modificadores.py
701
4.03125
4
""" Formatando valores com modificadores :s - Texto (strings) :d - Inteiros (int) :f - Números de ponto flutuante (float) :.(NÚMERO)f - Quantidade de casas decimais (float) :(CARACTERE)(> ou < ou ^)(QUANTIDADE)(TIPO - s, d ou f) > - Esquerda < - Direita ^ - Centro """ num_1 = 10 num_2 = 3 divisao = num_1 / num_2 pri...
4f05c3064f9a83c50261f092ce1fc501bcad5c8c
aclneves/curso_python_udemy
/PythonBasico/aula04/exercicio.py
293
3.828125
4
""" Criar um cadastro imprimindo: Nome (Str) Idade (Inteiro) Altur (Float) Se é maior de idade (Bool) Mostrando o o tipo de dado de cada um: """ # Nome print('Antonio Neves', type('Antonio Neves')) # Idade print(33, type(33)) # Altura print(1.79, type(1.79)) # É maior? print(33 >= 18, type(33 >= 18))
025005cfdec4892732b59cfe918a55e204ae7496
aclneves/curso_python_udemy
/PythonBasico/aula23/split.py
647
4.0625
4
""" Split, Join, Enumertate em Python Split - Dividir uma string # str Join - Juntar uma lista # str Enumerate - Enumerar elementos da lista # list """ string = 'O Brasil é o país do futebol, o Brasil é penta!' lista = string.split(' ') # O que divide a String é definido dentro das aspas lista2 = string.split(',') p...
0c17308237e785b9f07f01ddcb711785ea668c17
ZZ1314/Learn_Code
/rvs.py
565
3.90625
4
# 反向排序 # def rvs(s): # if s == "": # return s # else: # return rvs(s[1:]) + s[0] # 斐波那契 # def fib(n): # if n == 1 or n == 2: # return 1 # else: # return fib(n - 1) + fib(n - 2) # 汉诺塔 count = 0 def hanoi(n, src="A", dst="C", mid="B"): global count if n == 1: ...
5299c63125e05e06ab394ef91005ab4060017d3a
govindzyx1/acopen
/bankFun.py
1,844
3.6875
4
import sqlite3 con=sqlite3.connect("e:\\pyprg\\mydb6.db") cur=con.cursor() con.execute('''create table if not exists bank(name text not null,acno integer primary key,bal integer)''') def showOption(): print("1 Deposit:") print("2 Withdraw:") print("3 Check bal:") print("4 Show Detail: ") ...
16baa18fe65c440959f7e10ebdfe530baba8e9b3
boddu110/bioinfo
/Functions_Algorithms/sliding_window.py
902
3.53125
4
#!/usr/bin/env python3 #sliding_window.py import sys def sliding_window(k,string): kmers=[] for start in range(0,len(string)-k+1): kmers.append(string[start:start+k]) return kmers def gc_content(dna): ''' Returns [0, 1], the fraction of GCs in the given string''' # For consistency, make...
a0a60598fac031d88ba20c42ca3449c466212867
Akhilvats/python
/Applications/StonePaperScissor/01-StonePaperScissor.py
1,481
3.9375
4
import random cpu = ["Stone","Paper","Scissor"] cpu_choice = random.choice(cpu) counter = 0 while True: user_choice = input("Enter your choice : ") if user_choice == cpu_choice: print("Match Tie") elif user_choice == "stone" and cpu_choice == "Scissor": print("CPU : ",cp...
250168fc34182bd32d973d3cf6c28883fe0d13ed
WHJR-G8/G8-C2_TA_1
/Sol_TA_1.py
137
3.78125
4
import turtle side = 200 for i in range(4): #write the number for which loop has to be repeated turtle.forward(side) turtle.left(90)
9caa874a0e33b5f5e222b7c9cf3401111d3d9df6
dhruvinmehta/advent-of-code
/AoC_2019/day_11.py
1,951
3.65625
4
# Problem Statement # https://adventofcode.com/2019/day/11 from AoC_2019.Common.Computer import Computer class Robot: DIRECTIONS = [(-1, 0), (0, 1), (1, 0), (0, -1)] def __init__(self, computer, start_panel=0): self.panels = {(0, 0): start_panel} self.dx = 0 self.position = (0, 0) ...
b07efadc3157d2b5925b95c3d33e6b8c26b17c53
dhruvinmehta/advent-of-code
/AoC_2019/day_10.py
5,618
3.609375
4
# Problem Statement # https://adventofcode.com/2019/day/10 import math def read_input_file(file): asteroid_map = [] with open(file) as file: line = file.readline() while line: asteroid_map.append(line.strip()) line = file.readline() return asteroid_map def g...
aef1fb8f5d9f879905c6dcb5fc87f5dd84d81dc3
j-chavez-sw/TSP-delivery-implmentation
/venv/ThreeOpt.py
6,425
3.6875
4
# Julian A. Chavez #I.D. #: 000966293 from Vertex import * import random from math import exp import copy # inspiration from a Udemy course by Holczer Balazs - https://www.udemy.com/course/advanced-algorithms-in-java/ # inspiration from Wikipedia article on 3-opt algorithms - https://en.wikipedia.org/wiki/3-opt cl...
debc44151157ca7e87839d8206466f9c1404e13f
ashgole/Python-Pyramids-solutions
/Coding-Battle-4/Q3.py
686
3.578125
4
""" Q. 3 Program: print: * * * * * * * * * * * * * * * * * * * * * * * * * and so on... input: integer """ def solution(n): # Defining function try: # Exception Handling size=5 for x in range...
7aeff5f14228d8850565e7a93c641885a2f87f01
ashgole/Python-Pyramids-solutions
/Coding-Battle-8/Q3.py
228
3.671875
4
def solution(n): word1=[] word2=[] for i,w in enumerate(n): if w.isupper(): word1=n[:i] word2=n[i:] break print(word1) print(word2) solution('helloAsh')
2242e842bcebe667ca5c0b28dc7de294e555971a
pri-bala/pri-bala.github.io
/mod.py
984
3.8125
4
import random import numpy as np def GenerateWellConceptName(): #First Letter strName = chr(random.randrange(65,91)) #Second letter?! if random.random() > 0.7: strName += chr(random.randrange(66,69)).lower() #Final numbers strName += "-" + str(random.ra...
14d7d784c9d4ed2fad980f46d00965082388a55c
goldspino/Week-1-Homework
/main.py
284
3.609375
4
natural_numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] strl1 = "abc" strl2 = "def" strl3 = strl1+strl2 int1 = 1 int2 = 2 int3 = 3 int4 = int1+int2 int5 = int4+int3 bool1 = True bool2 = True bool3 = False bool4 = True bool5 = False cars = ("Ferrari, " "Lamborgini, " "Jaguar") print(cars)
0dbb92ab5d54374949e39147f0ffa6c034a4826f
sjeff002/Code_Samples
/Python_Algorithm/makechange_original.py
2,513
3.921875
4
######################################################################################################### ##Name: Shannon Jeffers ##Assignment: Homework 3 number 5 ## https://www.youtube.com/watch?v=NJuKJ8sasGk This video helped me greatly ################################################################################...
c87a7b2d052851c5c2c978636d29d22877353cf8
physics91si/fangzp-lab5
/trig.py
783
4
4
#!/usr/bin/python # The following statements are used to import numpy and matplotlib. import numpy as np import matplotlib.pyplot as plt # TODO fill in this function def integrate(y, dx): integral=(np.sum(y))*dx return integral # TODO write code here to setup arrays x and y = sin(x) and then plot them. # Aft...
d5336239b5db506f80269d85f8b0b4bb6ca9f4ab
dcragusa/LeetCode
/1-99/70-79/75.py
2,062
4.34375
4
""" Given an array with n objects colored red, white or blue (represented by integers 0, 1, and 2), sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white and blue. Note: You are not suppose to use the library's sort function for this problem. Example: Input: [2, 0, ...
bd42aae37e10dd6af40b2f9deaef942a5bfa4218
dcragusa/LeetCode
/100-199/110-119/112.py
1,419
4.1875
4
""" Given the root of a binary tree and an integer `target_sum`, return `True` if the tree has a root-to-leaf path such that adding up all the values along the path equals `target_sum`. A leaf is a node with no children. Example 1: Input: root = [5, 4, 8, 11, None, 13, 4, 7, 2, None, None, None, 1], target_sum = 22, ...
6b1914ee8aab2ad9a6d4dacc0ade2581acaf5894
dcragusa/LeetCode
/1-99/90-99/98.py
1,908
4.3125
4
""" Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a node contains only nodes with keys greater than the node's key. Both the left and right subtrees mu...
ab4cde1297d67e70cf920c2288309e179085cdf8
dcragusa/LeetCode
/1-99/20-29/24.py
1,823
4.34375
4
""" Given a linked list, swap every two adjacent nodes and return its head. You may not modify the values in the list's nodes, only nodes itself may be changed. Example: Given 1->2->3->4, you should return the list as 2->1->4->3. """ """ Firstly we swap the first two elements. We then iterate across the list, copying...
efd2f12aa8c7ab9bc45d150e747852c70010529f
dcragusa/LeetCode
/1-99/70-79/70.py
2,026
4.28125
4
""" You are climbing a staircase with n steps. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Note: Given n will be a positive integer. Example 1: Input: 2, Output: 2 Explanation: There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 steps Example 2: Input:...
1e941dff165827fd643b735fb82593730409c85b
dcragusa/LeetCode
/100-199/110-119/113.py
1,532
4.125
4
""" Given the root of a binary tree and an integer `target_sum`, return `True` if the tree has a root-to-leaf path such that adding up all the values along the path equals `target_sum`. A leaf is a node with no children. Example 1: Input: root = [5, 4, 8, 11, None, 13, 4, 7, 2, None, None, 5, 1], target_sum = 22 Outpu...