blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
a3deec695cf0473ccb80c3e77f6c0b57fd07699d
KKGar/password-retry
/password.py
251
4.09375
4
password = 'a123456' i = 3 # remaining times while i > 0: pwd = input('Please enter the password: ') if pwd == password: print('Log in success!') break #逃出迴圈 else: i = i - 1 print('Password is incorrect! Remaining', i,'times')
8e5bb430d0352a3e305918fce800455d78938e3f
LorenzoSacchi/Blackjack
/BlackJack.py
3,614
4.15625
4
import random import console #Class that creates a single card class Card: """ create one card methods: Onecard - return the card design OneValue - return the card actual value """ def __init__(self,card,value,sign): self.card = card self.value = value self.sign = sign def OneCard(self): if ...
67306a05d7e23c8080d519e2dcb0c4a0537213ce
RicHz13/PythonExercices
/C38Decoradores.py
815
3.609375
4
#Un decorador es una función que recibe otra función y regresa una 3er función #Para reconocer un decorador, puedes ver que tiene un arroba sobre la declaración de una función #Útil para definir si una función debe ejecutarse o no. #Por ejemplo: #En servidores web, existen ciertas funciones que nada más deben e...
e44ce833e21fb6c607eb82ea1d6bf7c977130803
sunzhqiiang888/KingSun
/kyo/python/1_function/a_decorator.py
790
3.546875
4
#!/usr/bin/env python3 def p(func): def inner(s): return '<p>' + func(s) + '</p>' return inner def tag(*args, name='p', **kwargs): def _tag(func): def inner(*args, **kwargs): return '<%s>%s</%s>' % (name, func(*args, **kwargs), name) return inner return _tag @tag(...
1e0eba1b1d893f30cf932c055ec6c045cdeabdc2
formation2020/slides
/python/examples/csv/read_monty.py
156
3.609375
4
import csv file = 'examples/csv/monty_python.csv' with open(file) as fh: rd = csv.DictReader(fh, delimiter=',') for row in rd: print(row)
f28ad6190f69c963252dc8e7aec243c712456be4
weychi/yzu_python
/lesson01/Hello.py
112
3.5625
4
import random y = 0 x = 0; while 1 : x = random.randint(1,9) print(x) if(x % 2 == 0): break;
5a7bceae3d0902d73892722b07ae62b2d70fe178
JuanCaychoPaucar/codigo-virtual-4-backend
/Semana1/dia2/02-transformar-tipos.py
131
3.515625
4
# Ingresar valores edad = input("Ingresa tu edad: ") print(edad) print(type(edad)) edadEntero = int(edad) print(type(edadEntero))
408327743480555c58f3e579f0dc0e3b8db75fdb
aboucaud/adventofcode2017
/day04/day04.py
1,448
3.90625
4
""" """ from typing import List from collections import Counter def valid_passphrase(phrase: str) -> bool: counter = Counter(phrase.split()) for val in counter.values(): if val > 1: return False return True assert valid_passphrase("aa bb cc dd ee") assert not valid_passphrase("aa b...
c92135011c07f2a07c56126662f52b2cb48db010
aboucaud/adventofcode2017
/day24/day24.py
1,538
4
4
""" http://adventofcode.com/2017/day/24 """ from typing import List def parse_input(input: List[str]) -> List[List[int]]: return [list(map(int, line.split('/'))) for line in input] def build_bridges(parts, pin, bridge): available_parts = [part for part in parts if pin in part] # print(f'Available parts ...
5ba21c48abe1d3dc5f53f901e36423a69cb8a59a
Connor24601/Othello
/othelloPlayers.py
4,944
4.0625
4
import othelloBoard from typing import Tuple, Optional '''You should modify the chooseMove code for the ComputerPlayer class. You should also modify the heuristic function, which should return a number indicating the value of that board position (the bigger the better). We will use your heuristic function when running...
cc026974c3ce14ebbe67a6d488275473762a00b7
sasogeek/ContactManager
/add_delete_search_contacts.py
658
3.765625
4
from contacts import Contacts add_delete_search_contact_ = True phone_book = Contacts() while add_delete_search_contact_: check = input('Add/Delete/Search/Quit a contact? a/d/s/q ') if check == 'a': contact = phone_book.add_contact() add_delete_search_contact_ = True elif check == 'd': ...
dba0492edad611c00d9d0009778881147a7d42ef
Geeorgee23/Socios_cooperativa_MVC
/main.py
2,652
3.671875
4
from socios import Socios from controlador import Controlador from datetime import datetime controlador = Controlador() while True: print("Actualmente hay ",controlador.numSocios()," socios") print("1.- Añadir Socio") print("2.- Eliminar Socio") print("3.- Listar Socios") print("4.- Registrar P...
9d4191a3fc0688dafe61bb3a4ee4c6e9e7ae11ba
jarvisteach/appJar
/docs/Lessons/topics/recursion/adjList.py
305
3.765625
4
# list of lists adjLists = [ [1,2], [2,3], [4], [4,5], [5], [] ] # testing print("Neighbors of vertex 0: ", adjLists[0]) print("Neighbors of vertex 3: ", adjLists[3]) print("\nPrint all adjacency lists with corresponding vertex") n = len(adjLists) for v in range(0,n): print(v, ":", adjLists[v])
56b0bc0cf840fe0849e3b7d287b4245feb49335d
jarvisteach/appJar
/docs/Lessons/topics/records/sample1.py
220
3.515625
4
bob = ('Bob', 30, 'male') print( 'Representation:', bob) jane = ('Jane', 29, 'female') print( '\nField by index:', jane[0]) print( '\nFields by index:') for p in [ bob, jane ]: print( '%s is a %d year old %s' % p)
6bf26142b6bc5d22a478e606a1371fcf2c44ccac
jarvisteach/appJar
/docs/Lessons/topics/records/sample2.py
413
3.5625
4
import collections # create the record, Person = collections.namedtuple ('Person', 'name age gender') print( 'Type of Person:', type(Person)) bob = Person(name='Bob', age=30, gender='male') print( '\nRepresentation:', bob) jane = Person(name='Jane', age=29, gender='female') print( '\nField by name:', jane.name) p...
8d46136a978666dc1a21b64df14ca92edaa39c14
chaudharyachint08/Multiple-Sequence-Alignment
/Codes/LCS_Overlap.py
3,225
3.59375
4
# Dynamic Programming implementation of LCS problem import time import IP import DNA def lcs(X , Y): # find the length of the strings m = len(X) n = len(Y) # declaring the array for storing the dp values L = [[0 for x in range(n+1)] for x in range(m+1)] """Following steps build...
c1fe260237f4a694c49c6191271a3d5870241e6f
pawan9489/PythonTraining
/Chapter-3/3.Scopes_1.py
1,353
4.625
5
# Local and Global Scope # Global variable - Variables declared outside of Every Function # Local variable - Variables declared inside of a Function g = 0 # Global Variable def func(): i = 30 # Local Variable print("From Inside Func() - i = ", i) print("From Inside Func() - g = ", g) print('---- Global Var...
b9310befbc4a399a8c239f22a1bc06f7286fedee
pawan9489/PythonTraining
/Chapter-2/4.Sets.py
1,504
4.375
4
# Set is a collection which is unordered and unindexed. No duplicate members. fruits = {'apple', 'banana', 'apple', 'cherry'} print(type(fruits)) print(fruits) print() # Set Constructor # set() - empty set # set(iterable) - New set initialized with iterable items s = set([1,2,3,2,1]) print(s) print() # No Indexing - ...
56e43c7c6023db7f49332b69086826f198938b34
pawan9489/PythonTraining
/Chapter-4/6.Magic_OR_Dunder_Methods.py
4,933
3.96875
4
# Magic or Dunder Methods - __Method__ # Meta Object Protocol # Enrich your classes by providing some implementation # Accomplishes a Contract => like Interfaces in C# or Java # Initialization of new objects (__init__) # Object representation (__repr__, __str__) # Enable iteration (__len__, __getitem_...
ea4f3b0a569bcc2fd312286f4d44383a2ef6729a
pawan9489/PythonTraining
/Chapter-4/1.Classes_Objects.py
1,641
4.21875
4
''' Class Like Structures in Functional Style: Tuple Dictionary Named Tuple Classes ''' d = dict( name = 'John', age = 29 ) print('- Normal Dictionary -') print(d) # Class Analogy def createPerson(_name, _age): return dict( name = _name, age = _age ) pr...
df3792581d58282d7a157f748617891b69c94d9c
pawan9489/PythonTraining
/Chapter-2/7.TypeConversions.py
1,515
4
4
# Iterconversions between data structures l = [2, 3, 4, 5, 2] t = ('a', 2, True, -4.5, True) s = {False, 10, 34.5} d = {'a': 1, 'b': 2} print() # List Contructor with multiple Iterables print("list(list) = {0}".format(list(l))) print("list(tuple) = {0}".format(list(t))) print("list(set) = {0}".format(list(s))) print("...
ca7b96d6389b50e8637507cce32274991e792144
SK7here/learning-challenge-season-2
/Kailash_Work/Other_Programs/Sets.py
1,360
4.25
4
#Sets remove duplicates Text = input("Enter a statement(with some redundant words of same case)") #Splitting the statement into individual words and removing redundant words Text = (set(Text.split())) print(Text) #Creating 2 sets print("\nCreating 2 sets") a = set(["Jake", "John", "Eric"]) print("Set 1 ...
fea886cfe9281350bc1efc3dccb996498cb055b8
SK7here/learning-challenge-season-2
/Kailash_Work/MySQL/MySQL_Insert.py
999
4.03125
4
#Package to use MySQL import mysql.connector #Creating a connection and opening the specified DB DB_Name = input("Enter the database name : ") mydb = mysql.connector.connect( host="localhost", user="# Your username #", passwd="# Your password #", database=DB_Name ) #Crating a cursor to execute...
0164661e3480ce4df1f2140c07034b3bb75a6c3b
SK7here/learning-challenge-season-2
/Kailash_Work/Arithmetic/Calculator.py
1,779
4.125
4
#This function adds two numbers def add(x , y): return x + y #This function subtracts two numbers def sub(x , y): return x - y #This function multiplies two numbers def mul(x , y): return x * y #This function divides two numbers def div(x , y): return x / y #Flag variable used for ca...
8a6026e238eba1caa1f9a6c2bdceb2d2784a468d
VantasHe/MLSOM_PD
/test.py
1,168
3.890625
4
import nltk # Import nltk. See www.nltk.org/install.html from nltk.corpus import wordnet as wn # Import WordNet def main(): # Define main function word1 = input('Word1:') # Get input from terminal word2 = input('Word2:') print(cal_similarity(word1, word2)) # Call 'noun_similarity' function and p...
df585dc87cd99c226216f9ad8fec2d2410e5e037
kittytian/learningfishcpy3
/48example.py
796
3.671875
4
''' 一个容器如果是迭代器,那就必须实现__iter__()魔法方法,这个方法实际上就是返回迭代器本身。 接下来重点是要实现的是__next__()魔法方法,因为它决定了迭代的规则 斐波那契数列 需要两个因子 所以在init初始化里面定义一个a一个b ''' class Fibs: def __init__(self): self.a = 0 self.b = 1 #下一个值等于前两个和 def __iter__(self): return self #返回本身 本身是个迭代器 def __next__(self): self.a, sel...
97862197e15c57c499a8abf7302908d86b38ecdf
kittytian/learningfishcpy3
/digui2.py
1,939
4.09375
4
#回文联 def is_palindrome(n, start, end): # 定义一个函数,三个形参。n为整个字符串内容,start为开始索引位置,end为末尾索引位置。 if start > end: # 如果 start的索引大于末尾索引位置的时,返回真值,表示已经判定过整个字符串了,一开始我也一脸懵逼,后来仔细想想明白了: # 假定字符串有五个长度[0,5],(最好在纸上写下0 1 2 3 4 五个数字) # 当开始索引[2]=末尾索引[2]的时候,双方都指在中间数2这个位置的时候,就已经检查完毕,那为什么要判定大于的情况呢? # 假定字符串有四个长度[0,...
7337c033becfb2c6c22daa18f54df4141ff804ac
kittytian/learningfishcpy3
/33.3.py
1,904
4.5
4
''' 2. 尝试一个新的函数 int_input(),当用户输入整数的时候正常返回,否则提示出错并要求重新输入。% 程序实现如图: 请教1: int_input("请输入一个整数:") 这一句括号里的即是一个形参又是一个输入?为什么? 这一句的括号里不是形参,是实参,传递给了int_input函数 它并不是一个输入,能够作为输入是因为int_input函数中调用了input函数,才有了输入的功能 请教2: def int_input(prompt=''): 这里的我用(prompt)和(prompt='')的结果是一样的,他们有区别吗?如果是(prompt='')的话是什么意思? 第一种(prompt)并...
9a509d327d55321e718d06c9fc3ca63f788c96fc
kittytian/learningfishcpy3
/31天气查询.py
1,570
3.765625
4
#31课课堂演示 把原来的city这个字典变成pkl文件 然后加载进来 import urllib.request import json import pickle #建立城市字典 把pkl文件载入 pickle_file = open('city_data.pkl', 'rb') city = pickle.load(pickle_file) password=input('请输入城市:') name1=city[password] header = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chro...
bb253f977f19bc69c71741e10e2d9f6be1191eea
kittytian/learningfishcpy3
/16.4.py
642
4.21875
4
''' 哎呀呀,现在的小屁孩太调皮了,邻居家的孩子淘气,把小甲鱼刚写好的代码画了个图案, 麻烦各位鱼油恢复下啊,另外这家伙画的是神马吗?怎么那么眼熟啊!?? 自己写的时候注意点 循环 还有判断!!一定要细心 会写 ''' name = input('请输入待查找的用户名:') score = [['米兔', 85], ['黑夜', 80], ['小布丁', 65], ['娃娃', 95], ['意境', 90]] flag = False for each in score:#遍历 if name in each: print(name + '的得分是:', each[1]) flag = ...
3817b27e6c6fb3d83cf5b52927ec3566c075451b
kittytian/learningfishcpy3
/23.1.py
664
4.0625
4
''' 1. 写一个函数get_digits(n),将参数n分解出每个位的数字并按顺序存放到列表中。 举例:get_digits(12345) ==> [1, 2, 3, 4, 5] 看了下答案解题思路:利用除以10取余数的方式,每次调用get_digits(n//10),并将余数存放到列表中即可。要注意的是结束条件设置正确。 自己写: def get_digits(n): list1 = [] if n: list1.append(n % 10) get_digits(n // 10) print(list1) get_digits(12345) 输出[] [1] ...
33d0681848619697f3236def10951be9751c43ce
kittytian/learningfishcpy3
/17.0.py
498
4.53125
5
''' 编写一个函数power()模拟内建函数pow(),即power(x, y)为计算并返回x的y次幂的值 递归(22课课后题0))和非递归法 def power(x, y): return x ** y print(power(2,3)) 看了答案发现 人家的意思是不用**幂函数 ''' ''' def power(x, y): result = 1 for i in range(y): result *= x return result print(power(2, 3)) ''' def power(x,y): if y: ret...
032358bb5bd38a079f8c5f0afff079648242fa08
kittytian/learningfishcpy3
/42.1.py
781
4.03125
4
''' 1. 移位操作符是应用于二进制操作数的,现在需要你定义一个新的类 Nstr,也支持移位操作符的运算: #>>> a = Nstr('I love FishC.com!') #>>> a << 3 'ove FishC.com!I l' #>>> a >> 3 'om!I love FishC.c' 字符串切片!! class Nstr(str): def __lshift__(self, other): return self[other:] + self[:other] def __rshift__(self, other): return self[-other:] +...
ad7e9ef9966439a410c7ab821da2a5ce4c025015
kittytian/learningfishcpy3
/42.2.py
1,370
3.984375
4
''' 2. 定义一个类 Nstr,当该类的实例对象间发生的加、减、乘、除运算时,将该对象的所有字符串的 ASCII 码之和进行计算: #>>> a = Nstr('FishC') #>>> b = Nstr('love') #>>> a + b 899 #>>> a - b 23 #>>> a * b 201918 #>>> a / b 1.052511415525114 #>>> a // b 1 和41课第2题一样 class Nstr(int): def __new__(cls, arg=0): if isinstance(arg,str):# 如果arg是字符串 tot...
d424d0bf42f28ec2617309e4bcf68dbe66cabd20
kittytian/learningfishcpy3
/36.0.py
404
3.890625
4
''' 0. 按照以下提示尝试定义一个 Person 类并生成类实例对象。 属性:姓名(默认姓名为“小甲鱼”) 方法:打印姓名 提示:方法中对属性的引用形式需加上 self,如 self.name ''' class Person: #属性:姓名(默认姓名为“小甲鱼”) name = '小甲鱼' #方法:打印姓名 def print_name(self): print(self.name)
d4ce6c189534e9f21e702ea84f27cc47de1836fa
kittytian/learningfishcpy3
/factorial_1.py
516
4.09375
4
''' 写一个求阶乘的函数 ---正整数阶乘指从1乘以2乘以3乘以4一直乘到所要求的数。 ---例如所给的数是5,则阶乘式是1×2×3×4×5,得到的积是120,所以120就是4的阶乘 以下是非递归版本 ''' def factorial(n): result = n #注意初始值是n for i in range(1, n): #因为范围是1到n-1 result *= i return result number = int(input('请输入一个正整数:')) result = factorial(number) print("%d 的阶乘是:%d" % (number, re...
8eec822dd11b1f6f1f4453b9a2e2fe40dbfd5cbf
michalmaj/programowanie_aplikacji_w_jezyku_python
/wyk_1/wyk_1_tekst.py
846
3.90625
4
# tak pisząc jest probem, bo każdorazowa zmiana imienia i wieku musi nastąpić w każdym prinie print("był sobie mężczyzna i nazywał się Kłentin") print("miał 55 lat") print("bardzo lubił imie Kłentin") print("ale nie lubił, że ma 55 lat") # pierwsza wersja: utworzenie zmiennych i ich modyfikacja imie = "Kłentin" wiek =...
302ecbdb31271cbb404791fd4e69f94c8774a54a
michalmaj/programowanie_aplikacji_w_jezyku_python
/wyk_3/wyk_3_zip_unzip.py
1,056
4.09375
4
# "Odpakowywanie" (unzip): lista = [1, 2] a, b = lista # a = lista[0], b = lista[1] print(a, b) # splat (inaczej asterisk): x = [1, 2, 3] print(x) # drukuje listę (1 argument) print(*x) # drukuje "rozpakowaną" listę (3 argumenty) print(x[0], x[1], x[2]) # równoważny zapis x = "Python" print(x) print(*x) # zip/unzip ...
18480bdc8d7713d23c6cce7e1e095b53f77cf4f1
Jaydenzk/DS-Unit-3-Sprint-2-SQL-and-Databases
/module2-sql-for-analysis/insert_titanic.py
1,640
3.921875
4
import pandas as pd import psycopg2 import sqlite3 #Reproduce demopostgres lecture #Extract data from csv df = pd.read_csv("titanic.csv") df['Name'] = df['Name'].str.replace("'", " ") # Make sqlite3 file and Connect to get cursor conn = sqlite3.connect('titanic.sqlite3') curs = conn.cursor() # data fr...
6963e68980e6a7b1c0ea2e50c6b62b5237cf5b42
Julie-H/GoogleChallenge
/GoogleChallenge_J.py
3,612
3.53125
4
# -*- coding: utf-8 -*- """ Created on Sat Aug 13 19:20:33 2016 @author: Damien """ # -*- coding: utf-8 -*- """ Created on Sat Aug 13 14:21:25 2016 @author: Julie """ import string def listOptimise(positions, termsList): while len(positions[termsList[0]])>1: #Remove the position of the 1st item of the l...
b1565d007d1eebd18b9eef56747f11b686efd19b
swissmurali/Python-
/myex/exc1.py
254
3.65625
4
print "I will now count my chickens:" print "Hens", 15 + 15 / 3 print "Roosters", 50 - 20 * 2 % 4 print "Now I will count the eggs:" print 5 + 5 + 1 - 2 + 3 / 1 * 2 print "Is it true that 3 + 2 < 5 - 7?" print 3 + 2 < 5 - 6 print "Is it greater?", 5 > 4
efd17d8216ea0b7848b07238bef557c189514b32
PavanGupta01/pythonTraining
/class/id_exp.py
397
3.578125
4
__author__ = 'pavang' __Date___ = '' import copy class Point: def __init( self, x=0, y=0): self.x = x self.y = y def __del__(self): class_name = self.__class__.__name__ print(class_name, "destroyed") pt1 = Point() pt2 = copy.copy(pt1) pt3 = pt1 print(id(pt1), id(pt2), id(pt3))...
035e5ba36bfcb82b444e78e55a80bc4c30a0b5a5
PavanGupta01/pythonTraining
/scope/scope_eclosing.py
543
3.578125
4
__author__ = 'pavang' __Date___ = '' X = 10 # Global scope name: not used def f1(): # global X # X = 20 # Enclosing def local def f2(): nonlocal X # global X X = 30 print('f2: ' + str(X)) ...
4d1455a28a83758176391f13a392f9590d2c10ab
ahmedzaabal/Python-Demos
/functions.py
796
3.984375
4
from datetime import datetime #this is a functions current date and time #custom messages # def print_time(task_name): # print(task_name) # print(datetime.now()) # print() # first_name = "Ahmed" # print_time("task is done") # for x in range(0, 10): # print(x) # print_time("Task is done") def ge...
0067a705e03144ed487716e4e6e38fa69be4a539
zain101/AI_Pracs
/programs/src/best_first_n_queens.py
2,578
3.890625
4
import heapq import random, copy from os import sys, path visited=[] class MYPriority_Q(object): """docstring for MYPriority_Q""" def __init__(self): self.heap = [] def add(self, m): if (m.values(), m) not in self.heap: heapq.heappush(self.heap, (m.values(), m)) def get(self)...
d37b0464e97f61aa1cb3637fdaf4f76f0ccd3009
eugengh/listainclasa
/inclasa.py
617
3.625
4
with open("lista.txt", "r")as f: x=list(eval(f.readline())) x.sort(reverse=True) y=sorted(x) with open("output.txt", "w") as f: f.write("Lista: "+ str(x) +"\n") f.write("Lista sortata "+str(y)+"\n") f.write("Lista sortata iners" +str(x)+"\n") f.write("Numarul de elemente din lista: " + str(l...
36f624bddc0a623ecc9123049f1e1a14186217dd
githubfun/LPTHW
/CodingBat/front3.py
300
3.90625
4
def front3(str): if len(str) < 3: return str * 3 else: return str[0:3] * 3 print "'' gives ", front3('') print "'Java' gives ", front3('Java') print "'Chocolate' gives ", front3('Chocolate') print "'abc' gives ", front3('abc') print "'oz' gives ", front3('oz') print "'m' gives ", front3('m')
4e8b2c18ebf0d7793c7be7dc2830842f26535ab1
githubfun/LPTHW
/PythonTheHardWay/ex14-ec.py
1,061
4.25
4
# Modified for Exercise 14 Extra Credit: # - Change the 'prompt' to something else. # - Add another argument and use it. from sys import argv script, user_name, company_name = argv prompt = 'Please answer: ' print "Hi %s from %s! I'm the %s script." % (user_name, company_name, script) print "I'd like to ask you a few...
517b3ded388be8ca065a4af822aeb74b991d6036
githubfun/LPTHW
/CodingBat/cat_dog_alt.py
226
3.640625
4
def cat_dog(str): return str.count("cat") == str.count("dog") print "cat_dog('catdog') is ", cat_dog('catdog') print "cat_dog('catcat') is ", cat_dog('catcat') print "cat_dog('1cat1cadodog') is ", cat_dog('1cat1cadodog')
cfd0643d9683222a28b2325859a7108f0bca2a74
githubfun/LPTHW
/PythonTheHardWay/ex03-ec05.py
2,017
3.84375
4
# This version uses floating-point calculations to insure accuracy to two places (sufficient for the formulas). # The first line of executable code prints a statment (the stuff contained between the quotes) to the screen. print "I will now count my chickens:" # Next we print the word "Hens" followed by a space, then t...
3b76da959defc159b101c26b32a8d256fb321ebc
githubfun/LPTHW
/CodingBat/make_out_word.py
350
3.859375
4
def make_out_word(out, word): front_out = out[:2] back_out = out[2:] return front_out + word + back_out print "make_out_word('<<>>', 'Yay') yields ", make_out_word('<<>>', 'Yay') print "make_out_word('<<>>', 'WooHoo') yields ", make_out_word('<<>>', 'WooHoo') print "make_out_word('[[]]', 'word') yields ", ...
f59a0e720d2f4cfe8a03948c6eda34746f7865b2
githubfun/LPTHW
/CodingBat/refactoring/sum13_after.py
503
3.890625
4
def sum13(nums): total = 0 i = 0 r = len(nums) while i < r: if nums[i] == 13: i += 2 else: total += nums[i] i += 1 return total print "sum13([1, 2, 2, 1]) is ", sum13([1, 2, 2, 1]) print "sum13([1, 1]) is ", sum13([1, 1]) print "sum13([1, 2, 2, 1,...
b188bceeaf7d88b547fc90b891c0ef8edc1bc9ab
githubfun/LPTHW
/PythonTheHardWay/projects/lexicon_project/ex49ec/lexicon.py
1,242
3.828125
4
# Modified for Exercise 48, Extra Credit def scan(sentence_to_parse): directions = {'north', 'south', 'east', 'west', 'down', 'up', 'left', 'right', 'back'} verbs = {'go', 'kill', 'eat', 'stop', 'shoot', 'take', 'get', 'talk'} stop_words = {'the', 'in', 'of', 'from', 'at', 'it', 'to', 'and'} nouns = {'bear', 'princ...
03d710fb5e89ebd20523ccaf3b1530adc509c48d
githubfun/LPTHW
/CodingBat/has22_first.py
744
3.828125
4
def has22(nums): if nums.count(2) == 0: return False elif len(nums) < 2: return False elif len(nums) == 2: return nums[0] == 2 and nums[1] == 2 else: i = 1 while i <= (len(nums) - 1): if nums[i] == 2 and (nums[i+1] == 2 or nums[i-1] == 2): ...
c8176ae9af68ecc082863620472e9fe440300668
githubfun/LPTHW
/PythonTheHardWay/ex03.py
1,688
4.1875
4
# The first line of executable code prints a statment (the stuff contained between the quotes) to the screen. print "I will now count my chickens:" # Next we print the word "Hens" followed by a space, then the result of the formula, which is analyzed 25 + (30 / 6) print "Hens", 25 + 30 / 6 # Line 7 prints right below ...
c5841693cc3e722cfe041a7469a8b43c5ce48c8d
githubfun/LPTHW
/PythonTheHardWay/ex23-avg_age.py
484
3.703125
4
# Script from Bitbucket.org, and example from someone's "Intro to Python" course. # Copied and modified as part of LPTHW Exercise 23 # Copied/modified code begins below people = [ [ 'Herb', 74 ], [ 'Carole', 71 ], [ 'Jay R.', 48 ], [ 'Missi', 46 ], [ 'Teri', 43 ], [ 'Erica', 39 ], [ 'Geoff', 34] ] # My family member...
49a5b9d687ddd5616afcf589d61c79402c9a2ff3
githubfun/LPTHW
/CodingBat/without_end.py
339
4
4
def without_end(str): if len(str) == 2: return '' else: return str[1:(len(str)-1)] print "without_end('Hello') yields ", without_end('Hello') print "without_end('java') yields ", without_end('java') print "without_end('coding') yields ", without_end('coding') print "without_end('fb') yields ",...
c25a349f58f679513bedb2c66b06c3a393265abe
shamil-t/number_to_word_converter
/num_to_word.py
1,134
3.84375
4
below_20 = ["","one","two","three","four","five","six","seven","eight","nine", "ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen", "eighteen","ninteen"]; above_20 = ["","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"] thousands = {100:'hundred', 1000:'thousand', 100000...
0318f0eb8a34086650aafdf16d7077a2bcdc2741
IAmTurbanMan/CIS104
/Week 7/Exercise2.py
290
3.890625
4
numbers = [] divisibleNumbers = [] for i in range(1, 1001): numbers.append(i) for x in numbers: if (x%7 == 0): divisibleNumbers.append(x) print("The number of integers that are divisible by 7 within the range 1-1000 is: {}".format (len(divisibleNumbers)))
39352d5c8ea9da797337d05ef58c5a6f8f77a277
AdamLosinski/AdamLosinski
/ZadanieDziennik.py
1,497
3.921875
4
#!/usr/bin/python3 from numpy import mean class Student: def __init__(self, name, lastname): self.name = name self.lastname = lastname self.grade = 0.0 self.grades = [] self.grades_weight = [] self.average = 0.00 print("New student added: " + self.name + " " + self.lastname) def new_grade(self,...
ba2a6b867c35fb80b5010ad1875020c55bb15147
Feeling-well/word-to-Excel
/wordread.py
7,428
3.828125
4
#作者:苏向阳 #平台:pycharm ,python3 #日期:2018.12.1 #功能:提取word表格内容到excel内。运行前需要先创建一个空的Excel文档,然后直接点击运行选择需要转换的word文档和需要保存到的Excel文件就行。 import win32com from win32com.client import Dispatch, constants from docx import Document from tkinter.filedialog import askopenfilename import tkinter.filedialog def select_inv(c...
cce990bf76facc021f3106a7f035c970273cb6a9
astlock/Outtalent
/Leetcode/246. Strobogrammatic Number/solution1.py
282
3.578125
4
class Solution: def isStrobogrammatic(self, num: str) -> bool: rotates = [0, 1, None, None, None, None, 9, None, 8, 6] for n1, n2 in zip(map(int, num), map(int, num[::-1])): if n1 != rotates[n2] or n2 != rotates[n1]: return False return True
33892bcfc08319b607d197a58ba3975b1e7276a5
modzozo/hack101
/week0/day0/sum_of_divisors.py
218
3.765625
4
import math def sum_of_divisors(n): sum = 0 for iterate in range(1,n+1): if n % iterate == 0: sum = sum + iterate return sum def main(): print (sum_of_divisors(100000)) if __name__== '__main__': main()
18cbc0427899c6e7ce432eb3973a261c19ee8594
modzozo/hack101
/week4/day0/manage_company.py
2,755
3.875
4
import sqlite3 class ManageCompany(): def __init__(self): self.connect = sqlite3.connect("company.db") self.connect.row_factory = sqlite3.Row self.cursor = self.connect.cursor() def list_employees(self): exe = self.cursor.execute('''SELECT id,name, position FROM employees'''...
e12728b653a685aba01bf66f0b89f2d31f8b0c6d
Flor91/Data-Science
/Code/3-numpy/np_vectorizacion.py
1,143
4.25
4
""" 1) Generemos un array de 1 dimension con 1000 elementos con distribución normal de media 5 y desvío 2, inicialicemos la semilla en el valor 4703. 2) Usando algunas de las funciones de Numpy listadas en Métodos matemáticos y estadísticos, calculemos la media y el desvío de los elementos del array que construimos en...
7f296b1df2cfc4c81fc0398de63e95725803a2b7
rafaelsantosxp/igti
/fundamentals/2/3-conditions_elif.py
416
4.09375
4
# Example_7 x = float(input('Type the first number')) y = float(input('Type the second number')) print('Type 1 to ADD') print('Type 2 to SUBTRACT') print('Type 3 to MULTIPLY') print('Type 4 to SPLIT') choice = int(input('Which one?')) if choice == 1: print(x + y) elif choice == 2: print(x - y) elif choice == ...
d80e8ce7826655dba9e228b29abcd279c6413a8c
rafaelsantosxp/igti
/fundamentals/3/4-Range.py
140
3.609375
4
# Example_Range_1 # len verify length data = input("Type a string: ") for i in range(len(data)): print((data[i])) print("End of code")
add9ea117616b03698d26bf4c200815bf241dfb6
rafaelsantosxp/igti
/fundamentals/Task-1/codigo1.py
130
3.71875
4
idade = int(input("entre com sua idade : ")) nova_idade = idade % 1 print ("no proximo ano voce tera: {} anos".format(nova_idade))
f16de759b46a7fd02f9840669f5cbd3be77fa8d3
DevBash1/PyQaver-Demos
/Time/server.py
336
3.59375
4
from time import gmtime, strftime now = strftime("%H:%M", gmtime()) if("name" in _POST): #_POST is like $_POST in PHP name = _POST["name"] if(name.strip() == ""): print("Please Enter Your Name!") else: print("Hello {}, The Server Time is {}".format(name,now)) else: print("Please En...
59b743c282501d6d5c6adaa7487a6b66ca34c24f
alf1983/gb
/1.py
481
4.03125
4
duration = input("Input duration: ") duration = int(duration) minutes = 0 hours = 0 days = 0 seconds = duration % 60 minutes = duration // 60 if minutes > 60: hours = minutes // 60 minutes = minutes % 60 if hours > 24: days = hours // 24 hours = hours % 24 if days > 0: print(days, "дней"...
1cf8de4490b02e2102d3b7337f54b707e12d3362
chase-g/euler
/euler20.py
255
3.671875
4
#Project Euler 20 #"Find the sum of the digits in the number 100!" def factorial(n): answer = 1 while(n > 0): answer = answer * n n = n - 1 return answer num = factorial(100) st = str(num) amount = 0 for i in st: amount += int(i) print(amount)
914517de052849732eda167d48859fb4ac4e5f50
xiaolinzi-xl/python_imooc
/twl/c8.py
702
3.5
4
import time def decorator(func): def wrapper(*args,**kw): print(time.time()) func(*args,**kw) return wrapper @decorator def f1(func_name): print('this is a function' + func_name) @decorator def f2(func_name1,func_name2): print('haha ' + func_name1 + ' ' + func_name2) @decorator def f...
c40082b0cff483709b8858ddfe19406e38c38446
xiaolinzi-xl/python_imooc
/eleven/c2.py
472
4.0625
4
from enum import Enum class VIP(Enum): YELLOW = 1 GREEN = 2 BLACK = 3 RED = 4 class VIP1(Enum): YELLOW = 1 GREEN = 2 BLACK = 3 RED = 4 # print(type(VIP.BLACK)) # print(VIP.BLACK.name) # print(VIP.BLACK.value) # for x in VIP: # print(x) # result = VIP.BLACK > VIP.GREEN 枚举不支持大小比较,...
f993801a82c941acf0c48eca30ab9ac52d8aa202
xiaolinzi-xl/python_imooc
/six/c1.py
292
3.9375
4
print('hello phython') # a = 2 ''' 流程控制语句 条件控制 循环控制 if else for while ''' mood = False if mood: print("go to left") else: print('go to right') print("back away") # 云服务 商业授权 a = 1 b = 2 if a > b: print('a > b') else: print('a <= b')
64bcfd97e6e23d48e5c03b0c2499c9a4c0cd92a1
britnicanale/06SoftDev
/08_lemme_flask_u_sumpn/app.py
1,354
3.6875
4
'''Britni Canale SoftDev1 pd6 K8 -- Fill Yer Flask 2018-09-19''' from flask import Flask app = Flask(__name__) @app.route("/") ##creating home page of web page def hello_world(): return "<!DOCTYPE html><html><head><title>BRITNI CANALE</title></head><body><h1> This is a website that contains some information</h1...
88f1e468de82a9f3d0fcdfab65a657fe147a8e73
kurkol/python3_spider
/基本/正则表达式/非贪婪.py
222
3.578125
4
import re content = 'Hello 1234567 Word_This is a Regex Demo' result1 = re.match('^He.*(\d+).*Demo$', content) print(result1.group(1)) result2 = re.match('^He.*?(\d+).*Demo$', content) print(result2.group(1)) c=input()
8307da4c40f4cc3ebd2e8823e31b93ac683bac0d
abrosen/classroom
/itp/spring2018/countWordBeginnings.py
510
3.6875
4
counts = {} data = open("words.txt", 'r') for line in data: line = line.strip() line = line.lower() letter = line[0:2] if letter in counts: counts[letter] = counts[letter] + 1 else: counts[letter] = 1 mostCommonLetter = "" highestCount = 0 for letter in counts: if counts[letter...
b549c9db156fd82a945a101f713d0c66a14c64f8
abrosen/classroom
/itp/spring2020/roman.py
1,147
4.125
4
roman = input("Enter a Roman Numeral:\n") value = {"I" :1, "V":5, "X":10, "L":50,"C":100,"D":500,"M":1000} def validate(roman): count = {"I" :0, "V":0, "X":0, "L":0,"C":0,"D":0,"M":0} for letter in roman: if letter not in count: return False for letter in roman: count[letter...
539eaa2d0069cee0731b57fad4ca23614b840e20
abrosen/classroom
/itp/fall2019/createImage.py
256
3.546875
4
import image win = image.ImageWin(640, 480, "Image Processing") myPic = image.EmptyImage(100,100) for x in range(myPic.getWidth()): for y in range(myPic.getHeight()): myPic.setPixel(x,y, image.Pixel(200,255,0)) myPic.draw(win) win.exit_on_click()
3793d42c3709b43cdde99b2bbe3ece027b11da14
abrosen/classroom
/itp/spring2020/pigLatin.py
919
3.8125
4
# apple -> 0 # 01234567 # xyzabcde -> 3 def findFirstVowel(word): index = len(word) - 1 for char in word: if char in "aeiou": return word.index(char) """ for index, letter in enumerate(word): if letter in "aeiou": return index """ return index d...
7324063f73376ac7ea6b139f0d1e4c98e44b193e
abrosen/classroom
/itp/spring2021/shapes.py
741
3.890625
4
import math class Triangle: def __init__(self, side1, side2, side3): self.side1 = side1 self.side2 = side2 self.side3 = side3 def __str__(self): return "triangle with sides [" + str(self.side1) +", "+ str(self.side2) + ", " +str(self.side3) + "]" def get_perimeter...
baab7e3488a58f13cc94f0395264b6dfbaa5ad45
abrosen/classroom
/itp/spring2020/scamGame1.py
743
3.578125
4
""" Nine Card Hustle: add 2 more red cards (7 red, 2 Black), shuffle and place in a 3 x 3 array. The even money bet is that you can find three cards in a straight line that are red. (up, down and diagonals count). What are the real odds? RRR BRR RBR """ import random def createDeck(): cards = "RRRRRRRBB" car...
d50e9fb5f2154082d0f81f680db428b651a8c6c1
abrosen/classroom
/itp/fall2019/nestedTurtle2.py
381
3.953125
4
import turtle bob = turtle.Turtle() bob.shape("turtle") bob.shapesize(1.5,1.5) bob.penup() def triangle(bob): for line in range(5): for _ in range(10 - line* 2): bob.forward(50) bob.stamp() bob.back(50*(10 - line *2)) bob.right(90) bob.forward(50) bob.left(90) bob.write("Hello, world how are you...
fa5d43c77ef6b01fddd71b0de9e34366ec30603d
abrosen/classroom
/itp/spring2018/turtleTest.py
216
3.609375
4
import turtle bob = turtle.Turtle() screen = turtle.Screen() bob.shape("turtle") screen.colormode(255) for x in range(20): bob.forward(20 + 10*x) bob.lt(120) bob.pencolor(10*x +50, 10*x, 0) turtle.done()
58fde0a747e1877b46b67a0e72f4d026082bb404
abrosen/classroom
/itp/spring2021/monteCarlo.py
1,186
3.640625
4
import random """ def dealHand(): deck = (list(range(1,11)) + [10,10,10]) * 4 random.shuffle(deck) return deck[0:2] TRIALS = 100000 wins = 0 for _ in range(TRIALS): hand = dealHand() if 1 in hand and 10 in hand: wins += 1 print(wins/TRIALS) """ def roll(): die1 = ["eye","eye","eye...
06879b5007d2755936133143a2cd01ace89b4481
abrosen/classroom
/itp/spring2020/forLoopsAndSequences.py
143
4.15625
4
word = 'hello' listOfNums = [1,2,3,4,5,"three"] for letter in word: print(letter) for thing in listOfNums: print(thing, type(thing))
393e44c5af61bab2155ecbad77c562da10964834
abrosen/classroom
/itp/spring2018/testRandom.py
248
3.625
4
import random num1 = 0 num2 = 0 num3 = 0 TRIALS = 3000000 for _ in range(TRIALS): num = random.randint(1,3) if num == 1: num1 += 1 elif num == 2: num2 += 1 elif num == 3: num3 += 1 print(num1,num2,num3)
6d7fb8508d9eafe5963a2f4acf4f90ada0b7aa0c
abrosen/classroom
/itp/spring2021/dateChecker.py
1,159
4.03125
4
def isLeapYear(year): # if not year % 4 == 0: return False elif year % 100 == 0: if year % 400 == 0: return True else: return False else: # divisible by 4, but not by 100 return True #def complexCalculation(x,y,z_prime,scary_greek_letter): ...
bf84516891d60a5bba8e7c37e84373931a3134bf
abrosen/classroom
/itp/spring2020/fileReadingExample.py
280
3.578125
4
data = open("shakespeare.txt","r") #print(data) countDracula = 0 countWords = 0 for line in data: words = line.split() countWords = countWords + len(words) print(words) """ if "dracula" in line.lower(): print(line) countDracula = countDracula +1 """ print(countWords)
388cac6c8c2fe26e2cb4d88584dac9dc39c45563
abrosen/classroom
/itp/spring2021/piglatin.py
758
3.953125
4
def findFirstVowel(word): vowels = 'aeiou' for index, letter in enumerate(word): if letter in vowels: return index return -1 def convertToPigLatin(word): vowelIndex = findFirstVowel(word) if vowelIndex == -1: return word elif vowelIndex == 0: # if the word starts wi...
8987b85cf884dbaa3295df110539bb1c517d7f00
abrosen/classroom
/itp/fall2019/examp.py
79
3.875
4
print("Please enter your name:") name = input() print("Your name is " + name)
e2ba774131b26bcebcd74b9074e4b17b8a21b25b
abrosen/classroom
/itp/fall2019/multiColor.py
224
3.703125
4
import turtle bob = turtle.Turtle() bob.pensize(50) colors = ["red","green","cyan","blue","purple","black","#ff00ff","brown","red", "yellow"] for color in colors: print(color) bob.color(color) bob.forward(50)
6db17e91e654e5229ccad28166264478673839d9
abrosen/classroom
/itp/spring2020/booleanExpressions.py
427
4.1875
4
print(3 > 7) print(6 == 6) print(6 != 6) weather = "sunny" temperature = 91 haveBoots = False goingToTheBeach = True if weather == "raining": print("Bring an umbrella") print(weather == "raining" and temperature < 60) if weather == "raining" and temperature < 60: print("Bring a raincoat") if (weather == "rain...
c71bc97744c8a66d17ad908ee95c7314f84525ad
abrosen/classroom
/itp/spring2022/loops functions and sequences.py
960
3.984375
4
import turtle #text = "hello there, general kenobi!" #num = 13 #lowTemps = [2,4,-8,-7,-2,-7,-2,3,4,-2] #for char in text: # print(char) #total = 0 #for temp in lowTemps: # total = total + temp #print(total) #print(len(lowTemps)) #print(total/len(lowTemps)) #print(len(text)) def drawSquare(theTurtle,size): ...
d247b9ca4d9021d7af5fb1d5960c7d183f5f774f
abrosen/classroom
/itp/summer2018/forCounting.py
243
3.921875
4
for x in range(100,0,-3): print(str(x) + "\t"+ str(x**2)) LIMIT = 100 for x in range(0,LIMIT,6): print(x) print("changing steps") print("--------------") step = 1 for x in range(0,100,step): print(x, step) step = step + 1
2aa79e8f961bed16ce1d9ff435b00ca24fa42319
abrosen/classroom
/itp/fall2020/helloname.py
133
4.09375
4
name = input("What is your name: ") print("Hello, " + name) num = input("Please enter a number and I will double it: ") print(num*2)
2f6fe3623ba1c3bb8d82de2988f6ddd9c083ee04
abrosen/classroom
/itp/recusionExamples.py
2,877
3.65625
4
import random """ 7! = 7*(6*5*4*3*2*1) = 7 * 6! = 7 *720 = 4900 + 140 6! = 6*5*4*3*2*1 = 6 * 5! = 6 * 120 = 720 5! = 120 n! = n * (n-1)! = n * (n-1) * (n-2)! 1. Recursive case n! = n*(n-1)! 2. Base case(s) 1! = 1 , 0! = 1 3. Recursive cases move toward the base case """ def factorial(n): if n == 0: ...
ace85466e4ad045a772f66faecaaca972fca924e
zen-char/DBMS-Fault-Injection-Framework
/src/utils.py
3,594
3.703125
4
""" Author: Gerard Schroder Study: Computer Science at the University of Amsterdam Date: 08-06-2016 This file contains simple json helper functions. FILE: json_functions.py USAGE: python attach_strace.py """ import io import json import hashlib import datetime as dt """ Str to time & time utilities """ #...
209d2dfd0dbb9979ad8b075d650a5f4b3f296c25
Ankita-neha/instabot
/instabot.py
6,806
3.578125
4
import requests # Here importing the requests library which is installed by using pip. APP_ACCESS_TOKEN = '1599633091.2fc0da1.63f5a1608a3e4414b4d96117bca38027' BASE_URL = 'https://api.instagram.com/v1/' def self_info(): # this is the function which fetches my instagram profile details by using api....
d673e94fa65fbb88d3af0bb0171cc9a8254e8305
djohnson67/sPython3rd
/math/io/write_sales.py
534
3.90625
4
#prompts for sales and writes to sales.txt def main(): #get number of days num_days = int(input('For how many days do you have sales? ')) #open sales file sales_file = open('sales.txt','w') for count in range(1, num_days +1): #get sales for day sales = float(input('Enter ...