blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
3dd9636f2b5c8b486c777c137a594650d0d2978d
kookoowaa/Repository
/SNU/Python/BigData_Programming/170731/Class.py
722
3.578125
4
class PartTimer: '''A Simple Class''' hour_rate = 7500 total_parttimer = 0 # nickname = None # def setnickname(self, name): # self.nickname = name def __init__(self, name, place='133-dong'): # initial self.total_wage = 0 self.nickname = name self.work...
bca8402f3b817753715d7f275124e63f39414a1e
ThinkerDreamer/CPT051
/noelle_sql_pthon_demo.py
1,040
3.53125
4
#https://www.w3schools.com/sql/sql_insert.asp #https://www.w3schools.com/python/python_mysql_select.asp import mysql.connector from datetime import datetime now = datetime.now() #connection mydb = mysql.connector.connect( host="localhost", user="root", password="", database="HospitalPython" ) ''' CREATE TABLE...
621897fcdff985d4d47fd336a4702fd327648ff6
981377660LMT/algorithm-study
/7_graph/环检测/无向图找所有的环dfs.py
1,161
3.59375
4
from typing import List from typing import Iterable, Mapping, Sequence, Union AdjList = Sequence[Iterable[int]] AdjMap = Mapping[int, Iterable[int]] Graph = Union[AdjList, AdjMap] def findCycleGroup(n: int, graph: "Graph") -> List[List[int]]: """无向图找到所有的环,图可能不连通""" def dfs(cur: int, pre: int) -> ...
42193bd1c442efaefe6720ad9753b49c400fe1ad
jaliagag/21_python
/UCEMA/12/fibonacci.py
175
4.21875
4
numero = int(input('ingresa un numero: ')) def Fibonacci(n=1, a=0, b=1): print(a) for i in range(n-1): c = a + b print(c) b = a a = c Fibonacci(numero)
d806c3e95a9f8dfd7772ca09890e582a81df94db
cjwoodruff/Python_Tutorials
/Loops/while_loop.py
469
4.28125
4
# Using a while loop, iterate x down from 10 to 0 x = 10 while x > 0: print(x + ' is greater than zero') x-- print('x is now equal to 0') # Ask user for input and print the input if is isn't # which continues # or 'done' which ends the loop print("Type 'done' when you want to leave the loop.") while True: ...
e9f53ecd7edb59f7327883f400c2628a07929d6f
Douglas29X/Programa-de-nomenclaturas-na-quimica-organica
/nomenclatura dos compostos organicos/quimica_organica.py
2,873
3.765625
4
from abc import ABCMeta, abstractmethod from listas import csv_para_python import os class Organico(metaclass= ABCMeta): quantidade = ['di','tri','tetra'] @abstractmethod def get_sufixo(self): pass @abstractmethod def monta_composto(self): pass def imprime_...
d11e2117fbdcbc4b21f4339e6a7de36858e1d859
Sasha1152/Training
/classes/property_diameter.py
315
3.734375
4
class Circle(): def __init__(self, radius): self.radius = radius @property def diameter(self): return 2 * self.radius c = Circle(5) print(c.radius) print(c.diameter) c.radius = 6 print(c.diameter) c = Circle(8) print(c.diameter) # c.diameter = 1 # AttributeError: can't set attribute
6dab3b4ee40411371e7b8a3d132246bf46128b75
abhi9741/random-number-generator-algorithm
/v2.py
1,361
3.890625
4
#Author : Abhinav Reddy Nimma (16XJ1A0504) import random from random import randint as r #random library has an easy partern of showing random integers that can be easily cracked, so we just use it in solving our algorith l=1 print "enter an upperbound from (5,7,11,17,23,53,61,71,101,503), upperbound U gerates a ...
ac734eda427eb7386087871e265e51777662ca05
acetoacetato/ANN
/main.py
5,366
3.734375
4
import math import numpy as np class Neurona: def __init__(self, input = list(), output = list(), de_input = False): self.input = list() self.val = 0.0 self.de_input = de_input self.input_pesos = list() # Si la lista de input está vacía, entonces se queda ahí for i i...
80c2b052011ba15f1607ccf1ff5c67c657f12464
JarateKing/Competitive-Programming-Textbook
/code/runtime_complexity_1.py
137
3.53125
4
# read in n n = int(input()) # O(1) algorithm result = 0 if (n == 99): result = 1 # output the result from our algorithm print(result)
44923382c01c22eed966ed92b18f9a1e424764e2
caimengyuan/daydayup
/advUsage/decoraterMember.py
297
3.8125
4
''' 装饰器 ''' import time def timeit(fun): def res(): start_time = time.time() fun() end_time = time.time() print('the function use time: %.2f'%(end_time - start_time)) return res @timeit def f(): time.sleep(3) f() # the function use time: 3.00
e869335eb87e30bd33c47819233a0c1315a8067a
MrMyerscough/Coding-Course-Stuff
/python/playground/test.py
3,297
3.765625
4
x = ['c', 'g', 'r', 't', 'v'] x[1] = 'e' x.remove('t') x.append('m') x.pop(2) print(x) # import random # exit = False # print('welcome to math practice! pick an option.') # while exit != True: # print('1 - practice addition') # print('2 - practice subtraction') # print('3 - practice multipl...
6851fed0742e345618ef87789695581c17eeec29
colephalen/SP_2019_210A_classroom
/students/jsward/session02/fizz_buzz.py
374
3.609375
4
#fizz_buzz.py # write 1 to 100 inclusive # for multiples of 3 print "Fizz" # for multiples of 5 print "Buzz" def fb(): for i in range(100): fb_string = "" if i % 3 == 0: fb_string += 'Fizz' if i % 5 == 0: fb_string += 'Buzz' if len(fb_string) < 1: ...
e7eebfe38d7a501ef3947e79c40a7c10d17b1cd8
krnets/codewars-practice
/6kyu/Drunk friend/index.py
1,258
3.890625
4
# 6kyu - Drunk friend """ You're hanging out with your friends in a bar, when suddenly one of them is so drunk, that he can't speak, and when he wants to say something, he writes it down on a paper. However, none of the words he writes make sense to you. He wants to help you, so he points at a beer and writes "yvvi"...
8190e92bded4a972285bac4f9a754fd00e543785
chy996633/python_practise
/beginning_python/chapter_9/property.py
836
3.75
4
class Rectangle: def __init__(self): self.width = 0 self.height = 0 def setSize(self,size): self.width, self.height = size print "set size, width, height : ", size def getSize(self): return self.width, self.height s = Rectangle() s.height = 100 s.width = 50 print ...
e4a5a6ba561ad1620c0f154e9c573fb90aa454b5
Mugala/Password-locker
/credential_data.py
641
3.625
4
class Credential: """ Class that generates new instances of credential Generate password for the user hold the username and the password... """ pass account_desc = [] #this is where the passwords will be held once generated def __init__(self,gen_passcode,): #the intance variable ...
285f634ad82f3fe053a30c463498d5677d6de74b
rjgonza/Lab
/python/LPTH/ex48/ex48/lexicon.py
539
3.71875
4
#!/usr/bin/python mappings = { 'north' : 'direction', 'south' : 'direction', 'east' : 'direction', 'go' : 'verb', 'kill' : 'verb', 'eat' : 'verb', 'the' : 'stop', 'in' : 'stop', 'of' : 'stop', 'bear' : 'noun', 'princess' : 'noun' } def scan(x): pieces = x.split(' ') ret_val = [] for piece in pieces: i...
8a4c49fab4ed566975fef77fd4ffa937ca07cf30
Krupal775/python
/format.py
131
3.5625
4
name = "krupal success" work = "enterpreneur" # a = f'{name} and work as {work}' a = "{} and work as {}".format(name,work) print(a)
5022076be427232b9b836d5319a7b16c036fd218
Vanderson10/Codigos-Python-UFCG
/uni7/SemLetrasIguaisConsecultivas/semlicons.py
779
3.84375
4
#deixar tudo em maisculo upper() #usar um for para acessar cada elemento da lista #usar outro for para analisar as letras dentro da lista #se a letra consecutiva de uma plavra for igual, então vamos remover essa palavra def remove_consecutivas(lista): soma = 0 for i in range(len(lista)-1,-1,-1): prox =...
e25c93b77d99e4d788f10a8705b9ec6100ee1fea
OskarKozaczka/pp1-OskarKozaczka
/02-ControlStructures/Programs/2.42.py
152
3.546875
4
a = int(input("Wprowadz liczbe a: ")) b = int(input("Wprowadz liczbe b: ")) if(b==0): print("Dzielenie przez 0!") else: print(f"Wynik : {a/b}")
f4e51963cb1460a5c60a78c796b67cdc46c71215
imruljubair/imruljubair.github.io
/teaching/material/Dictionary/7.py
277
4.125
4
# Adding keys and values in dictionary # Modifying keys and values in dictionary card = {} for letter in ['A', 'B', 'C']: card[letter] = [] for k in card: card[k] = [1,2,3,4] print(card) card['D'] = [5,6,7] card['A'] = [8,9,10] print(card)
3472a218f5dc9411b708e2e9d6571cde422ce6c2
syeal01/python_programing
/alphabet_tree.py
235
3.765625
4
# Author: Aliabbas Syed # Print a Alphabet tree diagram like this # A # A B # A B C # A B C D # A B C D E rows = int(input("Enter Number of Rows? ")) for i in range(rows): for j in range(i): print(chr(j+65), end=" ") print()
6b8eb9da8d56eb2ff159ec295308ac77918328a0
Luislogue/blog_notas
/apps/blog_de_notas.py
1,171
3.765625
4
''' Blog de notas de Luis -------------------- v1.0 ==================== Ejercicio que puntua 3 puntos del final ''' def escribir_nota(nota): f=open("notas.txt", "a") f.write(nota) f.close() def leer_nota(): f=open("notas.txt", "r") contenido =f.read() return contenido ...
f255ffdb7d64142ee64af86fb5235d2ccf96601f
Cbkhare/Challenges
/CodeForces_630_C_LuckyNumbers.py
815
3.90625
4
if __name__=='__main__': n = int(input()) print (pow(2,(n+1))-2) ''' C. Lucky Numbers time limit per test 0.5 seconds memory limit per test 64 megabytes input standard input output standard output The numbers of all offices in the new building of the Tax Office of IT City will have lucky numbers. Lucky nu...
16492b258148861a868d43aa1f98e595545dd460
lcqbit11/algorithms
/hot100/021-合并两个有序链表.py
913
4.1875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from utils.listNode import ListNode, show_list_node, generate_node_list ## # 将两个升序链表合并为一个新的 升序 链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。 # def mergeTwoLists(list1, list2): if not list1: return list2 if not list2: return list1 p = list1 q = list2 ...
c3e28db7c652ade37104dcd1556dcfab15258a6e
baolibin/leetcode
/排序/350. 两个数组的交集 II.py
1,383
3.84375
4
# coding:utf-8 ''' 350. 两个数组的交集 II 给定两个数组,编写一个函数来计算它们的交集。 示例 1: 输入:nums1 = [1,2,2,1], nums2 = [2,2] 输出:[2,2] 示例 2: 输入:nums1 = [4,9,5], nums2 = [9,4,9,8,4] 输出:[4,9] 说明: 输出结果中每个元素出现的次数,应与元素在两个数组中出现次数的最小值一致。 我们可以不考虑输出结果的顺序。 ''' class Solution: def intersect(self, nums1: List[int], nums2: List[int]) -> List[int]: ...
d7602576d78e1407310cbe40cf04a9b04868d8dc
Andromalios/practicepython.org
/2.OddOrEven.py
1,291
4.4375
4
# Practicepython.org Exercise 2 - Odd or Even # Ask the user for a number. #Depending on whether the number is even or odd, print out an appropriate message to the user. #Hint: how does an even / odd number react differently when divided by 2? # Extras: # 1.If the number is a multiple of 4, print out a diffe...
bf0c956e493db875480693ce060f812b4b0e833f
harshitpoddar09/InterviewBit-Solutions
/Programming/Graph Data Structure & Algorithms/Bfs/Level Order.py
703
3.84375
4
# Definition for a binary tree node # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: # @param A : root node of tree # @return a list of list of integers def levelOrder(self, root): ans=[] i...
7071e58c329cb04788aad333d8956f9e6aa19d9a
sqrvrtx/AoC2015
/day2/day2.py
1,006
3.703125
4
#!/usr/bin/env python3 def calculate_paper(instruction): l, w, h = tuple(map(int, instruction.split('x'))) x, y, _ = sorted([l, w, h]) return (2 * l * w) + (2 * w * h) + (2 * h * l) + (x * y) def calculate_ribbon(instruction): l, w, h = tuple(map(int, instruction.split('x'))) x, y, _ = sorted([...
86259fc276a79039291d8496bfc8606f90b65566
MrPoldi/JFZ
/A02.py
404
3.65625
4
import sys def contains_pies(string): string = string.lower() if string.startswith("pies "): return True elif string.endswith(" pies"): return True elif " pies " in string: return True elif string.rstrip("\n") == "pies": return True else: return False ...
71303d922b574eacbc781147f926a4c62dcf14c2
rajasekaran36/GE8151-PSPP-2020-Examples
/unit4/insertion-sort.py
214
3.734375
4
numbers = [6,7,3,1,5,2,4] for i in range(1,len(numbers)): key = numbers[i] j = i - 1 while(j>=0 and key<numbers[j]): numbers[j+1] = numbers[j] j=j-1 numbers[j+1]=key print(numbers)
525111bdc2b7033702760968eb129671d3e071ec
bpham0313/cecs-451-ai
/n-queens/hill_climb.py
1,612
3.546875
4
from board import Board import copy import numpy as np class Hill_Climb: def __init__(self): self.no_steps = 0 def solve_board(self, board): best_board = Board(len(board.get_map())) q_list = [board.find_q()[k][1] for k in range(len(board.get_map()))] best_board.set_q...
8a289e0494e13853a4d4a89e53d338fb7d2ff76e
frcteam1502/inverse-kinematics
/Main.py
2,555
3.578125
4
import math import pygame SCREEN_HEIGHT = 700 SCREEN_WIDTH = 700 BLACK = (0, 0, 0) WHITE = (255, 255, 255) BLUE = (50, 175, 255) STARTING_LOCATION = (350, 350) ORIGIN = (0, 0) LEG1_LENGTH = 200 LEG2_LENGTH = 100 pygame.init() screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) pygame.display.set_caption(...
5c100d6294ea9402942639ae5f5d2fe5ac0b7eb4
snehaagupta/pycodes
/reverselist.py
100
4.09375
4
def reverse(list): l=list[::-1] return l list=[1,2,3,4,5] print(reverse(list))
9537fb12cc5355fd4b37bc0c9289e560bd7e46d3
YehEmily/FinalProject
/final.py
15,304
3.5
4
"""Emily Yeh and Lydia Zuehsow""" """This program allows a person to wave a green "wand" to cast spells, Harry Potter-style!""" """For future reference, here's a link to our Google doc: https://docs.google.com/document/d/1daGjz8CWycfev0Fs96ru-Na5JNtqs2nVE1fHZ1ydhX0/edit?usp=sharing""" # ****************** IMPORTED S...
5d2f3a6fe9df34d9f47203ac9ff3f36858faca73
fucky850112/01
/python/exercise/weather.py
2,815
3.6875
4
#!/usr/bin/env python # # Kristopher Newsome # krisnewsome@gmail.com # # 20130912 # # This will display current weather conditions for a zip code. # There are a lot of free weather APIs. I just happen to pick worldweatheronline.com. import urllib2 import json import cPickle as pickle import os, sys, time # I chose no...
ea9bc49367b4ddb99da321959cc9d3ccd9570062
krish0031/Python-101
/practice 2.0/Most Common Words.py
878
4.21875
4
# to print out ten most common words # count the number of occurances for each word # sort them in descending order # print the first 10 sorted elements in the resulting list fhand = open('romeo.txt') data = fhand.read() #print(data) data = data.split() #print(data) d = dict() # if word is in the dictionary add 1 to t...
7b1bd409b67852db7b8f4c9bbd9301d73321b0cc
sgzwiz/brython
/tests/test_strings.py
1,086
3.71875
4
# strings log('spam eggs') log('doesn\'t') log("doesn't") log('"Yes," he said.') log("\"Yes,\" he said.") log('"Isn\'t," she said.') hello = "This is a rather long string containing\n\ several lines of text just as you would do in C.\n\ Note that whitespace at the beginning of the line is\ significant." log(hello)...
807134da0d6fdd0402bd999b451526bb858dc77c
Vladislav124382423/Study
/31.py
123
3.828125
4
a = int ( input ("enter first number:")) a = int(a * 4 * a) b = int(a * 4 * a) c = int(a * 2) print("Result is", a, b, c)
0eae8d5c023bccffafbf7818d345897b028a15d2
isabelcoboruizazuaga/AgendaContactos
/main.py
5,443
3.765625
4
import tkinter from builtins import list from tkinter import * import pickle ''' Elemento Contacto (Clase) ''' class Contacto(): def __init__(self, nombre, apellidos, telefono): self.nombre=nombre self.apellidos=apellidos self.telefono=telefono def print(self): ...
67e8eda36c208d5927799c1290cac6d625cf1050
Lokeshyadav2398/assign-of-files-and-strings
/numofwords.py
141
3.75
4
count=0 fd=open("words.txt","r") for line in fd: words=line.split() count=count+len(words) print("number of words:",count) fd.close()
f3d82d22b03ddf8aa962931034dc6f855d3f631a
MicroFish91/DigitalCrafts2
/Python/tictactoe.py
901
4.28125
4
SIZE = 3 board = [] # Start with an empty List for y in range(SIZE): # Each element in the board will also be a List board.append([]) for x in range(SIZE): # Fill our inner Lists with the coordinates board[y].append("[%d][%d]" % (y, x)) # Print the board as a grid for row in board: ...
507d4b7d953d89e9d40934535f56d1419658b228
nabaz/python-experiments
/year_you_trun_100.py
1,245
4.25
4
import time import datetime class YearToTurnHundred: """Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old. Extras: - Add on to the previous program by asking the user for another number...
87fd59b63e03da8a5281d5f3c2eb8f828c0bcb95
mousters/Finmath_Python1
/Python Lecture Code/THE BASICS/value_present_in_tree.py
327
4.0625
4
def isPresent (root,val): # write your code here # return 1 or 0 depending on whether the element is present in the tree or not cur = root while cur: if cur.value == val: return 1 elif cur.value < val: cur = cur.right else: cur = cur.left r...
35720ff21ac78d83973c32960f1048111541ed7d
lcc728/python
/magicBall.py
1,370
3.78125
4
# Magic Ball #https://www.george.tw/2020/05/01/python-dict-magic-8-ball/ import random # https://zh.wikipedia.org/wiki/神奇八號球 magicMap={ 1:'It is certain (這是必然)', 2:'It is decidedly so (肯定是的)', 3:'Without a doubt (不用懷疑)', 4:'Yes, definitely (毫無疑問)', 5:'You may rely on it (你能依靠它)', ...
1c3be539c5e6a1756054b69f2c0028f7c99587ca
Luolingwei/LeetCode
/TwoPointers/Q611_Valid Triangle Number.py
1,270
3.71875
4
class Solution: #solution1 dfs # def triangle(self, path): # if path[0] + path[1] > path[2] and abs(path[0] - path[1]) < path[2]: # return True # else: # return False # def dfs(self, nums, start, path, res): # if len(path) == 3: # if self.triangle(...
ad9015a7728e3f0cb374369106691ecd4493690d
Zakaria9494/python
/learn/boolean.py
288
3.65625
4
the_world_is_flat = False if the_world_is_flat: print("be careful not to fall off!") else: print("dont be careful!") # Fibonacci series: # the sum of two elements defines the next # the sum of two elements defines the next a, b = 0, 1 while a < 10: print(a) a, b = b, a+b
6c17eb89e3368d046c1add2a1b780c83d6a03a87
roni-kemp/python_programming_curricula
/CS3/0700_car_driving_neural_net_evolutionary/draft14/car.py
5,990
3.671875
4
import pygame, math, line_segment #Whether or not to draw sensor lines display_sensors = True #Getting this close to a wall signifies a crash crash_limit = 7 #Max speed of all cars in pixels per frame speed_max = 5 #Acceleration as a percentage of max speed per frame acceleration = 0.004 #How far vision senses extend ...
7d666187c3546c4589ad20ceafc9150adb8f996f
gowthambittu/python-learning
/list_gen.py
928
3.984375
4
#MAIN SOLUTION: import math """ Converts Decimal to Binary. """ def decimalToBinary(n, places): return bin(n)[2:].zfill(places) """ Generator function that yields subset of the set of integers between 0 and n-1. Input: size of the set we compute the subset of. Output: Iterator of the subset. Returns list of ...
bf3d5192944a5b7899900c28ee98ec72971c3c31
adityamonga/Leetcode
/maxsubarray.py
505
3.515625
4
class Solution: def maxSubArray(self, nums) -> int: max_till_here = nums[0] max_all_time = nums[0] for i in range(1, len(nums)): max_till_here = max(nums[i], nums[i]+max_till_here) max_all_time = max(max_all_time, max_till_here) return max_all_time if __name...
9324b9ff23d1479946879d4311b6de66a420e79f
harisovaO/documents
/4week/cutTheFraction.py
215
3.65625
4
n, m = int(input()), int(input()) def ReduceFraction(n, m): nod = m % n if nod == 0: return n else: return ReduceFraction(nod, n) nod = ReduceFraction(n, m) print(n // nod, m // nod)
950582c87c44b39e5d2dd5b01c547b8d8d69d6f5
camilariquelme/pythontalentodigital2020
/CODINGDOJO/7.-PYTHON/3.- PYTHON OPP/BankAccount.py
1,247
3.6875
4
class BankAccount: def __init__(self, account_number, balance, tasa_interes): self.account_number = account_number self.balance = balance self.tasa_interes = tasa_interes def deposit(self, amount): self.balance+= amount return self def withdraw(self, amoun...
e608b9f6280cda59944531cccda5b34484fa1d0b
kaixiang1992/python-review
/stage1/decorator_demo/demo5.py
2,056
3.609375
4
""" 2019/11/27 20:54 123.【Python装饰器】装饰器实现Flask的url映射 """ # TODO: 装饰器实现Flask的url映射 """ 装饰器模拟实现Flask的Url映射 """ from functools import wraps USER = { 'is_login': True } # TODO: 登录拦截装饰器 def login_required(func): @wraps(func) def wrapper(*args, **kwargs): if USER.get('is_login'): func(*arg...
f01d294c975d42b418578cbcb9957b3bea18e6c7
SoumenNath/Python-Theatre
/SoumenNath_movieSystem.py
10,965
4.03125
4
""" Soumen Nath ICS4U SoumenNath_movieSystem.py Description: The program allows customers to purchase tickets to view available movies at The ByTowne Cinema. The customers are allowed to select a movie and a date to view the movie. They can then select the type and number of tickets to purchase, along with reserv...
4f7d022ee71338fc1bc6b261836f063338ef222b
OScott19/TheMulQuaBio
/code/temperatures.py
768
4.28125
4
import re ## Goal: find the average temperature ## in January for all the cities in ## Data/AvgTemperature # The records look like: # 1 1 1995 58.3\r\n <- used for new line # First: build a regular expression that # extracts the day, year and average temperature myreg = re.compile(...
07fdcee2180cea409931386feee23e265e6fd88f
heangly/AlgoExpert-Problem-Solutions
/solutions-in-python/14. Caesar Cipher Encryptor.py
1,407
4.125
4
""" Casesar Cipher Encryptor Given a non-empty of lowercase letters and a non-negative integer representing a key, write a function that return a new string obtained by shifting every letter in the input string by k position in the alphabet, where k is the key. Note that letters should "wrap" around the alphabet; in ...
124d7fd5785c40b359d850b751a26ec651f51366
GabrielRCAmaral/Brincando-de-Python
/URI/1017.py
93
3.71875
4
# -*- coding: utf-8 -*- h=int(input()) v=int(input()) consumo=h*v/12.0 print "%.3f" %consumo
0048e8d1d35a703aefac026778cc7701ec8a5438
kmust-why/Python
/project/python-记事本/notepad.py
1,798
3.5625
4
from tkinter import * import tkinter.filedialog def newfile(): txt = text.get(1.0,END) if not txt: return savefile() #print('new') def openfile(): filename = tkinter.filedialog.askopenfilename(title='打开文档',filetypes=[('文本文档', '*.txt'), ('python文件', '*.py')]) if not filename: ...
65e6dc004d5c27891c63d4c639c66a99f684f5cb
fglshm/ms-research-src
/python/word_count/analyze.py
3,040
3.828125
4
""" 文の単語数に着目した前後の文の類似度の分析 1. 変化の度合いが大きい文のペアはスピーチのどこで出現するか. """ import numpy as np import matplotlib.pyplot as plt class Data: """ 単語数に基づく文の前後の文の類似度データを保持するクラス """ def __init__(self, speech_type): self.similarities = self.load_similarities(speech_type) def load_similarities(s...
a975909e8ba392224a3428517a733750d144bb36
BrendanOssebaar/f1m1PYT
/Stel_vragen.py
533
3.984375
4
print("Hey you, what's your name?") a = input() print("alright, hi " + a) print("How old are you?") b =int(input()) print("Nice, you are " + str(b) + " years old") if b < 24: print("You are younger than me!") elif b > 24: print("You are older than me!") elif b == 24: print("You are just as old as me!") p...
3efc0fc73ac41af9ac77e905c7cf68b82a71a2d5
brayan-mendoza/ejercicios_examen
/L-2.py
357
4.21875
4
# utlizando ciclos (loops) dinujar un triangulo de asteriscos def triangulo(altura): for numero_linea in range(altura): espacios = altura - numero_linea - 1 print("", espacios) asteriscos = 1 + numero_linea * 2 print (" " * espacios + "*" * asteriscos) alt = int(input("int...
a13f56b16fabdf3041bf7586c441ce0d40194a05
delroy2826/Programs_MasterBranch
/GoogleInterviewQ1.py
1,412
3.59375
4
#Providing Perfect change for the given amount a=True while a: amount = int(input("Enter the Amount: ")) temp_amount = amount coin_in_account = sorted([1,2,5,10,20],reverse = True) count= 0 coin_count=1 index = 0 while True: try: if coin_in_account[index]<=temp_amount: ...
3e1caa73062d3cf7b541a06d66776a0599f070c6
rustydigg918/Fun
/LOST_CHELLANGES/adding_the_numbers.py
429
3.828125
4
"""Question: GET THE RECURSIVE SUM OF DIGITS INTO ONE DIGITS i/p- 14432, 987, 3345,2 o/p- 5, 6, 6, 2 """ """MY SOLUTION def digital_root(n): _tokens = [int(i) for i in str(n)] _sum = sum(_tokens) if len(str(_sum)) > 1: _sum = digital_root(_sum) return _sum ...
0812e3b1e8a1db0c7da9778e94d2f4942356d02a
civart2/dataprocessing
/Homework/Week3/convertCSV2JSON.py
930
4.0625
4
#!/usr/bin/python3 #made by Civio Arts import csv import json def main(): # asks user the file location to convert input_location = input("Read location:") # asks user where the save the converted file output_location = input("Write location:") # declare jsonlist for json objects jsonlist = ...
cd8a09b6d4d478c3e6a282052faff63dfb5fd207
adcneto/PythonCode
/scripts/VerificaNumerosViznhos.py
979
4.09375
4
#Este programa verifica se há em um número (representado em base 10) dois dígitos adjacentes iguais PrimeiroDigitoZero = True while PrimeiroDigitoZero: num = input("Entre com um número inteiro que não comece com '0': ") if int(num)/(10**(len(num)-1)) < 1: PrimeiroDigitoZero = True else: ...
5f023a3d1403b0162b7f5cecaa61803e726154cb
focardi-francois-philippe/Atelier4
/ex4.py
2,545
3.5
4
import re def mot_correspondant (mot:str,motif:str)->bool: """[summary] verifie si un motif et present dans mot Args: mot (str):mot fournit motif (str): motif peux contenir des jokers (.) Returns: bool: True si motif present False sinon """ correspond = False if(re.mat...
a287d66264d1e83042f073eed659d70e2212969d
madhav06/Python_to_Access_WebData
/Week2/Regex_nonblank_chars.py
266
3.609375
4
#python 3 import re hand = open('mbox-short.txt') for line in hand: line = line.rstrip() if re.search('^X-\S+:', line): print(line) #comments: ''' ^ - match the start of the line. \S - Match any non-whitespace character + - one or more times '''
9ee60a4d3bc8c6f82bd855639863d55505c49e29
mikaav/Learn-Python
/Begin8.py
169
3.5625
4
# Даны два числа a и b. Найти их среднее арифметическое: (a + b)/2 a = int(input()) b = int(input()) s = (a + b) // 2 print(s)
4c4fbfbc74266064225d50abbe4afc533ec509a3
a-angeliev/Python-Fundamentals-SoftUni
/Final Exam Retake 10.04.2020/01. Secret Chat.py
739
3.953125
4
text = input() data = input().split(":|:") while not data[0] == "Reveal": if data[0] == 'InsertSpace': index = int(data[1]) new_text = text[:index]+" "+text[index:] text = new_text print(text) if data[0] == "Reverse": substring = data[1] if substring in text: ...
fc4d7d467c1ea510a6276db94faf71a09732a1eb
east4ming/pyEdu
/XunlianYing/day01/print_star.py
82
3.640625
4
print('*' * 10) for i in range(2): print('*' + ' ' * 8 + '*') print('*' * 10)
7d609a8e7d347d962e04940d95532069c46e854d
Shaunwei/LeetCodePy
/lintcode/BinaryTree_DivideConquer/binary_tree_level_order_traversal.py
2,155
3.984375
4
""" Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ class Solution: """ @param root: The root of binary tree. @return: Level order in a list of lists of integers """ def levelOrder(self, root): # one...
01d18115d7c991ee0db427d0b408cb8f38fcc108
HoangAce/ExerciseCodeforcer
/1405A.py
294
3.578125
4
def main(): answers = [] t = int(input()) for i in range(t): n = int(input()) p = list(map(int, input().split())) p.reverse() answers.append(p) for answer in answers: print(" ".join(map(str, answer))) if __name__ == '__main__': main()
2786d5a4d567beca97e878ddd0e4fd5f25daae20
SantaC0103/Traffic_model_ver
/main_phase_2.1_ver.py
8,985
3.796875
4
import numpy as np import pandas as pd import time import matplotlib.pyplot as plt ACCELERATION_UP = 3 ACCELERATION_DOWN = -6 # Maximum speed of 30m/s, consider as 100km/h in real life MAX_SPEED = 30 MAX_DISTANCE = 50 TRAFFIC_LIGHTS_SWITCH_TIME = 60 ROUTE_LENGTH = 2000 CROSSOVER_POSITION = 1000 # Driv...
4d30e0c1cdce537b5ce17a8a2e528050b7f47a02
cheba4ok/python_for_everybody
/assignments_chapter1-10/ex8_6.py
289
4.15625
4
num_list = list() while True: num = input('Enter a number : ') try: num = float(num) except: if num == 'done': break print('Not a valid number!!') continue num_list.append(num) print('Maximum :', max(num_list), '\nMinimum :', min(num_list))
ad4a8902640312de9818ec52affb7569506f2918
MichalSl/Python_exercises
/coin_toss.py
373
4.09375
4
import random def coinToss(): number = int(input("How many coin tosses? ")) heads = 0 tails = 0 toss = 0 for x in range(number): toss = random.randint(0,1) if toss == 0: heads += 1 else: tails += 1 print("Heads: {}"...
99872279aa8ac8dc633f8d3e7b9a51bb1767c6f8
beytullahoglu/AutonomousRCCar
/HumanDrive.py
4,875
3.640625
4
# Author: Buğra Beytullahoğlu, https://github.com/beytullahoglu # I could not be able to finish this project without help of: # Autonomous RC Car by hamuchiwa, https://github.com/hamuchiwa/AutoRCCar # https://machinelearningmastery.com/tutorial-first-neural-network-python-keras/ # This Code will be used to collect use...
b72c1b2fc9504b679749b2815aa412f89132ca87
bsextion/CodingPractice_Py
/Misc/Data Structures/LinkedList/search.py
1,305
3.84375
4
#REVIEW class LinkedList: def __init__(self, node=None): self.head = Node(node) def append(self, data): new_node = Node(data) if self.head is None: self.head = new_node return else: last_node = self.head while last_node.next: ...
5f5432e183ea6e7d09092e75d83b79479c5738ed
sunitakunwar/test_feb_19
/q2.py
497
3.96875
4
'''Create a class Circle which has a class variable PI with value=22/7. Make two methods getArea and getCircumference inside this Circle class. Which when invoked returns area and circumference of each ciecle instances.''' class Circle: PI = 22/7 def __init__(self,radius): self.radius = radius def getArea(self...
481bc24a09c4f571afefae34a237b63aec54b089
fahmida185/Datacamp-
/SciNet CNN/Intro To Machine Learning/crossvalidation.py
2,974
3.53125
4
# # Compute Ontario Summer School # Machine Learning in Python # 13 June 2018 # Erik Spence # # This file, crossvalidation.py, contains functions which run # crossvalidation on a polynomial fit to some noisy data. The # functions plot the best result and save the figure. # # This code was stolen, almost wholesale, fro...
1839d1fe23224f82dcaaa6596196a035a6908d01
robbertbloem/robbertbloem.github.io
/python/011_line_properties_linestyle.py
890
3.71875
4
""" LINE STYLES By default, Matplotlib makes solid lines. Manually, this can be set using 'linestyle' or 'ls' and one the options listed below. linestyle description '-' solid '--' dashed, use 'dashes = (on, off)' to change the gaps '-.' dash_dot ':' dotted 'None' draw nothing ' ' draw...
6ad916a706c684d061a58a1466feaff07afd6c89
mpreath/aicrashcourse
/chapter5.py
3,410
3.75
4
# Thompson Sampling Introduction from scipy.stats import beta import numpy as np import matplotlib.pyplot as plt # predefined win rates for each slot machine (AI model is unaware of these) conversion_rates = [0.10, 0.14, 0.05, 0.08, 0.12] reward_values = [1, 1, 1, 1, 1] N = 5000 # number of samples...
1deac2b9fa0ac90515c78baea19334b3c6dd5f09
anlaganlag/Processing
/畫sin.pyde
1,021
3.6875
4
r1= 100 # 在畫面左邊的大圓 r2= 10 #在大圓的紅色點,相當於一個mark點 t =0 #時間等於開始 circleList = [] #用於存儲高度的歷史數據,即高度y def setup(): size(600,600) #大爲600的屏幕 def draw(): global t,circleList background(200)#背景色0是黑色 255是白色 #所以這裏是灰白 translate(width/4,height/2) #畫面靠左邊的位置 noFill() #大圓不需要填充 stroke(0...
d660580896da391257adbbd9ea71a74e8f8c9a8b
43reyerhrstj/DataStructures_Stacks_Queues_Dequeues
/stack_using_python_list.py
608
3.671875
4
class StackEmpty(Exception): pass class StackUsingList: def __init__(self): self.data = [] def __len__(self): return len(self.data) def isEmpty(self): return len(self.data) == 0 def push(self,value): self.data.append(value) def top(self): if n...
6f84adff9ca49aeac6e96d5fd46454c48a3e64fc
abdulazizkomilov/turtle
/18-lesson.py
929
3.734375
4
#print(" Sizga kerak mahsulotlar ro'yxatini tuzing. \n") #mahsulotlar = [] #ask = True #n = 1 #while ask: # mahsulot = input(f" {n} mahsulot nomini kiriting: ") # mahsulotlar.append(mahsulot.capitalize()) # print(f" Mahsulotlar ro'yxati {mahsulotlar}") # quit = input(' Davom etish uchun "again" deb yozing yoki tug...
8fba3336bbd9b4479174341cfa2021428c34933e
angry-Johanna/Fruechtekorb-Zirkus
/Zirkus.py
1,076
3.515625
4
#!/usr/bin/env python from Figur import * import random class Zirkus: zirkustruppe=[] kunststuecke=["den Handstand *macht Handstand*","das Rad schlagen *schlägt ein Rad*","den Rückwärtssalto *macht einen Rückwärtssalto*","den Affen machen *Ugha Ugha","Feuer spucken *spuckt Feuer*","Schwerter schlucken ...
6d55583041b7faa841c0d3705a4616c8f0061255
arunkuttiyara/python
/tut_point/for_loop.py
157
3.875
4
#!/usr/bin/python for letter in 'Python': print letter print letter fruits = ['apple','mango','banana']; for fruit in fruits: print fruit
a2accabb21b1ca9a7aa04579a52d0a28889b7514
anuragmukherjee2001/Python_codes
/NPTEL codes/nptel14.py
194
3.71875
4
def find(list1,num): for each in list1: if(each!=num): print(each) else: break t = [] for i in range(30): t.append(i) find(t,29)
9536afe317b11ca9fe262fe3b06f5ffdd1a2b391
poorvijajodiya/Tkinter
/Radio_Button.py
784
3.765625
4
from tkinter import * root = Tk() #r=IntVar() #r.set("2") Modes = [("Pepperoni","Pepperoni"),("Onion","Onion"),("Cheese","Cheese"),("mashroom","mashroom")] pizza = StringVar() pizza.set("Pepperoni") for text,mode in Modes: Radiobutton(root,text=text,variable=pizza, value=mode).pack(anchor=W) def clicked(va...
3118ef4ad44925271c411274686d23fde622b76c
Richiewong07/Python-Exercises
/file_and_exceptions/practice/addition_calculator.py
558
4.21875
4
# Write a while loop so the user can continue entering numbers even if they make a mistake and enter text instead of a number. print("Enter 'q' at anytime to quit: ") while True: try: x = input("Enter a number: ") if x == 'q': break x = int(x) y = input("Enter another...
1740cbe9ed39466a7d83f2e64647c1a320c40da2
DJTakushi/heisig
/heisig.py
2,514
3.625
4
#Accepts kanji text string #Outputs heisig string #heisig word in place of each kanji, separated by a space #if no heisig found, kana #!/usr/bin/env python # -*- coding: utf-8 -*- import sys import os try: # for Python2 from Tkinter import * ## notice capitalized T in Tkinter except ImportError: # fo...
a214e2c0c31c5b98701de8226be7557396d03b2e
dennisausbremen/tunefish
/server/models/simple_math.py
407
3.5625
4
def average(list): if len(list) == 0: return 0.0 else: return round(sum([x.vote for x in list]) / float(len(list)), 2) def variance(list): if len(list) == 0: return 0.0 else: variance_val = 0 average_val = average(list) for i in list: varianc...
c935c8027ecdd76a6d512dc6730f8d42b7ed345c
tusharchamoli/project123
/ex24.py
842
3.984375
4
print("You\'d wonder what \\ this\'ll do") print("\n new lines and \t tabs") poem=""" \tThe lovely world with logic so firmly planted cannot discern \n the needs of love nor comprehend passion from intuition and requires an explanation \n\t\twhere there is none. """ print("--------------------...
ae14f1f5968e6a93895679dff16da797f47651a0
SHSBStudentRobotics/SRProject2018
/action.py
434
3.796875
4
#Type is either "move", "stop" or "turn". class Action: def __init__(self,newType,angle,dist = 0): self.type = newType self.angle = clampAngle(angle) self.dist = dist def changeType(self,newType): self.type = newType return self def clampAngle(angle): if angle > 18...
3b76875ec54479b956a45331c3863f956a61df9a
mounui/python
/examples/use_super.py
643
4.125
4
# -*- coding: utf-8 -*- # super使用 避免基类多次调用 class Base(object): def __init__(self): print("enter Base") print("leave Base") class A(Base): def __init__(self): print("enter A") super(A, self).__init__() print("leave A") class B(Base): def __init__(self): prin...
4999e8a910e04248f5b340292c5856d599068f30
jwodder/euler
/euler0009.py
857
4.125
4
#!/usr/bin/python """Special Pythagorean triplet A Pythagorean triplet is a set of three natural numbers, $a<b<c$, for which, $$a^2 + b^2 = c^2$$ For example, $3^2 + 4^2 = 9 + 16 = 25 = 5^2$. There exists exactly one Pythagorean triplet for which $a + b + c = 1000$. Find the product $abc$.""" # Ass...
86f17fbd1e5dbd0842d74335b82e9a990a0df40e
aligerami/assignment2
/chapter13-2.py
418
3.765625
4
def main(): file_name=input("enter file name : ") ifile=open(file_name,"r") line_number=0 char_number=0 word_number=0 for line in ifile: line_number=1+line_number char_number=char_number+len(line) word_number=word_number+ len(line.split(" ")) print(char_number, "...
634fba8263892e8e48d35837b84eef20cfc67014
hugsy/cemu
/cemu/os.py
575
3.578125
4
from dataclasses import dataclass from typing import Union @dataclass class OperatingSystem: name: str def __str__(self): return self.name def __fspath__(self): return str(self).lower() def __eq__(self, __value: Union[str, "OperatingSystem"]) -> bool: if isinstance(__value, ...
64e036d362f7abec7b1194bd7d3225a712e1c00e
baites/pyds
/pyds/PriorityQueue.py
3,298
4.125
4
"""Implement a pure python priority queue""" from collections.abc import Container, Sized from pyds.exception import EmptyQueue class Item: """Implement an queue item.""" def __init__(self, priority, value, key): self.priority = priority self.value = value self.key = key """Sorti...
2baf68988fd821345b08342d53a4d9ce106ad8dc
daniel-reich/ubiquitous-fiesta
/c9i3mdjuwwzMF3Por_10.py
427
3.65625
4
def bemirp(n): if not is_prime(n): return 'C' if not is_prime(flip(n)) or flip(n) == n: return 'P' if not is_prime(up_down(n)): return 'E' return 'B' def flip(n): return int(str(n)[::-1]) ​ def up_down(n): dic = {'0': '0', '1': '1', '6': '9', '8': '8', '9': '6'} return int(''.join(dic.get(d, 'False') ...
78c1d61c3b4c1889b3be5a6153c892f1a909e04f
pranayrao/Fun-with-Python
/XO.py
2,224
3.84375
4
board = [' ']*10 gameState=True message = '' def clear_board(): global board,gameState board = [' ']*10 gameState=True def printBoard(): print " "+board[7]+" | "+board[8]+" | "+board[9]+" " print "------------" print " "+board[4]+" | "+board[5]+" | "+board[6]+" " print "------------" p...