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
758a91bf1eefd576051c24401423f4c6578180fa
haveano/codeacademy-python_v1
/03_Conditionals and Control Flow/02_PygLatin/06_Pop Quiz.py
603
4.21875
4
""" Pop Quiz! When you finish one part of your program, it's important to test it multiple times, using a variety of inputs. Instructions Take some time to test your current code. Try some inputs that should pass and some that should fail. Enter some strings that contain non-alphabetical characters and an empty string...
6efae81bdbee61a5e960c0bce1039a31a48c3bb2
haveano/codeacademy-python_v1
/11_Introduction to Classes/01_Introduction to Classes/03_Classier Classes.py
967
4.46875
4
""" Classier Classes We'd like our classes to do more than... well, nothing, so we'll have to replace our pass with something else. You may have noticed in our example back in the first exercise that we started our class definition off with an odd-looking function: __init__(). This function is required for classes, an...
ac257b941ab242c0a3e7da941200b2a757f50be2
haveano/codeacademy-python_v1
/03_Conditionals and Control Flow/02_PygLatin/11_Testing, Testing, is This Thing On.py
870
4.03125
4
""" Testing, Testing, is This Thing On? Yay! You should have a fully functioning Pig Latin translator. Test your code thorougly to be sure everything is working smoothly. You'll also want to take out any print statements you were using to help debug intermediate steps of your code. Now might be a good time to add some...
b844dfedfd2b5f4f7f5c6c71d64b978cdde3e2f4
haveano/codeacademy-python_v1
/02_Strings and Console Output/02_Date and Time/01_The datetime Library.py
287
4.03125
4
""" The datetime Library A lot of times you want to keep track of when something happened. We can do so in Python using datetime. Here we'll use datetime to print the date and time in a nice format. Instructions Click Save & Submit Code to continue. """ from datetime import datetime
3c6f0c6039e2a9d52e415b7b235adda8f27bb3e6
haveano/codeacademy-python_v1
/03_Conditionals and Control Flow/02_PygLatin/01_Break It Down.py
677
4.25
4
""" Break It Down Now let's take what we've learned so far and write a Pig Latin translator. Pig Latin is a language game, where you move the first letter of the word to the end and add "ay." So "Python" becomes "ythonpay." To write a Pig Latin translator in Python, here are the steps we'll need to take: Ask the user...
26c8ad332a82464bb4e423fc0f801e8f709297f0
haveano/codeacademy-python_v1
/03_Conditionals and Control Flow/02_PygLatin/09_Move it on Back.py
672
4.21875
4
""" Move it on Back Now that we have the first letter stored, we need to add both the letter and the string stored in pyg to the end of the original string. Remember how to concatenate (i.e. add) strings together? greeting = "Hello " name = "D. Y." welcome = greeting + name Instructions On a new line after where you ...
ed920d881c1a5fa00c6137a741e648894730e987
haveano/codeacademy-python_v1
/10_Advanced Topics in Python/01_Advanced Topics in Python/04_Building Lists.py
672
4.625
5
""" Building Lists Let's say you wanted to build a list of the numbers from 0 to 50 (inclusive). We could do this pretty easily: my_list = range(51) But what if we wanted to generate a list according to some logic—for example, a list of all the even numbers from 0 to 50? Python's answer to this is the list comprehens...
87476d33bbd28688c9eca22541842eda77c5cf44
Akash2918/PPL
/Assignment1/q9.py
903
4.28125
4
print("\nFinding first 10 Harmonic Divisor Numbers :\n") """def floating(n) : x = 1 s = 0 for i in n : x = x * i for i in n: s = s + x/i print("The value of s is : ", s) return s/x """ def calculate(n) : # function that calculates harmonic sum and returns its division with total number of divisors s =...
22bad9dbff13ff2cc7ed83466621d11e6cf1fc28
Akash2918/PPL
/Assignment1/q5.py
352
4
4
#print("Enter the page numbers : \n") n = int(raw_input("Enter the total number of pages : ")) i = 1 print("Enter the page numbers and press 0 to exit \n") m = [ ] while i != 0 : i = int(raw_input()) if i != 0 : m.append(i) #i = i + 1 print(m) print("The page numbers not in the list : ") for x in range(1, n+1) :...
62dfcc8347fded08bd5b1a98e8c8364e6559422e
gooners006/hangman-the-game
/main.py
859
3.84375
4
import time import random words_bank = [ "january", "border", "image", "film", "promise", "kids", "lungs", "doll", "rhyme", "damage", "plants", ] def start_game(): word = random.choice(words_bank) def init_game(): time.sleep(1) print("Let's play Hangman!") ...
0a141b427641e1ca31e5844bcb3d663d90815aaf
Alexa-PL/-Python_dz1
/dz_1.1/step_2.py
138
3.578125
4
a = 2 b = 4 c = 3 summa1 = a+b+c print("summa1=",summa1) x = input("Введите число x ") print("x=",x) r = a+b+c-int(x) print(r)
9744996df1f268a9f328ba1fd060515ebfe72997
anaballe/Competitive_Programming
/Python programs/str1.py
203
3.859375
4
# to arrange words in lexiographically manner in a sentence print('enter the string') s=input() tac=s.split() tac.sort() new_s='' for i in range(0,int(len(tac))): new_s=new_s+tac[i]+' ' print(new_s)
04aa84c87a26ed7a33a4fa50b426bce5c7c7acdd
alkesh-srivastava/enpm661-p3-phase3
/Cost.py
1,459
3.765625
4
import matplotlib.pyplot as plt import random import math def roundingpoint(point): # It rounds the floating point number to a float point of 3 significant figure after decimal. if point[0].is_integer() and point[1].is_integer() or (point[0] - 0.5).is_integer() and ( point[1] - 0.5).is_int...
ae3779ddf8e94c5c649ea8297d74eff495e51e0b
liuleee/python_base
/day04/07-函数的文档说明.py
299
4
4
# -*- coding: utf-8 -*- #计算数字和的函数 def sum_num(num1,num2): ''' 计算数字和的函数 :param num1: 第一个数字 :param num2: 第二个函数 :return: 返回值 ''' result = num1 + num2 return result value = sum_num(1,2) print(value) help(sum_num)
5c7696d5516e17dad77789fd3f7e994b3a4a8c12
liuleee/python_base
/day06/02-魔方方法-del-.py
786
3.71875
4
# -*- coding:utf-8 -*- import time #__del__ :当对象释放的时候会自动调用__del__方法 #1.程序退出,程序中使用的对象全部销毁 #2.当前对象的内存地址没有变量使用的时候,那么对象会销毁 class Person(object): def __init__(self,name,age): self.name = name self.age = age def __del__(self): print("对象释放了",self) #第一种情况,程序退出,程序中使用的对象全部销毁 #创建对象 person_xiao = P...
e0b4e15b11963d9db6e8640a210f4740888bc11b
liuleee/python_base
/day02/10-for循环的使用.py
982
4.3125
4
# -*- coding:utf-8 -*- #获取容器类型(字符串,列表,元组,字典,set)中每个数据使用for循环最简单 # my_str = 'abc' # for value in my_str: # print(value) # my_list = ['apple','peach','banana','pearl'] # for value in my_list: # print(value) #循环遍历的时候下标和数据都需要,可以使用enumerate my_list = enumerate(['apple','peach','banana','pearl']) # for value in m...
c31ba53f5e8483d494ff05b48a933f0b7678c39f
liuleee/python_base
/day05/06-if判断的拓展.py
556
3.671875
4
# -*- coding:utf-8 -*- #if判:bool,数字,容器(字符串,列表,元组,字典,集合),None(空值) if True: print('条件成立') #数字类型:非o即真,只要不是0就是成立的 if 1: print('success!') # if 0: # print('success!') #容器判断的时候,如果容器类型里面有数据那么表示条件成立,否则条件不成立 if "xxx": print("ddd") if [1,2]: print('nnnnn') if {'name':'liu'}: print('dddd') #非None条件成立,None...
98d09ec5fab1aa57644c26883764e7a69eefac9d
liuleee/python_base
/day04/16-函数使用多个装饰器.py
368
3.609375
4
# -*- coding: utf-8 -*- def decorator1(func): def inner():#inner其实就是你封装传入函数的代码 print('_'*30) func() return inner def decorator2(func): def inner():#inner其实就是你封装传入函数的代码 print('_*'*30) func() return inner @decorator1 @decorator2 def show(): print('AAA') show()
41c7aea00d921911323772600e471b7850938784
liuleee/python_base
/day04/12-装饰器.py
619
3.734375
4
# -*- coding: utf-8 -*- #装饰器本质上就是一个函数,可以给原函数的功能上进行拓展,这样的好处是,不改变原函数的定义及调用的操作 #装饰器——》通过闭包完成的 def decorator(new_func): def inner(): print('-'*10) new_func() #返回的函数是闭包 return inner #在使用@decorator的时候装饰器的代码就会执行# show = decorator(show) @decorator #使用装饰器,装饰下面的函数 def show(): print('aaaaaaa'...
48984c6ed7443214e935a6f01b7e89125b291874
liuleee/python_base
/day04/03-可变类型和不可变类型.py
799
3.9375
4
# -*- coding:utf-8 -*- #可变类型:可以在原有数据的基础上对数据进行修改(添加或者删除或者修改数据),修改后内存地址不变 #不可变类型:不能在原有数据的基础上对数据进行修改,当然直接赋值一个新值,那么内存地址会发生改变 #可变类型:列表,集合,字典,对数据进行修改后内存地址不变 #不可变类型:字符串,数字,元组,不能再原有数据的基础上对数据进行修改 my_list = [1,5,6] #查看内存地址 print(id(my_list)) my_list[0] = 2 print(id(my_list)) my_tuple = (2,5,8) print(id(my_tuple)) my_tuple ...
0a295bbe24347d24bc5f2195bc631b2f5c544358
liuleee/python_base
/day03/15-匿名函数.py
871
4
4
# -*- coding:utf-8 -*- #匿名函数:使用lambda关键字定义的匿名函数 # lambda 定义参数 : 返回值 result = (lambda x,y : x+y)(1,2) print(result) # 一般使用变量保存匿名函数 func = lambda x,y : x*y result = func(1,2) print(result) #匿名函数的应用场景,简化代码 def is_os(num): if num % 2 == 0: return True else: return False result = is_os(1) pri...
fd9c863f8e4438d0571d6b74e86e87e3e0f7c3cf
liuleee/python_base
/day01/07-输出和输入.py
454
4.09375
4
# -*- coding: utf-8 -*- print("Hello world") my_str1 = 'hello' my_str2 = 'world' #提示:输出多个参数,多个参数之间默认使用空格做分隔 print(my_str1,my_str2) print(my_str1,my_str2,sep='&') #print默认输出信息后会换行 print('hello',end=' ') print('world') print('换行\nhh') #输入:py3里面使用input name = input('请输入您的姓名') #提示:input返回的数据都是字符串 print(name, type(nam...
eba7e07b2ee51b4c70ed829acde256362afc7494
liuleee/python_base
/day01/06-数据类型转换.py
556
4.21875
4
# -*- coding: utf-8 -*- num = 10 my_str = '10' # 把字符串转为int类型 num2 = int(my_str) # print(type(num2)) s = num + num2 # print(s) my_float_str = '3.14' print(type(my_float_str)) num3 = float(my_float_str) print(type(num3)) num4 = 4.55 # 浮点数转int型时,只取整数 num5 = int(num4) print(num5) # eval:获取字符串中的 原始 数据 my_str = '5' v...
954867db053a71a2747dbc521e5f4cfab21ef2c1
bibilal/Practise
/Python/argv_stdin.py
786
3.5625
4
# ^_^ coding:utf8 ^_^ #! /usr/bin/python2 #! /usr/bin/python3 ''' 同时从命令行参数和标准输入读取输入 ``` echo -e 'a\nb\nc' | python argv_stdin.py ``` 和 ``` python argv_stdin.py a b c ``` 的输出都是 ``` inputline: a inputline: b inputline: c ``` ''' import sys import select def input_from_stdin(): targets = list() while sys.stdin...
c58dfcb175e94613d813570082c391b6a90f8423
bibilal/Practise
/PythonMachineLearningCookbook/Chapter08/operating_on_data.py
909
3.515625
4
# ^_^ coding:utf-8 ^_^ import numpy as np import pandas as pd import matplotlib.pyplot as plt from convert_to_timeseries import convert_data_to_timeseries # 输入数据文件 input_file = 'data_timeseries.txt' # 加载输入数据 data1 = convert_data_to_timeseries(input_file, 2) data2 = convert_data_to_timeseries(input_file, 3) # 将数...
d407815bdbbb32e8f1e295b50f80d222338e5e2b
ankitandel/function.py
/8h.py
162
3.6875
4
# write a python program to detect the number of local variable declared in a function .sample output 3 def var(): x=10 y=20 c=x+y print(c) var()
2b229803bcb9a175dac4b1b85e2b712c77adba7c
ankitandel/function.py
/4h.py
311
4.1875
4
# write a python program to print the even numbers from a given list.[1,2,3,4,5,6,7,8,9] def is_even_num(b): i=0 while i<=len(b): if i%2==0: print("even number",i,end="") else: print("odd number",i) i=i+1 b=[1,2,3,4,5,6,7,8,9] is_even_num(b)
730e807801f279a221f97727d987096d9eca56a9
ankitandel/function.py
/hackthon.py
98
3.796875
4
# write a python function to find the max of three numbers. list=[4,6,9,44,32,56] print(max(list))
71b8bb1e442cdd596bed2a337a52f0e2698e38ba
ankitandel/function.py
/ques6.py
140
3.546875
4
def number(): a=[1,2,3,4,5,6,7,8,9,10] i=0 sum=0 while i<len(a): sum=sum+a[i] i=i+1 print(sum) number()
d83018f0f91ff745c700dd7cc7a9e6aa96b43d9c
rexlifei/LeetCode
/142_linked-list-cycle-ii(环形链表 II).py
1,017
3.546875
4
''' https://leetcode-cn.com/problems/linked-list-cycle-ii/ 判断链表是否有环,并找到环起点 用快慢指针,首先判断是否有环,然后找起点 ''' # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def detectCycle(self, head): """ ...
3e597b559e0896e61718db4fdff1ae9768cb9377
Hugens25/School-Projects
/Python/NestedList.py
753
3.90625
4
students = [] student_names = [] student_scores = [] second_place = [] names = ["Harsh","Beria","Varun","Kakunami","Vikas"] scores = [20,20,19,19,21] for i in range(5): name = names[i] score = scores[i] students.append([name, score]) student_names.append(name) student_scores.append(score) minimum...
44935d08378e3ea009eb45fb697b0e3aa0140ecc
Hugens25/School-Projects
/Python/lesseroftwoevens.py
91
3.84375
4
a = 2 b = 5 if a % 2 == 0 and b % 2 == 0: print (min(a,b)) else: print (max(a,b))
e07c1cc2d44f19fb2995e20042019957ba213217
Hugens25/School-Projects
/Python/oldmcdonald.py
79
3.625
4
word = 'macdonald' print (word[0].upper()+word[1:3]+word[3].upper()+word[4:])
6a0ba96a22772cde37ee3ba953f1e622f7750b27
Hugens25/School-Projects
/Python/triathlon.py
1,269
3.796875
4
from operator import itemgetter, attrgetter num_races = int(input()) results = [] def sort_list(l): for item in l: item = tup(item) sorted(l, key=lambda item: item[3]) return l for i in range(num_races): competitors = [] race_info = input().split() num_runners = int(race_info[0]) ...
f41d4f5dc63c6c3cb6b4d01b783869808a17e26e
Hugens25/School-Projects
/Python/stack.py
592
3.9375
4
class Stack: def __init__(self): self.count = 0 self.stack = [] def push(self, a): self.stack.insert(0, a) self.count += 1 def pop(self): removed_value = self.stack[0] self.stack.pop(0) self.count -= 1 return removed_value def peek(self...
6187a00a20864c19ab9d9de6689142a447b108c2
Hugens25/School-Projects
/Python/split.py
150
4.21875
4
str = 'Print only the words that start with s in this sentence' strlist = str.split() for string in strlist: if string[0] == 's': print(string)
9a4d68ca45b89958797d21ea64fc12c98d3a1ecb
RZW-A-A/Libraray-Management
/userinterface.py
2,233
3.71875
4
from librarymgmt import Book class Booklibrary: booklist = [] def addbooks(self): print() print("***Enter Book detail***") print() bookid = int(input("1. Enter Book Id : ")) bookname = input("2. Enter Book Name : ") bookprice = int(input("3. Enter Book Price : ")) bookauthor = input("4. Enter ...
483922fac59985c5101afc58c4d82335ed23319d
Destroyer4114/Python
/ot.txt
1,589
3.859375
4
def find_shortest_path(graph, start, end, path =[]): path = path + [start] if start == end: return path shortest = None for node in graph[start]: if node not in path: newpath = find_shortest_path(graph, node, end, path) if newpath: ...
79c84b2a02be2f608cf6a3228de59eebb8a27460
Mokui/M4105C-PythonProject
/Equipment.py
769
3.90625
4
#/usr/bin/python3 """ Equipment class file """ class Equipment(object): """ Equipments are the objects available in an installation and usefull to an activity. An Equipment is defined by an id (who is the primary key in the DataBase) a name, an installation and a list of activities """ def __i...
ca97a3d375795e9e0b70f036c20e39305a1e8ad0
abhijeet-venom/twowaits-twoc
/Day 1/program2.py
186
4.15625
4
number = float(input("Enter the number: ")) sqrt = number ** 0.5 print("Square root of", number ,"is", sqrt) #code contributed by Aman Mishra (https://github.com/amanmishra2391), 2nd IT AITH
83b68260952aff4bb11b1376f4fbd999fe272a03
smitdoshi/MS_Course_PythonProgramming
/Assignment1_ans.py
7,548
3.703125
4
# Author SMIT N DOSHI # Tried to make using MVC (Model View Controller) DESIGN PATTERN # FUNCTIONS FOR DISPLAYING VALUES def displaytMainMenu(): print("----------------------------------------------------") print("Select category:") print("1. Drink") print("2. Snacks") print("3. Exit") def d...
6a72352d697c6ce1570a2bdf1c580bcaebd72dde
bbaumg/Sensor
/testoledv2.py
1,291
3.546875
4
# OLEDtext.py # This Python code is meant for use with the Raspberry Pi and Adafruit's monochrome displays! # This program is the simplest in the whole repo. All it does is print 3 'Hello!'s in various forms on the OLED display. # It illustrates how to change the font size and positioning of text on the OLED... As we...
ef098803a2926ec1cfc5345f4896c61d5262849b
nicolasmunozupb/LaboratorioRepeticionRemoto
/positivos.py
314
3.71875
4
pares=0 for x in range(0,99999999999999999999999999999999999999999999): x=int(input("digite un numero")) if x % 2 ==0: pares = pares + 1 else: break print("el programa se detuvo por el ingreso de un numero impar; u la cantidd de numeros pares fue:", pares)
a4d8ba02d2245f52b07fdf628a8609b6580539fe
fuzzy69/my
/my/core/misc/stats.py
2,215
4.03125
4
from datetime import datetime from functools import wraps from time import time from typing import Tuple, AnyStr def time_it(func): """Measure function execution time""" @wraps(func) def wrapper(*args, **kwargs): start_time = time() result = func(*args, **kwargs) elapsed_time = in...
de5ca10490b04698e3208def472f5df822de15d1
AlvinNgo123/FinancialBudgetAdvisor
/my_module/test_functions.py
9,712
3.796875
4
"""Test for my functions. """ import unittest.mock as mock import functions as f ## ## @mock.patch('functions.input', side_effect=['alvin', 'Alvin Ngo', '18', 'A18 COGS','']) def test_say_intro_get_name(mock_choice): """Tests for the say_intro_get_name function""" # Test with just a first name name = f.say_intro_...
253230ce2d240eaff7aee23c949b7e9a3824ecbd
maringantis/ObjectOrientedProgrammingCodes
/ObjectOrientedProgrammingCodes-Python/src/MagicNumbers.py
597
3.65625
4
def arithmatic_boggle(magic_number, numbers): index = 0 tmp = 0 #if len(numbers) == 0 and magic_number == 0: # return True if isMagicNumber(magic_number, numbers, index, tmp): print('Magic Number') return True else: print('Not a Magic Number') return False def...
21cced07ce4cf5abbcf22728b0a885585101320c
kavisha-nethmini/Hacktoberfest2020
/python codes/DoubleBasePalindrome.py
733
4.15625
4
#Problem statement: The decimal number, 585 is equal to 1001001001 in binary. #And both are palindromes. Such a number is called a double-base palindrome. #Write a function that takes a decimal number n and checks if it's binary equivalent and itself are palindromes. #The function should return True if n is a double-ba...
ddf3ad731d90640acd04db08b215b3c0e2fe6d53
zhenyuyan/Dynamic-Programming-BWT
/questions/test2.py
1,388
3.65625
4
def rotate(s): i = 0 l = [s] while i < len(s) - 1: s = s[len(s) - 1] + s[0:len(s)-1] l.append(s) i = i + 1 return l def bwt_encode(s): """Burrows-Wheeler Transform Args: s, string, which must not contain '{' or '}' Returns: BWT(s), which contains '{' and '}' """ ...
09675a481a7ef5165077f56818707b3a55b0b7c3
dmalinovsky/kindle-hyphens
/hyphenator.py
3,994
3.6875
4
#!/usr/bin/env python #coding=utf-8 """ Hyphenation, using Frank Liang's algorithm. Ned Batchelder, July 2007. This Python code is in the public domain. Not English hyphenation patterns and code changes added by Denis Malinovsky, 2012-2013. """ from importlib import import_module import re class Hyphenator: def...
fa4062ca2eb80c11819d607cff84dafd8b31dc9e
sadrayan/connected-vehicle-iot
/src/Servo.py
828
3.546875
4
import Adafruit_PCA9685 class Servo: def __init__(self): self.angleMin=18 self.angleMax=162 self.pwm = Adafruit_PCA9685.PCA9685() self.pwm.set_pwm_freq(50) # Set the cycle frequency of PWM #Convert the input angle to the value of pca9685 def map(self,value,...
eca59072ea32cf20f230fbf4d983b29a3e4b05cc
jatinkrmalik/advent-of-code-2017
/day5/mazeofTwistyTrampolines.py
1,591
3.953125
4
def convertToList(ip): ''' Function to read the file, split on each new line, convert to list and ignore the last blank and then convert each element to int ''' return list(map(int, ip.read().split('\n')[:-1])) def mazeRunner_part1(steps): ''' Function to play the game - Part 1 ''' cur...
c737f26733658a3a434e6b0a45746c02f4f993e0
SolsticeProjekt/snake
/examples/fizzy.py
242
3.828125
4
def fizzy(): s = "" for num in range(1, 101): if num % 3 == 0 and num % 5 == 0: s += "FizzBuzz " elif num % 3 == 0: s += "Fizz " elif num % 5 == 0: s += "Buzz " else: s += str(num) s += " " return s print(fizzy())
97d489f5124fbeec139435e2ad1ee3eda3426bfc
VasantG/TurtleImage
/turtleimage.py
194
4.03125
4
# The program generates a star like image. import turtle NUM_TRIANGLES = 20 turtle.forward(200) turtle.left(240) for x in range(NUM_TRIANGLES): turtle.forward(150) turtle.left(190)
afc2a246579baff747a04b9c2e4ee5ee92897390
sliceofpython/showandtell
/PyPig.py
1,262
3.859375
4
''' PyPig Chra94 Two player, proof of concept ''' import random score = {'PlayerOne': 0, 'PlayerTwo': 0} def turn(player): global score player = 'PlayerOne' while True: turn = 0 print(player + ' is up!') print('You have ' + str(score[player]) + ' points.') while Tr...
1c26e632d7c117ddc8614b6e43d7a8281f1cc827
arvino-98/220Assignment3
/assignment3.py
7,203
3.828125
4
''' Arvin Aya-ay Programming Assignment 3 ''' import networkx as nx inputFile = 'sample_in.txt' rawInputArray = [] with open(inputFile) as f: for line in f: rawInputArray.append(line.split()) ''' Print Utilities //////////////////////////////////////////////////////// ''' ''' printMultilineAdjList() Prin...
18c71da36253ba5dd904c18c06d96848030ccafa
kimhan0421/Edwith_python
/worked_exercise/exercise_2.3.py
632
4.09375
4
"""사용자가 일한 시간(hours)과 시급(rate per hour)을 프름프트에서 입력하면, 임금 총액을 계산해 주는 프로그램을 만들어 보세요. 35시간을 일 하고, 시간당 2.75 만큼을 벌었다고 가정하겠습니다. (그러면, 임금 총액은 96.25가 됩니다). 여러분은 input 함수를 써서 문자열(string)타입을 읽어오게 되지만, float()을 통해 변환을 해주어야 합니다. """ hour = float(input("Enter your hours: ")) p_hour=float(input("Enter your rate per hour: ")) total...
bf3e04a813140e7b2016831d573f93639aee38b9
wancongji/python-learning
/lesson/8/practice2.py
203
4
4
count = 0 total = 0 while True: num = input("输入n个数:") if num == 'q' or num == 'Q': break n = int(num) count += 1 total += n aver = total / count print(aver)
d08eaf0c5fac8abfbe1310faf1efc7318a7a9a5f
wancongji/python-learning
/lesson/15/匿名函数.py
374
3.84375
4
print((lambda :0)()) print((lambda x,y:x+y)(3,4)) print((lambda x,y=3:x+y)(3)) print((lambda x,*,y=3:x+y)(3,y=4)) print((lambda *args:[x+1 for x in args])(*range(5))) print((lambda *args:{x+1 for x in args})(*range(5))) print([x for x in (lambda *args:map(lambda x:x+1, args))(*range(5))]) print([x for x in (lamb...
396fa2e6dc6ebe1795c17a38082c4f735246b55e
wancongji/python-learning
/lesson/15/课堂练习.py
755
3.984375
4
# 求n的阶乘 def factorial(n): if n == 1: return 1 else: return n * factorial(n - 1) print(factorial(5)) # 将一个数逆序放入列表中,列入1234=>[4,3,2,1] def reversal(n, lst=[]): if n: lst.append(n[len(n) - 1]) reversal(n[:len(n) - 1]) return lst def reversal1(n, lst=[]): x, y = divm...
6748f7fbaba3fd5787b392f26cca3875ea4dee5c
wancongji/python-learning
/lesson/8/杨辉三角.py
643
3.703125
4
# 版本一 # triangle = [[1], [1,1]] # n = 6 # for i in range(2,n): # pre = triangle[i-1] # cur = [1] # # 除去头尾两个1,进行循环 # for j in range(0,i-1): # cur.append(pre[j]+pre[j+1]) # cur.append(1) # triangle.append(cur) # print(triangle) # 版本一改进版 triangle = [] n = 8 for i in range(0,n): ...
c62b24ca62cf6b7a6ef94b4a774b00c2c07b3561
wancongji/python-learning
/lesson/26/duixiang.py
739
4.46875
4
class MyClass: """ A example class """ x = 'abc' # 类属性 def __init__(self): # 初始化 print('init') def foo(self): # 类属性foo,也是方法 return "foo = {}".format(self.x) class Person: x = 'abc' def __init__(self, name, age=18): self.name = name self.y = age ...
5e94315bfe25f3afe469c6baacb18f0d123decde
piupom/Python
/tuplePersonsEsim.py
2,212
4.71875
5
# It is often convenient to bundle several pieces of data together. E.g. if the code processes information about people, then each person's information (name, age, etc.) could be bundled. This can be done in a naive manner with e.g. a tuple (also shown below), but classes provide a more convenient way. A class definiti...
1c8961f64984abc1bc5e6776f357f0152c780f69
piupom/Python
/wordLengthFilter.py
428
3.765625
4
import sys #Implement your wordLenFilter generator below def wordLenFilter(filename,length): with open(filename) as infile: for line in infile: for word in line.split(): if len(word) == length: yield word #Implement your wordLenFilter generator above for i, word in enumerate(wordLenFilter(...
ebc4ac030865e8b8d1b983c81b3e7a0ccb2334fc
piupom/Python
/leapyear2.py
286
3.90625
4
line = input() while line: vuosi=int(line) status='is not' if vuosi%4==0: status='is' #leap year if vuosi%100==0: status='is not' #not leap year if vuosi%400==0: status='is' #leap year print("The year", vuosi, status, "a leap year.") line = input()
e8b3807b0f9d38fe7b554e73c91797fd8e13b062
piupom/Python
/classFunctionsPersonsEsim.py
1,538
4.40625
4
# Classes have also other "special" functions. One common is __str__, which defines how to represent the object in string format (e.g. what is printed out if the object is passed to the print-function). Here we transform the printPersonObject-function from above into a __str__-member function. Now Person-objects can be...
8b746ca827fa6e652e2d5bc47eb897abe74a0cd0
projectsMuiscas/avangers
/funcionesTuplas.py
1,604
4.21875
4
# devolviendo varios valores desde una funcion def estadisticas_basicas (operado , operando): suma = operado + operando resta = operado - operando multi = operado * operando res = (suma,resta,multi) return res mysuma , myresta , mymulti = estadisticas_basicas (2 ,2) print (mysuma , ...
576163aeff796052051f0ab2260d4d3785ae08c2
goytia54/peasant_invasion
/alien_invasion/peasant.py
1,320
3.65625
4
import pygame from pygame.sprite import Sprite class Peasant(Sprite): """A class to represent a single alien in the fleet""" def __init__(self, ai_settings, screen): """Intialize the alien and set its starting positions.""" super(Peasant, self).__init__() self.screen = screen...
14550304f4b5e26daad82d1338e903cc07619370
Saymonex/labpython
/Z2_P1.py
479
3.796875
4
#Napisz program, który liczy za użytkownika. Umożliw użytkownikowi #wprowadzenie liczby początkowej, liczby końcowej i wielkości odstępu między kolejnymi #liczbami. poczatek = int(input("Podaj swoja liczbe poczatkowa: ")) koniec = int(input("Podaj swoja liczbe koncowa: ")) skok = int(input("Podaj wielkosc odstepu mied...
fe3438bef2c7aac5e06e3fcfacfd9691283482e3
arutters/learn_python_the_hard_way
/ex13.py
639
4.09375
4
from sys import argv # read the WYSS section for how to run this script, first, second, third, fourth = argv print("The script is called:", script) print("Your first variable is:", first) print("Your second variable is:", second) print("Your third variable is:", third) print("Your fourth variable is:", fourth) # w...
d910c36a7df8d38d652f78d7186c44f124726317
arutters/learn_python_the_hard_way
/ex12.py
282
4
4
age = input("How old are you?") height = input("How tall are you?") weight = input("How much do you weigh?") print(f"So you are {age} years old, {height} tall, and weigh {weight} pounds.") # This is the same principal as ex11 just a shorter and quicker way of # making it happen
923a822bb263814d9af788e325e228cfba233894
roblivesinottawa/intermediate_100_days
/day_twentythree/turtle_crossing/carmanager.py
1,631
4.21875
4
from turtle import Turtle import random COLORS = ["red", "orange", "yellow", "green", "blue", "purple"] STARTING_MOVE_DISTANCE = 5 MOVE_INCREMENT = 10 # create a class and methods to manage the movement of the cars class CarManager: def __init__(self): # create a variable to store all cars and set it to an empty...
e3fb5a4aa7de3aa0ef1557b686c849afb5cc652f
emilioego/data_stream_ml_sevici
/bikes.py
2,691
3.59375
4
import requests import pandas as pd import sqlite3 import traceback import time import datetime # Setting up NAME = "seville" STATIONS = "https://api.jcdecaux.com/vls/v1/stations" APIKEY = "2513ba8c201960d6193114b29d9be3e78dfce408" conn = sqlite3.connect("seviBikes.db") # Connect to database (creates ...
723c6f6651acf7e698fcb59757a0d4ba57f84655
twopiharris/230-Examples
/python/arrays/anagramTest.py
706
3.984375
4
""" anagram tester """ alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" def countLetters(phrase): #build empty letterScore letterScore = {} for char in alpha: letterScore[char] = 0 for letter in phrase: if letter in alpha: letterScore[letter] += 1 return letterScore def main(): wordList = o...
ff066394dd8984de215fc8d764887b3e0e220d34
twopiharris/230-Examples
/python/TKSimple/TKSimple.py
13,492
4.15625
4
from tkinter import * import random import math #import msvcrt Windows only library - not used so removed (sound effects?) class Sprite(object): """ A sprite object for the TK canvas INITIALIZATION filename: the address of the image file (default is in sam...
690574f888f0c7a65aef7402f12c56e5a928e7dd
twopiharris/230-Examples
/python/basic3/nameGame.py
533
4.25
4
""" nameGame.py illustrate basic string functions Andy Harris """ userName = input("Please tell me your name: ") print ("I will shout your name: ", userName.upper()) print ("Now all in lowercase: ", userName.lower()) print ("How about inverting the case? ", userName.swapcase()) numChars = len(userName) print ...
79e4d18d59311d6b3fb55e5e7270084c89bf215b
twopiharris/230-Examples
/python/demos/bind.py
1,104
3.84375
4
#bind.py from Tkinter import * class Bind(Tk): def __init__(self): Tk.__init__(self) self.lblOut = Label(self, text = "press a button") self.btnOne = Button(self, text = "one", width = 20) self.btnTwo = Button(self, text = "two", width = 20) self.btnThree = Button(self, text = "three",...
4ae1083afdbad66864869b56ce6c2e5c580e033d
twopiharris/230-Examples
/python/objects/critterModule.py
436
3.546875
4
""" CritterModule.py Basic critter class """ class Critter(object): def __init__(self): object.__init__(self) self.name = "I have no name" def sayHi(self): print "Hi, my name is %s!" % self.name def main(): c = Critter() c.name = "George" c.sayHi() #this code only runs mai...
f19aac2067efefa4595e7e76f4ea6280a915498b
twopiharris/230-Examples
/python/demos/war.py
3,007
3.921875
4
""" cardGame.py basic card game framework keeps track of card locations for as many hands as needed """ from random import * NUMCARDS = 52 DECK = 0 PLAYER = 1 COMP = 2 cardLoc = [0] * NUMCARDS suitName = ("hearts", "diamonds", "spades", "clubs") rankName = ("Ace", "Two", "Three", "Four", "Five", "Six", "Seven...
56bd2e97d9577a7410f38dfa71c2e3cad80e1665
twopiharris/230-Examples
/python/demos/imgDemo.py
737
3.65625
4
""" imageDemo.py demonstrates using images in Tkinter """ from Tkinter import * class App(Tk): def __init__(self): Tk.__init__(self) #photoImage file type must be gif or pgm !!?! #convert and resize in image editor as needed #be sure to save each image as a member va...
deb9718bfcbf3b60891dd88d7c7b07e4f8cb7d4a
twopiharris/230-Examples
/python/basic3/inventory.py
851
3.890625
4
""" inventory.py Demonstrates lists 4/20/06 """ inventory = [ "toothbrush", "suit of armor", "latte espresso", "crochet hook", "bone saw", "towel"] print("I packed these things for my adventure:") print(inventory) print print("I love my {} and my {}".format(inventory[2...
7d88f2a2dff5286c80d7fcf9a03fd70b9162f42f
twopiharris/230-Examples
/python/basic3/intDiv.py
443
4.53125
5
""" integer division explains integer division in Python 3 """ #by default, dividing integers produces a floating value print("{} / {} = {}".format(10, 3, 10 / 3)) #but sometimes you really want an integer result... #use the // to force integer division: print("{} // {} = {}".format(10, 3, 10 // 3)) #integer d...
f648d2ad1b6cbe12977e6fcc2beda160e67127d3
twopiharris/230-Examples
/python/arrays/distCalc3.py
859
3.984375
4
""" distCalc3.py calculate distance with a 2d list Modded for python 3.4""" def getCity(title): keepGoing = True while (keepGoing): print (""" {} 0) Indianapolis 1) New York 2) Tokyo 3) London """.format(title)) cityNum = input("City: ") if cityNum in ("0", "1"...
62f6db34a9d8397a6b03730efffa90c61d4e95fd
twopiharris/230-Examples
/python/TKSimple/SpriteDemo.py
1,471
3.796875
4
""" spriteDemo.py building a sprite object """ from tkinter import * import random from TKSimple import * import math class App(Tk): def __init__(self): Tk.__init__(self) self.title("TKSimple Demo") self.scene = Scene(self, 750, 600) self.backgro...
4cfe582a5b8739b9d27c5ee618eced11c0e6bd21
twopiharris/230-Examples
/python/demos/multiPanels.py
1,794
3.734375
4
""" multiPanels.py illustrating multiple panels in Tkinter """ from tkinter import * class App(Tk): def __init__(self): Tk.__init__(self) self.state = "A" self.lblA = Label(self, text = "Hi there. A.", width = 30) self.lblA.grid(row = 0, column = 0) ...
c697ec283beb0a4104bacb44bf58e273d357004a
Gliperal/Advent-of-Code
/day12.py
1,717
3.75
4
import math import file_input lines = file_input.get_input(12) # Using Cartesian coordinates, not screen coordinates def sin(angle): return math.sin(angle * math.pi / 180) def cos(angle): return math.cos(angle * math.pi / 180) def rotate(coords, angle): return [ coords[0] * cos(ang...
39f5f3a772193a9091ddacbf17aa60fb68d099ee
Gliperal/Advent-of-Code
/day22.py
1,772
3.75
4
import file_input lines = file_input.get_input(22) i = lines.index("Player 2:\n") crab_cards = [int(line.strip()) for line in lines[1:i-1]] my_cards = [int(line.strip()) for line in lines[i+1:]] def score(cards): n = len(cards) score = 0 for i, card in enumerate(cards): score += (n - i)...
c825dd2eedd03715f8cd2e3837d396b599d8d449
Jeshaltus2019/Pythoncodes
/Combining Dictionaries and Lists.py
226
3.8125
4
player = {'Messi': [31,'Argentina','FC Barcelona']} print(f'{"Player":10} {"Age":3} {"Country":10} {"Club":10}') print('-'*50) for name,info in player.items(): print(f'{name:10} {info[0]:10} {info[1]:10} {info[2]:10}')
17100850e0dbfc3032878ef1460225ca1f983eeb
nicolas-1997/Python_Profesional
/timezones2.py
426
3.90625
4
from datetime import datetime import pytz def timezones(): citys = ["America/Argentina/Buenos_Aires","America/New_York America/Mexico_City","America/Mexico_City"] for city in citys: city_timezone = pytz.timezone(city) city_date = datetime.now(city_timezone) print(f"City of {city}: ", ...
39d92a796d5431f4be11fadf5cf59d979e825cb7
matheushsouza/slizzy
/src/slizzy/util/frange.py
394
3.84375
4
class frange: """A frange is a range delimited by two floating point values. It is not an enumerator as the standard range.""" def __init__(self, lower, upper): if lower > upper: raise ValueError("frage: lower bigger than upper") self.lower = lower self.upper = upper def __contains_...
dadf22fa2e609273f3834179757be65ef2ea68ca
collinpikeusa/SoftwareProcess
/RCube/sandbox/sandbox.py
361
3.5625
4
''' Created on Sep 22, 2018 @author: Collin Pike ''' if __name__ == '__main__': a = {'a': 'b', 'b':'c', 'd': 'b'} b = a.values() k = 0 for i in a.values(): for j in b: if(i == j): k += 1 if(k > 1): print('too many') if(k > 1): ...
cc3b80189e8a80b6a6fb351b18ab9514ca9bccd8
tompainadath/Student-Data-Storage-in-Hashtable-with-Collision-Avoidance
/project_code.py
7,296
3.78125
4
################################################################################ ### Name: Tom Painadath ### Description: This program simulates packets of data arriving at irregular times. The data ### gets read from the file and is placed in a queue where it waits for its turn ### to get pro...
531e5f05ad2ce3ec7568bc3045c64e85a9c2c37f
EuricoDNJR/beecrowd-URI
/Em Python/1011.py
98
3.671875
4
raio = float(input()) pi = 3.14159 calc = (4.0/3)*pi*raio**3 print('VOLUME = {:.3f}'.format(calc))
9a05cc73b5fb5b45de625f84d10592b20f682cd7
EuricoDNJR/beecrowd-URI
/Em Python/1142.py
167
3.640625
4
numerolinhas = int(input()) a = 1 b = 2 c = 3 cont = 0 while(cont<numerolinhas): print("{} {} {} PUM".format(a,b,c)) cont += 1 a += 4 b += 4 c += 4
3c78e665e08e55ca3c42f773f044b4a1f12aa732
varskann/datastructures_and_algorithms
/datastructures_and_algorithms/sorting/selection_sort.py
1,430
4.09375
4
__author__ = "Kanishk Varshney" __data__ = "06-May-2020" import inspect def sort(array): """Sort array using Selection sort Logic: Select n-smallest element and place it in the nth block of array Intuition: Assume a card deck in your hand down, say 1 to 13 - You scan through...
6a9139c4c29cb5fb67e51bd3d5b49630f58d6da6
jacksonwlyons/CSE-231
/proj10.py
13,374
3.875
4
############################################################################## # Computer Project #10 # # Algortithm # Seahaven Solitaire game # Class # Prompt for choice input/menu # Build methods to validate and choose between different options # Display current game # Game is won on...
e1aca7e2495ac09f800bb62fecb1e9a99d98d0db
En-Blip/EncryptionEngine
/encryptionAndDecryption.py
3,403
3.703125
4
import random alphabet=' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQR5STUVWXYZ1234567890' keynums='123456789' testNum=3 print(""" +------------------------------------------------------+ | Noah 's Encryption and Decryption Algorithm | | Created Dec 3, 2020 | | ...
279a148bcee508d67e4f958047460d133368e0fd
samirian/HELS
/helpers.py
831
3.8125
4
def read_configuration(filename: str): """Reads a configutation file and returns the parameters as a dictionary. """ configuration = {} with open(filename) as configuration_file: for line in configuration_file.readlines(): row = line.replace('\t', '').replace('\n', '').split('=', 1) if len(row) == 2: r...
6089bea0ebf15f1388322e19afe96c75bb36c33f
moritan0000/py_practice
/Short_Coding.py
2,808
3.625
4
def _if(a, b): # long if a == 10 and b == 10: print('both') elif a != 10 and b != 10: print('neither') else: print('either') # short print(['neither', 'either', 'both'][(a == 10) + (b == 10)]) # long if a < b: c = 4 else: c = 2 # short ...
a435fc78517da9c56887da89ad93d4693301c79f
moritan0000/py_practice
/HackerRank.py
6,226
3.546875
4
def sock_merchant(n, ar): from collections import Counter pair = 0 sock_counter = Counter(ar) for v in sock_counter.values(): pair += v // 2 return pair def counting_valleys(n, s): now = 0 valley = 0 for i in range(n): if now == 0 and s[i] == "D": valley += ...
a1edd6d10e35a8c87be257c5a60c0b6ca54088d0
rmcarthur/acme_labs
/Lab18v1.py
2,015
3.671875
4
from __future__ import division import numpy as np import scipy.stats as stats from matplotlib import pyplot as plt def mc_int(f, mins, maxs, numPoints=500, numIters=100): '''Use Monte-Carlo integration to approximate the integral of f on the box defined by mins and maxs. INPUTS: f - A function handle....