blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
f5e20b542289e708891d558541397436047b6f47
Giorc93/PythonCourse
/Exceptions/exception3.py
302
4.03125
4
import math def sqrtFunc(a): if a < 0: raise ValueError('Number should be grater than 0') else: return math.sqrt(a) op1 = (int(input('Insert a number: '))) try: print(sqrtFunc(op1)) except ValueError as NegativeNumber: print(NegativeNumber) print('Program ended')
84604c70398644841b5e0ef1e707b52647dc7437
thiagosouzalink/my_codes-exercices-book-curso_intensivo_de_python
/Capitulo_09/exercise9_11/exercise9_11.py
472
3.734375
4
""" 9.11 – Importando Admin: Comece com seu programa do Exercício 9.8 (página 241). Armazene as classes User, Privileges e Admin em um módulo. Crie um arquivo separado e uma instância de Admin e chame show_privileges() para mostrar que tudo está funcionando de forma apropriada. 9.12 – Vários módulos: Armazene a classe ...
236bd6bc2224c6400286a2e8c4e61562df776335
shalommita/PrakAlpro-Lab-10
/LAB-10-DICTIONARY.py
1,442
3.546875
4
# SHALOMMITA P # 71200640 # LAB 10 DICTIONARY # INPUT # OPSI PILIHAN # BARANG YANG AKAN DITAMBAH/DIHAPUS # JUMLAH BARANG YG AKAN DITAMBAH # PROSES # UBAH KE DALAM DICT # LAKUKAN PERCABANGAN dan Perulangan While # OUTPUT import sys keranjang={} def utama(): print(""" Keranjang Stok Toko ...
2117665327969dfe4c5c918a8dcc56820207adbf
nebofeng/python-study
/01python-base/Dictionary.py
445
3.578125
4
#coding=utf-8 #{} 是字典 。字典可以覆盖修改。删除可以删除单个元素 del 还可以 删除整个词典 。 .clear() 方法 mydict1 = dict(([1, 'a'], [2, 'b'])) print(mydict1) mydict2 = dict.fromkeys((1,2,3),'a') print(mydict2) str1 = ['import','is','if','for','else','exception'] a={key:val for key,val in enumerate(str1)} print(a) M = [[1,2,3],[4,5,6],[7,8,9]]#求m中3,...
23b2d6d241628b0dc2648272fbc7b771cbf64233
intothedeep/Project-Euler
/problem009.py
726
4.125
4
#!/bin/python3 #suppose a<b<c, then a<n/3. a**2 = c**2-b**2 = (c-b)(c+b) = (c-b)(n-a) def find_biggest_pythagorean_set(n): pt_set = [] for a in range(n // 3, 1, -1): if (a ** 2) % (n - a) == 0: k = (a ** 2) / (n - a) if (n - a - k) % 2 == 0: b = (n - a - k) / 2 ...
a6f6425e658750cdf619bae954c2340a56458592
sanidhyamangal/interviews_prep
/code_prep/abstract_structures/queue_stack/stack_min.py
1,575
3.703125
4
# Implement a stack with a function that returns the current minimum item. __author__ = 'tchaton' import unittest import numpy as np from collections import defaultdict import numpy as np class Node: def __init__(self, value, prev=None, next=None, cnt=1): self.value = value self.prev = prev ...
c65fd5984f97e22f995f3c7894ec555464b86506
FirdavsSharapov/PythonLearning
/Python Course/Learning Python/LeetCode Exercises/remove_duplicate.py
1,525
4.25
4
from datetime import date, timedelta def count_digits(text: str) -> int: count = 0 for char in text: if char.isnumeric(): count += 1 return count # def days_diff(a, b): # start_date = date(*a) # end_date = date(*b) # return timedelta(end_date - start_date) # print(days_d...
76d7b528c45a1025ebcf66f7574e661bd0a03604
Boyko03/Python101
/week_6/decorators/test_accepts.py
1,585
3.78125
4
import unittest from accepts import accepts class TestAccepts(unittest.TestCase): def test_function_accepts_args_of_type_str_and_given_str(self): @accepts(str) def say_hello(name): pass exc = None try: say_hello(name='Boyko') except Exception as e: ...
4675b61d2907150b03a9b12ed936346c1727390c
weston100721/python-demo
/fundemental/Condition.py
1,639
4.3125
4
#!/usr/bin/python # -*- coding: UTF-8 -*- x = int(raw_input("please input an integer:")) # 单分支的条件判断。 if x > 0: print x # 双分支的条件判断。 if x > 0: print x else: print x * 2 # 多分支的条件判断。 if x < 0: x = 0 print "Negative changed to zero" elif x == 0: print "zero" elif x == 1: print "Single" else: ...
8995cb03d9852910ac8d19772f1b6754580b558d
m2be-igg/neurorosettes
/examples/rosette_formation.py
1,207
3.59375
4
"""Script to simulate the formation of Homer-Wright rosettes.""" import numpy as np from neurorosettes.simulation import Simulation, Container def create_tissue(container: Container) -> None: """Creates and registers new neurons in the simulation world.""" radius = 24.0 number_of_cells = 9 t = np.li...
b00afd394497e210b4387d90cc5e95586e924b30
Lorenzo97/tests
/fun.py
332
3.515625
4
def sum2(a,b): '''sums 2 numbers''' return a+b def power(a,b): '''a^b''' c = a**b return c def fwrite(file, L): channel=open(file, 'w') for i in L: channel.write(i+ '\n') channel.close() return 0 ''' fwrite('intro',['hi, ','myname is Lorenzo ','and I am ','a farmer ...
876bcaf26cc1a7c6e5ac7a330b00d37044ed6158
zz-tracy/hello_python
/python_dictionaries/dictionaries.py
3,417
3.671875
4
# 访问字典中的值 alien = {'color': 'green'} print(alien['color']) # 向字典中添加键-值对 alien_0 = {'color': 'green', 'points': 5} print(alien_0) alien_0['x_position'] = 0 alien_0['y_position'] = 25 print(alien_0) # 修改字典中的值 alien_0 = {'color': 'green'} print('The alien is ' + alien_0['color'] + '.') alien_0['color'] = 'yellow' ...
1f0f7962f3e527fc31e6a425b8a9d63c1ad7bd16
NestY73/Algorythms_Python_Course
/Lesson_3/max_between_min.py
1,050
4.03125
4
#------------------------------------------------------------------------------- # Name: module1 # Purpose: Homework - Lesson 3_Algorythms # # Author: Yuri Nesterovich # # Created: 31.03.2019 # Copyright: (c) Fujitsu 2019 # Licence: <your licence> #---------------------------------------------...
8ea1d7f6b8c02b6548ca590fb343bc1c72322603
seanxyuan/TSP_Robot_Path_Planning
/ArtificialNodes/artificial_nodes.py
1,010
3.59375
4
import input, basic_graph, add_nodes, deposition_cost class ArtiticialNodes(object): def __init__(self): pass def readFile(self): # Reading the graph from the input file self.graphInput = input.Input() self.graphInput.readFile('input.json') def makeGraph(self): # C...
9160b4654c0e1d0e95fb99c6e9c6cd07dae76b75
Eldalote/CDP-Component-Database-Program
/Component-Database/.ipynb_checkpoints/Component_Database-checkpoint.py
1,249
3.515625
4
from tkinter import * import tkinter.messagebox import sqlite3 from sqlite3 import Error import db_handler import Resistors def get_screen_size(): """ Hack to get the resolution of the active monitor :return: x, y, tuple with resolution in pixels. """ test = Tk() test.update_idletasks() t...
6bb8a8105ee0f76f8541b5974777715845058476
nathruby/adventofcode_2019
/Day_4/part1.py
748
3.859375
4
INPUT = '146810-612564' def find_passwords_in_input_range(input): input_array = INPUT.split('-') start = int(input_array[0]) end = int(input_array[1]) password_count = 0 for password in range(start, end+1): if is_password_valid(password): password_count+=1 print(passwor...
1641604d1e919298728150ec6bc05c1060252a57
PDXDevCampJuly/michael_devCamp
/python/sorting_algorithms/sorting_algorithms.py
3,373
4.53125
5
# Implementation of various sorting algorithms for lists ########################## from sys import argv import time filename = (argv[1]) # python sorting algorithm def python_sort(our_list): return sorted(our_list) def list_swap(our_list, low, high): """ Uses simultaneous assignment t...
56f71e003b6e8796c625c43def8562a16b0b4f53
GalyaBorislavova/SoftUni_Python_Advanced_May_2021
/4_Comprehensions/06. Word Filter.py
122
3.8125
4
words = input().split() even_len_words = [word for word in words if len(word) % 2 == 0] print(*even_len_words, sep="\n")
1be3f688ec9fc28ee183ef8f10711f934be395de
shen-huang/selfteaching-python-camp
/exercises/1901100064/1001S02E05_stats_text.py
2,910
4
4
import string text = '''The Zen of Python , by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough ...
204ef6b76ca5902fc4e5e1a239245f63804c4ab0
TommyX12/vim-smart-completer
/plugin/sc/completion_results.py
4,452
3.96875
4
# import vim import heapq class UniqueValuedMaxHeap(object): """ A priority queue where all values are unique. Data format: (value, priority) """ def __init__ (self, max_entries = 0): self.data = [] self.indices = {} self.max_entries = max_entries def set_max_en...
9ee6c23d9799d1cf56be67e8711ac18106f6a981
GoingMyWay/LeetCode
/82-remove-duplicates-from-sorted-list-ii/solution.py
707
3.6875
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution(object): def deleteDuplicates(self, head): """ :type head: ListNode :rtype: ListNode """ dummy = ListN...
d618291d69e419b5a5ac49d9f6b35524d9650a0b
thenger/combCheck
/combinations_RAW.py
454
3.625
4
def do(s): print (s) def spin(s, sNew): if (len(s) == 2): do (sNew + s[0] + s[1]) do (sNew + s[1] + s[0]) else: for char in s: srl = s.replace (char, "", 1) spin (srl, sNew + char) def combine(s): ...
4bb71b9104207dead1ae3e07fd59abc14cac50d3
jdamato41/python4e
/chap2_ex2.py
192
4.09375
4
#this program converts a farenheit temperature to celius print ('welcone to the Temperature Converter') farh=input("enter a temperature in degrees fareheit \n") farh= int(farh) print (farh*2)
86cca3e6766ed771b7d5fb73ef79d89107e39286
dpica21/STEP-2017
/gameloops.py
191
3.828125
4
tries = 5 counter = 0 while counter < tries : guess = int(input("guess a number between 0 and 10:")) counter = counter + 1 if guess == 4: print("right") else: print("wrong")
e94713b450d2be3c4ac7c67c8d972cb97ebd1852
bmoyles0117/codeeval
/38-string-list/test.py
733
3.5
4
import sys def base_convert(val, n, chars): s = '' total_chars = len(chars) while val > 0: s = chars[val % total_chars] + s val /= total_chars if len(s) < n: s = chars[0] * (n - len(s)) + s return s def get_possibilities(n, chars): chars = list(set(chars)) pos...
f4313f19b87034af96387c154a00dc3038376d38
PolinaSergeevna/Lesson4
/Lesson4_HW7.py
235
4.03125
4
def my_func(n): temp = 1 for i in range(1, n + 1): temp *= i yield temp n = int(input("Просьба указать число для расчета факториала? ")) for _ in my_func(n): print(_)
701228f404f5d39d1160f5a82e39acd15743ca61
deepabalan/googles_python_class
/sorting/9.py
97
3.828125
4
strs = ['hello', 'and', 'goodbye'] shouting = [s.upper() + '!!!' for s in strs] print shouting
4cddc981e0be0bf25d367ed79163053124997acb
huageyiyangdewo/learn_algorithm
/test/breadth_first_seatch_test.py
487
3.703125
4
from graph.breadth_first_search import BreadthFirstSearch from graph.graph import Graph g = Graph(13) g.add_edge(0, 5) g.add_edge(0, 1) g.add_edge(0, 2) g.add_edge(0, 6) g.add_edge(5, 3) g.add_edge(5, 4) g.add_edge(3, 4) g.add_edge(4, 6) g.add_edge(7, 8) g.add_edge(9, 11) g.add_edge(9, 10) g.add_edge(9, 12) g.add_...
d28792bacfaf19069b63678289f7919dcf153588
Sarkanyolo/AdventOfCode
/AoC2019-python/Day4/day4.py
1,093
3.78125
4
from typing import List, Tuple, Dict def getLines(filename: str) -> List[str]: with open(filename) as file: return [line.strip() for line in file] def manhattan(point: Tuple[int, int]) -> int: return abs(point[0]) + abs(point[1]) def getPath(steps: List[str]) -> Dict[Tuple[int, int], i...
da656c7b187d415acfe8ebe2f8180d42582bed8a
weiyuyan/LeetCode
/每日一题/March/面试题 10.01. 合并排序的数组.py
2,114
4.3125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # author:ShidongDu time:2020/3/3 ''' 给定两个排序后的数组 A 和 B,其中 A 的末端有足够的缓冲空间容纳 B。 编写一个方法,将 B 合并入 A 并排序。 初始化 A 和 B 的元素数量分别为 m 和 n。 示例: 输入: A = [1,2,3,0,0,0], m = 3 B = [2,5,6], n = 3 输出: [1,2,2,3,5,6] ''' from typing import List # 第一种方法:直接拼接到A的尾部然后使用sort()方法排序 # class So...
f3177ee8917784ab7e84d57cba3cd22978f4dd5a
t3eHawk/pepperoni
/pepperoni/record.py
4,826
3.78125
4
"""Elements used for record preparation and creation.""" import datetime as dt import os import sys import threading class Record(): """Represents a particular logging record as an object. This class describes the record. Record is an entity that is going to be send to the output as a single and separat...
232967c03f3c81b93cbfbfac36dc1d3fb8cda304
snehilk1312/Python-Progress
/Timedelta.py
1,363
3.765625
4
#HACKERRANK QUESTION #You are given 2 timestamps in the format given below: #Day dd Mon yyyy hh:mm:ss +xxxx #Here +xxxx represents the time zone. Your task is to print the absolute difference (in seconds) between #them. #Input Format #The first line contains , the number of testcases. #Each testcase contains lines, ...
422a14e76828c3584a68df4eeed1dfc9872115ea
geekquad/al-go-rithms
/data_structures/linked_list/python/double_linked_list.py
1,667
4.28125
4
class Node(object): def __init__(self, value): self.value=value self.next=None self.prev=None class List(object): def __init__(self): self.head=None self.tail=None def insert(self,n,x): #Not actually perfect: how do we prepend to an existing list? if n!=None: x.next=n.nex...
c818e1d0cf4c0b070bd489ea9919d36e6d658113
khangesh9420/CARD-VALIDATION
/main.py
918
4.25
4
# Enter the card number by User and use .strip() for unwanted spaces card_number = list(input("Enter the card number :").strip()) # Remove the last digit i.e check digit check_digit =(card_number.pop()) #Reverse the card_number card_number.reverse() # make an empty list future_use = [] #check for the even index and od...
fee9e78b8cf3a99214d35d7b901bedb81f344c11
JKChang2015/Python
/w3resource/List_/Q013.py
185
3.625
4
# -*- coding: UTF-8 -*- # Q013 # Created by JKChang # Thu, 31/08/2017, 16:35 # Tag: # Description: 13. Write a Python program to generate a 3*4*6 3D array whose each element is *.
e2ea5161ae19e2d50f23f36667316907034bbb26
traore18/python_academy
/exo.py
352
3.71875
4
def print_list(number_list): for i in number_list: if i > 20: print "Big Number" else: print "Small Number" my_list = [1, 3, 10, 24, 400, 4, 100000] print_list(my_list) def keep_printing(number_list): i = 0 while i < len(number_list): print "Index at %d" % i print number_list[i] i =...
5e5bc3fe23e851bbb54a84dc9a22309d5f8db3e6
daisy037/ProjectEuler
/problem1.py
145
3.9375
4
sum = 0 n = int(input("Enter limit : ")) print (n) for i in range (1,n) : if ((i % 3 == 0) or (i % 5 == 0)):sum += i print("sum = " +str(sum))
1afb3a48641f0f6007e432efc09a24b7d01c1967
deltaint-project/deltaint
/INTPath-DINT/system/controller/device.py
1,988
3.59375
4
# -*- coding:utf-8 -*- class Port(object): """ Describe a switch port it contains the num of this port and the name of device which contains this port """ def __init__(self, portNum, deviceName): self.portNum = portNum self.deviceName = deviceName class Table(object): """ ...
742263358edd71e0225a725f25e11e86ac515456
FutureSeller/TIL
/ps/baekjoon/1676.py
84
3.6875
4
N = int(input()) answer = 0 while N: answer += N // 5 N = N // 5 print(answer)
cb27ea051352d805e0bab0c5f93924c9b9db0ab2
avijeetsingh1988/CodingPractice
/Python/Basics Exercises/squaringlist.py
654
4.40625
4
def squaringlist(list): for i in list: print(i**2) a=[4,5,6] squaringlist(a) #ALTERNATE WAYS TO DISPLAY THE SQUARES IN A LIST# #1 Using append b=[] for number in a: b.append(number**2) print(b) #2 Using Map d=map(lambda n:n*n,a) print(list(d)) #3 Using for numbers = [1, 2, 3, 4, 5] squared_nu...
1de64f8231559f59598ebabc5ad2c8a5e0773ead
jharna-dohotia/my_Repo
/knight.py
2,797
3.984375
4
# Python3 code for minimum steps for # a knight to reach target position # initializing the matrix. dp = [[0 for i in range(8)] for j in range(8)]; def getsteps(x, y, tx, ty): # if knight is on the target # position return 0. if (x == tx and y == ty): return dp[0][0]; # if already calculated then ...
a8c1927e45577400e8af79fea48f5708eeea0601
MichalBrzozowski91/algorithms
/Algorithms_and_Data_Structures/bubble_sort.py
394
3.984375
4
def bubble_sort(nums): flag = True no_of_swaps = 0 while flag: flag = False for i in range(len(nums)-1): if nums[i] > nums[i+1]: nums[i], nums[i+1] = nums[i+1], nums[i] no_of_swaps += 1 print('Swap',no_of_swaps,':',nums) ...
f5da8ad77fde88a2f30c3e30ea026d0762eee448
payalgupta1204/Data_Structure_Algorithms
/quick_select.py
1,276
3.984375
4
import random def inputnumber(message): while True: try: userInput = int(input(message)) except ValueError: print("Not an integer, enter int value") continue else: return userInput def partition(arr, low, high): wall = low - 1 piv...
d31683e7457304c7d446eec406780637caf9ce77
fatezy/Algorithm
/datastructure/work2/进制转换.py
823
3.578125
4
# 十进制转换为八进制 class Solution: def ten_to_eight(self,num): if not num: return 0 res = [] while num: num,remainder = num // 8, num % 8 res.append(remainder) return ''.join(str(x) for x in res[::-1]) def ten_to_eight2(self,num): res = ...
d48d01022509348f889e164e74b8de7f45396ee7
BrandiCook/cs162project2
/StoreTester.py
4,083
3.671875
4
# Author: Brandi Cook # Date: 10/5/2020 # Description: This program is to test a simulated store, named Store.py # Store.py has members, grocery items, and keeps track of items in cart as # well as price. StoreTester.py ensures functions and classes are working properly. import unittest import uuid from cs16...
3222c164ae7c0392b5962f24ee5803b7dfa37e33
yangruihan/raspberrypi
/python/les8/les8_2.py
1,295
3.734375
4
#!/usr/bin/env python3 def sanitize(time_string): if '-' in time_string: spliter = '-' elif ':' in time_string: spliter = ':' else: return(time_string) (mins, secs) = time_string.split(spliter) return(mins+'.'+secs) class AthleteList(list): def __init__(self, a_name, a_...
97b5b9e2fb538a4d392b086e91eaff974a4a5f97
jarulsamy/Edge-Detection
/src/Theory.py
1,015
3.53125
4
from Myro import * from Graphics import * import math setX = [1, 2, 3, 4] setY = [1, 2, 3, 4] devSumX = 0 devSumY = 0 sumX = 0 sumY = 0 # Calc Avg X for i in range(len(setX)): sumX += setX[i] avgX = sumX / len(setX) # Calc Avg Y for j in range(len(setY)): sumY += setY[j] avgY = sumY / len(setY) # Stdev Equat...
e39ff1bb39484479840c146c2b50cbd2e2d6b10c
caringtiger/battleships
/main.py
4,555
4.0625
4
#!/bin/python import random if user_difficult == "4": gridsize_x = 11 gridsize_y = 11 else: gridsize_x = 7 gridsize_y = 6 # Game difficulty torpedo count. 0 = Easy, 1 = medium etc. game_difficulty_torpedos = [15,10,5,10] def main(): user_difficulty = get_user_difficulty() user_play_again = T...
61a77776a79c7866a806b871c9a796f46151d963
zeal2end/LogicCodes
/Pypy/combinations.py
638
3.796875
4
from itertools import combinations def backtrack(arr,i,n,cur=[]): if i==n: print(cur) else: backtrack(arr,i+1,n,cur); cur.append(arr[i]) backtrack(arr,i+1,n,cur) cur.pop() def main(): Array = [int(a) for a in input("Enter the Array here: ").split()] length = len...
3e93f3697284dd3e74241292da68c5430e48095e
gandrewstone/chainsim
/simEmergentConsensus.py
5,261
3.546875
4
from chainsim import * def runChainSplitSbyL(MinerClass, smallPct, largePct,preforktime=6000, postforktime=1000000): """ Returns the number of chain tips in the final full blockchain. There is one tip per chain fork. """ random.seed() # 1) chain = Blockchain() # Create a group of miners with EB=1MB, AD...
71b3fdf1ad46224f18c041c462e38dd753821a09
Joel1210/CodingDojo
/python_stack/python/fundamentals/complete/functions_basic_I.py
1,237
3.984375
4
print("1.") def a(): return 5 print(a()) print("2.") def b(): return 5 print(b()+b()) print("3.") def c(): return 5 return 10 print(c()) print("4.") def d(): return 5 print(10) print(d()) print("5.") def e(): print(5) x = e() print(x) print("6.") def f(b,c): print(b+c) print(f(1,2) ...
0b5b6611619ccc95edeade796d164282ef22be5d
franciszxlin/pythonlearn
/Exercises/ch8e5.py
360
3.734375
4
# -*- coding: utf-8 -*- """ Created on Sat Dec 30 16:40:40 2017 @author: zil20 """ fname = input('Enter a file name: ') fhand = open(fname) fcount = 0 for line in fhand: if not line.startswith('From'): continue fcount += 1 words = line.split() print(words[1]) print('There were', fcount, 'lines in the...
9666c3ed9dac42fe46aaaa16afed2c85661daaae
hmd1996/Python-Learning
/Python_600课/py_07_逻辑运算符应用.py
252
3.78125
4
age = int(input('请您输入您的年龄')) if age <0 or age > 120: print('怪胎?') elif age >= 0 and age <=18: print('您还不能进网吧哟') else: print('网吧欢迎您!') is_vip = False if not is_vip : print('不是VIP')
6e1eeebda39b66a62c9eb423e30bbeb9d31edf1c
ensarbaltas/14.Hafta-Odevler
/14.hafta 3.odev.py
1,941
3.9375
4
""" 14.Hafta 3.odev @author: ensarbaltas """ import random #oyuncu sayisi random.randint ile secildi oyuncusayisi=random.randint(2,4) #print('oyuncusayisi ',oyuncusayisi) scores=[] count1=0 while count1<oyuncusayisi: scores+=[random.randrange(5,120,5)] scores.append(random.randrange(5,120,5)) scores.sort(...
8537f95be7e7a9e685d6ef6ef1c3011a19bb429e
vargheseashik/python
/Languagefundamentals/sumpattern.py
118
3.9375
4
num=int(input("enter the number")) sum=0 for i in range(1,num+1): data=str(num)*i sum=sum+int(data) print(sum)
9b6193cce636516ed273129490dd53f55696d9f1
PullBack993/Python-Advanced
/5. Functions Advanced - Exercise/3.Min Max and Sum.py
271
3.703125
4
# input # 2 4 6 # output # The minimum number is 2 # The maximum number is 6 # The sum number is: 12 nums = list(map(int, input().split())) print(f"The minimum number is {min(nums)}") print(f"The maximum number is {max(nums)}") print(f"The sum number is: {sum(nums)}")
369b6deda986697894141aaed5d4ee114c8ff2fc
WuZhiT/xtpython
/xt18.py
494
4
4
#this oneis like oyur script with argv def print_two(*args): arg1,arg2 = args print(f"arg1: {arg1}, arg2: {arg2}.") #ok,that *args is actually pointless, we can just do it def print_two_again(arg1,arg2): print(f"arg1: {arg1}, arg2: {arg2}.") #this just takes one argument def print_one(arg1): print(f"a...
2e11bb22a151f8c2473ea0adacd84103d034ca07
spettigrew/pythonII-guided-practice
/online-store/store-guided.py
3,122
4.03125
4
#OOP - object oriented programming or design. ''' Take a complicated topic and make it into a modular application. Objects or classes O - blueprints / prototype; creating and grouping data. Holds data - attributes of a prototype of a blueprint. Uses methods - functions. You pass arguments, a function receives parameter...
6482219b4a67da9104c1eef987646ad75e001f36
theokott/txt-combiner
/txtcombiner.py
1,887
4.21875
4
import glob filetype = raw_input("What is the file extension to be combied?: ") #Asks the user for the extension used by files to be combined filetype = "*." + filetype #Adds a wildcard and . to the filetype to be used by the glob function filenameList = glob.glob(filetype) ...
1fc7843da2c664aca96d20efb6593c7ff2c2ebaf
seonghyeon555/Python_Project2.0
/test1.py
100
3.5
4
a=input().split(' ') x=int(a[0]) y=int(a[1]) print(x+y) print(x-y) print(x*y) print(x//y) print(x%y)
9ce14a8fe4897117b7eb2e077fd8b8d91c48f3f5
RandyHodges/Self-Study
/Java/Machine Learning/LinearRegression.py
1,316
3.671875
4
import matplotlib.pyplot as plt import numpy as np from sklearn.datasets import load_diabetes from statistics import mean def best_fit_slope_and_intercept(xs, ys): m = (((mean(xs)*mean(ys)) - mean(xs*ys)) / ((mean(xs)*mean(xs)) - mean(xs*xs))) b = mean(ys) - m*mean(xs) return m, b def simply(o...
b2c9a1c2682aa8661d589cb00d2ab1ca936438c2
KurinchiMalar/DataStructures
/DynamicProgramming/LongestPalindromicSubsequence.py
2,057
3.59375
4
__author__ = 'kurnagar' ''' ''' # Time Complexity : O(n*n) # Space Complexity : O(n*n) ''' Algorithm: 1) Fill all diagonal to 1. lcps[i][i] = 1 # meaning single letter palindrome (lvl = 1) 2) if Ar[i] == Ar[j]: lcps[i][j] = lcps[i+1][j-1] + 2 # 2 means, say i corresponds to a , then j also will be a ....
fbc04177f13ad32239b9540bfc1427b6985e13dc
AmitBaanerjee/Data-Structures-Algo-Practise
/leetcode problems/704.py
906
3.875
4
# 704. Binary Search # # Given a sorted (in ascending order) integer array nums of n elements and a target value, write a function to search target in nums. If target exists, then return its index, otherwise return -1. # # # Example 1: # # Input: nums = [-1,0,3,5,9,12], target = 9 # Output: 4 # Explanation: 9 exists in...
2c2813c88325e3cb5fdc274056de85ecfc312c92
KeyoungLau/lazy4power
/ncre-py/chapter6/元组.py
243
3.78125
4
s = list() for i in range(11): s.append(i) # 用tuple()函数把列表s转换为元组 s = tuple(s) print("原元组为:", s) # 对列表s进行切片,步长为2 print("从第四个开始对元组进行切片,步长为2: ",s[3::2])
0bc7f0d1c200033ccdb72f6f59a6d4dfadf765d6
netletic/pybites
/121/password_no_regex.py
995
3.71875
4
MIN_LENGTH = 8 def _has_lower_upper(password): return any([c.islower() for c in password]) and any([c.isupper() for c in password]) def _has_number_and_char(password): return any([c.isdigit() for c in password]) and any([c.isalpha() for c in password]) def _has_special(password): return not password.i...
73dfbcd2caa3537ff0ca44f2b66a742b51d5d94c
imarevic/psy_python_course
/notebooks/Chapter8/instblock.py
1,811
3.53125
4
# import pygame modules import pygame, os import TextPresenter # initialize pygame pygame.init() # create screen screen = pygame.display.set_mode((700, 700)) pygame.display.set_caption("Solution Rendering Multiline Text") # create a font object # parameters are 'system font type' and 'size' font = pygame.font.SysFon...
d81efd82d060436d1ce4b932f8c966f0a9324c26
sunnyhyo/Problem-Solving-and-SW-programming
/lab9-6.py
209
3.59375
4
#Lab9-6 (문자열 -> 숫자변환) x = input("숫자1: ") y = input("숫자2: ") z = input("숫자3: ") #문자열을 숫자로 변환하여 덧셈 연산 result = int(x) + int(y) + int(z) print(result)
dc372bc2d35f5ab669a74fa9d20f6def00b79908
Crone1/College-Python
/Year One - Semester Two/Week Three/numcomps_031.py
789
4.125
4
import sys n = int(sys.argv[1]) + 1 def is_prime(n): i = 2 while i < n and n % i != 0: i = i + 1 return n == i print('Multiples of 3: {}'.format([num for num in range(1, n) if not num % 3])) print ('Multiples of 3 squared: {}'.format([num * num for num in range(1, n) if not num % 3])) print ('...
2e4350f4729246eb92b64dc5809b2fea645eeadd
chensuim/leetcode
/trie.py
469
3.5
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2017/12/17 下午1:40 # @Author : Sui Chen class Trie(object): def __init__(self, words): self.data = [None] * 27 for word in words: layer = self.data for char in word: index = ord(char) - ord('a') ...
7ce5cc030d2e8e3593f9877361311e90ca136b82
Guitarboyjason/PythonExercise
/baekjoon/11729-하노이 탑 이동 순서.py
289
4.03125
4
from queue import LifoQueue N = int(input()) def hanoi(stack_1,stack_2,stack_3): if stack_3.size == N: return 1 if stack_1 != stack_1 = LifoQueue(maxsize = N) stack_2 = LifoQueue(maxsize = N) stack_3 = LifoQueue(maxsize = N) for i in range(N,0,-1): arr_1.append(i)
be8863b3895f790910ca839e1c010c84ec0923f1
SharonReginaSutio99/Python-basic
/prac_07/KivyDemos-master/dynamic_labels.py
880
3.53125
4
""" Name: Sharon Regina Sutio Link: https://github.com/SharonReginaSutio99/cp1404practicals """ from kivy.app import App from kivy.lang import Builder from kivy.uix.label import Label class DynamicLabelsApp(App): """Main program - Kivy app to make dynamic labels.""" def __init__(self, **kwargs): """...
be846e0932bf068348083e1cdf350d75e3e17b7e
yordanivh/intro_to_cs_w_python
/chapter05/Chapter5ExcersicesPart2.py
2,666
3.734375
4
Python 3.8.0 (v3.8.0:fa919fdf25, Oct 14 2019, 10:23:27) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license()" for more information. >>> ph=2 >>> if ph < 3.0: print(ph, "is VERY acidic! Be careful.") elif ph < 7.0: print(ph, "is acidic. SyntaxError: EOL while scanning strin...
ae50317ea13b4058734e05c13761d90830d1d054
Johnny-kiv/sheduler
/test/time 3.py
1,545
4.03125
4
#Это напоминальщик #версия 3 #Автор: johnny-kiv import time a2 = int(input("Введите минуты работы: ")) b2 = int(input("Введите минуты отдыха: ")) с2 = int(input("Введите часы нахождения в школе: ")) if a2 == 0: a4 = 60*20 if b2 == 0: b4 = 20*60 if с2 == 0: с4 = с2*(60*60) else: a4 = a2*60 b4 = b2*6...
e289ad2877356c1ce5bfc65a0cd6147a3a2e43a5
RobinXYuanBlog/PythonAlgorithm
/recursion/Hanoi.py
493
4.25
4
# def hanoi(steps, left='left', right='right', middle='middle'): # if steps: # hanoi(steps - 1, left, middle, right) # print(left, '=>', right) # hanoi(steps - 1, middle, right, left) # # 3 0 0 # 2 0 1 # 1 1 1 # 1 2 0 # 0 2 1 # 1 1 1 # 1 0 2 # 0 0 3 def hanoi(steps, left='left', middle='m...
7d1e7d5cff060ae621fb0147b8ca142a87032266
quentin-lipeng/python-first
/less2/less2-1/part2-5.py
570
3.796875
4
count = 0 while count < 5: print('凉凉一首') count += 1 pass print('over') def one_hun(): num1 = 0 flag = 1 while flag <= 100: num1 += flag flag += 1 else: print(num1) pass pass # 2550 def dou_sum(): num = 0 end = 100 start = 0 flag = 1 while...
15d8c86cc6cf85f0f8ebcf1e5e22c2b127ddd8e1
Tayl1989/WordReferenceAutoSort
/venv/Include/back_up.py
451
3.703125
4
# 注意: 需要安装python-docx库 from docx import Document import re import copy # file_path = input("请输入文档的绝对路径地址: ") file_path = r'D:\Development\python\docx-quotes-sort\venv\Include\test.docx' document = Document(file_path) for p in document.paragraphs: flag = re.match(r"^(\[\d+\])", p.text) if flag: # pri...
a347e9f3015e70d46c0804cd81ace26864706c58
diegoscolnik/ClaseAbiertaSelenium
/principiante.py
299
3.71875
4
#Programa de principiantes de la clase abierta de automation a = 1+5 b = 8 print(a+b) print(a-b) print(a*b) print(a/b) print(a**b) print(a%b) print(8//3) print(8/3) c = "Hola Mundo" d = 'Hola Mundo' print(c) print(d) e = 1.4648646468 f = 68616158616 print(f/e) g = True h = False print(g) print(h)
0164c5eab11adb9ceb9081fd66b8388278bfbab0
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_199/3197.py
2,651
3.5
4
import itertools with open('A-small-attempt1.in', 'r') as f: prob1 = f.readlines() total = int(prob1[0]) happy = 0 down = 0 case = 0 flips = 0 total_pancakes = 0 answer = [] # run through the rest of the lines for x in range(1, total+1): # 1,total+1 # per run format contained at this level success...
39bcbe9d664219f56608744cc6e2b0e88261fa2a
carriehe7/bootcamp
/IfStatementBasics.py
1,118
4.125
4
# if statements basics part 1 salary = 8000 if salary < 5000: print('my salary is too low, need to change my job') else: print('salary is above 5000, okay for now') age = 30 if age > 50: print('you are above 50. you are a senior developer for sure') elif age > 40: print('your age is bigger than 40. you...
ed51c7733c5c43339625e26a53329df0e2c05fbe
rodolforicardotech/pythongeral
/pythonparazumbis/Lista01/PPZ01.py
208
3.8125
4
# 1) Faça um programa que peça dois # números inteiros e imprima a soma desses dois números n1 = int(input('Informe o primeiro número: ')) n2 = int(input('Informe o segundo número: ')) print(n1 + n2)
a36ada6c22eefff15d9ddff7175229ff46c77810
vitor251093/SimuladorAD.2018-1
/simulador/models/pacote.py
1,251
3.640625
4
""" Classe Pacote que guardara todas as informacoes pertinentes ao Pacote, do momento que chega, ate o momento que sai do sistema. """ class Pacote(object): def __init__(self, id, tempoChegadaNoSistema, indiceDaCor, canal=-1, indiceEmCanal=0, servico=0): self.id = id self.indiceDaCor = indice...
58bd4d11754b4193b021bbb1287a1b2bd5ced61f
IshaBharti/python_list_loop_ifelse_fun
/menue.py
443
3.921875
4
day=input("enter day") meal=input("enter time") if day=="monday" and meal=="breakfast": print("poori sbji") elif day=="monday" and meal=="lunch": print("daal chawal") elif day=="monday" and meal=="dinner": print("chicken rice") elif day=="tuesday" and meal=="breakfast": print("tea and toast") elif day==...
422c14c8b99277984dc7d141fe6cb2ab2670a43f
HG-Dev/OrthoTurtleSim
/__main__.py
1,061
3.75
4
''' Main executable for the 2D turtle moving simultor. ''' import time from turtlesim.world_render import WorldDrawer from turtlesim.turtle import Turtle from turtlesim.datatypes import Coord from turtlesim.exceptions import ExitInterrupt def main(): """ Main body for starting up and updating simulation """ # ...
b73d0ffff7aeccc54f72afdd3833fffb25b838dc
Ronak912/Programming_Fun
/hashmap/CheckIfListCandivideIntoPairs.py
921
3.96875
4
# http://www.geeksforgeeks.org/check-if-an-array-can-be-divided-into-pairs-whose-sum-is-divisible-by-k/#disqus_thread # https://ideone.com/IO9hw2 # Input: arr[] = {9, 7, 5, 3}, k = 6 # Output: True # We can divide array into (9, 3) and (7, 5). # Sum of both of these pairs is a multiple of 6. # # Input: arr[] = {92, 75...
5a0a0dabeb19145957a028c41819e9c19b54f6a1
Sayam753/semester-3
/adsa/S20180010158_karger.py
1,505
3.546875
4
# Karger's algorithm implementation by Sayam Kumar - S20180010158 import random # Merge Utility def merge(graph, u, v): # Adding all connections of v to u for vertex in graph[v]: graph[vertex].remove(v) if vertex!=u: # Removing self edges graph[u].append(vertex) graph[vertex...
3ab75b8c4ff05816fbe8db2751667704c06c2408
xionghhcs/algorithm
/剑指offer/34_UglyNumber.py
1,445
3.5625
4
# -*- coding:utf-8 -*- class Solution: def GetUglyNumber_Solution(self, index): # write code here if index <=0: return None ugly_numbers = [0] * index ugly_numbers[0] = 1 p1, p2, p3 = 0,0,0 ugly_cnt = 1 while ugly_cnt < index: min_u...
edd626dd420df7e1c4125503d136c2414bb61992
pioella/Study
/7list_ex.py
790
3.984375
4
# 지하철 칸별로 10명, 20명, 30명 # subway1 = 10 # subway2 = 20 # subway3 = 30 subway = [10, 20, 30] print(subway) subway = ["유재석", "조세호", "박명수"] print(subway) print(subway.index("조세호")) print(subway[1]) subway.append("하하") print(subway) subway.insert(1, "정형돈") print(subway) print(subway.pop()) print(subway) # print(subwa...
e4cf002451e6a3eb109ed6405875d66ab4b24e14
iyuangang/pycode
/swap.py
235
3.546875
4
#!/usr/bin/python # coding:utf-8 a = [] for i in range(10): a.append(input("entert the num:")) print a for i in range(9): for j in range(i+1,10): if a[i] > a[j]: a[i],a[j] = a[j],a[i] print a
f62fb8762a3a217067fe79e18924ed3b7b4ab8b2
mogalaxy64/Schedule-maker
/scheduleMaker.py
686
3.890625
4
def lineCounter():#This finds the total amount of lines in the doc to show the num of classes file = open("Schedule Example.txt") lines = 0 for line in file: line = line.strip("\n") lines += 1 return lines def main(): classNum = lineCounter() f = open("...
d2ca186a106557665c70df1065371fb46fc72cf2
Amutha-4/amjo
/set2,1.py
129
4.09375
4
n=int(input("enter a number:")) sum1=0 while(n>0): sum1=sum1+n n=n-1 print("the sum of first n natural number is",sum1)
531d448d7e55ec3e3719f35b68a94674cf900ce7
bopopescu/Projects-1
/1/1_1/默写测试/用户基双分支础判断.py
618
4.09375
4
""" _username = "kevin" _password = '123456' username = input("username: ") password = input("password: ") if username == _username and password == _password : print("welcome" , _username) else: print("wrong username or password") """ name = input("name: ") sex = input("sex: ") age = int(input("age: ")) #if...
f7c5ae4ca4fb62d8374725b4c52884cb530d1000
JavaRod/SP_Python220B_2019
/students/rfelts/lesson04/assignment/tests/test_unit.py
4,554
3.546875
4
#!/usr/bin/env python3 # Russell Felts # Assignment 4 - Unit Tests """ Unit test for the basic_operations """ from unittest import TestCase import logging from peewee import DoesNotExist from customer_model import DATABASE, Customer from basic_operations import add_customer, search_customer, delete_customer, \ u...
bdaf541814e9d9a7fcf15ffd76bc966a7ae9d4de
gyuhwanhwang/algorithm
/LeetCode/lc_21.py
1,396
4
4
# Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode: # l1에 항상 작은 값이 오도록 if (not l1) or (l2 and l1.val > l2.val): l1, ...
d3de501361b16e0c19b9c7e274a4169c48938a11
ragamandali/pythonlabs
/classexamples/variables.py
155
3.71875
4
myname = "Raga" # nameofvariable = valueofvariable print(f"My name is {myname}") print(f"{myname} goes to high school") print(f"{myname} likes to read")
25c4832b2ca591d190a98cc4c5951b2f31984a01
ratchanon-dev/solution_py
/GradeII.py
553
3.953125
4
"""GradeII""" def main(): """grade cal""" grade = float(input()) if 95 <= grade <= 100: print("A") elif grade > 100 or grade <= 0: print('ERR') elif 90 <= grade < 95: print("B+") elif 85 <= grade < 90: print('B') elif 80 <= grade < 85: print('C+') ...
00b9f46e41de29693a515d315e7cf79ccd429905
ApurvaKunkulol/REST-APIs-with-Flask
/functions/code.py
275
3.859375
4
__author__ = 'LENOVO' # Most basic form of a function. def hello(): print("hello") def user_age_in_seconds(): age = int(input("Please enter your age(in years): ")) print("Age in seconds: ", age * 365 * 24 *3600) print("Good Bye!!") user_age_in_seconds()
13375b0a0fd83deb90a2214bac12c360db5e076a
ralphplumley/coursera
/algo-toolbox/week4_divide_and_conquer/1_binary_search/binary_search.py
898
3.984375
4
# Uses python3 import sys import math # 8 1 3 5 5 7 9 11 13 # 1 9 def binary_search(arr, target): minIndex, maxIndex = 0, len(arr) - 1 while maxIndex >= minIndex: midIndex = math.floor((minIndex + maxIndex) / 2) if arr[midIndex] == target: return midIndex elif arr[midInde...
b48e924693ac1d8c7eb70fcf62303a5779f03969
sasha-n17/python_homeworks
/homework_3/task_5.py
659
3.953125
4
def calc_sum(): """Возвращает сумму чисел из введённых строк. Q - спецсимвол для выхода.""" result = 0 flag = True while flag: s = input('Введите строку из чисел, разделённых пробелом: ').split() if 'Q' not in s: numbers = [float(el) for el in s] result += sum(num...
421264e11e1c77b5ecf34accd17b72c252846b64
HackerSchool/HS_Recrutamento_Python
/Ielga_Oliveira/Projeto.py
2,524
3.75
4
import MenuAPP def ler(id): ficheiro = open('Registo.txt','r') password = "" for linha in ficheiro: id2= linha.split('-')[0] if id==id2: password = linha.split('-')[1] break ficheiro.close() return password def escrever(username,password): ficheiro = ope...
6271371810fa5337ec52db0a30b373f831913ead
fis-jogos/ep1-shape
/actors/meteor.py
641
3.59375
4
class Meteor: """ This class represents the aircraft controlled by the user. """ def __init__(self, actor, positionX, positionY,mass, speed, gravity=100): self.actor = actor self.positionX = positionX self.positionY = positionY self.mass = mass self.speed = speed ...