blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
35ac9bd3bd42f8ae2a31dbe1b92eb32dff0b05ce
Arsen0312/if_else_elif
/problem1.py
63
3.984375
4
a = 2**3 b = 3**2 if a > b : print('a') if a < b : print('b')
6c721285f512e4b43c49411f1f929ddbe9548637
anu3096/sieveOfEratosthenes
/Python/sieve.py
1,213
4.0625
4
#!/usr/bin/python import math import time """ Compile & run program - python sieve.py """ primeArray = [] """Asks the user for the upper limit of prime numbers to calculate""" """verifies if the user's upperLimit input is truly a numeric number""" try: upperLimit = int(raw_input('Enter the upper limit of pr...
8223ddb8b71ccfc39483e428dffe309c764cca9f
kinjo-icolle/programming-term2
/src/basic-c3/try-finally.py
311
3.65625
4
try: val1 = float(input("分子を入力してください")) val2 = float(input("分母を入力してください")) result = val1 / val2 print("結果は{0}です。".format(result)) except: print("エラーが発生しました") finally: print("finally句で実行されます。")
cb1a79d1347b85fbb566c118b157eae1ca9fc513
troubleshoot/python_stack
/Python/Python_Fundamentals/User.py
399
3.671875
4
class User: def __init__(self, name, balance): self.balance = balance self.name = name def make_withdraw(self, amount): self.balance -= amount return self def display_user_balance(self): print("User:",self.name,"- Balance: $",self.balance) return self george = User("George", 100) li...
576563c6d44b33da3d06e117ba9b58c27b38b938
BeastboyHellriser/Python-is-easy
/AssinmentNo1.py
902
3.796875
4
''' Python work assignment 1 Course: Pyhton is easy Author: Vishal Email: vishal300999@gmail.com ''' #Name of the song Song = "War of change" #Genre of the song Genre = "Rock" #Name of album Album = "The end is where we begin" #Name of the band Band = "Thousand foot ...
b50ffd88d8707785614d0fbd396bb0d70b215536
sarthaksr19/OpenCV
/basic.py
1,223
3.734375
4
import cv2 as cv img = cv.imread('images/yuvi.jpg') cv.imshow('Yuvi', img) # 1. Converting to grayscale gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY) cv.imshow('gray_image', gray) # 2. Blur # blur = cv.GaussianBlur(img, (3,3), cv.BORDER_DEFAULT) # to increase the bluryness of image we need to increase kernel size of ...
6919ff2ce85c7d5991a4ce2e836d49c19bbef271
soundestmammal/machineLearning
/py_docs_lessons/four.py
1,079
4.125
4
# -*- coding: utf-8 -*- # Besides the while startment just introduced, Python knows the usual control flow statements known from other languages with some twists. x = str(input("Please enter an integer: ")) if x < 0: x = 0 print('Negative changed to zero') elif x == 0: print('Zero') elif x == 1: print...
a2dd1f0f28034569e4fcb85ded74d9fc756b13a4
soundestmammal/machineLearning
/bootcamp/functions.py
699
3.890625
4
def name_function(): print('Hello') name_function() def say_hello(name="Name"): print('Hello '+name) say_hello("Sally") result = say_hello('David') def say_hello(name="Name"): return ('Hello '+name) def add(n1, n2): return n1+n2 def dog_check(mystring): if 'dog' in mystring: return True else: return Fa...
7a709eb41dc5be0619e9b5fd6e3d6528d00d920a
alexfertel/ebm
/src/utils.py
551
3.546875
4
#!/usr/bin/env python3.6 import hashlib from config import * def cut(l: str, n: int = MESSAGE_LENGTH): result = [] for i in range(0, len(l), n): result.append(l[i:i + n]) return result def inbetween(a, b, c): """ Is c between a and b :param a: int :param b: int :param c: int...
271f33553d1110a1065aada162be61fd6ae3a063
yarik335/GeekPy
/HT_6/task_1_6.py
2,952
4.0625
4
eimport pprint def check_arguments(x, y): try: int(x) int(y) temp = x * y temp = x + y temp = x - y temp = x / y except (TypeError, ValueError): print("Error! Maybe you have entered a line but number is required") return True class Calc: "...
e54c05673005232caf48b10df90bf923672ba8d1
yarik335/GeekPy
/HT_1/task7.py
191
4.28125
4
# 7. Write a script to concatenate all elements in a list into a string and print it. myList = input("enter your list: ") myList = myList.split(sep = ',') print(myList) print("".join(myList))
ec24304cdf4ceae5ae8a09deb9825f86fc3d9932
yarik335/GeekPy
/HT_6/task_13_14.py
198
3.609375
4
class Thing: pass class Thing2: letters = 'abc' class Thing3: letters = 'xyz' example = Thing() print(Thing2.letters) print(Thing3.letters) print(type(Thing)) print(type(example))
5f857143da53963947e83770e752ee020a6d406e
yarik335/GeekPy
/HT_6/task_11.py
610
3.765625
4
"""http://www.pythonabc.com/best-way-count-instances-python-class/""" class MyClass: num_of_instamces = 0 @classmethod def countInstances(cls): cls.num_of_instamces += 1 @classmethod def getNumInstances(cls): print(cls.num_of_instamces) def __init__(self): self.count...
5a10d774d9184de071ee431a0c4e31e43e74fecb
jakubnowicki/python-prog
/iteracje.py
2,728
3.65625
4
def range5(): return [1, 2, 3, 4, 5] for x in range5(): print(x) def range5(): print("Podaję 1") yield 1 print("Podaję 2") yield 2 print("Podaję 3") yield 3 yield 4 yield 5 for x in range5(): print("Pobrałem", x) def infinity(): i = 0 while True: yield i ...
1ba4949faab9b882748c9dc41c409e10c28fe23e
keerthanavelu2005/python1
/Heap sort.py
696
4.0625
4
def heapify(a, n, i): largest = i l = 2 * i + 1 r = 2 * i + 2 if l < n and a[i] < a[l]: largest = l if r < n and a[largest] < a[r]: largest = r if largest != i: a[i], a[largest] = a[largest], a[i] def heapSort(arr): n = len(arr) for i in range(n // 2 - 1, -1, ...
af5f16222628f33659709776cae6bc1994feb238
Bhoomika2820/cloudcounselagelp3
/at8.py
212
3.578125
4
""" CODING QUESTIONS:8 Write a Python program to calculate the sum of the positive integers of n+(n-2)+(n-4)... (until n-x =< 0). """ n=int(input()) sum1=0 for i in range(n,0,-2): sum1+=i print(sum1)
ea15f48c7228fffca9c7f5c3fff182a099dcec80
bfmcneill/python3-fundamentals
/decorators/dec-test.py
992
3.71875
4
from functools import wraps from timeit import default_timer as timer def timeit(func): """ Modified from Python timit decorator https://gist.github.com/winogradoff/8ea1372676bdc6b3a59a86d79a0a5f64 """ @wraps(func) def timed(*args, **kw): ts = timer() result...
20d6737dd2e4142c41f6fe411b18edfee15c6054
pramilagm/coding_dojo
/my_environments/flask/flask_fundamentals/game/server.py
1,014
3.546875
4
from flask import Flask app = Flask(__name__) @app.route('/') def index(): return '<h1>welcome to the Park where do you wanna go left or right </h1>' @app.route('/left') def left_way(): return '<h3>welcome too the zoo what do you wanna see TIGER or MONKEY</3>' @app.route('/left/tiger') def tiger(): ret...
9d8d4af8d1d31a9e8e2d8148b574bede9062b96e
CiortanFlorin/Tic-Tac-Toe
/main.py
1,648
4
4
from logo import logo game_on=True turns=0 moves=[' ',' ',' ',' ',' ',' ',' ',' ',' '] taken=[] print(logo) #Function that lays the X&O grid def lay_grid(): grid = [] counter = 0 for n in moves: counter +=1 grid.append(n) if counter<9: if counter%3==0: ...
386069b24fe7009ad3568ffec2647ffa3b2add89
vasidzius/Introduction-to-Discrete-Mathematics-for-Computer-Science
/Course-1-Mathematical-Thinking-in-Computer-Science/Largest-Amount-that-Cannot-Be-Paid-with-5-and-7-Coins.py
1,158
3.765625
4
''' Largest-Amount-that-Cannot-Be-Paid-with-5-and-7-Coins Imagine we have only 5- and 7-coins. One can prove that any large enough integer amount can be paid using only such coins. Yet clearly we cannot pay any of numbers 1, 2, 3, 4, 6, 8, 9 with our coins. What is the maximum amount that cannot be paid? ''' def...
3fd523561fac4ca1396b40fa51dc1b159a2ea1f1
ylianakiryukhova1/computational_geometry
/Points_and_Lines/4.py
1,162
3.890625
4
import math class Line: def __init__(self, a, b, c): self.a = a self.b = b self.c = c def __str__(self): if self.a < 0: real_a = "-%.2f"%(abs(self.a)) else: real_a = "%.2f"%(self.a) if self.b < 0: real_b = "- %.2f"...
48265d53557dfccd48a60a2671a540defda02ff6
ksenia-b/Technical-Interview
/string/first_non_repeated_character.py
856
4.21875
4
""" How to program to print first non repeated character from String? Read more: https://javarevisited.blogspot.com/2015/01/top-20-string-coding-interview-question-programming-interview.html#ixzz5uzeFObjn """ str = "Meeting" def find_first_non_repeated_character(s): dict_1 = dict.fromkeys(list(str), 0) pr...
d04a13680c3fa00ab52ba1c3c10dfcf2f77efbc6
florianm/rest-framework-latex
/rest_framework_latex/utils.py
566
3.625
4
def escape_latex(value): """Escape a value for Latex """ value = value.replace('\\', '\\textbackslash{}') value = value.replace('{', '\\{') value = value.replace('}', '\\}') value = value.replace('#', '\\#') value = value.replace('$', '\\$') value = value.replace('%', '\\%') value = ...
c6c2fd6f887dc66e2068cff3cf5b2e2a91eadc31
vmuthabuku/Questioner-api-v1
/app/api/v1/utils/validator.py
1,218
3.765625
4
def check_using_id(list_name, other_id): """use the relevant id to find question item""" my_item = next((item for item in list_name if item['questionid'] == other_id), None) if my_item: return my_item return False def check_id(list_name, other_id): """use the relevant id to find meetup i...
14a81c714178f7e9e15f7d4fe7521f906a8ac992
nicolabc/BetaGo-Zero
/go_codercaste.py
30,534
3.5
4
import numpy as np from copy import deepcopy ## The number of spots per side of the board ## This code allows for an nxn board boardsize = 9 ## Value determining whether the player wants to quit or not gameon = 1 ## Lists of groups that have been removed from the board via capture, ## held in these varaibles in case, ...
3afbd8858a77fe232ab3d006c7bc22ab1bb67574
Developer-20/trip-profit-calculator
/trip profit calculator.py
2,536
4.375
4
#Build an application that help transport companies analyze potential profit to different destinations #destination dictionary that contains 7 keys and 7 data in the keys respectively destination = { "lagos": 1300, "enugu": 880, "maiduguri": 1400, "calabar": 940, "acrra": 1600, "cotonou"...
f50bf95a8678273fb164dbb263d49ee3a7aaee07
teemal/nstda
/basic_graph.py
3,293
3.796875
4
#!/usr/bin/env python # # basic_graph.py # # Library # Provides: # Graph object, which as a constructor takes a flow file # import os, sys class UndirGraph: def add_node(self, node_id): self.nodes.add(node_id) def add_link(self, node_source, node_dest): self.add_node(node_source) ...
13c662dc05481ca895d0ddc39594a098f43ae004
jacksonmoreira/Treinos-Python
/Scripts/treino001.py
486
4.03125
4
print('-=-' * 30) print(' MÉDIA ESCOLAR ') print('-=-' * 30) print('''Digite duas notas e eu irei tirar a média entre elas.''') n1 = float(input('Digite a sua primeira nota: ')) n2 = float(input('Digite a sua segunda nota: ')) me = n1 + n2 / 2 print('Sua primeira nota foi {} e sua segunda nota foi {}!'.format(n...
4d2e487cc163999f5145dcc998c491886581046c
eZanmoto/Modeller-3D
/actions.py
1,189
3.921875
4
class Actions: """ Mutable """ def __init__( self ): """ Creates a new record of actions which may be undone. """ self.undos = [] self.redos = [] def do( self, do, undo ): """ Does the action specified by do, which may be undone. do - ( action, [...
916eba87b5d6d5652c84e6d18dc17ee260ee6e56
yaseen-ops/python-practice1
/LinearSearch.py
686
3.734375
4
#For Loop pos = 'Dummy' def search(list, n): for i in list: if i == n: globals() ['pos'] = list.index(n)+1 # +1 is added to make human readable, as list starts from '0' return True list = [3,5,7,9,1] n = 9 if search(list, n): print('Found at', pos) else: print('Not Found'...
699b234310fa96bc4c775932782d282fe4da8ac0
dravest/PythonDataStructures
/linkedListStack.py
1,393
3.84375
4
''' Name: Thomas Draves Date: 07-09-2018 Description: A Linked List that implements a Stack ''' class Node: #constructor def __init__(self): self.data = None self.next = None #method for setting the data def setData(self, data): self.data = data #method for getting ...
94b6778da097b913a0e2b824411ff3ce5c51fcc6
gsamba92/Movie-Recommendation-application-based-on-sentiment-Analysis
/watchlist_db.py
1,874
3.71875
4
import sqlite3 as lite def createTable(): try: conn.execute('CREATE TABLE IF NOT EXISTS WATCHLIST(movie_ID INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT NOT NULL, img TEXT NOT NULL, rating TEXT NOT NULL, isWatch INTEGER);') print("Table created successfully.") except Exception ...
c8914cb7e57a374b38f54b4eafd3a0707183c529
ashisheni15/HackerRank
/Python/Introduction.py
1,072
4.09375
4
#Say "Hello, World!" With Python print("Hello, World!") #Python If-Else #!/bin/python3 N = int(input()) if N % 2 ==0 : if N in range(2,6): print("Not Weird") if N in range(6,21): print("Weird") if N >20 : print("Not Weird") else : print("Weird") #Arithmetic Operators if _...
9d5b17c22b6c288cf7ceacc5254faab73c7bbf69
denibulkashvili/FacebookPostScraper
/utils/scraper.py
838
3.71875
4
"""Module for scraping""" from bs4 import BeautifulSoup class Scraper: """Scraper class""" def __init__(self, html): self.html = html self.soup = BeautifulSoup(html, "lxml") print(f"[Scraper] Retrieved page") def find_posts(self): """Scrapes posts on a page""" po...
abc3191d535b3080727a1bc5a55f0be177a5a39c
K-Roberts/codewars
/String Incrementer.py
1,773
4.1875
4
''' Created on Nov 14, 2018 @author: kroberts PROBLEM STATEMENT: Your job is to write a function which increments a string, to create a new string. If the string already ends with a number, the number should be incremented by 1. If the string does not end with a number the number 1 should be appended to the new st...
7d55656d582da78c03b72cef27936a3dbe12cc9b
sbalun/codecademy-homework
/more-list-challenges.py
3,157
4.59375
5
""" 1. Every Three Numbers Create a function called every_three_nums that has one parameter named start. The function should return a list of every third number between start and 100 (inclusive). For example, every_three_nums(91) should return the list [91, 94, 97, 100]. If start is greater than 100, the function s...
e0a05e822d77adfbcbb33568092be308d6758e90
santom11/Python
/Decorators/class_decorator.py
911
3.59375
4
import functools class CountCalls: def __init__(self, func): functools.update_wrapper(self, func) self.func = func self.num_calls = 0 def __call__(self, *args, **kwargs): self.num_calls += 1 print(f"Call {self.num_calls} of {self.func.__name__!r}") return self.f...
2581ac4e77dd61beb78f2fdbaaca54e820217bc7
pjanowski/Pawel_PhD_Scripts
/python/regexp.py
747
3.984375
4
#! /usr/bin/python import re import os ###Various examples of regular expression usage in python #print os.listdir('.') p=re.compile('ab*') #print p string='hello this is abbe age abe ae lincoln' #print p.search(string).group() #print p.search(string).start() #print p.search(string).end() #print p.search(string)....
40387763730916bc2bf3caa2740e4eb211043810
pjanowski/Pawel_PhD_Scripts
/matplotlib/scatter_plot_bug.py
383
3.921875
4
#!/usr/bin/env python from matplotlib import pyplot as plt x = [1,2,3,4,5,6] y = [1e-2, 2e-3, 6e-3, 7e-3, 4e-3, 3e-3] plt.plot(x,y,color='red') plt.scatter(x,y,color='orange') print x print y plt.yscale('log') plt.show() x = [1,2,3,4,5,6] y = [1e-2, 2e-3, 0, -3, 4e-3, 3e-3] plt.plot(x,y,color='red') plt.scatter(x,...
665355f77432a5c135344a92a1e2af013d9cb9d1
songlinjian/my-Leetcode
/002/002.py
979
3.796875
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def addTwoNumbers(self, l1, l2): """ :type l1: ListNode :type l2: ListNode :rtype: ListNode "...
480c9bb1d75f5180c77139407444f3d70b37d41f
kbmulligan/cs545-a1
/perceptron.py
10,039
4.28125
4
import numpy as np from matplotlib import pyplot as plt class Perceptron : """An implementation of the perceptron algorithm. Note that this implementation does not include a bias term""" def __init__(self, max_iterations=100, learning_rate=0.2) : self.max_iterations = max_iterations self...
a5892ed8530f14f6d037e01c62bd3f67a8741b52
morsedan/Intro-Python-II
/src/player.py
1,969
3.765625
4
# Write a class to hold player information, e.g. what room they are in # currently. from room import Room class Player: def __init__(self, current_room, items=[]): self.current_room = current_room self.items = items def try_north(self): if self.current_room.n_to != None: se...
92313736ef6adf006abe0c08653ce489fbce9af2
Nishal1/comp1050-prac-week-3.
/w3.py
125
4.1875
4
hungry=input("are you hungry or not") if hungry=='y': print("no food for you mate") else: print("still no food..")
743f592482f5983513d03f15918d2c337a9cd35f
ssavann/PY-widgets
/place.py
465
3.671875
4
''' Tkinter : Créer des interfaces graphiques Les widgets: Faire un place() -> pour placer les widgets ''' import tkinter from tkinter import messagebox fenetre = tkinter.Tk() #forcer la dimension à 800x600 fenetre.geometry("800x600") #widgets label = tkinter.Label(fenetre, text="texte du label", bg="blue") ...
f8e450412a503dc0824e7e98913923cd2bd15364
ssavann/PY-widgets
/taille_police.py
738
3.53125
4
''' Tkinter : Créer des interfaces graphiques Les widgets: Faire un place() -> pour placer les widgets ''' import tkinter from tkinter.font import Font police = ("Saab", 20, "bold") #fonctions def agrandir(): police = ("Rasa", 50, "bold") label.config(font = police) #interface graphique fenetre = tkinter...
f3842066b4d13ac1ce11a5a9d11ad3bef1cff56c
channingc177/IME1130L
/Battleship_Brainstorming.py
4,944
4.125
4
from random import randint import turtle fleets = [ [2], [2, 3], [2, 3, 4], [2, 3, 3, 4], [2, 3, 4, 5], [2, 3, 3, 4, 5] ] def start_menu(): turtle.hideturtle() turtle.color("white") turtle.penup() turtle.speed(0) turtle.goto(0, 0) blast_screen("black") turtle.write...
5e983b9f59abb810180f57a76833f64d70aa8707
hubwayPredict/main
/Tests/MLexample.py
1,379
4
4
import matplotlib.pyplot as plt import numpy as np from sklearn import datasets, linear_model import pickle # # Load the diabetes dataset diabetes = datasets.load_diabetes() # # Use only one feature diabetes_X = diabetes.data[:, np.newaxis] diabetes_X_temp = diabetes_X[:, :, 2] # # Split the data into training/test...
164f3bcbcdf4bf9755dc731ab1229f0bc39f4c76
epersike/py-simple-structs
/stack.py
1,433
3.90625
4
class SimpleStackPopException(Exception): pass class SimpleStackItem: def __init__(self, obj=None, prev=None, nxt=None): self.obj = obj self.prev = prev self.next = nxt def __str__(self): return str(self.obj) class SimpleStack: def __init__(self): self.len = 0 self.first = None self.s = None def ...
9bec319fd9674305f4282bf12813d151f3f0208c
KSSHARSHA/My-DSA-Project
/DATASTRUCTURES.py
7,206
3.53125
4
import random import smtplib import json import time Id=[] info={} bus1=[] tktlst=[] print(' WELCOME TO GROUP 3 TICKET BOOKING SYSTEM') lst=list() for i in range(1,51): lst.append(i) fname=list() for j in range(1,51): fname.append(j) fname=list() for j in range(1,51): fn...
ad2e795cc692100fb8c6588e6b521b6d9977646f
GitHublsh/S-Python-Demo
/demo/ext15.py
340
3.828125
4
import math def move(x,y,step,angle = 0): nx = x+step*math.cos(angle) ny = y-step*math.sin(angle) return nx,ny def power(x): return x*x print(power(2)) def enroll(name, gender): print('name:', name) print('gender:', gender) enroll('Hello',"f") d = {'a':1,'b':2,'c':3} for key in d: print(key) for ch ...
c566303c70b103b0d3218eb194947e67c525da04
GitHublsh/S-Python-Demo
/demo/ext31.py
624
3.90625
4
# sorted 排序 from operator import itemgetter L1 = [1,3,2,4,5,8,6] print(sorted(L1)) # 可自定义排序,可接受一个key函数来实现 L2 = [1,2,-4,3,8,-9] print(sorted(L2,key = abs)) # 忽略大小写比较字符串 L3 = ['An','Dan','co','El','ban'] print(sorted(L3,key = str.lower)) # 反向排序 print(sorted(L1,reverse = True)) # tuple 排序 L4 = [('Bob', 75), (...
d7d0038ca1c5952060d323e793c2ae6eb8d1e125
GitHublsh/S-Python-Demo
/demo/ext18.py
194
3.875
4
# 迭代器 from collections import Iterable print(isinstance('abc',Iterable)) print(isinstance([1,2,3],Iterable)) print(isinstance(123,Iterable)) for x,y in [(1,2),(3,4),(5,6)]: print(x,y)
b7355aaa98520c5057516d62bbfa9446853c4b4e
Ansh2103/Quantity-Measurement-Using-Python
/Main/Quantity_Measurement.py
2,418
3.96875
4
import enum class QuantityMeasurements: def __init__(self, unit, value): ''' declared __init__ constructor to initialize the attributes of Class QuantityMeasurements :param unit: unit will be provided by user :param value: value will be provided by user ''' ...
2df15ca9f175e90bcb150c5adc13ccb0796689e6
Bmeimei/3532_A01075487
/Labs/Lab6/auction_simulator.py
7,764
3.90625
4
""" Implements the observer pattern and simulates a simple auction. """ import random class Auctioneer: """ The auctioneer acts as the "core". This class is responsible for tracking the highest bid and notifying the bidders if it changes. """ def __init__(self): self.bidders = [] ...
d6f79491ca5f9bcc8c475b97e428d3a754352eeb
Bmeimei/3532_A01075487
/Labs/Lab7/book_analyzer_optimized.py
1,949
3.765625
4
""" This module is responsible for holding a badly written (but not so bad that you won't find this in the workplace) BookAnalyzer class that needs to be profiled and optimized. """ class BookAnalyzer: """ This class provides the ability to load the words in a text file in memory and provide the ability t...
ee358aaf282ba4c47e7f687e3d297e9d85185605
Bmeimei/3532_A01075487
/Labs/Lab6/callable_object_example.py
491
3.5625
4
class AClass: def __init__(self, message): self.message = message def __call__(self, message2): print(f"Object's message: {self.message}") print(f"Message passed in parameter: {message2}") def foo(self): print('foo') def main(): callable_object = AClass("You just used...
ecbcd6378b4004d412bf3b92ee1970b8beff9093
Bmeimei/3532_A01075487
/Labs/Lab3/library.py
5,115
3.828125
4
""" This module houses the library""" from book import Book from dvd import DVD from journal import Journal from catalogue import Catalogue from library_item import LibraryItem class Library: """ The Library consists of a list of books and provides an interface for users to check out, return and find book...
ad924703c559dc3edb37af3f5e7fee141448c85e
Bmeimei/3532_A01075487
/Labs/Lab4/categories.py
899
3.671875
4
# Author: Luke Mei # Student Number : A01075487 # Created time : 2021/1/21 0:39 # File Name: categories.py from enum import Enum, auto class Categories(Enum): """ An Enum class that represents 4 categories of budgets in Budget class. - GAMES_ENTERTAINMENT - CLOTHING_ACCESSORISE...
4a68803d540a875eff78c3481737519915b67e5d
wuzhipeng2014/Innovation
/PythonTest/gettingStarted/listOperationOptimization.py
1,051
3.671875
4
# coding:utf-8 # Filename: listOperationOptimization.py from __future__ import division '''列表相关的优化操作''' list1 = [1, 2, 3, 4] chtoeng = {'1': 'one', '2': 'two'} # 简化列表元素操作,(根据条件用列表内指定的元素初始化其它列表) list2 = [i * 2 for i in list1 if i == 3] print list2 # 输出列表内容 print list1 # 函数传递可变参数 def getMeanAges(*args): sum = 0 ...
e67963e83c20203f8c793611a5aa5616265a425e
wuzhipeng2014/Innovation
/PythonTest/gettingStarted/if.py
608
4.1875
4
#!/usr/bin/python # filename: if.py num=23 runing=True while runing: guess = int(raw_input('enter an integer')) if guess == num: print 'you gussed it' break runing = False print runing elif guess < num: print 'your guess is less than that' elif guess > num: print 'larger' else: print 'your guess i...
5ad49bd5847ef69721f8930fc4176df5dafd0945
julioaviladias/Econometria
/Exercícios 25 de maio/Ex7.py
257
3.859375
4
# -*- coding: utf-8 -*- """ Created on Fri May 25 19:28:07 2018 @author: Asus """ #Entrada idade=float(input("Digite a idade do carro:")) #Processamento if idade<=3: print("O carro é novo") if idade>3: print("O carro não é novo")
75582afe56bebaa8b16a0b08b64c0a4765e97318
raymonstah/Hacking-Ciphers
/Reverse/reverse.py
354
3.984375
4
# Reverse Cipher # The first example of Hacking Secret Ciphers # A simple, weak cipher to encrypt a string. # Raymond Ho message = raw_input("Enter your string: ") # Look at this pythonic way.. print message[::-1] # The uglier way translated = '' i = len(message) - 1 while i >= 0: translated = translated + messa...
255beb5760b926b6cd887beb466efcd81ae02cec
aclaudio123/testing-python-apps
/Python-Refresher/ex2_lists_tuples_sets.py
2,304
4.15625
4
# List # - Uses [] # - Mutable (size of the list can be increased) i.e. more items can be added # Ordered i.e. items print out in same order inside the [] list_grades = [77, 80, 90, 95, 100] list_grades.append(105) # append() used for adding items at end print(sum(grades) / len(grades)) # list operations print(list_g...
6cf2cbae54d68bcbf6a0950e356c325c3d54a938
aclaudio123/testing-python-apps
/Python-Refresher/ex11_decorators.py
1,836
4.6875
5
# A decorator is a function that gets called before another function import functools def my_decorator(func): # decorator being before another function @functools.wraps(func) # functool to wrap around the function being passed def function_that_runs_func(): # function used as wrapper print("In the...
7f31bee773c245764695a2227388137e55ed2b80
aclaudio123/testing-python-apps
/Python-Refresher/ex4_list_comprehension.py
515
4.0625
4
my_list = [0, 1, 2, 3, 4] # list comprehension builds a list of elements # building a list of x an_equal_list = [x for x in range(5)] # range(5) = [0, 1, 2, 3, 4] multiply_list = [x * 3 for x in range(5)] # building a list of even numbers print([n for n in range(10) if n % 2 == 0]) people_you_know = ["Rolf", " Joh...
68bc3e307884e271f7b2174aec244e681deb8a2b
Sparsh-Sharma/vortexMethods
/src/diffusion.py
2,280
3.546875
4
# Code for 2-dimensional vortex methods # Written by: Achyut Panchal # Aerospace Engineering, Indian Institute of Technology Bombay # Inspired by lectures from Prof. Prabhu Ramachandran, IIT Bombay # Functions for applying vorticity diffusion import numpy import definations as dfn import math import random import mat...
3f7a2fc5956baa2c21aa47f183da88c855127412
Chaoli-Zhang/atoolbox
/astro/21cm/cube_mean.py
826
3.53125
4
#!/usr/bin/env python3 # # Copyright (c) 2017 Weitian LI <weitian@aaronly.me> # MIT License # """ Calculate the mean values of the cube. """ import argparse import numpy as np def main(): parser = argparse.ArgumentParser( description="Calculate the mean value of the data cube") parser.add_argument(...
414142b54e8ddb06cae76459177090e2178afb37
hacksman/learn_python
/double_underscore/__dict__.py
1,018
4.1875
4
#!/usr/bin/env python # coding:utf-8 # @Time :10/30/18 18:12 """ 📋 --->>> 控制台 🤔 --->>> 解析 📢 --->>> 说明 🌰 --->>> 例子 materials: # python 类 __dict__ 在赋值时的使用 1. https://blog.csdn.net/AlanGuoo/article/details/78006942 """ class Foo(): def __init__(self): self.a = "a" ...
3b9871dc766422126390e77424660f5278d924a3
hacksman/learn_python
/algorithm/linked_list/linked_remove_nth_from_end.py
1,408
3.6875
4
#!/usr/bin/env python # coding:utf-8 # @Time :10/20/18 17:30 class Listnode(object): def __init__(self, val): self.val = val self.next = None node1 = Listnode(1) node2 = Listnode(2) node3 = Listnode(3) node4 = Listnode(4) node5 = Listnode(5) # class Solution: # def removeNthFromEnd(self, h...
b0db31c0206c7459b6edd05be18d8c8e641e0615
Rvelamen/Algorithm
/other/other/08.py
460
3.578125
4
class Solution: def generateParenthesis(self, n: int) : res = [] def DFS(paths, l, r): if l > n or r > l: return if len(paths) == n*2: res.append(paths) return DFS(paths + '(', l+1, r) DFS(p...
c985495141f4c1f2a0bae7e1e8e415a822633577
Rvelamen/Algorithm
/other/daily/twosum.py
516
3.671875
4
# -*- coding:utf-8 -*- __author__: 'Rvelamen' __data__ = '2021/9/8 7:13' class Solution: def twoSum(self, nums, target): _dict = {} for _, _items in enumerate(nums): if target - _items in _dict: return [_, _dict[target - _items]] else: ...
29c0a499dca89c65fa9f01ef8f6f03a576dcb9db
gaoxianglyx/python
/test.py
4,038
3.765625
4
# 以#号代表注释 #print('学习python') #age = int(input('请输入你的年龄:')) age = 15 if age>=18: print('age=',age) elif age>=12: print('hello %d years-old child'%age) else : print('WTF') print(list(range(21))) d={'c':11,'b':31}#定义一个dict对象 print('a' in d)#True print(d.get('a',12),d['c'])#使用get来获取一个key的value,不存...
1f26945ca18bf12ba6407f69545350fa248c906b
NamJueun/Algorithms-with-Data-Structure-using-Python
/chap2/리스트스캔/list1.py
297
3.671875
4
## 리스트 스캔 1 : 원소 수를 len() 함수로 미리 알아내서 0에서 원소 수 -1까지 반복합니다. # 리스트의 모든 원소를 스캔하기(원소 수를 미리 파악) x = ['John', 'George', 'Paul', 'Ringo'] for i in range(len(x)): print(f'x[{i}] = {x[i]}')
f7193e4ad474b7d2475da3a8101f45e901443e7d
KIMSUBIN17/Code-Up-Algorithm
/Python/1286 최댓값, 최솟값.py
207
3.8125
4
numbers = [] for i in range(0, 5): number = input() numbers.append(int(number)) numbers.sort() print(numbers[len(numbers) - 1]) #최댓값 print(numbers[0]) #최솟값
07f07da8c3d19c25e50827dba5795eaa87f31d33
KIMSUBIN17/Code-Up-Algorithm
/Python/1274 소수 판별.py
138
4.09375
4
n = int(input()) isPrime = 'prime' for i in range(2,n): if n % i == 0: isPrime = 'not prime' break print(isPrime)
a2513363a5fc1ca7ee61ff7df4fcca9c44cf06c1
BradleyMidd/learnwithbrad
/hangman.py
1,467
3.78125
4
# Hangman import getpass # Player 1 Function def player1(): typeword = getpass.getpass("Player 1 Type a word in: ") if typeword != "": split = list(typeword) return split else: print("Empty value, please try again!") # Player 2 Function def player2(): life = 9 word = player...
26b553e05d14cceada5225e749dd458805e64eb1
ginajoerger/Intro-to-Computer-Programming
/Homework 0/exercise1.py
567
4.40625
4
# HOMEWORK 0 - EXERCISE 1 # Filename: 'exercise1.py' # # In this file, you should write a program that: # 1) Asks the user for a family name # 2) Asks the user for a given name # 3) Prints the sentence 'Hello <given name> <family name> !!!' # # Example: # *INPUTS FROM THE USER # Family name: Corcolle # ...
49243107feca57777dd85172695911a02026abb0
ginajoerger/Intro-to-Computer-Programming
/Homework 1/exercise2.py
905
4.25
4
# This code asks the user to input the number of packages they want to purchase, # then prints the total amount of the purchase after discount. quantity = float(input("Number of packages: ")) #inputs the number of packages price = 49.99 #sets price to 49.99 # Next lines of code determine discounts based on quantity #...
4797f539e0122acd0e9786974dffe8a24d3ac624
allen2000/Python
/gcd/d.py
332
3.796875
4
def gcd(a, b): if a > b: smaller = b else: smaller = a for i in range(1,smaller + 1): if((a % i == 0) and (b % i == 0)): gcd = i return gcd n1 = int(input("输入第一个数字: ")) n2 = int(input("输入第二个数字: ")) print( n1,"和", n2,"的最大公约数为", gcd(n1, n2))
9b15caa9ba4162244fb572a75d4362a30b862e37
allen2000/Python
/6_comprehension.py
1,405
3.859375
4
############################################################### #####列表中每个元素的平方生产一个新的列表 [x_expr for x in iterable if condition ] #####把一个序列或是其他可迭代对象中的元素过滤或是加工,然后再创建一个新的列表 ############################################################### list0=[1,2,3,4,5,6,7,8,9] list1=[] list2=[] list3=[] for i in range(len(list0)): l...
5e8f0bda4865afafc8298bce438dc37d56d68477
avcopan/automol-old
/automol/graph/_stereo/_intco_linalg.py
4,019
4.09375
4
""" integer 3-vector library """ from numbers import Real as _Real from numbers import Integral as _Integral import numpy def unit_direction(int_xyz1, int_xyz2): """ unit direction vector pointing from `int_xyz1` to `int_xyz2` """ int_xyz = numpy.subtract(int_xyz2, int_xyz1) uint_xyz = numpy.divide(in...
50e3407a9a02d22441262e8e9979c9d7f683fda2
jwasinger/CS325
/project1/new/linear.py
998
3.53125
4
def max_subarray(nums): maxSum = -float("inf"); endingSummation = -float("inf") for i in range(len(nums)): if endingSummation > 0: endingSummation = endingSummation + nums[i] else: endingSummation = nums[i] if endingSummation > maxSum: maxSum = endingSummation if not (maxSum > 0...
5f8f1386e0362eabd285de733f0425842068ae9e
tatarflavia/CS-UBB-projects
/Fundamentals of Programming/Connect Four/Validators/Validator.py
827
4.0625
4
''' Created on 3 ian. 2019 @author: Armin ''' from Errors.Errors import ValidError class ValidBall(object): #this class represents the validation for a ball object def __init__(self): pass def validate_ball(self,ball): #function that validates a ball, raises an error if the ball is not rig...
96898a12871463e4a79ebbc1f1b58c0b760e87a0
rfaprofeta/urijudgeonline
/uri1157.py
88
3.75
4
# -*- coding: utf-8 -*- a=int(input()) for i in range(1,a+1): if a % i == 0: print(i)
d47562e65ecbe024048f26a4b8d6320a9eb26abc
rfaprofeta/urijudgeonline
/uri1073.py
113
3.890625
4
# -*- coding: utf-8 -*- a=int(input()) for i in range(1,a+1): if i%2 == 0: print('{0}^2 = {1}'.format(i,i**2))
f30a3943c62e75c51eef90337b0baf86c340e9a0
rfaprofeta/urijudgeonline
/uri1117.py
230
3.890625
4
# -*- coding: utf-8 -*- nota1=0;nota2=0 while True: a=float(input()) if a < 0 or a > 10: print('nota invalida') else: if nota1 == 0: nota1=a else: nota2=a print('media = {:.2f}'.format((nota1+nota2)/2)) break
cd462b1dff7cf987d17f105346c6026e4636587d
rfaprofeta/urijudgeonline
/uri1189.py
300
3.515625
4
# -*- coding: utf-8 -*- tipo = input() soma = 0.0 counter = 0 for linha in range(12): for coluna in range(12): valor = float(input()) if coluna < linha and coluna + linha < 11: soma+=valor counter+=1 if tipo == 'S': print('{:.1f}'.format(soma)) else: print('{:.1f}'.format(soma/counter))
1f2fb082d5355c9512f2f22fdd08d68dab3cb0d0
rfaprofeta/urijudgeonline
/uri1041.py
374
3.640625
4
# -*- coding: utf-8 -*- x,y=map(float,input().split(' ')) if x == y == 0.0: print('Origem') if x > 0.0 and y > 0.0: print('Q1') if x < 0.0 and y > 0.0: print('Q2') if x < 0.0 and y < 0.0: print('Q3') if x > 0.0 and y < 0.0: print('Q4') if x > 0.0 and y == 0.0 or x < 0.0 and y == 0.0: print('Eixo X') if x == 0.0 a...
298981954ef067179e92bb3a43b4d1cdf4fffb7a
rfaprofeta/urijudgeonline
/uri1113.py
159
3.734375
4
# -*- coding: utf-8 -*- while True: a,b=map(int,input().split(' ')) if a < b: print('Crescente') elif a > b: print('Decrescente') elif a == b: break
bcc3010f674350aefa65e6af2a7eb1ebe7d1e731
rfaprofeta/urijudgeonline
/uri1074.py
269
4.0625
4
# -*- coding: utf-8 -*- a=int(input()) for ii in range(a): i=int(input()) if i == 0: print('NULL') if i%2 == 0: if i>0: print('EVEN POSITIVE') elif i<0: print('EVEN NEGATIVE') else: if i>0: print('ODD POSITIVE') elif i<0: print('ODD NEGATIVE')
c7178135d6cb36bbd5944475415184158342a7d2
mkeuschnig/0Player-Scrabble
/deprecated/Scrabble Solver.py
63,723
3.640625
4
# TODO: using threading-module to make the program multithreaded (optional). # TODO: culling for play-suggestions - when the Row already has 15 Letters, no play can be made # when "BIENENHAUS" is already in a (say, horizontal) row, reverse the lookup: # Look at the wordlist and look for words that contains ...
e404ed69345e6355a318d971fcb3c14673dae356
DenisVargas/PhytonRoadToMaster
/Tutorial/Dictionaries.py
1,164
4.34375
4
#Los diccionarios son un tipo de dato similar a los arreglos pero trabaja con claves en vez de indices. #Cada valor se accede utilizando una clave que puede ser de cualquier tipo de dato. #Examples of Dictionaries phonebook = {} #Declaracion phonebook["John"] = 938477566 #Asignación phonebook["Jack"] = 938377264 #Asig...
0970f45514fc90edd51d403ec6fc570c876edada
DenisVargas/PhytonRoadToMaster
/Tutorial/Program.py
1,631
4.53125
5
#Usa el interprete para testear comandos sin escribir un programa completo. #Python es object oriented. no hace falta declarar el tipo ni declararlos por adelantado. #Toda variable es un objeto. #Variable types: number - integers and floating points myint = 20 myfloat = 10.23 myExpresoFloat = float(20) mystring = 'Can...
53a73e257507984b4b50a3e7178e5779fd755247
abhisheksahnii/python_you_and_me
/local_variable.py
201
3.59375
4
#!/usr/bin/env python3 def change(b): a = 90 print(a) a = 9 print("Before the functional call ", a) print("inside change function", end = ' ') change(a) print("After the function call ", a)
6543c016f9ddaac55499a43b926d638b10242f0d
abhisheksahnii/python_you_and_me
/swap_number.py
202
4.15625
4
''' Program to swap ''' def swap(x, y): x, y = y, x return x, y word1 = input("Enter first letter: ") word2 = input("Enter second letter: ") print("Swapping two numbers:",swap(word1, word2))
f2a916f167af26f0a4efc3b224023655d1e9e614
geovanecomp/Studying
/python/python_api_programs/simple_request_2.py
787
3.90625
4
# Using urlopen --------------------------------------------------------------- # from urllib.request import urlopen # kittens = urlopen('http://placekitten.com') # response = kittens.read() # body = response[509:1000] # print (body) # Using requests --------------------------------------------------------------- impo...
c680588962659e5942f47e3ed9c081abb18befbe
NayoungBae/algorithm
/week_2/07_is_existing_target_number_binary_nayoung.py
1,263
3.75
4
# 다음과 같이 숫자로 이루어진 배열이 있을 때, 2이 존재한다면 True 존재하지 않는다면 False 를 반환하시오. finding_target = 2 finding_numbers = [0, 3, 5, 6, 1, 2, 4] def is_exist_target_number_binary(target, numbers): # 나름 선택정렬 생각하고 해본건데.. for i in range(len(finding_numbers)): min_number = numbers[i] min_number_index = i fo...
b70734d12d9ae3f544c525d8e11826b0ee1c9d75
onegules/Number-Guessing-Game
/NumberGuessGame/GameLoop.py
2,257
4.0625
4
from NumberGuess import NumberGuess class Game(NumberGuess): def __init__(self,guesses = 5, high=100): print("Type object_name.howto() for instructions on how to play") self.guesses = guesses self.high = high def howto(self): print("\nIn this game, the program will choose a num...
bf126cfcebbca61bbcac099f6413299e56c19109
grayreaper/pythonProgrammingTextbook
/convertF2C.py
633
4.34375
4
# convertF2C.py # A program to convert Fahrenheit temps to Celsius # BY: Gray Reaper def main(): print("This program converts Fahrenheit temperatures to Celsius.") fahrenheit = eval(input("What is the Fahrenheit temperature?")) celsius = (fahrenheit - 32) * 5 / 9 print("The temperature is...
b21dea2b98ad32f89ef6b851dc5a728e2251d673
FififiJamie/MNIST_NN_Practice
/train.py
598
3.59375
4
import numpy as np class Network(object): def __init__(self, sizes): self.num_layers = len(sizes) self.sizes = sizes self.biases = [ np.random.randn(y, 1) for y in sizes[1:] ] self.weights = [ np.random.randn(y, x) for x, y in zip(sizes[:-1], sizes[1:]) ] def feedForward(self...