blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
8443922b7622f77d7fc914c64ebe5a0bd248de3a
pcsazro/python
/test02/mega/big07.py
1,066
3.671875
4
data = input("당신의 나이를 입력 ") # 나이가 100세 이상이면, 어른이시군요! # 나이가 100세 미만이면, 어른이 아니시군요! # 숫자로 변환할 필요가 있다. age = int(data) # 조건문(비교연산자)의 결과는 True/False if age >= 100 : #콜론(:) print('어른이시군요!') # 조건문의 결과가 True else: print('어른이 아니시군요!') # 조건문의 결과가 False # >(초과), >=(이상), ==(동일), !=(다름) <-!는 not의 의미 ...
4245d3badf49e697dbee8d52382c5eb828fde387
pcsazro/python
/test02/movie/price.py
699
3.828125
4
# movie 패키지를 만드세요. # price.py 모듈을 만드세요. # info 함수 정의 # 처리 내용은 같이 볼 사람 이름, 관계(ex.친구) 입력 # 볼 사람 정보 (이름, 관계) 출력 #pay 함수 정의 # price = 10000 # 인원수 입력 #지불할 금액 출력 def info(): name = input("이름 ") rel = input("관계 ") print(name, rel) #강사님께서 한번에 입력하는 것으로...
a9542064149dba8577841cf3e82f2869e498999a
pcsazro/python
/test02/mega/big12.py
361
3.640625
4
# 원래 가입한 아이디는 root임. # 로그인할 id를 입력 >> root # 로그인 되었습니다. # 로그인할 id를 입력 >> root1 # 로그인 되지 않았습니다. id = str("root") ida = input("로그인할 id를 입력: ") if ida == id: print("로그인 되었습니다.") else: print("로그인 되지 않았습니다.")
c95fb7ec011de928a1c0e0df30ddcec7b922890e
cngonzalez/plotto-game
/main.py
1,357
3.703125
4
import click from plotto_gen import PlottoGen __author__ = "Carolina Gonzalez" plotto = PlottoGen() # @click.group() # def main(): # """ # Simple CLI for illustrating a very basic story generation strategy # """ # pass @click.command() # @click.argument('feeling') def start(): click.echo("GAME ST...
4951b456e74f38676adef269bc8a0c0a9d355743
keithxm23/CTCI
/Ch3_Stacks_and_Queues/q3_5.py
593
3.96875
4
#implement queue using two stacks from stacks import Stack class Queue(): def __init__(self): self.base = Stack() self.buff = Stack() #insertion in O(n) def enqueue(self, data): while(True): try: self.buff.push(self.base.pop().data) except: self.base.push(data) while(True): try: ...
336aec1946d93091219b2e2c2e85d4d51fbbe585
keithxm23/CTCI
/Ch1_Arrays_and_Strings/q1_4.py
425
3.75
4
#replace all spaces in a string with %20 str = raw_input("Enter an string: \n") spacecount = str.count(" ") str = list(str) strlen = len(str) for i in xrange(0,spacecount*2): str.append("") print str index = len(str)-1 for j in xrange(strlen-1,-1,-1): print str[j] if str[j] == " ": str[index] = "0" str[index...
f41029b9dbb2b6a6ad577074731a46fb6def9663
xuqing-ict/BackupCode
/Python/course/hello.py
1,314
3.546875
4
#!/usr/bin/env python # -*- coding : utf-8 -*- #both ok __doc__ = 'my first python' 'my first python ' __anthor__ = "QingXU" import sys try: import cStringIO as StringIO except ImportError: #catch a ImportError exception import StringIO class Hello(object): def hello(self,name = 'world'): ...
e97c48cc1b0d0b460adc1f4078ce925e720c8f5b
xuqing-ict/BackupCode
/Python/traverse.py
300
3.796875
4
#!/usr/bin/python #a = [1,2,3,4,5] def traverse1(a): print "traverse 1\n" for i in range(len(a)): print str(i) + "\t" + str(a[i]) + "\n" def traverse2(a): print "traverse 2\n" for index,item in enumerate(a): print str(index) + "\t" + str(item) + "\n" return #traverse1(a) #traverse2(a)
454c24380fa8502c6341892cd62d9de82df00841
BilanHalya/Python
/Lab_7.py
929
3.625
4
import random n=10 day=[random.randint(1,31) for i in range(0,10)] month=[random.randint(1,12) for i in range(0,10)] year=[1930 for i in range (0,10)] xy=zip(day,month,year) xy=list(xy) print(xy) L=[] for i in range(1, n+1): a='Date'+str(i) L.append(a) D={k:v for (k,v) in zip(L,xy)} print('Наші дати:') ...
187b3f7fc5a6cbb3a8897518455b3bc79fe76c82
BilanHalya/Python
/Lab_8_2.py
502
3.796875
4
from math import* def calculate(*n): multie=1 print('Наші параметри наступні:') for i in range(len(n)): print(n[i]) if pow(2,i-1)<n[i]<pow(2,i+1): d = 0 else: d = 1 if d == 0: print('Наш результат = 0') else: for i in range...
12fce4f7ce9ea15815d7a60c862d8d9ea1e70fcc
daviuezono/mc920
/projeto/teste/ffmpeg.py
2,299
3.53125
4
#!/usr/bin/python # -*- coding: utf-8 -*- import re import subprocess from decimal import Decimal from os import system from sys import exit name = raw_input("Enter the movie filename (WITH file extension): ") # validate the movie filename (should not have any spaces or special chars). while not re.match("^[A-Za-z0-9...
7c201a3ac61dc15e1b190a957138b33041ad16d7
pablosq83/Pruebas3
/cuentapalabras.py
671
3.90625
4
#!usr/bin/python # -*- coding: utf -8 -*- """ Se va a definir una función que de una lista de n palabras, contabilice cuántas comienzan por un caracter dado. Autor: Pablo Sulbarán (psulbaran@cenditel.gob.ve) Fecha: 02-03-2018 """ n= int(raw_input("Introduzca el número de palabras ")) i=0 listap= [] for i in range(n)...
521861ef9fdf0f9c4a7faf2da552b9be179e9eab
pablosq83/Pruebas3
/mayor2.py
517
4.21875
4
#!usr/bin/python # -*- coding: utf -8 -*- #Primer programa en python """ Procedimiento que compara dos números reales y determina cual es el mayor Autor: Pablo Sulbarán (psulbaran@cenditel.gob.ve) Fecha: 27-02-2018 """ n1 = float(raw_input("Introduzca el primer numero ")) n2 = float(raw_input("Introduzca el segundo n...
e4a3823d9d030fc26c72fde0a153615ce13f0681
DracoNibilis/pands-problem-sheet
/secondstring.py
351
4.25
4
# Write a program that asks a user to input a string and outputs every second letter in reverse order. # Author: Magdalena Malik #input for text text = input("Please enter a sentence: ") reversed_text = text[::-1] # reversed given text every_second_letter = reversed_text[::2] # select every second letter from the re...
4528107b08a548f08f15c80a59674ffc1b01819f
AlexUrtubia/OOP_Python
/User/user.py
2,225
4
4
class User: # aqui está lo que tenemos hasta ahora def __init__(self, name): self.name = name self.saldo = 0 # agrega el método deposit #def make_deposit(self, amount): # toma un argumento que es el monto del depósito # self.account_balance += amount # la cuenta del usuario específi...
b0b9cbff9a87b480af27c3da60d181554bb50250
bradleyboehmke/python-jumpstart-course-demos
/apps/09_real_estate_analyzer/you_try/my_real_estate_app.py
1,628
3.703125
4
import pandas as pd def main(): print_header() df = load_data('SacramentoRealEstateTransactions2008.csv') most_extreme_home(df, extreme='max') most_extreme_home(df, extreme='min') average_house(df, beds=None) average_house(df, beds=2) def print_header(): print('------------------------')...
9bef3353465c6da5fdbe3e50e5446fbd3f14c908
anjumunothtrainingsl1/pythonDecCiti
/classesExample.py
2,974
4.125
4
#classes, objects, inheritance,abstraction,encapsulation,polymorphism, decorators class Shape: #class var - shared by all the objects; one copy for all the objects # #instance var -- for each and every obj exclusively ctr=10 # class var def __init__(self,s1,s2): #self - this - object on wh...
b257fe63388ec7a2a580c94ba5a1a8a04dd36d0d
anjumunothtrainingsl1/pythonDecCiti
/fileExample1.py
433
3.53125
4
# read ; write; append; # open; perform the op; close # open -- file; mode (r,w,x, a, t,b,r+ ); encoding -- utf-8 # close try: f=open("sample2.txt",mode="w",encoding="utf-8") f.write("This is the first line") f.write("\nThis is the second line") f.writelines(["This is the third line","\nThis i...
daa92299c004fc08fa5b500b26df5631f86959c2
nehamehta2110/100DaysOfCode
/Mathematics/factorialItr.py
190
4.125
4
def fact(number): """ Returns the factorial of a number """ f = 1 for i in range(2, number+1): f = f*i return f if __name__ == '__main__': print(fact(3))
d5cf9d262daffeff66b51debad9f730601394bbc
kellerwilt/Python_mess
/Geometry.py
1,104
3.921875
4
import string import math shape = raw_input().lower() if shape.split().count('hexagon'): sides = 6 if shape.split().count('pentagon'): sides = 5 if shape.split().count('decagon'): sides = 10 if shape.split().count('octagon'): sides = 8 if shape.split().count('infinityagon'): print "Shut up Thomas" e...
52364d740d3eb571c2ad32802e8cf3b91c193716
jhinkoo331/leetcode
/solution/0414____Third Maximum Number.py
542
3.84375
4
from typing import List class Solution: def thirdMax(self, nums: List[int]) -> int: return self._1(nums) def _1(self, nums): """ *perf 85, 69 """ a, b, c = [float('-inf')] * 3 for i in nums: if i > a: a, b, c = i, a, b elif i == a: pass elif i > b: b, c = i, b elif i == b: pa...
214b2303caa3e025a517cb414bf7e8c74db90da8
jhinkoo331/leetcode
/solution/0515____Find Largest Value in Each Tree Row.py
1,143
3.875
4
# Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right from queue import Queue from typing import List class Solution: def largestValues(self, root: TreeNode) -> List[int]: return self._1(root) def _1(self,...
35e018591b01b13a8091daecdb6b5eed597d27f9
joshsizer/free_code_camp
/algorithms/inventory_update/inventory_update.py
1,622
3.953125
4
""" Created on Sun Apr 25 2021 Copyright (c) 2021 - Joshua Sizer This code is licensed under MIT license (see LICENSE for details) """ def inventory_update(arr1, arr2): """Add the inventory from arr2 to arr1. If an item exists in both arr1 and arr2, then the quantity of the item is updated in arr1. ...
ec3a217066be475fda9e7041639815c86358e732
DincerDogan/Python-2
/Understanding Limits-264.py
769
3.546875
4
## 4. Limits Using SymPy ## import sympy x2,y=sympy.symbols("x2 y") limit_one=sympy.limit((-x2**2+3*x2-1+1)/(x2-3),x2,2.9) print(limit_one) #import sympy #x2,y = sympy.symbols('x2 y') #limit_one = sympy.limit((-x2**2 +3*x2-1+1)/(x2-3) , x2, 2.9) ## 5. Properties Of Limits I ## import sympy x,y=sympy.symbols("x...
df382844f87202dcdef05b3c98b2acf9f0a1b270
DincerDogan/Python-2
/Introduction to evaluating binary classifiers-58.py
2,288
3.53125
4
## 1. Introduction to the Data ## import pandas as pd from sklearn.linear_model import LogisticRegression admissions = pd.read_csv("admissions.csv") model = LogisticRegression() model.fit(admissions[["gpa"]], admissions["admit"]) labels=model.predict(admissions[["gpa"]]) admissions["predicted_label"]=labels print(adm...
dfdbaf1d9e39f2da8ceba919755d6f163c0e27e6
DincerDogan/Python-2
/Introduction to Pandas-8.py
1,451
4.09375
4
## 3. Read in a CSV file ## import pandas food_info=pandas.read_csv("food_info.csv") print(type(food_info)) ## 4. Exploring the DataFrame ## import pandas food_info=pandas.read_csv("food_info.csv") first_twenty=food_info.head(20) #print(first_twenty) print(food_info.shape) #print(food_info.columns) print(food_info.i...
eceddd9d8778b4445e75bc921506ccf4b186ec37
chinakids/learn-python
/dome/2.函数.py
3,689
3.96875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #python 3.4.3,这只是笔记,不代表跑得通..... #定义函数 def,关键字 def my_abs(x): if x >= 0: return x else: return -x #空函数使用 pass 占位,不然会报错 def nop(): pass #pass可用在其他语句 if <表达式>: pass #函数内参数检查isinstance(<数据>,<数据类型>),if not isinstance((a,b,c),(int,float)) def m...
71c21e9448a1ef2c54368a2ec01e86235e010862
n1kk0/katas
/python/src/anagrams.py
298
3.9375
4
def anagrams(word, words): ''' shortest: return [item for item in words if sorted(item)==sorted(word)] ''' output = list() word = ''.join(sorted(word)) for anagram in words: if word == ''.join(sorted(anagram)): output.append(anagram) return output
b045e133b8f2b8525edd959acd0657b82407f06a
n1kk0/katas
/python/src/duplicate_encode.py
520
3.625
4
def duplicate_encode(word): ''' best: return "".join([ "(" if word.lower().count(letter) == 1 else ")" for letter in word.lower() ]) ''' letters = {} out = "" for letter in word: if letters.get(letter.lower()): letters[letter.lower()] ...
462b5f3fb66408007f86c8232d1ab5fd8ff16132
tanmay2893/SPOJ
/INVCNT.py
1,087
3.59375
4
def merge(l,r,a): #print l #print r global count nl,nr=len(l),len(r) #print nl #print nr i,j,k=0,0,0 while i<nl and j<nr: if l[i]<=r[j]: a[k]=l[i] i+=1 else: #print 'yay' count+=nl-i #print count ...
062c25e8590f07ad22e972e21add2fb5915341d2
gvheisler/SimpleProblemsPython
/SimpleProgrammingProblems/Elementary/04.py
242
4.25
4
#04 - Write a program that asks the user for a number n and prints the sum of the numbers 1 to n n = int(input("Please, insert a number:")) sum = 0 for i in range (1, n): sum = sum + i print("The sum of the numbers 1 to", n, "is", sum)
64b47c7aaf93ff931d317ef40bde240dd1b32f28
gvheisler/SimpleProblemsPython
/ProblemsOnFourOperations/07.py
347
3.59375
4
#7. A factory manufactured 483685 toys in three weeks. The production in first week was 146345 toys and in second week 138152 toys. # Find the production in the third week. total = 483685 first_week = 146345 second_week = 138152 third_week = total - first_week - second_week print("The production in the third wee...
a788dba4879f33e56d1ee87b49421979ecdb1694
gvheisler/SimpleProblemsPython
/ProblemsOnFourOperations/13.py
343
3.75
4
#13. Maria bought 96 toys priced equally for $12960. The amount of $1015 is still left with her. # Find the cost of each toy and the amount she had. amount = 96 total = 12960 leftover = 1015 each_price = total / amount total_money = total + 1015 print("Each toy cost $", each_price, "and she had $", total_money,...
50261b3b9489cd86b2933fedf23a7f6a1586b0aa
reidogadobot/games
/game1.py
1,767
3.765625
4
def cassino(): from random import choice from time import sleep saldo = 75 print('[*]OLÁ, SEJA BEM-VINDO AO CASSINO ^_________^') jogador = str(input('[*]PARA COMEÇAR, APERTE ENTER ʘ‿ʘ ')) while True: frutas = ["🍋", "🍇", "🍓"] slot1 = choice(frutas) slot2 = choice(frutas) ...
d0f056720cc0e6e89a32985caf2b39b48151ad57
KateKapranova/GdP
/tu03_primeCheck.py
886
4.3125
4
#algorithm which decides if a number is prime #algorithm checks if a number can be divided by anything apart from 1 and itself def primeCheck(n): for i in range(2, n): if n % i == 0: return "is not prime" return "is prime" #test cases: print(7 ,primeCheck(7)) print(111 ,primeCheck(111)) print(...
f78505416cf816245f9084693ab118a626d57a0d
KateKapranova/GdP
/tu03_complement.py
658
4.0625
4
#algorithm to calculate the matrix of a complement graph def complementMatrix(m): #initialising the matrix of the complement graph rows = len(m) columns = len(m[0]) comp = [[0 for i in range(columns)] for i in range(rows)] #calculate the complement matrix: for i in range(rows): ...
e285be1d7d4ef892501d6972b642f8a5f9a5256d
hclife/code-base
/lang/python/practices/ds_str_methods.py
337
4.15625
4
#!/usr/bin/env python3 name='swaroop' if name.startswith('swa'): print('Yes, the string starts with "swa"') if 'a' in name: print('Yes, the string contains str "a"') if name.find('war')!=-1: print('Yes, the string contains str "war"') delimiter='_*_' mylist=['brazil','russia','india','china'] print(delimit...
ab795b5bc0d361ced99a2a6b57648805a4e27720
hclife/code-base
/lang/python/practices/lambda.py
314
3.734375
4
#!/usr/bin/env python3 points=[{'x':2,'y':3}, {'x':4,'y':1}] points.sort(key=lambda i:i['y']) print(points) def make_incrementor(n): return lambda x:x+n f=make_incrementor(42) print(f(0)) print(f(1)) pairs=[(1,'one'),(2,'two'),(3,'three'),(4,'four')] pairs.sort(key=lambda pair:pair[1]) print(pairs)
1cafa8b5f9a104a5e01aaa5d6dfd819e36e6ec08
hclife/code-base
/lang/python/practices/ds_sequence.py
1,024
3.953125
4
#!/usr/bin/env python3 shoplist=['apple','mango','carrot','banana'] name='swaroop' # indexing / subscription operations print('item[0]=',shoplist[0]) # apple print('item[1]=',shoplist[1]) # mango print('item[2]=',shoplist[2]) # carrot print('item[3]=',shoplist[3]) # banana print('item[-1]=',shoplist[-1]) # ban...
e2f1940854c57d73b9336aba2f53d9179319c936
hclife/code-base
/lang/python/practices/func_docstring.py
439
4.34375
4
#!/usr/bin/env python3 def print_max(x,y): '''Print the maximal value of two numbers. These two numbers both should be integers.''' x=int(x) y=int(y) if x>y: print(x,'is maximum val') else: print(y,'is maximum val') def my_func(): """Do nothing, but document it. No, re...
48429f60369f56d82a40f79a6d5bb76851c14ebc
frazierprime/articles-and-papers
/project_euler/euler_four.py
1,741
4.3125
4
#!/usr/bin/env python3 # A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. # Find the largest palindrome made from the product of two 3-digit numbers. MAX_NUMBER_TO_TEST = 999 MIN_NUMBER_TO_TEST = 100 TEN = 10 # O(n) where n is = nu...
6ddaa8cc8ce8bb581ad3cec176501ed34cc42edb
DivyaYagnik/python-projects
/socket_program/client.py
926
3.53125
4
import socket from .server import handle_client HEADER = 64 FORMAT = 'utf-8' PORT = 5050 DISCONNECT_MSG = "!DISCONNECT!" SERVER = socket.gethostbyname(socket.gethostname()) ADDR = (SERVER, PORT) class User: def __init__(self, name): self.name = name client = socket.socket(socket.AF_INET, socket.SOCK_STR...
d5f27f8348db6109230ddb6ec49ba2387587ac85
Noah-Giustini/Base-26-Converter
/base26.py
2,771
4.09375
4
import sys #The convertTo method takes one parameter x and is the input integer that will be converted to a base26 number def convertTo(x): num = x result = [] string = "" alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] #While loop t...
4b56ed7c89dff3a3f132240cd57f59acd9a07ecd
syedwajid01/TicTacToe
/tictactoe.py
4,894
4.15625
4
# ------------- Functions --------------- # Play a game of tic tac toe #This function prints the board def printBoard(board): print("\n") print(board[7] + " | " + board[8] + " | " + board[9] + " 7 | 8 | 9") print(board[4] + " | " + board[5] + " | " + board[6] + " 4 | 5 | 6") print(board[1] + " ...
318652244b44f980b1266a978927f3bc6e06d07a
hamasl/IMAT2150
/Task6/chap2point7cp3.py
428
3.6875
4
import numpy as np from Task6.newtons_multivariate_method import newtons_multivariate if __name__ == '__main__': df_a = lambda x: np.array([3 * x[0]**2+1, -3 * x[1]**2, 2 * x[0], 2 * x[1]]).reshape(2, 2) f_a = lambda x: np.array([x[0] ** 3 - x[1] ** 3 + x[0], x[0] ** 2 + x[1] ** 2 - 1]) print(newtons_multi...
c950c8601e980f6d2ea11d69032610b1caf69b90
hamasl/IMAT2150
/Common/bezier.py
759
3.953125
4
import matplotlib.pyplot as plt import numpy as np def get_bezier(x, y): b_x = 3 * (x[1] - x[0]) c_x = 3 * (x[2] - x[1]) - b_x d_x = x[3] - x[0] - b_x - c_x b_y = 3 * (y[1] - y[0]) c_y = 3 * (y[2] - y[1]) - b_y d_y = y[3] - y[0] - b_y - c_y return lambda t: x[0] + b_x * t + c_x * t ** 2 ...
43dddd3b868c611c0798f68e55947bc6011a4694
hamasl/IMAT2150
/Task4/chap6point1cp1.py
1,247
3.609375
4
import math def correct_sol_a(t): return 0.5 * t ** 2 + 1 # NOTE know that this is bad practice, but this file will never be used by anyone else than me, and only used for this one exercise def fun_a(t, y): y return t def correct_sol_b(t): return math.e ** (1 / 3 * t ** 3) def fun_b(t, y): r...
2d74881bf970324b126746c39ceb6ea0b420f917
mricim/m10
/ex1/calcularDni.py
669
3.734375
4
def calcularDni(): diccionario = { 0: "T", 1: "R", 2: "W", 3: "A", 4: "G", 5: "M", 6: "I", 7: "F", 8: "P", 9: "D", 10: "X", 11: "B", 12: "N", 13: "J", 14: "Z", 15: "S", 16: "Q", ...
b6000f5728a0bbdea4fafd383561624f192b6b84
mricim/m10
/apuntes/sdf.py
933
4
4
print("hola Mundo") print ("hola", "mundo") pes=input("quien es el pes?") type(pes) print(pes) llist=(range(10)) print(llist) llistaA=[x*2 for x in range(10)] print(llistaA) llista=[x**2 for x in range(10)] print(llista) llistaD=[x**2 for x in range(10) if x%2==0] print(llistaD) n = 6 str = "Tinc {} anys".form...
017be8cc7d7f5363b54fa59e8a81a3e31177bb58
Schikoti/Deep-learning-basics
/Assignments/svm.py
4,099
3.578125
4
import numpy as np class SVM(object): def __init__(self, n_epochs=10, lr=0.1, l2_reg=1): """ """ self.b = None self.w = None self.n_epochs = n_epochs self.lr = lr self.l2_reg = l2_reg def forward(self, x): """ Compute "forward" computati...
046b4e9759a4d58b88805c2935f7dbfa37be8506
Broast42/cs-module-project-hash-tables
/applications/word_count/word_count.py
1,259
4.28125
4
def remove_char(word): whitelist = set("abcdefghijklmnopqrstuvwxyz' ") new_word = ''.join(filter(whitelist.__contains__, word)) return new_word def word_count(s): # Your code here #dict to store words and number of times it appears words = {} #set all letters to lower case s = s.lower()...
102144b5b6a6316a0f45554986212133bb71f167
gitter-badger/python_me
/hackrankoj/math/find_angle.py
572
4.15625
4
#!/usr/bin/env python # coding=utf-8 import math ab,bc=float(raw_input()),float(raw_input()) print str(int(round((math.atan(ab/bc)*180)/math.pi)))+'°' ''' 我一开始是import cmath 终于明白了,cmath是complexmath,cmath.atan()等操作返回的都是complex类型的数!!! import math ab = float(raw_input()) bc = float(raw_input()) tang = ab / bc rad = mat...
9b12921d9390491f86e7ea88c775b114fe7a0b70
gitter-badger/python_me
/exercise/20160520/Tkinter_example.py
656
3.703125
4
#!/usr/bin/python #-*- coding: utf-8 -*- # File Name: Tkinter_example.py # Created Time: Fri May 20 14:01:41 2016 __author__ = 'Crayon Chaney <mmmmmcclxxvii@gmail.com>' import Tkinter from Tkconstants import * tk = Tkinter.Tk(className='first window') #初始一个Tk类,貌似是主窗口 frame = Tkinter.Frame(tk,borderwidth=20) #这应该是初始...
63e2a75c78322efe71db3551cd30a99878759d9e
gitter-badger/python_me
/hackrankoj/strings/string_validator.py
5,089
4.40625
4
#!/usr/bin/python #-*- coding: utf-8 -*- # 问题 # You are given a string . # Your task is to find out if the string contains: alphanumeric characters, alphabetical characters, digits, lowercase and uppercase characters. ''' 方法1(错误) task = ['isalnum()','isalpha()','isdigit()','islower()','isupper()'] string = raw_input...
ecc74e018ddec0f2292198190ac4f6adaf023374
gitter-badger/python_me
/exercise/20160519/27_reverse_string_by_recursion.py
331
3.828125
4
#!/usr/bin/python #-*- coding: utf-8 -*- # File Name: 27_reverse_string_by_recursion.py # Created Time: Thu May 19 10:47:48 2016 __author__ = 'Crayon Chaney <mmmmmcclxxvii@gmail.com>' from sys import stdout def reverse(s,idx): if idx >= len(s): return reverse(s,idx+1) stdout.write(s[idx]) s = ra...
631b081d97844477c10a66ed3243f35a2a16356c
gitter-badger/python_me
/exercise/20150522/review_class.py
828
3.6875
4
#!/usr/bin/python #-*- coding: utf-8 -*- # File Name: review_class.py # Created Time: Fri May 22 09:15:44 2015 __author__ = 'Crayon Chaney <mmmmmcclxxvii@gmail.com>' class Student(object): def __init__(self,name,score): self.__name = name self.__score = score def show(self): print "nam...
79eb7cef431c19609b50f178697d01d3b11341ba
gitter-badger/python_me
/hackrankoj/built-in/anyorall.py
1,067
3.953125
4
''' Task You are given a space separated list of integers. If all the integers are positive, then you need to check if any integer is a palindromic integer. palindromic就是回文数 Input Format The first line contains an integer N. N is the total number of integers in the list. The second line contains the space separate...
9706179553e20a0bc4e8f25237c9494e601c5b8c
gitter-badger/python_me
/exercise/20160519/30_palindrome.py
1,253
3.671875
4
#!/usr/bin/python #-*- coding: utf-8 -*- # File Name: 30_huiwen.py # Created Time: Thu May 19 14:41:01 2016 __author__ = 'Crayon Chaney <mmmmmcclxxvii@gmail.com>' #一个5位数,判断它是不是回文数。即12321是回文数,个位与万位相同,十位与千位相同。 import sys def digits(n): global count if n== 0: return else: digits(n/10) ...
2fcd6a8cbab4bf49a520288bfeb9cb3fb4fd0cb6
gitter-badger/python_me
/exercise/20150510/iter.py
1,308
3.703125
4
#!/usr/bin/python #-*- coding: utf-8 -*- # File Name: iter.py # Created Time: Mon May 11 00:29:28 2015 __author__ = 'Crayon Chaney <mmmmmcclxxvii@gmail.com>' class fib(object): def __init__(self): self.a,self.b = 0,1 def __iter__(self): return self def next(self) : self.a,self.b =...
2dcfdf2bf9a1bc1042923474fa3711099c709d96
gitter-badger/python_me
/hackrankoj/BasicDataTypes/test_prime.py
303
3.8125
4
#!/usr/bin/python #-*- coding: utf-8 -*- # File Name: test_prime.py # Created Time: Fri Sep 16 18:14:23 2016 __author__ = 'Crayon Chaney <mmmmmcclxxvii@gmail.com>' import math def prime(num): for i in range(2,int(math.sqrt(num)+1)): if num % i == 0: return False return True print prime(inp...
c4c126c5a2b8a0964880d30e0c7947f76b81d1ad
gitter-badger/python_me
/hackrankoj/collections/most_commons.py
1,814
4.0625
4
#!/usr/bin/env python # coding=utf-8 ''' You are given a string S. The string contains only lowercase English alphabet characters. Your task is to find the top three most common characters in the string S. Sample Input aabbbccde Sample Output b 3 a 2 c 2 ''' #my solution from collections import Counter print...
f071a7a0c87b9136b9afe1aa78d98f4acd17226e
gitter-badger/python_me
/exercise/20160516/18_sum_a_aa_aaa.py
531
3.671875
4
#!/usr/bin/python #-*- coding: utf-8 -*- # File Name: 18_sum_a_aa_aaa.py # Created Time: Tue May 17 15:43:01 2016 __author__ = 'Crayon Chaney <mmmmmcclxxvii@gmail.com>' #求s=a+aa+aaa+aaaa+aa...a的值,其中a是一个数字。例如2+22+222+2222+22222(此时共有5个数相加),几个数相加有键盘控制。 a = int(raw_input("input a > ")) times = int(raw_input("plus times ...
6c7ae807bfd70f3cf4b990911e19fc6daa56f80c
gitter-badger/python_me
/exercise/20150509/encrypt.py
656
3.609375
4
#!/usr/bin/python #alpha = [chr(i) for i in range(97,123)] def encrypt(alpha): #return chr(ord(alpha)+13) return alpha def encode(msg): return map(encrypt,msg) def transmit(source,dest): dest = source return dest def decode(msg): for i in range(len(msg)): msg[i] = chr(ord(msg[i])+2) ...
940eb90c3497f8c22c39f213c4f4ef09534f1321
gitter-badger/python_me
/exercise/20160516/14_fenjiezhiyinshu.py
1,311
4
4
#!/usr/bin/python #-*- coding: utf-8 -*- # File Name: 14_fenjiezhiyinshu.py # Created Time: Tue May 17 09:55:59 2016 __author__ = 'Crayon Chaney <mmmmmcclxxvii@gmail.com>' #将一个正整数分解质因数。例如:输入90,打印出90=2*3*3*5。 import math import sys #找到最小的质数 def if_prime(n): top = int(math.sqrt(n+1)) flag = 0 for i in range...
11c62c54432d3264414d2a4b3ea164a642ed67fc
gitter-badger/python_me
/hackrankoj/sets/discard_remove_pop.py
3,062
3.546875
4
#!/usr/bin/env python # coding=utf-8 ''' #我的 n = input() s = set(map(int, raw_input().split())) for _ in range(input()): order=raw_input().split() cmd = order[0] arg = order[1:] cmd = 's.'+cmd+'('+''.join(arg)+')' eval(cmd) print sum(s) #关于分解这个命令,给忘了。翻了以前的记起来的。 因为pop没有带参数,而discard, remove 是带参数的,所...
b36662b32450c48ff6bb152210ea0ca3a705ab65
gitter-badger/python_me
/hackrankoj/itertool/IterablesandIterators.py
4,506
4.3125
4
#!/usr/bin/env python # coding=utf-8 ''' The itertools module standardizes a core set of fast, memory efficient tools that are useful by themselves or in combination. Together, they form an iterator algebra making it possible to construct specialized tools succinctly and efficiently in pure Python. To read more abo...
e39c9133453f445d8ce028f4a18200fb5a27921e
gitter-badger/python_me
/GUI/component/StringVar.py
652
3.59375
4
#!/usr/bin/python #-*- coding: utf-8 -*- # File Name: StringVar.py # Created Time: Thu Mar 2 16:23:11 2017 __author__ = 'Crayon Chaney <mmmmmcclxxvii@gmail.com>' from Tkinter import * def callback(*args): print 'variable changed!' top = Tk() label = Label(top,text = 'test stringvar') label.pack() cwd = String...
19da0df72e236eca9ea4bad3c90818fab4c53bc6
gitter-badger/python_me
/corepythonprogramming/13_13_2_time60.py
1,475
4
4
#!/usr/bin/env python # coding=utf-8 ''' 创建一个简单的应用,用来操作时间,精确到小时和分 可用来跟踪职员的工作时间,ISP用户在线时间,,在扑克比赛中玩家总时间等。 ''' class Time60(object): def __init__(self,hour,minute): self.hr = hour self.min = minute def __str__(self): return '%d:%d'%(self.hr,self.min) __repr__ = __str__ #下一步干什么呢?...
aefeb50757cf5df747ae20300f53c53888c51715
gitter-badger/python_me
/exercise/20150506/global.py
197
3.5625
4
def func(a): global x a += 1 print "parameter named a ",a print "In function",x x = x + 1 x = 2 print "Outside",x func(x) print "After function",x
68cb62e5d516e60f3fe43db4066fb9bf5eaacf52
gitter-badger/python_me
/hackrankoj/itertool/permutations.py
551
3.578125
4
#!/usr/bin/env python # coding=utf-8 from itertools import permutations print '\n'.join([''.join(_) for _ in sorted(list(permutations(*map(lambda s:int(s) if s.isdigit() else s,raw_input().split()))))]) #上面语句的list可以不用写,单纯返回一个迭代器,反正前面有for ''' permutations(iterable[,k])函数会根据中的iterable的顺序排列,'213'就会先2开头,然后1开头,再3开头, ''' ...
59d9db31a9042dccd7a82d833b5efd64e59e89e1
gitter-badger/python_me
/hackrankoj/strings/find_a_string.py
1,188
3.640625
4
#!/usr/bin/python #-*- coding: utf-8 -*- # recursive solution def findall(s, sub): if s.find(sub) == -1: return 0 else: start = s.find(sub) + 1 return 1 + findall(s[start:], sub) string,substring = raw_input(),raw_input() print findall(string,substring) #我的方法 # string,substring= raw...
d4850ed0f09ed43adfe7e14866145ebe5b6477ec
varun-va/Python-Practice-Scripts
/GeeksforGeeks/largest_elelment_list.py
546
3.765625
4
def getMax(l): # Time complexity: O(n*2) for x in l: for y in l: if y > x: break else:# else can be added to a FOR loop in Python return x return None #return [i for i in l if i > l] def getMaxLinear(l): # lineat: theta N if not l: ...
44b338ac6836c3d7dacfb18865d8ea1c5f760071
zenema/job-board
/e2e/date.py
218
3.59375
4
import time input = "Wed Aug 05 04:21:47 UTC 2020" output = time.strptime(input, '%a %b %d %H:%M:%S %Z %Y') print(output) # default formatting - "%a %b %d %H:%M:%S %Y" print(time.strptime('Wed Sep 19 14:55:02 2018'))
8e6bce62e5e77ff8eac414c385441733a34a571a
monty233038/python-basic
/dec to hexdec.py
819
3.578125
4
decimal_num = int(input('enter a decimal no ')) hex_list = {10: 'A', 11: 'B', 12: 'C', 13: 'D', 14: 'E', 15: 'F' } remainder_dec = [] remainder_hex = [] remainder = 10 # decimal 256 while decimal_num >= 1: if decimal_num < 16:...
9efd81b9baa744a34110749ae0d9735c2238bca3
grayvalley/sandbox
/app/src/side.py
433
3.859375
4
from enum import Enum class Side(Enum): B = 1 S = 2 def side_to_str(side): if side == Side.B: return 'B' elif side == Side.S: return 'S' else: raise ValueError("Side not understood.") def get_opposite_side(side): if side == Side.B: return Side.S elif sid...
de53fc7368d0d323385868ca87612aa0c485a64c
dvirdov/pythonProject2
/bgu.py
1,283
3.796875
4
import os import sys def is_foreign_letter(letter: str): try: letter.encode(encoding='utf-8').decode('ascii') except UnicodeDecodeError: return True # cant be coded into ascii - means foreign letter else: return False def alternate_name_in_hebrew(name: str): new_name = "" ...
f7b91547fc81c5b85a17c3143624455c6b940f02
spalit2017/Data-Science
/Twitter Streaming and analytics App/tweetwordcount/barplot_top20.py
966
3.671875
4
import sys import matplotlib.pyplot as plt import numpy as np import psycopg2 # Use psycopg to connect to Postgres # Database name: Tcount; Fields : word and count # Table name: tweetwordcount conn = psycopg2.connect(database="Tcount", user="postgres", password="pass", host="localhost", port="5432") # Create a ...
0b3d962aebb7c321e1604dd05e958426513f6bfa
Otimthomas/python_projects
/findMax.py
497
4.25
4
def findMax(num1, num2, num3): if (num1 > num2 and num1 > num3): print(str(num1) + ' is the greatest number among the three') elif (num2 > num1 and num2 > num3): print(str(num2) + ' is the greatest number among the three') else: print(str(num3) + ' is the greatest number among the ...
678485295e92666b0e1c2a7293e5a5e90f9e029c
Harichandanak/saichandu
/program17.py
131
3.578125
4
g=int(input(" ")) temp=g sum=0 while(g>0): rem=g%10 sum=rem**3+sum g=g//10 if(temp==sum): print("yes") else: print("no")
681ad553bceeb1a27997a5d9d74492bd569a7269
shahrukh-git/git
/guessing_number.py
929
4.03125
4
import random import time guess = 0 tries = 0 number = random.randint(1,10) name = input("Hey!, May I Know Your Name?: ") print("Hello "+name+".") question = input("Are You Ready To Guess? (yes/no): ") time.sleep(1) if question.lower() == 'no': time.sleep(1) print("I'm sorry, We'll meet each other next time...
7f2ee6b57952b5791cdb169fff2ad9dcbe9e5515
LexDUA/StudyGit
/StudyGitr/square.py
306
3.765625
4
''' Created on 13 окт. 2021 г. @author: Alex ''' import my_funcs as mf # # for too funcs - loop from 1 to 10 # print("square") for i in range(10): print(f"The square of {i} is {mf.square(i)}") print("cube") for i in range(10): print(f"The square of {i} is {mf.cube(i)}")
1d4af57bc21817b972403e4aa6b1cfd0997c5a46
JJDLTorre/MyNotes
/python/tests/term_code/term_code.py
556
3.765625
4
def convert_from_term_code(term_code) -> str: """ >>> convert_from_term_code(2202) 'Winter 2020' >>> convert_from_term_code(2204) 'Spring 2020' """ term_name = "" if (str(term_code).endswith('2')): term_name = "Winter" elif (str(term_code).endswith('4')): term_name ...
c25309c8d8b853d5b73e284ef089e589e7c21f72
Renita1206/Python-Games
/Hangman.py
1,024
3.59375
4
import random lives=7 l=[] def display(a): print(a) def generateAns(w): a="_"*len(w) return a def updateAns(c,w,ans): for i in range(len(w)): if(c==w[i]): ans=ans[0:i]+c+ans[i+1:] return ans print("The Categories are:") print("1.Countries") print("2.Famous People") choice=in...
2423636977b2b3da2201cccdcfe7e8e583ba9028
InfHo/PythonCourse
/lesson_1/function_and_loops.py
214
3.875
4
#create new function which loops through "Hello" def halloschreiber(): for buchstabe in "HELLO": print(buchstabe) #repeat halloschreiber() three times for j in range(3): halloschreiber()
4e2f34277847bae2485b85087e7cf68312884b30
InfHo/PythonCourse
/turtle/rauten/raute_8.py
824
3.625
4
import turtle import random turtle.bgcolor("white") #neuer Farbmodus. Anstatt "blue" etc. können jetzt r,g,b farben benutzt werden turtle.colormode(255) stift = turtle.Turtle() stift.speed(4) stift.shape('turtle') stift.width(2) #die drei werte stehen für r=rot, g=grün, b=blau und sollen zwischen 0-255 liegen ...
b513c97a9884a2459cf4352956ca97f42ff37993
syf107/Complete-Python-Developer-ZTM
/section07-fcprogramming/fcp3.py
280
3.546875
4
#lambda expressions. from functools import reduce my_list = [1, 2, 3] your_list = [20, 30, 40] print(list(map(lambda item: item * 2, my_list))) print(list(filter(lambda item: item % 2 != 0, my_list))) print((reduce(lambda acc, item: acc + item, my_list))) # lambda exercise
230312b53876665b1e74a0cf73b3bab66dc42ab5
yatesmac/Alien-Invaders
/alieninvaders/settings.py
1,504
3.703125
4
"""This module stores the Settings for the game.""" class Settings: """A class to store all the static and dynamic settings for Alien Invaders game.""" # Constant game settings are stored as class attributes. # Screen screen_width = 900 screen_height = 600 # Ship ship_limit = 2 # Bul...
b682521c0358dd22beddaaed8fe60a975ed77284
n73274246/280201001
/lab10/example3.py
237
3.8125
4
def sum_of_nested(x): if not isinstance(x,list): return x else: sum_result = 0 for item in x: sum_result += sum_of_nested(item) return sum_result a_list = [3,12,76,[4,56,43],[2,8],81,75] print(sum_of_nested(a_list))
4202905713c5b6147fceb57ea3c01c26dddd67ca
n73274246/280201001
/lab10/example1.py
66
3.640625
4
def f(n): if n == 0: return 0 return 3+f(n-1) print(f(8))
201a8a027ca1502191c322f2e7ccf2cec7204e7a
n73274246/280201001
/lab4/example4.py
136
4.09375
4
a = int(input("Write a number ")) b = int(input("Write another one ")) power = 1 for i in range(1,b+1): power = power * a print(power)
2c1fce592f9d8718b92a33f8ea1882696fa55fd9
n73274246/280201001
/lab2/example4.py
107
3.671875
4
tempc = input("Write a celcius, please") tempc = float(tempc) tempf = tempc * 1.8 +32 print("It is", tempf)
da8b910fba1f3362dd0d26491ee1ddc9ab0c7400
SDD-Maples/CarPort
/ViewCar/LotView.py
1,790
3.703125
4
import sqlite3 import cv2 DataBaseName = "Cars.db" class LotView(object): """This is built to run the lot""" SqlFile = DataBaseName def __init__(self): return def SaveCount(self, name, newCount): """Writes to the sqlite file the new Count""" try: conn = sqlite3.con...
787f2c2cf5503f63ba98101713eaefdeb6e91762
ajasif/Extract-Summary
/TextRank.py
6,706
3.515625
4
import itertools import networkx as nx import nltk import operator import math import Tkinter as tk import tkFileDialog import textwrap ''' Takes in a single or multiple news or scholarly text articles and extracts a summary. @author: Team 11 ''' def mymain(): print "Enter 1 for single document summarization." ...
57debb449cf7463b950bcb8e77988a4967c18192
zwep/domotica
/adventofcode_2022/day13.py
3,926
3.71875
4
import os import re import string import numpy as np from adventofcode_2022.helper import DPATH import matplotlib.pyplot as plt import string import itertools def process_input(puzzle_input): puzzle_pairs = [] temp_list = [] for i_item in puzzle_input: i_item = i_item.strip() if i_item != ...
c9f1ede59c1b4028d154af644e2a2134a9d290bc
Shubhamg2595/RESTful-APIs-using-Flask
/Restful.py
1,870
3.53125
4
from flask import Flask,request from flask_restful import Resource,Api app = Flask(__name__) api = Api(app) #an api works with a resource and each resource must e a classs items = [] 'simply creating a Student class that is actually inheriting the properties of resource class' class Item(Resource): def get(sel...
a33975c7979c1a60ed5d9613881209f90a776d79
rtiinuma/udacity_logs_analysis
/db.py
1,173
4.03125
4
#!/usr/bin/env python3 import psycopg2 class Database(): '''Database class to encapsulated connections and queries to database. ''' def __init__(self, dbname): '''Database class constructor initializing database name and validating connection. Throws exception if connection to specifie...
20ca7b2d10fdec57bf687632728141e1e53c0c4a
connorads/Exercism
/python/locomotive-engineer/locomotive_engineer.py
2,051
4
4
"""Functions which helps the locomotive engineer to keep track of the train.""" from typing import TypedDict def get_list_of_wagons(*wagons: int) -> list[int]: """Return a list of wagons. :param: arbitrary number of wagons. :return: list - list of wagons. """ return [*wagons] def fix_list_of_...
dd0a1bc2fb7cd186591c80a24040a17dc2bf63c8
snowmancode/soft2
/RaceApp.py
477
3.59375
4
name = input("What is your name? "); occupation = input("What do you do for a living? "); hobby = input("What is your hobby? "); ethnicity = input("What is your ethnicity? "); fancy_line = "=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0"; print("\n\n\n"); print(fancy_line); print("\n", name); p...
4cf7f2e5cd184fffce25a00ddb4f35d52f4c1e28
Techie-PawandeepSingh/MyTerminal
/system/rfile.py
444
3.59375
4
import os import time os.system("cls") oldname = input("Type file name: ") if os.path.exists(oldname): os.system("cls") newname = input("Type new name: ") os.rename(oldname, newname) print("File name was successfully changed.") time.sleep(2) os.system("python main.py") exit(...
a1bf38aaa0741e05f44709b31c76b7d214b69676
vishnuprakash406/sample_project
/sort.py
349
4.1875
4
arr=[] n=int(input("enter the size of the list :")) for i in range(0,n): temp=input("enter the number to array to be sorted: ") arr.append(temp) print("the unsorted array is",arr) arr.sort() print ("sorted list is : ",arr) <<<<<<< HEAD #hello ======= #program for sort >>>>>>> 4bd3ad2d62a567268fff27612510569...