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
98f1fdecd0f9777aa753bae922dce6ca65bbcc37
steingrd/euler
/problem12.py
1,126
3.6875
4
#!/usr/bin/env python # Copyright (c) 2008 by Steingrim Dovland <steingrd@ifi.uio.no> from euler import findfirst, primefactors, DefaultDict from operator import mul # The sequence of triangle numbers is generated by adding the natural # numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + # 7 = 28. ...
bb813d50ddcf1684434de894831ff1c22c56a0ad
steingrd/euler
/problem97.py
580
3.53125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2008 by Steingrim Dovland <steingrd@ifi.uio.no> # The first known prime found to exceed one million digits was # discovered in 1999, and is a Mersenne prime of the form 269725931; it # contains exactly 2,098,960 digits. Subsequently other Mersenne primes, ...
e859587fc1155e50a9f7f9e5964245c5fe0cdee2
aagnone3/deep-rl
/p1_navigation/its_bananas.py
5,036
3.78125
4
#!/usr/bin/env python # coding: utf-8 # # Navigation # In this notebook, you will learn how to use the Unity ML-Agents environment for the first project of the [Deep Reinforcement Learning Nanodegree](https://www.udacity.com/course/deep-reinforcement-learning-nanodegree--nd893). # ### 1. Start the Environment import o...
b74ee0c8f0c7ab909600d8f15cb104351a9a0aaf
Monzillaa/practices-python
/lists.py
1,280
4.21875
4
demo_list = [1, 'hello', 1.34, True, [1,2,3]] colors = ['red', 'red', 'red', 'green', 'blue'] ##Definimos las listas a travez de un constroctor o funcion llamado list numbers_list = list((1,2,3,4)) print(numbers_list) #print(type(numbers_list)) #r = list(range(1, 10)) #print(r) #print(dir(colors)) #print(len(demo_lis...
11b83f28ff0f6d8b176f1633b70b6654bc2e5106
DaviStalleiken/codigos-de-desafios
/exercicios-python/ex030.py
157
4.0625
4
num = int(input('Digite um número inteiro: ')) if (num % 2) == 0: print('O número escolhido é PAR.') else: print('O número escolhido é ÍMPAR')
c3431e94c961977b6e10cc43cf5123614e64e98c
DaviStalleiken/codigos-de-desafios
/exercicios-python/ex042.py
563
3.875
4
r1 = float(input('Primeiro segmento: ')) r2 = float(input('Segundo segmento: ')) r3 = float(input('Terceiro segmento: ')) if r1 < r2 + r3 and r2 < r1 + r3 and r3 < r2 + r3: print('Você \033[32mpode\033[m formar um triângulo. ', end='') if r1 == r2 == r3: print(f'Seu triângulo é \033[36mequilátero\033[m...
8bd1e6d128055c4406243eec47323ee37cf4d40b
DaviStalleiken/codigos-de-desafios
/exercicios-python/ex006.py
254
4.125
4
n = int(input('Digite um número: ')) print(f'O dobro do seu número é {n*2}.') print(f'O triplo do seu número é {n*3}.') print(f'A raiz quadrada do seu número é {n**(1/2):.2f}.') # A raiz quadrada também pode ser feita com a funcão pow(n, n*1/2)
1d48068f26c55b17b458bc89078c9f65d4076eec
DaviStalleiken/codigos-de-desafios
/exercicios-python/ex040.py
459
3.96875
4
n1 = float(input('Primeira nota: ')) n2 = float(input('Segunda nota: ')) media = (n1 + n2) / 2 if media < 5: print(f'Sua média foi de {media} e você está \033[31mREPROVADO\033[m.') elif media >= 5 and media <= 6.9: # Também é possível utilizar elif 7 < media <= 5 print(f'Sua média foi de {media} ...
9c526720d4aa5c3016aa8972ec4c8c93a078dd56
DaviStalleiken/codigos-de-desafios
/exercicios-python/ex017.py
184
3.546875
4
from math import hypot co = float(input('Comprimento do cateto oposto: ')) ca = float(input('Comprimento do cateto adjacente: ')) print(f'A sua hipotenusa medirá {hypot(co,ca):.2f}')
da4115f4f762b550a6fb2bd07b451294a5de68b9
yamada46/Python_class
/Lab2.py
1,157
4.1875
4
''' Module 8 - Lab 2 1 1 unread reply. 1 1 reply. Instructions: When you try to open a file that doesn't exist on your file system the open function raises a nice error called FileNotFoundError ```bash >>> open('some_file_location.txt', 'r') Traceback (most recent call last): File "<stdin>", line 1, in <module> File...
b70765edd48e29f40027e612e2d2af9e07d528e0
yamada46/Python_class
/Mod5_Lab3.py
1,603
4.34375
4
#! /Users/gailyamada/PycharmProjects/ITFDN2018/venv/bin/python3 ''' Module 5 - Lab 3 Denise Elizabeth Mauldin Let's do some analysis of the Seattle Wage Data CSV file Make sure you have downloaded the data from here: https://catalog.data.gov/dataset/city-of-seattle-wage-data/resource/1b351da9-d1a9-48e4-850c-a1af51c4...
994964e186d4034cccb1f89d1a78feff148e7717
yamada46/Python_class
/Mod3_Lab2.py
1,191
4.25
4
''' Mod3_Lab2 make a variable with one animal find unique letter give user letters + 3 guesses compare each guess to unique letters print out the matches ''' # Make a list of animal animal = "raccoon" unique = set(animal) #print(unique) # store guesses guessed_letter = set() num_guess = len(unique) #print(num_guess)...
adfbfde6e2c9be0042c137fb9ee15b812dffb026
Skaylen/python
/Bhaskara.py
1,264
3.953125
4
#!/bin/env python3.7 # # Projeto: Bhaskara # Autor: Mac Brener - Skaylen # Data: 24/07/2020 # print('Programa para calcular equações do 2º Grau.\n') print('Estrutura da função do segundo grau: \nax² + bx + c = 0\n') try: try: a = float(input('Digite o valor de a: ')) b = float(input('Digite o valo...
e6022920b576c8ec899c4dbacad8cf0d1af2b67c
GMU-vision-robotics/View-Invariant-Visual-Servoing-for-Navigation
/rrt/bresenham.py
2,410
3.921875
4
# Code based on the following two web pages. # https://www.cs.helsinki.fi/group/goa/mallinnus/lines/bresenh.html # https://en.wikipedia.org/wiki/Bresenham's_line_algorithm # # Paul McKerley (G00616949) def slope(p1, p2): if p1[0] == p2[0]: raise ValueError("Undefined slope for points ({}, {}) and ({}, {})"...
6548bb30eea23d2dd7e269294356f98e4e617844
dbbudd/Python-Experiments
/AI/EasyAI_examples/JugFilling.py
4,503
3.8125
4
class jug: def __init__(self, size): self.size = size self.volume = 0 self.waste = 0 def empty(self): self.waste = self.waste + self.volume self.volume = 0 def fill(self): self.volume = self.size def is_full(self): return self.volume == self....
862a9f2dae57fac22a76313003eb873e4626ddce
dbbudd/Python-Experiments
/Databases/03_Python-Populate_External_File.py
673
3.984375
4
import sqlite3, csv my_database = "cars.db" my_file = "data.txt" db = sqlite3.connect(my_database) db.row_factory = sqlite3.Row db.execute("DROP TABLE IF EXISTS Cars") db.execute("CREATE TABLE Cars(column_1 TEXT, column_2 TEXT, column_3 TEXT);") #open CSV file reader = csv.reader(open(my_file, 'r'), delimiter='|') ...
c9f1f0d7b0b9d038613acddb431edf858912e7c7
dbbudd/Python-Experiments
/Databases/Cars/insert_car_data.py
1,568
3.515625
4
#!/usr/bin/python print "Content-type: text/html" print #import the libraries import cgi import cgitb; cgitb.enable() import sqlite3 import sys form = cgi.FieldStorage() val_CarID = str(form.getvalue('car_id')) val_Make = str(form.getvalue('car_make')) val_Model = str(form.getvalue('car_model')) val_Value = str(form....
7db370195f994057a327082ae7f6dd7814496e7e
dbbudd/Python-Experiments
/Pokemon/PokeCGI/test_query.py
2,775
3.5
4
#!/usr/bin/env python import csv import sqlite3, sys, os from os import system import contextlib #create a database connection db = sqlite3.connect('pokemon.db') db.row_factory = sqlite3.Row def simple_select(): searchstr = "'%" + "C" + "%'" my_data = db.execute(""" SELECT * FROM Locat...
94d518d89abbcdab41f6354a1a9735568fc58399
dbbudd/Python-Experiments
/AI/EasyAI_examples/Mastermind1.py
2,729
4.21875
4
#!/usr/bin/env python #!/usr/bin/env python """Python Mastermind Program that tests your skills at the game Mastermind. """ import random instructions = """ === The Mastermind game === Object of the Game The computer picks a sequence of 4 pegs, each one being one of any of six colors. The object of the game is t...
6b53e8c4ad1a8612af62c2358ec8987e94278008
dbbudd/Python-Experiments
/AI/Regex/regex_examples.py
1,121
3.71875
4
#!/usr/bin/env python import re ''' text = open("sample.txt") for line in text: print(line) a = re.split('\W+', line) print(a) ''' ''' text = 'That wayward #OldMan of "Kilkenny"' lines = re.split('\W+', text) for word in lines: print(word) ''' ''' text = 'That wayward #OldMan of "Kilkenny"...
895b515ba467abb6be1edec84e47f97b079bf997
dbbudd/Python-Experiments
/Pokemon/OO Project/Archive/poke.py
367
3.5625
4
class Pokemon(object): def __init__(self, number, name, species, HP, attack): self.number = number self.name = name self.species = species self.HP = int(HP) self.attack = int(attack) my_pika = Pokemon('1', 'Daniel', 'Earth', 200, 100) print (my_pika.name) print(my_pika.HP)...
90793c9080556a63dc60e0471b9919dd9f97bf35
dbbudd/Python-Experiments
/AI/02_Visualising_Recursion/01Sierpinski_Triangle(with_Tkinker).py
663
3.59375
4
#!/usr/bin/env python from Tkinter import * import math def sierpinsky(canvas, x, y, size, level): x = float(x) y = float(y) if (level == 0): canvas.create_polygon(x, y, x+size, y, x+size/2, y-size*math.sqrt(3)/2, ...
100715cb38450e6e45cd8bc5cbc3469f7ae8aed1
dbbudd/Python-Experiments
/Databases/Eve Online/00 Raw Data/00_EVE-Create.py
2,454
3.65625
4
import sqlite3 import sys import csv #create a databease connection db = sqlite3.connect('eve.db') db.text_factory = str #DROP TABLES db.execute("DROP TABLE IF EXISTS Regions;") db.execute("DROP TABLE IF EXISTS Types;") db.execute("DROP TABLE IF EXISTS Transactions;") #CREATE TABLES db.execute("CREATE TABLE Regions...
25d4476c2ceacc8bc20c1184280a443e9d99fa00
dbbudd/Python-Experiments
/AI/Probability/backjack.py
1,475
3.625
4
import random class Dealer(): def __init__(self): self.cards = [1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,11,11,11,11,12,12,12,12,13,13,13,13] print(self.cards) def shuffleDeck(self): random.shuffle(self.cards) #print(self.cards) ...
e872d88a1d1bc63c46bc58feb946f7ceafc1e9df
KYBee/DataStructure
/assignment1/assignment01_01_polynomial_02.py
2,387
3.875
4
class polynomial(): def __init__(self, coef): self.coef = coef self.num = len(coef) def print_poly(self): for coef in self.coef: print(f"{coef[0]} {coef[1]}", end=" ") def substitute(self, x): result = 0 for c in self.coef: result += c[0]*x**...
fb2a71812725108222ec7247c2087e3c3081c43e
KYBee/DataStructure
/assignment4/assignment4_02.py
2,977
3.65625
4
import random import string class Node: def __init__(self, data, link=None): self.data = data self.num_link = link self.name_link = link class LinkedList: def __init__(self): #학번을 기준으로 하는 head -> num_head #이름을 기준으로 하는 head -> name_head self.__num_head = Node(Non...
33bd3a1cd2f33e627516e983a672d54af74bc8f2
KYBee/DataStructure
/assignment1/assignment01_01_polynomial_01.py
2,632
3.984375
4
class polynomial(): def __init__(self, coef): self.coef = coef self.degree = len(coef) - 1 def print_poly(self): for coef in self.coef: print(coef, end=" ") def substitute(self, x): result = 0 for i in range(self.degree+1): if not self.coef[i...
fe94e0f3f99cc7aa6df99c8ed993ced2a6b06cda
BStarcheus/algorithms
/graphs/breadthFirstSearch.py
2,291
3.9375
4
try: from .graph import * except: # Running file as __main__ from graph import * def breadthFirstSearch(graph, startNode, endNode, visual=False): """ Search the graph until you find the endNode using breadth first search. :param graph: Graph object to be searched for a path :param start...
90970f0c742577a14d4cf16d42e05b24f9110ec2
AllenWalkerD3/python-snake-game
/snake.py
1,952
3.5625
4
from turtle import Turtle, pos STARTING_POSITIONS = [(0,0), (-20, 0), (-40, 0)] MOVE_DISTANCE = 20 UP = 90 LEFT = 180 RIGHT = 0 DOWN = 270 class Snake: def __init__(self): self.segments = [] self.create_snake() self.head = self.segments[0] def create_snake(self): for positio...
b9d4d7b2191e42c57ce2100f2ca79696e33227ed
devindoherty/dust
/pytests.py
383
4.15625
4
# Python Learning Lessons some_var = int(input("Give me a number, any number: ")) if some_var > 10: print("The number is bigger than tenerooonie.") elif some_var < 10: print("The numbah is smaller than 10.") elif some_var == 10: ("YO. The numbah is TEN!") some_name = str(input("Hey, what's your name...
282e172e5fb9a33b9e191a7da936a83832a8ea99
Sravya0598/firstrepo
/subpgm.py
59
3.53125
4
#This is a Subtraction program a=5 b=2 res=a-b print(res)
8b7206d46407012cbf76fae9dc6b8294dbfad69a
justinclark-dev/CSC110
/code/Chapter-12/fibonacci.py
460
4.125
4
# This program uses recursion to print numbers # from the Fibonacci series. def main(): print('The first 10 numbers in the') print('Fibonacci series are:') for number in range(1, 11): print(fib(number)) # The fib function returns the nth number # in the Fibonacci series. def fib(n): if n ...
64c15c40e01c760b1ff558c027b556941dfcd4b3
justinclark-dev/CSC110
/code/Chapter-4/simple_loop2.py
180
4.5
4
# This program also demonstrates a simple for # loop that uses a list of numbers. print('I will display the odd numbers 1 through 9.') for num in [1, 3, 5, 7, 9]: print(num)
8199f930e624b3fff1407da55bb68b7b94265303
justinclark-dev/CSC110
/sample-programs/week2/circle.py
975
4.5625
5
# circle.py # Program to calculate area and circumference of a circle. # NOTE: we import the math module so we can use the built-in definition for pi. # The output section demonstrates formatting numbers for output; # notice how the format function performs appropriate rounding. # CSC 110 # 9/25/2011, updated 10/4/20...
70d689c1704d84da2b580c62c9ce96946ef0184d
justinclark-dev/CSC110
/code/Chapter-5/draw_circles.py
761
4.34375
4
import turtle def main(): turtle.hideturtle() circle(0, 0, 100, 'red') circle(-150, -75, 50, 'blue') circle(-200, 150, 75, 'green') # The circle function draws a circle. The x and y parameters # are the coordinates of the center point. The radius # parameter is the circle's radius. The color parameter...
4d670180768a15612fb0e713a9c84f91467ebc23
justinclark-dev/CSC110
/sample-programs/week7/sin_cos_solution.py
1,675
4.25
4
# sin_cos_solution2017.py # One possible solution for the trapezoid / sin_cos_squared lab exercise. # CSC 110 # Winter, 2017 import math # import statement needed for math.pi, math.sin() and math.cos() def main(): # Part 1a: print('\nPart 1a: The area shown on the table row is ' \ + format(area...
ed4fb135aa6b2ab48d911992a98c9a88c98df11d
justinclark-dev/CSC110
/code/Chapter-6/show_coffee_records.py
711
4.09375
4
# This program displays the records in the # coffee.txt file. def main(): # Open the coffee.txt file. coffee_file = open('coffee.txt', 'r') # Read the first record's description field. descr = coffee_file.readline() # Read the rest of the file. while descr != '': # Read the quantity f...
881d7d16bd126bd54adc97dd4fdc80f34bb758ff
justinclark-dev/CSC110
/sample-programs/week2/representational_error.py
2,519
4.25
4
# representational_error.py # # A demonstration of representational error # CSC 110 # Sp'12 message = """The sequence of Python statements in this file demonstrates that even very simple calculations, such as repeatedly adding 0.1 to a number, can result in very small errors in the result. This kind of error is no...
ec3ed0d9d053666f982aeb763eab95f7abc0ff93
justinclark-dev/CSC110
/code/Chapter-5/random_numbers.py
256
4.15625
4
# This program displays a random number # in the range of 1 through 10. import random def main(): # Get a random number. number = random.randint(1, 10) # Display the number. print('The number is', number) # Call the main function. main()
e67622cc50ed79eb5b7fd439f432c4b9735d6b8d
justinclark-dev/CSC110
/code/Chapter-3/sort_names.py
388
4.5
4
# This program compare strings with the < operator. # Get two names from the user. name1 = input('Enter a name (last name first): ') name2 = input('Enter another name (last name first): ') # Display the names in alphabetical order. print('Here are the names, listed alphabetically.') if name1 < name2: print(na...
0a32e1518187691f96b37671fa7937b5d4953f5b
justinclark-dev/CSC110
/code/Chapter-4/simple_loop3.py
142
4
4
# This program also demonstrates a simple for # loop that uses a list of strings. for name in ['Winken', 'Blinken', 'Nod']: print(name)
0e5bb675ace9199be4ead4f5fbf03e2dd78f226e
justinclark-dev/CSC110
/code/Chapter-5/hypotenuse.py
453
4.4375
4
# This program calculates the length of a right # triangle's hypotenuse. import math def main(): # Get the length of the triangle's two sides. a = float(input('Enter the length of side A: ')) b = float(input('Enter the length of side B: ')) # Calculate the length of the hypotenuse. c = math.hypot(...
b06222c64b5447729bc8f9e63bc381e0ff12c848
justinclark-dev/CSC110
/calculator-tips.py
794
3.828125
4
# CSC 110 - Practice Activity #2 # Tip Calculator # Section 03 # Justin Clark # 1/14/2020 # input billAmountEntered = float(input('Enter bill amount $: ')) tipPercentEntered = float(input('Enter tip %: ')) # processing tipCalculated = billAmountEntered * (tipPercentEntered / 100) amountToPay = billAmountEntered + tip...
9c924b4fec9a4cad771cb19b9c08e66fe91e14e5
justinclark-dev/CSC110
/code/Chapter-10/coin_argument.py
503
4.15625
4
# This program passes a Coin object as # an argument to a function. import coin # main function def main(): # Create a Coin object. my_coin = coin.Coin() # This will display 'Heads'. print(my_coin.get_sideup()) # Pass the object to the flip function. flip(my_coin) # This might display 'H...
681e9436c9a93e5ed352401bd181ea998dbbc2c2
justinclark-dev/CSC110
/assignments/assignment-2-pyramid.py
4,696
4.125
4
# CSC 110 - Assignment #2 # Pharaoh's Friend Construction! # Section 03 # Justin Clark # 1/15/2020 class Pyramid: # contants BLOCK_HEIGHT = 1.5 # meters BLOCK_WIDTH = 2 # meters BLOCK_LENGTH = 2.5 # meters BLOCK_WEIGHT = 15000 # kg # __init__ is Python's constructor method def __init__(s...
b4dcce09936d8277e06e00eccc9ce8ed71496e35
justinclark-dev/CSC110
/code/Chapter-2/string_input.py
219
4.34375
4
# Get the user's first name. first_name = input('Enter your first name: ') # Get the user's last name. last_name = input('Enter your last name: ') # Print a greeting to the user. print('Hello', first_name, last_name)
6f794c8062f50008c3836b0b4fd0f788f844ec62
justinclark-dev/CSC110
/Labs/class-examples-3.4.2020.py
2,907
3.859375
4
def sum2(arr): # returns the sum of all the numbers in the list arr # arr must contain only numbers total = 0 for x in arr: total += x return total def average_positive(arr): # returns the average of all the positive nubers in the arr # returns 0 if the list contain no positive n...
5d8491001d26d1e19ea2ad7dd55b2fe591dfd69f
justinclark-dev/CSC110
/code/Chapter-7/write_number_list.py
382
4.03125
4
# This program saves a list of numbers to a file. def main(): # Create a list of numbers. numbers = [1, 2, 3, 4, 5, 6, 7] # Open a file for writing. outfile = open('numberlist.txt', 'w') # Write the list to the file. for item in numbers: outfile.write(str(item) + '\n') # Close th...
c7013d7638fd00f2cb912f980e6072c4d730d3bf
justinclark-dev/CSC110
/code/Chapter-10/car.py
485
3.703125
4
# Car class class Car: def __init__(self, make, model, year): self.__make = make self.__model = model self.__year = year def set_make(self, make): self.__make = make def set_model(self, model): self.__model = model def set_year(self, year): self.__year ...
3c0421300920f0a4cad73d4433b93b4e6bd6e2de
justinclark-dev/CSC110
/code/Chapter-6/modify_coffee_records.py
1,960
4.4375
4
# This program allows the user to modify the quantity # in a record in the coffee.txt file. import os # Needed for the remove and rename functions def main(): # Create a bool variable to use as a flag. found = False # Get the search value and the new quantity. search = input('Enter a description to ...
624fffdc27b4ff779cb9a5037ff31edf588ebe1a
justinclark-dev/CSC110
/sample-programs/week3/blocks.py
305
3.640625
4
# function to print a block # illustrates modular decomposition # CSC 110 # Fall 2011 def main(): printBlock() def topBottom(): print('+ - - - - - +') def gaps(): print('| |') def printBlock(): topBottom() gaps() gaps() gaps() gaps() topBottom() main()
a7c1397b07bbcb2ee45c221f089e39526f836981
justinclark-dev/CSC110
/sample-programs/week4/sort_names.py
539
4.5625
5
# sort_names.py # # This program demonstrates how the < operator can # be used to compare strings. # from Tony Gaddis def main(): # Get two names from the user. name1 = input('Enter a name (last name first): ') name2 = input('Enter another name (last name first): ') # Display the names in alphabe...
42e5cb88c09528d1527241dbb28bdf5b5846651f
justinclark-dev/CSC110
/sample-programs/week2/Boxes.py
2,906
4.0625
4
# Boxes.py # Demonstration of Input/Processing/Output # Calculates some characteristics of a cardboard # box given user specifications. # Updated to change variable naming style. # CSC 110 # 2/2/13 # CONSTANTS -- information we already know CARDBOARD_COST_PER_SQUARE_METER = 1.25 # in dollars per sq. meter CA...
4146805a276701f7682d09357f1fbb17d9601418
justinclark-dev/CSC110
/lab-activity-3.py
1,054
4.28125
4
# CSC 110 - Lab Activity #3 # Simple Functions with Parameters # Section 03 # Justin Clark # 1/22/2020 # Part 1: # ============== # print(s, a, b, c) # output: apple 3 6 12 # output: banana 4 5 13 # output: cherry 6 3 15 # output: date 5 3 13 # output: elderberry 5 3 13 # output: fig 6 2 14 # output...
310e714493f57c69ee45f848374b9a6909a84328
justinclark-dev/CSC110
/Labs/class-examples-3.6.2020.py
517
4.125
4
alphabet = 'abcdefghijklmnopqrstuvwxyz' for letter in alphabet: print(letter, end=', ') original_string = 'abcdefghijklmnopqrstuvwxyz' # reverse order of string (short way) new_string = original_string[::-1] print(new_string) # reverse order of string (long way) for i in range(len(original_string)-1,-1,-1): ...
75a0bfe6189a61afdb89d6a28d78302b42e16eda
justinclark-dev/CSC110
/code/Chapter-4/spiral_circles.py
476
4.625
5
# This program draws a design using repeated circles. import turtle # Named constants NUM_CIRCLES = 36 # Number of circles to draw RADIUS = 100 # Radius of each circle ANGLE = 10 # Angle to turn ANIMATION_SPEED = 0 # Animation speed # Set the animation speed. turtle.speed(ANIMATION_SPEED) # Draw 3...
fcc3625ba4ce2cda956c0876949f1d467efc3604
justinclark-dev/CSC110
/for-loop_known-and-unknown-step.py
571
3.609375
4
def step_known(n_min, n_max, step): print('-'*25+'step_known():') n_max += 1 for i in range(n_min, n_max, step): print('\t',i) def step_unknown(n_min, n_max, rows): print('-'*25+'step_unknown():') n_max = 900000 n_min = 450000 rows = 10 step = (n_max - n_min) // (rows -...
84f5de15c0fcca0c3f79e2162e1596bfd611df65
justinclark-dev/CSC110
/code/Chapter-6/read_running_times.py
933
4.0625
4
# This program reads the values in the video_times.txt # file and calculates their total. def main(): # Open the video_times.txt file for reading. video_file = open('video_times.txt', 'r') # Initialize an accumulator to 0.0. total = 0.0 # Initialize a variable to keep count of the videos. cou...
b4e83529f04bc831ce02e89b28681a9b3e8e11dd
justinclark-dev/CSC110
/sample-programs/week7/read_numbers.py
779
4.15625
4
# read_numbers.py # # Sample program to read numbers from a file, count them and sum them. # Assumes each line in the file contains a valid number. # CSC 110 # Winter 2012 # open the file 'numbers.txt' for reading infile = open('numbers.txt', 'r') total = 0 # initialization count = 0 # initialization line = infile...
6b9b30272ef0b9e1741a6e182a9961500cecceca
justinclark-dev/CSC110
/code/Chapter-8/split_date.py
394
4.59375
5
# This program calls the split method, using the # '/' character as a separator. def main(): # Create a string with a date. date_string = '11/26/2012' # Split the date. date_list = date_string.split('/') # Display each piece of the date. print('Month:', date_list[0]) print('Day:', date_li...
887d47441759e233f45ddcc1bbf6d72fdd40a79b
justinclark-dev/CSC110
/code/Chapter-4/squares.py
319
4.21875
4
# This program uses a loop to display a # table showing the numbers 1 through 10 # and their squares. # Print the table headings. print('Number\tSquare') print('--------------') # Print the numbers 1 through 10 # and their squares. for number in range(1, 11): square = number**2 print(number, '\t', square)
b666fe641a21567a199fe85e5a9dda4716c8046a
justinclark-dev/CSC110
/sample-programs/week9/string_accumulator.py
387
3.984375
4
# string_accumulator.py # # This short program demonstrates the use # of a STRING ACCUMULATOR named 'result'. # CSC 110 # Winter 2018 colors = ['red', 'green', 'blue', 'purple'] result = 'The artist said...' # INITIALIZATION for word in colors: result += '\nI like the color ' + word + '!' # UPDATE result += '\n...
4fe77514b2b5d0047f8b96253e4ba18844151f90
justinclark-dev/CSC110
/code/Chapter-2/variable_demo4.py
276
4.0625
4
# This program demonstrates variable reassignment. # Assign a value to the dollars variable. dollars = 2.75 print('I have', dollars, 'in my account.') # Reassign dollars so it references # a different value. dollars = 99.95 print('But now I have', dollars, 'in my account!')
5d3c457e60aa3b822559fb150016c85506983d80
justinclark-dev/CSC110
/sample-programs/week6/rabbits_solution.py
552
3.828125
4
# rabbits_solution.py # Rabbits Lab -- One Possible Solution # CSC 110 # Fall 2011 pop = 190 # set the initial population value for year in range(1,11): # simulate the passage of 10 years if pop > 150: # if pop at beginning of the year is > 150... pop -= 100 # take awa...
83e162928cd05eeab5d65a4f885d8f640e805afd
justinclark-dev/CSC110
/code/Chapter-8/login.py
2,093
3.6875
4
# The get_login_name function accepts a first name, # last name, and ID number as arguments. It returns # a system login name. def get_login_name(first, last, idnumber): # Get the first three letters of the first name. # If the name is less than 3 characters, the # slice will return the entire first name. ...
954b2c33bbdeb0cf70fd552296095fc7f1153d93
Tammyqian/Python
/test/test1/feibonaqi.py
456
3.96875
4
# -*- coding:utf-8 -*- def fbnq(num): f = [0,1] for i in range(num): f.append(f[-1] + f[-2]) return f num = input('please input a num:') # print fbnq(num) fb = fbnq(num) def fbnq2(num): a, b = 0, 1 print a,'\n',b while b < num: a, b = b, a + b print b fbnq2(num) #斐波那契数列可以...
bd4f680c1b0c4a45d1afe01d6f4b8a9bfaf835f8
PietrzakJustyna/PythonSnake
/snake.py
5,362
3.546875
4
import pygame import random import ptext pygame.init() grey = (138, 147, 166) yellow = (255, 255, 102) black = (0, 0, 0) red = (213, 50, 80) green = (0, 255, 0) blue = (50, 153, 213) window_width = 400 window_height = 400 window = pygame.display.set_mode((window_width, window_height)) pygame.display.set_caption('Sn...
8a0a76bb8df53578f3c391bd0a149210ecb1dbbf
rds123/python_code_practice
/primenum.py
501
4.1875
4
def is_prime(num): for i in range(2, num): if (num % i) == 0: return False return True num = int(input("Enter a number: ")) check_prime = is_prime(num) if check_prime: print('Your number is a Prime') else: print('Your number is not a Prime') C:\Users\Rahul\PycharmPro...
77b939ffe2faeb8bf7a2838edfe969aecc25bd21
jiupeiz/nhk
/02.py
227
3.8125
4
#!/bin/python # -*- coding: utf-8 -*- str1 = u'パトカー' str2 = u'タクシー' str3 = u'' for a, b in zip(str1, str2): str3 = str3 + a +b print(str3) # envoloped print(''.join([a + b for a, b in zip(str1, str2)]))
089aa7cc40034ea68b754d39c7813ad55be5c37d
dbridgem/Breath-Baseline-Tracking
/baseline_tracker.py
1,540
3.5625
4
# -*- coding: utf-8 -*- """ Script to convert pressure values into flow rate by interpolating a baseline @author: devon """ import numpy as np import pandas as pd def Pythonbaselinetracker(pressure, calibration_factor): m = len(pressure) baseline = np.zeros(int(np.floor(m/600)))#Preallocate...
e537ff1290314a2a73a03c46ce7e8bb8dbda0dd8
jonathan-mothe/ListaDeExercicios
/estrutura_sequencial/ex005.py
187
4.28125
4
''' Faça um Programa que converta metros para centímetros. ''' metros = int(input('Digite um valor em metros: ')) print('O valor informado em centímetros é igual a:', metros * 100)
d6e4a3476bf2ec2c36200932ad85ade811a5bd5e
jonathan-mothe/ListaDeExercicios
/funcoes/ex007.py
557
3.703125
4
def valor_pagamento(valor, dias_atraso): if (valor < 0): return None if (dias_atraso > 0): multa = valor * 0.03 adicional_atraso = valor * (dias_atraso * 0.01) return valor + multa + adicional_atraso else: return valor # Entrada de Dados valor = 1 while (valor != 0)...
f8301ae6b21ee133fa7577fd1e496983706dd934
jonathan-mothe/ListaDeExercicios
/estrutura_sequencial/ex013.py
689
3.90625
4
''' Tendo como dado de entrada a altura (h) de uma pessoa, construa um algoritmo que calcule seu peso ideal, utilizando as seguintes fórmulas: Para homens: (72.7*h) - 58 Para mulheres: (62.1*h) - 44.7 ''' sexo = input('Informe seu sexo (M/F): ') altura = float(input('Informe sua altura: ')) peso = float(inpu...
3f9bd65c73111bff677c280204bf576ff2dcbb9b
zhangted/trees-graphs-python
/sorting.py
1,259
4.28125
4
#bubble sort def bubbleSort(array): #go left to right, switch values if left is < right #do repeatedly until no swaps made on 1 runthrough swapped = True while swapped == True: swaps = 0 for i in range(len(array)): if i+1 < len(array): if array[i] > array[i+1]: swap(i,i+1,array) swap...
5f2b7f206b5f64d7dbe4cdf36ebfd69d5f0dcbdb
LoisBN/python
/env/code/tme9.py
2,844
3.890625
4
#encoding:utf8 #tme9 #exercice 9.5 def est_lettre(c): """ str -> bool Hypothese : len(c) == 1 (caractere) Retourne True si le caractere c est une lettre, ou False sinon.""" return ((c >= 'a') and (c <= 'z')) \ or ((c >= 'A') and (c <= 'Z')) \ or (c in {'é', 'è', 'à', 'ù', 'œ'}) def chargement...
deac93c1e46df78b27380e541e43c12201aa4161
LoisBN/python
/env/code/exercice6-9.py
1,141
3.890625
4
#encoding:utf8 #Exercice 6.9 #Question 1 def jonction(L,c): """ list[str] * str -> str Hypothèse : len(c) = 1 retourne la chaîne composée de la jonction des chaîne de L séparées deux-à-deux par le caractère séparateur c. """ texte = "" for i in range(0, len(L)): if L[i] != L[l...
1110b1ae7fbe868d9048a75f4a8c957a0ff56b14
DiwakarDevapalan87/Python
/MIT_Exercise4.py
101
3.859375
4
end = int(input("end: ")) sum = 0 i = 1 while i <= end: sum += i i = i+1 print(sum)
666b5b0a2ed8fbf23bc2fa50933166ce30ace126
ChrisDesigns/terminal-clock
/app/utility.py
2,941
3.703125
4
# give a number # return the boolean value for each of nine position # side note, the 1st / 3rd bits are useless and will always be 0 def returnDisplay(number): boolArangement = { 1: [0,0,0, 0,0,1, 0,0,1], 2: [0,1,0, 0,1,1, 1,1,0], 3: [0,1,0, ...
12ce2f3be6eb72583f521c25783ac0447bfd7ec2
SophiaRodina/Labs
/laboratory1/RodinaS2.py
481
3.515625
4
import re print("Родина София, КМ-94. Завдання №1 - Написати програму-фільтр") n = list(input("Введіть значення з клавіатури: ")) while len(n) != 1: print("Ви повинні ввести один символ!") n = list(input("Введіть значення з клавіатури: ")) if bool(re.match('^[0-9]{1}$', (n[0]))): print("Ви ввели цифру") e...
15a6a0418c06476a18542dd5a57d9044ff619494
donnellan0007/python-projects
/crossword_solver/crossword_re.py
635
3.90625
4
def load_words(): with open('words.txt') as word_file: valid_words = set(word_file.read().split()) return valid_words def user_crossword(): user_input = input('> Put your crossword in here, letter by letter: ').split() looking_for = input('> What words are you looking for? (Separate with spac...
a03c2c8458ca6d988652c269d86ec706ad8b429a
vipulshah31120/PythonClassesByCM
/DailyClasses/01-03-2021/math_ex.py
348
3.59375
4
x = min(3, 98, 222, 10, 0, -3) print("Minimum value: ",x) y = max(3, 98, 222, 10, 0, -3) print("Maximum value: ", y) z = abs(-3.67) print(z) a = pow(67, 4) print(a) import math b = math.sqrt(9876) print(b) c = math.ceil(3.8) d = math.floor(3.8) e = math.floor(3.5) f = math.ceil(3.5) print(c) print(d) print(e) pri...
9fb3096befee18c9933c7febfa0a1cf1adb48bca
vipulshah31120/PythonClassesByCM
/DailyClasses/17-02-2021/class_ex.py
713
4
4
name = "CMPundhir" age = 12 print(type(name)) print(type(age)) # python is object oriented language # Almost everything in Python is an object, with its properties and methods. class Student: name = "Vipul" student1 = Student() student1.age = 20 print(student1.name) print(student1.age) # in python built-in funct...
ffc4ecf5ea7aa4ff185620c4e84982426beeb347
vipulshah31120/PythonClassesByCM
/DailyClasses/02-02-2021/lambda_ex.py
348
3.65625
4
def after10year(age): return age + 10 #tradional method vipulAge = after10year(20) print(vipulAge) cmAge = after10year(12) print(cmAge) abc = lambda age : age + 10 #Using lambda function vipulGf = abc(20) print(vipulGf) # we can pass multiple params as well in lambda expression sum = lambda a,...
514dbc55fd0b4b6b1b9767a56094b8ec3ca68bad
vipulshah31120/PythonClassesByCM
/DailyClasses/08-02-2021/module1.py
695
3.84375
4
# A module is a file containing Python definitions and statements. # The file name is the module name with the suffix .py appended. # Within a module, the module’s name (as a string) is available as the value of the global variable __name__. import module2 as m2 import module3 as m3 #import prime_checker as m4 print(_...
d177804a33ca4990f9aae45192a1cf698dc578c6
vipulshah31120/PythonClassesByCM
/Homework/04-02-2021/tuple.py
399
4.1875
4
#A tuple consists of a number of values separated by commas t = 12345, 6789, "vipul" print (t[0]) print (t[2]) t = (12345, 6789, "vipul") # Tuples may be nested: u = t, (1,2,3,4) print(u) # Tuples are immutable #t[0] = 55 print(t) #TypeError: 'tuple' object does not support item assignment # but they...
bf9b7279fb95436dbb1a5e7c8b34b4047b2aac0d
vipulshah31120/PythonClassesByCM
/DailyClasses/01-03-2021/practice1.py
537
3.765625
4
class Laptop : def __init__(self, name, price) : self.name = name self.price = price def show(self) : print("Laptop Name: ", self.name) print("Laptop price: ", self.price) l1 = Laptop("Lenovo", 45000) l1.show() class Laptop2(Laptop) : def __init__(self, name, price, color) : Laptop.__init__(self, name,...
fcc148f796072c2e27fd4c711a76f8cf18f37d7b
vipulshah31120/PythonClassesByCM
/DailyClasses/17-02-2021/class_ex2.py
636
3.78125
4
class Student: def __init__(self, name, age, subjects, stream, sports) : self.name = name self.age = age self.subjects = subjects self.stream = stream self.sports = sports def myself(self) : essay = f''' My name is {self.name}. My age is {self.age}. I study these {len(self.subjects)} subjects: {self...
334989e90ffc7bf7fd7754653af9592ed1ebcb1c
bgschiller/algorithms
/algorithms/structures/treaps.py
3,304
3.640625
4
import functools import random def identity(x): return x class Treap(object): def __init__(self, key=None, cmp=None, parent=None): self.elem = None self.parent = parent self.right = None self.left = None self.key = key if self.key is None: self.key =...
a46dffdf49372eaff1093ddb5feeb7b47b5a211b
dgapitts/classic-problems-python
/chap1-small-problems/Fibonacci/fib5_timeit.py
763
3.640625
4
import time def fib5(n: int) -> int: if n == 0: return n # special case last: int = 0 # initially set to fib(0) next: int = 1 # initially set to fib(1) for _ in range(1, n): last, next = next, last + next return next if __name__ == "__main__": start_time = time.time() print(fib5...
52e8e65efd1b764ff6417fe5c988ce572d5a8671
shwezinoo/python-excercises
/ex38.py
520
3.75
4
ten_things="Apple Orange Crows Telephone Light Sugar" print "Wait there's not 10thing in that list" stuff=ten_things.split(' ') more_stuff=["Day","Night","Song","Frisbee","Corn","Banana","Girl","Boy"] while len(stuff)!=10: next_one=more_stuff.pop() print "Adding :",next_one stuff.append(next_one) print ...
c91f58c7408b30a0dabec081672fbe939416e3a2
Ishan1717/CodingSchool
/calc.py
2,971
4.6875
5
#Overall function that when called actually executes the calculator. This calculator should display a list of options to the user: whether they want to add, multiply, divide, substract a set of numbers. Additionally, the user should have the options to exponentiate a number, take a number to an nth root, or quit the ca...
5ec203c5277ecc0d4ac8e8a28741963d63efc3c7
ezpher/data-structures-python
/dynamic_array.py
5,781
4.15625
4
'''using ctypes module raw array, for implementing dynamic array since list in python is already a dynamic array''' import ctypes class DynamicArray(): '''instantiating new array when class is created''' def __init__(self): self.length = 0 # size that user sees self._capacity = 1 # ac...
03a9b7d0fd4ddcf3726468d9f320b04e390a988f
joonhae97/computer_network_assignment
/assignment1/assignment1.py
652
3.921875
4
import sys def quick_sort(arr): if len(arr)>1: pivot = arr[len(arr)-1] left, mid, right = [],[],[] for i in range(len(arr)-1): if arr[i]<pivot: left.append(arr[i]) elif arr[i]>pivot: right.append(arr[i]) else: mid.append(arr[i]) mid.append(pivot) return quick_sort(left)+mid+quick_sort(r...
687bc8fdba2429e4ed47690a33551bddcbd552c1
artemigkh/ProjectEulerSolutions
/Problems 20-29/problem21-AmicableNumbers.py
573
3.5625
4
#https://projecteuler.net/problem=21 #in this problem some optimizations timewise are possible, such as storing the results #of divisors to not repeat calculations in memory, or adding both amicable number pairs #at once and then noting not to the second one but the range is so small it really #isn't necessary #it's ju...
f19825a8b53bc84ff3b8023a89ebc6061dfd542b
mrparkonline/python3_for
/solutions/for_factorial.py
152
4.25
4
num = int(input('Enter a value: ')) product = 1 for value in range(num, 0, -1): product *= value print('Factorial of',num,'is', product)
edda4b6fcbb545ca96ffe69bcd823f24ec8f98db
wppply/LeetCode-in-Python
/p61.py
1,322
3.9375
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def rotateLeft(self, head, k): """ :type head: ListNode :type k: int :rtype: ListNode """ if not head...
3441c4467f86b825f9c60ed04cf7a1ddce989126
wppply/LeetCode-in-Python
/p215.py
507
3.734375
4
import heapq class Solution(object): def findKthLargest(self, nums, k): """ :type nums: List[int] :type k: int :rtype: int """ nums = [-1*num for num in nums] heapq.heapify(nums) for i in range(k): temp = heapq.heappop(nums) return...
8145553f479ba1cab1520b6d203c945c4c2b9d16
julienmetivier/carreRouge
/helper.py
614
3.5625
4
import math class Helper(object): def getAngledPoint(angle,longueur,cx,cy): x = (math.cos(angle)*longueur)+cx y = (math.sin(angle)*longueur)+cy return (x,y) getAngledPoint = staticmethod(getAngledPoint) def calcAngle(x1,y1,x2,y2): dx = x2-x1 dy = y2-y1 ...
4dc46b4e53f3571f0a1678497590e84c4ba17b72
eporon/Snake
/ModGrafico.py
3,261
3.671875
4
''' MODULO UTILIZADO PARA LA CREACION DE MENUS EN CONSOLA ''' import curses from curses import KEY_RIGHT, KEY_LEFT, KEY_UP, KEY_DOWN, A_BOLD, A_UNDERLINE,textpad from random import randint menu = ['1. Play', '2. ScoreBoard', '3. User Selection', '4. Reports', '5. Bulk Loading', '6.Exit'] menuReport = ['1. Report of us...
703cc921a17b96dd65852b111b36e0caeefb33a5
arunnjoshi/Python
/Basic/stringMethod.py
170
3.84375
4
str="Python By mosh Crash course" print(str.capitalize()) print(str.upper()) print(str.lower()) print(str.replace('course','course for beginner')) print('Python' in str)