blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
59828494e185921afd2d6cee7244ee4bfc0545a3
itschloe1/experiencing-webprogramming
/project-wk2.py
696
3.890625
4
# 과제 2 - 회사 조직도 만들기 class Person(): def __init__(self,name, age, sex): self.name = name self.age = age self.sex = sex class AccompanyPerson(Person): position = "대리" accompany_person = AccompanyPerson("chloe", "30", "female") print(accompany_person.name) print(accompany_person.ag...
de0995963956424a60d50f167d0e575cda17097c
azeddinebouabdallah/dataVisualizationPython
/main.py
1,066
3.921875
4
# Visualization in PYTHON # matplotlib: basic library for data visualization # some others: vispy, seaborn, pygal, folium, pandas import matplotlib.pyplot as plt fig = plt.figure('Histogram') ax = fig.add_subplot(1,1,1) ax.hist([30, 35, 30, 27, 60, 50, 53, 45, 40, 37], bins = 7, facecolor = 'g', normed=True) # nor...
c89e2f88e8d28776f07e26eaa6c3bc64072568d2
Matheuspp/projeto-de-algoritmos-SIN213
/pesquisa_sequencial.py
607
4.09375
4
''' author: Matheus date: april 2021 ''' def pesquisa_linear(arranjo, item): ''' Uma impletação simples em python de uma busca sequencial complexidade: O(n) ''' if len(arranjo) == 0: return None idx = 0 for i in arranjo: if item == i: return idx ...
45258b29e75025e3a9cf01ea5a01f56b24cfbe5d
mwnickerson/python-crash-course
/chapter_7/multiples_of_10.py
312
4.34375
4
# multiples of 10 # chapter 7 exercise 3 # prompts users for a number and tells if multiple of 10 user_number = input("Please give me a number: ") user_number = int(user_number) if user_number % 10 == 0: print(f"{user_number} is a multiple of ten") else: print(f"{user_number} is not a multiple of ten")
50e63dfb325988f98f39a4b7deebd0b88fe1c32c
rpalfini/RRT_circle_load
/RRT_2_circular_objects.py
8,004
3.84375
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Title: Rapidly-Exploring Random Tree (RRT) algorithm Time: September 17, 2018 during MSR Hackathon Author: Chenge Yang Email: chengeyang2019@u.northwestern.edu """ import numpy as np import math import matplotlib.pyplot as plt from matplotlib.path import Path import ...
da915e308927c3e5ed8eb0f96937f10fd320c8ab
Technicoryx/python_strings_inbuilt_functions
/string_23.py
360
4.46875
4
"""Below Python Programme demonstrate ljust functions in a string""" #Example: # example string string = 'cat' width = 5 # print right justified string print(string.rjust(width)) #Right justify string and fill the remaining spaces # example string string = 'cat' width = 5 fillchar = '*' # print right justified stri...
99f5c3f112857f0671f5aa6b2bc96357e8017487
DarrenZhang01/ComputerVision
/image_classification/test.py
653
3.6875
4
# reference from stanford CS231n "http://cs231n.github.io/classification/#intro" from nn import NearestNeighbor import data_utils Xtrain, Ytrain, Xtest, Ytest = data_utils.load_CIFAR10("cifar-10-batches-py") # transform each image into a 1-dimensional array Xtrain_rows = Xtrain.reshape(Xtrain.shape[0], 32 * 32 * 3) X...
82c8735b86f0d5246484a1c1c23c1f089a2cdec8
HeDefine/LeetCodePractice
/Q888.公平的糖果交换.py
1,675
3.578125
4
#!/usr/bin/env python3 # https://leetcode-cn.com/problems/fair-candy-swap # 爱丽丝和鲍勃有不同大小的糖果棒:A[i] 是爱丽丝拥有的第 i 块糖的大小,B[j] 是鲍勃拥有的第 j 块糖的大小。 # 因为他们是朋友,所以他们想交换一个糖果棒,这样交换后,他们都有相同的糖果总量。(一个人拥有的糖果总量是他们拥有的糖果棒大小的总和。) # 返回一个整数数组 ans,其中 ans[0] 是爱丽丝必须交换的糖果棒的大小,ans[1] 是 Bob 必须交换的糖果棒的大小。 # 如果有多个答案,你可以返回其中任何一个。保证答案存在。 #   # 示例 1: # 输入:...
5b1c132a185d6e92f5dd073844ad57f41659dde7
alejogonza/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/1-last_digit.py
592
3.984375
4
#!/usr/bin/python3 import random number = random.randint(-10000, 10000) # extraer el numero negativo if number < 0: newn = number % -10 # extraer el numero positivo elif number >= 0: newn = number % 10 # si es mayor que 5 if newn > 5: print('Last digit of {:d} is {:d} ' 'and is greater than 5'.for...
53118a945fdf41d5563cde9fdb91520890c20cb8
daniel-reich/ubiquitous-fiesta
/Z8REdTE5P57f4q7dK_1.py
148
3.59375
4
def collatz(n): s, m = 1, n while n > 1: if n % 2: n = (n * 3) + 1 else: n /= 2 s += 1 m = max(m, int(n)) return (s, m)
48f03295f9574bdae213b9d42065db5ef82da7b6
mailmaldi/UMBC
/MaldiMailer/src/python/mc-backup.py
5,166
3.953125
4
"""Example of Missionaries and Cannibals for use with AIMA code""" #! /usr/bin/python from search import * class MC(Problem): """ Classic missionaries and Cannibals problem. A state is represented by a three typle (M,C,B) where M, C and B are the number of missionaries, cannibals and boats on the left...
823135b7469f31087e728c5161354e4940e0c5de
AnshTrehan/old-python-codes
/password.py
166
3.796875
4
a=int(input("enter the password")) password=20 if a is password: print("You have succesfully loggined") else: print("Try again") if a is not password:
693d159d9ab77f6f359511e0764d93ec1120e5f2
AdamZhouSE/pythonHomework
/Code/CodeRecords/2668/60792/298419.py
267
3.734375
4
num=int(input()) for i in range(0,num): k=int(input()) if k==8: print("7 15") elif k==6: print("1 7") elif k==16: print("15 31") elif k==7: print("0 7") elif k==5: print("2 7") else: print(k)
934aca5e31ac7b1fddcbfe69c1963ea67dfbde6a
kuning19901/Algorithms-SedgewickandWayne-Python
/ch1-Fundamentals/ch1.1/ex1.1.6.py
315
3.609375
4
class ex_1_1_6: def main(self): f=0 g=0 for i in range(0,16): # print(i,end="\n") print(f,end="\n") f=f+g g=f-g programa=ex_1_1_6() programa.main() # imprime cero por 15 veces facil de comprobar por prueba de escritorio
6e6d8672622cb53d86cf3307eb255045266e4291
benkrubot/Project_6
/Project_6.py
4,738
4.34375
4
# This program will sort the random integers created by finding the lowest value corresponding to the label using cget, # then using a loop that will recreate the label with the lowest value sorting into ascending order. The loop in organize # is probably inefficient as it will only create 1 green label (indicating s...
36b6877957cc2aed04faa719f21ec701c8349262
axelmaldonado/lc101
/vigenere.py
579
4.125
4
from helpers import alphabet_position, rotate_character def encrypt(text, key): ans = ""ow i = 0 for letter in text: if letter.isalpha(): ans += rotate_character(letter, alphabet_position(key[i%len(key)])) i += 1 else:...
e2aa4be87f3ebac13257a435d69103aab00c0e45
Ryuis92/Algorithms
/BOJ/3036.py
306
3.6875
4
# https://www.acmicpc.net/problem/3036 def GCD(a, b): while b: c = a % b a = b b = c return a num = int(input()) rings = list(map(int, input().split())) first = rings.pop(0) for ring in rings: gcd = GCD(max(first, ring), min(first, ring)) print("{}/{}".format(int(first/gcd), int(ring/gcd)))
c1720b2df4a68a862bdd8b106c113f175ee4a514
TurnerWarr/Assignment2SoftwareTesting
/Retire.py
492
3.578125
4
def Retire(current_age, annual_salary, perc_save, desired_goal): saving = annual_salary * perc_save; employ = saving * 0.35; saving += employ; goal = desired_goal / saving; goal = round(goal, 0); if(goal + current_age >= 100): out = "Goal cannot be met with current parameters "; ...
6bae255d42446234960d6c7dece0408a63c457bb
QMSS-G5072-2021/cipher_gu_zhaokailu
/src/cipher_zg2382/cipher_zg2382.py
1,218
4.46875
4
def cipher(text, shift, encrypt=True): """ encrypting or decrypting a text with Caesar cipher. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet Parameters ---------- text : string text waitin...
dc51eaa6db848ca1f7bfbba623de1119d9608254
limiracle/python_example
/com/py/oo_test/type_example.py
920
3.71875
4
#coding=utf-8 #我们来判断对象类型,使用type()函数 print type(123) print type('abc') print type(abs) import types type('abc')==types.StringType type(str)==types.TypeType #有一种类型就叫TypeType,所有类型本身的类型就是TypeType #使用isinstance()函数 #对于class的继承关系来说,使用type()就很不方便。我们要判断class的类型,可以使用isinstance()函数 class Student(object): def __init__(se...
bcc6aee1f52480c8379eab7ce8bea0785d1ff582
prasang-gupta/online-courses
/data-structures-and-algorithms-specialization/course-01-algorithmic-toolbox/assignment/week-03/fractional_knapsack.py
1,014
3.671875
4
# Uses python3 import sys def get_optimal_value(capacity, weights, values): value = 0. # write your code here best = [0] * len(weights) for i in range(len(weights)): best[i] = values[i] / weights[i] data = [(x, y, z) for x, y, z in sorted(zip(best, values, weights), reverse=True)] curwe...
a8273ca136b8a72cd95e703787c1893ddeae84d4
JasonPhone/python-gadgets
/clock_laser.py
4,307
3.90625
4
# coding=utf-8 # 三对正交质点做矢量合成 # 需要: # 表盘:12 个大点(小时)和 48 个小点(分钟),以及 1 组坐标轴(浅色 RGB) # R #ff0000 #ffaaaa # G #00ff00 #aaffaa # B #0000ff #aaaaff # 质点:3 对共 6 个,浅色 RGB # 指针:3 个,实色 RGB,较大的圆点 # 效果线: # 坐标轴分开可能更好看?六芒? # @author ja50n # @time 2020-10-24-happy 2^10 day! import turtle impor...
e4768765b061072ef2f5fe856bd96b740aca33e1
rayo329/Antonio-markov
/markovmaestre.py
246
3.578125
4
import markovify with open("corpus.txt") as f: text = f.read() text_model = markovify.Text(text) for i in range(1): print(text_model.make_sentence()) # # for i in range(3): # print(text_model.make_short_sentence(280))
f924b9a38d4c5bf2e1a768b7405a6d4327884391
queryor/algorithms
/剑指offer/Permutation.py
878
3.6875
4
# -*- coding:utf-8 -*- # 题目描述 # 输入一个字符串,按字典序打印出该字符串中字符的所有排列。 # 例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,cab和cba。 # 输入描述: # 输入一个字符串,长度不超过9(可能有字符重复),字符只包括大小写字母。 class Solution: def Permutation(self, ss): # write code here if not ss: return [] if len(ss) == 1: ...
c28a48a6efcd6770969b241f478cf1162691e120
cyberkoko/python_bootcamp_18_8
/Zjazd4/Praca_z_json/zad1.py
621
3.5
4
import json baza_employees = ["Imie","Nazwisko","Rok urodzenia"] # zapis do pliku with open("employees.json", "w") as f: json.dump(baza_employees, f) # otwarcie pliku with open("employees.json") as f: baza_employees = input("Co chcesz zrobić ? ") if baza_employees == 'd': input("Imie ") ...
642837a891e0e1814c3268badd55c9df9768de3b
gyurel/Python-Advanced-Course
/exercise_multidimensional_lists_second/alice_in_wonderland.py
2,115
3.5625
4
# import sys # from io import StringIO # # test_input1 = """5 # . A . . 1 # R . 2 . . # 4 7 . 1 . # . . . 2 . # . 3 . . . # down # right # left # down # up # left # """ # # test_input2 = """7 # . A . 1 1 . . # 9 . . . 6 . 5 # . 6 . R . . . # . 3 . . 1 . . # . . . 2 . . 2 # . 3 . . 1 . . # . 8 3 . . . 2 # left # down # ...
ddf649a0796297bfcb5caf92bd7d7fe915ec1031
akaliutau/cs-problems-python
/problems/hashtable/Solution49.py
450
4.0625
4
""" Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. Example 1: Input: strs =...
28667f023b0fb2bdd6a70b0773a396df3ab431b7
PARKINHYO/Algorithm
/BOJ/1789/1789.py
312
3.640625
4
import sys input = sys.stdin.readline class Solution: def sum_of_numbers(self, S: int): count = 1 while True: if S - count - (count + 1) < 0: return count S -= count count += 1 print(Solution().sum_of_numbers(int(input())))
b3f7538364118fef65d707653fc53de26ca103d3
hsi-cy/codewars
/SOLVED/who_likes_it.py
997
4.25
4
#You probably know the "like" system from Facebook and other pages. People can "like" blog posts, pictures or other items. We want to create the text that should be displayed next to such an item. # Implement a function likes :: [String] -> String, which must take in input array, containing the names of people who lik...
cdc9f8aacc75801d5cd8945cb52b41b41a3c6217
yungbyun/uae
/code/myplot.py
912
3.671875
4
import numpy as np import matplotlib.pyplot as plot ''' Usage: import myplot guy = myplot.MyPlot() guy.show_list(list) import numpy as np import myplot.py gildong = myplot.MyPlot() gildong.set_attribute('o-') gildong.show(np.arange(1, 5, 0.1)) ''' class MyPlot: # display using a graph attr = 'o-' # line attri...
5839cae504e07ee74550c86509a878728f08733e
lesleyfon/Sprint-Challenge--Computer-Architecture
/cpu.py
8,449
3.90625
4
"""CPU functionality.""" import sys class CPU: """Main CPU class.""" def __init__(self): """Construct a new CPU.""" self.register = [0] * 8 self.ram = [None] * 256 self.pc = 0 # Program Counter, address of the currently executing instruction self.memory_loc = 0 ...
f8fa557356da5770ffa09bf8d5d783e3d2cb56a6
sareamato/sareamato
/RectangularMult.py
2,560
3.984375
4
#!/usr/bin/env python # coding: utf-8 # This code is for rectangular multiplication import numpy as np import math # In[5]: def rectangular (x,y): if x< 0 and y > 0: sign = 'negative' elif x > 0 and y < 0: sign = 'negative' else: sign = 'positive' x = abs(x) y = abs(y...
c39c17cca5bb4e50a31c0e6602b76b73458b61ce
jblovett/comp110-21f-workspace
/exercises/ex01/relational_operators.py
517
4.03125
4
"""Relational ops""" __author__ = "730155204" left: int = int(input("Left hand side: ")) right: int = int(input("Right-hand side: ")) less: str = str(left < right) greater_or_equal: str = str(left >= right) equal: str = str(left == right) not_equal: str = str(left != right) print(str(left) + " < " + str(right) + "...
a6241ab15d7a41e786fd0c216d040f940c3e99dc
Zane-P/CP1404Practicals
/Misc/letter_counter.py
218
4.125
4
import string def count_letters(input_str): counter = 0 for char in input_str: if char.lower() in string.ascii_lowercase: counter += 1 return counter print(count_letters("Test123"))
284aa5f2ea9f5aae3261423ce574b739007ad676
starrye/LeetCode
/all_topic/esay_topic/剑指 Offer 21.调整数组顺序使奇数位于偶数前面.py
1,240
4.1875
4
# encoding: utf-8 """ @Project : @File: 剑指 Offer 21.调整数组顺序使奇数位于偶数前面.py @Author: liuwz @time: 2022/3/30 12:00 下午 @desc: """ from typing import List """:cvar 输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有奇数在数组的前半部分,所有偶数在数组的后半部分。   示例: 输入:nums = [1,2,3,4] 输出:[1,3,2,4] 注:[3,1,2,4] 也是正确的答案之一。   提示: 0 <= nums.length <= 50000 0 <=...
e5035afa1948902fe32c4892121e3b7ab7f28ef8
zhaochuanshen/leetcode
/Copy_List_with_Random_Pointer.py
1,098
3.84375
4
''' A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy of the list. ''' # Definition for singly-linked list with a random pointer. # class RandomListNode: # def __init__(self, x): # self.label = x # ...
a78af751d01f17b0f656ef9ae5edb30aa18b2b39
Philip-Loeffler/python
/SectionFive/removingItemsBackwards.py
794
4.125
4
# removing rogue values from an unsorted list can bedone with less code that previous examples # when removing an item from a list while iterating forward, the size of the list changes # things go wrong here because items that are removed, shuffle down to fill in the gap # that messes up the index number as we work fow...
9a44cef2376d6b1e7af1340b77a6a524ac2aa842
oskarsja/Python_101
/Python_101/107_functions.py
2,092
3.8125
4
# 1. Uzrakstiet funkciju add_mult, ar trīs parametriem. Atgriež rezultātu, kas ir 2 mazāko argumentu summa reizināta ar lielāko argumenta vērtību. # Piemērs: add_mult(2,5,4) -> atgriezīs 30 def add_mult(number1, number2, number3): my_list = [number1, number2, number3] my_list.sort() result = my_list[0] + my...
9981e298128a94236cbcc46f413f85ee040e9009
arironman/MSU-Python
/ex-8-b(Pattern)/5.py
289
3.984375
4
#Pattern of 1 and 0 in alternate columns n=int(input("Enter Number of rows: ")) m=int(input("Enter Number of columns: ")) for i in range(0,n): for j in range(0,m): if j%2 == 0: print("1",end=" ") else: print("0",end=" ") print("")
f6af1a4d76c88ff34dfcfd1fbeca17d34e802f77
leils/dance-visualization
/data/csv_parser.py
382
3.796875
4
import sys import csv def main(argv): data_num = int(argv[0]) base = (data_num - 1) * 3 #The data is indexed at 1, not 0 with open('data.csv', 'rb') as csvfile: r= csv.reader(csvfile, delimiter=",", quotechar="|") for row in r: print row[base + 1] + "," + row[base + 2] + "," + row[base + 3...
ccef952b1a6957c4bba63c58dc14d354edf07daa
ulink-college/code-dump
/paper2_tasks/TestScoresApp/testScores_Task1_1.py
1,960
3.671875
4
########################################33333 # Test Scores Calculation App # # A teacher needs a program to record marks for a class of 30 students who have sat two computer science tests. # The system will need to store studnets names and their marks in seperate arrays and all marks will need to be validated on entry...
29b545d4a9dd3fe45053a3dcd8a9d591f7de3d01
nikos-daniilidis/hadoop-mapreduce-o
/reducer2.py
1,144
3.84375
4
#!/usr/bin/python import sys maxSale = -1. oldKey = None ''' Find the value of the highest individual sale for each separate store, using a file with records of purchases. Each line in purchases.txt is: date\ttime\tstore name\titem description\tcost\tmethod of payment e.g. 2012-01-01 09:00 San Jose M...
db3b70e844d16af0a947b994e88ca8150101e72d
menquist/Michael_Enquist
/Python/Hackerrank/Warmup-Diagonal Difference.py
1,022
4.21875
4
''' Given a square matrix, calculate the absolute difference between the sums of its diagonals. Input Format The first line contains a single integer, denoting the number of rows and columns in the matrix . The next lines denote the matrix 's rows, with each line containing space-separated integers describing th...
830fb7f04e0377bd01ac86c0655577a811f86013
shoriwe-upb/TallerEjercicios
/Exercises/ejercicio-36.py
248
3.8125
4
def main(): a = float(input("Number a: ")) b = float(input("Number b: ")) c = float(input("Number c: ")) if a + b > c: print("Es mayor") elif a + b < c: print("Es menor") if __name__ == '__main__': main()
ff2ac853af7c37896ef316a71677902fe937db01
HamonOverdrive/sendex_stuff_and_interactive_algorithms
/interativeProjects/chapter 1/warCard.py
2,102
3.8125
4
import random # notes about making card class and deck https://stackoverflow.com/questions/41970795/what-is-the-best-way-to-create-a-deck-of-cards class Card: def __init__(self, value, suit): self.value = value self.suit = suit def __str__(self): return str(self.value) + ' '+ str(self....
5cce1b52c2afa6529a66a6d40df9ff2c649c1482
mouyleng2508/PycharmProjects
/week02:ex/27_mean_of-list.py
141
3.515625
4
def mean_of_list(lists): average = sum(lists) / len(lists) return average avg = mean_of_list([50, 10, 62, 32]) print(round(avg, 2))
a493ef969a3c2e021318bb00555308b823e6da1b
pandasandeggs/Python-Practice
/madlib.py
2,490
4.0625
4
def madlib_game(): #starts the game print "Let's play Mad Libs!" first_madlib() user_option() #function for first round def first_madlib(): #collects users input name = raw_input("Choose a name: ") place = raw_input("Choose a place: ") food = raw_input("Choose a food: ") ...
903ad3afd1df5e2fe4451c436a21d0797bfa82e9
BlackGoku36/PythonRaytracer
/util/vector.py
2,014
3.65625
4
from math import sqrt from random import random class vec3 : def __init__(self, x, y, z) : self.x = x self.y = y self.z = z @staticmethod def length(v) : return sqrt(v.x ** 2 + v.y ** 2 + v.z ** 2) @staticmethod def normalize(v) : v_len = vec3.length(v) ...
a2de46c50c0807fc7d6104b10592f857a9fa990b
mupotsal/Programming_Practice_IGIT
/stringsss.py
404
3.875
4
def reverseWords( s: str) -> str: splitted_sent = s.split() new_lis = [] rev_str = "" for i in range(len(splitted_sent)): x = splitted_sent[i][::-1] # this is how to reverse the sentence letters new_lis.append(x) rev_str += x if i == len(splitted_sent) - 1: ...
e93f4a290a9eed35453de95e228f4b60b428e0f6
Paulacamposro/Coursera
/buscaModeloCasquete.py
960
3.6875
4
class Casquete: def __init__(self, titulo, marca, artista, ano): self.titulo = titulo self.marca = marca self.artista = artista self.ano = ano class Buscador: def busca_por_titulo(self, colecao, titulo): for i in range(len(colecao)): if colecao[i]....
e820c493a3f7259d3ec76d911e650771706fab7f
flashfinisher7/ML_Fellowship
/Week1/Program6.py
266
3.984375
4
from datetime import date First_date = date(2014, 7, 2) Last_date = date(2014, 7, 11) diff = Last_date-First_date print(diff.days) print(First_date >= Last_date) print(First_date <= Last_date) print(First_date == Last_date) print(First_date != Last_date)
9a72870fbc63bab4057c8f1b88d6ef4bf45f3f84
trilamsr/LeetCode
/0429_N-aryTreeLevelOrderTraversal/N-aryTreeLevelOrderTraversal.py
1,007
3.6875
4
from collections import defaultdict """ # Definition for a Node. class Node: def __init__(self, val, children): self.val = val self.children = children """ class Solution: def levelOrder(self, root: 'Node') -> List[List[int]]: ret = defaultdict(list) def recurse(node, ...
653470f989448188bfeac05e2bc786bcc4f38a8c
schw240/Fastcampus_secondtest
/python_basic/section11-1.py
2,160
3.5
4
# Section11 # 파이썬 외부 파일 처리 # 파이썬 Excel, CSV 파일 읽기 및 쓰기 # CSV : MIME(형식) - text/csv import csv # # 예제1 # with open('python_basic/resource/sample1.csv', 'r') as f: # reader = csv.reader(f) # next(reader) #Header 스킵 # # 확인 # print(reader) # print(type(reader)) # print(dir(reader)) # print() ...
0c214ebedaef41540534d80dda84d7e8dc0d2582
yaronlevi1/CDcode
/Python/python_fundamentals/FindCharacters.py
158
4
4
word_list = ['hello','world','my','name','is','Anna'] char = 'o' o_list = [] for i in word_list: if char in i: o_list.append(i) print(o_list)
ba6a23a93731a8374409d9995078b10b9b3ee825
kyclark/rosalind.info
/17_perm/perm.py
1,086
3.796875
4
#!/usr/bin/env python3 """Enumerate permutations""" import argparse from itertools import permutations from typing import NamedTuple class Args(NamedTuple): num: int # -------------------------------------------------- def get_args(): """Get command-line arguments""" parser = argparse.ArgumentParser( ...
f3c8934a0408e7910aceb4522e807b8580fc59ad
ccewart/diplomacy
/map/territory.py
1,950
3.6875
4
# -*- coding: utf-8 -*- """ Created on Sat Jul 13 06:47:02 2019 @author: Jamesrulz """ class subtypeException(Exception): pass class supplyCentreException(Exception): pass class Territory: ''' defines a territory which is the unit that the map consists of ''' ''' a territory has a name, a set of adj...
a8c4b9ad4a92a7b26096cb5e51b000ffb10a3826
YoupengLi/Jianzhi-offer-sorting
/第3章 高质量的代码/reverseList.py
1,722
3.890625
4
# -*- coding: utf-8 -*- # @Time : 2019/1/17 0017 下午 4:30 # @Author : Youpeng Li # @Site : # @File : reverseList.py # @Software: PyCharm ''' 题目:输入一个链表,反转链表后并输出反转后链表的头节点。 例如 1->2->3->4->5 ==> 5->4->3->2->1 tmp = pHead.next 把当前节点的下一个节点保存下来 pHead.next = pre 把前一个节点移到当前节点的下一个节点,因为要翻转节点,pre始终指向要...
df75ace38c1ec8f7c9ba29ab8db9609c5a85b56b
Tempade/python-projects
/Connect4/proj07.py
14,811
3.984375
4
################################################################# # CSE 231 Project 7 # # Functions and Mutables # User is given a description of Connect Four # User is asked to pick a color between white and black # User is then told what color you and your opponent is # User is shown the boa...
32369676acb2cc4879187db98fbcc9eb3b7c5c50
mitsuhoiida/keio2018pyalgdat-assignment
/submissions/a21647348/part4/part4.py
2,424
3.625
4
from assignment import * def main(): # ----- # 1. Load the context dictionary using the load_pkl function. # 2. Compute a 10 nearest neighbors graph using your implementation of the # get_knn_graph function for all the words appearing in the corpus. # 3. Save the graph neighbor dictionary to a f...
be813038a520bb8182c3c277aee0b2eed5ec468b
amartyas02/ML_Templates
/Multiple_linear_regression.py
2,304
3.75
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt data = pd.read_csv('/home/amartya/Desktop/Udemy_data/Multiple_Linear_Regression/50_Startups.csv') X = data.iloc[:, :-1].values y = data.iloc[:, 4].values from sklearn.preprocessing import LabelEncoder labelencoder = LabelEncoder() X[:,3] = labelen...
f17bde3f81c92630b1c5eed25bd9a9be74c9f18c
bhornung/python-utilities
/source/pandas_utils.py
1,749
3.65625
4
import numpy as np import pandas as pd def calculate_rolling_mean_std(df_, win_size, pad_size = None, add_expanding = False): """ Calculates the rolling mean and \pm 1 standard deviations of a series. Parameters: df_ ({pd...
6a16be20593348a97b054ea0d60ca3f4b0a0d23a
programmingkids/python-level3
/chapter10/work08.py
543
3.6875
4
""" 関数「get_triangle_area」を定義してください 関数名:get_triangle_area 引数:2個 base(底辺)、height(高さ) 戻り値:数値 処理:2個の引数(底辺と高さ)に基づいて三角形の面積を計算します。 三角形の面積を戻り値として返します 以下のように表示する処理を作成してください 10.0 """ # 以下の部分に関数を定義します # これ以降は修正してはいけません num1 = 4 num2 = 5 print(get_triangle_area(num1, num2))
f0270fceadf702c87939e0dc56e9a3ac768e6764
Pr0Vlad/Coding-Problems
/valid parens.py
801
3.796875
4
#having valid parrenthesis/brackets/etc that match class paren(object): def check(self, s): #a map for what matches with what parens = { '[' : ']', '{' : '}', '(' : ')', } #parens inverted inverse = {v:k for k,v in parens.items()} stack = [] for c in s: ...
5fadd69da194ed9971e5c03b35e790703845a4a2
mario-marques/yrl
/pibic-2020-2021/programas/replace-char/replace-char-2.0.py
1,077
4.1875
4
#! /usr/bin/env python3 # -*- coding: utf-8 -*- # Authors: Juliana Lopes Gurgel; Leonel Figueiredo de Alencar Araripe # <julianalgurgel@alu.ufc.br; leonel.de.alencar@ufc.br> # Date: 03/22/2021 """ Usage: replace_char_new.py INPUT_FILE Example: replace_char_new.py test.txt """ import sys 'This program corrects som...
4eb7bb3b77de7d9a9b3b98149ed21bb2c9622e45
jimboy911/guestList
/guestList.py
547
3.953125
4
#guestList.py import csv #import the csv module into the program def main(): with open("GuestList.txt", "r") as guestList: #opens GuestList.txt file, saves it as guestList, then closes the file guests = csv.reader(guestList) #goes through the entire guestList and seperates each entry with a comma ...
413744f30147a17fd6f53f3dc50892005e589e3f
EmilHernvall/projecteuler
/primes.py
1,031
3.515625
4
import math def eprimes(max): sieve = range(0, max) pos = 2 primes = [] while pos != max: while pos < max and sieve[pos] == 0: pos += 1 if pos == max: break; n = sieve[pos] sieve[pos] = 0 primes.append(n) i = pos while i...
611c1761815209178f573ab63bc3ce5f9d4cd55a
avalvillar/Self_Paced-Online
/students/stefan_lund/Lesson_3/strformat_lab.py
4,106
3.53125
4
# python3 # strformat_lab.py def task_one(my_tuple): """ my_tuple: tuple, ( 2, 123.4567, 10000, 12345.67) """ # first item file = "{:{padding}>{str_len}}".format(my_tuple[0], padding = 0, str_len = 3) # second item two_dec = "{:.2f}".format(my_tuple[1]) # third item...
a4f45a44de7a3aeeaf9601b36eb49132790fa154
feliperromao/curso-python-cod3r
/fundamentos_projetos/area_circulo_v10.py
422
3.578125
4
from math import pi import sys def calcular(raio): area = pi * float(raio) ** 2 return area def myHelp(): print('É necessário informar a área do circulo.') print('Sintaxe: {} <raio>'.format(__file__)) if __name__ == '__main__': if len(sys.argv) < 2: myHelp() else: raio = sy...
700864825e31c37350a9c60d63370a382d571ee4
Chreno972/P4_chess_tournament
/app/models/models_admin.py
1,011
3.765625
4
"""The administrator module Returns: class: The administrator's class """ class Admin: """The game administrator class""" def __init__(self, name, prename): """Game administrator initialisation Args: name (str): The game administrator name prename (str): The game...
bbb47dc535d871117d478c213e7bdf42bb139393
mathewjustin/pylearn
/ds-algo/dsalgos/ds-arrays/arrays.py
355
3.9375
4
array = [2,3,5,7,1] print(array[0]) # index based access , indexes will be starging with 0 print(array[0:2]) #returns from index 0 to index 2 exclusive print(array[:-1]) # all expect last 1 array2 = [10.0,3,'Justin'] # In python array can mix the types # linear serch O(N) max=array[0] for num in array: if n...
c7e00c7e11d07e7101970c0dd4a07aa6626bf01f
danr18/Python-Programs
/closest.py
1,095
3.90625
4
# closest.py: takes three floats x, y, and z from the command line, reads from # standard input a sequence of coordinates (x_i, y_i, z_i), and writes the # coordinates of the point closest to (x, y, z). import stdio import sys # Read x, y, and z from command line, as floats. x = float(sys.argv[1]) y = float(sys.argv[...
07c6d563676939d7cdec307210a7351a773a9e26
laufei/PythonExample
/other/Example_21.py
535
3.84375
4
# coding: utf-8 __author__ = 'liufei' ''' 题目:猴子吃桃问题:猴子第一天摘下若干个桃子,当即吃了一半,还不瘾,又多吃了一个第二天早上又将剩下的桃子吃掉一半,又多吃了一个。 以后每天早上都吃了前一天剩下的一半零一个。到第10天早上想再吃时,见只剩下一个桃子了。求第一天共摘了多少。 ''' def fn(x): tmp, result = 1, 0 for _ in range(x-1): tmp = (tmp + 1) * 2 result = tmp return result print fn(10)
0e3001187be165e38a52bdada410c738cd8fbdda
JiyeonChoi97/Python_prac
/14-class/exam4.py
882
3.859375
4
class HelloWorld: message = 0 # 클래스 변수 def setEng(self): self.message = 'Hello Python' # 인스턴스 변수 def setKor(self): self.message = '안녕하세요. 파이썬' def setKor2(self): message = '파이썬 파이팅!!!' # 지역 변수 def sayH...
309c1fd7a5e30ae27f026e0c09d4636ea17dcf84
Ricarss/Python-B-sico
/search_and_sorts/merge_search.py
1,113
3.53125
4
import numpy.random as rd def ar_gen(): size = rd.randint(10,15) # código que genera el tamaño de la lista ar = [rd.randint(0,size) for i in range(size)] # código que genera el listado return ar def merge_join(l): if len(l) > 1: mid = len(l)//2 left = l[:mid] right = ...
32f355adb14f3ff92b488322f0e2d50ac24fc67d
calebe-takehisa/repository_Python
/procedural_programming/ex032.py
888
4.03125
4
""" Faça um programa que leia um ano qualquer e mostre se ele é Bissexto. SAÍDA: Que ano quer analisar? Coloque 0 para nalisar o ano atual: Não é Bissexto: O ano xxxx NÃO é bissexto. É Bissexto: O ano xxxx é Bissexto OBS:Chama-se ano bissexto o ano ao qual é acrescentado um dia extra, ficando com 366 dias,...
daaa71041ffe38ae847cf0b1ea68a7d2f3b31d43
ishitagithub/Library-Management
/Ishita csproj/arstud.py
1,578
3.53125
4
#ishita import mysql.connector mydb=mysql.connector.connect(user='root', host='localhost', password='Ishita.mysql') mycur=mydb.cursor(buffered=True) mycur.execute("use library") def addstudent(): mycur.execute("use library") ...
fec6f964f39def5274c50acb79b04185638115c8
Lidico/ProjectEulerEx
/numberLetterCounts - Ex17.py
2,152
3.828125
4
""" If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used? NOTE: Do not count spaces or hyphens. For example, 342 (thre...
913eb521c9252c19c1129c444f36e9abc1a99200
ospiotrek/TicTacToe
/main.py
3,883
3.96875
4
##Ogolnie to wszystko jest pomieszane w caly swiat## #####Plansza board =['-', '-', '-', '-', '-', '-', '-', '-', '-'] def show_board(): print('(1|2|3)\n(4|5|6)\n(7|8|9)\n') print(board[0] + '|' + board[1] + '|' + board[2]) print(board[3] + '|' + board[4] + '|' + board[5]) print(board[6] + '|' +...
ea9d31802262b8040fd49182b1d01693e13cd45d
mhashilkar/Python-
/4.0_file.py
791
4.03125
4
#open a file fo = open('test.txt', 'w') #Get some info print('Name: ', fo.name) print('Is Closed: ', fo.closed) print('Opening Mode: ', fo.mode) # WRITE IN TEST.TXT FILE FROM PYTHON fo.write('I Love Python') fo.write(' and javascript') fo.close() #AFTER CLOSEING FILE WE HAVE TO AGAIN OPEN THAT FILE # THIS CODE WILL ER...
3e35e73292129beeeacc4bdbd9398a4819f331f8
CodeGuardianAngel96/OOPS-I-Posted
/NotStartingWithS.py
643
4.3125
4
''' Write a function in python to count the number of lines from a text file "WORD.txt" which is not starting with an alphabet "S". Example: If the file "story.txt" contains the following lines: A boy is playing there. She is good. An aeroplane is in the sky. sky is pink. Alphabets and numbers a...
614d8832f5e4368f8b1ea116d195631abb4a120c
pauleclifton/GP_Python210B_Winter_2019
/students/WooseokJ/List+WJ.py
1,444
4.09375
4
# coding: utf-8 # In[10]: # Series 1 print("Series 1") fruits = ["Apples", "Pears", "Oranges", "Peaches"] print(fruits) newfruit = input("Please type in a new fruit ") fruits.append(newfruit) print(fruits) index = input("Please enter a number from 0 to 4 ") selected = fruits[int(index)] print("You have selected fru...
c78136fa2d7fbddd3784c1d7ce6086d63537922c
zhenggang587/code
/mitbbs/274.py
813
3.625
4
class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def getSolution(self, head1, head2): p2 = head2 m2 = {} while p2: if p2.val not in m2: m2[p2.val] = 0 else: break p2 ...
e40a1295085df1e0bf14f589c9c55993f63fb428
borshec/w3resource_exercises
/128.py
96
3.84375
4
import re s = "DNDJDtDDJDJD" res = re.search("[a-z]", s) if res is not None: print("Exist")
6acffafe02267799b7457b585dbfb905a5380a05
RafaRomero8/My-First-curso-in-phyton
/exhaustiva.py
1,344
3.890625
4
def run(): objetivo = int(input('escoge un numero'))#quiero encontrar la rai cuadrada de un numereo random epsilon = 0.0001 #presicion que queremos(acepto una incertidumbre del1%) paso = epsilon**2 #mas pequeño que epsilon,debemos recorrer un tramo probando as posibles soluciones respuesta = 0.0 #variab...
1003ef2a180861be74bc4c90a77567f0cafa1c58
zmarkovic1987/python_projects
/project1/basic_syntax/methods_demo2.py
467
3.84375
4
""" Positional Parameters They are like optional parameters Anc can be assigned a default value, if no value is provided from outside """ def num_sum(x=2, y=3): """ Get sum of 2 numbers :param x: :param y: :return: """ return x + y sum1 = num_sum() sum2 = num_sum(y=5) sum3 = num_sum(x=10...
15d5846475832b341cf184c8ba03713dc3843449
saipujithachandhragiri/udemy_python_practice
/35.py
211
4.15625
4
# Create a function that takes any string as input and returns the number of words for that string. def wordcount(str): str = str.split() return(len(str)) str = 'bharath reddy kandula' print(wordcount(str))
0ab04016b37df5ca8d6730f003f67543bcec6ab9
damclaugh/UW_Programming_In_Python
/lesson-05-mailroom-with-dictionaries-damclaugh/mailroom.py
3,137
4.0625
4
#!/usr/bin/env python3 import sys from operator import itemgetter # donor list donor_db = {"Bill Gates": [653772.32, 12.17], "Jeff Bezos": [877.33], "Paul Allen": [663.23, 43.87, 1.32], "Warren Buffett": [1663.23, 4300.87, 10432.25], "Mike Bloomberg": [10786.77, 4567.8...
2b8a475b1c742cdd58812728d605e8d15f9b55fa
privateHmmmm/leetcode
/075-sort-colors/sort-colors.py
2,826
4.125
4
# -*- coding:utf-8 -*- # # Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. # # # # Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively. # # # # Note: ...
20d1f7a41b5179108fed14ae2534c2cdcbcff4c1
IBSHAMI/Typing-Test-GUI
/test_page.py
13,727
4.03125
4
from tkinter import * from random import choices import datetime # test variables time = 60 wpm = 0 cpm = 0 accuracy = 0 # a function to create the text to be used in the typing test # the words has been taken randomly from a word generator website def create_text(): with open("words.txt", "r") as words: ...
c69d650c562f7a60daf7e418991ec47e57a1cda4
sarthakagrawal927/6th-sem-cse
/IT_LAB/lab4/practice.py
339
3.90625
4
class Person: "This is new class, this is comment" age = 10 def __init__(self, name): self.name = name self._age = 0 def greet(self): print('hello from {name}'.format(name=self.name)) print(Person.age) print(Person.greet) harry = Person('harry') harry.greet() # equates to P...
557c1eb5cbcc92e74519539d98187a5b1528d6dc
SmashAF/Random_Code_Storage
/weekly_challenges_completed.py
26,637
4.0625
4
''' WCC: February 1st, 2021 ''' # def quad_solver(a ,b, c, x): # return (a*x**2 + b*x + c) # def mult_table(x): # table = [] # for col in range(1, x+1): # using = [] # for row in range (1, x+1): # using.append(col * row) # table.append(using) # return...
ad0da0fad153e0ff8a80b6a75b2489d5ee2ea888
wangtao666666/leetcode
/20181008-665-Non_decreasing_Array.py
537
3.703125
4
# encoding = 'utf-8' class Solution(object): def checkPossibility(self,nums): """ :param nums: :return: """ if len(nums) < 2: return True a1 = nums[:] a2 = nums[:] for i in range(len(nums)-1): if nums[i] > nums[i+1]: ...
8dae4f3314635000da261263052677d6b748f2ea
jalex141/nuclear-power
/src/cleaning.py
4,356
3.609375
4
import pandas as pd import seaborn as sns import numpy as np import re import os import sys sys.path.append('../') def download_dataset(): '''Downloads a dataset from kaggle and only keeps the csv in your data file. Beware of your own data structure: this creates a data directory and also moves all the .csv fi...
486e665889bd50a4ff15ba8cd3ce112917f8f0dd
rafarc97/Courses
/Python/interfaces/interfaceslabel.py
736
3.734375
4
from tkinter import * root=Tk() miFrame=Frame(root,width=500,height=400) miFrame.pack() miImagen=PhotoImage(file="1.gif") Label(miFrame,image=miImagen).place(x=100,y=200) #miLabel=Label(miFrame,text="Hola alumnos de Python") #miLabel.pack()#adapta la raiz y el frame a lo que ocupe el mensaje #para que se respeten las ...
d46090cdcdd3f8eba2413690fa934f228e7bc91d
Clifnich/Image-Segmentation
/app.py
2,095
3.734375
4
# This is a image processing application # You can input an image, set the label # set size and expect to see the image # separated into several parts as you specified # import the necessary packages import matplotlib.pyplot as plt # I'm using another image library #import matplotlib.image as mpimg import numpy as n...
f183775ed3a7c04cfc5c0be1e4ba0a5a15b8ee35
JafetMo5601/DS_algorithms
/Algorithms/Rotation.py
282
4
4
def shiftNumber(number, arr): arr.insert(0,number) def Rotate(arr, k): if k == 0: return arr else: while k > 0: shiftNumber(arr[-1], arr) arr.pop(-1) k -= 1 return arr arr = [3,8,9,7,6] print(Rotate(arr, 3))
92e7f8ba723b7b4bfbc717e8778eb0fa44f0c670
Nkugsw/python-notes
/10142018.py
470
4.125
4
travel = ['kuwait','langkawi','ny','japan','vienam'] #print('The first three items in the list are:') #print(travel[:3]) #print('Three items from the middle of the list are:') #print(travel[1:4]) #print('The last three items in the list are:') #print(travel[-3:]) friendpizza = travel[:] friendpizza.append('cannoli'...
80403ad4b4edd85ce0dae9528623a01d5cd81015
Addarsh/PythonPrograms
/BinarySearch/BinarySearch.py
455
3.96875
4
#Implement Binary Search solution def Bsearch(arr,elem): start = 0 end = len(arr)-1 return bsearch(arr,elem,start,end) def bsearch(arr,elem,start,end): if(start > end): return False mid = (start + end)/2 if(arr[mid] == elem): return True if(arr[mid] > elem): return bsearch(arr,elem,start,mid-1) if(arr[mid] ...
e30548e39ef3d97ee4b14f97b2855353153d94c1
vladsadretdinov/olge-molchanov-oop
/17 ООП super() и делегирование родителям.py
567
3.78125
4
class Person: def __init__(self, name): self.name = name class Student(Person): def __init__(self, name, surname): super().__init__(name) self.surname = surname # super().__init__(name) s = Student('Ivan', 'Ivanov') print('s.__dict__', s.__dict__) class Person1: def he...
eaf9917c9390a22240ae38136f3bb1f24061b207
AruzhanBazarbai/pp2
/tasks/task4/E.py
328
4.03125
4
''' def f(text): words=text.split() max_size=len(max(words,key=len)) return [word for word in words if len(word)==max_size] text=input() s=f(text) print(*s) print(len(*s)) ''' def f(text): words=text.split() word=max(words,key=len) return word text=input() s=f(text) print(s) print(len(s))...