blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
59a2f82317bc85485726d4afd49de00fa0990e27
Prashanth073-cloud/Python-files
/countingSort.py
1,461
3.890625
4
def main(): unsortedList = [10,1,5,12,1,18,0,6] countingSort(unsortedList) def countingSort(unsortedList): countList = [] #initializing list with zeroes. count list size is maximum of the unsortlist for items in range(max(unsortedList)+1): countList.append(0) #print(countLi...
726acb608f63cc2fb97970b0e35a84bced82f8fc
SSyeon/Programming-Python-
/1학기/multi.py
306
3.78125
4
def multi_num(multi, start, end): result = [] for n in range(start, end): if n % multi == 0: result.append(n) return result multi2 = multi_num(17, 1, 200) print("multi_num(17, 1, 200) :", multi2) print() multi3 = multi_num(3, 1, 100) print("multi_num(3, 1, 100) :", multi3)
6d7750da09f5c3e96951cfb161e5f79ab7ff76a2
SenFuerte/dt211-3-cloud
/Euler/Sol_nr6.py
682
3.859375
4
squRes = 0 sumOfSquares = 0 def squareOfTheSum(nr): # define a method to calculate the square of the sum global squRes # squRes have to be global for use in this method. for i in range(1, nr+1): squRes = squRes + i # add all numbers to squRes return (squRes * squRes) # square the added numbers def sumOfT...
c1245c0f79bf441021263672fce7a69bfd7171ed
mvoecks/CSCI5448
/OO Project 2/Source Code/Canine.py
1,888
4.21875
4
import abc from Animal import Animal from roamBehaviorAbstract import hunt ''' We will define the behavior of all Canines to hunt when they roaming, therefore we will create the roamBehaviorAbstract hunt class to use to set out roam behavior. ''' huntBehavior = hunt() ''' Here we create our Canine abstract c...
4de5f9ed9e924063809a1a95bea978d7ba4a462a
Aasthaengg/IBMdataset
/Python_codes/p03130/s065579795.py
526
3.546875
4
import collections as cl # 全街のつながりは保証されていて、橋は3本固定なので、枝分かれしてなければたどり着けるはず def main() : bridges = [] for i in range(3) : in_list = [int(i) for i in input().split()] bridges.extend(in_list) c = cl.Counter(bridges) com = c.most_common() if (com[0][1] == 2 and com[1][1] == 2 and com[...
a4a19cbabab3921402b36ec5b9c338cf50dcd5cb
otisscott/1114-Stuff
/Homework 2/oms275_hw2_q7.py
446
3.953125
4
# Otis Scott # CS - UY 1114 # 19 Sept 2018 # Homework 2 def bmi(w, h): bmi = w / h ** 2 return bmi weight = int(input("Please enter weight in kilograms: ")) height = float(input("Please enter height in meters: ")) print("BMI is: " + str(bmi(weight, height))) pweight = int(input("Please enter weight in pounds...
3620cab4d9984262e313548b3d29a68704a1145c
parzivale/woolsey-exercises
/exercises/exercise_1.py
630
3.953125
4
name = "A new student" description = "A program that takes in a students name, age and nationality and outputs it to a text file and the console" class student: def __init__(self, name, age, nationality): self.name = name self.age = age self.nationality = nationality self.content = [self.name, self.a...
ea9738de509dc760765702e7b666d88b86611356
OmarSalah95/Sorting
/src/recursive_sorting/recursive_sorting.py
4,503
4.0625
4
<<<<<<< HEAD # Helper function below to merge 2 sorted arrays def merge( arrA, arrB ): merged_arr = [] i_of_a, i_of_b = 0, 0 # We initiate a loop to continue to iterate until 1 of the 2 arrays we recieved as inputs has been completed. We will then tack # Whatever is left of the remaining array to the en...
5daf0b07f4e19f2ab73b4d08f1d858ab62941642
Said-Akbar/exercises
/Python_by_Zelle/chapter_4_ex/ex7.py
1,365
3.921875
4
# ex 7 Circle Intersection. Created by SaidakbarP 12/24/2019 from graphics import * def main(): #r = int(input("Enter Radius of the circle: ")) win = GraphWin("Circle Intersection", 640, 640) win.setCoords(-10, -10, 10, 10) # entry box for radius radius_entry = Entry(Point(-3, 9), 10) radius_en...
5f6709d502b7d3b195173b50a265d4422af81298
adsl305480885/leetcode-zhou
/653.两数之和-iv-输入-bst.py
1,825
3.65625
4
''' Author: Zhou Hao Date: 2021-04-09 20:30:42 LastEditors: Zhou Hao LastEditTime: 2021-04-09 20:57:34 Description: file content E-mail: 2294776770@qq.com ''' # # @lc app=leetcode.cn id=653 lang=python3 # # [653] 两数之和 IV - 输入 BST # # @lc code=start # Definition for a binary tree node. # class TreeNode: # def __ini...
3f78445c7a568a58370a6060417a3004b3287868
visha-v/Trying_Python
/miles_into_km.py
147
4.15625
4
miles = input('Enter Miles: ') miles = int(miles) km = (miles * 1.60934) print("{} miles equals {} kilometers".format(miles, float(km)))
d4d246fc4604c443e3ed4653f6dd441fa04953b0
FiodorGrecu/Exercises
/data_structures/binary_trees/2_search_node/solution/model_solution/solution.py
575
3.8125
4
# Write solutions here class Node: def __init__(self, key, left=None, right=None): self.left = left self.right = right self.key = key def search(root, key): if not root: return False if key == root.key: return True elif key < root.key: return search(root...
8ddba3a17040540648341b4e83822ced1b26855e
xiao-a-jian/python-study
/month01/day15/exercise01.py
381
3.703125
4
""" 定义函数,获取成绩.如果输入有误,重新输入,直到输入正确。 """ def get_score(): while True: try: # score = float(input("请输入你的成绩")) # return score return float(input("请输入你的成绩")) except: print("输入错误重新输入") print("成绩是:", get_score())
8f90ddbf11dbeb10e49983bb1cde07e28d671afa
nyck33/coding_practice
/Python/leetcode/dpv_longest_palindromic_subseq.py
1,207
3.8125
4
def longest(the_str): ''' :param the_str: :return: length of longest palindromic subseq and the subseq from s(i..j) ''' length = len(the_str) T = [[0 for x in range(length)] for y in range(length)] #subseq of 1 is a palindrome for i in range(length): T[i][i] = 1 # shift...
cbb1cdb15048c604a6b019a895534f72c1f84404
viegasviegasviegas/alegriaDaRapaziada
/GnomeSort.py
275
3.53125
4
def gnome(lista): pivot = 0 lista_length = len(lista) while pivot < lista_length - 1: if lista[pivot] > lista[pivot + 1]: lista[pivot + 1], lista[pivot] = lista[pivot], lista[pivot + 1] if pivot > 0: pivot -= 2 pivot += 1 return lista
4cda8e27092ad617bba45961d635cdcb46e74421
shuddha7435/Python_Data_Structures-Algorithms
/Queue.py
1,142
4.15625
4
class Queue: def __init__(self,size): self.items = [0] * size self.max_size = size self.head, self.tail, self.size = 0, 0, 0 def enqueue(self,item): if self.is_full(): print("Queue is full!") return print("Inserting", item) ...
ed8e99d90faaf4b797915eaa6f1cfaae049c18a5
heejongahn/algospot
/BEGINNER/endians.py
2,052
3.65625
4
##### Problem # The two island nations Lilliput and Blefuscu are severe rivals. They dislike # each other a lot, and the most important reason was that they break open boiled # eggs in different ways. # People from Lilliput are called little-endians, since they open eggs at the # small end. People from Blefuscu are c...
0527958448ad9fb3fc5a3a400358f2c9a7f5e3a5
swissfiscal/offer
/leetcode_7整数反转.py
774
4.15625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' Created on 2019/3/12 @author: luomashuzi desc: 给出一个 32 位的有符号整数,你需要将这个整数中每位上的数字进行反转。 示例 1: 输入: 123 输出: 321 示例 2: 输入: -123 输出: -321 示例 3: 输入: 120 输出: 21 ''' class Solution(object): def reverse(self, x): """ :type x: int :rtype: int ...
7c61bd421a08cf59210cb2857f4b813dbd2eed02
dongpingbio/ModelNeuro
/stim.py
4,601
3.671875
4
class Stim: """ A class for adding current injections into model neurons or networks. Takes in a maximum time (T), sampling rate (Fs), and steady-state current (I0) as initial parameters. Note that these parameters are relative to miliseconds, not seconds. Thus, for a 10 kHz sampling rate, one would...
8629ac500602b9df014cf5f9e66de96e82469dae
Runweiw/Stats607
/Assignment_1/test_assignment1_RunweiWang.py
1,404
3.96875
4
#1.1 import assignment1_Data as a1Data #import module as 'a1Data' crime = a1Data.get_US_crime() #assign it to a local name 'crime' with() means return to a list, #without() means return to a function print(crime,'\n') #1.2 import assignment1_RunweiWang as a2Data #import module as 'a2Data' print('Do the lists...
48fb16159bc9b5ddbe86709ef960e6baaf146c30
Jon-Ting/UH-DA-with-PY-summer-2019
/part03-e03_most_frequent_first/ans.py
417
3.546875
4
#!/usr/bin/env python3 import numpy as np def most_frequent_first(a, c): b = a[:,c] # get column c _,s,t = np.unique(b, return_inverse=True, return_counts=True) idx = np.argsort(t[s]) return a[idx][::-1] def main(): np.random.seed(0) a = np.random.randint(0,10, (10,10)) print("a:\n",...
87cfcb03bb2a62d4d28a1f0b8760d7eca9b65168
pujanm/competitive_programing
/Mock1-DJ-2019/editor.py
198
3.75
4
import math operations = int(input()) num1 = math.ceil((operations - 2) / 2) num2 = abs((operations - 2) - num1) if num1 > num2: print(num1 + num2 * num1) else: print(num2 + num1 * num2)
00376b59dc26a85b18667a4bff3b32239cc93d53
tomglinnan/EC400
/Penalties.py
2,895
3.984375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ PENALTY SHOOTOUT EXTENSION """ """ In the in-person class, we talked about an extension to the penalty shootout question How penalties work: each team takes 5. If one team has scored strictly more than the other, that team wins. If it's a draw, then we have sudden...
50dcbd1a0b793e0ef9a91dda6ef34d6746ace2ba
sigma7i/PythonLessons
/Lesson04/easy.py
1,998
3.765625
4
# Все задачи текущего блока решите с помощью генераторов списков! # Задание-1: # Дан список, заполненный произвольными целыми числами. # Получить новый список, элементы которого будут # квадратами элементов исходного списка # [1, 2, 4, 0] --> [1, 4, 16, 0] original_list = [1, 2, 4, 0] pow_list = [i*i for i in origina...
317a67648c49c473f9521b0a22eddfafd1ea0169
ThyEvilOne/LSC-python-class-Noah-David
/DavidBChap10/10.3.2.py
755
4.15625
4
user_input = '' while user_input != 'q': try: weight = int(input('Enter weight (in pounds): ')) if weight < 0: raise ValueError('Invalid weight.') height = int(input('Enter height (in inches): ')) if height < 0: raise ValueError('Invalid height.') bm...
fea59d34bbd6651097865c7ae1dc84e24f3b2a07
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_136/2139.py
1,170
3.5625
4
import sys def main(): f = None output = None case = 1 if len(sys.argv) > 1 : f = open(sys.argv[1]) output = open(sys.argv[1][:-2] + 'out', 'w') else: print("PROBLEM") return tests = int(f.readline().strip()) case = 1 cost = 0 goal = 0 farm = 0 ...
13613c93925cc5c581ede043f507b636517f5e56
eyal-shagrir/Graph-Cluster-Covers
/utilities/util.py
8,501
3.703125
4
import networkx as nx import numpy as np import matplotlib.pyplot as plt GRAPH_GENERATION_TRIES = 1000000 PROBABILITY_STEP = 0.01 def draw_graph(g): nx.draw(g, with_labels=True) plt.show() plt.close() def generate_graph(n, p=0.5): """ :param n: number of nodes :param p: probability for choo...
9a41edd8472ab06c2bfbad83d1285cd3598fd1f0
yeodongbin/PythonLecture
/03.Algorithm/Sort/selection_sort2.py
831
3.625
4
import unittest def selectionSort(input): for i in range(len(input) - 1): # assume the min is the first element idx_min = i j = i + 1 # test against elements after i to find the smallest while j < len(input): if(input[j] < input[idx_min]): # foun...
da702e3d62e07ea1804cc43b2fce36f2b27a30e9
quincysoul/python-ds-binarytree
/solutions/k_largest_elements_BST_eop14_3.py
813
4
4
import binarytree from collections import deque, namedtuple """ Problem: For 1 Binary Search Tree, return the k largest elements For simplifying tests, accept params as follows: tree_root: binarytree.Node k: int Return: val of k largest elements in array. __5 / \ 3 7 / \ \ 1 4 10 ...
ec02a8db5649b9da64db012e369b826f44ccd13e
Gendo90/HackerRank
/Tech Screenings/Verizon/Verizon Media Software Engineer.py
1,843
3.6875
4
# First technical screening question for Verizon Media Software Engineer def minOperations(comp_nodes, comp_from, comp_to): # Write your code here comp_groups = {} #could make a map of values back to keys, to see which key it is under... #useful later... together = zip(comp_from, comp_to) if(len...
05969df2502bf52f7e5318c80bfc62966c14d331
alejandroorca/alejandroorca.github.io
/ejercicios_pc/09.py
1,113
3.84375
4
def asterisco(x): # Esta funcion imprime tan solo * multiplicado por X ( donde X será la longitud mas larga de caracteres ) a = "*" * x return a def lista(x): # Esta funcion me va a dar la longitud mas larga de caracteres y le sumo 4 ( para el * inicial y final mas espacios ) c = 0 #contador for i in ...
27b061b08861fc11da06a18cce84fe2afff63476
testautomation8/Learn_Python
/CSV_Reader/CSVReader.py
290
3.796875
4
# Script to read data from CSV file import csv with open("D:\Learning\Python\PycharmProjects\CSV_Reader\example.csv") as csvfile: readCSV = csv.reader(csvfile, delimiter=',') for row in readCSV: print(row) print(row[0]) print(row[1]) print(row[2])
b0da78c93d739505bd08811ec89fe7f3e25c986e
julianespinel/training
/hackerrank/climbing_the_leaderboard.py
2,751
4.15625
4
''' https://www.hackerrank.com/challenges/climbing-the-leaderboard # Climbing the leaderboard The function that solves the problem is: ```python get_positions_per_score(ranks, scores) ``` The solution uses `deque` instead of lists. Why? To have O(1) in appends and pops from either side of the deque. See: https://do...
3ca2464197e5ea01e66fe1f8ce0836c2ac8150a8
yanghaotai/leecode
/十大排序算法/10、基数排序.py
1,178
3.75
4
''' 10、基数排序 基数排序是一种非比较型整数排序算法,其原理是将整数按位数切割成不同的数字,然后按每个位数分别比较。由于整数也可以表达字符串(比如名字或日期)和特定格式的浮点数,所以基数排序也不是只能使用于整数。 基数排序 vs 计数排序 vs 桶排序 基数排序有两种方法: 这三种排序算法都利用了桶的概念,但对桶的使用方法上有明显差异: 基数排序:根据键值的每位数字来分配桶; 计数排序:每个桶只存储单一键值; 桶排序:每个桶存储一定范围的数值; ''' def radix_sort(array): max_num = max(array) place = 1 while max_num >= 10 ...
4aef7b821c1f046aa867b660358536607f1400ff
rbiswasfc/algorithms
/recursion/recursion_part1.py
3,978
3.84375
4
from typing import List class ReverseStringRecursion: def reverseString(self, s: List[str]) -> None: """ Do not return anything, modify s in-place instead. """ if len(s) <= 1: return s def helper(p1, p2, s): if p2 < p1: return ...
da3b80465afdbedba8738a65079b5194b40275c9
nanli-7/algorithms
/150-evaluate-reverse-polish-notation.py
1,663
4.03125
4
""" 150. Evaluate Reverse Polish Notation - Medium #stack Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression. Note: Division between two integers should truncate toward zero. The given RPN expression is alwa...
94aaec9936fe17ebab1c6cbc5640fcc8ec0cab8f
feer921/PythonStudy
/04-数据类型的转换.py
665
4
4
# 进制转换,将 int类型以不同的进制表现出来 # 类型转换 将一个类型的数据转换为其他类型的数据 int==>str str==>int bool==> int int==>float age = input("请输入您的年龄:") print(type(age)) # <class 'str'> # print(age+1) # 会报错误,因为 接收到的用户输入,都是 [str]字符串类型;在python里,如果字符串和数字做 加法去处,会直接报错 # 应该 把字符串类型的变量 age 转换成为数字类型的 age # 使用 [int]内置函数可以将其他类型的数据转换成整数 age = int(age) pri...
d98730e97b8373c1fb0e0bcbc8a54a282e373e38
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/226/users/4148/codes/1637_1055.py
378
3.59375
4
# Teste seu código aos poucos. # Não teste tudo no final, pois fica mais difícil de identificar erros. # Use as mensagens de erro para corrigir seu código. from math import* g = 9.8 v0 = float(input("v0: ")) a = float(input("angulo: ")) d = float(input("distancia: ")) r = (v0) **2 * sin(2*(radians(a)))/g F = abs(r-d) i...
a68522813edc142fd7df3bb65f113c3b60f5af8f
NitinBnittu/Launchpad-Assignments
/problem3.py
131
3.53125
4
l=[1, 2, 3, 2, 0, 65, 21, 4, 2, 10] a=2 out=[] for i in range(0,len(l)): if l[i] == a: out.append(i) print(out)
41ba438e60e3857854451abcdb3319e2faa2065b
arifkhan1990/Competitive-Programming
/Data Structure/Linked list/Singly Linked List/practice/Leetcode/Intersection_of_Two_Linked_Lists _Solution.py
1,248
3.78125
4
# Name : Arif Khan # Judge: Leetcode # University: Primeasia University # problem: Intersection of Two Linked Lists # Difficulty: Medium # Problem Link: https://leetcode.com/explore/learn/card/l...
e8d144ecd4c3ce763c95470a94203b8a8343dd15
adamchung40/CSE-1321
/Labs/Lab4/WeeklyPay/WeeklyPay/WeeklyPay.py
285
3.796875
4
#Class: CSE 1321L #Section: 16 #Term: Spring 2019 #Instructor: Kristin Hegna #Name: Adam Chung #Lab#: 2 hours = int(input("How many hour did you work? ")) std_hours = 40 if hours > 40: overtime = (hours - 40)*15 + (std_hours*10) print(overtime) else: print(hours*10)
3242e005f7db7f56a6f772c740949b1f7aa6b7bc
ThiagoScodeler/Curso-Python-Inatel
/exercicios_python/exec26/exec26.py
439
3.671875
4
def calc_vet(): vet_numbers = list() for n in range(4): vet_numbers.append(int(input("Forneça um número: "))) vet_par = list((n for n in vet_numbers if n % 2 == 0)) vet_impar = list((n for n in vet_numbers if n % 2 != 0)) print("Lista original: ") print(vet_numbers) print("Lista pa...
acaf8269ce9d390b3c017b1dde3c39ab99e7a4c9
mary-tano/python-programming
/python_for_kids/book/Projects/kehrwert.py
228
3.765625
4
# Обратное число try : print("Введи число: ") Number = float(input()) if Number != 0 : print(1/Number); else : print("Нет результата"); except : print("Нет числа!")
c982ab2e90c34f5369c1ea59c4a5867dd7433c7c
Jacolla/learning
/python/python.py
11,720
3.921875
4
# _______________________________________________ #Todo en phyton es un objeto #Las variables son marcadas por el contenido, no el contenedor. # msg = ("toma yaah") # print(msg) # _______________________________________________ # numero1=10 # numero2=20 # if numero1>numero2: # print("El numero uno mola mas") # ...
4152580f0efc0ed49f8e825f25334d8f2ea3347a
kyledugan/linear-algebra
/week3/symmetrize_upper.py
353
3.875
4
import numpy as np # makes the bottom half symmetrical to the top half def symmetrize_upper(A): # check that A is n x n matrix if len(A.shape) != 2 or A.shape[0] != A.shape[1]: return "FAILED" for i in range(1, A.shape[0]): A[i,:i] = A[:i,i] return A A = np.array([[1,2,3],[4,5,6],[7,...
6e6cc4c176dbb9c28f52ca678d86336b20191573
TheRealTimCameron/cp1404Practicals
/prac_04/list_exercises.py
810
3.921875
4
# No.1 Numbers stuff numbers = [] for number in range(5): given_number = int(input("Number: ")) numbers.append(given_number) print("The first number is {}".format(numbers[0])) print("The last number is {}".format(numbers[-1])) print("The smallest number is {}".format(min(numbers))) print("The largest number is ...
e7450a2ef9ed2c606d66a536c18e46f23be43f0f
rafaelperazzo/programacao-web
/moodledata/vpl_data/111/usersdata/235/63812/submittedfiles/av2_p3_m2.py
720
3.59375
4
# -*- coding: utf-8 -*- import numpy as np m=int(input('digite o numero de linhas e colunas sendo l=c:')) a=np.zeros((m,m)) for i in range(0,a.shape(0),1): for j in range(0,shape(1),1): a[i,j]=int(input('digite os valores para a matriz:')) def quasemagica1(a): lista1=[] for i in range(0,a.shape[0],1...
a97b45518f8246a8f5ae3a6326beda932b7c53d0
pksaelee/GirlsWhoCode
/codeEncryption.py
1,327
4.09375
4
#GLOBAL VARIABLES codeList =[] realList = [] #FUNCTIONS def createCodeWords(): codingWords = True while codingWords: print("Would you like to add a word to your code words? (y/n)") ans = input().lower() if ans == "y": print("What is the real word?") ...
4b38aa5ebff9dabc644b0bb1f6638e826727be04
katherinemurphy/ComputerElective
/Practice3.py
364
3.671875
4
name = raw_input("what is your name?") last = raw_input("what is your last name?") year = input("what is your birth year?") band = raw_input("what is your favorite band?") movie= raw_input("what is your favorite movie?") friend = raw_input("who is your best friend?") age = 2015 - year print "you are ", age , "years old...
61e1e11f6d9a66c804f5bb6f3e8a0f4d7a88a8da
CCC53/Python
/Curso Python/1/entradas_de_usuario.py
569
3.828125
4
#En este programa se hara un ejemplo muy simple con el uso de entradas print("\tSaludos") nombre= input("Escriba su nombre: ") print("El nombre que has digitado es: ",nombre) #Por defecto python convierte las variables en tipo string y para convertirlo a entero o flotante se hace esto: edad= input("Ahora escriba s...
6ebadb51969d9bcbfe4c6380c922595f9f75e522
jofre44/EIP
/scripts/functions.py
1,158
4.3125
4
print("Actividad 3. Programacion Avanzada en Python") print("Alumno: Jose Sepulveda \n") print("Ejercicio 1: Crear función para sumar o restar valores") def suma_resta(num_1, num_2): try: num_1 = float(num_1) num_2 = float(num_2) except: print("Error!! Datos introducidos no son números...
3f4cae0f9cb71c79b0889f55f14d0700ec587be7
guolas/acm_icpc_team
/acm_icpc_team.py
931
3.859375
4
#!/bin/python3 def get_knowledge_of_the_pair(person_1, person_2): knowledge = 0 for ii in range(len(person_1)): knowledge += person_1[ii] | person_2[ii] return knowledge N,M = [int(x) for x in input().strip().split(" ")] persons = [] for ii in range(N): topic_t = [int(x) for x in list(input()....
9b352ff17f306aca7828afb4d1e8f683c76abd82
soulorman/Python
/practice/practice_4/kmp1.py
896
3.546875
4
# KMP算法 # 首先计算next数组,即我们需要怎么去移位 # 接着我们就是用暴力解法求解即可 # next是用递归来实现的 # 这里是用回溯进行计算的 def calNext(str2): i=0 next=[-1] j=-1 while(i<len(str2)-1): if(j==-1 or str2[i]==str2[j]):#首次分析可忽略 i+=1 j+=1 next.append(j) else: j=next[j]#会重新进入上面那个循环 retu...
a3618cd48ad08024b48f9304ece96c74b1039815
kevin-kretz/Park-University
/CS 152 - Introduction to Python Programming/Unit 6/Assignment 2/programming_assignment_2.py
2,855
4.34375
4
""" Unit 6 - Programming Assignment (2) By Kevin Kretz | 20 July 2019 Using the data provided from the file "health-no-head.csv", print the values of the appropriate states according the filters provided by the user. Also print the states with the lowest and highest number of effected people. """ def main(): #ge...
f059dcd41e634569dc9d1af36a06f3889d7ab695
tarnfeld/pi-tools
/gpio/memory.py
1,769
3.71875
4
#!/usr/bin/python import time from RPi import GPIO # Define the connection pins PIN_LED = 12 PIN_BUTTON = 8 def setup(): """Setup the GPIO library / pins""" # Setup the connections GPIO.setup(PIN_LED, GPIO.OUT) GPIO.setup(PIN_BUTTON, GPIO.IN) # Reset the output LED to off GPIO.output(PIN_L...
0247996f0f850290dd4e403e3f054688a9efc27f
CrislyGonzalez/Python-basic
/Metología de programación para niñas/modulo2/Ejercicio2OperadoresLogicos.py
597
3.734375
4
#Operacion de Suma def suma(): numeroUno= 2 numeroDos= 2 resultadoSuma= numeroUno + numeroDos #Operacion de Resta def resta(): numeroUno= 5 numeroDos= 1 resultadoResta= numeroUno - numeroDos #Operacion de Multiplicación def multiplicacion(): numeroUno= 2 numeroDos= 4 resultadoMu...
b6e76e0c84de165e87cc222d8080e8d7dac43622
RMeiselman/CS112-Spring2012
/hw12/points.py
1,785
4.5625
5
# Point Object # ===================================== # Create a Point point class. Point objects, when created, look like this: # >>> pt = Point(3,4) # >>> print pt.x # 3 # >>> print pt.y # 4 # # In addition points have the following methods: # distance(self, other): # calculates the di...
89431c7f0e900c44d9cdd9aa8cd40b7fa28ca2d6
Wu-zpeng/PythonLearn
/day13/02 生成器函数.py
1,642
3.71875
4
# def func(): # print(111) # yield 222 # ret = func() # print(ret) #打印的是生成器地址 # gener = ret.__next__() # print(gener) #通过 __next__来取值,和迭代器一样 # def fun(): # print(111) # yield 222 # print(333) # yield 444 # # gen = fun() # ret = gen.__next__() # print(ret) # ret = gen.__next__() # print...
263ddebaf1b4b3a34eb11bb2eba0fccd281ced24
CodeSoju/UdacityDS_Algo
/Problems/nth_row_pascal.py
582
3.78125
4
def nth_row_pascal(n): if n == 0: return [1] current_row = [1] for i in range(1, n +1): prev_row = current_row current_row = [1] print("Value of i: ", i) for j in range(1, i): print(prev_row[j], prev_row[j-1]) next_number = prev_row[...
138328b1c16d641532cd295fec1ea4187c1a182d
satyam-seth-learnings/ds_algo_learning
/Applied Course/4.Problem Solving/3.Problems on Linked List/14.Reverse K alternative nodes in a linked list.py
3,324
3.890625
4
import sys class node: def __init__(self, info): self.info = info self.next = None self.random=None class LinkedList: def __init__(self): self.head = None def display(self): temp = self.head while (temp): print("{} ->".format(temp.inf...
8d39c25ffc14a29d451e95177dcfa14e25cd045b
cameronww7/Python-Workspace
/Python-Bootcomp-Zero_To_Hero/Sec-3-Py-Object-and-Data-Basics/11-Py-Numbers.py
302
3.921875
4
from __future__ import print_function """ Prompt 11 Numbers : """ print("11 Numbers") print(2 + 1) print(2 - 1) print(7/4) print(7%4) # Two the Power of 3 print(2**3) temp = 2 + 2 temp = 2 + temp print(temp) # https://docs.python.org/2/tutorial/floatingpoint.html print(0.1 + 0.2 - 0.3)
912c09b33930e10847afb142969ac139e0db6272
joshp8a/python
/3.1 and 3.2.py
359
3.765625
4
hrs = raw_input('Hours? ') pay = raw_input('Rate? ') try: iHrs = int(hrs) except: print 'ERROR, please enter a numeric input' sys.exit() try: fPay = float(pay) except: print 'ERROR, please enter a numeric input' sys.exit() if iHrs > 40: print 'Pay is', ((iHrs-40)*fPay*1.5)+(fPay*...
422795a87bd9fb0767ac30ccc79eb592defee9ec
ESMCI/cime
/CIME/ParamGen/paramgen_utils.py
5,693
4.03125
4
"""Auxiliary functions to be used in ParamGen and derived classes""" import re def is_number(var): """ Returns True if the passed var (of type string) is a number. Returns False if var is not a string or if it is not a number. This function is an alternative to isnumeric(), which can't handle sci...
7fe4463f98056eb4f73b11eaf9a5d033d436561e
ki4070ma/python-playground
/raise_from/raise_from.py
607
3.6875
4
# https://docs.python.org/ja/3.8/library/exceptions.html # https://docs.python.org/ja/3/reference/simple_stmts.html#the-raise-statement def raise_exc(): try: print(1 / 0) except Exception as exc: raise exc def raise_from_exc(): try: print(1 / 0) except Exception as exc: ...
c1958a0ada14b0df5ec5f64041af225c8a701e41
Anomium/Quinto-Semestre
/Python/Ejercicios Python - Taller 2/Ejercicio 5.py
163
4
4
def orden(num): #y = sorted(num) num.sort() return num x=[] for i in range(3): x.append(input("Digite 3 valores enteros: ")) print(orden(x))
6a4b7ab86a02567a9ac093de1b0757db2d0d1822
ShivamRohilllaa/python-basics
/5) Dictionary.py
646
3.96875
4
# Make a dictionary of four words :- '''print("Enter Your Word") dict = {"Dog": "Kutta", "House": "Ghar", "Water": "Paani", "Rat": "Chuha"} dictinpt = input() print(dict.get(dictinpt))''' d2 = {"Harry": "Potter", "Aliza": "Beth", "Shivam": {"Burger": "Junk Food", "Chowmein": "Junk Food", "Pizza": "Baked"}} # Delete F...
08d20bd4d836d6228ad0e06650ae31acba78af6d
AugustineAykara/Competitive-Coding
/Coding Interview Problems/Sample03/solution.py
224
3.75
4
def fib(n): if(n in memo): return(memo[n]) if(n == 1 or n == 0): return memo[n] memo[n] = fib(n-1) + fib(n-2) return memo[n] n = int(input()) memo = {0:0, 1:1} print(fib(n-1))
7e72aea5b3530b61e32951f6c81a3a8eaf65e6f1
swissvoc/-Getting-Started-with-Object-Oriented-Programming-in-Python-3
/Section 1/object.py
319
3.671875
4
class Car: def start(self): print("Car started") def reverse(self): print("Car taking reverse") def speed(self): print("top speed = 200") def main(): volvo=Car() volvo.start() volvo.reverse() volvo.speed() if __name__ == "__main__": main()
5b60734a6562ec687683c56aa254e61566a5c0b8
tzxyz/leetcode
/problems/0747-largest-number-at-least-twice-of-others.py
1,721
3.75
4
from typing import List class Solution: """ 在一个给定的数组nums中,总是存在一个最大元素 。 查找数组中的最大元素是否至少是数组中每个其他数字的两倍。 如果是,则返回最大元素的索引,否则返回-1。 示例 1: 输入: nums = [3, 6, 1, 0] 输出: 1 解释: 6是最大的整数, 对于数组中的其他整数, 6大于数组中其他元素的两倍。6的索引是1, 所以我们返回1.   示例 2: 输入: nums = [1, 2, 3, 4] ...
55a4c2c91b3177724c321a86599cf99d4b3a09b6
lyds214/DSA-Implementation
/Stacks and Queues/Stack Implementation (Array).py
681
4.125
4
class Stack(): def __init__(self): self.array = [] self.length = 0 # Returns the value of the last element def peek(self): return self.array[self.length - 1] # Adds the element at the end of the array def push(self, value): self.array.append(value) s...
06b20212dafd15eb923c8bfce7d035e45e92c1ae
ShangruZhong/leetcode
/Tree/99.py
1,255
3.640625
4
""" 99. Recover Binary Search Tree inOrder to find the first and second wrong node, and swap their val @date: 2017/05/07 """ # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class S...
f0f4049c7f561e8244292afe08556da4141ab0b5
davidhuangdw/leetcode
/python/410_SplitArrayLargestSum.py
1,955
3.5
4
from unittest import TestCase # https://leetcode.com/problems/split-array-largest-sum/ import itertools class SplitArrayLargestSum(TestCase): def splitArray(self, nums, m): """ :type nums: List[int] :type m: int :rtype: int """ n = len(nums) sums = [0] ...
8821a3454fbf7a16b1da7e3d37297907ea804250
Benji-Saltz/Early-Python-Projects
/Gr.11 Computer Science/Gr.11 Computer Science Lists.py
1,188
3.953125
4
''' By: Benji Saltz Date:11/9/2016 Description: Three programs, one which finds highest mark and average, another than sees how many a's are in a sentence and one which find 3 younest and oldest out of 50 people ''' import random marks=[] #stores inputed marks for i in range(5): #only allows 5 marks.append(int(inpu...
a66726c3464c27dc092269f78902c60006f4964e
rebornbd/ALGORITHM-DATASTRUCTURE
/ds/queue/python/03-queue-reverse.py
478
3.84375
4
from queue import Queue import copy def reverseQueue(queue: Queue): if queue.empty(): return item = queue.get() reverseQueue(queue) queue.put(item) def displayQueue(queue: Queue): while(not queue.empty()): print(queue.get()) q = Queue() tem = Queue() q.put(10) q.put(20) q....
03129093614a40692aac03e2fd9e964257c1d72b
m8k7j/interview
/by_myself/reverse_string.py
557
3.890625
4
#!/usr/bin/env python # coding=utf-8 """ input_s = "terry ding is a good boy" output_s = "yob doog a si gnid yrret" """ def reverse_string(input_s): li_s = list(input_s) #字符串转列表 reverse_li = [] reverse = "" for i in range(len(li_s)): #当用pop的时候会影响到原列表, #因此不能用 for i in li_s, 而是用长度 reve...
26c622b918315d210b7806bc7cd70a1f74e1fb94
AstroYoung617/PythonStudy
/python_day1/testhello.py
247
3.84375
4
username = input() list1=input() print(list1) if username == "杨宇航": print("welcome") print("帅哥") if username == "李阳": print("welcome") print("猪头") else: print("not welcome") print(False)
81d54cf76b754e9ede21c901a1768e2a1d196f9c
nathanbarnesduncan/442-HW-1
/update_locations_modified.py
1,839
3.859375
4
#!/usr/bin/env python3 """ This program generates N random coordinates in space (3D), and N random velocity vectors. It then iterates M times to update the locations based on the velocity. Finally, it outputs the sum of all coordinates as a checksum of the computation. Coordinates start in the range...
ef83a7ee58c3e714e65264e1a4b62040e6fa84da
ChinaChenp/Knowledge
/learncode/python/json/dump.py
298
3.65625
4
import json filename = 'numbers.json' numbers = ['1', '2', '3', '4', '5'] with open(filename, 'w') as file_object: json.dump(numbers, file_object) with open(filename) as file_object: numbers2 = json.load(file_object) print(numbers2) for number in numbers2: print(number)
1c7fa902b0fa28ced07384b2a85cef537fc1dc98
viblo/pymunk
/pymunk/shape_filter.py
4,464
3.75
4
from typing import NamedTuple class ShapeFilter(NamedTuple): """ Pymunk has two primary means of ignoring collisions: groups and category masks. Groups are used to ignore collisions between parts on a complex object. A ragdoll is a good example. When jointing an arm onto the torso, you'll wan...
63048c65dae2fd68de8ced6939c5035e345be69a
zlatnizmaj/Advanced_Algorithm
/Bai tap Python_KHMT/BST.py
1,487
3.6875
4
# -*- coding: utf-8 -*- """ Created on Fri May 25 09:21:16 2018 @author: Administrator """ class Node: def __init__(self, val): self.val = val self.left = None self.right = None class BST: def __init__(self): self.root = None def isEmpty(self): return self.root == ...
2345a7d9220d890cb4def299da95b4f6df0abbc2
sohamglobal/core-python
/20-sortlast.py
294
3.65625
4
# generate sorted list of last names in title case def getlastnames(nm): lnm=[] for n in nm: lnm.append(n.split(" ")[1].title()) lnm.sort() return(lnm) nm=["ethan hunt","mohd salah","edan hazard","david luiz","amir khan"] l=getlastnames(nm) print(l) # content of sohamglobal.com
bc97a69be14d09333d61674f469d5fd904892d16
roboGOD/Python-Programs
/sumOfLogs.py
105
3.5
4
import math a = int(raw_input()) summ = 0 for i in range(1,a+1): summ += math.log(i, a) print summ
30173464f4a01a4657e789af79bd9043f0d1204c
pranav1214/Python-practice
/lec10/dp3.py
368
3.53125
4
# wapp to insert rows into student table from sqlite3 import * con = None try: con = connect("test.db") print("Connected") cur = con.cursor() sql = "insert into student values(10, 'Amit')" cur.execute(sql) con.commit() print("Record Saved") except Exception as e: print("Insertion issue", e) finally: if con is...
fa5307df33cb36294872b3ac1a90be64d716161f
Bolvis/Pix-Challange-2020-eliminacje
/18.py
109
3.5625
4
for row in input: row = row.split("\t") if int(row[1]) % 2 == 0 and row[2].find("a") != -1: print(row[0])
f3a06cb1599db5e5cfac071d734ac5af7e2115c3
ankita2308/gittest
/factorialnumber.py
146
3.765625
4
def fact(n): if n==1: return 1 else: return n*fact(n-1) print(fact(5)) n=6 f=1 for a in range(1,n+1): f=f*a print(f)
0d680402858c6a0388f1985fb78be61c520a2496
yousstone/python3_learning_note
/do_map.py
103
3.546875
4
#!/usr/bin/python3 #coding=utf8 def f(x): return x * x print(list(map(f,[x for x in range(1,11)])))
7480c6a69f4cf35cbd353e73241d8e22394eb664
tolekes/new_repo
/Exhaustive enumeration.py
655
3.9375
4
possible_result = [111,222,333,444,555,666,777,888,999] #lookup table for the results for initial_number in range(100,999): #the range is between 100 and 999 because the numbers being added are 3 figured total_sum_of_numbers = 3*initial_number # i multiplied by 3 because the three no added are thesame if t...
3185b83e288b3a33a06db7bf716df0e5c39259a1
AntonFromEarth/from_lessons
/lesson22/les22.py
2,003
4.125
4
def linear_shift(array: list, shift: int) -> list: ''' array = [1, 2, 3, 4] shift = 1 => [0, 1, 2, 3] array = [1, 2, 3, 4] shift = 2 => [0, 0, 1, 2] array = [1, 2, 3, 4] shift = 3 => [0, 0, 0, 1] ''' temp = array[:-shift] temp1 = [0 for i in range(shift)] temp1.extend(temp) ret...
50115ab355ba19d34d5547868db3821fb4064bd7
CelsoAntunesNogueira/Phyton3
/ex066 - Só vai parar quando digitar 999.py
224
3.765625
4
n = 0 s = 0 cont = 0 while True: n = int(input("Digite um número ,se quiser parar digite 999: ")) if n == 999: break cont += 1 s += n print(f"Foram mostrados {cont } números e a soma deles é {s}")
1f7af09fe9c4b54ad03d8e6ef159f4740e3b04dd
go0space/Hello-Python
/5.py
1,921
3.984375
4
# 조건문 : if # if문은 한 라인에 모두 쓸 수 있으므로 문법상 조건식 뒤에 :(콜론) 사용 x = 9 if x < 10: print(x) print("한 자리수") if x < 100: print(x) # 한 라인에 표현 # if문 조건식이 참이 아닐 경우, elif문 사용, 모든 if문이 거짓일 때, else문 블럭 실행 x = 20 if x < 10: print("한 자리수") elif x < 100: print("두 자리수") else: print("세 자리 이상") # if문 안에서 수행하지 않고 그냥 ...
811f47ff793439a1eb3a8247ad9649f0846561dd
7ss8n/ProgrammingBasics2-Python
/lab07-cachingWebpage-scalingZipedImage/task4/cursor.py
887
3.84375
4
class Cursor: """Represents cursor""" def __init__(self, document): """Initializes variables""" self.document = document self.position = 0 def forward(self): """Move position forward""" self.position += 1 def back(self): """Move position back""" ...
f3b7863d5695e387ef70ff73696b52d0568dd075
zed1025/coding
/coding-old/Codechef/Uncle_Johny.py
2,919
3.90625
4
t = int(input()) for i in range(t): n = int(input()) #N denoting the number of songs in Vlad's playlist. numbers = list(map(int, input().split())) #N space-separated integers A1, A2, ..., AN denoting the lenghts of Vlad's songs k = int(input()) #K - the position of "Uncle Johny" in the initial playl...
162d9cc2c67af4634237b830454f44cee32b8875
Kalson/Python-Treehouse
/pick_a_number_game.py
909
4
4
import random guess_nums = [] allowed_guesses = 5 run = True while run and len(guess_nums) < allowed_guesses: random_num = random.randint(1, 10) new_number = int(input("Guess a number from 1 to 10: ")) print("The random number is {}, your number is {}".format(random_num, new_number)) if new_number < 1...
667e5a67923fe53f24be040c46cc2004fed2fd44
Grissie/Python
/1-Sintaxis/08-diccionarios.py
1,068
3.734375
4
# -*- coding: utf-8 -*- """ Created on Sun Sep 13 18:59:48 2020 @author: Gris """ #Creacion de un diccionario vacio x={} x['1']="Uno" x['2']="Dos" x['3']="Tres" x['4']="Cuatro" x['5']="Cinco" print(x) #Diccionario usa clave:valor v={'red':'rojo','green':'verde','blue':'azul'} print(v) #Las claves y valores pueden ...
6e51c817c46503ec2e5058e37b7ce1ea38265bf6
chenyan198804/myscript
/MyPython/MyPro06/oldboy02.py
508
3.8125
4
''' Created on 2016年10月18日 @author: y35chen ''' name = input("please input your name:") age = input("please input your age:") job = input("please input your job:") salary = input("please input your salary:") print(type(name),type(age),type(job),type(salary)) print( ''' Pernal information of %s: ...
4e6d75cfe2363aaaf7459a8d55abe2857ec463d6
willpiam/oldPythonCode
/7CharecterRandomInt.py
257
3.65625
4
import random #random is a set of instructions for coming up with a number. newNum = random.randint(0000001,1000000)#the value of newNum is decided by #choising a random number between 0000001 to 1000000 print newNum #displays the value of newNum
b98c0666f79411abb69a7af4cb2bd30bfcc2e244
kubos777/cursoSemestralPython
/CodigosClase/Funciones/ejercicio1.py
775
3.921875
4
# -*- coding: utf-8 -*- def datos(): datos=[] nombre=str(input("Ingresa tu nombre: ")) datos.append(nombre) apMat=str(input("Ingresa tu apellido paterno: ")) datos.append(apMat) apPat=str(input("Ingresa tu apellido materno: ")) datos.append(apPat) direc=str(input("Ingresa tu dirección: ")) datos.append(direc)...
8df47310fe3d517afeea62aa99e732e023495431
munyoudoum/python-bootcamp-2020-01
/pav.munyoudoum19/week02/sc05_sudoku.py
1,000
3.65625
4
def sudoku(x): for ls in x: check = [] if len(ls) != 9: return "Invalid" else: for num in ls: if num < 1 or num > 9: return "Invalid" else: check.append(num) if sorted(check) != list(r...
60e01ca6e310db41b6c5597383d8d4a34f7fef8f
Piotr-Iwanicki/MilestoneProject_MoviesStorage
/movie_storage_app.py
4,762
3.921875
4
from movies_storage import m_storage def search_submenu(): print("_"*48, "\n") print("MOVIE`S SEARCHING - SUBMENU :") print(''' 1 - search by movie title 2 - search by director 3 - search by year of premiere 0 - back to main menu ''') def submenu_search_title(): title = input("En...
1b4d3b3198da8b095e17417844f84e747d0db0c9
quantumjim/jupyter-engine
/engine.py
1,453
3.546875
4
from ipywidgets import widgets from IPython.display import display def run_game(game): ''' Runs the given game. This game engine supports turn based play. In each turn, the player chooses first chooses an option for an input named `a`, and then chooses an option for `b` and one for `c`. The...