blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
b7a777c05fd37642a487677bad4542d064850dc1
MarcoASB/python-challenge
/PyPoll/poll_results.py
2,245
3.703125
4
# Import dependecies import pandas as pd data = pd.read_csv('Resources/election_data.csv') # A complete list of candidates who received votes def candidates (data): list_candidates = data.Candidate.unique() return list_candidates # Count and percentage of candidates def votes (data): data['Count'] = 1 ...
26a07246153352e984b2a9742c2d0390b53c9c2c
AlexKaracaoglu/Cryptography
/PS5/AKaracaoglu_HW5.py
10,813
3.90625
4
#Alex Karacaoglu #Crypto_HW5 #I completed problems 1,2,4,6,7,8 import conversions import euclid_etc #After using the hex(number) -> string method it puts '0x' at the front and 'L' #at the end because it is a long and in order to convert back to ASCII using the #conversions methods provided you need to have t...
95e792e1275a44e99bd4e7051d94b7776a3527e9
PrakashBorade022/PythonPrograms
/Programs to Understand the Control Structures of Python/sum of first n odd numbers.py
362
4.3125
4
# Python program to print sum of a first n odd numbers sum =0 n = int(input("Enter a value of n ")) for i in range(1,n+1): if i%2!=0: sum+=i print("Sum of first {} odd numbers = {}".format(n,sum)) # Test case 1 ''' Enter a value of n 5 Sum of first 5 odd numbers = 9 ''' # Test Case 2 ''' Enter a value of...
86c4d9b01511502c80cf77ce48c82173d0571fc2
Ivan-Voroshilov/1_lesson
/4.py
133
3.9375
4
x = int(input('Input number... ')) max = 0 while x >= max: x1 = x % 10 if x1 >= max: max = x1 x //= 10 print(max)
143574b59482dbb05d0834791ecc579f2073713f
glock3/Learning-
/Misha/Numbers/recursion_deuce_power.py
482
4.28125
4
def calculate_division_by_two(number): if number == 1: print('Entered number is a power of 2.') elif number % 2 == 0: number = number / 2 calculate_division_by_two(number) else: print('Entered number is NOT a power of 2.') def main(): print('This program define, if ente...
ca4b85c06aa1b1aa5aa9419b6f7a9511f73e6ac4
AxelPuig/The_Rene_Project
/rene/talker/__init__.py
4,119
3.515625
4
import os import platform class Talker: """ Makes the raspberry talk """ def __init__(self): self.hello_said = [] self.hello_in_process = {} self.nobody_rate = 0 self.time_since_last_action = 0 def inform_preparing(self): rene_parle("Salut a vous les copains ! Je m...
a73f26e22bb28f99b336dc73d019d03cd3c9d14a
CodePracticeComputerScience/ProjectReportsOfResume
/pwMan-template_edited.py
4,870
3.71875
4
# KuntalPatel #11/14/2019 # This program stores passwords in a file # that is encrypted with a master password # # system packages: gcc libffi-devel python-devel openssl-devel # python packages: pycryptodome # references: # 1. https://stackoverflow.com/questions/19232011/convert-dictionary-to-bytes-an...
de3a044a9cc5e7734b7fc6ed1cdf084b55c585f5
liruileay/data_structure_in_python
/data_structure_python/question/chapter1_stack_queue_question/question1.py
1,129
3.984375
4
from development.chapter6.ArrayQueue import Empty class Stack(object): """设计一个基于列表的栈这个栈具有getMin功能""" def __init__(self): self._data = [] self._help = [] def __len__(self): """获取栈中元素的个数""" return len(self._data) def is_empty(self): """判断栈中元素是否为空""" return len(self._data) == 0 def push(self, v)...
6875bc546b723a30bcb2f5e98d400d414ddd1d50
cswizard11/lambda
/unit_3/sprint_1_lambdata-cswizard11/sprint_challenge/acme_report.py
1,454
3.71875
4
from random import randint, sample, uniform from acme import Product # Useful to use with random.sample to generate names ADJECTIVES = ['Awesome', 'Shiny', 'Impressive', 'Portable', 'Improved'] NOUNS = ['Anvil', 'Catapult', 'Disguise', 'Mousetrap', '???'] def generate_products(num_products=30): products = [Pr...
79bf4dfe89d15e192f3b6af0c0fd5a19c0d0e33f
bedros-bzdigian/intro-to-python
/week3/pratical/lists/problem3.py
308
3.875
4
import argparse parser = argparse.ArgumentParser() parser.add_argument("number", help="display a cube of a given number", type=int) args = parser.parse_args() list2 = [0 , 'hi' , 2 , 100 ,300 , 2] x = list2.count(args.number) print ("list2: " , list2) print ("the number of using this number is: " , x)
937e9794c08a886c46d17b0bf4ac2ef8398e51a7
kanmani-kamalanathan/Kattis-Solutions
/No Duplicates/nodup.py
77
3.5625
4
print('yes' if (lambda z: len(z) == len(set(z)))(input().split()) else 'no')
7804844bab670497f42d06f061c479cc6d91ed13
rockingrohit9639/pythonBasics
/classes.py
299
3.578125
4
class Students: def print_details(self): print(f"Name : {self.name}\nRoll No : {self.roll_no}\nSection : {self.sec}") std1 = Students() std1.name = input("Enter name of student : ") std1.roll_no = input("Enter roll no : ") std1.sec = input("Enter section : ") std1.print_details()
6745f7d639da66708ce7b2ea4e1b0177af6e76ef
CJLucido/Intro-Python-I
/src/14_cal.py
2,566
4.625
5
""" The Python standard library's 'calendar' module allows you to render a calendar to your terminal. https://docs.python.org/3.6/library/calendar.html Write a program that accepts user input of the form `14_cal.py [month] [year]` and does the following: - If the user doesn't specify any input, your program should ...
64e51192f10b196a58ef5cbbdaacaf99cbf901f4
geronimo0630/2021
/clases/juego2.py
1,317
4
4
import random #---entradas---# mensaje_saludo = 'juguemos!' pregunta_introduccion = ''' en este juego debes acertar un numero que va desde el 1 al 10!!! puedes intentarlo antes que se te acaben las vidas!!! ingresa tu numero: ''' pregunta_dificultad =...
184f9b4b2995fd8078c10440192e62f5279a391a
RoseGreene/Homework
/years100.py
165
3.96875
4
name = input("Enter your name: ") age = int(input("Enter your age: ")) old = 100 - age print(name + "," + " after " + str(old) + " years you will be 100 years old!")
9094047497cfd16e27ae34fdf5b03fcc6823c335
FabricioGalvani/data-engineering
/etl.py
3,445
3.65625
4
from openpyxl import load_workbook import xlsxwriter import csv def load_csv_files(input_file): ''' Function to load the csv files. Parameters: input_file (str): File input. Returns: file (obj): The csv file. ''' with open(input_file, encoding='utf-8') as csvfile: ...
41b2e4e0d08dc15f31431d107c91bffb4745e3f2
yeehaoo/mini-projects
/bank.py
1,165
3.65625
4
import tkinter as tk class Root(tk.Tk): def __init__(self): super().__init__() self.balance = 100 self.frame = tk.Frame(self) self.frame.pack() self.label_1 = tk.Label(self.frame,text="Bank Account") self.label_1.pack() self.lblAmount = ...
76a0bf2b11c1fc18714630bbd720f56469eca66c
robingarbo/DOTfiles
/bin/group
1,240
3.71875
4
#!/usr/bin/python import sys, os, getopt def usage(): print("group inputs to NUM fileds per line, joined by \" \" ") print("group NUM") print("group NUM <arg1> <arg2> ... ") if __name__ == '__main__': if (len(sys.argv)<2): usage() sys.exit(1) opt, args = getopt.getopt(sys.argv[1:],...
30d3502ddf188b01078071871cd8d3370928bdf4
eclipse-ib/Software-University-Fundamentals_Module
/14-Retake_Exams/Mid_Exam_Retake-10_December_2019/01-Disneyland_Journey.py
489
3.65625
4
journey_cost = float(input()) months = int(input()) saved_money = 0 for i in range(1, months+1): if i % 2 != 0 and i != 1: saved_money = saved_money * 0.84 if i % 4 == 0: saved_money = saved_money * 1.25 saved_money += journey_cost / 4 diff = abs(journey_cost - saved_money) if saved_mo...
17f7c7ab35a9bb71e7261cd6fa8a8233c22b4a9a
jinsookim/iitp18-hyu-bigdata
/section-A/source/proj06_control/p6_s13.py
316
3.78125
4
num_a = 100 num_b = 200 if num_a > num_b: print('숫자A가 더 큰수입니다.') max = num_a elif num_a < num_b: print('숫자B가 더큰수입니다.') max = num_b else: print('숫자A와 숫자B는 같습니다.') print('숫자A와 숫자B중 최대값은', max, '입니다.')
db8af07dbf5f6f4dca65caa427d61e8da1574ee9
ilkerkesen/euler
/source/040.py
329
3.65625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- LIMIT = 1000000 def main(): frac = "" i = 1 while len(frac) <= LIMIT: frac += str(i) i += 1 result, i = 1, 1 while i <= LIMIT: result *= int(frac[i-1]) i *= 10 print result if __name__ == "__main__": ...
d003d9a5417cc96025328c586393fa0bb7596da6
Ahmed-Boughdiri/Python-Math
/compose.py
1,300
3.53125
4
class Compose: def __init__(self,equation): self.equation = equation def start(self): result = [] operations = { "+": "PLUS", "-": "MIN", "*": "MULT", "/": "DIV" } start_char = 0 end_char = -1 while(end_char...
b898301c1100a38420864823c58546865b25b9f3
ananiastnj/PythonLearnings
/LearningPrograms/Generator_Iterator.py
875
3.828125
4
'''for i in [1,2,3,4]: print(i) for c in "Antony": print(c) for d in {"x" : 1, "y" : 2}: print(d) for line in open("Test.txt"): print(line) ''' ''' # Example 1 x = iter([1,2,3,4]) print(x) print(x.__next__()) print(x.__next__()) ''' ''' #Example 2 : Iterator class yrange: def __init__(self,n): self.i = 0 ...
1c9aeea69b0068d3bbc9245ec004c0aebb631d7c
Omkar02/FAANG
/RemoveDupFromSortedArray.py
1,264
3.890625
4
import __main__ as main from Helper.TimerLogger import CodeTimeLogging fileName = main.__file__ fileName = fileName.split('\\')[-1] CodeTimeLogging(Flag='F', filename=fileName, Tag='Array') ''' Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length. ...
c021c716f2cb5d8e666c3ab5be7c0b84c9486641
danielleappel/Python-Tutorial
/Code/fern_iterative.py
1,044
3.78125
4
import matplotlib as mpl import matplotlib.pyplot as plt import numpy as np import random def fern_call(n): """Generates a fern fractal iteritavely. Keyword arguments: n -- the number of iterations """ v = ([0,0]) # Start at the origin. plt.plot(v[0],v[1],'go', alpha = 0.3) plt.title("Fer...
e306e71782d870b494d05fb4576e5341bac4b8d9
TJBos/CS-Algorithms
/algo_foundations/other_algos/filtering_hashtables.py
593
3.9375
4
#reducing duplicates from a list by turning in a hashtable items = ["apple", "pear", "banana", "orange", "banana", "grape", "pear"] filter = dict() for item in items: filter[item] = 0 result = set(filter.keys()) #print(result) #I think in JS you can just make a Tuple out of an array and convert back to array....
5750f5a4d509fb2bf625cff9f6d07ab0fbd9480a
dyjae/LeetCodeLearn
/python/hot100/46.Permutations.py
3,060
3.859375
4
#!/usr/local/bin/python3 # -*- coding: utf-8 -*- __author__ = 'Jae' from typing import List class Permutations: # 函数 def permute4(self, nums: List[int]) -> List[List[int]]: from itertools import permutations return permutations(nums) # https://leetcode.com/problems/permutations/ # ...
33b733cdadf5f0bffcf42b89aa37f5d8566cb8da
FrankUSA2015/jianzhiOffice
/32-3.py
1,028
3.640625
4
# -*- coding: utf-8 -*- #这个题的精妙所在有两点,第一点用双端队列的知识。第二点用了res来判断奇偶。 import collections class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def levelOrder(self, root: TreeNode) -> [[int]]: if not root: return [] r...
36685782a0e2d6c2c21bf97385142e10c4eb95a1
ejm2095/practice
/utils.py
398
3.53125
4
__author__ = 'undergroundskier' def factors(n): fact=[1,n] check=2 rootn=n**.5 while check<rootn: if n%check==0: fact.append(check) fact.append(n/check) check+=1 if rootn==check: fact.append(check) fact.sort() return fact def largest(lst):...
b77a8e0314ed649bfb5ba40aa5469b6f82b27e41
KYBee/DataStructure
/assignment2/assignment02_01_cal.py
4,198
3.859375
4
class Stack: def __init__(self): self.items = [] self.top = -1 def push(self, val): self.items.append(val) def pop(self): try: return self.items.pop() except IndexError: print("Stack is empty") def top(self): try: re...
fba419edc5054d87aa2fc8ccdeb82e06375f3f86
Greatbar/Python_Labs
/10_1.py
92
3.546875
4
s = str(input()) n = int(input()) print(s[n - 1] if 0 < n <= len(s) else 'ОШИБКА')
203ec0810426ac272f1483f50b50b4d437b086ba
larkaa/project_euler
/question17.py
2,321
3.921875
4
#!/usr/bin/env python3 #question 17 # count the number of letters in the numbers 1 to 1000 # format # one hundred and thirty one digits_str = ['','one','two','three','four','five','six','seven','eight','nine'] teens_str = ['ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','ninet...
6b6f948b442e09c04b243baa184541471cb829d3
Faraday1221/project_euler
/problem_1.py
477
4.1875
4
#If we list all the natural numbers below 10 that are multiples of 3 or 5, we #get 3, 5, 6 and 9. The sum of these multiples is 23. #Find the sum of all the multiples of 3 or 5 below 1000. ##solution using a for loop y=0 for i in range(1,1000): if i%3 ==0 or i%5==0: # print 'i is equal to', i y += ...
37f02c4606514931ad7a5ca7e6ddd9282ef659d0
TGathman/Codewars
/5 kyu/Simple Pig Latin/Simple Pig Latin.py
164
3.703125
4
# Python 3.8, 20 march 2020 def pig_it(text): punc = ["!", ".", "?"] return " ".join(i[1:] + i[0] + "ay" if i not in punc else i for i in text.split())
3efd1aba802a2d12c5edb649d28e243c4b39772b
kingsamchen/Eureka
/crack-data-structures-and-algorithms/leetcode/plus_one_linked_list_q369.py
932
3.65625
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None # 核心思路 # 这题是 add_two_numbers_II_q445.py 的特例版本,做法更简单 # 另,这题没说不能修改原链表,所以可以先reverse,变成低位在前 # 处理之后再 reverse 回去 class Solution(object): def plusOne(self, head): """ :type...
195eb2d55248246faafa8057a16f299eb32fe69a
bgoonz/UsefulResourceRepo2.0
/_REPO/MICROSOFT/c9-python-getting-started/python-for-beginners/13_-_Functions/print_time_with_message_parameter.py
593
4.1875
4
from datetime import datetime # Define a function to print the current time and task name # Function the following parameters: # task_name: Name of the task to display to output screen def print_time(task_name): print(task_name) print(datetime.now()) print() first_name = "Susan" # Call print_time() fun...
4793d7af2f152a0f691a07033ff969e840b8fbb2
hilalhusain/waterjugproblem
/waterjugprob.py
717
3.78125
4
jug1 = int(input("Small Jug Capacity: ")) jug2 = int(input("Large Jug Capacity: ")) amt1 = int(input("water present in small jug, J1: ")) amt2 = int(input("water present in large jug, J2: ")) t = int(input("Final in Large Jug: " )) #jug1 = 3 #jug2 = 5 #t = 1 def jugSolver(amt1, amt2): print(amt1,...
c003bbee5f5301bcb3dfc3c617d0ab13f8c2a22a
nageshwarbr/PersonalProjects
/healthyProgrammer/healthy_programmer.py
1,901
3.515625
4
# Healthy Programmer # 9am - 5pm # Water - water.mp3 (3.5 litres) - Drank - log - Every 40 min # Eyes - eyes.mp3 - every 30 min - EyDone - log - Every 30 min # Physical activity - physical.mp3 every - 45 min - ExDone - log # Rules # Pygame module to play audio from pygame import mixer from datetime import datetime fro...
b18ac0d8aa4856d2f7dddc44e1d74dee6b3ab7c6
YizhuZhan/python-study
/map&reduce&filter.py
709
3.640625
4
# -*- coding:utf-8 -*- import math import functools def add(x, y, _f): return _f(x) + _f(y) print(add(25, 9, math.sqrt)) def format_name(s): return s[0].upper() + s[1:].lower() print(list(map(format_name, ['adam', 'LISA', 'barT']))) def f(x, y): return x + y print(functools.reduce(f, [1, 3, 5, 7, 9]))...
f8c8012d19d57bddea61f43ee000c1003c0a8f15
UX404/NeuralNetwork-Numpy
/Layer.py
1,049
3.65625
4
import numpy as np class Linear(): def __init__(self, input_num, output_num): self.weights = (np.random.rand(input_num, output_num) - 0.5) / 10 # [-0.05, 0.05] self.bias = np.ones((1, output_num)) # 1 self.x = None self.m = None self.y = None def forward(s...
3b89ba49d0ff4a720956a4cb69f69df147f5fff8
davidally/IS211_Assignment1
/assignment1_part2.py
1,091
4.53125
5
#!/usr/bin/env python # -*- coding: utf-8 -*- """Assignment 1 - Part 2""" class Book(object): """This class creates a book. Attributes: attr1 (str): The title of the book. attr2 (str): The author of the book. """ title = '' author = '' def __init__(self, title, author): ...
0bb1dd2919f33772aefa4cd06461a11affe57143
AndongWen/leetcode
/数据结构/树/0066convertBST.py
1,035
3.90625
4
'''538把二叉搜索树转换为累加树 给定一个二叉搜索树(Binary Search Tree),把它转换成为累加树(Greater Tree),使得每个节点的值是原来的节点值加上所有大于它的节点值之和。''' '''思路:中序遍历,先遍历右子树''' class Solution: def convertBST(self, root: TreeNode) -> TreeNode: sum = 0 q = coll.deque() cur = root while cur or q: while cur: ...
89756e4d05c4c6ec175e13bd64a8da15fa9ea20e
lcx94/python_daily
/data_structure/2020-04/20200416/path_sum.py
1,086
4.1875
4
# -*- coding: utf-8 -*- """ --------------------------------- File Name: path_sum Description: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. Given the below binary tree and sum = 22, 5 / \ 4 8 / ...
67288610691403d7bec2e4eefe07da06a94461b4
tobyt99/pythoncolt
/functions.py
2,225
4.15625
4
# exercise 44 # def return_day(day): # days = { # 1 : "Sunday", # 2 : "Monday", # 3 : "Tuesday", # 4 : "Wednesday", # 5 : "Thursday", # 6 : "Friday", # 7 : "Saturday" # } # if day in days: # return days[day] # return None # return_day(5) ...
0c919b071db1faaceaed4d0597b126cc876dc111
Nakarp/Python
/Calculator/main.py
614
3.890625
4
import re print(" ") print("Calculator 2000") print("Type 'exit' to exit\n") previous = 0 run = True def math_equation(): global run global previous equation = "" if previous == 0: equation = input("Enter equation:") else: equation = input(str(previous)) if equation == "...
df479415001b9deac5fd94b60fad7e978317b576
shermannatrix/python-dev
/Python AIO/Book 2 (CH3) Lists_Tuples/sets_basics.py
422
3.640625
4
sample_set = {1.98, 98.9, 74.95, 2.5, 1, 16.3} sample_set.add(11.23) # Adding items to the set sample_set.update([88, 123.45, 2.98]) print(f"Updated set: {sample_set}") # Make a copy and show the copy ss2 = sample_set.copy() print(ss2) # Loop through the set and print each item right-aligned and formatted print("\...
eee7f2412c349b86781ff357c96dd1c674fa9365
EwertonBar/CursoemVideo_Python
/mundo01/desafios/desafio031.py
258
3.546875
4
dist=float(input('Qual a distância da sua viagem? ')) if dist <= 200: print('O preço da sua passagem será {} reais. Tarifa: R$0.50.'.format(dist*0.5)) else: print('O preço da sua passagem será {} reais. Tarifa: R$ 0.45.'.format(dist*0.45))
448559a0ad1c98ec36b563d1c6ba8bd6e1b64051
bihtert/second
/Histogram of Frequencies.py
219
4.03125
4
#Histogram of Frequencies n = int(input("Number of Frequency:")) freq = [] for i in range(1,n+1): f = int(input("Enter frequency %s" %i)) freq.append(f) for i in range(n): print(freq[i], ":" , freq[i]*"*")
e295d0f90daa2c6622436bea363e39fdedc30231
mevol/python_topaz3
/topaz3/train_test_split.py
8,293
3.5625
4
""" Script to split a directory into training and testing samples. Can take a directory filled with subdirectories (which should all be equal) or a directory of similar files (same extension). Copies the test samples to the test directory provided and then deletes them from the original location. """ import argparse...
ac28cbc95a4faabc5b5d816c451d98bffe43cee4
simrankaurkhaira1467/Training-with-Acadview
/assignment9.py
3,482
4.3125
4
#ASSIGNMENT ON CLASSES #question 1: Create a circle class and initialize it with radius. Make two methods getArea and getCircumference inside this class. class Circle(): def __init__(self, radius): self.radius=radius def getArea(self): print("Area is : " + str(3.14 * self.radius * self.r...
8043f03708063ede50be2f30a08a1cecdae3816a
jojojames/Python
/mergeList.py
1,320
3.609375
4
def mergeList(aList, bList): """@todo: Docstring for mergeList. :aList: @todo :bList: @todo :returns: @todo """ aIndex = 0 bIndex = 0 aLen = len(aList) bLen = len(bList) mergedList = [] while aIndex != aLen and bIndex != bLen: if aList[aIndex] < bList[bIndex]: ...
e688daaf5690251e18be02ee121826bb81f35298
han-shang/AID2018
/thread02.py
460
3.78125
4
from threading import Thread from threading import Lock lock1 = Lock() lock2 = Lock() def print_numbers(): for i in range(1,53,2): lock1.acquire() print(i) print(i+1) lock2.release() def print_abc(): for i in range(65,91): lock2.acquire() print(chr(i)) ...
ae6ec8ad898a16dd4aaf6144590046097123c231
vyaswanth965/Parent-reports
/Parent_reports_process/launch_instances.py
750
3.53125
4
# -*- coding: utf-8 -*- """ Created on Fri Jun 12 14:02:41 2020 @author: EILAP6621 auto launch EC2 instance """ import boto3 aws_access_key_id= 'AKIA4TXJH6XFLQANY3FQ' aws_secret_access_key= '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' ec2 = boto3.resource('ec2',region_name='ap-south-1',aws_access_key_id=...
11984873882273abd211f61c6d5bd4420f6672ea
Ovidiu2004/rezolvarea-problemelor-if-while-for
/if_while_for_8.py
475
3.875
4
a=eval(input("a = ")) b=eval(input("b = ")) c=eval(input("c = ")) if (a>0 and b>0 and c>0): if ((a<b+c) and (b<a+c) and (c<a+b)): if ((a==b==c)): print ("triunghi echilateral") if (((a==b) and (a!=c)) or ((b==c) and (b!=a)) or ((a==c) and (a!=b))): print ("triunghi is...
7d93fa640bc47ca903e47c19038dd34a5cc616db
kyleetaan/git-pythonmasterclass
/src/basics/sets.py
421
3.90625
4
# farm_animals = {"sheep", "cows", "chickens"} # for animal in farm_animals: # print(animal) # print("=" * 40) # farm_animals.add("jobert") # print(farm_animals) even = set(range(0, 40, 2)) print(even) print(len(even)) print() squares = {1, 4, 9, 16, 25} print(squares) print(len(squares)) print() print(even.un...
c9dd13cdf272967325f62d536eef68ff385be3bf
twaun95/Algorithm
/이진트리/BnSearch_1.py
737
3.859375
4
#리스트 내에서 원하는 원소의 위치 찾기 #이진탐색 #재귀함수 def binary_search(array, target, start, end): #원소가 존재하지 않을 때 start와 end 가 교차한 순간 if end < start: return None #중간값을 구하고 소숫점 내림 mid = (end + start) // 2 if target == array[mid]: return mid+1 elif target > array[mid]: return binary_search(array, target, mid + 1,...
c8225a2c3803ec07acec492c44775abd439c62bb
ConradKilroy/DataJoy_Python
/3DLinePlot.py
2,037
3.796875
4
# First the required libraries are imported: # * `Axes3D` allows adding 3d objects to a 2d matplotlib plot. # * The `rcPArams` method to customize the legend font size. # * The `pyplot` submodule from the **matplotlib** library, a python 2D # plotting library which produces publication quality figures. # * The `numpy...
7c45fa33d85577d89244433b86887d3e18199329
nima1367/Test---VolumeCalculator
/VolumeCalculator/Face.py
953
3.765625
4
import numpy as np import math class Face: """ Constructor of the Face class""" def __init__(self, vertices): """ NormalFinder function finds the normal vector of the given polygonal face (the result is not normalizd) """ def NormalFinder(vertices): edge1 = np....
7a6c53c12700a536c3c02f3269d92c35459be5a0
RickyL-2000/python-learning
/business/方方/作业3/problem3.py
643
3.515625
4
import random print("作业5:统计分数出现次数") scores = [] for i in range(1000): scores.append(random.randint(0, 100)) counter = {} for score in scores: if score in counter: counter[score] += 1 else: counter[score] = 1 counter = sorted(counter.items(), key=lambda x: x[1], reverse=True) for item in coun...
d4fa47260d7f656cff1aff15d34c6c71740df069
Ania9/dip_example
/dip_29-135/e4_22.py
91
3.578125
4
def f(x): return x*2 print f(4) g= lambda x: x*2 print g(4) print (lambda x: x*2)(4)
cbaeda882d6c8137a2540923f7d8294ccb4fd13a
edprince/uni
/210/old-lab/substring.py
307
3.765625
4
def substring(s, b, l): return s[0:b] + s[b+l:len(s)] userString = raw_input('Please enter a string: ') startSplice = int(input('Please enter the index of start of substring: ')) spliceLength = int(input('Enter the length of the splice sub: ')) print(substring(userString, startSplice, spliceLength))
63e1f1b2681e962c6604f5bd1560e8708a393e79
vekergu/ops_doc
/learn_python/python练习100题/071-input-output.py
1,145
3.734375
4
#!/usr/bin/env python #-*- coding: utf-8 -*- #============================================================================= # FileName: # Desc: # Author: 白开水 # Email: vekergu@163.com # HomePage: https://github.com/vekergu # Version: 0.0.1 # LastChange: # History: #=============...
b9f100619beb5f5db1ac24aa21e495c92699f406
xw0220/pythoncourse
/experiment4/test6.py
196
3.859375
4
n=input("please input an integer:") n=int(n) factor=1 i=1 while i<=n: print('{}*{}={}'.format(factor,i,factor*i)) factor=factor*i i=i+1 print("the factor is:",factor) print("baihu")
0a45ba854255bc83f24db180e117fd7305ee9132
DroogieDroog/pirple_python_is_easy
/hw8/main.py
4,298
4.34375
4
""" pirple/python/hw8/main.py Homework Assignment #8 Create a note-taking program that allows you to do the following to files of notes: 1) Create a new one 2) Read one 3) Replace one completely 4) Append to one 5) Replace a single line in one """ import os.path as path def create_new_file(new_f...
1e01c4af189960135a4eb8f9b31b3ba06882f373
chungtseng/rosalind-1
/code/GreedySort.py
891
3.671875
4
import sys import os def flip(array, num): ind = [abs(el) for el in array].index(num) reverse = [-el for el in array[num - 1:ind + 1][::-1]] return array[:num - 1] + reverse + array[ind + 1:] def perm_print(permutation): print '(%s)' % ' '.join(str(el) if el < 0 else '+' + str(el) for el in permutat...
e64a87a732480b36eab9b59e11021f7122afec2d
UWPCE-PythonCert-ClassRepos/Self_Paced-Online
/students/nDruP/lesson03/mailroom.py
4,267
4.25
4
#!/usr/bin/env python3 """ 1. Create Data structure that holds Donor, Donation Amount. 2. Prompt user to Send a Thank You, Create a Report, or quit. 3. At any point, the user should be able to quit their current task and return to the original prompt 4. From the original prompt, the user should be able to quit the scip...
3b05728bbd3a045acf0f742803d867ce2f2de374
green-fox-academy/marijanka
/week-4/Monday/double.py
79
3.609375
4
af = 123 def double(number): return number * 2 af = double(af) print(af)
01c18b4421a46a91e48eb94b585143253d93a9da
lollipopnougat/AlgorithmLearning
/力扣习题/208实现 Trie (前缀树)/problems.py
1,154
3.890625
4
class Node: def __init__(self, v: str, end = False): self.value = v self.child = {} self.end = end class Trie: def __init__(self): self.root = Node(None) def insert(self, word: str) -> None: p = self.root l = len(word) i = -1 for i in range(...
ee6dcd67c8e2749602919d82a72ffa774c1608d4
sh2268411762/Python_Three
/SXB/venv/函数/函数的定义.py
614
4.03125
4
# 例 6-1 def sayHello(): # 函数定义 print("Hello World!") # 函数体 sayHello() # 函数调用 # 例 6-2 def sayHello1(s): # 函数定义 print(s) # 函数体 sayHello1("Hello!") # 函数调用 sayHello1("How are you?") # 例 6-3 def fac(num): if num == 1: return 1 elif num < 1: return 0 else: ret = 1 ...
816bbba05e41fddc8c2cc7068ec0ad0b5652e8e8
jollywing/jolly-code-snippets
/algorithm/insertion_sort.py
688
4.09375
4
# Knowledges: # insertion # function define # for loop # range() # if statement # swap 2 objects # print def insertion_sort(a): for i in range(1, len(a)): for j in range(i, 0, -1): if a[j] < a[j-1]: t = a[j] a[j] = a[j-1] a[j-1] = t ...
3878351a762f5b47a3e40b93b290cfc95583f914
Mahadevan007/myrepository
/noofnumeric.py
103
3.8125
4
string = input() count = 0 for i in string: if i.isdigit(): count = count + 1 print(count)
ea36a9c0396673b92f5e09b174db83b6c4a3af18
nicosoncin/ThisIsCodingTest
/Binary Search/7-7.py
220
3.546875
4
n = int(input()) array = set(map(int, input().split())) m = int(input()) targets = list(map(int, input().split())) for target in targets: if target in array: print('yes', end=' ') else: print('no', end=' ')
05c209d39842b010e5ba4a965d472f3fdf210317
PragayanParamitaMohapatra/Basic_python
/MCQ/replace.py
36
3.671875
4
a="ABCD" print(a.replace("AC","XY"))
531f8d1ba3c0ca9dd434bf95e66eff5e26785746
GriszaKaramazow/codewars-python
/6kyu - Write Number in Expanded Form.py
925
4.1875
4
# You will be given a number and you will need to return it as a string in Expanded Form. For example: # # expanded_form(12) # Should return '10 + 2' # expanded_form(42) # Should return '40 + 2' # expanded_form(70304) # Should return '70000 + 300 + 4' # NOTE: All numbers will be whole numbers greater than 0. ...
02fc6d4408a665b388ed5354e261aa4adda635c3
sammycosta/uri-python
/uri_2927.py
518
3.5625
4
# URI Online Judge | 2927 #A -> alunos \\ C -> computadores \\ X -> pc queimados por Caio \\ Y -> pc sem compilador # nome: Samantha Costa A, C, X, Y = [int(x) for x in input().split()] pcs_disponiveis = C - (X+Y) - 1 #-1 é o pc que o prof vai usar. resultado = 'default' if 0 < A and Y and X <= C <= 1000: if pcs_di...
fa18256c47c366ae913db23c79da48a6d923d052
chrido/i13monclient
/dto/temphdatatypes.py
1,914
3.671875
4
import uuid class TempHumidityMeasurements: """ This class represents a measurement from temperature humidity sensor default Node: 19, 22, 23, 24 """ def __init__(self, ts, temp, temp_external, humidity, battery): """ :param ts: timestamp in the format of datetime.now() :param temp: float representing me...
d7359f7e8d8a422bfb827f481c1d12e538a69f09
masci/playground
/cstutoring/003.py
633
3.78125
4
""" If there are 3 people in a room, the probability of two of those people having THE SAME birthday is 0.008. For 4 people, it is 0.016 and for 5 people, it is 0.027. Using the same rule of at least two people in a room of size 25, what is the probability (rounded to the nearest 1000th) of two people having THE SAME B...
8511bb25ad9766ad356ae8c21c28e9d094eeafcc
sahilganguly/pynet_test
/exercise17.py
310
3.65625
4
#!/usr/bin/env python def Function(x, y, z=20): return (x + y + z); print "Sum: {}".format(Function(1, 5, 10)) print "Sum: {}".format(Function(x=1, y=5)) print "Sum: {}".format(Function(1, y=5, z=20)) print "Sum: {}".format(Function('I', 'am', 'Groot')) print "Sum: {}".format(Function([1], [5], [100]))
35850b5230d9e5274648b749f5902fe894980a67
amymhaddad/cs_and_programming_using_python
/week3_exercises/how_many_ex.py
290
3.75
4
animals = { 'a': ['aardvark'], 'b': ['baboon'], 'c': ['coati'], 'd': ['donkey', 'dog', 'dingo'], } def how_many(aDict): count = 0 for anim in animals: len_values = len(animals[anim]) count += len_values return count print(how_many(animals))
3c392d9426baefac70db93a3c090dbcdd7e37f34
kehsan/python-games-2014
/pong.py
7,030
4.125
4
# Implementation of classic arcade game Pong ###### The program should be loaded on to #### ###### http://www.codeskulptor.org/ to be able to run #### ## The classic Ping-pong video game from the 70s ## Up and Down Arrow for the right player to move the ...
0b6772f72e55f1eaf0671a9a21c75cd1b398cd55
infexorg/jetstream
/jetstream/calc.py
1,184
3.984375
4
def pathcalc_om(om1, om2, om3, omd): """Calculate the path required to reach a target by anchoring waypoints on orbital markers. Args: om1 (float): Distance in km of closest OM to target. om2 (float): Distance in km of 2nd closest OM to target. om3 (float): Distance in km of 3rd clo...
4ced180a7d4839d8604b0ea2546d1dff6e59942c
josecbm/2PracticaJunio2017_201504231
/cola.py
951
3.515625
4
import pila class nodoLista(object): """docstring for listaCola""" def __init__(self,dato): self.dato =dato self.siguiente = None self.aux = None class listaCola(): global listapila listapila = pila.pila() def __init__(self): self.cabeza = None def add(self , dato): nuevoNodo = nodoLista(dato) i...
a4855e912a3de2795e5395de645a21b765e5837c
erdaibi/niubi
/add_commodity.py
1,303
3.546875
4
class CommodityModel: def __init__(self, cid, name, price): self.cid = cid self.name = name self.price = price class CommodityView: def __init__(self): self.controlle = CommodityController() def display_menu(self): print("1) 获取商品信息") print("2) 显示商品信息") ...
53b78c98709d6eac8ac2211beb79353657779cfd
15194779206/practice_tests
/education/A:pythonBase_danei/4:阶段项目/A-Days/2.1:.py
998
4.03125
4
""" 练习2:为两个已有功能(存款取款),添加新功能 """ def func_dition(func): def wapper(*args): print("验证账户") return func(*args) return wapper @func_dition def deposit(money): print("存款",money) def withdraw(): print("取钱") return 10000 deposit(5000) """ 练习3:为学生的学习方法,添加新功能(统计执行时间) ...
9f1818f931bccd2c4b6846c244431babb75f9a42
lizcarey13/cs61a
/practice/summation.py
276
4.03125
4
def summation(term, n): i, total = 1, 0 while i <= n: total += term(i) i += 1 return total def square(x): return x * x def sum_squares(n): i, total = 1, 0 while i <= n: total += square(i) i += 1 return total """Sum the first n powers of two >>>summation()
a4942b24f13460eba24253377950c54b07dbb949
thomas-li-sjtu/Sword_Point_Offer
/JZ17_Has sub tree/solution.py
1,410
3.78125
4
# -*- coding:utf-8 -*- # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def HasSubtree(self, pRoot1, pRoot2): # write code here if not pRoot1 or not pRoot2: return False tree1 = [pRoot1] ...
625e9e48496d3da1d8f042ddd794c30fe07c81dd
devLorran/Python
/ex0091.py
670
3.71875
4
'''Crie um programa onde 4 jogadores joguem um dado e tenham resultados aletórios. Guarde esses resultados em um dicionário. No final coloque esse dicionário em ordem, sabendo que o vencedor tirou o maior número no dado''' from random import randint from time import sleep from operator import itemgetter dado ...
a52a12b6de0070c0c52c100ed6eff59e1e52bccd
dilipRathoreRepo/data_structures
/recursion/word_split.py
430
3.59375
4
# word_split('themanran',['the','ran','man']) def word_split(phrase, list_of_words, output=None): if output is None: output = [] for word in list_of_words: if phrase.startswith(word): output.append(word) word_split(phrase[len(word):], list_of_words, output) return ...
dd96001a6221c2692c84521dc6dfe1572e5a3698
dudrbs703/codeup-python-100
/print_6070.py
269
4
4
# print_6070.py a = int(input()) if (a is 12) or (a is 1) or (a is 2): print("winter") elif (a is 3) or (a is 4) or (a is 5): print("spring") elif (a is 6) or (a is 7) or (a is 8): print("summer") elif (a is 9) or (a is 10) or (a is 1): print("fall")
d9988fbbde144f45fdbeb8a20c09b61afcb77db9
jddelia/algos_and_ds
/Section5/seclectionSort.py
566
3.984375
4
#! /usr/bin/python3 # This program implements a selection sort. import math def selection_sort(lst): new_lst = [] lowest = math.inf for passnum in range(len(lst)): for i in lst: if i in new_lst: if new_lst.count(i) == lst.count(i): continue ...
6b8d17fdddcdc6d868d402ae5516245092aba6c6
Harrywekesa/Animal-game
/turtlegraphics.py
1,829
4.21875
4
import turtle as t def rectangle(horizontal, vertical, color): t.pendown() t.pensize(1) t.color(color) t.begin_fill() #This for looop draws a rectangle for _ in range(1, 3): #this range function maks the loop run twice t.forward(horizontal) t.right(90) t.forward(vertica...
931c6dfe8e1d170598ed91646ad970aca8182607
rohan-thomas/Coding-Problems
/ValidAnagram.py
468
3.5
4
class Rohan(object): def isAnagram(self,s, t): maps = {} mapt = {} for c in s: maps[c] = maps.get(c,0)+1 for c in t: mapt[c] = mapt.get(c,0)+1 if maps == mapt: print("true") else: ...
a5a34ca8b1c1547daee21ab9092f118668fee04a
anster01/Routing_App
/dijkstra.py
1,136
3.6875
4
def dijkstra(graph, start, end, weight): duration = {} pred = {} for node in graph.keys(): duration[node] = float('Inf') pred[node] = '' duration[start] = 0 all_nodes = list(graph) while len(all_nodes) > 0: shortest = duration[all_nodes[0]] short...
c45cd7cd5193d711e9c99977848080058efd17ad
laloparkour/pildoras_informaticas_python
/Practicas/#mail.py
208
4.0625
4
email = input("Introduce un correo: ") arroba = email.count("@") if (arroba != 1 or email.find("@") == 0 or email.rfind("@") == len(email)-1): print("Email Incorrecto") else: print("Email Correcto")
85ad3666cc319b11c434cf7d0bcc2471e65e1d48
jjack94/boolean_functions
/equal.py
615
4.15625
4
# james jack # 3/5/21 # function that takes two inputs from a user and prints whether they are equal or not def equal(): # creates function x = int(input("What is the first number you would like to use?: ")) # first var y = int(input("What is the second number you would like to use?: ")) # second ...
570bf3803ba8d3a67def77f1f775b7c9336cb487
sammcd4/calculator
/calc.py
472
4
4
import numbers def add_values(val1, val2): # Add any values, handling any conversion from string val1_, val2_ = val1, val2 if not is_valid_number(val1_): val1_ = float(val1) if not is_valid_number(val2_): val2_ = float(val2) return val1_ + val2_ def is_valid_number(val): va...
51a2092f4209825d5d9e465e9bd2502def18cf24
LarisaFonareva/Dictionaries
/2.18_Genealogy_ancestors_and_descendants.py
1,195
3.890625
4
def func(child, parent): if child==parent: # если дошла до первого предка return True while child in d: child=d[child] # ребенком делаю родителя, ищу его родителя if child==parent: # если дошла до первого предка return True return False d={} for _ in range(int(...
8f2fdfe386f20fe86d5bad71fedb94e63b4c1ee9
Aasthaengg/IBMdataset
/Python_codes/p02819/s945954757.py
219
3.703125
4
import math def prime(n): for k in range(2, int(math.sqrt(n)) + 1): if n % k == 0: return False return True n = int(input()) while True: if prime(n): break else: n += 1 print(n)
1906d71621de84e3e88bee1983e937d8436eaa13
sergeykoryagin/tproger
/tasks/task13.py
135
3.765625
4
num1 = input() num2 = num1 + num1 num3 = int(num2 + num1) num1 = int(num1) num2 = int(num2) result = num1 + num2 + num3 print(result)
f501345a2e092b8b9030031e4c90ccdb0b17c34e
jmetzz/ml-fundamentals
/src/neural_networks/base/activations.py
2,300
4.3125
4
from typing import Sequence import numpy as np def step(z: float) -> float: return 1.0 if z >= 0.0 else 0.0 def sigmoid(z: np.ndarray) -> np.ndarray: """Calculate the sigmoid activation function The sigmoid function take any range real number and returns the output value which falls in the range o...