blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2593cb01da3ffa075e249882ffe4c3032e65461d
TaviusC/cti110
/p4t1a_Cousar.py
690
4.21875
4
# This program wil use turtle graphics to draw both a square and a triangle. # 3/18/2019 # CTI-110 P4T1a - Shapes # Tavius Cousar # Import turtle import turtle # Set up window and turtle (tut) wn = turtle.Screen() wn.title('Square and Triangle Drawing') tut = turtle.Turtle() # Set up turtle movement for...
3a11f0df22eb5c8f2ca9252e8795ee1d1ffdba62
mclavan/Work-Maya-Folder
/2014-x64/prefs/1402/joint_renamer.py
919
3.640625
4
''' Lesson - Joint Renamer joint_renamer.py Description: Practical use of loops. Renaming joint based upon a naming convention. How to Run: import joint_renamer reload(joint_renamer) ''' print 'Joint Renamer - Active' import pymel.core as pm ''' Get Selected. pm.ls(selection=True) ''' joint_chain = pm.ls(s...
6d69d8c1d5e7fc1b066871a970440b4a9376ccd9
kirschovapetra/B-PROG1
/02 26.9/02 for,while/2 1^3+2^3+...+n^3.py
119
3.515625
4
print('zadaj n') n = int(input()) vysledok = 0 for i in range(1,n+1): vysledok = vysledok + (i)**3 print(vysledok)
70176699d87d479a5933ffc5e6976e16405e8ecd
gerardward3/bbc-technical-test
/gameOfLife.py
3,698
3.921875
4
# BBC Technical Test - Software Engineering Graduate Trainee Scheme # Author - Gerard Ward # Date - 03/02/2019 # Game of Life # # - Requires Python 3 and Pygame # - Game is played on 25 x 25 grid, can be changed by editing GRID_HEIGHT and GRID_WIDTH variables # - Live cells are white, dead cells are black # - Seeded gr...
1e0fb310e7e3446ec241f235dc896b2925481c7c
jewelism/practice-python
/4_1/ch4_ex1.py
102
3.875
4
# -*- coding: utf-8 -*- # sum = 0; for i in range(1,100): if(i%3==0): sum += i; print(sum)
2cf8ba1eeafb8680e5bd4f4bb82831edecf09464
EstebanAlarconO/Actividad-4---Hash
/functions.py
3,558
3.515625
4
import sys import random import math from datetime import datetime #se cambia la semilla a utilizar por hora random.seed(datetime.now().hour) def entropia(texto): base = 128 #correspondiente a la cantidad de caracteres ASCII entropia = len(texto)*math.log(base, 2) #H = L*Log2(W) return entropia #Funcion ...
6f2ccb192058d71bfbadda459bab078c3049a5b6
paul-schwendenman/advent-of-code
/2020/day15/day15.py
1,122
3.625
4
from __future__ import annotations from typing import List from aoc import readfile from collections import defaultdict, Counter def part1(data: str, turns: int = 2020) -> int: start = [int(num) for num in data.split(',')] counter = defaultdict(list) # sequence = [] turn = 0 for item in start: ...
aa769aba94a8ae513c0bdf506402fddd73519a2e
lucadibello/RimeSegateBot
/classes/config.py
1,977
4.125
4
import json class Config: """ This class is used for manage the config file """ def __init__(self, filepath: str): """ Constructor method. It saves into an attribute the config file path. :param filepath: Config file path """ self.filepath = filepath ...
3de7fad3666c0cc503330cae84a986c0ce7b5afa
rebecahassan/python-challenge
/PyPoll/main.py
1,482
3.59375
4
import os import csv file = 'election_data.csv' with open(file, newline="") as election_data: electionreader = csv.reader(election_data, delimiter=",") # Read the header row first csv_header = next(election_data) total_votes = 0 candidates=[] votes=[] index = 0 for row in electionreader:...
bf359f264311bd83105764a70207a67360835493
valerie-bernstein/Moon-and-Magnetotail
/x_rotation_matrix.py
300
3.703125
4
import numpy as np def x_rotation_matrix(theta): #rotation by the angle theta (in radians) about the x-axis #returns matrix of shape (3,3) rotation_matrix = np.array([[1, 0, 0], [0, np.cos(theta), np.sin(theta)], [0, -np.sin(theta), np.cos(theta)]]) return rotation_matrix
d63314e061f9ba4f566245ce58e3014a766de361
Khaleec/newpackage
/newpackage/sorting.py
1,407
4.1875
4
def bubble_sort(items): '''Return array of items, sorted in ascending order''' new_items = items.copy() for i in range(len(new_items)): for j in range(len(new_items)-1-i): if new_items[j] > new_items[j+1]: new_items[j], new_items[j+1] = new_items[j+1], new_items[j] ...
6a7d3913d918d32c60ea486a05f0168b74d330e0
segfaultx/prog3
/Python/Blatt7/a23.py
387
4.25
4
#!/usr/bin/env python3 lst = list(range(0, 101)) # create list with range 0-100 print(lst[:11]) # print first 10 elements of list print(lst[-11:]) # print last 11 elements of list print(lst[0::10]) # print every 10th element of list print(lst[len(lst) // 2]) # print middle element of list print(lst[5:-5:3]) # pr...
f956a6791151f7647012841eecc204dfd20739d9
dale-wahl/materials_pipeline
/collect_labs.py
1,974
3.65625
4
import sys import lab_to_db_updater import csv_creater """ This program creates a master csv to combine lab results with procurement and material processing data. From the SQL database, it relies on the material_procurement, ball_milling, and hot_press tables. It handles ICP and Hall lab results files, recording meas...
3e7149f32f2c2f969e44a01d3e204fdd96581803
kalietong/03
/00_parentheses.py
649
3.953125
4
ex = input("type something ") def task1(s): ret = "" i = True for char in s: if i: ret += char.upper() else: ret += char.lower() if char !=' ': i = not i return ret print(task1(ex)) def task2(s): word = task1(ex) vowels = ('A','E', '...
a563cd716d0f29d6b4f84ff3001bdc259b5e5172
megwinslo/final
/main.py
8,626
4.125
4
"""" Name: Megan Winslow CS230: SN2F Data: Skyscrapers around the World URL : Description: This program creates a webpage separated into different pages to showcase each function. Included in these pages is: a bar chart that shows how many skyscrapers were created per year, a pie chart showing percentage of materials ...
ec0a5fdd4aa0a9391ba98ef7631fd18b45b04c7b
ADEnnaco/ProjectEuler
/problems/Problem006.py
1,293
4.0625
4
# -*- coding: utf-8 -*- # Problem6.py> """ The sum of the squares of the first ten natural numbers is: 1^2+2^2+...+10^2=385 The square of the sum of the first ten natural numbers is,: (1+2+...+10)^2=55^2=3025 Hence the difference between the sum of the squares of the first ten natural numbers and the square of ...
676b7147351998248ca22d30a96f86b346290dc8
Uche-Clare/python-challenge-solutions
/Uche Clare/Phase 1/Python Basic 1/Day 14/Task 4.py
106
3.515625
4
x = 78 y = 78 z= 54 if x==y==z: print('They\'re the same value') else: print('They\'re different')
5bda6598d3c2219b986af5c2a2dc8ae202d09a3c
clemencegoh/Python_Algorithms
/algorithms/HackerRank/level 1/random/Find_Particle_Collision.py
1,078
4.09375
4
# # Given an array of integers representing speeds of imaginary particles, # find the particles which will 'collide' with position n as given. # Collision will not affect the current speed or direction of the moving particle. # # Examples are given below # def collision(speed, pos): # Here we assume there are no...
bf7bcff89220864e64991e8cd8b041ee0ccfed8a
mcmalach/real-python-test
/sql/sqla.py
415
3.890625
4
#!/usr/bin/env python #Create a SQLite3 databse and table #import the sqlite3 library import sqlite3 #create new database if the databse dosen't exist already conn = sqlite3.connect("cars.db") #get a cursor object used to execute SQL commands cursor = conn.cursor() #create a table cursor.execute("""CREATE TABLE in...
4d812860075d5a8e324d3cd2d8c088b5e94583df
jpiland16/sequence-prediction-analysis
/networks.py
11,356
3.53125
4
print("\nLoading PyTorch...\n") import torch from torch import nn, Tensor from tqdm import tqdm from sequence_utils import one_hot_encode def get_train_set(train_data: list, seq_len: int, num_bands: int) -> 'tuple[Tensor]': """ Generate a pair of training sequence Tensors (X[], y[]) where y is one ...
ba6f48e1cad7d4ad3363ddd3854b7b9e2bcafb42
mtahaakhan/Intro-in-python
/Python Practice/boolean.py
598
4.3125
4
# A student makes honour roll if their average is >= 85 # and their lowest grade should be greater than or equals to 70 gpa = float(input('What was your Grade Point Average: ')) lowest_grade = float(input('What was your lowest grade: ')) # You can also use boolean values if gpa >= 85 and lowest_grade >= 70: # If this ...
e0b406c7ab6f81b53a1319de01adc7f39f5ef8b1
praneesh12/python_review
/edx/Loops and strings/Loops.py
3,000
3.609375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue May 15 21:51:13 2018 @author: praneeshkhanna """ # ============================================================================= # while loo # ============================================================================= x = 3 ans = 0 itersLeft = x whil...
8809bd75c714ce946a0a666a06b7c8a7bb909cb7
shubham3rajput/Practice
/C@SKR/Codevita2/9.py
645
3.546875
4
# a=6 # b=3 # if a>b: # l=a # w=b # else: # l=b # w=a # count=0 # q=l//w # r=l%w # count+=q # if r>w: # q2=r//w # r2=r%w # count+=q2 # if r2==1: # q3=w # count+=q3 # else: # q2=w//r # r2=w%r # count+=q2 # if r2==1: # q3=r # count+=q3...
9c3c667cfd8b74e46192d7563ee077b7804f104c
JulietteLACOUR/2TP12
/Exercice 3.py
170
3.8125
4
def pow(x, n, i=0): if i == n: return 1 return pow(x, n, i+1)*x print(pow(42, 0)) # 1 print(pow(1, 10)) # 1 print(pow(2, 5)) # 32 print(pow(7, 2)) # 49
b7cbb5552167df4bf543636fa0554ae7b1b75252
curtesyflush1/Testing
/almost_there.py
364
3.71875
4
# ALMOST THERE: Given an integer n, return True if n is # within 10 of either 100 or 200 def almost_there(x): #num1 = range(90,110) if x in range(90,110,1): return True elif x in range(190,210,1): return True else: return False # Or the following: def almost_there(x): ret...
05c61cc389f1c6ba8cbd4a6097b8cb25eac286d2
sajid2612/data-structure
/number-system/binary-decimal.py
514
4.0625
4
print "Enter a Binary Number:" binary_num = input() rem = len(str(binary_num)) % 3 binaryStr = str(binary_num) if rem == 2: binaryStr = "0" + binaryStr if rem == 1: binaryStr = "00" + binaryStr index = 0 octalCandidates = [] octalIndex = 0 decimalNumber = 0 strLength = len(binaryStr) j = 1 for i in binaryStr...
9316ed311bfd8977e97628b933323f69b26d8c53
RobertVallance/block_breaker_game
/block_breaker.py
27,294
3.875
4
# BLOCK BREAKER WITH CLASS ''' A very simple version of the block breaker game, with 2 blocks that the user must destroy by bouncing the ball on them using a controlled bar at the bottom''' import pygame, sys from pygame.locals import * import random as rm # This is the level number that our class wi...
1f0008bf8e38c041b0e971c8516aa74c712b8a3e
d4nmerron/python_learn
/practice/ex1.py
404
4.03125
4
#http://www.practicepython.org/exercise/2014/01/29/01-character-input.html print "what is your name" name = raw_input() print "what is your age" age = raw_input() print "give me a number between 1 & 100" number = raw_input() print "%s" % (number) * 100 print "You will be 100 in year: " 2016 + 100 - ...
3a65103eaea0e209e501d6a8f9a372bcb99ec461
Pnickolas1/Code-Reps
/AlgoExpert/Linked List/sum_of_linked_lists.py
987
3.640625
4
""" sum of linked lists: """ # This is an input class. Do not edit. class LinkedList: def __init__(self, value): self.value = value self.next = None def sumOfLinkedLists(linkedListOne, linkedListTwo): # create a new node newLinkedList = LinkedList(0) currentNode = newLinkedList ...
12556c0445d83d0b3016ca4d2bc8d8de6db673b4
jcp0578/practise-Python
/leecode/二叉树的最大深度/maxDepth.PY
2,483
3.625
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- ''' AC but not a good solution ''' import time # Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None def stringToTreeNode(input): input = input.strip() input ...
265a648ff37bbedb12b04330a8e0750a5f0afc73
rockchalkwushock/pdx-code-labs
/adventure_game.py
2,672
4.0625
4
import random width = 10 # the width of the board height = 10 # the height of the board # create a board with the given width and height # we'll use a list of list to represent the board board = [] # start with an empty list for y in range(height): # loop over the rows board.append([]) # append an empty row ...
97d024ae38e6403dd5db63ab2ce574b43ab8dc75
jenjohmar/superpy5
/sell.py
4,242
3.703125
4
import argparse from helpers import * def sell(prod_name: str, sell_price: float, sell_date: str, amount: int): #checks if format of date is correct, if not error message checkSellDate = checkDate(sell_date) # if format date is correct executes code if checkSellDate == True: # sell_dat...
659a8250c1a6697dad43d2c9c91add0532aa020c
gu3vara/gu3vara.Python
/1_Chinese vs Python/8_你在哪个level?.py
898
4.125
4
import 游戏设定 ###############上面是定义############################## ###############下面是主要功能############################## def 创建角色(): 游戏角色名 = input("请输入你的角色名:") print("创建角色成功,你好," + 游戏角色名 + ",欢迎来到游戏联盟!") return 游戏角色名 你现在的角色=创建角色() print(你现在的角色+"进入了新手村!") 捡到经验书 = input("请输入下一个指令---") if 捡到经验书 == "捡到经验书": 游戏...
8e2f06ef303eec8aec1402b55476c5b4373ab5dc
xiaotuzixuedaima/PythonProgramDucat
/PythonPrograms/python_program/binary_to_hexadecimal.py
284
3.9375
4
# 54. Python Binary to Hexadecimal ???? binary = input("Enter any number in Binary Format: "); if binary != 'x': temp = int(binary, 2) print(binary,"in hexadecimal =",hex(temp)) ''' output == Enter any number in Binary Format: 101011010 101011010 in hexadecimal = 0x15a '''
9bba8462211bc1dc06fae841d37c461ad1ab3c3c
armcburney/practice
/python/data_structures/trees/pre_order.py
503
4.15625
4
#!/bin/python3 """ Node is defined as: self.left (the left child of the node) self.right (the right child of the node) self.data (the value of the node) """ def preOrder(root): """ Pre-order traversal. Example: Input: 3 / \ 5 2 / \ / 1 4 6 ...
22287c402be26db25877b00556caadb32182bf22
DZ521111/Dz-Algo-Expert
/Find Closest Value In BST/fullCode.py
721
3.640625
4
''' Author : Dhruv B Kakadiya ''' class BSTree: def __init__(self, value): self.value = value self.left = None self.right = None def addVlaue(root, value): if root is None: return BSTree(value) else: if (root.value < value): root.right = BSTree(root.righ...
1ba0e39a5b02104f8b805d9fc45d1d518df1db7f
jyryuitpro/pythonProject
/01. 자료구조 이론/28.트리(Tree)-7.py
5,622
3.875
4
class Node: def __init__(self, value): self.value = value self.left = None self.right = None class NodeMgmt: def __init__(self, head): self.head = head def insert(self, value): self.current_node = self.head while True: if value < self.current_nod...
a601ff4902bee57c728f12896a89a76c67eda826
RayHubb/Sweepstake
/sweepstake.py
782
3.5625
4
import random class Sweepstake: def __init__(self, name): self.contestant_list = {} self.name = name self.winner = name def register_contestant(self, contestant): key = len(self.contestant_list) + 1 self.contestant_list[key] = contestant def pick_winner(self): ...
ddfc3b78477d0d622d99d3211d96cf7dc0ac0079
sbuckley02/python_programs
/tictactoe.py
2,452
4.1875
4
''' This is a 2-player Tic-Tac-Toe game. Players input the number of the box they want to place an X or O in. ''' board = [] turns = 0 gameOver = False def clear_output(): #clear the terminal window for num in range(0,50): print('') def startUp(): #executes before a game is played clear_output() q1 = input('Wel...
e8538c147d69b6777217ea93dd96fbff0aa3b354
go4Mor4/My_CodeWars_Solutions
/5_kyu_Simple_Pig_Latin.py
551
4.40625
4
''' Instructions Move the first letter of each word to the end of it, then add "ay" to the end of the word. Leave punctuation marks untouched. Examples pig_it('Pig latin is cool') # igPay atinlay siay oolcay pig_it('Hello world !') # elloHay orldway ! ''' #CODE def pig_it(text): words, new_phrase = text.spli...
fa0e7e4c8c7597147626916e88444fe5ec230d15
tjhamad/CheckiO
/Sum in a Triangle.py
4,535
3.96875
4
# -*- coding: utf-8 -*- ''' The musical notes shine as a melody begins to drift through the air. Harmonies intertwine and come to a crescendo. With the final note resonating through the air, a circular hole opens up in the center of the chamber floor. Sofia, Nikola and Stephen peer over the edge and see the top of ...
04e0f2c2ee3de78a9fccfa025e90ddec11d87213
Muttakee31/solved-interview-problems
/leetcode/374.guess-the-number.py
494
3.546875
4
class Solution(object): def guessNumber(self, n): """ https://leetcode.com/problems/guess-number-higher-or-lower/ another binary search """ low = 1 high = n while(low <= high): mid = (low+high)//2 f = guess(mid) if ...
e1c9fcfb20d117d97410f0c85c880f2f4e4eb982
Th3Lourde/l33tcode
/169_majority_element.py
2,277
4.1875
4
''' Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the majority element always exist in the array. Ok so we are given that the majority element always exists in the array It is also true tha...
4db062896087090d4b4fa6ede9cce3825c2647d4
JacobAMason/Project-Euler
/10.py
1,087
3.875
4
#!python3 """ The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. """ import logging, time logging.basicConfig(level=logging.INFO, format="[%(levelname)s] %(message)s") def sieve(n): l = list(range(n+1)) for i in range(2, n+1): ...
8b3a8af746aa9cda4768312465d254b892fc8b49
locnt1195/hackerrank
/Algorithms/multi_big_int.py
1,418
3.578125
4
# Libraries Included: # Numpy, Scipy, Scikit, Pandas def plus_big_int(a, b): a = a[::-1] b = b[::-1] len_a = len(a) len_b = len(b) greater = len_a > len_b and a or b smaller = len_a > len_b and b or a res = [] num = 0 for i in range(0, len(smaller)): s = int(a[i]) + int(b[i...
6e20280979840f853a04b8b6ccab06b518ba70bd
KleinTong/Daily-Coding-Problem-Solution
/shuffle_cards/main.py
383
3.640625
4
from random import randint def rand_num(k): return randint(0, k) def shuffle(arr): def exch(i, j): item = arr[i] arr[i] = arr[j] arr[j] = item for i in range(len(arr) - 1, -1, -1): index = rand_num(i) exch(index, i) if __name__ == '__main__': arr = [i for ...
8800b958cdd526b3018dc3336b285245bc25ee0b
yangxiyucs/leetcode_cn
/leetcode/69. square of X.py
855
4.125
4
# 实现 int sqrt(int x) 函数。 # # 计算并返回 x 的平方根,其中 x 是非负整数。 # # 由于返回类型是整数,结果只保留整数的部分,小数部分将被舍去。 # # 示例 1: # # 输入: 4 # 输出: 2 # 示例 2: # # 输入: 8 # 输出: 2 # 说明: 8 的平方根是 2.82842..., #   由于返回类型是整数,小数部分将被舍去。 # # 来源:力扣(LeetCode) # 链接:https://leetcode-cn.com/problems/sqrtx # 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 from math import e,log ...
7701e23553ef46831b41be67ae5d1693e31e0003
bozhikovstanislav/Python-Fundamentals
/Class-HomeWork/06.Animal.py
3,156
3.65625
4
class Animal: def __init__(self, name, age, number_l="", iq="", cruelty=""): self.__name = self.set_name(name) self.__age = self.set_age(age) self.__number_l = self.set_number_of_legs(number_l) self.__iq = self.set_IQ(iq) self.cruelty = self.set_cruelty(cruelty) def set_...
e026dd21ed7e1dccc33d65468ceb0ae1ac6403f1
MiloszBoghe/School-Y1-
/IT Essentials/IT-essentials Oefeningen/H6_Strings/Voorbeelden/Oef 6.10.py
260
3.9375
4
# tekst omzetten naar hoofdletters zonder gebruik te maken van de methode upper tekst = input("Geef een tekst in: ") nieuw = "" for letter in tekst: if letter.islower(): nieuw += chr(ord(letter) - 32) else: nieuw += letter print(nieuw)
bcfad320c943ae3ecb200ce65aa45947771cf30a
zinderud/ysa
/python/first/functions01.py
1,050
4.09375
4
def greet_user(isim): print("merhaba "+str(isim)+"!") greet_user("ali") def greet_user_fullname(firstname,lastname): print("Hello "+firstname+" "+lastname) greet_user_fullname("cemal ","süreyya") def user_dob(day, month, year): return str(day)+':'+str(month)+":"+str(year) birthday = user_dob(day=12, yea...
b743be233bee1c6ca2ab8e92c9d993d57dee2546
rgrohit80/trypython
/binarySearch.py
412
3.875
4
arr = [2, 3, 4, 10, 40] def binarySearch(arr, num, li, ri): if ri >= li: mid = li + (ri - li) // 2 if num == arr[mid]: print(mid) elif num > arr[mid]: return binarySearch(arr, num, mid + 1, ri) elif num < arr[mid]: return binarySearch(arr, num, l...
4299de5cb96e82315260b11567b610395ea0c37a
CruzerNexus/Repo
/pythonFullStack/creditCardValidation.py
1,001
3.96875
4
# creditCardValidation.py def creditCardValidation(num): # turns string into list of ints num = list(num) print(num) for i, digit in enumerate(num): num[i] = int(num[i]) # print(i) # print(num[i]) # check digit checkNum = num.pop(-1) print(checkNum) print(num) ...
8a28a6357133442872bb357a812213af9446c210
Nurgazy24/task19_Palindrome
/task19Palindrome.py
91
3.6875
4
string = "tenet" if(string == string[:: - 1]): print("True") else: print("False")
9c1dae13e310463e81915648c8614a71517309ae
luvlee-liu/Flask_Tutorial
/code/create_table.py
565
3.859375
4
import sqlite3 connection = sqlite3.connect('data.db') cursor = connection.cursor() # entries = [ # (1, 'bob', 'asdf'), # # (2, 'jose', 'asdf'), # # (3, 'ana', 'asdf') # ] create_table = "CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, username text, password text)" cursor.execute(create_table) ...
c31df7016ac65c4797c8a6e4048969c39265bc68
raulhernandez1991/Codewars-HackerRank-LeetCode-CoderBite-freeCodeCamp
/Codewars/Python/6 kyu/Clocky Mc Clock-Face.py
101
3.65625
4
def what_time_is_it(angle): return str(round(angle/30))+":"+angle%30 print(what_time_is_it(360))
6afeb743b2ccbb6c7319b498ff8869cad14f177f
keshav955/Python-Machine-Learning
/Assignment Monday/use this for assignment.py
199
3.6875
4
# -*- coding: utf-8 -*- """ Created on Mon Aug 31 14:57:45 2020 @author: keshav """ n=int(input("enter a number")) sum=0 while(n>0): t=n%10 sum=sum+t n=n//10 print(sum)
cba7564ae14e13650be3d25eea5f495dc2f9e6fe
erickccuern/Programas-Simples
/minutos em horas.py
349
3.765625
4
print("""--------------CONVERSOR DE MINUTOS EM HORAS------------------ """) minutos = int(input("Digite quantos minutos se passaram: ",)) horas = minutos//60 print(""".......... .......... .......... CALCULANDO .......... .......... ..........""") print("RESULTADO:",minutos,"Minutos, equivalem a:",horas,"Hor...
ac57a0cdd3111024339c369abfc7640eccdfe6b4
PageCHogan/portals-and-portals
/Tile.py
881
3.546875
4
class Portal: # very simple class to define a portal as an object files = [ "images/portals/portalBurgundy.png", "images/portals/portalCyan.png", "images/portals/portalGreen.png", "images/portals/portalRed.png", "images/portals/portalYellow.png", ] def __init__(se...
656303e6b8b6e613f2a43ba62394ad915c65b462
xing3987/python3
/base/基础/_10_card_admin_main.py
1,044
3.53125
4
#! /usr/bin/python3 # 使用“#! python3路径在linux中再赋予可执行-x权限,则该文件可以在Linux中直接执行” from 基础 import _10_card_admin_tool from helper import _helper # 设计一个名片管理系统 while (True): _helper.print_line("*") print("欢迎使用【名片管理系统】v1.0") print() print("1.新建名片") print("2.显示全部") print("3.查询名片") print() print("0....
4e209afb97c76617fd9bc1f03977829e7eea3e2c
US579/US579
/unicorntest/q1.py
1,698
3.5625
4
class Sudoku: def solveSudoko(self, matrix): self.matirx = matrix self.solve() def solve(self): row, col = self.findUnassigned() if row == -1 and col == -1: return True for num in [str(i) for i in range(1, 10)]: if self.canFill(row, col, num): ...
19f8cb1431b432f0c0e951449ad27eea1d3e1b04
fwk1010/python-learn
/io-example.py
1,710
3.875
4
#!/usr/bin/env python3 ''' This file is to learn about io more detail. ''' import os from io import StringIO from io import BytesIO class TestCase(): def in_input(self): s = input('input a word\n') print('You key in', s) def in_file(self, file_name, file_path): with open(file_path + fi...
9011c19a3b5be1c7fb176d52fecefa19efc01084
lcbc-epfl/data_management
/script/create_metadata.py
8,268
3.53125
4
#!/usr/bin/env python3 """Generate a README file for metadata based on some input information.""" import os import datetime # ADD POSSIBLE README FILE TYPES HERE allowed_types = ['main', 'calculation'] # ADD POSSIBLE SUBJECTS HERE allowed_subjects = ['perovskites', 'biochemistry', 'photochemistry', 'methods'] class...
32e8ee35a37799075dd4ca1bafbcabacbb28923c
Ana-Vi/Homework
/Pythons/l1q9.py
301
3.765625
4
x= str(input("nome: ")) quantidade= int(input("qtd: ")) pu= float(input("preo unitrio: ")) total= quantidade* pu if quantidade<= 5: total= total*0.02 elif quantidade>5 and quantidade<=10: total= total*0.03 else: total= total*0.05 print("O preo do produto", x ," %.2f"%total)
ee0bf44d1b6dbf7e965ff42f12353dc809d23aa6
hardik96bansal/Algorithm-DS-Practice
/Algo/Greedy/egyptianFraction.py
283
3.859375
4
def egypt(num,den): ciel = 0 if(num==1): print('1/',den) elif(num<den): if(den%num == 0): print('1/',den//num) else: ciel = den//num +1 print('1/',ciel) egypt((num*ciel-den),(ciel*den)) egypt(12,13)
f7efa90efc3de2e5711d15ffb6d069039a546a2e
grawinkel/ProjectEuler
/025/p25.py
194
3.53125
4
# Problem 25 # What is the first term in the Fibonacci sequence to contain 1000 digits? n=1 n1=1 n2=1 x = 2 while 1: n=n1+n2 n2=n1 n1=n x+=1 if (len(str(n))>=1000): print x break;
19c23519ce2aa5fb7867f47c92380c999c3d4d20
marcusshepp/dotpy
/training/finished/iterables-gens-yield.py
1,060
4.46875
4
# -- Iterables -- # mylist is the iterable (reading the list one by one) mylist = [x*x for x in range(3)] for i in mylist: print "This is an iteration list ", i for i in mylist: print "This is the second iteration list ", i # -- Generators -- # notice () rather then [] - *only in interators* # generators don'...
f28923e93b0d08ebd1b444db117a30c6175fc94b
WangYoudian/Algorithms
/LeetCode/Day10/BinarySearchTree.py
3,857
3.890625
4
from queue import Queue # 使用链表结构实现二叉查找树 # 定义节点类型 class Node: def __init__(self, key): self.left = self.right = None # self.ltag = self.rtag = 0 self.key = key # 定义二叉树结构 # 包含的操作有:插入、删除、查找 # 次级的有查找前驱、后继节点 # 若指明要用线索二叉树,例如中序的线索二叉树结构,这样Node类中就得加入ltag和rtag,并对BST进行线索化 # 再有遍历(DFS、BFS) class BST: def...
a71c7153e26c8ab47b305c78d8222219a2d127a5
cleancodenz/pythonbasics
/collections/test35.py
494
4.0625
4
# in operator #it can be applied in list, dictionary, Tuples, and strings my_list = [1, 3, 4, 5, 6] my_dict = {"S": "Small", "M": "Medium", "L": "Large", "XL": "X-Large"} my_tuple = (10, 13, 15, 17, 11) name = "Elvis Presley" list_included = 1 in my_list dict_included = "S" in my_dict tup_included = 11 in my_tuple st...
457504799a30436c711bfca11aab213fdae61553
aijian139/FirstPythonDemo
/Demo03.py
881
3.71875
4
# 循环 # for in 循环 names = ['tom','rose','jack'] for name in names: print(name) # 计算1-10 的整数之和 sum = 0 for x in [1,2,3,4,5,6,7,8,9,10]: sum+=x # 注意代码的缩进的不同效果也不一样 print(sum) print(sum) # rang()函数 生成一个整数序列 # list()函数 可以转换为list a = list(range(5)) print(a) # 生成0-100的整数序列 然后相加 sum = 0 for x in range(100): sum += ...
d2338466fc928a2a2a3a86e7677e7921f21be606
popkovatatyana/try
/words collocations.py
1,451
3.625
4
import random import csv with open('file.csv', 'r', encoding = 'utf-8') as f: reader = csv.reader(f) d={} m=[] for key in reader: d[key[0]]= key[1:] print (d) for slovo in d: m.append(slovo) slovonovo=random.choice(m) for slovo in d: if slovonovo == slovo:...
0720e18e9cf8a0f699d6a85543ebfcbd5a2367d2
WitheredGryphon/witheredgryphon.github.io
/python/Python Challenge/equality.py
448
3.84375
4
#!/usr/bin/python puzzle_string = """kAewtloYgcFQaJNhHVGxXDiQmzjfcpYbzxlWrVcqsmUbCunkfxZWDZjUZMiGqhRRiUvGmYmvnJIHEmbT MUKLECKdCthezSYBpIElRnZugFAxDRtQPpyeCBgBfaRVvvguRXLvkAdLOeCKxsDUvBBCwdpMMWmuELeG ENihrpCLhujoBqPRDPvfzcwadMMMbkmkzCCzoTPfbRlzBqMblmxTxNniNoCufprWXxgHZpldkoLCrHJq vYuyJFCZtqXLhWiYzOXeglkzhVJ...
ae4c530f8bcb7aed692bcac2762282a429019fac
RahulBendre1/Competitive-Programming
/numberfun.py
329
3.6875
4
for case in range(int(input().strip())): a,b,c = list(map(int,input().strip().split())) if a+b == c: print("Possible") elif abs(a-b) == c: print("Possible") elif a*b == c: print("Possible") elif (a/b == c) or (b/a == c): print("Possible") else: print("Impo...
3ff164ac75c732bb8d4df86a8557e379475194ed
kruart/python_headfirst
/ch06_storing_and_manipulating_data/playWithInput.py
921
4.0625
4
todos = open('todos.txt', 'a') print('Put out the trash.', file=todos) print('Feed the cat.', file=todos) print('Prepare tax return.', file=todos) todos.close() # read from file in loop tasks = open('todos.txt') # read - default mode for ch in tasks: print(ch, end='') tasks.close() # write() try: somef...
297e26ddb558cf857094a39c7b43319ab2f8a759
CodeHemP/CAREER-TRACK-Data-Scientist-with-Python
/27_Unsupervised Learning in Python/02_visualization-with-hierarchical-clustering-and-t-sne/02_hierarchies-of-stocks.py
1,588
3.9375
4
''' 02 - Hierarchies of stocks In chapter 1, you used k-means clustering to cluster companies according to their stock price movements. Now, you'll perform hierarchical clustering of the companies. You are given a NumPy array of price movements movements, where the rows correspond to companies, and a lis...
2d20dd87f3e1ca3bcd60c1ad3b423dff094dcb93
dmlee1/NumberGuessingGameV2
/main.py
4,068
4.25
4
# Name: David Lee # Purpose: The purpose of this program is to create a number guessing game that allows the user to continue # to guess until they correctly guess the actual value of a randomly generated number between 1 and 100. # It will continuously update the accompanying txt file that holds the current top 5 lead...
c3de6492784dd7ec80233f0f945bb57456a21f65
sinner933/CODEME_Homework
/2/zadnaie 2.4.py
268
3.734375
4
#Napisz program, który wyświetli kolejne wyniki dla silnii liczby naturalnej n. n = int(input("Give number ")) factorial = 1 list = [] for i in range(2, n + 1): factorial *= i for i in range(0, n): list.append(i+1) print(n, "!=", list.copy(), factorial)
ac27f41feaa608168d60dc547672e6cc07979812
jcass77/pybites
/pybites_bite27/omdb.py
1,512
3.515625
4
import json import re from collections import Counter def get_movie_data(files: list) -> list: """Parse movie json files into a list of dicts""" movie_data = [] for file in files: with open(file) as f: movie_data.append(json.loads(f.read())) return movie_data def get_single_come...
566d9dec93c6fa7427e12e9b4fa7a88f6bbb47ae
tm24fan8/Learning-Python
/old/objects/ident.py
178
3.578125
4
#!/usr/bin/env python3 name = "Matt" first = name age = 1000 print(id(age)) age = age + 1 print(id(age)) names = [] print(id(names)) names.append("Fred") print(id(names))
3c94bd5c7c0f886813bf295997056db0e9c30264
guskovgithub/Guskov
/Lesson10/task2.py
1,361
3.921875
4
class Point: def __init__(self,line='0,0'): self.x, self.y = [float(i) for i in line.split(',')] def __str__(self): return 'x = ' + str(self.x) + ' y = ' + str(self.y) def __add__(self, other): return Point(self.x + other.x, self.y + other.y) def __sub__(self, ...
419fcde889af5b9bb09ee80872cc45ee9bb67c0d
microease/Python-Cookbook-Note
/Chapter_3/3.2.py
356
4.03125
4
# 你需要对浮点数执行精确的计算操作,并且不希望有任何小误差的出现。 a = 4.2 b = 2.1 print(a + b) from decimal import Decimal a = Decimal('4.2') b = Decimal('2.1') print(a + b) from decimal import localcontext a = Decimal('1.3') b = Decimal('1.7') print(a / b) with localcontext() as ctx: ctx.prec = 3 print(a / b)
27befae31d0d9965c25c0051a34dae226bcd7f0c
paulovictor1997/Python
/Dicionário/testedic.py
662
3.984375
4
#pessoa = {'nome': 'Paulo', 'sexo': 'M', 'idade':23} #pessoa['peso'] = 70.5 #for k, v in pessoa.items(): # print(f'{k} = {v}') #print(f'O nome dele é {pessoa["nome"]} e a sua idade é {pessoa["idade"]}') #brasil = [] #estado = {'UF': 'Alagoas','Capital': 'Maceió'} #estado1 = {'UF': 'Pernambuco','Capital': 'Recife'...
c506e877385a74dfff190618b5544edf189a84c8
YancyYu1996/self_study
/算法/数据结构/算法/choose.py
406
3.765625
4
# 选择排序,前面有序,选择后面最小的值插入前面 import numpy as np l = np.random.randint(0,100,13) def choose(l): for _ in range(len(l)): for j in range(_,len(l)): if l[j] < l[_]: l[j], l[_] = l[_], l[j] else: continue return l print(",".join([str(x) for x in l])) pri...
7a9b210fa3fc419d88ae01c0e8f97889e71f2b22
ccubc/DS_self_learning
/leetcode_algorithm/hacker_rank_medium_sherlock_and_anagrams.py
1,171
4.09375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jan 2 16:16:04 2020 Two strings are anagrams of each other if the letters of one string can be rearranged to form the other string. Given a string, find the number of pairs of substrings of the string that are anagrams of each other. Given a str, find...
48846258f4e366a6da447dffa3103ae9d24b7988
Liam-Stow/FIT1045Workshops_Public
/Workshop8/Task1.py
318
3.546875
4
file = open('Small.txt') locations = [] for line in file: line = line.strip() #Split postcode from string line = line.split('\t') postcode = int(line[0]) #Split towns appart line[1] = line[1].split(',') for place in line[1]: locations.append([postcode, place]) print(locations)
f06b132d16eeceebf3e63683eb2c2877b174cb4d
JitenKumar/PythonPracticeStepByStep
/Decorators/DecoratorExample/decorator.py
646
4.3125
4
# decorator is used to add extra functionalities to the existing function def i_am_decorator(old_func): def wrapper(): #print('Extra code can be put here before the old_func()') print('Do you want to be more powerful???') print('') old_func() print('training you inner st...
a0652b7dd9190fe12329f7cc8a0fce4e17220ad2
andreifortunato/pythonTest
/string2.py
142
3.65625
4
a = "Diego" b = "Mariano" concatenar = a + " "+ b print(concatenar.lower()) print(concatenar.upper()) concatenar=concatenar.lower()
eb81c64f54072d9b275b846fce22311c732650df
DhirendraPachchigar/daily-coding-problems-1
/python/378.py
726
3.859375
4
# ----------------------------- # Author: Tuan Nguyen # Date created: 20200526 #!378.py # ----------------------------- """ Write a function that takes in a number, string, list, or dictionary and returns its JSON encoding. It should also handle nulls. For example, given the following input: [None, 123, ["a", "b"], ...
c7f81ae25662d447d07b579f77a77571967d0dc2
josepas/algos2
/proyecto3/bubbleSort0.py
599
3.53125
4
#!/usr/bin/python3 # Proyecto 3 # # Algoritmo de Ordenamiento BubbleSort0 # # Autores: # Jose Pascarella 11-10743 # Amin Arria 11-10053 # # Ultima Modificacion: 19 / 12 / 2013 import time from random import * def BubbleSort0(A): n = len(A) co = 0 cambio = True while cambio: ca...
c34fe7579013699cc97fc5efb46e936ba91c7f15
yulvil/euler-python
/004.py
565
3.859375
4
#/bin/python # http://projecteuler.net/problem=4 # A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99. # Find the largest palindrome made from the product of two 3-digit numbers. def is_palindrome(n): s = str(n) return s == s[:...
35218d8a03fb191a0a8e55bc5a38cc00e037bc35
rodrigoc-silva/Python-course
/Lab05_dictionary_and_class/exercise-36.py
5,292
4.1875
4
#Program to calculate and display the loan for buying a car class Loan: #initializer def __init__(self, annualIntRate, numYearsLoan, loanAmnt, name): self.__annualIntRate = annualIntRate self.__numYearsLoan = numYearsLoan self.__loanAmnt = loanAmnt self.__name = name #ge...
9228a52748c7ea521ed616f1e531b3363a67454c
rubberdinghy/auto_nav
/Labs & homeworks & Others/stepper_motor_control.py
4,398
3.5625
4
# -*- coding: utf-8 -*- """ Created on Wed Mar 18 19:48:04 2020 @author: tuandung """ from time import sleep import RPi.GPIO as GPIO import rospy class Motor(object): def __init__(self, pins, mode=2): self.p1 = pins[0] self.p2 = pins[1] self.p3 = pins[2] self.p4 = pins[3] ...
fb359c2a9bbb67ce69f6005e154f343cbd05845d
minhtoando0899/baitap
/Bai_tap_ve _list/Buoi5/Tong2List.py
420
3.703125
4
class HHH: def __init__(self, list1, list2): self.list1 = list1 self.list2 = list2 self.tong1 = 0 def Tong(self): for a in self.list1: self.tong1 += a def Append(self): list.append(self.list2, self.tong1) def Tong2(self): for b in self.list2...
d73d7239f58bb644794f021a3860ec3d83417944
shaunagm/personal
/project_euler/p31-40/problem_34_digit_factorials.py
776
4.03125
4
# 145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145. # Find the sum of all numbers which are equal to the sum of the factorial of their digits. # Note: as 1! = 1 and 2! = 2 are not sums they are not included. import math def factorialDigitSum(number): factorialSum = 0 for i in str(number): factorial...
7553e4344a47808f07cbb0800e56d583608d261c
arjun289/eopi
/data_structures/graphs/depth_first.py
921
3.578125
4
class Node: def __init__(self, name): self.name = name self.adjacency_list = [] self.visited = False self.prdecessor = None class DFS: def dfs(self, node): node.visited = True print("%s" % node.name) for n in node.adjacency_list: if not n.v...
6564e7a36bb95144161d83b4fb274d67f5817406
097654321C/lesson-2
/lesson3.py
505
3.5625
4
x=input('輸入數字!') x=int(x) import random ans=random.randint(1,2) y=str('y') if x==ans: y=input('恭喜你!:),還要玩嗎?要請按0,不要請按1') elif y==1: print('bye bye') elif y==0: x=input('輸入數字!') else: print('你錯嘞>_<,再試一次') i=int(i) while x != ans or i<5: x=input('再輸入一次數字!') x=float(x) print('你錯嘞>_<,再試一次') i+1 ...
650e4b1b75817d8b4e44257ec55c1aacd05ccbac
dogeplusplus/Jaipur
/test_game_agent.py
4,877
3.609375
4
import unittest import jaipur import jaipur_players class jaipurTest(unittest.TestCase): def test_check_hands(self): j = jaipur.Jaipur(players.RandomPlayer('Alice'), players.RandomPlayer('Bob')) j.initial_setup() self.assertEqual(len(j.market),5) # Check players hand at most 5 cards...
7a12afe257bd7e69fb6c7c2e31c5473789888c40
larakollokian/foodalike
/ImprovedCNN.py
1,765
3.53125
4
from keras.models import Sequential from keras.layers import Dense, Conv2D, MaxPooling2D, Dropout, Flatten from keras.utils import to_categorical import pickle num_classes = 24 input_shape = 50 train_data = pickle.load(open("X_train.pickle", "rb")) train_labels = pickle.load(open("y_train.pickle", "rb")) train_labels...
f19f0012a4b733041e599adde6990bad18f703ad
soundaraj/python-practices1
/pentegonn.py
201
3.796875
4
import turtle myturtle = turtle.Turtle() def pent(length,angle): for i in range(5): myturtle.forward(length) #myturtle.backward(10) myturtle.left(angle) pent(120,72)
55883a42fe926a1f695520cd3dfcf92882bc403b
Agioss/tasks_for_nubip
/task2.py
7,426
3.828125
4
# Підключаємо графічну та математичну бібліотеки import tkinter import math # Функції, які відповідають за введення та виконання стандартних операцій def add_digit(digit): value = count.get() if value[0] == '0': value = value[1:] count.delete(0, tkinter.END) count.insert(0, valu...
c21903404ba90d1c4e660483b139e81df1f04085
liukai234/python_course_record
/面向对象/面向对象基础.py
680
3.609375
4
''' @Description: @LastEditors: liukai @Date: 2020-04-21 09:05:13 @LastEditTime: 2020-04-21 09:28:07 @FilePath: /pyFile/面向对象/test.py ''' class Student(object): def __init__(self, a, b): # 构造函数 self.a = a # self表示为数据成员 self.b = b def num1(self, c, d): # 成员函数 self.c = c # self表示为数据成员 ...