blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
165c49a7b83b957cff52126262743f8fb69ae256
smrafi047/reg-exp
/demo6.py
62
3.625
4
import re st="mahammad" result=re.split(r"h",st) print(result)
dc96ca1eca00815ce31d9cc7e9a5b46f567dd522
smrafi047/reg-exp
/demo19.py
88
3.546875
4
import re s1="rafi@gmail.com rafishaik@yahoo.com smrafi@co.in" result=re.findall(r"@\w+.(\w+)",s1) print(result)
e838ba47e848752abef9ebbed0d7dc30f826e93f
collective/p4a.common
/p4a/common/formatting.py
5,105
4.03125
4
from datetime import datetime from datetime import timedelta ONE_DAY = timedelta(days=1) def day_suffix(day): """ Return correct English suffix (i.e. 'st', 'nd' etc.) >>> day_suffix(1) u'st' >>> day_suffix(6) u'th' >>> day_suffix(21) u'st' >>> day_suffix(26) u...
726e8213ded93d4ab22e8cbb55f4873017b135fe
tedrepo/Algorithm
/Data structure and algorithm/2018-11-27-skip-list.py
2,727
3.71875
4
# -*- coding: utf-8 -*- # @Author: 何睿 # @Create Date: 2018-11-27 17:13:52 # @Last Modified by: 何睿 # @Last Modified time: 2018-11-27 17:13:52 """ Implementation of skip list The list stores positive interges without duplicates """ from typing import Optional import random class ListNode: d...
862c05fd465703a7a18213eb879aca1a272ed695
merry-hyelyn/Baekjoon-Online-Judge
/9000~9999/9498.py
475
3.765625
4
# 문제 # 시험 점수를 입력받아 90 ~ 100점은 A, 80 ~ 89점은 B, 70 ~ 79점은 C, 60 ~ 69점은 D, 나머지 점수는 F를 출력하는 프로그램을 작성하시오. # 입력 # 첫째 줄에 시험 점수가 주어진다. 시험 점수는 0보다 크거나 같고, 100보다 작거나 같은 정수이다. grade = int(input()) if grade >= 90: print("A") elif grade >= 80: print("B") elif grade >= 70: print("C") elif grade >= 60: print("D") else: print("F")
2aff98806d02b7909c217b423221f0c19466903c
merry-hyelyn/Baekjoon-Online-Judge
/2000~2999/2753.py
759
3.578125
4
# 문제 # 연도가 주어졌을 때, 윤년이면 1, 아니면 0을 출력하는 프로그램을 작성하시오. # 윤년은 연도가 4의 배수이면서, 100의 배수가 아닐 때 또는 400의 배수일 때 이다. # 예를들어, 2012년은 4의 배수라서 윤년이지만, 1900년은 4의 배수이지만, 100의 배수이기 때문에 윤년이 아니다. # 하지만, 2000년은 400의 배수이기 때문에 윤년이다. # 입력 # 첫째 줄에 연도가 주어진다. 연도는 1보다 크거나 같고, 4000보다 작거나 같은 자연수이다. # 출력 # 첫째 줄에 윤년이면 1, 아니면 0을 출력한다. year = int(i...
cc1b9144c33123cafcca1cec9b5d36bdc1d269e5
Ash515/hacktoberfest2021-3
/Python/Algorithms/Searching/breath-first-search.py
577
3.921875
4
# Author:- Vinod Patidar # GitHub:- vinodpatidar123 from collections import deque def bfs(tree,root): visited = [] connected = [] # visited.append(root) connected.append(root) while connected: node = connected.pop(0) if node <= len(tree.keys()): for nextnode in tree[no...
750ece742d1051d70b3ba9bc87bd123dca1739ac
LorenaFurtado/aula2_impostoDeRenda
/aula_1.py
1,727
4.125
4
""" caso eu queira que o python aceite acentos etc, basta declarar: # -*- coding: utf-8 -*- """ """ #funcao que define soma def soma(a,b): return a+b print (soma(12,100)) # versão onde o usuário define os parâmetros: def area_coroa3(r1,r2,pi=3.14): return (pi*r1**2) - (pi*r2**2) a1=input("digite r1:") a1 ...
db1f00c620df7d653be9ff3c6a5268f1a338177a
conexaomundom/Python
/pessoa2.py
910
3.625
4
from datetime import datetime from random import randint class Person2(): # class attribute is acessible only to class pessoa current_year = int(datetime.strftime(datetime.now(), '%Y')) # constrctor and self, name, age are instances def __init__(self, name, age): self.name = name ...
6455f1f07a6ccc3650e69dfa92c157961a1c04e6
conexaomundom/Python
/main.py
565
3.921875
4
# importando um classe do arquivo pessoa from pessoa import Person from pessoa2 import Person2 # em que p1 é da classe Pessoa() e p2 também é da classe pessoa p1 = Person2('Marina',24) p2 = Person('Julio', 26) # usou um molde para criar uma pessoa o molde é a classe Pessoa # o obejto p1 é uma instancia # ...
3cda6f44a0ed7008965db1aa4830d41e5ecc5708
D1M1TR10S/Algorithms-Python
/prob_sums_dice.py
597
4.03125
4
''' Find the probability that a roll of x number of dice will add up to n ''' from itertools import product from decimal import * def rolldice_sum_prob(n, dice_num): ''' Find number of possible combos adding up to n in dice_num number of dice Return number of matches divided by the total combos to get the ...
876c0e214bc58d96a4aaceacd6556aacbd6c38de
TeanaShe/HomeWorksPython
/ClassWork2708.py
1,387
4.3125
4
"""Max number from many numbers""" # n = int(input("how many numbers will be? ")) # my_list = [] # for i in range (n): # m = int(input('enter number ')) # my_list.append(m) # print(f"The maximum number in the list is {max(my_list)}") # print(f"The minimum number in the list is {min(my_list)}") """eval and odd...
3c50388254fc4f2bec832dbf157f60b89259d208
firdaussaad/python-essentials
/project3_building_a_multiple_choice_quiz.py
1,045
3.875
4
#!/usr/bin/env python3.6 class Question: def __init__(self, prompt, answer): self.prompt = prompt self.answer = answer question_prompts = [ "What colour are apples?\n(a) Red/Green\n(b) Purple\n(c) Orange\n\n", "What colour are bananas?\n(a) Teal\n(b) Magenta\n(c) Yellow\n\n", "What co...
fdf7bb4641b6e67b180e63f064e1e4cd0233fdc9
firdaussaad/python-essentials
/part5-if_statement_and_comparision.py
495
4.28125
4
#!/usr/bin/env python3.6 # != not equal # This scenario allow us to compare a series of numbers def max_num(num1, num2, num3): if num1 >= num2 and num1 >= num3: return num1 elif num2 >= num1 and num2 >= num3: return num2 else: return num3 print(max_num(10, 20, 30)) # This is a ...
6e47899fa939e68a0916eb503d246681ccb591aa
theolamide/Sorting
/src/iterative_sorting/iterative_sorting.py
1,942
4.15625
4
# TO-DO: Complete the selection_sort() function below def selection_sort(arr): # loop through n-1 elements print(arr) if len(arr) == 0: return arr for i in range(0, len(arr)): get_smallest_num_and_index(i, arr) smallest_result = get_smallest_num_and_index(i, arr) # if sm...
a1fcb8afd7aeeb38e64d249d68a0d5d0c04c6785
SeriphT/Portfolio
/hangman/Hangman.py
2,489
3.921875
4
#Hangman #Sabastian Taton #Nov. 26 2018 import time import random global MAX_WRONG global WORDS global word global so_far global wrong global used HANGMAN = ( """ ------- | | | | | | | | | -------- """ , """ ------- | | | | | 0 | | | | --------- """ , """ -...
7d996a30aaec494eef351af544e3c0f343efaa96
SeriphT/Portfolio
/Games/blackjack.py
3,584
4.125
4
import random class Card(object): """ A PLAYING CARD This class builds a single card to build a card, call Card() and pass in a rank and suit card1 = Card("A","s") """ RANKS = ["A","2","3","4","5","6","7","8","9","10","J","Q","K"] SUITS = ["♠","♥","♦","♣"] d...
7f0e5847d0a19d61ac3fd8836d7856aeca9d7432
dev-parvej/python-learning
/condition.py
237
4.0625
4
inputs = input("Please enter a string: ") if(len(inputs) < 6): print("Dick is too short") print("Call me") elif(len(inputs) > 6 and len(inputs) < 10): print("She is happy") else: print("She is crying or She is African")
85cd5c2e064c57172bc1bd9a3425cf2a4628c982
pranaymate/PythonExercises
/ex010.py
150
3.734375
4
money = float(input('How much money do you have in your wallet? R$ ')) # Currency Real Brazil print('You can bay {:.2f} Dollars'.format(money/3.27))
0221bfa97d2bb5af0076e65f8c230d8ec8dd7f66
pranaymate/PythonExercises
/ex019.py
352
3.90625
4
import random student1 = str(input('First student: ')) student2 = str(input('Second student: ')) student3 = str(input('Third student: ')) student4 = str(input('Fourth student: ')) student5 = str(input('Fifth student: ')) students = [student1, student2, student3, student4, student5] print('The student selected was {}'.f...
abfe4d2af71b5c790615a8098c7237f1e8ad14c7
pranaymate/PythonExercises
/ex044.py
967
4.125
4
shopping = float(input('How much was the shopping price? ')) print('Payment methods:') print('[1] cash payment') print('[2] credit card') print('[3] 2x at credit card') print('[4] 3x or more at credit card') option = int(input('Which one do you pick? ')) if option == 1: print('Your purchase of the R$ {:.2f} will co...
5684b50b4c4947bae400fe9e06773dc45439ab1d
pranaymate/PythonExercises
/ex024.py
87
3.8125
4
city = input('Type a name of your City: ') print('{}'.format('santo' in city.lower()))
35ff7c02feab41c680bc9a695e45e8466cf119b4
pranaymate/PythonExercises
/ex022.py
336
4
4
name = input('Type your full name: ') print('Analyzing your name...') print('Your name in uppercase {}'.format(name.upper())) print('Your name in lowercase {}'.format(name.lower())) print('Your name has {} letters '.format(len(name) - name.count(' '))) fname = name.split() print('Your first name has {} letters'.format(...
e56f615fccf40e7f2fb3b6dd57ceae8e08503ea1
pranaymate/PythonExercises
/ex050.py
219
4
4
number = 0 count = 0 for c in range(1, 6): value = int(input('Type a number: ')) if value % 2 == 0: number += value count += 1 print('The sum of all {} even numbers is {}'.format(count, number))
3a0573810328a53b5473e4ef9cf3b83f9a07cefa
playHing/udacity-program-design
/hw2-2.py
1,239
3.96875
4
# ------------------ # User Instructions # # Hopper, Kay, Liskov, Perlis, and Ritchie live on # different floors of a five-floor apartment building. # # Hopper does not live on the top floor. # Kay does not live on the bottom floor. # Liskov does not live on either the top or the bottom floor. # Perlis lives on a highe...
d46b9d249120884232c43da44a81782b3fc3c1a8
Blueflybird/Python_Study
/Python_Inty/practise_20200405_for_loop.py
251
4.1875
4
# my_list=[1,2,3,4,5,6,7,8,9,10] # print(my_list[0]) # print(my_list[1]) my_list=["jake","Tom","xi li"] for name in my_list: print(name) for number in range(10,21): print(number) for letter in 'inty': print("Each letter is: "+letter)
973291eaa55c717b5906b779d399bcb457683336
Blueflybird/Python_Study
/Python_Inty/practise_20200405_Dictionary.py
498
4.25
4
""" Python3 中有六个标准的数据类型 Nummer(数字) String(字符串) List(列表) Tuple(元组) Sets(集合) Dictionary(字典) """ myList=(1,2,3,4) myDictionary={"key":"value","key2":"value"} print(myDictionary) myPhones={"Iphone X":1000,"Sumsang S9":900} print(myPhones) #access dic keys Iphone_Price=myPhones["Iphone X"] print("Iphone price: "+str(Ipho...
36658d1aef33a7a1ec6354592346684f3aa494c5
RDGardner/Classification-and-Regression-Decision-Tree
/Programming Assignment 3 - Callis.py
118,535
3.78125
4
#!/usr/bin/env python # coding: utf-8 # # Programming Project 3 # ## 605.649 Introduction to Machine Learning # ## Ricca Callis # ## Directions # # The purpose of this assignment is to give you a chance to get some hands-on experience learning decision # trees for classification and regression. This time around, we...
7664e0181ca06897dae52d7b7b006dddf6d9cb5e
BishoySamuel/Mastering-Python
/Assignments/Assignment-002-Lessons-011-018.py
1,239
4.46875
4
#------------------------- #-- Mastering Python #-- Second Assignment #--For Lessons 011 To 018 #------------------------- NAME = "Bishoy" AGE = 37 COUNTRY = "Egypt" print('Hello %s, How You Doing \\\"Your Age is %d"' % (NAME, AGE)) print("Hello {:s},How You Doing \\\"Your Age is {:d}\"".format(NAME, AGE)) prin...
0a9319170d756360cfc0ef25ec1be8d3d0bb27aa
ChulWPark/Software-Engineering-Tools-Lab
/Lab07/oopLab.py
2,386
3.6875
4
#! /user/local/bin/python3.4 class TimeSpan: # Initializer def __init__(self, weeks, days, hours): if weeks < 0 or days < 0 or hours < 0: raise ValueError("The arguments cannot be negative") self.hours = hours % 24 if hours >= 24: days_temp = days + hours // 24 ...
185ced4c8e270f5f1d39909e04103c215dcf35c0
AkylbekMelisov/classes
/week4/day3/classes_task1.py
3,164
3.859375
4
class Car: wheels = 4 def __init__(self, name, year, color, model, is_crashed): self.name = name self.year = year self.color = color self.model = model self.is_crashed = is_crashed self.fuel = 100 self.run = 0 self.speed = 0 self.V = 20 ...
013a80c3cc8f0c7ff0ff9ee6d5d6571b084e8f71
Oleksandr015/Algorytmy
/AISD/recursion/digit_sum.py
891
4
4
""" PODPOWIEDZI: * użyj operatora // do dzielenia całkowitego * użyj operatora % * sprawdz czy liczba nie jest równa 0 aby uniknac dzielenia przez zero """ def digit_sum(number): if number == 0: return 0 result = number % 10 + digit_sum(number // 10) return result if __name__ == '__main__'...
2523b58b13fbca645d91f5b6183844c3ff626e06
Oleksandr015/Algorytmy
/AISD/recursion/failing_recursion.py
411
4
4
def recursion(): t = 0 recursion() def recursion_with_param_print_before(param): print(param) recursion_with_param_print_before(param) def recursion_with_param_print_after(param): recursion_with_param_print_after(param) print(param) if __name__ == '__main__': recursion() recursion_...
bec6f0e5a271c3ce1dc9dedef6af6c5e0915ed25
Oleksandr015/Algorytmy
/AISD/generators/comprehension.py
207
3.734375
4
if __name__ == '__main__': array = [1, 3, 5, 9, 2, 6] generator = (item for item in array if item > 3) print(generator.__next__()) print(generator.__next__()) print(generator.__next__())
7f1dd1efb2b307c87dcce1e69b24d7a9e198dead
lobodaalina/G11
/dictionaries.py
385
4.03125
4
def merge(dict1, dict2): full_dict = dict1.copy() full_dict.update(dict2) return full_dict def dict(): a = input("Введите ключ 1:") b = input("Введите значение 1:") dict1 = {a: b} c = input("Введите ключ 2:") d = input("Введите значение 2:") dict2 = {c: d} print(merge(dict1, di...
c16b4c9480d35e2dde07a2f38752545eade896e7
python-programming-1/homework-4-awesome-k
/rock_paper_scissors.py
1,843
4.0625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jul 24 11:40:58 2019 @author: awesome_k """ import random import time myScore = 0 compScore = 0 draw = 0 rps = ['r', 's', 'p'] playAgain = 'y' while playAgain == 'y': myChoice = input('Make a move! r/s/p') compChoice = random.choice(rps) ...
6fa1f5f88f5632a571dc447c31e85515a58d949d
Mach3psilon/Programming-Basics
/260201058_hw3.py
7,002
4.3125
4
# 260201058 #Eray Okutay # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Ball Crush # -*- coding: utf-8 -*- print("Welcome to the Ball Crush game!") print() from random import randint import time #It is a shortcut for the define inputs type. def integer(x): try: ...
d35946193e51b40bea47560d9259d09be998c6ab
jramaswami/Advent-Of-Code-2020
/07/python/day07.py
2,239
3.609375
4
""" Advent of Code 2020 :: Day 7: Handy Haversacks """ import sys from collections import defaultdict, deque import pyperclip def parse_line(line): """ Parse the line. Return a tuple where the first item is the container and the second item is a list of containees. """ left, right = line.split(' ...
359dae3e3eaa734c536741e971ed1f156b3e4d06
jramaswami/Advent-Of-Code-2020
/21/python/day21.py
2,521
3.953125
4
""" Advent of Code 2020 :: Day 21: Allergen Assessment """ import sys from collections import defaultdict import pyperclip def parse_line(line): """ Return a tuple containing (1) a list of ingredients, and (2) a list of allergens. """ line = line.strip() tokens = line.split() ingredients...
b2d1882d21262c55250117af116d383b928b1162
jramaswami/Advent-Of-Code-2020
/04/python/day04.py
3,493
3.703125
4
""" Advent of Code 2020 :: Day 4: Passport Processing """ import sys import pyperclip def parse(iterable): """ Parse input. Records are separated by two newlines. Returns a dictionary with the data fields. """ record = dict() for line in iterable: if line == '\n': yield r...
9d6fd394c3d935fe6d17e25ff9d8e43dba01945d
shouryaveer/rock-paper-scissors
/rock_paper_scissors.py
769
3.953125
4
import random print("********Welcome to Rock Paper Scissors********") def play(): n = 1 u = 0 c = 0 while n <= 5: user = input("Press r for Rock, p for Paper, s for Scissors: ") comp = random.choice(['r','p','s']) print("Computer:",comp) n += 1 if user == comp: ...
c4dabd4ebf342add92bf68d8290fc879ab9471cc
DebjitPramanick/Python-GUI
/Tkinter/lables.py
462
3.71875
4
from tkinter import * root = Tk() root.geometry("600x600") root.minsize(400, 400) # Defines minimum size of window root.maxsize(900, 900) # Defines maximum size of window root.title("My GUI") lb = Label( text=" Debjit Pramanick", bg="grey", fg="white", padx=10, pady=10, font=("arial",16,"ital...
e3ae2855c4e770cbc1886a8bd62ff269f3c0dc44
Anton-K-NN/MoneyBox
/Копилка - класс.py
1,460
3.703125
4
''' Реализуйте класс MoneyBox, для работы с виртуальной копилкой. Каждая копилка имеет ограниченную вместимость, которая выражается целым числом – количеством монет, которые можно положить в копилку. Класс должен поддерживать информацию о количестве монет в копилке, предоставлять возможность добавлять монеты в копи...
44d93962e7581274070e289f82fd93d6e3f2fee1
jelockro/mit-6.00sc-intro-to-computer-science-and-programming
/quizes/quiz4.py
357
3.875
4
wordlist = ['run', 'file', 'options', 'window', 'ruun'] lStr = 'nru' def findAll (wordlist, lStr): result = [] sortedL = sorted (lStr) for word in wordlist: sortedW = sorted (word) print sortedW if sortedW == sortedL: result.append(sortedW) return result pr...
b21f6dd23f878fad92e3d78c94c4f194ade150e5
jelockro/mit-6.00sc-intro-to-computer-science-and-programming
/ps2-hangman/ps2_hangman_josh.py
3,454
4.3125
4
# 6.00 Problem Set 3 # # Hangman # # ----------------------------------- # Helper code # (you don't need to understand this helper code) import random import string WORDLIST_FILENAME = "words.txt" def load_words(): """ Returns a list of valid words. Words are strings of lowercase letters. Dependin...
ee795ed79c0306812143e76eafb8383217540ee4
joshuawong1/CP1404Practicals
/prac_03/password_entry.py
376
4.0625
4
'''Joshua''' min_password = 6 def main(): password = get_password() print_asterisks(password) def print_asterisks(password): print('*' * len(password)) def get_password(): password = input('Enter password of 6 characters:') while len(password) < min_password: password = input('Enter p...
e89fc689b08a6b1ebfb71fecfe85d8509bdc988c
maidao/numpy_basic
/first_exe.py
1,292
3.5
4
import numpy as np a = np.array([1,2,3]) # Tạo ra mảng một chiều từ list print(a) # [1 2 3] print(type(a)) # <class 'numpy.ndarray'> print(a.shape) # (3,) --> mang 1 chieu, 3 phan tu a[0] = 5 # sua gia tri phan tu [0] cua mang tu 1 --> 5 print(a) # [5 2 3] # Tạo ra mảng hai chiều từ 2 list b = np.array([[1,2,3],[4,5...
1e2c13f634fb8cd3a557aff61c99b84a84ab1611
joshherkness/CSE-233-Project
/programming-exercises/3.py
425
4.1875
4
# Program 3.3 # # 1. Enter age # 2. Given the constraints, print if they are a baby, child, teenager, or adult. def main(): age = int(input('Enter your age (in years): ')) if age <= 1: print('Baby 👶') elif age > 1 and age < 13: print('Child 😣') elif age >= 13 and age < 20: print('Teenager 😎') ...
dec38db6f3ad730711d2678140e73f705057667a
joshherkness/CSE-233-Project
/programming-exercises/7.py
1,549
4.34375
4
# Program 3.7 # # 1. User enters two primary colors. # 2. Output secondary color that results from mixing the two colors. # # WARNING: Very terrible programming ahead. # However, we wanted to show the use of decision structures to complete the task. def main(): possible_colors = ['red', 'blue', 'yellow'] # Pro...
b70d1f61a1e93049e088a94e7097c153fb52e301
btror/Simple-Store
/Store/Main.py
739
3.953125
4
from Services import Services items = {} totalCost = 0 continueShopping = '' while True: item = input("What do you want to buy?") price = Services().userNumber("What is the price of the " + item + "?") amountOfItems = Services().userNumber("How many " + item + "'s do you want to purchase?") ...
61bd925c4188082031114059c610468a09731a9e
nlind/myDSCI401
/Lind_Assignment2_non_relevant_model.py
6,652
3.859375
4
# This illustrates several feature selection methods for regression. import pandas as pd import matplotlib.pyplot as plt import pprint from sklearn import linear_model from sklearn.model_selection import train_test_split from sklearn.metrics import mean_squared_error from sklearn.metrics import median_absolute_error f...
aa6847157bb012dd56873d02688593942d382a8b
arinablake/python
/homework3.py
6,825
4.59375
5
# Create a tuple containing the names of five countries and display the whole tuple. # Ask the user to enter one of the countries that have been shown to them and then display the index number # (i.e. position in the list) of that item in the tuple. tuple1 = ('Russia', 'USA', 'UK', 'France', 'Italy') print(tuple1) co...
020d4ff0b973105305b31d7fc8aa5a0527a93d6a
ahctampra/BMI
/BMI.py
891
4.3125
4
# BMI = 體重(公斤)/身高**2(公尺平方)   #過重:24≦BMI<27 #輕度肥胖:27≦BMI<30 #中度肥胖:30≦BMI<35 #重度肥胖:BMI≧35 #18.5≦BMI<24 #BMI < 18.5 過輕 print('您好,歡迎面對自己的BMI數值') height = input('請輸入您的身高(公尺)') weight = input('請輸入您的體重(公斤)') BMI = float(weight) / (float(height) ** 2) print(BMI) if BMI < 18.5: print('您已經過輕了,真的太瘦了!') elif BMI >= 18.5 and BMI <...
fcf8320ec248ad3d8b192ebe0ced06f0a046c825
faizan4053/CG_Lab
/assign_2 filling clipping/lineClipping/liang barsky/liangBarsky.py
2,143
3.625
4
from winSize import * from graphics import * from drawLine import * from drawPolygon import * from windowToViewport import * print( " Enter window size im the following order (xmin , xmax , ymin , ymax) :-") xwmin , xwmax , ywmin , ywmax = map(int, input().split()) window = size(xwmin , xwmax , ywmin , ywmax) print( ...
f8da1432606fc14ed8cf9ba53b502a6c17e2f561
faizan4053/CG_Lab
/assign_4 projection cube/projection_cube.py
8,783
3.875
4
from math import * import numpy as np from define_window import * from graphics import * color=['blue','orange','maroon','green','grey','purple','violet','brown','dark sea green','gold','tomato','magenta'] def print_line(x1,y1,x2,y2,color): #function to print line x=x1 y=y1 dx=x2-x1 dy=y2-y1 swap=0 if dx>0: ...
b0649301e75d084c01b8f959fd99317fcda23331
Govindabhakta/tugas-besar-daspro
/fungsi/login.py
884
3.59375
4
def login(x): global role paswValid = False while not(paswValid): uname = input('Masukkan username: ') pasw = input('Masukkan password: ') for i in x: if i[3] != 'Username': ...
595580f1ea8cb6a4fdb94f5ae456ef506c0f1a36
jakobkogler/pk-tool
/src/history.py
3,782
3.703125
4
class History: """ Records every change in the table and undo/redo this actions on command. """ def __init__(self, action_undo=None, action_redo=None, write_console=None, group_infos=None): self.history = [] self.history_foreward = [] self.current_data = [] self.action_u...
8789cb1b70129870303eec4f9a6f960832978ac6
spalladino/coursera-image-processing
/week1/main.py
2,526
3.546875
4
import cv2 import numpy as np IMAGE = '../images/lena.bmp' IMAGE_GRAY = '../images/lena.gray.bmp' def reduce_intensity(img, factor): """Quantizes an image by the specified factor""" return (img / factor) * factor def show_images(images): """Displays a set of pairs (title, image) one after the other""" for ...
e7ea0689fa0d3dde88d9983643666802a73e33c8
Amaayezing/ECS-10
/GradeNeed/grade_need.py
969
4.25
4
# Maayez Imam 10/2/2017 # Grade need program gradeWanted = str(input('Enter the grade you want in the class: ')) # user inputs their desired letter grade percentNeeded = float(input('Enter the percent you need to get that grade: ')) # user inputs the percent they need to get that letter grade currentPercent = float(...
a99bb107e8e65936e8cb5456bf9bb621b0b7bf63
Amaayezing/ECS-10
/change/change.py
815
3.78125
4
#Maayez Imam 10/2/2017 #Change program moneyWithdrawn = int(input('Please enter the amount of money you wish to withdraw: ')) ones = 0 fives = 0 tens = 0 twenties = 0 fifties = 0 hundreds = 0 modhundreds = 0 modfifties = 0 modtwenties = 0 modtens = 0 modfives = 0 hundreds = moneyWithdrawn / 100 modhundreds = moneyWit...
ca6d9b66113f0232f194f6f2a26ae955a4af8dda
Amaayezing/ECS-10
/cost_of_living/cost_of_living.py
489
3.890625
4
food = input('Food: ') food = float(food) rent = input('Rent: ') rent = float(rent) entertainment = input('Entertainment: ') entertainment = float(entertainment) transportation = input('Transportation: ') transportation = float(transportation) weed = input('Weed: ') weed = float(weed) netflix = input('Netflix: ') netfl...
b85ee7a2f13106e325a6f6c1b01173397ffd6858
felsewhere1/hello_world
/scripts/lists.py
734
3.953125
4
colors = ["red", "green", "blue", "yello"] print(colors[0]) print(colors[-1]) print(colors) for i in colors: print(i) colors[3] = "yellow" for i in colors: print(i) print(colors[1:2]) print(colors[1:]) print(colors[:4]) colors.reverse() #does not return! print(colors) colors.sort() print(colors) leapyear = [...
b1284db33653ebd903ed0be5ad0f87a52feb585a
ipetrushenko-softheme/codejam
/greedy/48-160A.py
399
3.5625
4
def read_tokens(): return input().strip().split(' ') def read_ints(): return [int(s) for s in read_tokens()] n, = read_ints() arr = read_ints() def solve(arr: list) -> int: arr.sort(reverse=True) total_sum = sum(arr) left = 0 for i in range(n): left += arr[i] right = total_...
f30cdb7f1a0c7e8b437d7e4638aee138070017f0
ipetrushenko-softheme/codejam
/implementation/46-755A.py
336
3.71875
4
from math import sqrt n = int(input()) def is_prime(n: int) -> bool: sq = int(sqrt(n)) + 1 for i in range(2, sq): if n % i == 0: return False return True def solve(n: int) -> int: for m in range(1, 1001): ans = n*m + 1 if not is_prime(ans): return m ...
9470d0743f0c45bf36c9d1a07e93d947d348847d
ipetrushenko-softheme/codejam
/recursion/28-1323A.py
1,055
3.625
4
def read_tokens(): return input().strip().split(' ') def read_ints(): return [int(s) for s in read_tokens()] def process_subset(arr, sofar): sum_so_far = 0 for idx, el in enumerate(sofar): if el == 1: sum_so_far += arr[idx] return sum_so_far def compute_subset(n, arr, sofa...
518d359e73add56d0ab92985c91c0730dda9b1ac
ipetrushenko-softheme/codejam
/graph/36-939A.py
1,390
3.625
4
def read_tokens(): return input().strip().split(' ') def read_ints(): return [int(s) for s in read_tokens()] n = int(input()) arr = read_ints() graph = [[] for _ in range(n)] visited = [0] * n parent = [-1] * n def add_edge(u, v): global graph graph[u].append(v) for u in range(n): v = arr[u]...
180d88bf19c8795aed5dc253791c464a109a018f
ipetrushenko-softheme/codejam
/bsearch/4-230B.py
998
3.984375
4
# https://codeforces.com/problemset/problem/230/B # preprocessing + binsearch def read_tokens(): return input().strip().split(' ') def read_ints(): return [int(s) for s in read_tokens()] T, = read_ints() numbers = read_ints() # 10 # 10 9 8 7 6 5 4 3 2 1 # NO # YES # NO # NO # NO 6 # NO 5 # YES 4 # NO ...
5ef35c9d9b96febb81de41a9f7be1c3ce86c0233
ipetrushenko-softheme/codejam
/implementation/45-520A.py
275
3.734375
4
def read_tokens(): return input().strip().split(' ') def read_ints(): return [int(s) for s in read_tokens()] n, = read_ints() s = input().strip() def solve(s: str) -> str: if len(set(s.lower())) >= 26: return "YES" return "NO" print(solve(s))
3775af6c6a209763d97ac429342ce6c64f4507ef
Muhammad5943/Data-Science
/pandas1.py
997
3.546875
4
import pandas as pd dict = { "country": ["Brazil","Rusia","India","China","South Africa"], "capital": ["Brasilia","Moscow","New Delhi","Beijing","Pretoria"], "area": [8.516, 17.100, 3.286, 9.597, 1.221], "population": [200.4, 143.5, 1252, 1357, 52.98] } brics = pd.DataFrame(dict) # menambah kolom lab...
5eee121c94edc71387189c972fcdb086af244fb2
DanielKulkamp/BlackJack
/blackjack.py
10,957
4.0625
4
# -*- coding: UTF-8 -*- ''' IMPLEMENTATION OF SIMPLIFIED BLACKJACK FOR COMPLETE PYTHON BOOTCAMP AUTHOR: DANIEL CLEMES KÜLKAMP ''' import random class Card(): ''' Playing cards class (from A to 10, J Q and K ) and suits of clubs, hears, spades and diamonds or joker ''' SUITS = ['clubs'...
f356bbccc1e9f44427e79d10bcb05d4a097b98b7
AaronPope/td_py2_secret_messages
/polybius_square.py
3,633
3.828125
4
# Aaron Pope # 05/22/2018 # Treehouse TechDegree - Python, Unit 2: Secret Messages """Encrypts & decrypts text, based on Polybius Square cipher encryption In order to have square dimensions, 5 subsets of the string library are utilized: ascii_uppercase 26 characters ascii_lowercase 26 characters ...
64db6f27d0b3d8e42532a3feefe266d327f96a17
saundera0436/CTI-110
/P4T2_BugCollector_AnthonySaunders.py
393
4.125
4
#Adding number of bugs for 5 days #CTI - 110 - P4T2 - Bug Collector #10-17-2018 #Anthony Saunders #Initialize the accumulator total = 0 # Get the bugs collected for each day for day in range(1, 6): print("Enter the number of bugs collected on day", day) bugs = int(input()) total = total + bugs ...
e112a9a0be06ef824d4957abd3a221358ffad75d
saundera0436/CTI-110
/P3LAB_SaundersA.py
804
4.34375
4
#CTI -110 #P3LAB - Debugging #Anthony Saunders #October 7 2018 def main(): #This program takes a number grade and outputs a letter grade. #System uses 10-point grading scale # Ask user to enter score score = float(input("Enter grade: ")) # Evaluate the grade ...
d8b02a05cda27acd3b396825cd2f90d398073881
saundera0436/CTI-110
/P5HW2_RockPaperScissors_AnthonySaunders.py
2,612
4.25
4
# Create a Rock, Paper, Scissors Game #11-5-2018 #CTI-110 P5HW2 Rock,Paper,Scissors #Anthony Saunders #import random import random # Define raw input raw_input = input # Define the computer choice function def rps(): computer_choice = random.randint(1,3) if computer_choice == 1: comput...
09cb6a226e94b6e56e77399792777ae5408c602a
xiaonilee/Introduction_to_Python_Programming_ud1110
/10292019Lesson4.py
3,846
4.5
4
# Break, Continue # Below, you'll find two methods to solve the cargo loading program from the video. # The first one is simply the one found in the video, which breaks from the loop when the weight reaches the limit. # However, we found several problems with this. # The second method addresses these issues by modif...
fd7bfeaca591723d27e7888a822011e9d2aa13db
xiaonilee/Introduction_to_Python_Programming_ud1110
/10222019Lesson2.py
5,597
4.0625
4
# Quiz: Average Electricity Bill # Write an expression that calculates the average of 23, 32 and 64 # Place the expression in this print statement print((23 + 32 + 64) / 3) # Quiz: Calculate # In this quiz you're going to do some calculations for a tiler. Two parts of a floor need tiling. One part is 9 tiles wide by ...
8cca2a9b1a82aede5ed1f4fa248683272495ff49
chenrun666/knowledgePoints
/Python相关/元类的理解/metaclassComprehend.py
2,335
3.640625
4
# class objectCreator(object): # pass # # # my_object = objectCreator() # print(my_object) # 可以打印一个类,因为他其实就是一个对象 # # # def echo(obj): # 可以将类作为参数传给函数 # print(obj) # # # echo(objectCreator) # # objectCreator.new_attribute = "foo" # 可以增加属性 # print(hasattr(objectCreator, "new_attribute")) # # objectCreatorMirror...
93c213c41b1587f5cbd84aeb25091bf10aeedfae
chenrun666/knowledgePoints
/算法相关/select_sort.py
825
3.859375
4
""" 一趟遍历记录最小的数字,放到第一个位置 再一趟遍历记录剩余列表中最小的数字,继续放置 交换次数少,比冒泡相对快一点 """ import random def find_min(li): min_val = li[0] for i in range(1, len(li)): if li[i] < min_val: min_val = li[i] return min_val def find_min_pos(li): min_val_pos = 0 for i in range(1, len(li)): if li[i] ...
fc6aff5ce21e3f6e7e1f9b6b5a25769595993653
Procos12/Coding_Challenges
/ginorts.py
298
3.90625
4
lower=[] upper=[] odd=[] even=[] x=input() for i in sorted(x): if i.isalpha(): if i.isupper(): y=upper else: y=lower else: if int(i)%2==0: y=even else: y=odd y.append(i) print("".join(lower+upper+odd+even))
af59c04ae551265db025eb163dc2570ac9c05e0a
minhkd98/kNN
/kNN.py
1,253
3.59375
4
""" kNN - k Nearest Neighbour __author__: vikas_rtr """ import numpy as np from scipy import stats as sts class kNN(): def __init__(self, k): self.k = k def _euclidian_distance(self, x1, x2): """Computes Euclidian Distance b/w two feature vectors X1 can be a numpy ndarray and x2 i...
a21a40a92b803f9b9447ff86af3b221661858c44
SueAli/cs-problems
/LeetCode/Closest Binary Search Tree Value.py
898
3.90625
4
# Closest Binary Search Tree Value # Time complexity is O(h) ~ height of the tree ~ O(log n) # Space complexity is O(1) # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None import sys class Solution(ob...
94f6f9cc356c05e3168e5b01c7a05609aef56015
SueAli/cs-problems
/interviewbit/Construct_Binary_Tree_from_Postorder_and_Inorder.py
1,591
3.890625
4
# Definition for a binary tree node class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: # @param inorder : list of integers denoting inorder traversal # @param postorder : list of integers denoting postorder traversal # @return...
18d90e3c1e9138c795789c86753437859a6ee91e
SueAli/cs-problems
/LeetCode/Valid Sudoku.py
1,620
3.828125
4
# Valid Sudoku # hash table # time complexity is O(n*n) # Space complexity is O(n) class Solution(object): def isValidSudoku(self, board): """ :type board: List[List[str]] :rtype: bool """ rows = len(board) cols = len(board[0]) hash_t = set() # validat...
e8aea3c58e2ef0e6730583822754908db9fa88ee
SueAli/cs-problems
/LeetCode/Binary_Tree_Level_Order_Traversal.py
1,113
4.03125
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None from collections import deque class Solution(object): def levelOrder(self, root): """ :type root: TreeNode :rtype: List[...
c608aa8f7c85f079bb8a3677cb01ac5ab0bda860
SueAli/cs-problems
/LeetCode/Binary_Tree_Maximum_Path_Sum.py
913
3.9375
4
#Binary Tree Maximum Path Sum # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def __init__(self): self.max_sum = None # Anyting is greater than None def ma...
54b82f3d10fb2c83d82d2a9e8ac9fc663e16c354
SueAli/cs-problems
/interviewbit/Min_Depth_Binary_Tree.py
710
3.8125
4
# Definition for a binary tree node class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None import sys class Solution: # @param A : root node of tree # @return an integer ### Time Complexity is O(n) ### Space Complexity is O( log n) def min...
ef04a0cc9fb4171af273a63b93d333a6ae8ef4e2
SueAli/cs-problems
/LeetCode/Group_Anagrams.py
545
3.828125
4
# Group Anagrams # Given an array of strings, group anagrams together. class Solution(object): def groupAnagrams(self, strs): """ :type strs: List[str] :rtype: List[List[str]] Time complexity is O(n * m log m ) """ res =[] h = {} for s in strs: # O(...
63684c29733b77a4966191306181f0173ad86b54
SueAli/cs-problems
/interviewbit/Complexity/Flatten_Binary_Tree_to_Linked_List.py
1,034
3.96875
4
# Definition for a binary tree node # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: # @param A : root node of tree # @return the root node in the tree # Time Comlexity is O ( n log n ) # Space Complexity is O ...
b04dcc7c7406347d33c2359bd71e2ba1f51c8d8e
SueAli/cs-problems
/LeetCode/Judge Route Circle.py
523
3.546875
4
# Judge Route Circle class Solution(object): def judgeCircle(self, moves): """ :type moves: str :rtype: bool """ # Time Comp O( len(moves)) # Space Comp is O(1) x,y = 0,0 for m in moves: if m == "U": y += 1 eli...
0105e85d373118ae280f6c2f8abc50cd6c272cbf
SueAli/cs-problems
/LeetCode/Populating Next Right Pointers in Each Node.py
755
3.890625
4
# Populating Next Right Pointers in Each Node # Definition for binary tree with next pointer. # class TreeLinkNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None # self.next = None class Solution: # @param root, a tree link node # @return no...
ea2cb8a1a7ff0e404f61457d6faa178b46553035
SueAli/cs-problems
/UVA/11203 - Can you decide it for ME?.py
1,204
3.828125
4
def isTheorem(me_txt): front_symb = 0 mid_symb = 0 back_symb = 0 i = 0 while i < len(me_txt) and me_txt[i] != 'M': if me_txt[i] == '?': front_symb += 1 else: return "no-theorem" i += 1 if i == len(me_txt): # 'M' Not found return "no-theore...
80633ee891cecbe76c0ea7bbe34806d7b744b0d4
SueAli/cs-problems
/LeetCode/Hamming_Distance.py
353
3.5
4
from collections import Counter class Solution(object): def hammingDistance(self, x, y): """ :type x: int :type y: int :rtype: int """ z = x ^ y c = Counter(bin(z)) if '1' in c: return c['1'] else: return 0 s = Solutio...
72b212ed11de114e4f9c5f1a976f5700698f9c17
SueAli/cs-problems
/LeetCode/Binary_Tree_Preorder_Traversal_using_Stack.py
704
3.9375
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def preorderTraversal(self, root): """ :type root: TreeNode :rtype: List[int] Time Complexity is O(...
8ec6bc48465d8588a26069266f02ad823cd6295b
SueAli/cs-problems
/interviewbit/Knight_On_Chess_Board.py
1,377
3.625
4
#Knight movement on a chess board # https://www.interviewbit.com/problems/knight-on-chess-board/ from collections import deque class Solution: # @param N : integer # @param M : integer # @param x1 : integer # @param y1 : integer # @param x2 : integer # @param y2 : integer # @return an integer de...
015dbe2de2479551ad5e6a29b8f0b2d84d06c087
SueAli/cs-problems
/LeetCode/Majority_Element_Hashing.py
776
3.5625
4
import math class Solution(object): def majorityElement(self, nums): """ :type nums: List[int] :rtype: int Time Complexity = O(n) --> Time to loop on all hash_t elements Space Complexity = O(n) --> the worst case all input array elements will be unique """ has...
b628317a92ca1e4420d7c9d1b3c67a2122db3f77
ymu0117/programming
/cipher/cipher.py
256
3.515625
4
from abc import ABC, abstractmethod class Cipher(ABC): """ Base class for cryptocryphy """ def __init__(self): pass @abstractmethod def encrypt(self): pass @abstractmethod def decrypt(self): pass
e9e2ba63f1f84d4ea744d47e57d18eed811d2305
suraj-nair-1/HackerRankSolutions
/CountLuck.py
1,646
3.515625
4
# Enter your code here. Read input from STDIN. Print output to STDOUT def alg(forest, visited, current, finish, count, n, m): if(current == finish): return count, True i, j = current visited[current] = 1 options = {} options[(i,j+1)] = 1 options[(i,j-1)] = 1 options[(i+1,j)] = 1 ...
a2f717e7d5122359f4bc71c4f366db5a001fd57d
yehyafarhat/cmps205
/git3.py
582
3.90625
4
max = 1000 min = 1 number = int(input('please think of a number between {0} and {1}:'.format(min,max))) while True: guess = ((min+max)//2) print('is your number {0}?'.format(guess)) answer = str(input("enter 'yes' to i guessed correctly\n" "enter 'false to its more than the number ab...
13d7c249ec4d0b30ae9bade26e5422ca47f9d077
ZSL-1024/Python-Crash-Course
/chapter_02_variables & data types/numbers.py
219
3.59375
4
a = 3 ** 2 b = 10 ** 6 c = 2 + 3*4 d = (2 + 3) * 4 print(a) print(b) print(c) print(d) # Avoiding Type Errors with the str() Function age = 23 message = "Happy " + str(age) + "rd Birthday!" print(message)
8942563fcf7c02bc500eb391f466e08abf5e2a08
ZSL-1024/Python-Crash-Course
/chapter_08_functions/cars.py
483
3.53125
4
# 8-14 cars.py def make_car(manufacturer, model, **options): """Make a dictionary representing a car.""" car_dict = { 'manufacturer': manufacturer.title(), 'model': model.title(), } for option, value in options.items(): car_dict[option] = value return car_dict my_modelY = make_car('tesle', 'mo...