blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
c52d8d57b335696d9214832b0eb005f181092ff5
Mansurjon1112/WHILE-Shart-sikl-operatorlari-30-ta-
/while09.py
409
3.765625
4
# -*- coding: utf-8 -*- """ While9. n natural soni berilgan (n > 1). 3k > n shartni qanoatlantiruvchi eng kichik butun k sonini aniqlovchi programma tuzilsin. Created on Tue Jun 29 17:51:38 2021 @author: Mansurjon Kamolov """ n=int(input('N=')) if n>0: p=1 k=0 while p<=n: p*=3 ...
6c52c03963a5bb114dab0ae5618dbf501c2c2138
Mansurjon1112/WHILE-Shart-sikl-operatorlari-30-ta-
/while24.py
588
3.59375
4
# -*- coding: utf-8 -*- """ While24. n butun soni berilgan (n > 1). n sonini Fibonachchi sonlari orasida bor – yo’qligini aniqlovchi programma tuzilsin. Fibonachchi sonlari quyidagi qonuniyat asosida topiladi. F1 = 1; F2 = 1; Fk = Fk-1 + Fk-2; k = 3, 4, … Created on Wed Jun 30 06:21:48 2021 @author: Mansurjon...
dafb29e533589396abf778f41cd65fadafa098a6
bioinformatica-corso/programmi-elementi-bioinformatica
/intro/fibo3.py
376
4.09375
4
#!/usr/bin/env python3 import argparse parser = argparse.ArgumentParser(description='Fibonacci.') parser.add_argument('limit', metavar='N', type=int, nargs=1, help='how many fibonacci numbers to compute') args = parser.parse_args() def fib(n): if n <= 1: return 1 else: re...
2d2a4c5ab28f57e683abfa13d553ff73b1e33ce2
Kritika997/python-practice-question
/keyIsExits.py
625
4
4
# a = {1:2,3:5,5:7} # def number(num): # if num in a: # return "yes" # else: # return "no" # print(number(8)) # from datetime import date # today = date.today() # print("Today's date:", today) from datetime import date today = date.today() print(today) # dd/mm/YY # d1 = tod...
3e89dd39fd1430ea84c4d5e9f02de7ff7195fcca
kenn-chen/algo-python
/sort/selection.py
198
3.640625
4
def sort(nums): for i in range(len(nums)): min_index = i for j in range(i+1, len(nums)): if nums[j] < nums[min_index]: min_index = j nums[i], nums[min_index] = nums[min_index], nums[i]
9853a2266d1acbf23b8bba45db882b0b444fa030
hari2pega/Python-Day-wise-Practice-Sheets
/Hari_July 27th_Practice Sheet - Numbers and Introduction to List.py
1,862
4.53125
5
#!/usr/bin/env python # coding: utf-8 # In[1]: #Commenting the Line #What ever has been written after the Hash symbol, It will be considered as Comment #Numbers #Integers 2+3 # In[2]: #Numbers 3-2 # In[3]: #Float - It will be give the decimal value - Declaring in Decimal is called Float 0.1+0.2 # In[8]: ...
9b11d1a23c27a2e6ff328649849a1a8159b55ccb
arifa06/purwdhika1
/Task-1.py
1,876
3.734375
4
#Soal 1 for i in range(2): num = int(input('Masukkan Angka : ')) if num == 0: print('0 bukan bilangan positif dan negatif') elif num < 0: print('masukkan bilangan bulat') elif num % 2 == 0: print(num,'bilangan genap') else: print(num,'bilangan ganjil') pri...
853054d7552a7916833fb900f5746120f8a785a8
JhoanAmaya/Fundamentos
/ejercicio10.py
1,439
4.0625
4
#Mostrar en pantalla la cantidad de meses transcurridos desde la fecha de nacimiento de un usuario. from datetime import date usuario = input("Ingresa tu nombre completo: ") año = int(input("Ingresa el año de nacimiento: ")) if (año<=0): print("¡Error no se puede hallar año con signo negativo!") else : mes = ...
5c42a748705353b54b96f8932d0380ecdca6c1e1
charleskausihanuni/210CT
/Q3 - Code.py
278
3.921875
4
#Highest perfect square of a number s = (int(input('Input number: '))) x = 0 if s >= 0: while x*x < s: x +=1 if x*x != s: x=x-1 print(x) else: print(x) else: print(str(s), 'is not a positive number')
63576eb8ee8e13671fe7e7bcc44151841b00917a
YuanGao0702/Hadoop-American-Airplane
/Airline-reduce3.py
959
3.75
4
#!/usr/bin/env python #How many total hours of airtime did each carrier have? #Student: Changle Xu, Yuan Gao, Bei Xia from operator import itemgetter import sys current_carrier = "" carrier = "" total = 0 airtime = 0 # input comes from STDIN for line in sys.stdin: # remove leading and trailing whitespace line...
84d365fed66ce095d257bb8cca8951c39ff684e0
Kalli/project-euler
/python/problem003.py
762
3.828125
4
''' Project Euler - Problem 3 http://projecteuler.net/problem=3 The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? ''' import math def isPrime(n): prime = True if n != 1: i = 2 while i < math.sqrt(n): if n % i == 0: ...
b271c53d541d33a1cd9c3bfcda640b7e747abc1a
xasopheno/euler
/problems/_020/euler_020.py
217
3.8125
4
def factorial(n): if n == 0: return 1 else: return n * factorial(n-1) def sumDigets(): strNum = str(factorial(100)) total = sum([int(i) for i in strNum]) print(total) sumDigets()
c827ae0b552e9d3b219c482fa0dd21d2988b78a7
xasopheno/euler
/problems/_007/euler_007.py
504
3.84375
4
import math # By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. # # What is the 10 001st prime number? def nth_prime(max, goal): count = 0 cache = [True] * max cache[0] = cache[1] = False for (i, is_prime) in enumerate(cache): if is_prime: ...
4bab5136a5371a50cd60f5abd3932e1392986c02
xasopheno/euler
/problems/_015/euler_015.py
368
3.796875
4
def route_num(cube_size): intersection = [1] * cube_size for i in range(cube_size): for j in range(i): intersection[j] = intersection[j]+intersection[j-1] print(intersection[j]) intersection[i] = 2 * intersection[i - 1] print(intersection) return intersection[cube...
08f2567e0558e010fb6c2d1444d93fdc7c16740b
vgrillot/mpf
/mpf/modes/game/code/game.py
22,469
3.5625
4
"""Contains the Game class which is the Machine Mode that actually runs and manages an the game in a pinball machine. Note that in the Mission Pinball Framework, a distinction is made between a *game* and a *machine*. A *game* refers to a game in progress, whereas a *machine* is the physical pinball machine. """ from...
98e2659ea9d1d94ffcf5ac94aa000b6b8b8dd8ec
dminoru/mypackage
/mypackage/weather.py
1,174
3.5
4
import sys import requests BASE_URI = "https://www.metaweather.com" def search_city(query): response = requests.get( f'{BASE_URI}/api/location/search/?query={query}' ).json() if response: return response[0] return None def weather_forecast(woeid): response = requests.get( ...
8cadabcf39152e2436518f0bdcbb1192b41d88f4
a1424186319/tutorial
/sheng/tutorial/L2基础类型控制语句/5 sinput 语句.py
288
3.796875
4
#input 语句 number = 20 user_number = input('请输入一个数字') user_number = int(user_number) if user_number > number: print('猜大了') elif user_number < number: print('猜小了') else: print('猜对了') """ input():接收用户输入,返回字符串 """
9a749d775f8ba83ae1b3a750af0cb9631d28d059
a1424186319/tutorial
/sheng/tutorial/L43更多存储格式/1.csv.py
577
3.703125
4
# csv # csv 一种逗号分隔的简单语法的一种文件存储结构.远比数据库简单,比excel也简单. # 场景: 备份数据,适合非电脑专业人士观看. import csv # 读取数据 file_path = "D:/testcsv.csv" with open(file_path) as f: reader = csv.reader(f) result = tuple(reader) print(result[0][1]) # 写数据 datas = [ ['1','小明','11'], ['2','憨豆','18'], ['3','鹏儿','88'], ] with open('t...
b7c0e0468e787e858fc131106b57e796c4db4dff
a1424186319/tutorial
/sheng/tutorial/L3函数/递归练习3.py
196
3.65625
4
# 斐波那契数列:1,1,2,3,5,8,13,21... → F(n)=F(n-1)+F(n-2) def f(n): if n <= 1: return 1 else: return f(n - 1) +f(n - 2) for n in range(1,11): print(f(n))
d5d44db810e71818986a936235825ebd022e1473
a1424186319/tutorial
/sheng/tutorial/L7本地文件读写/5with语句.py
1,062
3.75
4
# with语句 # file = open('english_ascii.txt','r') # content = file.read() # print(content) # file.close() # 传统写法缺点 每一次要记得打开或关闭文件,跟try except连用时结构不太清晰。 # with with open('chinese_utf8.txt','r',encoding='utf-8') as f: # f.__enter__() #文件打开的预处理 content = f.read() print(content) #f.__exit__() ...
ceb24a64691168850048fd77f26799874d07c4cc
a1424186319/tutorial
/sheng/tutorial/L3函数/9递归.py
988
3.875
4
## 递归 ##计算10的阶乘 #非递归写法 # a = 1 # for i in range(1,11): # a = a * i # print(a) #换一种思路 # 例如要计算5! # 5! = (1*2*3*4)*5 = 4!*5 # 4! = (1*2*3)*4 = 3!*4 # 3! = (1*2)*3 = 2!*3 # 2! = 1!* 2 # 所以 5! = (((1!* 2)*3)*4)*5 # n! = (n-1)! * n (n>=2) # 结论:f(n) = f(n-1) * n (n>=2) def factorial(n): if n == 1: return ...
13dfafcb649f51920548186bf486aa91a30b5464
a1424186319/tutorial
/sheng/tutorial/L6异常和异常捕获和debug/2捕获异常.py
1,973
3.640625
4
# 捕获异常 # 场景:一个大型项目,业务逻辑复杂。当出现异常错误时,我们并不希望程序终止,希望程序主体功能运行;收集分析错误信息。 # 示例1 def foo(): try: print(1/0) print('hello') except ZeroDivisionError: print('不能除以0') finally: print('我最后执行') print('world') def boo(): print('hello') foo() print('world') boo() """ (重点)捕...
d3bed98841ffcbb8d34e33a69c084ad4cff689e3
a1424186319/tutorial
/sheng/tutorial/L5类和对象/5类的继承(2).py
1,231
4.0625
4
#类的继承和重写 #引题:上一节课例子展示了子类继承父类,子类可以继承父类的属性和方法。但是生活中往往子类除了具备一些父类的特征,还具备自己个性化的特征。例如父类手机,子类OPPO手机类 独特特征侧重于拍照 ;苹果手机类 独特特征侧重于系统好。 class Animal(object): def __init__(self,name): self.name = name def run(self): print('动物在跑') class Dog(Animal): def swim(self): print('狗会游泳') class Cat(Animal)...
7f4695ffe5471043cae43e906c73042622f443ae
a1424186319/tutorial
/sheng/tutorial/L4数据结构/学生管理系统.py
1,614
3.8125
4
student_list = ['小王', '小红', '小李'] while True: print(""" 1-查询学员姓名 2-添加学员姓名 3-修改学员姓名 4-删除学员姓名 0-退出程序 """ ) a = int(input('请选择操作:')) if a == 1: print('行号\t\t姓名') print('-----------------') for i in range(0,len(student_list)): print(i+1,'\t\t',student_...
7d9f417762967f9fc95cd4834488355d404e15f4
a1424186319/tutorial
/sheng/tutorial/L7本地文件读写/8更多模式.py
713
3.78125
4
#open()更多模式 """ open()第二个参数mode模式: 'r',read 读取信息 'w',write 写信息 'rb',read byte 读取字节信息。 'wb',write byte 写字节信息。 """ with open('8write.txt','w',encoding='utf-8')as f: f.write('hello') f.write('world') f.write('你好\n') f.write('世界\n') with open('8write.txt','w',encoding='utf-8')as f: f.write('第二次写入信...
4108cba15729a078d0dce2b400120cdb00487d17
a1424186319/tutorial
/sheng/tutorial/L8包/3os.py
2,544
3.765625
4
# os # os包: IOS macOS , operate system 操作系统。主要负责新建文件、改文件名、路径、操作电脑系统相关的功能。是一个内置包。os包实质调用的是windows上的编程接口。 import os # from os import path, open # from os import * # 1>os.path.exists 判断是否存在文件 print(os.path.exists('1包引用.py')) # True print(os.path.exists('text.txt')) # False # 2> 重命名 # os.rename('aaa.txt', 'bbb.txt') ...
31c70783fe08d678b27c9016435e3a105f79b182
a1424186319/tutorial
/sheng/tutorial/L3函数/练习1.py
196
3.765625
4
# a=0 # b=1 # while b < 100: # print(b) # a,b=b,a+b print('1、','1、',end='') a = 1 b = 1 for i in range(3,10) : c= a + b print(c,'、',end = '') a = b b = c print(c)
bb743f28a67000ab10415d1c793820e313e9fb79
JoaoCarlosNascimento/AdvancedCalculator
/AdvancedCalculator.py
7,716
4
4
import numpy as np import matplotlib.pyplot as plt import os.path from os import path from mpl_toolkits import mplot3d def insert_file_name(number): if number == "1": file_name = input("Insert the name for your Note file: ") + ".txt" while path.exists(file_name): print("Inva...
74402dc7fb9d97f14ecaebf30b201a5b96a7e7e3
dogeplusplus/DailyProgrammer
/222balancingwords.py
1,304
4.3125
4
def balance_word(word): '''the position and letter itself to calculate the weight around the balance point. A word can be balanced if the weight on either side of the balance point is equal. Not all words can be balanced, but those that can are interesting for this challenge. The formula to calculate the weight of th...
a6c8fdd29cd26a67cc6150067924ecbc6421d7d8
dogeplusplus/DailyProgrammer
/252Coconuts.py
645
3.796875
4
def coconuts(sailors): total_coconuts = 0 completed = False while not completed: total_coconuts += 1 successful_division = True # Start the coconut pile coconut_pile = float(total_coconuts) for _ in range(sailors): if coconut_pile%sailors == 1. and coconut_pile > sailors: # 1 for the monkey coc...
83dc8b3001488e270cfefa94c1432585adf64fb9
dogeplusplus/DailyProgrammer
/216texasholdem.py
4,582
3.671875
4
import random import itertools class texasholdem: def __init__(self): suits = ['Diamonds', 'Clubs', 'Hearts', 'Spades'] numbers = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King', 'Ace'] self.deck = [n + ' of ' + s for s in suits for n in numbers] random.shuffle(self.deck) def deal_c...
2da2471afe52c099dc7fbcfd46e4a918484233c3
chisaim/MyFristPythonProject
/first/func_test.py
1,480
3.6875
4
# def func(a, b, c): # print('a = %s' %a) # print('b = %s' %b) # print('c = %s' %c) # # # func(1, c=3) # def howlong(first, *other): # return print(1 + len(other)) # # # howlong(123, 456, 789) # var1 = 123 # def func(): # global var1 # var1 = 456 # print(var1) # func() # print(var1) ...
46c8be9ed9b6490441d0405f83a4390cc4c5566d
babithdarshan/pandas-basics
/tranfers_statements.py
1,207
3.90625
4
#!/usr/bin/env python # coding: utf-8 # In[10]: for i in range(10): if i==7: print('loop excution is enough plz break the loop') print(i) # In[11]: cart=[10,20,600,60,70] for item in cart: if item >500: print('to place this order insurance must be required') break ...
8d2ab9d7f63b4487cdc51741da5a5637d4bda10d
babithdarshan/pandas-basics
/python_list.py
1,234
3.9375
4
#!/usr/bin/env python # coding: utf-8 # In[3]: l=eval(input('enter list:')) # In[4]: type(l) # In[7]: l=list(range(10)) # In[8]: print(l) # In[10]: l=list({10,20,30,40,50}) # In[11]: print(l) # In[12]: type(l) # In[13]: s='learning python is very easy' l=s.split() print(l) # In[14]: l...
bae3833a7aecbd7f7d87ccca9f8161d12896bf54
maq-622674/python
/c语言中文网/py/4.列表,元组,字典和集合/4.15py_dict字典方法完全攻略/main.py
2,146
4.0625
4
print(dir(dict)) #1.keys(),values()和items()方法 # 将这三个方法放在一起介绍,是因为它们都用来获取字典中的特定数据: # keys() 方法用于返回字典中的所有键(key); # values() 方法用于返回字典中所有键对应的值(value); # items() 用于返回字典中所有的键值对(key-value)。 scores = {'数学': 95, '语文': 89, '英语': 90} print(scores.keys()) print(scores.values()) print(scores.items()) a = {'数学': 95, '语文': 89, '英语': 9...
8a05fb63cf0ad82d885c1d4aa9d0b3c96faf1b70
maq-622674/python
/廖Py教程/py/8.面向对象编程/继承和多态.py
969
3.96875
4
''' 例子一 Animal父亲 DOg和Cat儿子 父亲啥都有 儿子啥都没有 ''' # class Animal(object): # def run(self): # print('Animal is running...') # class Dog(Animal): # pass # class Cat(Animal): # pass # dog=Dog() # dog.run() # cat=Cat() # cat.run() ''' 例子二 Animal父亲 DOg和Cat儿子 父亲啥都有 儿子也有 Dog可以看成Animal,但Animal不可以看成Dog。 ...
9b7ebf29fc78cf160361291530a3339ee5e0122a
maq-622674/python
/c语言中文网/py/7.函数和lambda表达式/7.1py函数/main.py
1,135
4.3125
4
''' Python函数(函数定义、函数调用)用法详解 ''' n=0 for c in "http://c.biancheng.net/python/": n = n + 1 print(n) #自定义 len() 函数 def my_len(str): length = 0 for c in str: length = length + 1 return length #调用自定义的 my_len() 函数 length = my_len("http://c.biancheng.net/python/") print(length) #再次调用 my_len() 函数 length ...
30c7107dc51933bf4c72c5a9cdd5e87c73ac6d01
maq-622674/python
/csdn_py/7.py网络爬虫基础(上)/1.py中的正则表达式.py
1,106
4.15625
4
# 一些表达式进行提取,正则表达式就是其中一种进行数据筛选的表达式。 # 正则表达式(Regular Expression)是一种文本模式,包括普通字符(例如,a 到 z 之间的字母)和特殊字符(称为"元字符")。 # 正则表达式通常被用来匹配、检索、替换和分割那些符合某个模式(规则)的文本。 # Python 自1.5版本起增加了re模块,它提供Perl风格的正则表达式模式。 # re 模块使 Python 语言拥有全部的正则表达式功能,使用前需要使用 import re 导入此模块 # compile 函数根据一个模式字符串和可选的标志参数生成一个正则表达式对象。该对象拥有一系列方法用于正则表达式匹配和替换。 imp...
117a672a7dc9c01ed5581a3983b3d7e57d53ecf9
maq-622674/python
/c语言中文网/py/5.py字符串常用方法/5.11py字符串大小写转换/main.py
521
4.21875
4
''' Python字符串大小写转换(3种)函数及用法 ''' #1.py title()方法 #两个单词之间无论用什么分开他都会把首字母变为大写 #比如apple——orange apple?orange apple_orange apple*orange str="c_biancheng.net" print(str.title()) #2.py lower()方法 #全部变小写 str="I LIKE C" print(str.lower()) #3.py upper()方法 str="i like c" print(str.upper()) #需要注意的是,以上 3 个方法都仅限于将转换后的新字符串返回,而不会修改原...
eafa74c3629d3a060d0b7ef22a2a95814f0410fe
maq-622674/python
/廖Py教程/py/22.异步IO/1.协程/main.py
1,426
3.875
4
''' 在学习异步IO模型前,我们先来了解协程。 协程,又称微线程,纤程。英文名Coroutine。 协程的概念很早就提出来了,但直到最近几年才在某些语言(如Lua)中得到广泛应用。 子程序,或者称为函数,在所有语言中都是层级调用,比如A调用B,B在执行过程中又调用了C,C执行完毕返回,B执行完毕返回,最后是A执行完毕。 所以子程序调用是通过栈实现的,一个线程就是执行一个子程序。 子程序调用总是一个入口,一次返回,调用顺序是明确的。而协程的调用和子程序不同。 协程看上去也是子程序,但执行过程中,在子程序内部可中断,然后转而执行别的子程序,在适当的时候再返回来接着执行。 注意,在一个子程序中中断,去执行其他子程序,不是函数调用,有点类...
c66f7680cda60b10403c6333c0ca8b2f76d314fe
maq-622674/python
/廖Py教程/py/12.进程和线程/duoxiancheng.py
3,512
4.40625
4
#导入time和threading高级模块 import time, threading # 新线程执行的代码: def loop(): #第三步输出thread is LoopThread running... print('thread %s is running...' % threading.current_thread().name) n = 0 #第四步 开始循环 循环5次0-4 判断是否n<5 #第七步 #第十一步 #第十五步 #第十九步 #第二十三步 判断5<5为False不执行while往下执行 while n < 5: ...
2636582ff3a8b5a46375e2c9872aba4ab708f792
maq-622674/python
/破解wifi/dict.py
1,177
3.5
4
#类 import os import itertools as its class Range(object): def __init__(self): self.current_address_1 = os.path.dirname(os.path.abspath(__file__)) def text_create(self): #desktop_path = self.current_address_1 #full_path = desktop_path +'\\'+ name + '.txt' # 也可以创建一个.d...
30cec9f487dceae3675ddd15b335ddb29c646d2b
maq-622674/python
/csdn_py/1.py基础/1.10综合案例实战.py
2,016
3.859375
4
# 学员信息在线管理 # 定义一个用于存放学员信息的列表变量 stulist=[ {'name':'zhangsan','age':20,'classid':'python02'}, {'name':'lisi','age':22,'classid':'python03'}, {'name':'wangwu','age':25,'classid':'python04'}] #定义一个学生信息的输出函数 def showStu(stulist): ''' 学生信息的输出函数 ''' if len(stulist)==0: print("========== 没...
9eaa9a75ce99872ed9add05a83c9700486cbe0c7
maq-622674/python
/廖Py教程/py/5.高级特性/迭代.py
1,517
4
4
d = {'a': 1, 'b': 2, 'c': 3} for key in d: print(key) for ch in 'ABC': print(ch) #所以,当我们使用for循环时,只要作用于一个可迭代对象,for循环就可以正常运行,而我们不太关心该对象究竟是list还是其他数据类型。 #那么,如何判断一个对象是可迭代对象呢?方法是通过collections模块的Iterable类型判断: from collections import Iterable #str是否可迭代 print(isinstance('abc',Iterable)) # list是否可迭代 print(isinstance([...
9daa371f8022d432593eab8791a18af4c9928a75
maq-622674/python
/c语言中文网/py/5.py字符串常用方法/5.3py_len()函数,获取字符串长度或字节数/main.py
1,207
3.578125
4
a='http://c.biancheng.net' print(len(a)) ''' 在实际开发中,除了常常要获取字符串的长度外,有时还要获取字符串的字节数。 在 Python 中,不同的字符所占的字节数不同,数字、英文字母、小数点、下划线以及空格,各占一个字节,而一个汉字可能占 2~4 个字节,具体占多少个,取决于采用的编码方式。例如,汉字在 GBK/GB2312 编码中占用 2 个字节,而在 UTF-8 编码中一般占用 3 个字节。 以 UTF-8 编码为例,字符串“人生苦短,我用Python”所占用的字节数如图 1 所示。 ''' #我们可以通过使用 encode() 方法,将字符串进行编码后再获取它的字节数。例如...
f35969e997535f08f0b3a0dc53af799f574f4624
salexkidd/box
/box/argparse/program.py
2,461
3.5
4
import os import sys from copy import copy from argparse import ArgumentParser from abc import ABCMeta, abstractmethod from ..functools import Function, cachedproperty class Program(Function, metaclass=ABCMeta): """Abstract console program representation. Client have to implement __call__ method. Parame...
3ee653deb35cfe423ec4a11a6d77cdb613de10c9
salexkidd/box
/box/importlib/object.py
1,519
3.984375
4
import importlib def import_object(name, *, module=None, package=None): """Import an object. Parameters ---------- name: str/mixed Object name in "[module.]module.]attr" form. module: str Anchor point from which to resolve attribute. package: str Argument is required when pe...
e90b652e9b9d921a5d3ca94e1b299ce07e07812f
sfmajors373/PythonPractice
/OddTest.py
364
4.1875
4
#Input largestoddnumbersofar = 0 counter = 0 #Test/Counter while counter < 10: x = int(input("Enter a number: ")) if x%2 == 1: if x > largestoddnumbersofar: largestoddnumbersofar = x counter = counter + 1 print(counter) #Output if counter == 10: print ("The largest od...
75c191c8b32ca4602ae05df46b3b53c3a8f279af
sfmajors373/PythonPractice
/Polysum.py
666
3.984375
4
import math def perimeter(s, n): """Assumes float inputs and returns the perimeter of a regular polygon""" return s*n def area(s,n): """Assumes float inputs and returns the area of a regular polygon""" return (0.25*n*(s**2))/(math.tan(math.pi/n)) def SumofAreaandPerSquared(s,n): """Assumes float ...
e63ba295012be2de5f00a97e4dabaad172f6a2c3
dmsloan/LearnPython
/stringInOrder.py
202
3.78125
4
s = 'azcbobobegghakl' bobs = 0 for l in range(len(s)): print(s[l] + "=" + str(ord(s[l]))) if s[l:l+3] == ("bob"): bobs += 1 print("Number of times bob occurs is: " + str(bobs))
0437a650113495e2f03408975dfe5c696577a8d1
dmsloan/LearnPython
/recursive.py
140
3.75
4
def mult(a,b): if b==1: return a else: return a + mult(a, b-1) print(mult(3,4)) print(mult(5,4)) print(mult(13,6))
c81b4f9c5a5622241d4dbbbab0444db01bf6eba2
dmsloan/LearnPython
/powerIteration.py
490
3.890625
4
def iterPower(base, exp): ''' base: int or float. exp: int >= 0 returns: int or float, base^exp ''' # Your code here # the following works but it is total crap, see the bottom for the proper way x = base if exp == 0: return 1 elif exp == 1: return base ...
597569f6aa4e5373fe62cc04d7cd4fd1cdb8a68c
ArthurD25/RPSLS
/human.py
599
3.515625
4
from player import Player class Human(Player): def __init__(self): super().__init__() self.score = 0 def set_name(self): self.name = input("What's your name?") print(self.name) def choosing_gesture(self): print("Choose a gesture:") gesture_index = 0 ...
ef96a79e8774ee0ff8c5cc918ce661fdfc5369bd
yunuseminyazici/python_exercise
/Problem3.py
321
4.0625
4
"""Problem 3 Bir aracın kilometrede ne kadar yaktığı ve kaç kilometre yol yaptığı bilgilerini alın ve sürücünü toplam ne kadar ödemesini gerektiğini hesaplayın.""" a=float(input("Kilometrede yakan tutar:")) b=int(input("Yapılan Kilometre:")) print("Ödenmesi gereken tutar:{} tl".format(a*b))
ad304aedebcb5efc029374d6769dde63fed42662
yunuseminyazici/python_exercise
/oyuncu_kaydetme.py
283
3.71875
4
print("Oyuncu kaydetme programı") ad = input("Oyuncu Adı:") soyad = input("Oyuncu Soyadı:") takim = input("Oyuncu takımı:") bilgiler = [ad, soyad, takim] print("Oyuncu Adı: {}\n Oyuncu soyadı: {}\n Oyuncu Takimi: {}\n".format(bilgiler[0],bilgiler[1],bilgiler[2]))
adda8a813a0252611e7fcb1e257b9545562b059c
yunuseminyazici/python_exercise
/Problem12.py
537
3.953125
4
"""Her bir while döngüsünde kullanıcıdan bir sayı alın ve kullanıcının girdiği sayıları "toplam" isimli bir değişkene ekleyin. Kullanıcı "q" tuşuna bastığı zaman döngüyü sonlandırın ve ekrana "toplam değişkenini" bastırın. İpucu : while döngüsünü sonsuz koşulla başlatın ve kullanıcı q'ya basarsa döngüyü break ile...
be803c3c9bd83ebdf9a80824cbbeb9db23292fbe
yunuseminyazici/python_exercise
/Python_Ders18_SqliteVeritabanı.py
498
3.5
4
import sqlite3 con = sqlite3.connect("dersler.db") #Database oluşturma cursor = con.cursor() def tabloolustur(): cursor.execute("CREATE TABLE IF NOT EXISTS ogrenciler (ad TEXT, soyad TEXT,numara INT,ogrencinotu INT)") #tablo oluşturma ve veri tipi belirleme def degerekle(): cursor.execute("INSERT IN...
02673b7a8aaac520aec772ab345391aae54ab1d8
Vlad-Mihet/MergeSortPython
/MergeSortAlgorithm.py
2,189
4.3125
4
import random # Generating a random Array to be sorted # If needed, the random elements assignment could be removed, so a chosen array could be sorted ArrayToBeSorted = [random.randint(-100, 100) for item in range(15)] def MergeSort (array, left_index, right_index): if left_index >= right_index: r...
89b88cc893ea8d7f44a5d59fa2d83765492581d4
najuzilu/ucsd_algorithms
/Algorithms_on_Graphs/week4/assignment/1_dijkstra/dijkstra.py
1,650
3.53125
4
#Uses python3 import sys import queue import heapq from heapq import heapify, heappush, heappop def distance(adj, cost, s, t): distance = [float("inf") for _ in range(len(adj))] previous = [None for _ in range(len(adj))] # initialize queue with starting node myQueue = [] distance[s] = 0 # make queue from all ...
bf6f3a79c82b91e0f3700889c135fcda3e1f03cc
najuzilu/ucsd_algorithms
/Algorithms_on_Graphs/week1/assignment/2_connected_components/connected_components.py
851
3.515625
4
#Uses python3 import sys def explore(v, visited, cc_coef): visited[v] = True if cc_coef not in cc_array: cc_array.append(cc_coef) for node in adj[v]: if visited[node] == False: explore(node, visited, cc_coef) def number_of_components(adj): global cc_array cc_array = [] # connected component array visi...
99539e3d7876a960fa7498b1797b1dc579126d1c
najuzilu/ucsd_algorithms
/Algorithms_on_String/week4/assignment/suffix_array_long/suffix_array_long.py
2,641
3.921875
4
# python3 import sys def sort_characters(s): """ Sort single characters """ alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' order = [None for _ in range(len(s))] count = [0 for _ in range(len(alphabet))] dict_map = {} # keeps track of mappings from letter to unique value # First iteration {s[i] appear...
b20c48f78e7e9ead7849a262a327b419abf97ee8
aloksharma999/GreaterNumber
/GreaterNumber.py
240
4.125
4
a = int(input('Enter the first number: ')) b = int(input('Enter the second number:')) if a > b: print(a,'is the bigger number') elif a <b: print(b,'is the bigger number') elif a ==b: print(str(a) + 'is equal to ' +str(b))
318398aa58fa552bd8a189e05b410f8f159e81ed
Vaibhav-2717/PythonSIP2021
/while.py
347
4.09375
4
# i = 1 # while i < 6: # print(i) # i += 1 # i = 1 # while i < 6: # print(i) # if i == 3: #break # break # i += 1 # i = 0 # while i < 6: # i += 1 # if i == 3: # continue #continue # print(i+1); i = 1 while i < 6: print(i) #else i += 1 else: print("i ...
384264b51f61977dcc85709d3b39c18aec7024d1
Hangyi/some_scripts
/003. judge_triangle/judge_triangle.py
600
3.671875
4
# 接受三角形三边,判断三角形形状 while True: try: a, b, c = map(float, input("输入三角形三边(以空格隔开): ").split()) except: print("输入有误,请重新输入\n") else: if(a + b <= c or a + c <= b or b + c <= a): print("输入的三边边长构不成三角形\n") else: if (a == b and a == c): print("是等...
8eb1b5f29d71bd8a128e70b4bf54328a23f9bef0
kpatel010/CS116
/Assignment 1/SIN.py
1,110
3.6875
4
def make_sin(partial_number): ''' Returns the 9 digit SIN givin the first 8 digits using a specifed algorithm make_sin: Nat -> Nat Requires Must be a 8 digit natural number Each digit in partial_number must be between 0 and 9 First digit cannot be 0 Examples...
adc3ffa4589eb3b72938769b44f262bd66dc7239
dychen/hackercup2014
/round1/coins_game/coins_game.py
1,076
3.515625
4
#FILENAME = 'coins_game_example_input.txt' FILENAME = 'coins_game.txt' OUTPUT = 'coins_game_output.txt' def calculate(num_jars, num_coins, target): record = [0] * N # Build the array that contains the minimum number of moves for each number of jars # from 1 to N. Note that the array indices are offset by 1...
e654ac0c8071c5720ce72df8bd013beffa640ab5
moo-nerim/20_Winter-Mogakco
/Lecture_02.py
1,432
3.984375
4
''' <21.01.06> 『목표』 ⊙ 파이썬 기초 문법 복습하기(2) 『결과』 - 조건문, 반복문 문법 학습 - 중첩반복문을 사용하여 별 모양 찍기 ''' ''' 반복문(for, while) a = range(1, 11) print(list(a)) for i in range(10): print(i) # 0 1 2 ... 9 for i in range(10, 0, -1): # 1씩 작아짐 print(i) # 10 9 8 ... 1 ''' # while문 i = 1 while i <= 10: print(i) i = i+1 ...
9664b1c928dfbe55d8083f5bf2391c582d48f753
veezhang/create-features-demo
/src/server.py
2,207
3.671875
4
from flask import Flask, request, render_template, session, redirect import pandas as pd from types import ModuleType app = Flask("create-features-demo", static_folder="static", template_folder="templates") # example data example_df = pd.DataFrame({ 'age': [4, 23, 45, 16, 32], 'posX': [0, 1, 2, 3, 4], 'p...
237c69200e477732fec81c7e8695e5848d2a0f10
jrg-sln/basic_python
/funRec.py
609
3.640625
4
cadena = "avada kedavra" contador = 0 while contador < 10: print cadena contador = contador + 1 def cuenta(limite): i = limite while True: print i i = i -1 if i == 0: break # Rompiendo el ciclo def factorial(n): i = 2 tmp = 1 while i <n+1: tmp...
7a864aba254e7531917b197c8dcc53e3cd0e20ce
jrg-sln/basic_python
/comparaciones7.py
935
4.21875
4
# -*- coding: utf-8 -*- ###########################Ejercicio sobre comparaciones#################### '''Ahora que ya sabe utilizar comparaciones hacer un programa que contenga la edad de varias personas y decir si es cierta o falsa la afirmación mediante una función, además use la impementación de la función main''' ...
b917243a6b00014da9415c8083b244ad38cabbb2
ettynan/Revature
/projects/project0/vehicles/model.py
2,677
3.5625
4
'''Vehicle model defining vehicle class behavior and attributes''' from project0.offers.model import Offer class Vehicle(): '''Class for storing vehicle information''' def __init__(self, db_id=-1, make='', model='', year='', color='', price=0): self._id = db_id self.make = mak...
e5bd4811160d514a5479df7f7793538cbb2b8fc7
leo-faizan/PythonBasics
/pythonBasics/BinarySearch.py
433
3.75
4
import random lst = (random.sample(range(1, 100, 2), 50)) lst.sort() key = int(input("enter the number to be searched: ")) l,r = -1,len(lst)+1 while(l <= r): mid = (l + (r-1)) // 2 if lst[mid] == key : print("number found in position", mid+1) break elif lst[mid] < key : l = mid...
5f4783efff3f567033bff8c2752602a13a3b7b2e
jackfish823/Hangman_Python
/Guess.py
597
4.125
4
import re #lib to search in a string def is_valid_input(letter_guessed): # checks if the function the input letter_guessed is good spread_guess = re.findall('[A-Za-z]', letter_guessed) #list of the guess_input of only english if len(letter_guessed) == len(spread_guess): if len(letter_guessed) =...
622568f3d5835402bad8b6459ae40bad5a40f6bc
osmr/imgclsmob
/tensorflow2/datasets/cls_dataset.py
735
3.71875
4
""" Classification dataset routines. """ __all__ = ['img_normalization'] import numpy as np def img_normalization(img, mean_rgb, std_rgb): """ Normalization as in the ImageNet-1K validation procedure. Parameters: ---------- img : np.array ...
4da5a0fab0cc0348a09b7c01823a14fdbf37753d
zqy628/hellogit
/day14.py
907
3.71875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' 用 Python 实现一个简单的微信红包算法 基本思路就是,有多少个红包,就循环多少次,每一次,在剩下的钱里面随机出一个值作为这个红包的金额,然后把金额从总金额中扣除。 这里要注意,需要保证每个人至少能拿得到 1 分钱。只剩最后一个人时,拿走剩下所有的金额。另外,为了保证计算时候方便,采用“分”作为金额的计算单位。 ''' import random def hongbao(): print '发送红包总金额:' money = input()*100 print '抢红包人数:' people = ...
ed07e02de1d08dc42835bebf8f2cc76321187cbc
zqy628/hellogit
/day33.py
1,208
3.8125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' 现有一个 m × n (m,n 都小于 100)的网格,位于左上角的 A 要去寻找右下角的 B,A 只能向下或者向右行走, 现在问题来了,按照刚才的规则,A 到达 B 一共有多少种不重复的路径? ''' # 转化成一个组合问题,C(m+n-2,m-1) from math import factorial def uniquePath(m, n): ''' :type m: int :type n: int :rtype: int ''' # your code here re...
71eda87427baaef70e6793e5e209bc34e11f5a00
zqy628/hellogit
/day15.py
1,225
3.609375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' 给你一个正整数n, 编程求所有这样的五位和六位十进制回文数,满足各位数字之和等于n(5<=n<=54)。 按从小到大的顺序输出满足条件的整数。 ''' import time startTime = time.time() # print startTime print '需满足的各位数之和:' sumInput = input() num_1 = [] for num in range(10000,1000000): sum = 0 lenth = len(str(num)) i =0 j = le...
96313c523fb6de7e349d334e8920f8646ee41f52
Sgiomlaireachd/PrivatBank_API
/PB_API/tutorial.py
1,700
3.5625
4
import requests import matplotlib.pyplot as plt def getAmount(month): if month == 2 : return 28 if month <= 7 : if month % 2 : return 31 else: return 30 else: if month % 2 : return 30 else: return 31 def getNeededDictionary(l,currency): for d in l: if d...
05fb5026f31cf26412666ea636395a8c0828b80e
DavidAlexandreTS/Deep-learning-projects
/Building a Recurrent Neural Network/Solution.py
32,393
3.6875
4
import numpy as np from rnn_utils import * # GRADED FUNCTION: rnn_cell_forward def rnn_cell_forward(xt, a_prev, parameters): """ Implements a single forward step of the RNN-cell as described in Figure (2) Arguments: xt -- your input data at timestep "t", numpy array of shape (n_x, m). ...
20fc7afb03d571408242c705e082c63978ecdaf0
szarroug3/Coding_Practice
/advent_of_code/2018/day06.py
2,346
3.6875
4
# !/bin/python3 # https://adventofcode.com/2018/day/6 from collections import defaultdict from utils import read_input def manhattan(a, b): x = a[0] - b[0] if x < 0: x *= -1 y = a[1] - b[1] if y < 0: y *= -1 return x + y def find_closest(curr, coords): di...
0d10c2def09c481db3739b9c561f3ee485f9b81e
szarroug3/Coding_Practice
/advent_of_code/2017/day21.py
2,321
3.640625
4
# !/bin/python3 # http://www.adventofcode.com/2017/day/21 from math import sqrt from utils import read_input def flip_x(grid): for i, row in enumerate(grid): grid[i] = row[::-1] return grid def flip_y(grid): return grid[::-1] def rotate(grid): rotated = [[] for x in grid...
326ac098791f41144eee5bc4c66b3a7516fd4a19
szarroug3/Coding_Practice
/advent_of_code/2017/day14.py
2,311
3.71875
4
# !/bin/python3 # http://www.adventofcode.com/2017/day/14 from utils import read_input from day10 import get_knot_hash def get_binary(knot_hash): binary = '' for c in knot_hash: integer = int(c, 16) binary += bin(integer)[2:].zfill(4) return binary def get_row(hash): ...
cbb25ca1352241aedcc999b5b65652bd9a8dc775
szarroug3/Coding_Practice
/advent_of_code/2017/day07.py
2,705
3.875
4
# !/bin/python3 # http://www.adventofcode.com/2017/day/7 from utils import read_input def parse_input(tower_info): for info in tower_info: info = info.split() subtowers = [] # get basic info name = info.pop(0) weight = int(info.pop(0)[1:-1]) # if w...
72de34f8b015cb67e8cd1a02acec0582cbc7c127
szarroug3/Coding_Practice
/hacker_rank/brute_click_o_mania.py
3,549
3.5
4
# !/usr/bin/python3 # https://www.hackerrank.com/challenges/click-o-mania/problem from copy import deepcopy from collections import defaultdict def get_connected(x, y, color, grid, visited): visited.append((x, y)) if x - 1 >= 0 and grid[x - 1][y] == color and (x - 1, y) not in visited: vi...
b938aa46dc667da21ac7978714db6b1372c5c3e7
Ramcharanprc/Python_programs
/socketPractice.py
442
3.65625
4
# Creating local server. import socket socketObj = socket.socket() print('Socket created successfully.') port = 221 socketObj.bind(('', port)) print('Socket binded to port: ' + str(port)) socketObj.listen(10) print('Socket is listening.') while True: client, address = socketObj.accept() message = "Welcome to Ram's s...
3ddef02ec1c24cc5d3e8821eebafed45ef49d2ac
JudyJiang/Python-Learning
/small practise/cookbook/descriptor2.py
2,443
3.921875
4
class Descriptor(object): def __init__(self, name=None, **opt): self.name = name for key, value in opt.items(): setattr(self, key, value) #descriptor, class that use the __set__ or __get__ #second argu is "instance" cause class instance can be set value to def __set__(self, instance, value): instan...
e6eb623fd554f282b745f1d5d2489bceff51342a
victoruribehdz/programing-2
/10 Exercises (C+Python)/Problem2.py
425
3.984375
4
#Given a list of strings delete all special chars in each one (non-alphanumeric chars). ini_string = "Ay%mi/madre$el?comandante#CR7*" #Type the string print ("initial string : ", ini_string) #Print the initial string getVals = list([val for val in ini_string if val.isalnum()]) #Delete all the special characters res...
052abb4e2e5291a2f7e5b5d9e52d77c52adaf19d
Jobsy/Sorting
/src/recursive_sorting/recursive_sorting.py
1,235
4.03125
4
# TO-DO: complete the helpe function below to merge 2 sorted arrays def merge(arrA, arrB): # elements = len( arrA ) + len( arrB ) # merged_arr = [0] * elements # TO-DO i = j = 0 k = [] while i < len(arrA) and j < len(arrB): if arrA[i] <= arrB[j]: k.append(arrA[i]) ...
ecfc083467a06ff836565a89858b8218e64bd56b
npradha/multTables
/multTables.py
386
4.28125
4
while True: print("\n") print("What number do you want the multiplication table of?") num = input() print("\n") for mul in range(13): answer = num * mul print(str(num) + " x " + str(mul) + " = " + str(answer)) print("\n") print("Do you want to input another number? (y/n)") ans = raw_input() if ans == 'y':...
b8fde136005138a7824945c14e63c9674d158bdd
seignovert/python-webgeocalc
/webgeocalc/decorator.py
1,422
3.65625
4
"""Webgeocalc decorators.""" from .errors import CalculationInvalidAttr from .vars import VALID_PARAMETERS def parameter(_func=None, *, only=None): """Parameter decorator setter with a validation check. Can be used in the following forms: - @parameter - @parameter() - @parameter(only='VALID_PAR...
20b3bba2480a4ec504aee0a1db35c01348c1b21d
Unrealplace/PythonProject
/基础知识学习/list_demo.py
1,440
4.25
4
arr = ['hello','world','nice to ','meet','you'] print(arr) # for 循环遍历 for x in arr: print(x) pass #通过下标来取列表中的元素 print(arr[0]) print(arr[-1]) #列表的增删改查操作 motor_cycles = ["honda","ymaha","suzuki"] # 列表末尾增加一个数据 motor_cycles.append("nice to meet you") # 修改 motor_cycles[1] = "oliverlee" #插入元素 motor_cycles.insert(0,"liy...
585fcfed03865a69f179d04818c5e1e1cf6cd470
MaxCosmeMalasquez/Ejercicios-Python-
/example2.12.py
943
4.125
4
# print("Write first number") # x = int(input()) # print("Write second number") # y = int(input()) # print("Write third number") # z= int(input()) # cadena = [x,y,z] # cadena.sort() # print(cadena) print("Write first number") x = int(input()) print("Write second number") y = int(input()) print("Write third number") z...
00dcc32d5b2be81fd6b37f355602bf951324d421
MaxCosmeMalasquez/Ejercicios-Python-
/ejemplo 2.1.py
254
3.953125
4
edad = int(input("Write your age : ")) if edad >= 18 : print("You´re " + str(edad) + "years old " ) print("You´re of age " ) else : print("You´re " + str(edad) + " years old" ) print("You are a minor") print("End of the program")
5e788b49112382d66d7d024cf6a0338d8b761afb
MaxCosmeMalasquez/Ejercicios-Python-
/while/for_2.py
306
3.953125
4
# for x in range(5,0,-1): # print(x , end=" ") # for nombre in ["Andres" , "Cosme"] : # print(nombre) # for x in range(5,0,-1) : # print(x , end=" ") print("Número elegido") nro = int(input()) total = 0 while nro != 0 : total+=nro print("Número elegido") nro = int(input())
6d4194036a4a17ba5c3e63615f6ec9a802ed08b4
MaxCosmeMalasquez/Ejercicios-Python-
/if2.py
300
4
4
contra = "andres" print("Ingresar contrasseña") clave = input() while clave != contra : print("Clave incorrecta") print("¿Desea volver a intentarlo? (S/N) :") OT_vez=input() if OT_vez.upper() == "N" : break if clave == contra : print("ingreso correcto") print("End")
59c1d30c9ecc3ad65efd3536e43356f07b5ea381
MaxCosmeMalasquez/Ejercicios-Python-
/example 2.7.py
446
4
4
print("Your first number") x = int(input()) print(" Your Second number") y = int(input()) if x >=0 and y>0: print("The result is " + str(x/y)) elif x == 0 : print("The result is " + str(x/y)) elif x< 0 and y < 0 : print("The result is " + str (x/y)) elif x<0 and y>0 : print("The result is " + str(x/y...
5aeea5f7b4f29fa39b4a353099595437ca13f51d
MaxCosmeMalasquez/Ejercicios-Python-
/ejerc14.py
148
3.59375
4
print("Juguemos") print("Brindame tu primer número") x = input() print("Segundo valor") y =input() z = (x + y ) print(str(z)) print(str((z)[::-1]))
0e04eb65b6c9c86e674835ca05d69fc01c7a02ba
MaxCosmeMalasquez/Ejercicios-Python-
/while/for/example1.py
1,096
3.921875
4
# print("Write your number") # x = int(input()) # i = 1 # for x in range(1,6): # i=i+1 # # final = i*x # # # print(final) # # print("Introdzca your number" ) # # x = int(input()) # # while x<=20 : # # x=1+x # # if x%2 ==0 : # # print(x) # #suma # print("Introdzca your number" ) # ...
8be300345e7d4f717d7815370db9bb7e91ef1901
celenksercan/Python
/createModule.py
319
3.609375
4
''' modul hakkında bilgilendirme ''' print('modul başarıyla eklendi.') number=10 numbers=[1,2,3] person = { "name": "Sercan", "age":"24", "city":"istanbul" } def func(x): ''' fonksiyon hakkında bilgilendirme ''' class Person: def speak(self): print('I speak English.')
cecac20ff590e1f506e966c426acb4f55f35923f
gosephjoh/encore-examples
/211/regex/regex_time.py
647
3.5625
4
""" Class Encore CIS 211 w/ Joseph regex_time.py Author: Joseph Goh Updated: 02/25/2021 """ import re time_pat = re.compile(""" # 24 hour clock (?P<hr> (0?[1-9]) # 01..09, 1..9 | (1[0-9]) # 10..19 | (2[0-4]) # 20..24 ): (?P<min>([0-5][0-9]) # 00..59 ): (?P<sec>([0-5][0-9]) # 00..59 ) """, re.VE...