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
ab23c463b85133fef8bc1284cdd630b9a99d28a7
Arch32/p-97
/guessingGame.py
652
4.03125
4
import random noOfGuesses=0 number = random.randrange(1,99) print("Guessing Game") print("Guess The from 1-100 in 8 guesses") state=0 while(noOfGuesses<8 and state == 0): Guess=int(input("Type Your Guess : ")) noOfGuesses=noOfGuesses+1 if(number>Guess ): print("The Number Is Greater Than ",Guess...
6b3b04604d1eb5c3fb9451eb6851b543e73859fd
Usharbudha/Python-Programming
/week 2.py
3,659
4.03125
4
# week 2 #functions def greet(): print('Hi, How are you?') greet() def greet(user): print(f'Hi {user}, you ran great.') greet('Usharbudha') def fav_book(user,book): print(f"{user} likes to read {book}") fav_book('Usharbudha','Fiction') def add(a,d): c=a+d return ...
aaefdc50a13f6da2f6dc686d3d102cd41aff7866
brunnoaraujo/folhinha
/sql.py
419
3.890625
4
import sqlite3 # create a new database if the database doesn't already exist with sqlite3.connect('sample.db') as connection: # get a cursor object used to execute SQL commands c = connection.cursor() # create the table c.execute('CREATE TABLE dados(temp TEXT, ldr TEXT, hora TEXT )') # insert du...
eccb0fa73ad5533126e9f2d1f1c71149d96b9b35
Otsuhachi/Price_sharing_LCB
/inner/funcs.py
1,897
3.921875
4
def generate_words(text): """受け取った文字列を1文字ずつ減らして返します。 Args: text (str): 文字列。 Examples: >>> list(generate_words("Examples")) ['Examples', 'Example', 'Exampl', 'Examp', 'Exam', 'Exa', 'Ex', 'E'] """ len_ = len(text) for i in range(len_): yield text[0:len_ - i] d...
48b51f3860102f80ecd734527b7f1b4f989b5bed
JayVer2/Python_intro_week2
/9_classes.py
373
3.859375
4
class cat: def __init__(self): self.size=40 self.colour="Blue" self.breed="Persian" def meow(self): print("Meow! I'm a "+self.colour+", "+self.breed+" cat.") bella = cat() daisy = cat() print(bella.size) print(bella.breed) #Change this cats breed & colour daisy.breed = "tabb...
4d726618926c5e8d18a6f6a1f6b69fe670c46ad5
JayVer2/Python_intro_week2
/7_dictionaries.py
469
4.125
4
#Initialize the two dictionaries meaningDictionary = {} sizeDictionary = {} meaningDictionary["orange"] = "A Fruit" sizeDictionary["orange"] = 5 meaningDictionary["cabbage"] = "A vegetable" sizeDictionary["cabbage"] = 10 meaningDictionary["tomato"] = "Widely contested" sizeDictionary["tomato"] = 5 print("What defi...
5b2e73c900fd78251702f4936d06f706b7bf0a72
dyr429/CartoGenerator
/TweetCollector.py
1,283
3.546875
4
#Created by Alex Ding #Python 2.7.1 #Collect tweets via tweepy API #Last Modified 4/27/2015 ############################################### import sys import tweepy import csv import json ################################################## consumer_key = "m9NJIKYkgwDBawW9lomDA" consumer_secret = "AwpRUyN7IiI5wpvw1RjyiA...
7ac50bea75c77e2b9f56b3309861c82f3937a76d
RSRamKumar/Programming_Lab_1
/sample solutions/handout 3/icosian.py
1,675
3.625
4
import sys # Describe a graph by its node (first letter) and its neighbors (following letters) g0= [ 'bcgz','cbdp','dcfm','fgdk','gbfh', 'qprz','pcnq','nmps','mdln','lkmt','kfjl','jhkv','hgjx','xhwz','zbqx', 'rqsw','snrt','tlsv','vjtw','wrvx' ] # Code the graph using a dictionary where each node is associ...
288746d6e471630d86fa7e2ef35de13a5d3d366b
yghkali/onekali
/course/test02.py
4,265
3.859375
4
''' #EP:1 import math r=eval(raw_input('Enter the length from the center to a vertex:')) pi=3.14 s=float(2 * r * math.sin(math.pi/5)) area =float( 5 * s * s / (4 * math.tan(math.pi/5))) print('The area of the pentagon is{}:'.format(area)) ''' ''' #EP:2 ji he xue import math x1,y1=eval(raw_input('Enter point 1 (x1 and ...
6585568752586aad9ab284fd25dcb6d1a6eeeb00
levalleyjack/RC-Car
/serialtest.py
1,331
3.671875
4
''' Program for reading and parsing data from a GPS connected to the Raspberry Pi serial pins Author: Jacob Sommer Date: 2020-01-20 ''' import time import serial import pynmea2 def parseGPS(str): ''' Parses the raw GPS data using pynmea2 ''' if 'GGA' in str: # the line containing all of the GPS data is identif...
b019d0cd997e8c94e5af01ff7f05f0ff8496ba70
avyartemis/UoPeople.CS1101.PythonProgrammingAssignments
/RainbowColors (Inverted Dictionary).py
1,544
4.28125
4
# CS1101(Intro To Python). Chapter 11: Dictionaries. Week 7. By Avy Artemis. # Theme: Creating an Artistic Inverted Dictionary RainbowColors = {'C1': ['Red', 'Rose', 'Sangria', 'Scarlet', 'Warm Colours'], 'C2': ['Orange', 'Carrot', 'Sandstone', 'Warm Colours'], 'C3': ['Yellow', 'Bu...
99181ce5c62c3ca64de06ff2b2333aa7bb3b3ad8
kjco/hb_homework
/accounting-scripts/melon_info.py
1,270
3.859375
4
"""Print out all the melons in our inventory.""" from melons import melon_lst, info_lst, melon_info_dict def print_melon(name, seedless, price): """Print each melon with corresponding attribute information.""" have_or_have_not = 'have' if seedless: have_or_have_not = 'do not have' # print(f...
6299ed3b2d3050e8e22e6dbac7ba97803f613d1d
mohitsharma98/DSA-Practice
/selection_sort.py
310
3.859375
4
def selection_sort(a): n = len(a) for i in range(0, n-1): mini = i for j in range(i+1, n): if (a[j]<a[mini]): mini = j a[i], a[mini] = a[mini], a[i] return a if __name__ == "__main__": a = [3,2,5,7,3,1,6,9,4] print(selection_sort(a))
b56bdb3019523f776ca7e6078a04ca14f9a2bd92
mohitsharma98/DSA-Practice
/queue.py
563
4.125
4
class queue: def __init__(self): self.s = [] def enqueue(self, x): self.s.append(x) def dequeue(self): if len(self.s)>=1: self.s = self.s[1:] else: print("Queue is empty!") def show(self): print(self.s) if __name__ == "__main__"...
fa713d8dbcb9271ee54a17688e6f5663314793cb
theoioana/ArtificialIntelligenceSchoolProject
/Code/test_module.py
1,666
3.984375
4
from RomaniaMapBuild import * from queue import PriorityQueue def dijsktra(initial, destination): """ This function calculates the shortest cost path from a source city to all the others city in romania_map. The dictionary romania_map represents the adjaency list of the graph on which Dikjstra algorithm ...
a1c2ff5d988ac41612233f09ee6422e06f7581dc
Cookie182/DAA
/Lab_2/Lab_2_DAA.py
14,083
3.84375
4
import numpy as np import pandas as pd from matplotlib import pyplot as plt import time import psutil import os from collections import deque # list of n numbers taken into consideration n = [10, 100, 1000, 10000, 100000, 250000, 500000, 750000, 1000000] """ The IDE i am using (Atom) crashes when i have to show all t...
4207246674a228f5ab87bf29c41ef6677a1165fc
jaclynchorton/Python-MathReview
/Factorial-SqRt-GCD-DegreeAndRadians.py
556
4.15625
4
#------------------From Learning the Python 3 Standard Library------------------ #importing math functions import math #---------------------------Factorial and Square Root--------------------------- # Factorial of 3 = 3 * 2* 1 print(math.factorial(3)) # Squareroot of 64 print(math.sqrt(64)) # GCD-Greatest Common Den...
6dbfd0b3e50f66e8023f46d013ff78a829286013
rol1510/AoC-2020
/Day-9/main.py
873
3.5
4
import itertools data = [] with open('input.txt', 'r') as file: data = [int(x) for x in file.readlines()] def is_valid(number, number_set): for a, b in itertools.combinations(number_set, 2): if a+b == number: return True return False def find_subset_of_size(target, number_set): fo...
ff3a6864704a341270542506e76e6a033ecfbf08
dyslexda/mln_scripts
/pa_sim.py
2,754
3.578125
4
import random class pa_simulator: # def __init__(self, pitch, swing, pitcher, batter, brc, result): def __init__(self, brc, result): # self.pitch = int(pitch) # self.swing = int(swing) # self.pitcher = pitcher.split('|') # self.batter = batter.split('|') self.brc =...
0c42486c66278ce62cf74133b9cd882994f7a09a
abuk74/Lista-zaliczeniowa
/Zad.6.py
1,932
3.734375
4
def Main(): inDef = str(input("Wybierz jednostke wejściową: C - Celsjusz, K - Kelwin, F - Fahrenheit, R - Rankine")) outDef = str(input("Wybierz jednostke wyjściową: C - Celsjusz, K - Kelwin, F - Fahrenheit, R - Rankine")) if inDef == outDef: print("serio?") return namesOfDef = [inDef,...
2ae0df42fe1638f5ebe57052e9ff23f227032e6e
abuk74/Lista-zaliczeniowa
/Lab12.py
2,639
3.90625
4
#zad2 ''''' import math as m def Main(): figure = input("Wybierz swoją figurę: K - Kula, S - Stożek, P - prostopadłościan") if figure == "K": Kula() elif figure == "S": Stozek() else: Prostopadloscian() def Kula(): r = float(input("Podaj promien kuli: ")) if r <= 0: ...
81f729b0100e988bcee1cc3f42cc42f7604039f3
abuk74/Lista-zaliczeniowa
/Sem2/14 (2).py
3,122
3.71875
4
import math class Figure: def __init__(self, numOfSides, isSquere): self.numOfSides = numOfSides self.isSquere = isSquere class Square(Figure): def __init__(self, numOfSides, isSquere): super().__init__(numOfSides, isSquere) def SquareArea(self, lenghtOfSide): if lenghtOfS...
032ea1f6556ce70ae28768bee6647fe683d8196b
JuliaAvez/inputs
/perfdataerr2.py
1,782
3.578125
4
#!/usr/bin/python import math import fileinput import sys def file_len(fname): # this is the counting function for lines in a file only with open(fname) as f: for i, l in enumerate(f): pass return i + 1 def replaceAll(file,searchExp,replaceExp): for line in fileinput.input(file, inpla...
a6e2bedbbe545a3f5cd1d91a99d985e7492b2611
pilihaotian/pythonlearning
/leehao/learn42.py
662
3.921875
4
# exec # 和eval略微不同,也是把字符串当作《程序文件》*.py来执行 # exec就是python编译器编译python语言文件的时候,调用的函数 # 如 s = cat a.py exec(s) # 格式:exec(表达式,全局变量(None),局部变量,(None)) # 自己写一个编译解析器,编译用户输入的语句 while True: s = input("请输入语句(bye结束)>>>") if s == 'bye': break else: exec(s) # 测试 # 请输入语句(bye结束)>>>a = 100 # 请输入语句(bye结束...
f08f9e36304298f966ad9142eacf7dd1839ac506
pilihaotian/pythonlearning
/leehao/learn8.py
252
3.734375
4
# 输入一些行文字,将文字保存在列表中,当输入空行时结束,并打印列表 L1 = [] while True: s = input("请输入文字(输入空行结束):\n") if s == '': break else: L1.append(s) print(L1)
305938b336b4ec01c878757542ed965f1245088f
pilihaotian/pythonlearning
/leehao/learn53.py
462
3.609375
4
# 装饰器 decorators # 用法 @函数 # 一个函数,主要作用是包装一个函数或类 # 传入一个函数 返回一个函数 def my_decorators(fn): # 装饰器函数 def fx(): print("fx开始") fn() print("fx结束") return fx def hello(): # 被装饰函数 print("hello,leehao") hello() # hello,leehao hello = my_decorators(hello) # 此种做法可以用装饰器@语法解决 hello() # h...
ef5bcf1e19834ae3bcc1742a824e986bef604ddf
pilihaotian/pythonlearning
/leehao/learn116.py
1,008
3.71875
4
# 异常(高级) # 异常处理5条语句 try except、try finally、raise、assert、with # with 用于对资源访问的场合,无论异常是否发生,都会执行必要的清理工作 # with 表达式1[as 变量1],...... # with 与 try finally相似,相对简洁 # with目前只能用于文件的打开与关闭 # 不用with的方式 try: f = open('test_data.txt') try: while True: s = f.readline() if not s: ...
175fc8b0765f2ee0c436b87bf6b9a7b5b92eae41
pilihaotian/pythonlearning
/leehao/learn41.py
716
4.09375
4
# eval # eval函数把字符串当作表达式执行 # 语法 eval(表达式,全局变量(None),局部变量,(None)) # Demo1 print(eval("max([1,2,3])")) # Demo2 a = 2 b = 2 # 取值顺序,从右到左,如果都没有,那么取内建值即a=2 b=2 print(eval("a+b")) print(eval("a+b", {"a": 10, "b": 20})) # 此处的a、b的值不从上面的a和b取 在本地取全局变量 # print(eval("a+b", {"a": 10})) # 报错,无法取到b的值 print(eval("a+b", {"a": 10, "...
d0c7bab49992c2e2fc6dbd76104d6846183eb51a
pilihaotian/pythonlearning
/leehao/learn104.py
746
4.125
4
# 继承、派生 # 继承是从已有类中派生出新类,新类具有原类的行为和属性 # 派生是从已有类中衍生出新类,在新类中添加新的属性和行为 # 基类、超类、父类、派生类、子类 # 单继承 class Human: def say(self, what): print("说", what) def walk(self, distance): print("走了", distance, "公里") class Student(Human): # 重写父类 def say(self, what): print("学生说", what) def ...
f13bf8e78ff5dbf61a7eb39e27da2b976883dc7b
pilihaotian/pythonlearning
/leehao/learn103.py
476
3.578125
4
# 面向对象编程 # 静态方法 定义在类内部的函数,函数的作用域是类内部 # 静态方法需要@static装饰符定义 # 静态方法和普通方法相同,不需要传入self和cls # 目的:静态方法只能凭借该类和该实例调用,限制作用域 # 静态方法不能访问类变量和实例变量 class A: @staticmethod def my_add(a, b): print(a + b) A.my_add(100, 200) # 类调用 A().my_add(300, 400) # 实例调用
cbb00184a9c60ad7f86f4ef63fe2608eb438f2f1
pilihaotian/pythonlearning
/leehao/learn115.py
1,004
3.703125
4
# *************重点******** # 重写 # 为一个类写迭代器 next iter class MyList: def __init__(self, iterable): self.data = [i for i in iterable] self.length = len(self.data) self.cur_pos = 0 # 游标位置初始化为0 def __repr__(self): return 'MyList(%s)' % self.data # 重写iter,返回自身 def __iter__...
1d23d183f299a908a041cc7b6c9af56a301b471a
pilihaotian/pythonlearning
/leehao/learn135.py
2,041
3.578125
4
# re模块 正则表达式 import re s = 'My email is 568233708@qq.com,pilihaotian@163.com' print(re.findall('\w+@\w+\.com', s)) print(re.findall('abc', 'abcdefghij')) print(re.findall('ab|cd', 'abcdefghij')) print(re.findall('ab|bc', 'abcdefghij')) print(re.findall('.oo.', 'it looks like a good book.')) print(re.findall('^hel...
ea9d9c568f5b0ec2cb445310c02fa7e4ba7837b0
pilihaotian/pythonlearning
/leehao/learn81.py
184
3.96875
4
# bytes与str互转 # str->bytes encoding # bytes->str decoding s1 = 'hello,世界!' print(s1) b = s1.encode(encoding='utf-8') print(b) s2 = b.decode(encoding='utf-8') print(s2)
ec72f0b37fe7c5788eba498b622f788bc7dd1352
pilihaotian/pythonlearning
/leehao/strTest.py
289
3.625
4
print("Tom\'s pet is cat. The cat\'s name is \"tiechui\"") a = 'Pyth' b = 'on' c = 3 print(a+b,c) print('\U00000319') print(ord('a')) print(chr(100)) print(a.isalnum(),a.isalpha(),a.isascii(),a.isdecimal(),a.isdigit(),a.isidentifier()) print("abc".center(20)) print("abc".center(20,'*'))
25cd60838b79f1996bb387d475dc64059e28cbd4
pilihaotian/pythonlearning
/leehao/learn92.py
912
3.84375
4
# 面向对象编程 # 类 # 类名(继承列表) # """类文档字符串""" # 实例方法的定义 # 类变量的定义 # 类方法的定义 # 静态方法定义 # 类的定义最后面加2个空格告诉解析器 类的定义已结束 class Student: def __init__(self, n, a, s): self.name = n self.age = a self.score = s def input_student(): L = [] while True: n = input("姓名:") if not n: ...
2224661c31e9cb4b657b14e380afedf1ca824c07
pilihaotian/pythonlearning
/leehao/learn25.py
376
3.5625
4
# 集合练习 # 经理 Manager = {"李浩", "刘备", "孙权", "曹操"} # 技术员 IT = {"李浩", "诸葛亮", "孙权", "司马懿"} # 二者都是 print(Manager & IT) # 只是Manager print(Manager - IT) # 只是IT print(IT - Manager) # 李浩是经理吗 print("李浩" in Manager) # 身兼一职的 print(Manager ^ IT) # 共有多少人 print(len(Manager | IT))
62db85d50d83dd86130783ba0ba36e67859fac9a
Tella-Ramya-Shree/Python_Assignment
/321810304048- Circumference of a circle.py
157
4.53125
5
#circumference of a circle pi=3.14 r= float(input('Enter radius of the circle:')) circumference=2 * pi * r print('circumference of a circle:',circumference)
a84265799e3ca8bdc48e7d1fb7fcac6bebb59d51
Whompithian/css527-project1
/des.py
26,760
4.125
4
#! /usr/bin/env python3.3 """DES implementation in Python by Brendan Sweeney, CSS 527, Assignment 1. Command-line driven implementation of the DES encryption algorithm in cipher- block chaining mode. There are three modes of operation: genkey, encrypt, and decrypt. genkey mode takes a password on the command line and...
1958639d0b6fc5cfa5897d89a0512ff257da8305
Jujhar/Typeform-CSV-Generator
/main.py
2,307
3.5625
4
# This file saves form responses from typeform.com into a CSV file with a title # row composed of questions # ***** *** * *** ****** # Created by Singh 2017 import requests, csv api = "XXXX" formNumb = 0 # Select which form to get data from, default 0 for first form # Get all forms via api key and retrieve form UID...
b582d0dced5a0303819dd5a8a3cb3b7d50fbe648
sevkembo/code_examples
/dice.py
1,094
4.21875
4
from random import randint class Dice: def __init__(self, sides=6): self.sides = sides def roll_dice(self): if self.sides == 6: print(randint(1, 6)) elif self.sides == 10: print(randint(1, 10)) elif self.sides == 20: print(randint(1, 20)) w...
690d9f3323ced474c50599171f6b6e124379e8d5
jinyuaa/201905-Practise
/2-Softmax-Regression/01-softmax.py
2,501
3.984375
4
# softmax 回归实例 # sklearn.datasets 自带的小数据集 手写体数据集 y:{0 1 2 3 4 5 6 7 8 9} # (1797,64) data 8x8大小 import numpy as np from sklearn.datasets import load_digits from sklearn.model_selection import train_test_split from sklearn import preprocessing def load_data(): digits = load_digits() x_data = digits.data y...
005aa3769f6c1fa7f281bfd101c6cf1dc60dec41
jinyuaa/201905-Practise
/CNN/5-1d-tensorflow.py
5,749
3.609375
4
# 训练样本过少,模型参数过多,容易过拟合 # 表现:训练集损失小,准确率很高,测试集损失大,准确率低 # Tensorboard 可视化网络结构图,损失及精度,调入接口 tf.summary from tensorflow.examples.tutorials.mnist import input_data import tensorflow as tf import pandas as pd import numpy as np from sklearn.model_selection import train_test_split import matplotlib.pyplot as plt # 数据预处理(规范化) ?...
e2ef7845e39bb0a1cf59b836198fadd722dfd0cd
larq/larq
/larq/quantizers.py
23,775
3.734375
4
"""A Quantizer defines the way of transforming a full precision input to a quantized output and the pseudo-gradient method used for the backwards pass. Quantizers can either be used through quantizer arguments that are supported for Larq layers, such as `input_quantizer` and `kernel_quantizer`; or they can be used sim...
0eacae023b58e7727bcfcec37684d47ab49ddfbb
Jabed27/Data-Structure-Algorithms-in-Python
/Algorithm/Graph/BFS/bfs.py
1,508
4.25
4
# https://www.educative.io/edpresso/how-to-implement-a-breadth-first-search-in-python from collections import defaultdict visited = [] # List to keep track of visited nodes. queue = [] #Initialize a queue #initializing a default dictionary with list graph=defaultdict(list) parent=[] dist=[] def init(n): for ...
74d32f995e371e4fed55de937c838789d4f6446e
Jabed27/Data-Structure-Algorithms-in-Python
/Algorithm/Graph/DFS/dfs.py
840
3.9375
4
#https://www.educative.io/edpresso/how-to-implement-depth-first-search-in-python#:~:text=Depth-first%20search%20(DFS),structures%20like%20dictionaries%20and%20sets. # Using a Python dictionary to act as an adjacency list from collections import defaultdict WHITE=1 GREY=2 BLACK=3 #initializing a default dictionary w...
a4a2e639b8c672ebfdb7f8b67f1f567c1ebc704e
Programmer7129/Python-Basics
/Functions.py
444
4.25
4
# For unknown arguments in a function def myfunc(**name): print(name["fname"]+" "+name["lname"]) myfunc(fname="Emily", lname="Scott") def func(*kids): print("His name is: "+ kids[1]) func("Mark", "Harvey", "Louis") # Recursion def recu(k): if(k > 0): result = k + recu(k-1) ...
b62519c97a4ae36a621b0eaa7cd9c3a24a333824
HG13BB/codingchallenges
/bin_tree_check.py
655
3.9375
4
def TreeConstructor(strArrlist2): ''' Determine if list of quoted tuples is valid construction of binary tree. list of quoted tuples --> string ''' # code goes here parents = {} for i in range(len(strArrlist2)): if strArrlist2[i][3] in parents: if parents[strArrlist2[i]...
9d781a07241316a5b2210e37aa7057ac664ed363
PApostol/PythonFun
/Sorting/Sort_Merge.py
404
3.9375
4
# O(nlogn) def merge_sort(mylist): if len(mylist) < 2: return mylist less = [] equal = [] greater = [] n = int(len(mylist)/2) pivot = mylist[n] for x in mylist: if x < pivot: less.append(x) elif x == pivot: equal.append(x) elif x > pivot: ...
d33c81c69d569c9216c4b222a6e30004f48fbd8b
PApostol/PythonFun
/sqlite3.py
882
3.609375
4
# create a database and add input & output import os, sqlite3 def writeToDatabase(myinput, myoutput): path = os.getcwd() if not os.path.exists(path+'/database/'): os.mkdir(path+'/database/') # create database if first time # columns: id, input, output if not os.path.isfile(path+'/database...
400c0c70bde70f658113afebfa113e2a2bb08847
BobBriksz/dsu3s3
/rpg_queries.py
3,589
3.859375
4
"""Sprint 2 Unit 3 SQL day 1 assignment""" import sqlite3 # for connecting to our database def connect_to_db(db_name="rpg_db.sqlite3"): conn = sqlite3.connect(db_name) return conn # for executing read queries def execute_query(cursor, query): cursor.execute(query) return cursor.fetcha...
33a6d4c2e2601edc6343826dff2b6b5cc370ee0b
rafirahim/python_pg
/newton.py
509
3.84375
4
import matplotlib.pyplot as plt # draw graph def draw(x,y): plt.xlabel('Distance between the objects') plt.xlabel('Distance between the objects') plt.grid(True) plt.plot(x,y,marker='*') plt.show() def force_r(): r=range(100,1001,50) f=[] m1=float(input('Enter the mass of the first ...
21b56e4cb5e09070f80028981b9d0578ffd86a3a
rafirahim/python_pg
/array.py
237
4.0625
4
nMax = float(input('Enter the number of elements in the array : ')) n = 1 a = [] while n < nMax: c =float(input('Enter the number :')) a.append(c) c=0 n = n +1 print(a) for index,item in enumerate(a): print index,item
8b79a57353b46afee0ff0d5465dcd1b73e990220
peinbill/leetcode_learning_card
/array/SolutionOffer21.py
296
3.71875
4
from typing import List class Solution: def exchange(self, nums: List[int]) -> List[int]: odd = [] non_odd = [] for num in nums: if num%2==0: non_odd.append(num) else: odd.append(num) return odd+non_odd
b6feb9d9807366625d85a333038a356117136c90
peinbill/leetcode_learning_card
/linked_list/SolutionOffer22.py
452
3.515625
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def getKthFromEnd(self, head: ListNode, k: int) -> ListNode: if head==None: return head pre = head post = head for i in range...
58a47845dc3923c3d96bb770fe123475350d0807
amanjaiswal240/SmallPyProjects
/calculator.py
2,280
3.78125
4
from tkinter import * root=Tk() #global operator def btnClick(numbers): global operator operator=operator+str(numbers) scval.set(operator) def btnClear(): global operator operator="" scval.set("") def btnEqual(): global operator sumup=str(eval(operator)) scval.set...
977c598ad324d5e192345565163b20ca082c570d
NUSTEM-UK/Heart-of-Maker-Faire
/QRmaker/QRmaker.py
1,832
3.671875
4
""" For the Heart of Maker Faire we need to generate a lot of paired QR codes and print them on stickers, this code generates the qr codes and places them onto a pdf """ # pyqrcode generates the QR codes # pip install pyqrcode import pyqrcode # pypng allows the codes to be saved as png files # pip install pypng import...
e729a0310383d011c86263ebe50ed8fbfef43724
NUSTEM-UK/Heart-of-Maker-Faire
/Heartsim/test/looptest3.py
1,468
3.890625
4
# Let's make a list of lists maxframes = 50 heart01 = [0, 1, 2, 3, 4, 5] heart02 = [6, 7, 8, 9] hearts = [heart01, heart02, heart01] print "Number of hearts:", len(hearts) heartlengths = [] for i in range(len(hearts)): heartlengths.append(len(hearts[i])) for index, heartlength in enumerate(heartlengths): prin...
a8192eb01c3592823d4333c63c73711c34883014
Intel76/pythonProject3
/main.py
618
4.0625
4
# Team member: Hanna Magan # Course: CS151, Dr.Rajeev # Date: 22 September 2021 # Programing Assignment 1 # import math # Program Inputs: [What information do you request from the user?] # ask user for dimensions (length,width and height) room_length = input("Enter room_length") room_width = input("Enter room_width") r...
2e7105c46c34b55b5e33f50a488d2dd004f2f0b1
martinLew/learn-python
/sys_argv.py
468
3.546875
4
import sys # sys.argv接收参数,第一个参数是文件名,第二个参数开始是用户输入的参数,以空格隔开 def run1(): print('I\'m action1') def run2(): print('I\'m action2') if 2 > len(sys.argv): print('none') else: action1 = sys.argv[1] action2 = sys.argv[2] if 'run1' == action1: run1() if 'run2' == action2: run2()...
89670d75a2484706abaad0f96a11ab3ed4a34b92
ramdharam/MyPythonPrograms
/binarYTreeHeight.py
793
3.921875
4
from collections import deque class Node: def __init__(self,v): self.data = v self.left = None self.right = None def treeHeight(root): if root is None: return 0 q = [root] q = deque(q) height = 0 while (True): nodes = len(q)...
9b6c0d66568106f51561bd20b65dd95da5dcc7f4
ramdharam/MyPythonPrograms
/snakesAndLadders.py
659
3.59375
4
class queueNode: def __init__(self, v=0, dist =0): self.v = v self.dist = dist def snakeAndLadderMinDice(move, N): visited = [False] * N queue = [] visited[0] = True queue.append(queueNode(0,0)) qe = queueNode() while queue: qe = queue.pop(0) v = qe.v ...
fd4181781dcd52f208ff9b128b2888c5316ad653
kartoniks/Studia
/AI/l1/randomwords.py
1,186
3.515625
4
import random from random import randint, sample f = open('z2words.txt') words = { s.strip() for s in f.readlines() } m = max([len(x) for x in words]) f2 = open('zad2_input.txt') texts = [s.strip() for s in f2.readlines()] def random_divide(s): if(len(s)==0): return '' for r in range(100): i = random.rand...
7775a8d864f6b6701ab619c0929203ec594600a7
ahmadmostafa10495/python-codeForcesProblems
/personclass.py
1,955
3.96875
4
class Person(): ID=0 def __init__ (self,name,address,contact_number,gender,age): self.name=name self.address=address self.contact_number=contact_number self.gender=gender self.age=age self.tempid=Person.ID Person.ID+=1 def setname (self,name): ...
8cdca50fb408d34a964a7777f839a1ff8127012e
ahmadmostafa10495/python-codeForcesProblems
/temp5.py
440
4.09375
4
import math def isprime (n): i=2 while 1: if n%i==0: return False if i>=math.sqrt(n): return True i+=1 x=int (input()) e=isprime(x) if e==False: print ("not prime") else: print("prime") """u=2 for f in range(2,int(math.sqrt(x))): if x%f...
404bd41a2201e8180caf5d3b98dbc118829ea058
ahmadmostafa10495/python-codeForcesProblems
/Word.py
186
3.671875
4
x=input() i=0 l=0 u=0 while i<len(x): if x[i].islower(): l+=1 elif x[i].isupper(): u+=1 i+=1 if u>l: print(x.upper()) else: print(x.lower())
57122b7faa841121231ecebc5f36b4078cf83aae
ahmadmostafa10495/python-codeForcesProblems
/HQ9+.py
142
3.703125
4
p=input() i=0 while i<len(p): if p[i]=='H' or p[i]=='Q' or p[i]=='9': print ('YES') break i+=1 else: print ('NO')
694d881d698c9d50db4a6cebf6bbb3b2a79f893a
ahmadmostafa10495/python-codeForcesProblems
/Bit++.py
209
3.5
4
m=x=int(input()) a=[] while m>0: m-=1 a.append(input()) i=0 e=0 while e<len(a): if a[e]=='X++' or a[e]=='++X': i+=1 elif a[e]=='X--' or a[e]=='--X': i-=1 e+=1 print (i)
8ad52dd61b5abc57dbcbbb06fefaf064167815a4
ahmadmostafa10495/python-codeForcesProblems
/temp.py
130
3.71875
4
print ("please write your name") x=str (input()) print ("please write your age") y=int(input()) print ("hello",x,"your age is",y)
74806729ba44cd8afa440fff5c3e3012bd321aeb
ahmadmostafa10495/python-codeForcesProblems
/Comparing Strings.py
92
3.609375
4
x=input() y=input() y=y[1]+y[0]+y[2:len(y)] if x==y: print("YES") else: print("NO")
18a4d9cf0ed25d3e74e5e670370c3a94f634d070
ITlearning/CodeUP_Python
/Code/81-90/86.py
118
3.578125
4
a = int(input()) i = 1 total = 0 while True : total += i i += 1 if total >= a: break print(total)
2f02fdaa2d7eb1b33a9176e5eda7b89f41c876ed
ITlearning/CodeUP_Python
/Code/61-70/64.py
119
3.671875
4
c,d,e = input().split() a = int(c) b = int(d) c = int(e) print((a if a < b else b) if ((a if a < b else b) < c)else c)
a27ac3ba7f3a5009348e9d68ca416ed50784281f
qaisjp/adventofcode
/2019/day10/app.py
2,179
3.53125
4
#!/usr/bin/env python3 from collections import namedtuple, defaultdict from typing import Iterable import math import sys Point = namedtuple('Point', ('x', 'y')) Obj = namedtuple('Obj', ('kind', 'pos')) def read_file(f=sys.argv[1]): y = 0 objs = [] with open(f, 'r') as f: for line in f: ...
a982d277f9388bb462645519a839ae6cfb46c1a9
wingsthy/data_structure
/offer/jump.py
283
4
4
#!/usr/bin/env python #-*- coding: utf-8 -*- def jumpFloor(number): if number == 1 or number == 2: return number n, m = 1, 2 for i in range(3,number+1): res = m + n n, m = m, res return res if __name__ == '__main__': print(jumpFloor(10))
0608bbd7bdecc84ee5e33c3892bb06544b9a30a3
jamesr23/myThinkPython2eAnswers
/section2/exersise2-2.py
432
3.78125
4
#!/usr/bin/env python3 # exersise 2-2 # Suppose the cover price of a book is $24.95, but bookstores get a 40% discount. # Shipping costs $3 for the first copy and 75 cents for each additional copy. # What is the total wholesale cost for 60 copies? price = 24.95 bookstore_price = 0.4 * price books_price = (bookstor...
eeff7dcd6cbe9d6fc0ae0f14eb0e0863829c2d54
jamesr23/myThinkPython2eAnswers
/section3/exersise3-1.py
711
3.53125
4
#!/usr/bin/env python3 # exersise 3-1 def draw_row(prefix, content, amount): # row = '+' + '-' * 4 row = prefix + (content * 4) # +--- print(row * amount, end = '') print(prefix) def print_grid(): draw_row('+', '-', 2) draw_row('|', ' ', 2) draw_row('|', ' ', 2) draw_row('|', ' ',...
5ad6c58ba7a4b8c236bc5a2088ea796ca4fb7d35
VindulaNR/Python_turtle
/mount.py
9,352
4.0625
4
import turtle import math import random from random import randint def draw_background(): #create screen object screen = turtle.Screen() #dimentions for the screen screen.setup(1200,700) #background color screen.bgcolor('#b3d9ff') #create new turtle turtle.hideturtle() turtle.spe...
79072e55960b5de9f56486db34748bfaa55c08b9
FayazGokhool/University-Projects
/Python Tests/General Programming 2.py
2,320
4.125
4
def simplify(list1, list2): list1_counter,list2_counter = 0,0 #This represents the integer in each array that the loop below is currently on list3 = [] #Initialise the list list1_length, list2_length = len(list1), len(list2) #Gets the length of both lists and stores them as varibales so they don't have to be called...
cc9f263a1572783633b45a68ba52e1be581d1365
leilii/com404
/1-basics/b-reviwe/2-input/4-repetition/3-repeatin-word/bot.py
183
4.25
4
#ask userfor a word print("Please enter a word") #read user respond word=input() #work lenght of word len_word=(len(word)) #display word for l in range(0,len_word,1): print(word)
9d0ff1ce8cb68eee8c9005c72c6041c0a959f8c5
leilii/com404
/1-basics/2-input/2-ascii-robot/bot.py
173
3.5
4
# Read in user's name print("Please inter eye character") ch = input() print("\t ########") print("\t # " + ch + " " + ch + " #") print("\t # _ #") print("\t ########")
39fdd0263563f932f80ce91303ba69e74bf67259
leilii/com404
/1-basics/3-decision/4-modul0-operator/bot.py
214
4.375
4
#Read whole number UserWarning. #work out if the number is even. print("Please enter a number.") wholenumber=int(input()) if (wholenumber%2 == 0): print("The number is even") else: print("The number is odd")
6b90ec8f6a5db66b37ad421428e21d16840fc3d9
leilii/com404
/1-basics/5-functions/1-greeting/2-leisure/bot.py
336
3.71875
4
def activity(): print("Please enter your acrtivity you like: ") act=str(input()) if (act=="watch movie"): print("watching a movie sounds like fun") elif (act=="play"): print("I have lots of toys to play with.") else: print("I am not sure if I will like it but I will give it a try."...
1bd24e3c1db569bfef4208c62d53bd5b76bd2a63
krystal199/GeekBrainsBA
/Homework01/task04.py
230
3.8125
4
enter = int(input("Введите число >>> ")) number = enter max = 0 while number and max != 9: print(number) current = number % 10 number = number // 10 max = current if current > max else max print(max)
5b898f04df1cb7a4cd74f145b4d38c754dfd22fc
arjun921/exercism
/python/clock/clock.py
429
3.75
4
def Clock(hh,mm): count=0 while mm<0: mm=60-(abs(mm)) count+=1 hh=hh-count while mm>=60: mm-=60 hh+=1 while hh>24: hh-=24 if mm==60: mm=0 hh+=1 while hh<0: hh=24-(abs(hh)) if hh==24: hh=0 hh = ("{0:0=2d}".format...
923ea5cba9e4623d628de411421465fc73c3fec6
RanHuang/Hello-World
/2014/python/lpthw/ex15.py
359
3.875
4
from sys import argv script, filename = argv txt = open(filename, 'r') print "Here is the content of your file %r:" % filename print txt.read() txt.close() txt = open(filename, 'a') txt.write('Open & Read') txt.close() print "Type a file to read again:" file_again = raw_input('>') txt_again = open(file_again) pr...
897402b6aa4affa2aa725d1ecba3e62c034da850
RanHuang/Hello-World
/2014/python/lpthw/ex18.py
596
4
4
#This one is like your scripts with argv def print_two_arguments(*args): arg1, arg2 = args print "arg1: %r, arg2: %r" % (arg1, arg2) # ok, that *args is actually pointless, we can just do this def print_two_arguments_again(arg1, arg2): print "arg1: %r, arg2: %r" % (arg1, arg2) # this just takes one argume...
464dfdaabab5b6cc0295fac22f6b20958aa12caa
miowch/algorithms
/exercises/divide_and_conquer.py
3,124
4.0625
4
""" EXERCISES 4.1 Write out the code for the earlier sum function. 4.2 Write a recursive function to count the number of items in a list. 4.3 Find the maximum number in a list. 4.4 Remember binary search from chapter 1? It’s a divide-and-conquer algorithm, too. Can you come up with the base case and recursive case ...
1a3f7d942ebb42d3fb99240600fe28000bc04d48
fwparkercode/Programming2_SP2019
/Notes/lists_and_comprehensionsB.py
3,599
4
4
# Our Friend the List import random my_list = ["Bev", "Abe", "Cam", "Dan", "Eve", "Flo", "Gus"] my_nums = [8, 4, 7, 5, 2, 19] print(my_list[1]) # print Abe print(my_list[4:]) # print Eve Flo Gus print(my_list[:3]) print(my_list[2:4]) print(my_list[-2]) # copy of a list #my_list2 = my_list # don't do this!!! my_list...
009831b5aa62fec3ff842cf1b9975406f938c0cf
fwparkercode/Programming2_SP2019
/test.py
423
3.828125
4
from turtle import * my_turtle = Turtle() my_window = Screen() my_turtle.goto(0, 0) # my_turtle.goto(100,100) my_turtle.fillcolor('red') my_window.colormode(255) for j in range(20): my_turtle.begin_fill() my_turtle.left(20) for i in range(3): my_turtle.fillcolor((255, j * 12, j * 12)) my...
e6fa17104e809eb4989f0d9930a5d4643db5b0d1
fwparkercode/Programming2_SP2019
/Notes/scrapingA.py
3,044
3.765625
4
# Web Scraping with Beautiful Soup import time import urllib.request import certifi from bs4 import BeautifulSoup import requests url = "http://quotes.toscrape.com" page = requests.get(url) # get request to that url print(page) #print(page.text) soup = BeautifulSoup(page.text, "html.parser") #print(soup.prettify()...
a0f42008ae704f65281e122b62276d57b8da11b0
fwparkercode/Programming2_SP2019
/Notes/sortingA.py
2,772
3.875
4
# Sorting import random import time # Swap values a = 1 b = 2 print(a, b) temp = a # store it before we destroy it a = b b = temp print(a, b) # the pythonic way a, b = b, a print(a, b) # make a random list of 100 numbers with value 1 to 99 # use list comprehension rando_list = [random.randrange(1, 100) for x in ra...
b7d81a61e20219298907d2217469d74539b10ac4
fwparkercode/Programming2_SP2019
/Notes/RecursionB.py
806
4.375
4
# Recursion - function calling itself def f(): print("f") g() def g(): print("g") # functions can call other functions f() def f(): print("f") f() g() def g(): print("g") # functions can also call themselves #f() # this causes a recursion error # Controlling recursion with depth def c...
87b4cdb7b05309fce8fa5edcf01456411acb6d91
Dav416/Prueba-Aprendiz
/Desarrollo/reto_3/reto3.py
2,319
3.609375
4
class Productomodel: def __init__(self,codigo,nombre,precio): self.codigo = codigo self.nombre = nombre self.precio = precio def mostrarinfo(self): print(f'Codigo del producto: {self.codigo}, nombre del producto: {self.nombre}, precio del producto: {self.precio}') class Cli...
c32fb384befd6f12d3b013ad4d0eaee594b7c122
ryoon-personal/2020PersonalStudy
/baekjoon/python/step3/3-3-8393.py
45
3.640625
4
num = int(input()) print(int((num+1)*num/2))
afb738e94500ac9c3f51fbebdafb8b6772e4dcf9
np-lax/DFS
/PortLookUp.py
3,798
3.921875
4
#!/usr/bin/env python ########################################################## #Name: PortLookUp.py #Version: 0.1 #Functionality: Create a dictionary of port numbers and then print out each port's description #Author: Rob Cilla ###################################################...
a9cd1770f4b87f5ba9f6680f423e8d3e3c3a143d
vishnu5898/DS_with_Python
/Module_1/Sorting/quick_sort.py
1,061
3.5
4
def hoare_partition(arr, low, high): pivot = arr[low] i = low - 1 j = high + 1 while(True): i += 1 while(arr[i] < pivot): i += 1 j -= 1 while(arr[j] > pivot): j -= 1 if(i >= j): return j arr[i], arr[j] = arr[j], arr[i] ...
0a5e0abab8f548478217e7c4eada8319b75d22cc
uia-worker/hanna
/oblig2/euler_pendelum_v2.py
1,826
3.75
4
import math from matplotlib import pyplot as plt # Funksjon for å vise resultater def plot_results(time, theta1): plt.plot(time, theta1) s = '(Initelle vinkelen = ' + str(theta0) + ' radianer)' plt.title("Oblig2 d)" + s) plt.ylabel('vinkel') plt.legend(['lineær'], loc='lower right') plt.show() ...
ca5f85dcdd769130e2b7fc95c08628004c088f60
GulsahKose/COMUodev
/fibonanchi_loop.py
353
3.96875
4
import time start = time.time() def fibonanchi(n): if n == 1 or n == 2: return 1; else: fib1=1 fib2=1 i=2 while (n>=i): fibonacci = fib1 + fib2; fib1 = fib2; fib2 = fibonacci; i=i+1 return fibonacci; print fibonanchi(5) end = time....
4b39c308f6d6051f9e107e02e83d33b7d97880fc
jsbautista/TesisCodigos
/tesis/MultiThread.py
721
4.03125
4
from queue import Queue from threading import Thread def foo(bar): print ('hello {0}'.format(bar)) return 'foo'+'hello {0}'.format(bar) que = Queue() # Python 3.x threads_list = list() t = Thread(target=lambda q, arg1: q.put(foo(arg1)), args=(que, 'perros!')) t.start() threads_list.append(t) # Ad...
b9a3734e22be4545444c7c19a821756350503429
chandraseta/spam-mails-detection
/dataset/CompareResult.py
409
3.5
4
# Compare 2 files and output the difference to difference.txt def compare(File1,File2): with open(File1,'r') as f: d=set(f.readlines()) with open(File2,'r') as f: e=set(f.readlines()) # Create file open('difference.txt','w').close() with open('difference.txt','a') as f: fo...
9efd5ecbfc762fad2628d609b24f1e81853cfdee
BenjaminJCox/Prog_Dat_Anal
/checkpoint_3/oscillator.py
1,861
4.09375
4
import math from matplotlib import pyplot """ This function calculates the displacement of the oscillator given omega_zero, gamma and time """ def shm(omega_zero, gamma, t): a = 1 if gamma > 2*omega_zero:#over damped p = math.sqrt(((gamma ** 2)/4) - omega_zero ** 2) b = gamma / (2 * p) ...