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
38e6d7934654348da470855deda3b5714a501eb6
LON3WO7F/Hacktoberfest-start
/Algorithms/bubble_sort.py
317
4.09375
4
def bubble_sort(list): for number in range(len(list)-1,0,-1): for num in range(number): if list[num]>list[num+1]: temp = list[num] list[num] = list[num+1] list[num+1] = temp list = [10,8,13,90,14,23,40,76,89,50] bubble_sort(list) print(list)
d7a2ed35231a8e1e2df2bc6cda47b2aa4ad6d1b4
michaelstucki/09_real_estate_appraisal
/lambda.py
241
3.65625
4
def find_sig_nums(nums, predicate): for n in nums: if predicate(n): yield n numbers = [1, 1, 2, 3, 5, 8, 13, 21, 34] sig = find_sig_nums(numbers, lambda x: x % 2 == 1) for s in sig: print(s, end=', ') print()
097bda6380cf4c3c5d7e9e5bef07aeab97a3127f
FEIHONGYI857/CS3243_project2_group8
/CS3243_P2_Sudoku_XX_ac3.py
7,139
3.71875
4
import sys import copy # Running script: given code can be run with the command: # python file.py, ./path/to/init_state.txt ./output/output.txt class Sudoku(object): def __init__(self, puzzle): # you may add more attributes if you need self.puzzle = puzzle # self.puzzle is a list of lists...
57570b28dd95d75a728ea4446785337e39800740
PannaAryan/Crappy-Football-Windows-version-
/TestCrappy.py
3,876
3.6875
4
import turtle import os #The window and input names window = turtle.Screen() window.title("Crappy Footfootball") #window.bgcolor("black") #Chobi load na hoile screen_width = 960 screen_length = 540 hscreen_width = 960/2 hscreen_length = 540/2 window.setup(screen_width, screen_length) window.bgpic("CrpF.png...
da63cdda380fd029bff67859baf09cd88d423058
Couperin100/2D-Platformer
/levels.py
3,093
3.84375
4
import pygame import constants import platforms class Level(object): """ This is a generic super-class used to define a level. Create a child class for each level with level-specific info. """ def __init__(self, player): """ Constructor. Pass in a handle to player. Needed for when mo...
383ee942f7b75c68c06fed34002378c4760a4190
AlexiaChen/pysonar2
/tests/redefine-op.test/redefine-plus.py
445
3.578125
4
# test class A: def __init__(self, value): self.value = value def __sub__(self, other): if isinstance(other, int): return 2 * other def __lt__(self, other): if isinstance(other, int): return len(str(self.value)) < other else: return Fal...
5f2b995ee76a54ce24808d3547615dd695865ff5
xianyu190912414/Practice-Python-
/函数/kw_args.py
415
3.8125
4
# 构造一个带关键字参数的函数 def print_scores(**kw): print(' Name Score') print('--------------------') for name, score in kw.items(): print('%10s %d' % (name, score)) print() print_scores(Adam=99, Lisa=88, Bart=77) # 先构造一个dict,再将dict作为关键字参数传入函数 data = { 'Adam Lee': 99, 'Lisa S': 88, 'F.B...
3840dab858ac58d475d61b58a1754deb9920f3f7
insidefree/Python_lessons_basic
/lesson07/home_work/hw0x_normal.py
699
3.5
4
import random class Ticket: def __init__(self, ticket): self.ticket = ticket @staticmethod def generate_ticket(): numbers = random.sample(range(1, 90), 15) it = iter(numbers) ticket = dict.fromkeys(range(1, 90), "-") i = 0 while i < 3: keys = ra...
c4cacf339b12e68958c13de76d2359dd041176ac
insidefree/Python_lessons_basic
/lesson05/home_work/hw05_easy.py
1,442
3.5625
4
import os import shutil # Задача-1: # Напишите скрипт создающий директории dir_1 - dir_9 в папке из которой запущен данный скрипт. # И второй скрипт, удаляющий эти папки. def create_folders(folder_name): try: os.mkdir(folder_name) print("Folder {} was created".format(folder_name)) except File...
61b52a0dfe4e0bebea0a5767c7811c6239105a25
yogi13995/Codes
/geeksforgeeks/Dynamic_codes/score/scorecount2.py
315
3.546875
4
def count(b): table = [0 for i in range(b+1)] table[0] = 1 for i in range(3, b+1): table[i] += table[i-3] for i in range(5, b+1): table[i] += table[i-5] for i in range(10, b+1): table[i] += table[i-10] return table[b] t = int(input()) for i in range(t): n = int(input()) print(count(n))
e82caca1c83dd091017ee73504f08f7205290c64
PreciousWarrior/Huge-Numbers-Calculator
/largeexpos.py
1,589
3.890625
4
import math #my brain exploded by the way please pay for surgery def first_exponent(b, e, tower_base): return(e*math.log(b, tower_base)) def bhatlog(x, n, b): #log(log(log(log(x))))//n times, with b base for time in range(0, n): x=math.log(x, b) if x<=0: return 0 return x d...
db88bab86bb7f31a23a8819b8d17553b5700a46d
DemonDaddy22/POS
/Main.py
5,480
3.78125
4
import Product as pr import Burger as br import Wrap as wr import Beverage as bv import Side as sd import Tax as tx import Bill as bl import Menu as me import sys #Taking order itemsList = [] qtyList = [] bur = [] wrp = [] bev = [] sid = [] cheese = [] ice = [] print() while True: op = input...
74468ab511fcb896f5350b7f80f284c96a0ebe3e
bogdancondurache/rxpy-backpressure
/rxpy_backpressure/locks.py
517
3.78125
4
from abc import abstractmethod class Lock: @abstractmethod def is_locked(self) -> bool: return NotImplemented @abstractmethod def unlock(self): return NotImplemented @abstractmethod def lock(self): return NotImplemented class BooleanLock(Lock): def __init__(self...
544922a19e4b926da2a05630f73d9362ec470a3c
ionuttdt/ASC
/lab1/task2.py
942
4.1875
4
""" Basic thread handling exercise: Use the Thread class to create and run more than 10 threads which print their name and a random number they receive as argument. The number of threads must be received from the command line. e.g. Hello, I'm Thread-96 and I received the number 42 """ from random im...
ffb7b778b4d4c18a4ec89c2d805190ee30567ab9
liutaopro/python
/python代码/flag.py
1,460
3.671875
4
#五星红旗 import turtle turtle.up() turtle.goto(-200,200) turtle.down() turtle.begin_fill() turtle.fillcolor("red") turtle.pencolor("red") for i in range(2): turtle.forward(438) turtle.right(90) turtle.forward(292) turtle.right(90) turtle.end_fill() #主星 turtle.up() turtle.goto(-170,145) turtle.down() tur...
7e76c3fc77ee10b0df883918b92fc2c385771880
mdemiral19/Python-By-Example
/Challenge 028.py
197
3.90625
4
'''Challenge 028: Update program 027 so that it will display the answer to to two decimal places.''' number = float(input('Enter a crazy high number: ')) result = number * 2 print(round(result,2))
a6f759f475a64cf716cad64148a52785e5903344
mdemiral19/Python-By-Example
/Challenge 043.py
771
4.5
4
'''Challenge 043: Ask which direction the user wants to count (up or down). If they select up, then ask them for the top number nd then count from 1 to that number. If they select down, ask them to enter a number below 20 and then count down from 20 to that number. If they entered something other than up or down, displ...
5b011da48b6b1b24690a9a3f5afd7dc59b4b54ff
mdemiral19/Python-By-Example
/Challenge 034.py
975
4.3125
4
'''Challenge 034: Display the following message: " 1) Square 2) Triangle Enter a number: " If the user enters 1, then it should ask them for the length of one of ts sides and display the area. If they select 2, it should ask for the base andheight of the trianlge and display the area. If they type in anything else, ...
fdda7c39fef178c7ec649ed8165d55e2828f827d
mdemiral19/Python-By-Example
/Challenge 001.py
176
4.21875
4
'''Challenge 001: Ask for the user's first name and display the output message: Hello [First Name]''' name = input('Enter the first name please:') print('Hello ' + name+ '!')
c084467ce703925b8d6f6ba47507bc60170bd0b0
mdemiral19/Python-By-Example
/Challenge 032.py
443
4.28125
4
'''Challenge 032: Ask for the radius and the depth of a cylinder and work out the total volume (circle area*depth) rounded to three decimal places.''' import math radius = float(input('Please enter the radius of a cylinder, preferably in cm: ')) depth = float(input('Please enter the depth of a cylinder, preferably in ...
14f9349a3b2a64777853d9c3fb377c7b2e66f99c
jamesx0517/python
/ex15.py
389
3.859375
4
#--coding utf-8-- from sys import argv script , filename = argv txt = open(filename) #使用open函數 打開檔案 print "Here's your file %s:" %filename print txt.read() #讀取檔案 print "Type the filename again" file_again = raw_input(">") #重新輸入檔案名稱 txt_again = open(file_again) #打開上頭的檔案名稱 的檔案 print txt_again.read() #讀取檔案
60fbe1d79326bc533cea8e5ca80c272dd19eb7ce
jamesx0517/python
/ex18.py
364
3.640625
4
#--coding utf-8-- def print_two(*args): arg1, arg2 =args print "arg1 %r arg2 %r " % (arg1 ,arg2) def print_two_again(arg1,arg2): print "arg1: %r arg2: %r" % (arg1 , arg2) def print_one(arg1): print"arg1: %r" %arg1 def print_none(): print "I got nothing" print_two("Mars","Yang") print_two_again("WenChieh...
a43e36ee1045d99d94a497ee49a4f61ef96371bb
Method-1/Dungeon_Crawlers
/DungeonWorld.py
380
3.546875
4
class DungeonMap: def __init__(self, size): self.board = [] self.create_map(size) def create_map(self, size): for width in range(size): self.board.append([]) for height in range(size): self.board[width].append("+") def display_map(self): ...
54d38afcc28c7d608a9e0cfcdfcd881cf23a4a01
pablovicz/formacao-python
/python - Exceptions/leitor.py
1,010
3.578125
4
class LeitorDeArquivo: def __init__(self, arquivo): self.arquivo = arquivo #raise FileNotFoundError print(f'Abrindo arquivo: {self.arquivo}') def ler_proxima_linha(self): print("lendo linha...") def fechar(self): raise IOError() print("Fechando arquivo..."...
bb9125f297496537c7dffe59bd88e4eb6859b171
pablovicz/formacao-python
/python - manipulacao-de-strings/RegularExpressions.py
532
3.8125
4
import re ## documentation ### https://docs.python.org/3/library/re.html email1 = "Meu numero é 1234-1234" email2 = "Fale comigo em 12341234" email3 = "1234-1234 é o meu celular" email4 = "lalalalal 989762345 lalalala 2144-2432" ## qualquer digito de 1 a 9 padrao = "[0-9]{4,5}[-]*[0-9]{4}" retorno = re.search(padr...
e8a9b0bf89f24fbd5f5c18c1a80d03a7c511d59b
sandipbhuyan/WSN
/dijkstra.py
1,286
3.546875
4
from collections import defaultdict class Graph: def minDistance(self, dist, queue): minimum = float("Inf") min_index = -1 for i in range(len(dist)): if dist[i] < minimum and i in queue: minimum = dist[i] min_index = i return min_index ...
80e02b8e1049f391d03f3d2cba046164c24f43a5
ripiuk/fant_sizer
/fant_sizer/fant_sizer.py
9,069
3.5625
4
#!/usr/bin python3.6 import os import argparse from collections import Counter __author__ = 'Oleksandr Rypiuk' def _get_sorted_files_size(the_path: str, number_of_output_files: int, min_first: bool): """ :param the_path: path to the directory, to be processed (with subdirectories too) :param number_of_o...
4e5ceb131fefba5adf6c70fea885ca09097e8d83
msiemieniukmorawski/python
/Day_4/ex_list_indexing.py
590
3.84375
4
c = [1,2,3,4,5,6] print('c', c) # jeżeli chcielibyśmy użyć tylko fragmentu listy możemy wybrać go za pomocą # zakresu print(c[2:5]) # od elementu o indeksie 2 do 5. elementu (element ma indeks 4 # ponieważ tablice indeksowane są od 0) print(c[1:]) # od elementu o indeksie 1 do końca listy print(c[:4]) # 4 pierwsze e...
49ebd6ef7381cceea93373357cb6b3bb3d6e60a4
msiemieniukmorawski/python
/homework2.py
1,687
3.84375
4
# Napisz program, który doradzi czy masz dzisiaj założyć kurtkę (bardzo na czasie). # Powinien pobierać od użytkownika co najmniej trzy parametry: bieżącą temperaturę, stan opadów # (brak, małe, duże, śnieg), wiatr (brak, mały, duży, huragan). Możesz zmodyfikować jakie wartości będzie mógł podawać użytkownik. # Stwórz...
1f5bb1eae65f0b93d82605080f2e703753d7d4fa
msiemieniukmorawski/python
/Day_4/ex_list.py
1,016
3.984375
4
# lista to przykład obiektu, który jest: # - zmienny (mutable) - zdefiniowana wcześniej lista może zostać np. wydłużona # - iterowalny - można przejść po jej elementach za pomocą pętli for # - uporządkowany - kolejność dodawania elementów do listy ma znaczenie a = [1, 2, 3] # definicja 3-elementowej listy print(a) #...
6aaf5f05bf3689fedf1e945d5c96db19daee775b
msiemieniukmorawski/python
/Day_9/monitor.py
1,109
3.578125
4
class Monitor(object): """Monitor komputerowy""" def __init__(self, prod, przek, proporcje="16:9"): """ Tworzy instancję obiektu typu monitor :param prod: str - producent :param przek: int - przekatna ekranu w calach :param proporcje: str - proporcje ekranu, defaultowo 16...
cd89fb4101c157821a0fbc8c793be45302f4b72e
msiemieniukmorawski/python
/hello.py
446
4
4
hello = 'hello' world = 'world' ex = '!' #name = input("jak masz na imię? ").capitalize() #print(name) #print(hello.upper() + " " + name + ex) #number = '3' #print(number.isnumeric()) lorem = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vulputate porta odio. Sed vitae neque molestie, consectetur di...
2f45a5250d51a7dd5e46d0383e1f14b6545437ff
msiemieniukmorawski/python
/Day_4/zad_2.py
426
3.96875
4
# Wypisz co 3 liczbę z przedziału od 1 do 10 wyłącznie, # wykorzystując pętlę "for" print('ver 1') for ii in range(1, 10, 3): print(ii) print('ver 2') for ii in range(1, 10): if ii % 3 == 1: print(ii) print('ver 3') for ii in (1, 4, 7): print(ii) # wersja z wykorzystaniem pętli while a = 1 while...
f716685e8c261069b4272f1a90bf714b43d26fad
msiemieniukmorawski/python
/Day_12/ex_unittest/ex_unittest.py
1,087
3.5625
4
import unittest from Day_12.unnecessary_math import multiply # Moduł unittest jest wbudowanym w pythona modułem do testów. # Każdy test powinen być zawarty w klasie dziedziczącej po unittest.TestCase. # Dzięki temu możemy łączyć testy, oraz wykonywać pewne kawałki # kodu przed (setUp) i po wykonaniu testu (tearDown)...
43782231cb4e7c72c50cade19c0a019443e6b0c2
mulualem04/ISD-practical-7
/ISD practical7Q5.py
334
4.25
4
def count_spaces(userinput): # function definition spaces = 0 for char in userinput : if char == " " : spaces = spaces + 1 # increment return spaces # the function returns the space between words userinput = input("Enter a string: ") print(count_spaces(userinput)) # Call the function w...
dec0f230d1ed558ec452679a2d6bbbcb4a99b89b
Sahadkp11/Calculator
/pythonCalculator.py
6,567
3.65625
4
from tkinter import * from tkinter import messagebox val = "" A = 0 operator = "" def btn_1_isclicked(): global val val = val + "1" data.set(val) def btn_2_isclicked(): global val val = val + "2" data.set(val) def btn_3_isclicked(): global val val = val + "3" data.set(val) def b...
15f02d2a46fce70fa351845a8fa2ff45c889d5a4
opklnm102/python-tutorial
/algo/seventeen.py
185
3.78125
4
#초를 시, 분, 초로 number = int(input("input seconds: ")) sec = number % 60 number /= 60 min = number % 60 number /= 60 hour = number print("%d : %d : %d" % (hour, min, sec))
82a446f3848792e3a3e9654feec3a8866358b057
opklnm102/python-tutorial
/algo/nineteen.py
295
3.53125
4
#5명 등수 출력 scores = [] while not len(scores) == 5: score = int(input("input score: ")) scores.append(score) seq = 0 for s in scores: seq += 1 rank = 1 for ss in scores: if s < ss: rank += 1 print("%d번째는 %d점, %d등" % (seq, s, rank))
d3d44f3786d6b57364ba16ae1d556e67b9d3421c
bbenefield89/Intro-Python
/src/adv.py
5,157
3.515625
4
# Write a text adventure that allows the player to move from room to room by # typing "n", "w", "s", or "e" for north, west, south, and east. # These are the existing rooms. Add more as you see fit. rooms = { "outside": { "name": "Outside Cave Entrance", "description": "North of you, the cave mout...
78ef7ee77d38b983eebdaaac076be278915966b1
morbidcorvid/CodingAdvent
/days/day1.py
1,438
3.875
4
# Day 1: Not Quite Lisp # Santa is trying to deliver presents in a large apartment building, but he can't find the right floor - the directions he got are a little confusing. He starts on the ground floor (floor 0) and then follows the instructions one character at a time. # An opening parenthesis, (, means he should g...
8e2e6391cb9c735e0ade21b395e75869217eebdd
morbidcorvid/CodingAdvent
/days/day15.py
3,816
3.75
4
''' Day 15: Science for Hungry People Today, you set out on the task of perfecting your milk-dunking cookie recipe. All you have to do is find the right balance of ingredients. Your recipe leaves room for exactly 100 teaspoons of ingredients. You make a list of the remaining ingredients you could use to finish the r...
5b65963c5b896bfbaa20cb029292c9b4574a5ef0
gourisnair/Python-Basics
/BasicOperationsInPy.py
264
4.0625
4
print "Hello, World" myName = raw_input("what is your name ") print(myName) print("Hello " + myName) length = len(myName) print("Length of your name is " + str(len(myName))) age = input("What is your age ") print("You will be " + str(int(age) + 1) + " next year")
f0a25388ce8279b47a7c2eca3b3e4d0e4e695bb4
joristork/compbox
/deliv/dec_2011/src/peephole.py
2,436
3.59375
4
""" File: peephole.py Course: Compilerbouw 2011 Author: Joris Stork, Lucas Swartsenburg, Jeroen Zuiddam The peephole module Description: Contains the Peephole and Peeper classes used for optimising code. """ class Peephole(object): """ wrapper for an iterable list of instructions;...
b9b302e2ff4d8de6d83f11bf92427e450ef8575c
hwchen/thinkpython
/thinkpython7-5piapprox.py
720
3.828125
4
#factorial, pi approximation think python 7.5 import math def factorial(n): if n == 0: return 1 else: return n * factorial(n-1) def formula_numerator(n): return float((factorial(4*n) * (1103 + (26390 * n)))) def formula_denominator(n): return float(((factorial(n))**4) * (396 **(4*n))) de...
3ae3a4f476ed05af68bec4d866d6bbbdb427130a
hwchen/thinkpython
/thinkpython5-6Koch.py
1,738
3.65625
4
#thinkpython chapter 5-14 exercises 5-6 Koch #Koch curve and snowflake import math from swampy.TurtleWorld import * world = TurtleWorld() bob = Turtle() bob.delay = 0.01 def koch_curve(t, x): """Koch curve with initial start length of x and angle of 60 degrees. t is turtle """ if x < 3: fd(...
fb60b00484be4d6a447ea7f1923b9d400b47f85f
hwchen/thinkpython
/thinkpython13smallproblems.py
2,949
3.78125
4
#Thinkpython Chapter 13 small problems (working with data) #13.1, process text of a book. #13.2 skip header of gutenberg book. process the rest of text import string import random def open_book_to_list(filename, title): """ Opens text file, puts all words into a list with no spaces, enlines, punctuatio...
cd32cbe0eabc14ced429882a2097af40c01cfd6e
hwchen/thinkpython
/thinkpython17.py
871
4
4
#thinkpython chapter 17 #17.1 - 5 class Time(object): """ time object, represents time in hh:mm:ss""" def print_time(self): print '%.2d:%.2d:%.2d' % (self.hour, self.minute, self.second) def time_to_int(self): return 3600*self.hour + 60*self.minute + self.second class Point(object): """attributes x and y, ...
4aa53accdfe795005d435abda989a8cfe28bb590
hwchen/thinkpython
/thinkpython4-3exercises.py
1,346
4.46875
4
#thinkpython chapter 4.3 exercises import math from swampy.TurtleWorld import * world = TurtleWorld() bob = Turtle() def square (t, length): """ Draws a square of length "length" using turtle "t" """ for i in range(4): fd(t, length) lt(t) def polygon(t,length,n): """ Draws a polygon...
16dd359aea177156e1f25ce784a1fed0c3d229d5
hwchen/thinkpython
/thinkpython8-10is_palindrome.py
169
3.84375
4
#Think python exercise 8.10 # one-line is_palindrome def is_palindrome(word): if word == word[::-1]: return True return False print is_palindrome("lool")
4b891825fbb3a5506434584971e615da1dcbacfe
cosmo-kramer/Glue
/Tests/alltests/gcd.py
175
3.640625
4
def gcd(a, b): int int print a, b if b == 0: return a else: return gcd(b, a%b) inp = 80 :int inp1 = 48 :int a= gcd(inp, inp1) :int print a
83ec58ac871dd5136c3e2f26b273c38da989da71
cff874460349/tct
/res/gui/moveCircle.py
1,380
4.25
4
# use a Tkinter canvas to draw a circle, move it with the arrow keys try: # Python2 import Tkinter as tk except ImportError: # Python3 import tkinter as tk class MyApp(tk.Tk): def __init__(self): tk.Tk.__init__(self) self.title("move circle with arrow keys") # create a can...
9e206a4d965852bc70a29148066616ac213adcd5
pontes-guilherme/webservice
/client/Functions.py
2,079
3.75
4
import os class Functions: @staticmethod def enter_to_continue(): """Espera um [enter] do usuário """ input() @staticmethod def menu(): """Exibe um simples menu de opções. A opção é escolhida através da entrada de dados pelo usuário Returns: ...
914e6a60269232b2ae8346bf0363c216570f9f9c
pushkargodbole/GPUPySPH
/cuda/test_cuda_nnps2.py
6,016
3.609375
4
"""A simple example demonstrating the use of PySPH as a library for working with particles. The fundamental summation density operation is used as the example. Specifically, a uniform distribution of particles is generated and the expected density via summation is compared with the numerical result. This tutorial ill...
350ab295565be8274fc0c0b2f99a92cb3e8e8428
elthran/RPG-Game
/models/abstraction_lv1/abilities_data.py
380
3.5
4
import pandas profs = pandas.read_csv('abilities.csv', dtype={'Name': str, "Description": str}) #You can declare each column's data type ALL_ABILITIES = [] for i, row in enumerate(profs.itertuples(), 1): ALL_ABILITIES.append((row.Name, row.Type, row.Tree, row.TreeType, row.Maximum, row.Description, row.Current, ...
7b7e55932ca14401c39e174e2ced01e5461ff557
elthran/RPG-Game
/services/naming.py
1,440
3.515625
4
def fix_camel_case(name): """Detect and fix camel case names. Otherwise these names will be lost when converting to 'title()'. """ if name[0].isupper() and name[1:].islower(): return name # print("Bad name:", name) fixed_name = name[0] + ''.join([" " + letter.lower() ...
3ee5c0d80aba0ef66adcf277b5a302f44e558bc8
Anh-KNguyen/Advance-Python
/callback.py
477
3.546875
4
# When you execute some function and want that function to call you back after you don't do something # Pass what is called a "callback" function to it import time # no callback def doSomething(doneMessage: str): time.sleep(2) print(doneMessage) # callback def doSomethingCB(cb=None): time.sleep(2) i...
5e84b875a8cd748635cde21912befd6781f92f02
Anh-KNguyen/Advance-Python
/callback-exercise.py
363
3.5
4
import urllib.request def downloadFromWeb(url, cb = None): rsp = urllib.request.urlopen(url) data = rsp.read() print('successfully downloaded', url) if cb is not None: cb(data) def callback(data) -> None: print(data) # callback function that prints the data downloaded from the url downlo...
176b9967b350927dec77cbce6c7cdcbc26cf85e6
monica141/lecture4
/classes2.py
886
4.28125
4
class Flight: #creating a new class with the innit method def __init__(self, origin, destination, duration): self.origin = origin self.destination = destination self.duration = duration #printing the information of the flight #we take self to know the object we are operating wi...
528bded853416c586a0ef19527ad77acdd06ddbc
eng-jonathan/Advanced_Econometrics
/homework_python/ps2.py
1,343
3.671875
4
# -*- coding: utf-8 -*- """ Spyder Editor Title: Econ 387 Homework 2 Author: Jonathan Eng Date: Febuary 19, 2020 """ import numpy as np import scipy as sp #1 def estimate_intercept_and_slope(x, y): mean_x = sp.mean(x) mean_y = sp.mean(y) sumnum = 0 sumden = 0 for i in range(0, len(x) - 1): ...
fa442e664d3fde8a5e57211990a8f83f999fccaa
fwparkercode/IntroGames
/sp18_student_games/Octavio Space Shooter/Octavio Space Shooter.py
15,311
3.90625
4
""" Octavio Lopez My first game """ import pygame import random # Define some colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (40, 255, 0) RED = (255, 0, 0) YELLOW = (255, 255, 0) pygame.init() # Set the width and height of the screen [width, height] screen_width = 700 screen_height = 500 size = (scree...
d5049eef28f3054892e178f1b1a406ebb5f9db39
fwparkercode/IntroGames
/Fa18_student_games/Ada Office/final_lab.py
9,407
3.609375
4
''' Ada Collins Final Lab Kevin's Famous Chili Maze ''' import pygame # -- Global constants # Colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) BLUE = (50, 50, 255) # Screen dimensions screen_width = 800 screen_height = 600 # Text x_offset = 200 # Call this function so the Pygame library can initialize itself pyga...
90b43ab1f9db19b9af43780534f814b3569e311f
fwparkercode/IntroGames
/Fa18_student_games/Elsie NBA Jam/Elsie_final.py
9,552
3.5
4
# Levels??!! # backround music. Lower the sound """ pygame base template Intro computer programming Elsie Rattner 2018 """ import pygame import random # Define colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 255, 0) RED = (255, 0, 0) BLUE = (0, 0, 255) YELLOW = (255, 255, 0) CYAN = (0, 255, 255) MAG...
3c014a605eaa2be0344c4110626d72231d0ed499
fwparkercode/IntroGames
/Fa18_student_games/Camille Air Hockey/game_drafting.py
6,933
3.515625
4
import pygame import math import random pygame.init() # Define some colors BLACK = (0, 0, 0) # (red, green, blue) WHITE = (255, 255, 255) GREEN = (0, 255, 0) RED = (255, 0, 0) BLUE = (0, 0, 255) GRAY = (120, 120, 120) YELLOW = (255, 255, 0) CYAN = (0, 255, 255) MAGENTA = (255, 0, 255) # Set the width and height of ...
ea13d18de8a1672b14bd74e93de08e88e30c0d59
Code-Institute-Submissions/Horror_Adventure_Game
/run.py
9,722
4
4
# Collecting the users name user = input("What is your name? \n") if user == "": print("Blank space not valid, please insert name") # A welcome message explaining the game and its function mechanic else: print("Welcome", user, ", this is a horror-adventure game based on a Japenese\n\ an urban legend that uses ...
bf331315404b25ab7aaffee7dd8a1b59d806a986
Splintzz/Simple-Sudoku-Solver
/Sudoku Solver.py
1,311
3.65625
4
import numpy as np EMPTY = 0 N = 3 NUM_ROWS = N * N NUM_COLS = N * N puzzle = [[6,7,9,0,0,8,0,0,0], [0,5,0,0,1,0,0,0,3], [3,1,0,0,2,0,5,0,0], [7,4,0,1,8,0,0,3,9], [0,3,0,0,0,0,0,1,0], [9,2,0,0,3,5,0,6,7], [0,0,7,0,4,0,0,5,6], [5,0,0,0,9,0,0,2,0], [0,0,0,5,0,0,3,8,1]] def solve() : gl...
55ab39c90bb59df3de73f705271f69866b414b03
MM-Phoenix/Beat-the-Hackers
/Password Generator V.python 2.7 🔐🐭.py
4,016
3.96875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Aug 27 10:30:25 2020 @author: Phoenix """ import random import sys WELCOME = "\nWelcome to Password Generator\n" START = "Enter \"OK\" to generate your unique password.\nEnter \"QUIT\" to exit the program.\n" CONTINUE = ["ok", "okay", "yes", "yep", ...
21291507e6b3aa9daf754269c1f0dbb339082925
SlosseElias/BP_testp
/Oef1.py
1,676
3.71875
4
# Dit is commentaar (commentarieer je programma) # Labo_Intro Oef1 # naam = input("Wat is jouw naam?") # voornaam = "Elias" # leeftijd = int(input("Wat is jouw leeftijd?")) # leeftijd = leeftijd + 10 #naam = "Slosse" #print("Welkom", voornaam, "\t", naam) #print("Welkom {0}. Jouw naam is {1}. \nJij bent {2:.2f} jaa...
4b2b9096c72a92c373df07ac3212a376f68eaf6c
pysnow530/adventofcode
/day1.py
1,324
3.625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import math import numpy as np def main(): """入口,读取R3,L4类似的字符串数据,打印最后与原点的距离""" position = np.array((0, 0)) positions = [position] direction = np.array((0, 1)) items_str = raw_input('input data: ') items = items_str.split(', ') for item in it...
bbaa897cb75764ed403e792b101c84de073442fd
Eloise999/Design_of_Computer_Programs_CS212_Udacity
/hw4-2.py
3,912
3.828125
4
# ----------------- # User Instructions # # In this problem, you will solve the pouring problem for an arbitrary # number of glasses. Write a function, more_pour_problem, that takes # as input capacities, goal, and (optionally) start. This function should # return a path of states and actions. # # Capacities is a tuple...
c86bf31fad69b37cfe9e483e05d3ba58f0b14cb2
parthpanchal123/Algorithms
/insertionsort.py
399
4.15625
4
def insertion_sort(arr): for i in range(1, len(arr)): hole = i value = arr[i] while(hole > 0 and arr[hole - 1] > value): arr[hole] = arr[hole-1] hole -= 1 arr[hole] = value return arr if __name__ == "__main__": print('Enter elements to sort') my...
f78b7ebdf99469fd659b4797e341efc4af73354d
timothy-WangS/Python-code-for-selflearner
/experiment/exp12_单例.py
821
3.765625
4
# 类创建的对象只有唯一实例 class LOnlyMe(object): # 懒汉式 __instance = None # 记录第一个创建的对象 __init_flag = False # 用于只初始化一次 def __new__(cls, *args, **kwargs): # 分配空间,返回对象引用 print("创建对象,分配空间") if cls.__instance is None: # 如果未创建 cls.__instance = super().__new__(cls) return cls.__in...
992564ad8cbb1880feee3ea651ee605530691294
KyleRichVA/sea-c45-python
/hw/hw13/trigram.py
1,954
4.28125
4
""" Short Program That Generates Over 100 Words Of A Moby Dick Style Story Using Trigrams. """ import random # get the file used to create the trigram file = open("mobydick.txt", "r") # take the text and store in memory line by line lines = [] for line in file: lines.append(file.readline()) file.close() # Used to...
1cc335521cf917c62a4d914afe3390215c19acff
RyanAVelasco/Jaoventure.net_Exercises
/Chapter_7.py
2,678
4.34375
4
import random print(""" === 7.1: Exercises with classes === Use the python documentation on classes at https://docs.python.org/3/tutorial/classes.html to solve the following exercises. 1. Implement a class named "Rectangle" to store the coordinates of a rectangle given by (x1, y1) and (x2, y2). 2. Implement the clas...
a506b8fc0cc4b443bf6fffaf64de0840b7cc0af0
Yushgoel/Python
/agefinder.py
290
4.125
4
from datetime import datetime now = datetime.now() print now date_of_birth = raw_input("Please enter your date of birth in DD-MM-YYYY.") #date_of_birth = int(date_of_birth) birth_year = date_of_birth.year current_year = now.year age = current_year - birth_year print "age = " + age
14d8c42d50341ba093681093f0679d6426cbc8cd
Yushgoel/Python
/ctrsumavg.py
239
4.15625
4
n = raw_input("How many numbers do you want to enter?") n = int(n) count = 0 sums = 0 while count < n: num = raw_input("Please enter a number.") num = int(num) sums = sums + num count = count + 1 avg = sums / n print sums print avg
48b3563283e0c5d6f058e13d596f56292f54390a
Yushgoel/Python
/tictactoe.py
4,159
3.765625
4
board = [] p1inputrow = -1 p1inputcolom = -1 p2inputrow = -1 p2inputcolom = -1 count = 0 breakornot = False for x in range(3): board.append(["_"] * 3) def print_board(boardv): for row in boardv: print " ".join(row) def check(): count = 0 p1rcount = 0 p1c1count = 0 p1c2count = 0 p1c3count = 0 p...
348f95bcbf9bc810b1956e879a39193dba257c63
Yushgoel/Python
/palindrome_check.py
431
3.78125
4
input_str = raw_input("PLEASE enter a word ") ctr = 0 rctr = len(input_str) - 1 char = "" list1 = [] for i in reversed(input_str): list1.append(i) if "".join(list1) == input_str: print "palindrome" input_str = "".join(list1) print input_str[0] while ctr < len(input_str): char = input_str[ctr] input_str[ctr] = i...
863968686f97dc5f0cb1bc620e6af53dbc497e17
Yushgoel/Python
/powers.py
264
4.15625
4
exponent = raw_input("Please enter the exponent.") exponent = int(exponent) num = 1 exponent_plus_one = exponent + 1 while num <= 10: ctr = 1 product = num while ctr <= exponent: product = product * num ctr = ctr + 1 print product num = num + 1
a071d442447f5cb8e58ddfcc11552c6bc3fca901
Yushgoel/Python
/highest_sum.py
1,054
3.8125
4
#wierd concept, let me explain- #highest sum of list : #list = 0, 2, -4, 1 #hihest sum of consecutive numbers #highest sum is 2 range1 = int(raw_input("How many numbers in list? ")) list1 = [] for i in range(0, range1): number = int(raw_input("Please enter number ")) list1.append(number) ctr = 0 for i in list1:...
46721b01bc315aab1c5385f737db648cd4c66aac
chiplunkar-shubham/MyCaptain
/fibonacci.py
206
4
4
def fibo(n): i=0 j=1 l=[0,1] for k in range(0,n-2): ans=i+j l.append(ans) i=j j=ans return l n = int(input("How many terms do u want : ")) print("The Fibonacci Series is : ",fibo(n))
5dcdff456bf5bb3604dad49f1ff42f3132ba632a
vchernoy/DatacenterCooling
/datacenter_cooling.py
4,717
4.03125
4
# Author: Chernoy Viacheslav # email: vchenoy@gmail.com # # The program solves "Datacenter Cooling" Problem presented by Quora # http://www.quora.com/challenges # reads and returns 0/1/2/3 matrix from the standard-input def read_input(): datacenter = [] w, h = [int(x) for x in raw_input().split()] for i in...
7c3d41a416ce172341fcba48a700faa3c6521de9
Stanwar/HackerRank
/Python/changingCase.py
313
3.734375
4
inString = input() inList = list(inString) output = "" for i in inList: if(i.isupper()): output = output + i.lower() elif(i.islower()): output = output + i.upper() else: output = output + i print(output) #### ####alternative code #### a = print(input().swapcase())
b7b02d737b543088e397e9d33f72c0ef12b83a3d
dzhang54/LPTHW
/LPTHW/ex15.py
479
3.875
4
#imported the modules from argv from sys import argv #uses the modules we imported script, filename = argv #opens the filename we put doesn't print out he text txt = open(filename) #prints out the file name using the formatter print "Here's your file %s:" % filename #prints out the the text within the code print tx...
833dea8eee1bf063740d00faafb4f587f2898c4c
anthonyjclark/adabot-prototyping
/rpi/demos/ledFade.py
762
3.84375
4
# RPi Demo using PWM # Fades an LED in and out from time import sleep import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD) GPIO.setup(12, GPIO.OUT) p = GPIO.PWM(12, 100) # starting frequency p.start(30) # starting duty cycle p.ChangeDutyCycle(80) p.ChangeFrequency(1000) duty_cycle = 0 for count in range(40): ...
0dc6f4e34e40bdc59ed515a5349ce6a3c558d181
shashankgupta2810/Train-Ticket
/Book_train_ticket.py
1,514
4.125
4
class Train(): # create a class # def init function and pass the variable what you required to book the ticket like train name , soucre ,seats, etc. def __init__(self,train_name,train_no,source,destination,status,seats,seatNo): self.seats=seats self.train_no=train_no self.train_name= ...
0474e924c4116517012f01ad3bccf9b20d53f3e5
Dikshitha0812/Data-visualisation
/scattergraph.py
182
3.6875
4
import pandas as pd import plotly.express as px df=pd.read_csv("data.csv") figure=px.scatter(df,x="Population",y="Per capita",color="Country",size="Percentage") figure.show()
57587b67dcee714f565a5fba869305a0d29c87ac
Louis192/Python_Challenge_1
/triplet.py
429
3.703125
4
# Complete the compareTriplets function below. def compareTriplets(a, b): alice=0 bob=0 for i in range(3): if a[i]<b[i]: bob+=1 elif a[i]>b[i]: alice+=1 return(alice,bob) if __name__ == '__main__': a = list(map(int, input().rstrip().split()))...
78e31363747f23594cbdea3dca7e2c4a942a9bd0
Louis192/Python_Challenge_1
/Min_max.py
290
3.65625
4
def minmax(arr): maximum=max(arr) minimum=min(arr) maxi=arr.copy() maxi.remove(minimum) mini=arr.copy() mini.remove(maximum) min_sum=sum(mini) max_sum=sum(maxi) print(min_sum,max_sum) arr=list(map(int,input().rstrip().split())) minmax(arr)
eb8e39107761264c3eecc22d455a1359884e2629
nirajkvinit/python3-study
/shreya/words_game/v1/shreya_words.py
4,261
4.125
4
import random, datetime, csv, os, sys ''' read original list of words ask for length of a word. ex 3 letter words get a random word from the words list save the generated word to a temporary list ask for confirmation to continue when negative confirmation save the temporary list to a file based on timestamp and exit ...
b99e7805a06f924b0edbce4113bc4bcd2b8c4a45
nirajkvinit/python3-study
/dive-into-python3/ch3/setcompr.py
546
4.5625
5
# Set comprehensions a_set = set(range(10)) print(a_set) print({x ** 2 for x in a_set}) print({x for x in a_set if x % 2 == 0}) print({2**x for x in range(10)}) ''' 1. Set comprehensions can take a set as input. This set comprehension calculates the squares of the set of numbers from 0 to 9 . 2. Like list comprehension...
a04c7dd33971969dba4e231164978d595e903f91
jandirdlctm/Miller-Algorithm
/miller_algorithm.py
1,947
3.71875
4
import random import math def StandardTest(x): state = 1 for i in range(2, int(math.sqrt(x)) + 1): if x % i == 0: state=0 return False break else: continue if state == 1: return True return False def MillerPrime(n): for i in r...
695abc03a7b2c0924e40dec9b14d28a681735fa6
AlfiyaZi/mycodinGame
/easy/thor.py
1,044
3.71875
4
import sys import math # light_x: the X position of the light of power # light_y: the Y position of the light of power # initial_tx: Thor's starting X position # # initial_ty: Thor's starting Y position light_x, light_y, initial_tx, initial_ty = [int(i) for i in input().split()] x2,x1=light_x,initial_tx y2,y1=light_y,...
65373d7f63b195850dc94333f6520941c9a8bb5e
shay-d16/Python-Projects
/4. Advanced Python Concepts/os_and_open_method.py
1,103
4.125
4
# Make sure to import os so that Python will have the ability to use # and access whatever method we're using import os # Make sure that when you call on a class and you want to access # it's methods within the class, you have mention the class first, # then put a period, then the method. EX: print(os.getcwd()) def...
23e1259ea3b50551b6f76dd2ffef23674635780d
shay-d16/Python-Projects
/5. Object-Oriented Programming/parent_class_child_instances.py
2,889
4.5625
5
# Python 3.9.4 # # Author: Shalondra Rossiter # # Purpose: More on 'parent' and 'child' classes # ## PARENT CLASS class Organism: name = "Unknown" species = "Unknown" legs = 0 arms = 0 dna = "Sequence A" origin = "Unknown" carbon_based = True # Now that you've defined this class and set...
ef3e2f58e52b8fd1c8855d36ba46a7899121a6aa
shay-d16/Python-Projects
/5. Object-Oriented Programming/polymorphism_submission_assignment.py
1,888
4.34375
4
# Python 3.9.4 # # Author: Shalondra Rossiter # # Purpose: Complete and submit this assignment given to me by the # Tech Academy # # Requirements: Create two classes that inherit from another class # 1. Each child should have at least two of their own attributes # 2. The parent class should have at least one method (f...
fdb5e146b6a462cc0454bf5ddfe5c0a636f859c0
microxoft/ST-ICC-102-T-002_3-2018-2019
/Ejercicio9_Fibonaci/Ejercicio9_Fibonaci.py
221
3.5625
4
num1 = 0 num2 = 1 num3 = num1 + num2 sumaPares = 0 while num3 < 4000000: sumaPares += num3 if (num3 % 2 == 0) else 0 num1 = num2 num2 = num3 num3 = num1 + num2 print(sumaPares) # 4613732
4e28bfbc5dade1e0cef2a498130435a4fce5fc8c
microxoft/ST-ICC-102-T-002_3-2018-2019
/Ejercicio5_Serie/Ejercicio5_Serie.py
1,214
3.984375
4
from math import sqrt def esPar(num): return num%2 == 0 def esPositivo(num): if num > 0: print("Es positivo.") elif num < 0: print("Es negativo.") else: print("Es cero.") def esPrimo(num): k = 2 while num % k != 0 and k <= sqrt(num): k += 1 ...
6119b3691c83d69b0000ea78f73f6ef01aac41e5
rajkumargithub/pythonexercises
/forloop.py
204
4.1875
4
#cheerleading program word = raw_input("who do you go for? ") for letter in word: call = "Gimme a " + letter + "!" print letter + "!" print call print "What does that spell?" print word + "!"
036397ba2c511a0fe9d0c10d84fe94946be89736
wangs0622/learning_Algorithm
/interview_algorithm/reMatch.py
5,577
3.75
4
''' Created on 2018年3月24日 @author: wangs0622 剑指 offer 19 题,正则表达式匹配问题 ''' # 按照书上的代码思路写的程序 def match(string, pattern): print(string, ' ', pattern) if len(pattern) == 0: if len(string) == 0: return True else: return False if len(pattern) == 1: if l...
c6093305980256c3c446d99dade96f21d85593f8
frozen007/algo-study
/Challenge/lps.py
843
3.703125
4
""" 5. 最长回文子串 https://leetcode-cn.com/problems/longest-palindromic-substring/ # tag(dp) """ class Solution(object): def longestPalindrome(self, s): """ :type s: str :rtype: str """ n = len(s) dp = [[False]*n for _ in range(n)] p_str = "" for l in r...