blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
3d7f4e371f4112ea7d851feaeb68f1bc69fcf253
wirsu/hackerrank_solutions
/twin_strings.py
1,487
3.90625
4
def twins(a, b): # Input: a and b are arrays of strings (of equal length) # Return an array of length equal to length of a with "Yes and "No"s # n number of strings to process n = len(a) output = [None] * n for i in range(0, n): ai_odd = [] ai_even = [] b...
e8ccc177f92efa20ef6e4c959ccb5e5c29444c12
AlexLinGit/SICP-and-Other-Code
/Python Crash Course Exercises/chapter 11 - tests/city_country.py
326
4
4
def city_names(city, country, population=""): """Formats a city name and its country""" if population: formatted = city.title() + ", " + country.title() formatted += " - Population: " + str(population) else: formatted = city.title() + ", " + country.title() print(formatted + "\n") return formatted ...
c25ec2803a9bf51852dc1b49489b0a9d0d46c578
schiob/TestingSistemas
/ene-jun-2019/LuisOrnelas/Practica 1/Triangulos.py
456
3.875
4
a = float(input("Ingrese el Primer lado del Triangulo: ")) b = float(input("Ingrese el Segundo lado del Triangulo: ")) c = float(input("Ingrese el Tercer lado del Triangulo: ")) if (a+b)>c and (a+c)>b and (b+c)>a: print("\nLos lados corresponden a un Triangulo:") if (a==b==c): print("\tEquilatero") ...
344f5a41543f7d64795e47b53bfab443f93da245
wxkpythonwork/sklearn_exam
/hungryalgorithm.py
3,302
3.53125
4
#!/usr/bin/env python # encoding: utf-8 """ @version: python2.7 @author: wxk @license: Apache Licence @file: hungryalgorithm.py @time: 2018/3/14 21:08 """ import timeit from collections import deque # ============================================================================== # 匈牙利算法 # ============================...
eecf88de6663ff92751e5d351d896226172db8dc
EvilPuddingLemon/LearingFluentPython
/S8/s8_7.py
459
4.03125
4
import copy t1 = (1, 2, 3) t2 = tuple(t1) print(t2 is t1) # t1 和 t2 绑定到同一个对象。 t3 = t1[:] print(t3 is t1) t4 = (1, 2, 3) t5 = copy.deepcopy(t1) print(t4 is t1) # 在控制台上建立两个一样的元祖则会输出false,而执行这个则会输出True,可能是优化了不会新建副本 print(t5 is t1) # 而使用深复制的无论是控制台和执行都没有新建副本,都是输出True s1 = 'ABC' s2 = 'ABC' print(s1 is s2)
a30f5ca5fac728d808ef78763f16ca54290765f6
AdamsGeeky/basics
/01 - Basics/11-flowcontrol-for-enumerate-loops.py
1,129
4.78125
5
# HEAD # Python FlowControl - for loop # DESCRIPTION # Describes usage of for loop in different ways # for different usages # # 'for' loop can iterate over iterable (sequence like) or sequence objects # Result provided during every loop is an index and the relative item # # RESOURCES # # # USAGE # 1 # # for i...
ea6462e819b7f92a02c0dee9a35277880b17e872
PythonPramod/OopsCaseStudies
/Assignment5.py
463
3.890625
4
# Person class class Person: def __init__(self,first_name,last_name,email,dob): self.first_name = first_name self.last_name = last_name self.email = email self.dob = dob def display(self): print("First Name:",self.first_name) print("Last Name:",self.last_name) ...
f1d9d311a5b6c716435a6a795c4d14c1205bb2cf
akshafmulla/PythonForDataScience
/Basics_of_Python/Code/10 for Loops.py
2,536
3.9375
4
# -*- coding: utf-8 -*- """ Created on Mon Feb 25 17:54:42 2019 @author: akshaf """ #For Loops for i in range(1,11,1): print(i, end=' ') # FInd odd number for i in range(1,11,2): print(i, end=' ') #Print the number in sequence taken from user n = eval(input("Enter number")) for i in range(1,n+1,1): ...
bcde53b5c881b40f7b1dde56d9a384134e048595
jkereako/algorithms
/tests/test_binary_search.py
1,007
3.5
4
import algorithms from algorithms import binary_search import unittest class TestBinarySearch(unittest.TestCase): def setUp(self): self.list = [i for i in range(10000)] self.high = len(self.list) - 1 self.low = 0 def test_for_element_in_list(self): found = binary_search.binary_...
065dd88662c75f649179f6407a086a7828759ee6
asitang/sklearn-hierarchical-classification
/examples/classify_digits.py
1,866
4
4
#!/usr/bin/env python """ Example of using the hierarchical classifier to classify (a subset of) the digits data set. Demonstrated some of the capabilities, e.g using a Pipeline as the base estimator, defining a non-trivial class hierarchy, etc. """ from sklearn import svm from sklearn.decomposition import TruncatedS...
5b2827414171e40916d5cca7fc8c443b60ea27fe
MR1213/Python
/PycharmProjects/pythonProject0001/lesson0007.py
457
3.9375
4
import turtle, random colors = ["red", "green", "blue", "orange", "purple", "pink", "yellow"] turtle.shape("turtle") turtle.hideturtle() turtle.pensize(10) turtle.speed(0) color = random.choice(colors) turtle.penup() turtle.goto(0,-90) turtle.pendown() for count in range(300000): color = random.choice(colors) t...
afa7ecf7e8edfa180a98683c46f69ed2b3080622
annamaryjacob/Python
/Flowcontrols/Looping/numrev.py
87
3.6875
4
i=0 n=int(input("Enter the number")) while(n!=0): print(n%10,end="") n=n//10
5feadf9a45ec81af002f4512ddc0d697816660f0
vivekshetty1902/LineCoding
/linecoding.py
1,966
3.53125
4
import numpy as np import matplotlib.pyplot as plt num_bits=int(input("Please enter number of bits:")) y=[i/2 for i in range(num_bits*2)] y=[] manchester=[] diff_manchester=[] bits=[] print("Enter the binary string:") for i in range(num_bits): y.append(i) y.append(i+0.5) y.append(i+0.5) y...
e30df21a0f0b1dca737b959447ba95f10e377b80
bugbuglou/hessian
/hessian_eigenthings/operator.py
614
3.609375
4
""" Basic linear operator abstractions """ class Operator: """ maps x -> Lx for a linear operator L """ def __init__(self, size): self.size = size def apply(self, vec): """ Function mapping vec -> L vec where L is a linear operator """ raise NotImplemented...
f8e0512e9378975c0094c3e05ecfc1f4add6cb4d
osipov-andrey/various_tasks
/ITVDN_Python_Advanced/006_typing/006_Homework/1_1_typing_classes.py
1,158
3.828125
4
from typing import List class Directory: def __init__( self, name: str, files: List['File'] = None, sub_directories: List['Directory'] = None, root: 'Directory' = None, ): self.name = name self.root = root self.files = files ...
eff3881f6b4f4bd25eeff5544714bb1a82826a8a
kyajpauley/cerebro
/UnitTests/TestRequiredUnits.py
852
3.59375
4
import unittest from Classes.RequiredUnits import RequiredUnits class TestStringMethods(unittest.TestCase): def test_RequiredUnits(self): testrequiredunits = RequiredUnits('Have a minimum of 60 units in the major') self.assertIsNotNone(testrequiredunits) self.assertEqual(True, testrequiredu...
72ccb3d45bcaed85e3548769ad87c6d125981745
bmdavi3/euler
/euler6.py
267
3.921875
4
def sum_of_squares(numbers): _sum = 0 for n in numbers: _sum += n * n return _sum def square_of_sums(numbers): _sum = sum(numbers) return _sum * _sum numbers = xrange(1, 101) print square_of_sums(numbers) - sum_of_squares(numbers)
49843c5496c92edff354e733ad38fca1417e5be8
josemalcher/Schoolofnet-Programador-Python
/01-Iniciando_com_python/functions.py
453
3.5625
4
def call_numbers(): for number in range(0,10): print(number) #call_numbers() def call_numbers_Limit(limit): #list = range(0,10) for number in range(limit): print(number) #call_numbers_Limit(5) def call_numbers_with_limit(limit): for number in range(10, limit): print(number) ...
1d6caff7e235e556f283951f2454d6b24d02c002
k-azadzoi/exercise.python_fundamentals
/src/main/string_evaluator.py
1,931
3.84375
4
# Created by Leon Hunter at 3:57 PM 10/23/2020 class StringManipulator(object): def get_hello_world(self): greeting = "Hello World" return greeting # TODO - Implement solution def concatenate(self, value_to_be_added_to, value_to_add): new_value = str(value_to_be_added_to) + str(...
81366c32de803b44c5006c9c858adf739c5426a1
ellakcd/mellons
/harvest.py
4,936
3.5
4
############ # Part 1 # ############ class MelonType(object): """A species of melon at a melon farm.""" def __init__(self, code, first_harvest, color, is_seedless, name, is_bestseller=False ): """Initialize a melon.""" self.pairings = [] self.code = code s...
2dfb98f2b4a3d83a93fc45e443380bb77f35c364
mahshidAM/Student-Data-Management
/model.py
6,634
3.8125
4
# -*- coding: utf-8 -*- """ Created on Thu Oct 28 17:27:02 2021 @author: mahsh """ import sqlite3 from sqlite3 import Error import pandas as pd class Model(): """School data management model""" def __init__(self): self.conn = sqlite3.connect('./data/school_management.db') def createRecord...
bc240e492449ca990560ef880ecad548a30796c4
leandro-alvesc/estudos_python
/guppe/erros/debuggando_com_pdb.py
2,457
4.03125
4
""" Debuggando com PDB PDB -> Python Debugger OBS: A utilização do print() para debuggar é uma prática ruim def dividir(a, b): print(f'a={a}, b={b}') try: return int(a) / int(b) except (ValueError, ZeroDivisionError) as err: return 'Ocorreu um erro: {err}' print(dividir(4, 7)) # Existem f...
7a36a6eb87672b4b13f8e69b97a092d6e8b12342
austinfouch/cmps367_hw2
/homework2.py
2,946
3.78125
4
def build_periodic_table(filename="periodic_table.txt"): input_file = open(filename, 'r') table = dict() for element in input_file: tokens = element.split() table[tokens[2]] = (tokens[1], int(tokens[0]), float(tokens[3])) return table def getInput(): while True: print("1) Search by s...
e7075ae4a49108e1c7bdd1a8a2d9fcd3e26eb8d7
hac425xxx/cpf
/test/graph/dfs.py
527
3.640625
4
#!/usr/bin/python # -*- coding: UTF-8 -*- # Check for the visisted and unvisited nodes def dfs(graph, start, visited=None, end_nodes = []): if visited is None: visited = set() visited.add(start) print(start) if start in end_nodes: return for next in graph[start] - visited: ...
0c5999fdf2cb64c6340e4ce1ffe0a418b028400d
eranfuchs1/DI_Bootcamp
/Week4/Day2/exercise_xp/exercise9/untitled.py
238
4.09375
4
fruits = input('enter your favorite fruits (space delimited): ').split(' ') if input('enter a fruit name: ') in fruits: print('You chose one of your favorite fruits! Enjoy!') else: print('You chose a new fruit. I hope you enjoy')
daf92cf0b3d9b0eefe657d7ca8fa9b6ab03aa83c
NBarnfield/CS-3-Coding-Exercises
/Chapter_2/Chapter2_ex3.py
165
4.1875
4
hours = input("How many hours did you work? ") rate = input("What is your hourly rate? ") pay = float(hours) * float(rate) print("Your wage will be {}.".format(pay))
b5d58f9fa207227ed87c694ca15474a35a977262
hakobera54/python
/4-12.py
147
3.5625
4
n=int(input("現在の西暦を入力してください:")) if n%4==0 or n%400==0: print("閏年です") elif n%100==0: print("平年です")
99f1f9a0fa9499a2a71c98e18c6bc7278bd73d6b
vector67/advent-of-code-2019
/Day 3/3-2.py
4,500
3.84375
4
directions_x = { 'R':1, 'L':-1, 'U':0, 'D':0 } directions_y = { 'R':0, 'L':0, 'U':1, 'D':-1 } print('') def get_wire_from_line(line): tokens = line.split(',') wire = [[0,0]] current_location = [0,0] for token in tokens: direction = token[0] distance = int(...
60f358705159b2f11be319b1e2b0e9011ff4c11b
JAYB2298/python
/assis_2.py
309
3.921875
4
source=input("Enter number between 0.0 to 1.0,") try: sc=float(source) except: print("Error Enter Number") if sc<=0 or sc>=1.0: print("Error") elif sc>=0.9: print("A") elif sc>=0.8: print("B") elif sc>=0.7: print("C") elif sc>=0.6: print("D") elif sc<0.6: print("Fail") quit()
98ea58873715e658245c0760a32e4eeb2ba6771b
MitsurugiMeiya/Leetcoding
/leetcode/Tree/96. 二叉搜索树的数量.py
1,727
3.734375
4
""" Given n, how many structurally unique BST's (binary search trees) that store values 1 ... n? Example: Input: 3 Output: 5 Explanation: Given n = 3, there are a total of 5 unique BST's: 1 3 3 2 1 \ / / / \ \ 3 2 1 1 3 2 / / \ ...
d45c7ff1bb41a2f529ca7b51f91d0d616bc45308
deepbsd/OST_Python
/ostPython4/test_naivearr2.py
2,330
3.828125
4
#!/usr/bin/env python3 # # # test_naivearr2.py # # Lesson 2: Data Structures # # by David S. Jackson # 7/7/2015 # # OST Python4: Advanced Python # for Pat Barton, Instructor # """ Test list-of-list array implementation using tuple subscripts" """ import unittest import naivearr2 as arr ...
ee8529be850e2a9636c0d6d77e44b3df18a034f3
Wangsteris/wangsteris.github.io
/while4.py
133
3.515625
4
acc=10 while acc >-1: print(acc) acc=acc-1 import time time.sleep(1) print('Time is Up boiiiiiiiiii!!!!')
60f9900fd212d37f012e19c4728b712b077f0f15
ariadn3/Athena
/Medium puzzles/stockExchangeLosses.py
238
3.53125
4
highestPoint = -1 biggestLoss = 0 n = int(input()) for i in input().split(): v = int(i) if v > highestPoint: highestPoint = v elif v-highestPoint < biggestLoss: biggestLoss = v-highestPoint print(biggestLoss)
f3a976799813a74a5463abe23e4999bc91b7387b
terintelivia/program-11
/pr11.py
2,694
3.625
4
n=int(input('Dati numarul de elemente din vector=')) a=[] print('Introduceti ',n,'elemente pentru vectorul creat') #if n<10: for i in range(0,n): x=int(input('Dati elementul=')) a.extend([x]) print('a) Afiseaza pe ecran componentele tabloului la un interval de 5 pozitii:',a) print('b) Afiseaza pe ecran ...
2a1a3027c253cb842217d6599b38ab1d954e13be
asifikbalpro/NumericalPy
/Solution/N-1-1-1-Fibonacci-Sequence.py
563
3.734375
4
# there's still one problem # the loop is infinty.. def mygold(n): x = 1 while n >= 1: x = 1 + 1 / x n -= 1 # print ("x= %d", x) return x def myfibo(n): golden = mygold(100) # call function once and save the value for later use # a = (golden ** n+1 - (1 - golden ** n+1) # problem brackets a**b+1 and ...
9a0a43e48dead2c5da0a7c38f52fd208044b9cb3
nbvc1003/python
/ch13/ser_index2.py
616
3.671875
4
import pandas as pd fruit = pd.Series([4000, 3000, 3500, 2000], index=['apple','mellon','orange','kiwi']) # index 1, mallon data출력 # index 1, mallon 인덱스 +데이터 # index 1 :3 # index mellon : kiwi # 4000작고 2000큰데이터 print(fruit[1]) print(fruit['mellon']) print('===============================') print(fruit[[1]]) print(fr...
866729883e3c39526f913a8b7afe153a1b38ce20
maverickz/Leetcode
/calculate_painting_cost.py
1,661
3.71875
4
""" There are a row of houses, each house can be painted with three colors red, blue and green. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color. You have to paint the houses with minimum cost. """ def calculate_p...
df552477504ff7033716315db8d3324545487a01
rodrigohpalmeirim/py3d
/engine.py
3,706
3.515625
4
from graphics import GraphWin, Point, Line from math import sin, cos, tan, radians field_of_view = radians(45) class Solid: def __init__(self, vertices, connections): self.vertices = vertices self.connections = connections self.items = [] def draw(self, window, color="gray", width=1, ...
2128eeb74a5c491f97b112267df23895bf84d4ba
shubham-ks14/Python_basics
/Programming_basics/4_Variables/Ex6_example.py
763
4.8125
5
# ** is used for dictionaries # Program to demonstrate unpacking of dictionary items using ** def fun(a,b,c): print(a,b,c) # A call with unpacking of dictionary d = {'a':2, 'b':3, 'c':5} fun(**d) # output is values fun(*d) # output is keys #%% # Program to demonstrate packing of dictionary ite...
8e217d6472c58f3f1d9ba9b18cf15ddd932ffb9b
tomdee/president
/framework.py
9,803
3.515625
4
# This is a very simple Python 2.7 implementation of the Information Set Monte Carlo Tree Search algorithm. # The function ismcts(rootstate, itermax, verbose = False) is towards the bottom of the code. # It aims to have the clearest and simplest possible code, and for the sake of clarity, the code # is orders of magnit...
c139fd7f2a8e6e3ad055008301237f8e21c2b030
stoneriver/AOJ-Python
/Lesson - ALDS1/ALDS1_3_B.py
1,525
3.609375
4
# Queue キュー class Queue(): def __init__(self, size): self.size = size self.Q = [None for i in range(size)] self.top = 0 self.btm = 0 def enqueue(self, x): self.Q[self.btm] = x; self.btm += 1; if self.btm >= self.size: self.btm ...
3f0e84859780edbe0295a12fc0d5dcd925f9a8bf
hklb94/qualification-seminar-materials-2018
/session-7/homework_solutions/insertion_sort.py
322
3.8125
4
def insertion_sort(data_list): for i in range(1,len(data_list)): curr_val = data_list[i] position = i while position > 0 and data_list[position - 1] > curr_val: data_list[position] = data_list[position - 1] position = position - 1 data_list[position] = curr_v...
34dec3809c0327a7de693d59551b1039169aefcf
lirixiang123/algorithm
/src/剑指offer/14-FindKthToTail.py
1,105
3.53125
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2020/6/6 22:40 # @Author : lirixiang # @Email : 565539277@qq.com # @File : 14-FindKthToTail.py """ 输入一个链表,输出该链表中倒数第k个结点。 """ # -*- coding:utf-8 -*- # class ListNode: # def __init__(self, x): # self.val = x # self.next = None #解法一:普通解法 cl...
db5a120bf4cf0d5d94df8b1b18446ee8950081f1
Igor7086/Lesson2
/Task2_5.py
337
4.1875
4
x = float(input("Введите положительное действительное число: ")) print("Дробная часть числа: ",(x%1)) """ x = float(input("Введите положительное действительное число: ")) print("Дробная часть числа: ", x-int(x)) """
74ceb42b77927981e11b352b600083894b4d4915
chaitraliv/Assignments
/P22.py
554
4.09375
4
#SOLUTION FOR P23 #P22 (*) Create a list containing all integers within a given range. lower= int(input (' Enter lower limit = ')) #TAKE LOWER AND UPPER LIMIT FROM THE USER upper= int(input (' Enter upper limit = ')) #FUNCTION TO PRINT DATA BETWEEN 2 LIMITS def print_data(lower,upper): mylist=[] ...
9106c991285e49e82bdaff557347601f893de4be
a625687551/Leetcode
/Leetcode/21. Merge Two Sorted Lists.py
568
4.0625
4
# !/usr/bin/python # coding: utf-8 # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def mergeTwoLists(self, a, b): """ :type l1: ListNode :type l2: ListNode :rtype: ListNode ...
6fc513f2c229995c43ff6ac1a60bb706bfa078af
py1-10-2017/JohnPetersen_python
/FilterByType.py
7,259
3.703125
4
#FILTER BY TYPE sI = 45 mI = 100 bI = 455 eI = 0 spI = -23 sS = 'Rubber baby buggy bumpers' mS = 'Experience is simply the name we give our mistakes' bS = 'Tell me and I forget. Teach me and I remember. Involve me and I learn.' eS = ' ' aL = [1,7,4,21] mL = [3,5,7,34,3,2,113,65,8,89] lL = [4,34,22,68,9,13,3,5,7,9,2...
ae22ca5e90fb69fb486235b20443a72499917760
taritro98/DSA_Prac
/stack.py
492
3.765625
4
class Node: def __init__(self, data): self.data = data self.next = None class Stack: def __init__(self): self.head = None def isEmpty(self): return self.head == None def push(self, item): new_node = Node(item) if self.isEmpty(): ...
00102f216a965140d2707bb7c3f01f95930fa08b
IceDerce/learn-python
/learning/function_varargs.py
866
4.09375
4
def total(a=5, *numbers, **phonebook): """ 它是如何工作的。 当我们声明一个诸如 *param 的星号参数时,从此处开始直到结束的所有位置参数 (Positional Arguments)都将被收集并汇集成一个称为“param”的元组(Tuple)。 类似地,当我们声明一个诸如 **phonebook 的双星号参数时,从此处开始直至结束的所有关键字 参数都将被收集并汇集成一个名为 phonebook 的字典(Dictionary)。 """ print('a', a) # 遍历元组中的所有项目 for single_...
31e10869643bc39445c7b105b167211076dcf5b2
vaibhavg12/Problem-Solving-in-Data-Structures-Algorithms-using-Python3
/Algorithms/2 Searching/APArray.py
1,635
3.546875
4
""" Given an array of N intergers you need to find if array elements can form an Arithimatic progression. """ import sys def isAP(arr): size = len(arr) if (size <= 1): return True arr.sort() diff = arr[1] - arr[0] for i in range(2, size): if (arr[i] - arr[i-1] != diff): ...
e6a55ed81f6b9f7fdc8ce1464756f926e348a60b
phpcolt/python
/zuoye/zuoye4.py
1,236
3.546875
4
#coding=utf-8 ''' 列举布尔值是False的所有值 None False 数值中的零,包括0,0.0,0j(虚数) 空序列,包括空字符串(”),空元组(()),空列表([]) 空的字典{} 自定义的对象的实例,该对象的__bool__方法返回False或者__len__方法返回0 ''' ''' l1 = [11,22,33] l2 = [22,33,44] 1、获取内容相同的元素列表 2、获取l1中有,l2中没有的元素列表 3、获取l2中有,l3中没有的元素列表 4、获取l1和l2中内容不同的元素 ''' l1 = [11,22,33] l2 = [22,33,44] list1 = set(l1) l...
16aef4bec7f547964e14cdfd8df45b1cf713452a
auraz/ca
/archive/ca/animation.py
2,917
3.921875
4
# -*- coding: utf-8 -*- """Визуализация клеточного автомата. Клавиша Enter - одна итерация, Spase - запустить/остановить анимацию """ import pygame, sys, math from ca import * # GLOBAL CONSTANTS TIMER_INTERVAL = 333 # интервал между итерациями в миллисекундах CANVAS_WIDTH = 1300 CANVAS_HEIG...
2ad44c855d19184d58362d1bc1274da005925cf3
ujjwalraina/CodingPractice
/max_frequency_in_string.py
809
3.734375
4
def test_max_frequency(strings,answer): print (max_frequency(strings)==answer) def test(): test1 = "aaaabbccddd" test_max_frequency(test1,'a') test2 = "AAAbbD" test_max_frequency(test2,'A') test3 = "ujjwal raina" test_max_frequency(test3,'a') test4 = "AabBcDCd" test_max_frequency(te...
d2f99ffe3d2d5ae2877fe69fdc1ff7d7846450b9
arovit/Coding-practise
/leetcode/serialize-and-deserialize-bst.py
1,732
3.75
4
#!/usr/bin/python # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Codec: def serialize(self, root): """Encodes a tree to a single string. :type root: TreeNode ...
3311193ce5b79158707bf544bcfe361dd8ad8ac2
awoka333/python_practice
/python crash course 01-8/assignments.py
677
3.515625
4
# 8-9 """ def show_messages(messages): for message in messages: print(message) messages = ["おはよう", "こんにちは", "こんばんは"] show_messages(messages) """ # 8-10 def send_messages(messages): for message in messages: print(message) sent_messages.append(message) sent_messages = [] messages = ["おはよう", "こんに...
5418149c93b25eda3adb104fae2a5a5fbfe91f9f
HenryNewcomer/CollegeProjects
/2020 - Intro to Programming/2020-10-18_d9_disc.py
1,288
3.921875
4
# Author: Henry Newcomer countries = ["Mexico", "Canada", "USA", "Germany"] print("Third element: ", countries[2]) countries[3] = "France" print(" -------------\nList of countries:") for country in countries: # The weird "u" tells Python to show a unicode-escaped character. # Since it's a specific character a...
6177dddf83e670eb8d467c5399b3e4d596b41977
perrym6949/CTI110
/P2HW2_ListSets_PerryMadelyn.py
1,331
4.28125
4
#CTI-110-0902 #P2HW2 - List and Sets #Madelyn Perry #3/9/2021 # #creates empty list listA = [] #asking how many numbers to input in list num = int(input("Please Enter the length of the list: ")) #append numbers in list for i in range(1, num + 1): num= int(input("Enter Numbers: ")) listA.append(num) ...
5102fad22e36a9a2db57920bb882f6dbfaeff2e3
hukeyy/learn_python
/day24-1/test.py
5,332
4.1875
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # Author: hkey # class Father1: # 定义父类 # print('class Father1') # # # class Father2: # 定义父类 # print('class Father2') # # # class Son1(Father1): # 单继承,父类:Father1 子类:Son1 # pass # # # class Son2(Father1, Father2): # 多继承: 父类:Father1, Father2 子类:Son2 # pass ...
ab6aad00928db133f947e7ec377627ce21b8d871
benfrisbie/python-puzzles
/top-k-keywords/top-k-keywords.py
2,186
3.515625
4
import unittest def top_k_keywords(reviews, keywords, k): keyword_count = {} keywords.sort() for keyword in [keyword.lower() for keyword in keywords]: keyword_count[keyword] = 0 for review in reviews: if keyword in review.lower(): keyword_count[keyword] += 1 ...
b6029fc3f14454ea2439b1cc22531e33290dd81d
bryandeagle/practice-python
/09 Guessing Game One.py
706
4.28125
4
""" Generate a random number between 1 and 9 (including 1 and 9). Ask the user to guess the number, then tell them whether they guessed too low, too high, or exactly right. (Hint: remember to use the user input lessons from the very first exercise) Extras: 1. Keep the game going until the user types “exit” 1. Keep tra...
6e71008d40d81f2e8b925d3f2ef928917837bb44
YosriGFX/holbertonschool-machine_learning
/math/0x05-advanced_linear_algebra/0-determinant.py
1,369
4.09375
4
#!/usr/bin/env python3 '''Determinant''' def new_m(matrix, a, b): '''new_m''' return [ [ matrix[i][j] for j in range(len(matrix[i])) if j != a ] for i in range(len(matrix)) if i != b ] def determinant(matrix): '''Calculates the determinant of a matrix'...
2d9bf0ab33083bb369932b82bed9e4dc925d001a
kyungtae92/python-basic
/day1001/Input05.py
303
3.984375
4
# 문자열은 인덱스 번호가 부여가 된다(문자단위로) strTemp = input("아무 문자열이나 입력하세요:") print("strTemp : ", strTemp) print("strTemp : %s" % strTemp) print('strTemp[0] : ', strTemp[0]) print('strTemp[1] : ', strTemp[1]) print('strTemp[2] : ', strTemp[2])
25915829b20ece82412907cb10d66437e1951bba
Aasthaengg/IBMdataset
/Python_codes/p02594/s732940370.py
66
3.65625
4
X = int(input().rstrip()) r = 'Yes' if X >= 30 else 'No' print(r)
0e8becc7ef8da70ecd06ffe44b146e9851d00f56
alihumes/python-challenge
/PyBank/main.py
2,164
3.578125
4
#name dependecies import os import csv #name variables months = [] revenue = [] revenue_change = [] #open "budget_data.csv" file_path = os.path.join("/Users/Ali/Desktop/DataBootCamp/WASHSTL201806DATA4-Class-Repository-DATA/Week 3 - Python/Homework/PyBank/Resources/budget_data.csv") with open(file_path,'r') as csvfile...
1cc5e3032b71bbeb7889ce7ffbea865598c9bb05
codbop/AI_mall_customers
/normalization.py
270
3.5
4
# -*- coding: utf-8 -*- from sklearn import preprocessing import numpy as np a = np.random.random((1, 4)) print(a) a = a*20 print("Data = ", a) # normalize the data attributes normalized = preprocessing.normalize(a) print("Normalized Data = ", normalized)
f9ff485e0a719cd31c84bb4852221b1b59ce30c8
ppakorn/dotaIsDown
/Codewars/4kyu/nesting-structure-comparison.py
979
3.671875
4
def same_structure_as(original, other): if not isinstance(original, list) or not isinstance(other, list): return type(original) == type(other) if len(original) != len(other): return False for i in range(len(original)): if isinstance(original[i], list): if isinstance(oth...
5e03df83e2a894815f5d7f5992ef1ffcd91bcb6b
cwza/leetcode
/python/240-Search a 2D Matrix II.py
891
3.765625
4
from typing import List class Solution: def searchMatrix(self, matrix: List[List[int]], target: int) -> bool: "Search from right-up to left-bottom, Time: O(m+n), Space: O(1)" m, n = len(matrix), len(matrix[0]) i, j = 0, n-1 while True: if i < 0 or i >=m or j < 0 or j >= ...
e5b8d225f21cb798e19b2c6f347c13a1c741da8f
erikseyti/MITx-6.00.2x
/Exercicios - Semana 1/Exercicio 1 - Greedy Cow Transport - 3.5.py
1,821
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Apr 4 12:12:50 2020 @author: erik """ ## Renomear Metodo para agir como uma função. # cows ={'Maggie': 3, 'Herman': 7, 'Betsy': 9, 'Oreo': 6, 'Moo Moo': 3, 'Milkshake': 2, 'Millie': 5, # 'Lola': 2, 'Florence': 2, 'Henrietta': 9} cows = {"Je...
f90e0f2d1f3ca3ee8b19ea09ef55c4ca4b4eba05
RogerMTorres/MisionTic
/Ciclo1/Proyecto 1/nivelacionclase3/Clase3p2.py
612
3.765625
4
def producto_mas_costoso (carrito_compras: dict) -> str: if carrito_compras == {}: return "no hay productos en el carrito" productos = sorted(carrito_compras.keys()) maximo = max(carrito_compras.values()) for producto in productos: if carrito_compras[producto] ==maximo: ...
6da5300c5a1867840e034c1050d56b353732670b
Rameshganesan/Mypython
/case_swap.py
281
4.03125
4
def swap_case(s): k = list(s) print(k) j = [] for i in k: if (i.islower() == True): j.append(i.upper()) else: j.append(i.lower()) return ''.join(j) if __name__ == "__main__": a = 'PreeTHI1' print(swap_case(a))
69c41444e17903277aae9a7dae075f37dcf1d7e9
DenisVritov/algorithms
/easy_collection/strings/reverse_integer.py
451
4.0625
4
""" Given a 32-bit signed integer, reverse digits of an integer. Input: 123 Output: 321 """ from typing import * def reverse_integer(x: int) -> int: """ Convert to string then reverse, keeping track of the sign of the value """ negative = -1 if x < 0 else 1 reversed_int = negative * int(str(abs...
a40403393d5bd35d210ed1c3642875ab32238c50
jayten-jeon/problem-solving
/leetcode/02-add-two-numbers.py
776
3.765625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: num1 = [] num2 = [] while l1.next: num1.append(s...
6948beabc7f835c55aa4820d1097bc9de83b9499
fenglihanxiao/Python
/Module01_CZ/day7_data_struct_str/04-代码/day7/119_切片.py
171
3.796875
4
""" 演示切片 """ list1 = [1,2,3,4,5,6] tuple1 = (1,2,3,4,5,6) set1 = {1,2,3,4,5,6,5,6} dict1 = {1:"aa",2:"bb",3:"cc",4:"dd"} print(list1[0:6:1]) print(list1[6:-1:-1])
9279d18f7f9deaed79b30b22d096688f16d7b8c1
bencummings/goo-py
/solutions/03_list_a.py
2,188
4.28125
4
""" Completed solutions for the first set of basic list exercises featured within Google's Python course. Usage: python 03_list_a.py """ def match_ends(words): """ Returns the count of words (contained within a list) that have matching start and end characters. """ count = 0 for word in...
ff0d1790cebf36c3abcf4b9a24452912b3b4dff6
zhangfaquan/AutonomousRobotChallenge
/motor_controls/gpioServo.py
1,739
3.765625
4
import RPi.GPIO as GPIO # always needed with RPi.GPIO from time import sleep class MotorControls: def __init__(self, pin1=18, pin2=19): GPIO.setmode(GPIO.BCM) # choose BCM or BOARD numbering schemes. I use BCM GPIO.setup(pin1, GPIO.OUT)# set GPIO pin1 as an output. You can use any GPI...
b063f577270259878d316014f0ab87d0e67ccc2b
koftyan/Simple-Neuros
/python/operations.py
1,156
3.734375
4
def elementwise_multiplication(vec_a, vec_b): assert(len(vec_a) == len(vec_b)) product = [] for i in range(len(vec_a)): product.append(vec_a[i] * vec_b[i]) return product def elementwise_addition(vec_a, vec_b): assert(len(vec_a) == len(vec_b)) product = [] for i in range(len(vec_a)): product.appe...
aa16c3e34b827a47f5fed9af8defa3e174786fa3
annisa-nur/wintersnowhite
/mainstatistic.py
958
3.515625
4
import statistic def main(): nama_file = input('Masukkan nama file: ') try: with open(nama_file, 'r') as input_file: data = input_file.readlines() for idx in range(len(data)): data[idx] = float(data[idx]) d...
62d618417f6bd3038add2272805e76e649d31e81
mehradadimi/Ferry_Average_Monthly_Delay
/Code/decoder.py
7,724
3.5
4
import string from cipher import dateT import datetime import re from cipher import DecryptException from cipher import FileDecoder """ This function uses get_pass() function to get the correct password from the user and returns an instance of FileDecoder class """ def create_instance(input_file, alphabet): whil...
209465b985164815a94bab7b00503670be984f46
keinam53/Python_Poczatek
/Wbudowane_struktury_danych/2_str/przyklad_1.py
967
3.765625
4
def run(): number_parts = ["123", "456", "789", "345"] print("-".join(number_parts)) print("".join(number_parts)) name = "-| Mariusz |-" left_clean = name.lstrip("-| ") right_clran = name.rstrip("-| ") both_clean = name.strip("-| ") print(name) print(f"{left_clean} B") print(f...
908262668a8718b3d2dc31db04979407b9860fea
ketansarode9/Client-Server-Socket-Programming-TCP-IPV4
/client.py
1,732
3.703125
4
import socket # Import socket module import sys import ipaddress try: try: host = str(ipaddress.ip_address(sys.argv[1])) # Reading IP Address port = int(sys.argv[2]) except IndexError: print("Wrong arguments - Terminating the Program") exit(1) ...
5471a9977ddb9b43c1f0f5d4cb8119f7573c4bbf
mattheuslima/Projetos-Curso_Python
/Aulas/Aula08.py
1,037
4.0625
4
#Import de bibliotecas e módulos #Para importar uma biblioteca completa, bastar utilizar o comando IMPORT e escolher a biblioteca, conforme abaixo import math num=float(input('Digite um número: ')) print('A raiz de {} é {}'.format(num,math.ceil(math.sqrt(num)))) #Se eu quiser selecionar apenas um módulo específico ...
d76e989f6a87271cc67260b0f5ec5737d3411116
fitrifebriyani/Dumbways_Fitri-Febriyani
/no2.py
612
3.765625
4
def productArray(arr, n): if (n == 1): print(0) return kiri = [0]*n kanan = [0]*n prod = [0]*n kiri[0] = 0 kanan[n-1]=0 for i in range(1,n): kiri[i] = arr[i-1] + kiri[i-1] for j in range(n-2, -1, -1): kanan[j] = arr[j+1] + kanan[j+1] for i in ra...
075c2224621c0bebfea6e5d205f7c8fc128b5153
akanshumahajan/Orient_Tbot_Polaris
/src/turtle_polaris/src/PI_controller.py
656
3.5
4
#!/usr/bin/env python2 import rospy class PI(object): """Simple PI controller class""" def __init__(self, P=1.0, I=0.0): self.kp = P self.ki = I self.current_time = rospy.get_time() self.previous_time = self.current_time self.clear() def clear(self): self...
c7684899dac9052316f31d23c56b1f9ff4e80c3c
LeoGraciano/python
/Manipulação de nome.py
475
3.6875
4
n = str(input('Qual seu nome: ')).strip() print('Seu nome é: {}.'.format(n)) print('Maiusculo: {}'.format(n.upper())) print('Minusculo: {}'.format(n.lower())) #nse = n.split() #nsec = len(nse[0]) #print ('Quantas letras tem o primeiro nome: {}'.format(nsec)) #nse = ''.join(nse) #nsc = len(nse) #print('Quantas ...
87601a4e04dde1efd9380bb63933bc8c2871467f
panwoo1/Algorithm
/recursion/factorial.py
535
4.34375
4
def factorial(n): if(n == 1): return n else: return n * factorial(n - 1) # Tail Recursion ... recursion stack의 내용을 overwrite하는 식으로 메모리 사용을 크게 줄일 수 있다. def tail_factorial(n, value=1): if(n == 1): return value else: return tail_factorial(n-1, value * n) # 호출과정 ''' tail_...
799f233a7d5453598e3207c2e8984c0056b4f1c4
geediegram/parsel_tongue
/itunu/comparisons.py
227
4.03125
4
first_number = int(input("Enter first number")) second_number = int(input("Enter second number")) third_number = int(input("Enter third number")) if first_number < second_number < third_number: print(True) else: print(False)
4749bd0e556a715059700dd24134d0cd392b7335
koziolaga/nauka-pythona
/haslo.py
517
3.78125
4
#ecret = 'pantofel' #haslo = 'tralala' #print "Secret -> "+ secret #print "haslo -> "+ haslo #for i in range (1, len(haslo) -1): print('podaj haslo: ') haslo = input() gwiazdki = (len(haslo) - 2) * "*" if len(haslo) == 0: print ('nie podano hasla') elif len(haslo) < 3: print ('za krotkie haslo') else: ...
b51da29c9c259c64a65216283baa2c281ac62096
EladioDeveloper/ArtificialIntelligence
/Practica 2/Part_II/2.26.py
179
3.953125
4
# 26. Write a Python program to create set difference setx = set(["a", "b"]) sety = set(["b", "c"]) setz = setx & sety print(setz) #Set difference setb = setx - setz print(setb)
5e1318a293109168962423a063444843a0170214
DmitriDanshin/WordsCounter
/database.py
660
3.515625
4
import sqlite3 import datetime class DataBase: @staticmethod def make_database(data: dict): try: con = sqlite3.connect('databases/database.db') cur = con.cursor() now = datetime.datetime.now() name = f'Words_{now.strftime("%d_%m_%Y_%H_%M")}' ...
0941b253bccecd016bba08c72ec87f08b438d6d2
rafaelperazzo/programacao-web
/moodledata/vpl_data/13/usersdata/82/5785/submittedfiles/flipper.py
376
3.796875
4
# -*- coding: utf-8 -*- from __future__ import division import math #ENTRADA P= input ('Digite o valor de P:') R= input ('Digite o valor de R:') #PROCESSAMENTO E SAIDA if P=0 and R=1: print ('C') else: if P=0 and R=0: print ('C') else: if P=1 and R=0: print ('B') else:...
9b412352f5e00fd2c75bc9f57a19fa2fe281196e
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/rna-transcription/bbbcb1c8970442eb8a364ce2dc617edc.py
723
3.6875
4
'''Module for DNA->RNA transcription''' def to_rna(dna): # return_str = '' # i = 0 # for base in dna: # if base == 'C': # return_str = return_str + 'G' # i = i + 1 # elif base == 'G': # return_str = return_str + 'C' # i = i + 1 # elif ...
3c6cdb5860bc76b51a64782e1c79e8e8ce84d644
kunal27071999/KunalAgrawal_week_1
/Week_1_datastructure_part1_Q23.py
187
3.8125
4
"""23. WAP to get the number of occurrences of a specified element in an array""" from array import * a = array('i',[1, 2, 1, 4, 4, 7, 7, 8, 9, 10]) for i in a: print(a.count(i))
2a9a2b9df0c9ac1cd5a76fa22725575478c246bb
pynoor/CoMa-1
/01PA09_quicksort/quicksort.py
1,657
4.21875
4
def quicksort(n, cmp, swp): ''' This function sorts a list of n elements using the functions swp and cmp paramteres: - n = length(L) - cmp : a function that compares two elements ''' if n <= 1: return 1 if n == 2: if cmp(0,1): return 1 els...
0d51861da67c10159433d3382a5256722ce77f51
edu-athensoft/stem1401python_student
/py210110c_python1a/day08_210228/funda_literal_4.py
204
3.890625
4
""" converting oct to dec converting dec to oct 8^n result 8^0 1 8^1 8 8^2 64 8^3 512 """ # oct -> dec c1 = 0o2345 print(c1) # dec -> oct d1 = 1253 print(oct(d1)) print(oct(1253))
354ffe519cea7a210b54bb0f48a8710385adc024
JoaoPedroBarros/exercicios-antigos-de-python
/Exercícios/Exercícios Mundo 2/ex071.py
340
3.53125
4
q = int(input('Quanto você vai sacar?')) c = q % 50 c1 = q//50 c2 = (q % 50)//20 c3 = (c % 20)//10 c4 = (c % 10)//1 print(f'Total de {c1} cédulas de R$50') print(f'Total de {c2} cédulas de R$20') print(f'Total de {c3} cédulas de R$10') print(f'Total de {c4} cédulas de R$1') # Funciona, mas foi feito sem nenhuma estrut...
6d714b73aa3bcc7d8412379577b468f52e7fa999
jerelhenderson/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/2-matrix_divided.py
883
3.671875
4
#!/usr/bin/python3 def matrix_divided(matrix, div): new_matrix = [] for row in matrix: for num in row: if type(matrix) is not list: raise TypeError("matrix must be a matrix (list of lists) of integers/floats") if type(num) is not int and type(num) is not float: ...
d237693b87a15cf9ec5a4e2c617046169573e957
cs-fullstack-2019-spring/python-review-misc-ChelseaW
/Misc Review.py
1,600
4.125
4
# KEY: In future please remove any code that is not of your solution submission as hard to tell what to grade # KEY: Missing Comments :-( def main(): # problem1() problem2() # challenge1() # challenge2() # def problem1(): #code will continue to run until q gets it to quit # user = "" # # while(use...
f75990b5eab28ae214c233d50a4d90a2031dc769
akhisulaymaan/wave2lab
/lab1of2.py
489
4.375
4
#Quiz: Slicing Lists #Selecting the three most recent dates from this list using list slicing notation. eclipse_dates = ['June 21, 2001', 'December 4, 2002', 'November 23, 2003', 'March 29, 2006', 'August 1, 2008', 'July 22, 2009', 'July 11, 2010', 'November 13, 2012', 'March 20, 2015...
241b65edaff8adaacc746cf024f4ac2a68a1d761
mathi348/fango
/numeros1.py
562
3.96875
4
negativos=0 positivos=0 mult15=0 valpares=0 for x in range (5): valor=int(input("ingrese un valor")) if valor<0: negativos+=1 else: if valor>0: positivos+=1 if valor%15==0: mult15+=1 if valor%2==0: valpares+=valor print ("cantidad de numer...
e9af9dc91bf81bca4571a274bfd0e143f3af2ef3
ursu1964/Algorithms-in-Python-1
/03-Algorithm-Analysis/Exercises/C3-35.py
548
4.03125
4
def disjoint(A, B, C): """Return True if there is no element common to all 3 lists.""" combined = [] for j in range(len(A)): combined.append(A[j]) for j in range(len(B)): combined.append(B[j]) for j in range(len(C)): combined.append(C[j]) temp = sorted(combined) for j...