blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
b739b06374f88cf0a90b01e2cf8a8872fa977770
poornimaramesh/fluent_python_exercises
/ch12/ch12_problem.py
1,771
4.03125
4
## Q1: Here are a bunch of classes. Refactor them taking into account the 8 principles ## under "Coping with Multiple Inheritance" on page 362. You are welcome to change ## anything you like and add additional classes etc. - I'm hoping this ## makes for a healty discussion on inheritance and design choices....
95589903dbf6dddab1e3f4b0c2f813f6143e8265
Ummyers/ProbabilidadPython
/Entregadas/RetoPython1Proba/reto3.py
616
3.828125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Oct 3 19:25:47 2020 Modificación de Guess My Number @author: ummyers """ import random print("Trata de adivinar el número en el que estoy pensando, tienes 5 intentos") the_number = random.randint(1,100) guess = int(input("¿Qué número crees que sea?")...
ee918e978a2599fce1beccd95786c218e6b49d59
Luciano-Grilli/ejercicios-python-del-curso-seguido
/Condicionales II.py
269
3.875
4
print("Verificar edad") #lower(),upper() minusculas o mayusculas edad=int(input("Ingrese su edad:")) if edad > 100 or edad <= 0: print("edad incorrecta") elif edad < 18: print("No puede pasar") else: print("puedes pasar") print("finalizado")
2cff96e1b5f30d5b5f1622c89412abbaa4b1219c
snovamo86861/PYTHON
/Strings.py
777
4.34375
4
#Strings can contain any number of variables tat are in your py script. Remember that a variable is any line of code where you set a name #name = (equal) to a value. In the code for this exercise you can put that in any string with # In this code, types_of_people = 10 creates a variable namesd types_of_people and set...
f16a15d1672e0265c299a03d28821d8447b431e1
Alfie-Awooga/Python-
/python-counter.py
362
4.15625
4
array_input = input("Enter a List of Numbers: ") split = array_input.split(" ") for x in range(0, len(split)-1): if not(split[x].isnumeric()): print("Not an integer") else: if int(split[x]) > 5: print("%d is greater than 5" % int(split[x])) if int(split[x]) < 5: p...
799e90adc903b37f47d64293df51cb62dc0de624
caltechlibrary/ames
/ames/utils.py
419
3.953125
4
def is_in_range(year_arg, year): # Is a given year in the range of a year argument YEAR-YEAR or YEAR? if year_arg != None: split = year_arg.split("-") if len(split) == 2: if int(year) >= int(split[0]) and int(year) <= int(split[1]): return True else: ...
7d2bb3806877d0b920d159dbf7452f54c7051a7c
AdarshKoppManjunath/Image-Processing
/assignment1/assignment1/source_code_files/q2.py
5,489
4.09375
4
""" This program is written in python3 and can execute using visual studio code. To execute this code, we need to have an input image in the raw format, and below command will help in running this program. python q3.py "input_imag_path" "output_image_path" inputimage_col inputimage_row outputimage_col outputima...
fbac1cdb907f09cc14c8375442973c1f69fc5ffd
rubayetalamnse/PYTHON-Turtle
/turtle2.py
390
3.765625
4
import turtle turtle.Turtle() turtle.color("red") turtle.pensize(5) turtle.shape("turtle") turtle.speed(3) turtle.forward(100) turtle.left(90) turtle.penup() turtle.backward(100) turtle.right(90) turtle.pendown() turtle.color("green") turtle.forward(100) #another turtle----> ruba = turtle.Turtle() ruba.color("blue")...
29b84bbb1ec6d0dc6427533114c07b6331f1c18d
EvgenijGod/interview_tasks
/Min_Range_Needed_to_Sort.py
1,184
3.890625
4
""" Given a list of integers, return the bounds of the minimum range that must be sorted so that the whole list would be sorted. """ def findRange(nums): left = [nums[-1]] * len(nums) right = [nums[0]] * len(nums) ind = 1 while ind < len(nums): if right[ind - 1] < nums[ind]: right[...
7a7187b3dd62f97f27c9e0761c53068d44585bb6
xizhang77/LeetCode
/Array/442-find-all-duplicates-in-an-array.py
1,039
3.9375
4
# -*- coding: utf-8 -*- ''' Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements that appear twice in this array. Could you do it without extra space and in O(n) runtime? Example: Input: [4,3,2,7,8,2,3,1] Output: [2,3] ''' ''' Refe...
8b1b69c68f33552b27f0378fb2323267f89307eb
ngreenwald89/Hackerrank
/Warmup/time_conversion.py
476
4.0625
4
#!/bin/python3 import sys time = input().strip() def time_converter(time): time = str(time) hr = int(time[:2]) part_of_day = time[-2:] if part_of_day == 'AM' and 1 <= hr <= 11: print(time[:-2]) elif part_of_day == 'PM' and hr == 12: print(time[:-2]) elif part_of_day == 'PM' a...
43e3fcaa93d61c693b5ebfa71a98147c144da63e
zh-en520/-
/aid1901/day1/demo4_shape.py
391
3.5625
4
#维度处理 import numpy as np a = np.arange(1,9) print(a) b = a.reshape(2,4)#变维2*4 print(a,b) c = a.reshape(2,2,2)#变维2*2*2 print(c) a[0] = 999 print(a) print(b) print(c) print(c.ravel()) print('==========================') #复制变维 d = b.flatten() print(d) d[0] = 888 print(d) print(b) print('-------------------------') #就...
a57bb7845b51989ae8d8f46de9fb398925bcfac7
milind-okay/source_code
/python/class_student.py
675
3.703125
4
class student: grade = [] def __init__(self, name ,id): self.name = name self.id = id def add_grade(self,num): return self.grade.append(num) def showgrades(self): grades = ' ' for grd in self.grade: grades += str(grd) + ' ' return grades def ave(self): sum = 0 for ...
640585ee29e642eb393dbc3e57663149330f3a5a
kate-melnykova/LeetCode-solutions
/LC1790-Check-if-One-String-Swap-Can-Make-Strings-Equal.py
1,914
4.125
4
""" You are given two strings s1 and s2 of equal length. A string swap is an operation where you choose two indices in a string (not necessarily different) and swap the characters at these indices. Return true if it is possible to make both strings equal by performing at most one string swap on exactly one of the stri...
c75b8b42eb55e10096de977bcb238f5910a339c4
flathunt/pylearn
/examples/reviews/review3.py
275
3.859375
4
#!/usr/local/bin/python my_string = 'Fred,33,George,101,Harry,17' my_list = my_string.split(',') # my_list = [ int(i) if i.isdigit() else i for i in mystring.split(',') ] print(my_list) # For more generic validation... # re.search(r'^(\+|-)?\d+(\.\d+)?$', num_as_str)
895bf7d7731ac536a42f0ff83b3fd22f9b7c27b8
birdManIkioiShota/DojinHakusho
/script/getPriceSalesPlot.py
693
3.640625
4
# _*_ coding: utf-8 _*_ import pandas as pd import numpy as np import matplotlib.pyplot as plt import datetime as dt import collections def getPriceSalesPlot(): data = pd.read_csv("../data/raw_data.csv", index_col='id') data['date'] = pd.to_datetime(data['date']) # 売上と値段の関係をプロットします x = data['pric...
341d9a7db5658779dc860c8708af688a70121c88
jhyun90/python-basics
/venv/numpyStack.py
460
3.96875
4
# NumPy in Python | Set 2 (Advanced) import numpy as np # Stacking a = np.array([[1, 2], [3, 4]]) b = np.array([[5, 6], [7, 8]]) # horizontal stacking print("\nHorizontal stacking:\n", np.hstack((a, b))) # vertical stacking print("Vertical stacking:\n", np.vstack((a, b))) c = [5, 6] ...
4885d094cbc90b9325e1568c1e75e85bdb60b620
number09/atcoder
/abc065-b.py
268
4.03125
4
int_n = int(input()) ar_int = list() for i in range(int_n): ar_int.append(int(input())) target = 1 counter = 0 while counter < int_n: target = ar_int[target - 1] counter += 1 if target == 2: # button 2 print(counter) exit(0) print(-1)
3b8afa8066139946a51a2fc28b3e27a77363405b
Hussain-007/automation_l2
/35.py
1,117
4.34375
4
'''35.Create Tuple as specified below a) Create a Tuple tup1 with days in a week & print(the tuple elements b) Create a Tuple tup2 with months in a year and concatenate it with tup1 c) Create 3 tuples( tup1,tup2,tup3) with numbers and determine which is greater. d) Try to delete an individual element in tup1 and tr...
f43f6c0f7ab30f602ea33b6ce2af7ccb062129d0
krishnanunni-pr/Pyrhon-Django
/functions/function3.py
102
3.65625
4
#FUNCTION WITH ARGUMENTS AND RETURN TYPES def add(num1,num2): return num1+num2 print (add(3,9))
d9d01c3cb26c5642608f83c4d53c8794d92be401
Nisar-1234/LeetCode-Hard
/329-Longest Increasing Path in a Matrix.py
4,244
4.1875
4
# https://leetcode.com/problems/longest-increasing-path-in-a-matrix/ """ Example 1: Input: matrix = [[9,9,4],[6,6,8],[2,1,1]] Output: 4 Explanation: The longest increasing path is [1, 2, 6, 9]. Example 2: Input: matrix = [[3,4,5],[3,2,6],[2,2,1]] Output: 4 Explanation: The longest increasing path is [3, 4, 5, 6]. Mov...
fd2f582d66a9493d7b59bd9aa91666623f73ae00
AlexOfTheWired/cs114
/FinalProject/changeReturn.py
978
3.734375
4
def calculate_coins_to_return(change): change = int(input("Amount Tendered?")) quarters_value = 25 dimes_value = 10 nickels_value = 5 pennies_value = 1 quarters_number = change // quarters_value dimes_number = q_remainder // dimes_value nickels_number = d_remainder ...
dd2479a72b08faa00721ddba93ebc3a7ed9bc699
llq1020/data-struct
/skip-list/skip_list.py
3,681
3.515625
4
import random MAX_LEVEL = 16 class Node: """ 跳表节点类 """ def __init__(self, level, key=None, value=None): self.key = key self.value = value self.forwards = [None] * level def random_level(): level = 0 for i in range(-1, MAX_LEVEL): level += random.randint(0, 1...
e05555e355b35f8dc5ffeee14a757b3f233d0243
ajitabhkalta/Python-Training
/program3.py
359
3.875
4
inp1=eval(input("Enter the first number:")) inp2=eval(input("Enter the second number:")) print("The arithametic operation are as follows:") print(inp1,"+",inp2,"=",inp1+inp2) print(inp1,"-",inp2,"=",inp1-inp2) print(inp1,"*",inp2,"=",inp1*inp2) print(inp1,"/",inp2,"=",inp1/inp2) print(inp1,"//",inp2,"=",inp1//in...
f56ad49a81f74618eebd215f662b13e2eab45ffb
tiagooandre/FEUP-FPRO
/Play/week02/Alarm_Clock.py
334
3.734375
4
h = int(input("H: ")) m = int(input("M: ")) h += 6 m += 51 while h > 24: h -= 24 break while m >= 60: m -= 60 h += 1 break while h >= 24 and m >= 60: h -= 24 m -= 60 h += 1 break while h < 10: h = "0" + str(h) break while m < 10: m = "0" + str(m) break print("%...
7fa8e1a76ee61b4dd96e58a8b9f64c92b6c5e252
wawj901124/mswt
/第四部分 技术基础知识/70match和search的区别.py
360
3.828125
4
import re s1 = "helloworld, helloworld" w1 = "hello" w2 = "world" #search扫描整个字符串 print(re.search(w1,s1)) print(re.search(w1,s1).group()) print(re.search(w2,s1)) print(re.search(w2,s1).group()) #match只在字符串开始的位置匹配 print(re.match(w1,s1)) print(re.match(w1,s1).group()) print(re.match(w2,s1)) print(re.match(w2,s1).group(...
4c8875bcda6a704e84d9663b5df582867d3cd285
slobodanI/Udemy---Pro-Advanced-Python-Programming
/01_Comprehension/01_list_comprehension.py
912
3.75
4
# # intersection of lists # list1 = [1, 2, 3, 4, 5] # list2 = [2, 3, 4, 5, 6] # # intersection = [x for x in list1 for y in list2 if x == y] # print(intersection) # # non_common_el = [(x, y) for x in list1 for y in list2 if x != y] # print(non_common_el) # ------------------------------------ # my_list = ['Hello World...
c92cf91cde5e658898fd538825a618add03ebafc
14Praveen08/Python
/n_times.py
46
3.515625
4
number = int(input()) print("Hello\n"*number)
8d7e4d45eacc3eb3562fa43b0ccb3615f570d7be
Rastatrevftw1538/SMC-CS102-Advanced-Programming
/Queues/dsmain.py
2,682
3.96875
4
from DisneyQueueTC import DSQueue from random import randint # we test the DSQueue with a model of the day. The DSQueue starts empty. # # BUSY: During the morning the ride is "busy" and more people are joining the # line that are getting on the ride. # We model this by assuming for every person who gets to rid...
51728a46fd09b4a1dfad96b2b58b941cb8c29b17
shalini2503/learn_py
/T5_Singh.py
965
4.15625
4
# program to calculate the average of all the numbers from the file you created (Tnumbers.txt) class ReadFile: # reads a file at given path, read the content and calculate average def read_file(self): f = open("Tnumbers.txt", "r") sum = 0 count = 0 line = f.readlin...
ab85889ce478bb584cca3f237186b5dee636557b
pku-cs-code/algorithm
/iterator.py
402
3.8125
4
#!/usr/bin/env python # _*_ coding:utf-8 _*_ # __author__ = caicaizhang class fn(): def __init__(self): self.i = 0 def __next__(self,n): # for i in range(10): self.i += 1 print("before:{}".format(self.i)) rev = yield n print("after:{}".format(self.i)) p...
37581673480b1bd350d74aec0ef030c59807149a
FACaeres/WikiProg
/matrizes/exercicio04.py
735
3.828125
4
"""guarda o tamanho das matrizes""" linhas = 3 colunas = 3 """obtem a matriz A do usuario""" matriz_A = [[]]*linhas for i in range(linhas): matriz_A[i] = list(map(int, input().split())) """obtem a matriz B do usuario""" matriz_B = [[]]*linhas for i in range(linhas): matriz_B[i] = list(map(int, input().split()))...
f2cf38142b2a74399ed08ba122181c435172b5e7
abishamathi/python-program-
/prime.py
129
4.15625
4
if(num>1): for i in range(2,num): if(num % 1)==0: print('num is not a prime number') else: print('num is a prime number')
7dc4f4fa0c4abd1d5e762588f03f46d905b1c17b
yababay/pencil-box
/lib/canvas.py
1,689
3.546875
4
from tkinter import Tk, Canvas from . settings import canvas_width, canvas_height from . pencils import parse_pencils from . settings import pencil_width, canvas_background global canvas def create_canvas(title='Коробка с карандашами', width=canvas_width, height=canvas_height): root = Tk() root.ti...
68cf5dc2d83d96561b96dc6c88c3c5d038e11692
todorovventsi/Software-Engineering
/Programming-Fundamentals-with-Python/regular-expressions/02.Match-phone-numbers.py
176
3.6875
4
import re numbers = input() pattern = r"\+359( |-)2\1\d{3}\1\d{4}\b" valid_numbers = [item.group() for item in re.finditer(pattern, numbers)] print(*valid_numbers, sep=", ")
7197d16004064af0872da72bd6b6e8c72f33ce42
XVXVXXX/leetcode
/0171.py
925
3.703125
4
# 171. Excel表列序号 # 给定一个Excel表格中的列名称,返回其相应的列序号。 # 例如, # A -> 1 # B -> 2 # C -> 3 # ... # Z -> 26 # AA -> 27 # AB -> 28 # ... # 示例 1: # 输入: "A" # 输出: 1 # 示例 2: # 输入: "AB" # 输出: 28 # 示例 3: # 输入: "ZY" # 输出: 701 # 来源:力扣(LeetCode) # 链接:https://leetcode-cn.com/problems/excel-sheet-column...
6bc17024081bd96f1017ce2b7c0fc08ff766001b
NHTdz/baitapthem
/sum_diagonal.py
462
3.703125
4
import random import numpy as np def matrix(m,n): lst = [[random.randint(1,10) for e in range(n)]for e in range(m)] lst = np.array(lst) return lst def sum_diagonal(lst,m,n): sum = 0 for i in range(m): for j in range(n): if i == j: sum += lst[i][j] return sum m...
a4197abb59203feda5566b4f0e209245f9b62496
lucasolifreitas/ExerciciosPython
/secao6/exerc9.py
85
3.921875
4
num = int(input('Informe o valor de N: ')) for i in range(1, num*2, 2): print(i)
6247b18746dce0d39894f1ac6a630eee4e042af1
BeijiYang/algorithmExercise
/validParentheses.py
1,142
4.09375
4
# Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. # An input string is valid if: # Open brackets must be closed by the same type of brackets. # Open brackets must be closed in the correct order. # Note that an empty string is also considered valid...
cba93ba6f5949e300c0f55bae65a5f9d798e53cf
apontejaj/Python-Bootcamp
/list.py
339
3.578125
4
my_list = ["string", 2, 3.131526] print (len(my_list)) print (my_list[1]) my_list.pop(1) print (len(my_list)) print (my_list[1]) my_new_list = [] print (len(my_new_list)) my_new_list.append("hELLO") print (len(my_new_list)) my_new_list.append(2) matrix = [my_list, my_new_list] print (matrix[0]) print (row[0] ...
d1d562b51b75d1b5b74533392a50f608cd764e80
gyurel/SoftUni-Basics-and-Fundamentals
/more_exercise_dictionaries/judge2.py
1,685
3.765625
4
contests_info_dict = {} input_str = input() while input_str != "no more time": student_name, contest_name, points = input_str.split(" -> ") points = int(points) if contest_name not in contests_info_dict: contests_info_dict[contest_name] = {student_name: points} elif student_name not in conte...
fc734802af04bd2c15a99dd671485d67564a15a6
leeanna96/Python
/Chap03/옷차림 추천_도전문제.py
135
3.78125
4
grade=int(input("취득한 학점 수를 입력하세요: ")) if grade>=140: print("졸업가능") else: print("졸업불가")
391b418268a5c5f21f6d3f3a91f9b5c91fc3412b
KamrulSumon/Python
/Academic/Python/Assignments/#4/Code/17.py
972
3.546875
4
class Fib: def __init__(self, val_count = float('inf')): self.initial_val_count = val_count def __iter__(self): self.val_count, self.result_queue = self.initial_val_count, [0, 1] return self def __next__(self): if self.val_count <= 0: raise StopIteration self.val_count -= 1 ...
092b96c32241d05b3eb683646bbb76de8d087632
davex98/Python_Lab
/Classes/MyComplex.py
1,228
3.78125
4
from math import sqrt class Complex(object): def __init__(self, real, imag=0.0): self.real = int(real) self.imag = int(imag) def __add__(self, other): return Complex(self.real + other.real, self.imag + other.imag) def __sub__(self, other): return Co...
9a77df389b4edb8cf112a1267f6c651713a5d579
lidongdongbuaa/leetcode2.0
/数据结构与算法基础/leetcode周赛/5238. Find Positive Integer Solution for a Given Equation.py
1,173
4.0625
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2019/10/27 11:58 # @Author : LI Dongdong # @FileName: 5238. Find Positive Integer Solution for a Given Equation.py '''''' ''' 题目分析 1.要求: 2.理解: 3.类型: 4.方法及方法分析: time complexity order: space complexity order: ''' ''' 法 思路: 方法: 边界条件: time complex: space complex:...
6182b8e8d4b98491044e5f7e4941d8a836e28139
ids0/ATBSWP
/Chapter_06/picnicTable.py
359
3.8125
4
def printPicnic(itemsDict, leftWith, rightWidth): print('PICNIC ITEMS'.center(leftWith + rightWidth, '-')) for k, v in itemsDict.items(): print(k.ljust(leftWith,'.') + str(v).rjust(rightWidth)) picnicItems = {'sandwiches': 4, 'apples': 12, 'cups': 4, 'cookies': 800} printPicnic(picnicItems,12,5) ...
5db0ac08b5f93094dc84be5a9250e30280845cb1
RobertoRosa7/python
/py_intro_to_python/itertool.py
1,685
3.828125
4
# -*- coding: utf-8 -*- import itertools from itertools import permutations from itertools import combinations from itertools import groupby from operator import itemgetter from databases import database def createGroupByDate(): ''' Criando groupos e ordenando pela py_data ''' # ordem b...
ea5045f01628e293c53570e5b32111f958be9164
AnniePawl/Data-Structures-Intro
/Code/histo_list.py
1,201
3.828125
4
# LISTS OF LISTS # Two-dimensional arrays # Results should look like this: ''' histogram = [['one', 1], ['fish', 4], ['two', 1], ['red', 1], ['blue', 1]] ''' # READ FROM THIS FILE # file = open("../sample_text.txt") def get_word_list(file_name='./creatures.txt'): '''Gets words, gets rid of nonsense''' file ...
eafb3a7b2e9f6de82291d3f292bc6edeceebb4a7
sups-vamp/hello-git
/assignment3.py
1,391
4.125
4
#LISTS #question-1 a=[] size=int(input("enter size of list")) for i in range(0,size): ans=input("") a.append(ans) print(a) #question-2 b=["google","apple","facebook","microsoft","tesla"] a.append(b) print(a) #question-3 #taking 'a' as ou...
cc68e0b1aeeb40d1646a058fc4435b6b7b5b7978
akeeme/python
/BankingProgram(LogicalOperator).py
310
3.8125
4
#Programmer: Akeeme Black #Date: 2/21 #Problem 1 '''To ask the user for salary and years''' salary=eval(input("Enter your annual salary ")) years=eval(input('Enter your year(s) at current job: ')) if salary>=60000 and years>=2: print("Congratulations!!! Your Qualified") else: print("You do not qualify")
929f580e8e559f8309e19f72208bf4ff0d537668
Maliha-Momtaz-Islam/pythonPractise
/task1.py
139
3.90625
4
x = str(input("please input your name:")) y = int(input("please input your age:")) p = int(2017-y+100) print("your name is:"+x) print (p)
4ddb8547aa9015148438aac7ae1e6be9c8f436e8
NKarachun/Practice-2
/Practice_15_KM-02_Karachun/main.py
3,499
4.46875
4
from factorial.factorial import * from exp_root.exponentiation import * from exp_root.root import * from logarithm.logarithm import * def main(): while True: n = input('''Choose what you want to find out (if you want to calculate the factorial - enter "f", if you want to calculate the expo...
3275e5c81bd38dc7790fb320dfc4c19d17404acb
jkbockstael/adventofcode-2017
/day08_part1.py
939
3.59375
4
# Advent of Code 2017 - Day 8 - I Heard You Like Registers # http://adventofcode.com/2017/day/8 import sys def run_program(source): registers = {} for line in source: registers = run_instruction(line, registers) return registers def run_instruction(line, registers): tokens = line.rstrip().spl...
afc4a02cc5a187fcce1a3eb9d026163a6971278a
christopherchoe/holbertonschool-higher_level_programming
/0x10-python-network_0/6-peak.py
847
3.984375
4
#!/usr/bin/python3 """ peak finder """ def find_peak(list_of_integers): """ finds any peak """ length = len(list_of_integers) half = length // 2 if length > 0: if length > 1: if length == 2: return list_of_integers[0] if\ list_of_integers...
83a16af151085358bb1a185592487248fabcccfa
snroeust/MTCP
/client.py
2,069
3.8125
4
# multi-task file downloader client import socket if __name__ == '__main__': # create a socket tcp_client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # connect to the server server_ip = input(" input server ip :") tcp_client_socket.connect((server_ip, 3356)) # send a...
3dc0384e2611acc6a2de5e94de634ef7453767c0
CFN-softbio/pycxdgui
/pycxdgui/tools/interpolations.py
822
3.515625
4
'''Extra interpolation techniques.''' import numpy as np def fillin1d(xdata,data,mask,period=None): ''' Fill in a 1d array by interpolating missing values. axis: if array is more than one dimension, run the correlation on the proper axis For numpy version 1.10 and higher, you can wrap a...
a5c6b4d6fd03b626e30a1766748c236820d54c3e
gedong009/stock-selection
/bin/mytest3.py
784
3.65625
4
#encoding: utf-8 import threading import test def work(): # obj = test.test_class() # print(obj.print()) obj = test.test_class().print() # test.print() if __name__ == '__main__': print("dsf") # 建立一个新数组 threads = [] # n = 10 n = 10 counter = 1 while counter <= n: na...
2f0fec9c4db0683cff4308895dd97f0eebbf706c
a1403893559/rg201python
/杂物间/python基础/day04/计算1到100.py
240
3.515625
4
# 需求是计算0~100之间所有数字的累计求和结果 # 求和的结果 默认是0 sum = 0 # 求和的数字 i = 0 while i <= 100: #求和 sum = sum + i # i+=1 和 i=i+1等价 i += 1 # i=i+1 print('和%d'%sum)
991284b01b3818bf48c6f7dd9896a5d194cff305
stellaapril/Python2
/csv/csv311.py
1,456
3.5
4
import csv #dictionaries yearsDic = {} datesDic = {} areasDic = {} typesDic = {} statusDic={} #open csv file file = open('capitalprojects.csv',newline='') reader = csv.DictReader(file) info = int(input('choose 1=fiscal_years,2=start_date,3=area,4=asser_type,5=planning_status: ')) for row in rea...
6de28f57b9a702075e3193b2e9b5f5175de5fdf6
egyeasy/TIL
/201901SSAFY/05PS/190130 String/itoa.py
145
3.703125
4
nums = 123053 words = "" while nums != 0: num = nums % 10 words = chr(num + 48) + words nums = nums // 10 print(words, type(words))
85f1b98449254d6030864a403b29f745ef7133a4
Amresh-Pathak/Guessing_game
/guessing_no.py
558
4.0625
4
x=14 attempt=1 print("It's a game of guessing correct number") print("Number of guesses is limited only 5 time: ") while(attempt<=5): guess_num=int(input("Enter your guessing number: \n")) if guess_num>x: print("Please enter lesser no.\n") elif guess_num<14: print("Please enter greaterno.\n"...
db289b90403402506fa3fcc7da0d603e27b81f13
Alewarrior/Algoritmos-em-python
/ConversãoDeCelsiusParaFahrenheit.py
148
3.875
4
temp = int(input("Digite a temperatura em Celsius: ")) result = (temp *1.8)+32 print("%dºC convertidos em Fahrenheit é : %dºF"%(temp,result))
7cebde55196028a511a1d1f855707378e661c340
matthewmuccio/InterviewPrepKit
/saq2.py
791
4.03125
4
#!/usr/bin/env python3 class MyQueue(object): def __init__(self): self.head = [] self.tail = [] def peek(self): self.digest() return self.tail[-1] def pop(self): self.digest() return self.tail.pop() def put(self, value): self.head.append(value) ...
a7a9b33118b7898ddc36062ff49fd6dca6640c4d
Kcheung42/Leet_Code
/0055_jump_game.py
3,181
3.984375
4
#------------------------------------------------------------------------------ # Questions: 0055_jump_game.py #------------------------------------------------------------------------------ # tags: ''' # 55. Jump Game Given an array of non-negative integers, you are initially positioned at the first index of the arra...
64fbde5365e3525e203012bb984b9dfb46ef94a4
mayfly227/day
/chapter09/iterable_itertor.py
1,630
4.03125
4
# 迭带器 from collections.abc import Iterator, Iterable class Company(): def __init__(self, employee_list): self.employee = employee_list def __iter__(self): # 返回一个iterator return MyIterator(self.employee) class MyIterator(): ''' 实现一个迭带器 ''' def __init__(self, list): ...
d71bea8a96624f30361a844af7f0b025c57b94c6
ketul-1997/assignment-1
/prog18.py
195
4.0625
4
string = "make in india" max_string = max(string.split(),key=len) print "the maximum string is :",max_string min_string = min(string.split(),key=len) print "the minimum string is :",min_string
f48ab364458d4bfc218ad592d1f320de20c521d8
steel-a/utilpy
/numbers.py
1,526
3.84375
4
def toFloat(value:str) -> float: """ -> Convert a input string in US or Europe/BRL format to float ##### Maximum decimal places of input string: 2 Possible inputs: '1,000,000,000.76','1,000,000,000.7','1000000000.76','1000000000.7','1.000.000.000,76','1.000.000.000,7' ,'1000000000,76','10000000...
e808ec5e66586779a04a6c55420c651999d238fa
chao-shi/lclc
/117_populate_next_bt_2_m/main.py
631
3.828125
4
# 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 nothing def connect(self, root): p = ...
7f8ca311798d4b385d4f0e4b1a65b69fe032ef95
panda3d/panda3d
/direct/src/directnotify/Logger.py
2,108
4.0625
4
"""Logger module: contains the logger class which creates and writes data to log files on disk""" import time import math class Logger: def __init__(self, fileName="log"): """ Logger constructor """ self.__timeStamp = 1 self.__startTime = 0.0 self.__logFile = No...
f4454675c4a9ee3a0c33433ae9f598054d61b719
yhs3434/Algorithms
/programmers/maxNumber.py
948
3.609375
4
# 가장 큰 수 # https://programmers.co.kr/learn/courses/30/lessons/42746 def solution(numbers): answer = '' quickSort(numbers, 0, len(numbers)-1) numbers.reverse() for n in numbers: answer+=str(n) answer = str(int(answer)) return answer def compare2(x,y): str_x = str(x) str_y = ...
9192c3aeb7265b5d99592b5a4306bcbabaebdf5f
wangfmD/pypro
/02_check/02_class/decorator/d6.py
542
3.5625
4
# coding=utf-8 def deco(myfunc): def _deco(*args, **kwargs): print "before %s() called." % myfunc.__name__ ret = myfunc(*args, **kwargs) print "after %s() called. result: %s" % (myfunc.__name__, ret) return ret return _deco @deco def myfunc(a, b): print "myfunc(%s,%s) cal...
62174afaf595917abecda575ece209371614367e
qmnguyenw/python_py4e
/geeksforgeeks/python/python_all/53_5.py
2,238
4.34375
4
Python – Sort Dictionary by Values and Keys Given a dictionary, sort according to descended values, if similar values, then by keys lexicographically. > **Input** : test_dict = {“gfg” : 1, “is” : 1, “best” : 1, “for” : 1, “geeks” > : 1} > **Output** : {“best” : 1, “is” : 1, “for” : 1, “geeks” : 1, “gfg”...
1845bfcada6cbb05d03e5e3ccc021c2ecea17cd2
lematty/lawn-mower
/lawn_mower.py
3,470
3.515625
4
x_list = [] y_list = [] facing_list = [] direction_tuple = ('N', 'E', 'S', 'W') # order of 90 degree rotation will never change instructions_list = [] boundaries = [] # Reads each line of file and populates lists def read_file(filepath): with open(filepath) as fp: line = fp.readline() count = 1 ...
ae5a534f7903f552e709d019785bac0c8844549e
CarlosUlisesOcampoSilva/Python
/For2.py
104
3.578125
4
cadena="" for j in range (1,6): for i in range (0,j): cadena = cadena + str(j) print(cadena)
ee09d3906de3c35653f0a05b940e22a0b0be2ee3
jainendrak/python-training
/Examples/3Functions/Intro/first.py
382
3.546875
4
'''def myfirst(name): print 'Hi %s this is a function call'%name myfirst('Sachin')''' def isEven(n): return n%2==0 def isPrime(n): for i in range(2,n): if n%i==0: return False else: return True #val = isPrime(6) #print val def nthFibo(n): a,b=0,1 for i in range(2,n+1...
5b7b87a8741fd72f2b386bad8f98fb3166b7bea8
synchronizedsynecdoche/Learn-Python-the-Hard-Way
/ex3.py
446
4.28125
4
print "I will now count my chickens:" print "Hens", 25.0+30.0/6.0 print "Roosters", 100.0-25.0*3.0%4.0 print "Now I will count the eggs:" print 3.0+2.0+1.0-5.0+4.0%2.0-1.0/4.0+6.0 print "I it true that 3+2<5-7?" print 3+3<5+7 print "what is 3+2?", 3+2 print "what is 5-7?",5-7 print "Oh, that's why it's False" print "Ho...
0155e540df9ffb903d74fc7ae4220c84f3e87ddc
seemavora/ICPC-LC-CCI
/ICPC/Winter12_27/permutedArithmetic.py
451
3.6875
4
numSeq = int(input()) sequence = [] numArr2 = [] def splitArr (arr): for i in range (len(arr)): tempStr = arr[i] arrList = (tempStr.split(' ')) arrList.pop(0) # print(arrList) numArr = [int(i) for i in arrList] numArr.sort() numArr2.append(numArr) return numArr2 # print(numArr2) f...
d64e68461faff518a38ee3025a851315acd96209
vansssa/python_assignment
/assignment1.py
219
3.515625
4
def is_perfect(num): return sum([ i for i in range(1, num) if num%i == 0 ]) == num #result=0 #for i in listnumber: # if num%i==0: # result=i+result #return result==num print is_perfect(6) print is_perfect(8)
10a24a72110e3a88068fd58c5f3edc31b045cca2
wenxu1024/Algorithm
/KnapSack/knapsack.py
509
3.578125
4
#! /usr/bin/python -tt def knapsack(c,w,p): l=len(p) A=[[0 for x in range(c+1)] for y in range(l+1)] for i in xrange(1,l+1): for j in range(c+1): if j<w[i-1]: A[i][j]=A[i-1][j] else: A[i][j]=max(A[i-1][j],A[i-1][j-w[i-1]]+p[i-1]) return A[l][c] if __name__=="__main__": pair...
a03a46ff86983203c34c7ee2d44bc516e524e49f
abaker178/python-challenge
/PyPoll/pypoll.py
2,934
3.625
4
# Dependencies import csv import os # declare variables csvpath = os.path.join("PyPoll", "Resources", "election_data.csv") candidates = { "names": [], "votes": [], "percent": [] } # compare each vote count to see who wins # return winner text def getWinner(c): curr_winner_votes = 0 ...
7302664bce79ac8ffc36ed2009ef4d49fd41c4c5
veerat-beri/dsalgo
/trees/bst/utils/check_bt_is_bst.py
1,939
3.796875
4
# Problem Statement # https://www.geeksforgeeks.org/a-program-to-check-if-a-binary-tree-is-bst-or-not/ from trees import LinkedBinaryTree, BuildLinkedBinaryTree import sys from trees.bst import BuildLinkedBinarySearchTree from trees.utils import Traversal def is_bt_bst(bt: LinkedBinaryTree, use_inorder=True): ...
cd990ec839a95b4e3c48de16516ab886c966f41e
jusongchen/pythonLearning
/execises/findPrimes.py
733
3.515625
4
def findFactors(num): import math upto = math.sqrt(num) for n in range(2,int(upto)+1): q,mod = divmod(num,n) if n != num and mod== 0: return (False,n,q) return (True,num,1) def processNumbers(fromNum, toNum): if fromNum <=0 or toNum <=0 or fromNum >toNum: prin...
55d5d6a5e5cd98b06f5cb2e138a7bd9186d92406
SANDEEP95890/Sudoku-Solver
/sudoku_solver.py
5,903
4.40625
4
""" Name: sudoku_solver.py Description: Solves Sudoku puzzles. First try to solve by filling in the cells with only one possibility. If it cannot go any further, use a backtracking DFS (depth-first search) algorithm to try the possible solutions. As soon as a solution is found, it terminates the algorithm and pr...
888ff189d7051af6ede24563f18c7f99757145f9
Jsrios29/Bayesian-Q-Learning
/BayesianAgent.py
14,709
3.5625
4
# -*- coding: utf-8 -*- """ Created on Sat Oct 31 13:18:01 2020 This class represents a Bayesian agent, which uses Bayesian Q learning to decide upon an action presented by a state Qvalue sampling: The agents knowledge of the available rewards are represented explicitely as probability distri...
a40ddbac7847cc3d2da67e51218d84538f6a4b4f
Thalisson01/Python
/Exercício Python #044 - Gerenciador de Pagamentos.py
790
3.640625
4
import time pn = float(input('Qual é o valor do produto? R$')) print('[ 1 ] à vista dinheiro ou cheque: 10% de desconto.') print('[ 2 ] à vista no cartão: 5% de desconto.') print('[ 3 ] em até 2x no cartão: preço normal.') print('[ 4 ] 3x ou mais no cartão: 20% de juros.\n') cp = int(input('Qual é a forma de pagamen...
8587e951dc368851268476d58bc554b6f528cc97
nachiketa-plutus/python_basics
/14_List&ListSlicing.py
453
3.5
4
# Same output for single quoted and double quoted strings. # Output includes string portion enclosed in single quotes. List = [44, 55, 44.55, True, "Raju", False, "Rahim", 33] print(List) List2 = [44, 55, 44.55, True, 'Raju', False, 'Rahim', 33] print(List2) # List Slicing List3 = ["Afzal", "Manish", 33....
d9b856f6a6a50b8f399d16783802cf5dd8be0854
Ekultek/codecademy
/Introduction to Bitwise Operators/1.py
1,256
4.65625
5
""" Description: Just a Little BIT Welcome to an intro level explanation of bitwise operations in Python! Bitwise operations might seem a little esoteric and tricky at first, but you'll get the hang of them pretty quickly. Bitwise operations are operations that directly manipulate bits. In all computers, numbers ar...
aef7e1b7dcdd6f1f6512bf05f4e43b83cdae0eaa
xuedong/hacker-rank
/Interview Preparation Kits/Interview Preparation Kit/Graphs/BFS: Shortest Reach in a Graph/bfs2.py
1,255
3.671875
4
#!/bin/python3 import queue from collections import defaultdict class Graph: def __init__(self, nodes): self.nodes = nodes self.edges = defaultdict(set) def connect(self, node_x, node_y): self.edges[node_x].add(node_y) self.edges[node_y].add(node_x) def find_all_distances(...
b2ae8863d58d267a5c94029062bf41f2b686bac5
omarcordero1/tipo_de_cambio
/conversor_de_moneda.py
221
3.671875
4
pesos = input("Cuántos pesos mexicanos tienes?: ") pesos =float(pesos) valor_dolar = 20.96 dolares = pesos/ valor_dolar dolare = round(dolares, 2) dolares = str(dolares) print("Tienes $ " + dolares + " dólares")
eabd9f588997d9037961f43ca57758c2e9cff943
petefarq/web-scraping-challenge
/mission_to_mars/scrape_mars.py
3,894
3.515625
4
from splinter import Browser from bs4 import BeautifulSoup import requests import pandas as pd def scrape(): #----- Get latest Mars news from NASA site---- url_nasa = "https://mars.nasa.gov/news/" response_nasa = requests.get(url_nasa) # Create BeautifulSoup object; parse with 'html.parser' so...
44b3d313b33bc4f6bc51e83a0abe925a1a2b6cbd
Zahidsqldba07/CodeSignal_Arcade
/Questions/Intro/Level 5/arrayMaximumAdjacentDifference.py
826
4.09375
4
""" Given an array of integers, find the maximal absolute difference between any two of its adjacent elements. Example For inputArray = [2, 4, 1, 0], the output should be arrayMaximalAdjacentDifference(inputArray) = 3. Input/Output [execution time limit] 4 seconds (py3) [input] array.integer inputArray ...
41d194d8514873df8c4701e849a0bbff6836591d
Sakishima/Main-rep
/np-edu1/path-3/edu-3.2.py
488
3.921875
4
# Функция для вычисления экспоненты def my_exp(x, n): s = 0 # Начальное значение суммы ряда q = 1 # Начальное значение добавки for k in range(n+1): s += q # Добавка к сумме q *= x/(k+1) # Новая добавка return s # Проверяем результат вызова функции x = 1 for n in range(11): prin...
082a03bc9f788614dcc004b4396c37b4e56ee27f
Hafizsaadullah/AI-Assignments
/Marksheet.py
1,384
4.28125
4
# Subject Alphabet Code E = "English" M = "Math" U = "Urdu" I = "Islamiat" C = "Computer" # Input and Output Marks E = int(input("Enter English Marks: ")) if E < 0 or E > 100 : print ("Please Enter Correct Marks (For Example 0-100)") M = int(input("Enter Math Marks: ")) if M < 0 or M > 100 : print ("P...
717b7e57c126389dd2ae26c63c62a766121695eb
chiragsanghvi10/ArtificialIntelligence
/speech/utils/objects.py
1,680
3.546875
4
class Frame(object): """Represents a "frame" of audio data.""" def __init__(self, bytes, timestamp, duration): self.bytes = bytes self.timestamp = timestamp self.duration = duration class Snippet(object): """Represents a snippet of the audio file post performing vad.""" def __in...
0603569cdd2a51bbce61853e37df9474aa310bd1
IrinaKrivichenko/stepic-nn
/NN.py
3,096
3.578125
4
import numpy as np class nn: def __init__(self, sizes, output=True): print('shape of the neural network:') print(sizes) print(f'input layer | number of neurons {sizes[0]} ') self.list_of_layers = [] np.random.seed(10) for x, y, i in zip(sizes[:-1], sizes[1:], range(l...
7cbd676a3c7a32c65ecd44dce12ce1f32caf8313
rodrigo-montenegro/curso-python
/atributos.py
861
3.734375
4
class Usuario: pass #sentencia nula def __init__(self, username='',correo='',nombre=''): self.username = username self.correo = correo self.nombre = nombre def saluda(self): print("Hola, soy un usuario " + self.nombre) def mostrar_username(self): print(self.us...
dbfe2dcc194deb7dd913e73a0254236a719bfa90
manoelsslima/datasciencedegree
/projetos/projeto-um/projetoum.py
7,462
3.90625
4
import csv ''' Data Science Degree - Let's code Autor: Manoel de Souza Silva Lima Data: 05/07/2021 ''' def abrir_arquivo(nome): '''Abre o arquivo informado e devolve uma lista com o arquivo organizado''' if (nome != None and nome != ''): try: arquivo = open(nome + '.csv', 'r') ...
b367293e84bcdee2645cc7b4f598e2444a4ab92f
ian-everett/python-helper
/numpy/main.py
971
3.875
4
''' numpy libary test ''' import numpy as np def redraw(board): ''' redraw game board ''' for row in board: print(row) def main(): ''' main() ''' current_board = np.zeros((3, 3)) # Create an 3 x 3 array of all zeros # fill some data current_board[0][0] = 1 curre...
369600f83d3830925df84a93b6ccfac208810106
BRZFA24/turtle-race
/main.py
1,711
4.1875
4
from turtle import Turtle, Screen import random is_race_on = False screen = Screen() screen.setup(width=500, height=400) user_bet = screen.textinput(title="Make your bet", prompt="Which turtle will win the race? Enter a color: ") print(user_bet) colors = ["red", "orange", "yellow", "green", "blue", "purple"]...
35d2141eea3ba5caa23d8fc9ae81a71037407b9b
MrHamdulay/csc3-capstone
/examples/data/Assignment_4/krdsha003/ndom.py
1,014
3.625
4
#Assignment 4 Question 2 #ndom #Shaheen Karodia #KRDSHA003 #2014-04-02 def ndom_to_decimal(a): b=0 Sum=0 power=len(str(a))-1 while power >-1: y=(6**(power))*(eval(str(a)[b])) Sum=Sum+y b=b+1 power=power-1 return (Sum) def decimal_to_ndom(a)...