blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
e88423071849746b980bc26b02d4c1d706085766
jaimevepe/jaimevepe
/Python/functions/return functions/cylinderArea.py
475
4.15625
4
""" This program calculates the area of a cylinder. Using a function with a Return Fill in the missing line for the calculation. The formula is 4r2. """ PI = 3.14159265358979 # global constant def cylinder_area(rad): return 4*PI*rad**2 # use value of global constant PI def main(): radius = float(in...
c662059759659adaf9037af1dfd41b0a78aa7931
jaimevepe/jaimevepe
/Python/functions/areaCylinder.py
380
4.25
4
""" This program calculates the area of a cylinder. Fill in the missing line for the calculation. The formula is 4r2. """ PI = 3.14159265358979 # global constant def cylinder_area(rad): area = 4*PI*rad**2 print('The cylinder area is', format(area,'.2f')) def main(): radius = float(input('Enter th...
70f285522dc8be944e10c755c97a3e96a9b46093
Hared998/PSI
/Mikowski/Mikowski_WdP01/Mikowski_cw3_WdP01.py
630
3.90625
4
print('%s %s' %('one', 'two')) print('{} {}'.format('one', 'two')) ################################## print("\n") class Data(object): def __str__(self): return 'str' def __repr__(self): return 'repr' print('%s %r' % (Data(), Data())) print('{0!s} {0!r}'.format(Data())) #################...
3c9e2c5c4ae1271040c63e7ae241f1d0863691d1
sucyella/ThinkPython
/ch04-case_study-interface_design_refactored.py
2,754
4.625
5
import turtle import math # refactor circle_v2() and arc() to use polyline() instead of polygon() # ignore polygon() and circle(), created just for testing # cleaned up the function interfaces by basing the value of n depending on the circle's circumference # .. where value of n is not manually entered # after arc is ...
0c251869fe3d26807d4894a1894061008045c072
rubenbarroso/challenges
/searchascendingmatrix.py
2,465
4.03125
4
# coding=utf-8 """ From http://programmingpraxis.com/2012/02/10/search-in-an-ascending-matrix/ Search In An Ascending Matrix February 10, 2012 Today’s exercise is taken from our inexhaustible list of interview questions: Given an m by n matrix of integers with each row and column in ascending order, search the matri...
61415de757b040d0e2ade75e18513103509796d9
samech-git/Scripts
/Membrane/water_leakage.py
2,984
3.59375
4
# Author: Samuel Genheden, samuel.genheden@gmail.com """ Program to calculate how many water molecules are leaking into the membrane """ import argparse import math import numpy as np from sgenlib import parsing from sgenlib import mol def _count_water_inside(dens1, dens2, fi, li, fx, lx) : return sum(dens1[...
f988f5f2396b852f7ee8ba989d41fa11f85c4bed
melitadsouza/LeetCode
/PalindromeNumber.py
335
3.671875
4
class Solution: def isPalindrome(self, x): """ :type x: int :rtype: bool """ if x < 0: return False num = x result = 0 while x: result = result*10 + x%10 x = x//10 return True if result == num else ...
9644f6e428ebffb95c3d612d966dea341d4a73f9
BetoSkey/Ejercicios-de-Cursos
/Estadistica Computacional con Python/tirar_dados.py
1,363
3.703125
4
import random def tirar_dado(): resultado_tiro = random.randint(1, 6) return resultado_tiro def secuencias_tiros(dados, tiros, secuencias): secuencias_tiros = [] for i in range(secuencias): listado_tiros = [] for i in range(tiros): for k in range(dados): ...
1887c73d2ac3137c9f8c273df96a7143ebb8318c
saveyak/lede_homework
/other_homework/homework-3-part2-lurye.py
2,449
4.1875
4
#Sharon Lurye #6/17/21 #Homework 3, Part 2 import requests key = "7c5bbdc48b25448b9bb141540211706" #What is the URL to the documentation? #https://www.weatherapi.com/docs/ # Make a request for the current weather where you are born, or somewhere you've lived. ridgewood_weather = requests.get("http://api.weatherap...
7fd188b97f3df26ef5bc88eed915a0d042437cc6
kondratyev-nv/training
/python/src/find_majority_element.py
1,006
4.15625
4
""" Given a sequence of elements a_1, a_2, ... , a_n, you would like to check whether it contains an element (majority element) that appears more than n/2 times. """ def find_majority_element(values): """ Returns the majority element or None if no such element found """ def find_candidate(): ...
2a16c84faa110721d56deca7974fc47dd559521d
kondratyev-nv/training
/python/src/unbounded_knapsack.py
955
4.03125
4
class Item: def __init__(self, v, w): self.value = v self.weight = w def knapsack(items, weight_limit): """ Given a knapsack weight W and a set of n items with certain value val_i and weight wt_i, we need to calculate minimum amount that could make up this quantity exactly. This ...
49e63795b40b25c0c8c038d6e3ab779808b03024
kondratyev-nv/training
/python/src/evaluate_reverse_polish_notation.py
1,439
4.5
4
""" Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression. """ def evaluate_reverse_polish_notation(tokens): """ Returns the result of evaluation of an arithmetic expression in Reverse Polish Notation ...
2bedf069fa128f3c78370be54140eea86000e283
kondratyev-nv/training
/python/src/count_possible_astronaut_pairs.py
1,829
4.125
4
""" The member states of the UN are planning to send two people to the Moon. But there is a problem. In line with their principles of global unity, they want to pair astronauts of two different countries. There are N trained astronauts numbered from 0 to N - 1. But those in charge of the mission did not receive info...
90b53b41dbcf659c93d4f876ac404d9011c005bc
kondratyev-nv/training
/python/src/is_word_pattern.py
1,201
4.4375
4
def is_word_pattern(pattern, sentence): """ Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str. Examples: - pattern = "abba", str = "dog cat cat dog" should re...
e9d0a0f7fca8e611c2a494fa9e9c218a01a560c6
kondratyev-nv/training
/python/src/get_recursive_digit_sum.py
964
4.3125
4
""" We define super digit of an integer x using the following rules: - If x has only 1 digit, then its super digit is x. - Otherwise, the super digit of x is equal to the super digit of the digit-sum of x. Here, digit-sum of a number is defined as the sum of its digits. You are given two numbers n and k. You have t...
dde5b692d6a1399ac75d4462e98f81487710d598
guptaraghav01/100DaysOfCode
/day4/rockPaperScissors.py
1,326
4.21875
4
import random rock = ''' _______ ---' ____) (_____) (_____) (____) ---.__(___) ''' paper = ''' _______ ---' ____)____ ______) _______) _______) ---.__________) ''' scissors = ''' _______ ---' ____)____ ______) __________) (____) ...
72cc155f14c7fe48a5e24d7e4af22baea5969e22
guptaraghav01/100DaysOfCode
/day_32/birthday_wisher/main.py
2,094
3.671875
4
from datetime import datetime import pandas as pd import random import smtplib MY_EMAIL = "example_mail@gmail.com" MY_PASSWORD = "password123" today = datetime.now() today_tuple = (today.month, today.day) data = pd.read_csv("birthdays.csv") birthdays_dict = {(data_row["month"], data_row["day"]): data_row for (index,...
dc85d5576691e52ccf3c3d55658c33f5cfc87112
guptaraghav01/100DaysOfCode
/day2/tipCalculator.py
659
4.40625
4
print("Welcome to the tip calculator!") bill = float(input("What was your total bill? $")) tip = int(input("What percent tip would you like to give? ")) num_people = int(input("How many people will split the bill? ")) tip_as_percent = tip/100 total_tip_amount = bill*tip_as_percent total_bill = bill + total_tip_amount...
17fc23bf02a592592fa71c47b37704d987d8866c
Aaron-T-T/connectfour
/board.py
3,547
3.78125
4
# docstrings class Board: def __init__(self, width, height): self.width = width self.height = height self.board = [[" "] * width for i in range(height)] def disp_board(self): topString = "" countString = "" for i in range(len(self.board[0])*2): ...
c7019551e038cf296df1eef023030436fb979e73
Iris-0829/LunarBlocks
/components/Draggable.py
1,686
3.765625
4
import pygame from typing import Tuple class Draggable: def in_range(self, mouse_loc): """ Checks if the mouse is currently on top of the object. :param mouse_loc: (x, y) coordinate of the cursor's location. """ return (self.loc[0] <= mouse_loc[0] <= self.loc[0] + self.dim...
432fa628d5747dd1d5207b52cc5bfd61f772d933
tikistuna/Project-Euler
/Euler28.py
1,481
4.03125
4
def make_spiral_square(side_length): #Assumes square is odd, else there is no unique center element n = side_length square = [[0 for i in range(n)] for j in range(n)] i = j = (n + 1)/2 square[i][j] = 1 dictionary = {'direction': 'right', 'i': i, 'j': j} #Need to append elements 2 thru n^2 ...
ff6e2e63980e41fd6b4d654c7ad8beb8f491b051
AhmadMamduhh/Data-Mining-Project
/clustering.py
2,002
4.125
4
class Clustering: """ This class applies the K-Means algorithm on the iris dataset to group similar species together """ def __init__(self, clustering_name): self.clustering_name = clustering_name def cluster(self, X_train, X_test, number_clusters): """ This method trains the model and cl...
97893a92c50fb0725d7e73929551d7856afd4296
googleliyang/python_simple_demo
/iterable_iterator.py
1,681
3.84375
4
# before write coroutine code, begin with iterable .. from advanced python of middle part # iterable object: a object that provide __iter__ magic method # iterator object: a object that provide __iter__ & __next__ magic method # iter method will call iterable __iter__, next method will call iterator __next__ # for ite...
647a24703510422ca527ad31eafc56a97a720db7
gmanasi13/L3Cube
/Assignment2/birthday_paradox.py
2,911
4.5625
5
#Author: AIM #L3Cube Assignment No: 2 #Problem Statement: Write a code that verifies - birthday paradox is indeed correct. #The program calculates the birthday paradox by the standard formula and also #by finding the duplicates in the list of birthdays. It then plots a graph for both #the methods for comparison. It...
ae5824569f08fa76c85b01cc8471509d4f3b3069
andrewcking/TwinNet-Pytorch
/helper.py
327
3.609375
4
""" HELPER FUNCTIONS """ def get_n_params(model): """ Get the number of parameters in model :param model: pytorch model :return: number of parameters """ pp = 0 for p in list(model.parameters()): nn = 1 for s in list(p.size()): nn = nn * s pp += nn ret...
5b56951330936bc60454f5d1d0e4f5f5a0798f25
adityasanghi96/movie-trailer-website
/media.py
1,090
3.703125
4
import webbrowser class Movie(): """This class provides a way to store movie related information""" VALID_RATINGS = ["G", "PG", "PG-13", "R"] # Attributes shared by all Movies def __init__(self, movie_title, movie_storyline, poster_image, trailer_youtube): # noqa """This method cr...
249c8d2d89dad3a15160d53bb8dc870c1aa80015
jakobjerickson/CryptoPals
/q3.py
4,246
3.640625
4
# -*- coding: utf-8 -*- """ Created on Tue Jul 7 11:20:32 2015 @author: jakoberickson """ from crypto_utils import hex_to_binary """ The hex encoded string: 1b37373331363f78151b7f2b783431333d78397828372d363c78373e783a393b3736 ... has been XOR'd against a single character. Find the key, decrypt the message. You ca...
c06c8e0bc81bcce8e9ef6520ce885d7bd15a4b1a
BrandonBigham/Python
/Intro_python/OOP/oop_intro.py
735
3.8125
4
class User: def __init__(self, userName): self.name = userName class Dog: def __init__(self, name, ownerName): #TOY ATTRIBUTES GO HERE (inside_init_function) print("_init_function has run!") self.name = name self.owner = User(ownerName) def bark(self): print...
c2ba50a15b2522fe60ee87f841d6b92f99066336
BrandonBigham/Python
/Intro_python/OOP/user_with_accounts.py
1,485
3.859375
4
class bankaccount: def __init__(self, int_rate, balance): self.interest_rate = int_rate self.account_balance = balance def deposit(self, amount): self.account_balance = self.account_balance + amount return self def withdrawal(self, amount): self.account_balance -= amo...
bf46ec8bdd07712f8704cb3c7ef758cf2663ef70
maxxb/cs373-collatz
/SphereCollatz.py
2,415
3.765625
4
#!/usr/bin/env python import sys # ------------ # collatz_read # ------------ memorized_cycles = [0]*1000000 def collatz_read (r) : """ r is a reader returns an generator that iterates over a sequence of lists of ints of length 2 for s in r : l = s.split() b = int(l[0]) e = i...
cce6653178ada2f807529729599fef26eae4dc70
bsjulien/Simple-Python-Projects
/Money Mgt Simple project/test_customer.py
1,347
3.703125
4
import unittest from customer import Customer # initializing the customer account information class Testcustomer(unittest.TestCase): # testing if the function c_transfer returns the right things when the password is not right # or when the amount inputted is greater than the balance def test_c_transfe...
9b86a1ae7f9aebf19af925d8c117732db7c8116b
bsjulien/Simple-Python-Projects
/Money Mgt Simple project/business.py
1,662
4.03125
4
from account import Account # defining Business class class Business(Account): """This class is a child class that inherits the characteristics from the main clas s account. the difference is that in this account all the transactions are free""" pass # defining transfer method def b_transf...
80f57e8e5c2bb1c96eb21ac180d1ce66b6523ff4
K1uV/Lection-14
/lekcuya_14_task_1.py
195
3.515625
4
def decorator(func): def wrapper(): print('l = 4 + 5') func() return wrapper @decorator def add(x = 4, y = 5): l = x + y print(l) adds = decorator(add) add()
3ec44bef5782cffb4746bb659fc26dac68a808b1
TomVS/adventofcode2017
/day1/sum.py
720
3.953125
4
def doubleSum(val): total = 0 for i,v in enumerate(val): if val[i-1] == v: # same! total += int(v) return total def halfwaySum(val): total = 0 offset = len(val)/2 for i,v in enumerate(val): if val[(i+offset)%len(val)] == v: total += int(v) ...
8762c41b337ff5ce6ad7785a129db2a7f302346e
Mounicask/Leetcode-problems
/Remove Nth Node From End of List.py
714
3.75
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode: if head is None: return None dummy = ListNode(0)...
25dbdaf9bc5bd3bae54fec69edea30848644d82d
yezhengli-Mr9/ExtremeNet
/queue_test.py
422
3.84375
4
import queue # From class queue, Queue is # created as an object Now L # is Queue of a maximum # capacity of 20 L = queue.Queue(maxsize=20) # Data is inserted into Queue # using put() Data is inserted # at the end L.put(5) L.put(9) L.put(1) L.put(7) # get() takes data out from # the Queue from t...
7b2f7b0985ab27667992b14b86226a0ce2df12e9
ThoPeumasschel/MyProjects
/MyPythonProjects/HelloTkInter.py
339
3.703125
4
# Example (Hello, World): import tkinter as tk tk = tkinter.tk() frame = tkinter.Frame(tk, relief="ridge", borderwidth=2) frame.pack(fill="both", expand=1) label = tkinter.Label(frame, text="Hallo Tkinter-Welt!") label, pack(expand=1) button = tkinter.Button(frame,text="OK",command=tk.destroy) button.pack(side="botto...
da27f7a688ac0911772f876182f26c551c1669ba
Newton-Duarte/python-alura
/advinhacao.py
1,270
3.828125
4
import random def jogar(): print('*********************************') print('*Bem vindo ao jogo da Advinhação*') print('*********************************') tentativas = 0 numero_secreto = random.randrange(1, 11) pontos = 1000 print('Qual nível de dificuldade?') print('(1) Fácil (2) M...
8e5ecc63e1e27e81320484778ec68ee29b8888a6
putrii99/Kelas_PBO
/aktifitas5.py
89
3.828125
4
x = int(input("masukan tinggi: ")) y= 1 while (y<=x): print("*" *(y)) y=y+1
5530e4e9f7093f9082762d0116b0a55cfac6719c
jagruthnath/MSIT_CT
/CT/L2P4.py
178
3.828125
4
a=int(input("Enter a : ")) b=int(input("Enter b : ")) if a>b: big=a else: big=b flag=0 while flag==0: if big%a==0 and big%b==0: flag=1 else: big+=1 print(big)
b4f1ba78e426b1f154234ddcb97abf4ed1d3c39a
jagruthnath/MSIT_CT
/CT/L1P6.py
160
3.625
4
n=int(input("Enter n : ")) i=2 j=1 f=[] f.append(1) print("Factors of ",n," are") while i<=n/2: if n%i==0: f.append(i) i+=1 f.append(n) print (f)
9eda76f1774c05fe6c8a6d4c76c49b4def2a6db4
ziemowit141/GeneticAlgorithm
/main.py
3,046
3.5
4
from Point import PositivePoint, NegativePoint, get_x, get_y import matplotlib.pyplot as plt from Function import Function from DriverCode import algorithm, NUMBER_OF_POINTS import numpy as np def generate_points(): points_list = [] positive_points_list = [] negative_points_list = [] for _ ...
360890fa16aca37f0d1dfc896d30df17920743ec
jhhj424/Python
/exam8.py
505
3.5625
4
''' Created on 2018. 12. 18. exam8.py : 문자를 '(내용)' 형태로 입력받기로 함. ( ) 입력을 안하면 ( )추가하기 startswith, endswith 함수 이용하기 @author: a ''' while True : s = str(input("문자입력하셈")) if s.startswith("(") & s.endswith(")") : print(s) elif s.startswith("(") : print("%s)" % s) elif s.endswit...
d8e6b969a4491edcb3bf2840debb8a347dca91be
jhhj424/Python
/181219/listex2.py
580
4.09375
4
''' Created on 2018. 12. 19. @author: a listex2.py : 컴프리헨션 ''' #1부터 5까지 값을 저장 mylist = [] for i in range(1,6) : mylist.append(i) print(mylist) #컴프리헨션 형태로 구현하기 mylist = [num for num in range(1,6)] print(mylist) #1부터 100까지 숫자 중 3의 배수만 저장하는 리스트 mylist = [] for i in range(1,101) : if i%3 =...
44e3cea33cb738cbf855c7a5c248b31b6a588372
jhhj424/Python
/181224/dbex2.py
784
3.546875
4
''' Created on 2018. 12. 24. @author: a dbex2.py : sqlite db 사용하기 ''' import sqlite3 con,cur = None,None data1,data2,data3,data4 = "","","","" con = sqlite3.connect("iddb")#db와 연결 객체 cur = con.cursor() #db에 sql 구문 실행 #cur.executescript(''' # create table usertable (id char(4) primary key, #...
85a882b923983c452128fb76ab9294df79e0d7b2
m-zetina/English_Exercises
/Practice.py
4,157
3.65625
4
import random from file_editor import unserialize_data as unserialize print("\n\n") print("\nWelcome to your daily English Exercises, Jimena!") print("You will find review verbs and sentences here to complete.") print("How this will work: Verbs and sentences, written in Spanish, will appear on the screen.") print("Y...
d5d27ab2b7f1da6bd6982c3edde6080d5c6c08f9
officialtech/PYTHON
/if | examples/atm.py
938
3.640625
4
from firebase.firebase import FirebaseApplication fb = FirebaseApplication("https://officialtech-team.firebaseio.com/") ask_pin = int(input("PIN no:")) c_pin = 4343 total_amount = 20000.0 if ask_pin == c_pin: print("Welcome to Bank") amount = int(input("Amount :")) if amount % 100 == 0: ...
a57f4498092f6cf0094d1feec0403f69cdd59e76
officialtech/PYTHON
/if | examples/double_same_sum.py
213
4.03125
4
def double_same_sum(n1, n2): if n1 == n2: return ((n1+n2)*2) return n1+n2 n1 = int(input("Number: \n")) n2 = int(input("Number: \n")) print(15*"-") print(double_same_sum(n1, n2))
3288efda4f196b17f88c5fc5f3d0bd5bf916adc7
officialtech/PYTHON
/Jupyter Notebook/lab9q1/lab9q1.py
1,517
4.25
4
#!/usr/bin/env python # coding: utf-8 # # Understanding Inheritance in Python # <img style="float: left "src="inheritance.png"> # In[71]: class Person: print("Person") def __init__(self, name, age): self.name = name self.age = age print(self.name, "is", self.age) d...
b4bd61d2be2f58112f74437bce8decbb386c58b4
officialtech/PYTHON
/for_loop/biggest_bigger.py
874
4.21875
4
# Thank-you big_number = 0 next_number = 0 for x in range(10): number = int(input("Number: ")) if number > big_number: next_number = big_number big_number = number else: if number > next_number: next_number = number print("Biggest Number: ", big_numb...
0462beca67cfa80fefe8c1481074f680849d7f7f
officialtech/PYTHON
/if | examples/positive_negative.py
643
4.5
4
""" Given 2 int values, return True if one is negative and one is positive. Except if the parameter "negative" is True, then return True only if both are negative. pos_neg(1, -1, False) → True pos_neg(-1, 1, False) → True pos_neg(-4, -5, True) → True """ def positive_negative(int1, int2, negative...
a1da31ffc8103a8b724b2dcce9c1da83e2b8962c
officialtech/PYTHON
/arguments | python.py
2,432
4
4
********************************************* Arguments **************************************** # The variables which are declared inside the function header are called arguments. # The scope of argument is from the function starting to function ending. Syntax:- def_keyword function_name(variable1,variable2,...va...
3aa6d5fefc03c335a4a95fce8c2f10418f846b5f
AkshitaJain0391/Python-Basics
/StockMarketMaxProfit.py
861
3.59375
4
#Stock Market Maximum Profit def stockPicker(shareValue): tempArray=[] for i in range(len(shareValue)-1): diff = shareValue[i+1] - shareValue[i] if (diff > 0): tempArray.append(shareValue[i]) tempArray.append(shareValue[i+1]) print(tempArray) if max(tempArray) - m...
663749cca0ff7c88034a4732b871cd2eed73f8db
AdityaNarayanan851996/CodingProblems
/CTCI/2.1.py
819
3.921875
4
# Q) 2.1: Write code to remove duplicates from an unsorted linked list. #code # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def deleteDuplicates(self, head): """ :type ...
881677e4c7d1adcd1b91474f084a4ae1a88b07cd
AdityaNarayanan851996/CodingProblems
/CTCI/2.5.py
1,555
4.0625
4
# Q) 2.5: Given a circular linked list, implement an algorithm which returns node at the beginning of the loop. #DEFINITION #Circular linked list: A (corrupt) linked list in which a node’s next pointer points to an earlier node, so as to make a loop in the linked list. #EXAMPLE #input: A -> B -> C -> D -> E -> C [t...
50555fbbea5732bec1c43aa80777f7412be5e2b4
HMkrtich/Dots-And-Boxes
/Board.py
5,153
3.8125
4
from collections import deque from Box import * class Board: def __init__(self, _m, _n): self.playerScore = 0 self.aiScore = 0 self.m = _m self.n = _n self.boxes = self.generateBoxes(_m, _n) self.openVectors = self.generateVectors(_m, _n) self.connectedVecto...
318f9415bed131366d12e488ad6bdee879136aef
turtleship69/hacktoberfest2021-1
/Python/Projects/JsonPPrinter/JsonPPrinter.py
933
3.625
4
import json import pprint import sys from urllib.request import urlopen import argparse parser = argparse.ArgumentParser(description='Pretty print a local json file or json file from the internet') parser.add_argument("Type", help="Either URL or file, choose whether you want to open a remote or local file") parser.add...
8ce23982b91ea3734c21a7a8e003a3c61b8bbd3f
ykuzin/amis_python
/task1.py
1,110
4.21875
4
""" Умова: Напишіть програму, яка отримує три числа і друкує їх суму. Кожне число користувач вводить у окремому рядку. Вхідні дані: 3 дійсних числа. Кожне число користувач вводить в окремому рядку. Вихідні дані: вивести суму трьох чисел на екран. """ #В программі користувач вводить 3 числа ,після чого виводить на ...
8081afce917d7305847d937cd0dad1b4d322000b
momentum-cohort-2019-02/w3d3-oo-pig-aaronsellek
/pigs.py
1,211
3.984375
4
import random # create computer class # create computer # make it so computer rolls die returning number 1-6 # continue rolling unless 1 is rolled or player chooses to "hold" # if one is rolled no points are awarded # dont hold unless it gets 20 points or more # trying to get total of 100 points # create human class #...
b33f93a0fe0c4cab0bb46edc896812b20c5e4875
bradwinters/Chromosomes
/gs.py
3,278
3.796875
4
import sys def NiceList(pList): OutString="(" for e in range(1,len(pList)): OutString+=pList[e]+" " #preO=OutString[:len(OutString)-1] preO=OutString[:-1] preO+=")" return preO def isSorted(pk,aList): ''' Assume its sorted, look for out of order elements and note them ...
55a37931d322cd88caa84fcd16b8a99279a2f251
he-mans/data_structures
/graphs.py
963
3.84375
4
class graph: def __init__(self): self.nodes = [] def add_node(self,new_node): if type(new_node)!= node: raise TypeError("only node type is allowed") self.nodes.append(new_node) def get_status(self): print(f"total nodes in graph -> {len(self.nodes)}") print("connection status :") for nodes in self.no...
504977e0da272ac3717d3853a96e81a7ba9dd134
paperboycreates/sorting-algorithms
/Counting_Sort.py
1,143
3.953125
4
# ==================================================================== # # File Name: Counting_Sort.py # Authors: Jacob Sheets & Jake Allinson # Date Created: 10 Sept 2019 # Version: 0.0.1 # Copyright: Copyright 2019, Sorting_Algorthims # Course: CS3410 Cedarville University # Description: Counting Sort Algorthim # =...
c69cb9f604a345495a4d369be081f59086c6d23a
alexander-cheung/ai
/assignment0/degrees/util.py
1,680
3.609375
4
class Node(): def __init__(self, actor, parent, movie): # current actor id self.actor = actor # what actor they did the movie with (parent) self.parent = parent # the movie they were in self.movie = movie class StackFrontier(): def __init__(self): self.f...
b3e35924a26d00ba804fbc36f80e8b7e01881942
kintneda/ev3dev-curriculum
/projects/mehrinka/project_2.py
6,095
4.0625
4
"""This is the final project for CSSE120, Introduction to Software Development. For this project, the robot can be driven using keystrokes on the computer. When the up button on the ev3 is pressed, the robot sends back the color sensed by the color sensor to the computer. The pc then interprets the data and prints an i...
e4560a186375d4affe471f57e4cc2c744d843fa3
wandersomMv/Algoritmos
/PSO/Fitness.py
757
3.90625
4
import City class Fitness: def __init__(self, route): self.route = route def route_distance(self): """ Função que retorna a distancia de uma rota""" #passar por todas as cidades e calcular o tamanho way_distance = 0 for i in range(0,len(self.route)): ...
e2610a6ce0ac32fe0a447fdab92e67f6371b0c7c
talitagiovanna/listas-IP
/Doação.py
96
3.515625
4
P = int(input()) Qtdedispensada = P%3 QtdeVila = int(P//3) print(QtdeVila) print(Qtdedispensada)
e4031a61beb4e10474cec7093d0cc236a079b72d
talitagiovanna/listas-IP
/20.2L3Q7 - Corrida dos Magos.py
1,776
3.6875
4
#lista com nomes de acordo com suas posições posicao = [] #loop para adicionar os nomes dos 14 magos de acordo com suas posições for i in range(14): posicao.append(input()) #guardando o mago que ficou em primeiro no ínicio da corrida primeiro = [posicao[0]] #números de ações de cada jogador N = int(input()) #nome ...
a2f1532545a1f2253c74add32ea07ff69770f933
talitagiovanna/listas-IP
/20.2L2Q8 - Invasão Skrull.py
1,106
3.84375
4
meta_de_infiltrados = int(input()) quantidade_skrulls = int(input()) numero_acontecimentos = int(input()) nivel_de_alerta = 0 for i in range(numero_acontecimentos): acontecimento = input() if acontecimento == "Substituicao": novos_infiltrados = int(input()) quantidade_skrulls += novos_infiltra...
c198a52067333a5d565c769c9d285bd8070f5cce
talitagiovanna/listas-IP
/20.2L2Q4 - Linhas Temporais.py
652
3.828125
4
X = int(input()) realidade_atual = 0 while True: try: y = int(input()) i = 1 for i in range(y + 1): realidade_atual += i except EOFError: if realidade_atual < X: print("Ainda nos falta um pouco...") elif realidade_atual == X: print("Fi...
32f4a13dbdf77f41dc3cae2c8e62733334113064
talitagiovanna/listas-IP
/20.2L2Q5 - Super espécies na galáxia.py
782
3.875
4
nome_especie = input() quantidade_1 = 0 while True: nome_1 = input() if nome_1 == "fim": break nome_2 = input() caracteristica_1 = input() caracteristica_2 = input() probabilidade_1 = int(input()) probabilidade_2 = int(input()) potencial_1 = int(input()) potencial_2 = int(...
0c02fef93dd847a4f07a86a848053b9a2c72a030
BjornChrisnach/Python_6hour_course
/Expert/contextManagers1.py
613
4.0625
4
# Contextmanagers # file = open("file.txt, "r") # try: # file.write("hello") # finally: # file.close() # with open("file.txt","r") as file: # file.write("hello") class File: def __init__(self, filename, method): self.file = open(filename, method) def __enter__(self): print("Enter") ...
281aabb0aff2aa01bc8a94297fa360c04b09685c
BjornChrisnach/Python_6hour_course
/read_files.py
230
3.765625
4
# read files file = open("file.txt", "r") f = file.readlines() newList = [] for line in f: newList.append(line.strip()) # newList.append(line[:-1]) # else: # newList.append(line) print(newList) file.close()
5be964b069506537585e50cbc04251d3e21b006c
BjornChrisnach/Python_6hour_course
/global_local.py
177
3.625
4
# global vs local var = 9 loop = True def func(x): global loop loop = 7 if x == 5: return newVar def otherFunc(): newVar = 5 func(2) print(loop)
4835c03f6e678668340cdb20e351fd0280cd9198
KatHewitt/KatHewitt.github.io
/Model_4.py
3,315
3.625
4
# -*- coding: utf-8 -*- """ Created on Tue Nov 6 14:03:03 2018 @author: gy18kah """ import random import operator import matplotlib.pyplot as plt import agentframework3 import csv import matplotlib.animation environment = [] with open('in.txt') as f: reader = csv.reader(f) for row in reade...
b5bce150014d17f309fcd3ce1fe4ceb02c0254ca
Neptune998/Codechef-Problems
/PSEUDO.py
88
3.609375
4
x=["b","a","c","d","b"] y=["b","d","c","b"] c=[] c.append(x) c.append(y) x1=[0] print(c)
fc42114a532a480a307fc5e1bf60b993f5bc2b4c
Neptune998/Codechef-Problems
/CLASS OBJECTS.py
351
3.546875
4
class Myfirstclass: def __init__(self, name, age,sex): self.name = name self.age = age self.sex=sex def myfunc(self): print("Hello man what is your name and age " + self.name,+ self.age, self.sex) print("your add and mobile no",+sec.add, sec.mob) p1 = Myfirstclass("G...
84f6376627882fcaa1e718025baef39ee90652c9
NatalieCole/Huffman
/Tree.py
2,774
4.03125
4
while len(letters) > 0: nodes.append(letters[0:2]) letters = letters[2:] nodes.sort() huffman_tree = [] huffman_tree.append(nodes) #recursivly combines base nodes to create the huffman tree and allocates either a 0 or 1 to each #pair of nodes prior to combinging which will be later used to createa ninary...
6d6f584bb1ecad9d961e7b6750a566dea8f142bc
CharlieMul/Platformer-Project
/RoomList.py
9,096
3.59375
4
import Rooms import Objects import pygame # RoomList stores the data for all of the rooms. STAGE1 = Rooms.roomList() # ROOMS are organized by... # 1. What is in the room # 2. The declaration of the room # These walls are used often, so they are here for easy reference. leftWall = Objects.Walls(0, 0, 80...
56732211d884f98bab538fb569390d693ac9aa1e
adheeshc/Graph-Theory
/Euler Circuit/euler_circuit.py
1,091
3.59375
4
import numpy as np import random def graph(num): return np.zeros((num,num)) num=6 graph=graph(num) graph[0,1]=1 graph[0,5]=1 graph[1,0]=1 graph[1,2]=1 graph[2,1]=1 graph[2,3]=1 graph[2,4]=1 graph[2,5]=1 graph[3,2]=1 graph[3,4]=1 graph[4,2]=1 graph[4,3]=1 graph[5,0]=1 graph[5,2]=1 #print(graph) def check_eule...
53854d4645710eb6e9eb053a86101ec0ad0158f6
quarkov/Receptions
/2.DiceProbability/dice_probability.py
756
3.796875
4
from math import factorial as f from scipy import product as p def probability(n, s, target): """ --------------------------------------------------------- n: int - number of dice s: int - number of sides of a dice target: int - target scores -----------------------------------------...
1a07ed1611ae74480b217b7db425b1c6a59918a7
Shubhampy-code/Let_us_C_book_solution_5th-Edition
/Chapter 3-The Loop Control Structure/let_us_c_3_(E_M).py
495
4.15625
4
""" The natural logarithm can be approximated by the following series. If x is input through the keyboard, write a program to calculate the sum of first seven terms of this series. """ valueOfX = float(input("Enter the value of x : ")) pow_of_x = 2 series = 0 while pow_of_x <= 7: series = series + (1/2)*pow(((valu...
b0a80455433e38895ac9823082bc5aa4a4fb06ea
Shubhampy-code/Let_us_C_book_solution_5th-Edition
/Chapter 2-The Decision Control Structure/let_us_c_2_(F_H).py
921
4.28125
4
"""In a company, worker efficiency is determined on the basis of the time required for a worker to complete a particular job. If the time taken by the worker is between 2 – 3 hours, then the worker is said to be highly efficient. If the time required by the worker is between 3 – 4 hours, then the worker is ordered to i...
66daf0335be898d79d35b5a0ac597d4bfff28c29
Shubhampy-code/Let_us_C_book_solution_5th-Edition
/Chapter 2-The Decision Control Structure/let_us_c_2_(F_F).py
1,491
4.46875
4
"""If the three sides of a triangle are entered through the keyboard, write a program to check whether the triangle is valid or not. The triangle is valid if the sum of two sides is greater than the largest of the three sides. """ side1 = float(input("Enter the first side of tringle : ")) side2 = float(input("Enter the...
d49e492f14fac6fb0575c81a433320e3af1371d7
Shubhampy-code/Let_us_C_book_solution_5th-Edition
/Chapter 2-The Decision Control Structure/let_us_c_2_(F_E).py
669
4.03125
4
"""A library charges a fine for every book returned late. For first 5 days the fine is 50 paise, for 6-10 days fine is one rupee and above 10 days fine is 5 rupees. If you return the book after 30 days your membership will be cancelled. Write a program to accept the number of days the member is late to return the book ...
46f1d1db55de064b5ae78054355a3608c25109f5
Shubhampy-code/Let_us_C_book_solution_5th-Edition
/Chapter 8-Arrays/let_us_c_8_(D_A).py
719
4.0625
4
"""Twenty-five numbers are entered from the keyboard into an array. The number to be searched is entered through the keyboard by the user. Write a program to find if the number to be searched is present in the array and if it is present, display the number of times it appears in the array.""" from array import* my_arra...
55dda304910308430ddbb252c98c2a305c01eec1
Shubhampy-code/Let_us_C_book_solution_5th-Edition
/Chapter 5-Functions & Pointers/let_us_c_5_(D_A).py
397
4.28125
4
"""Write a function to calculate the factorial value of any integer entered through the keyboard.""" def GetFactorial(num): i=num factorialVal = 1 while i >=1: factorialVal=factorialVal*i i -= 1 return factorialVal myNum = int(input("Get Number : ")) myFactorialValue = GetFactor...
3bfb7957761a74b1e90c23e0e6d2495ac2498d3e
Shubhampy-code/Let_us_C_book_solution_5th-Edition
/Chapter 1- Getting Started/let_us_c_1_(H_B).py
660
4.4375
4
distance_between_city = input("The distance between two cities (in km.):") dis = float(distance_between_city) in_meter = dis*1000 in_feet = dis*3280.84 in_inches = dis*39370.1 in_centimeter = dis*100000 print("The distance between two cities (in meter):" + str(in_meter)) print("The distance between two cities (in feet)...
448fc32ad5cc08d89a8826b597b31dc2164d1c20
Shubhampy-code/Let_us_C_book_solution_5th-Edition
/Chapter 3-The Loop Control Structure/let_us_c_3_(B_C).py
456
4.1875
4
"""Two numbers are entered through the keyboard. Write a program to find the value of one number raised to the power of another.""" """a = float(input("Enter number : ")) b = int(input("Enter number : ")) value = 1 i=1 while i <=b : value = value*a i=i+1 print(value) """ a = float(input("Write the ...
2ce0e9b3bfad46e925edd222bb9c3ea2d282a0a9
Nessa512/python
/Phyton/teste pra frescar.py
189
3.796875
4
A = str(input("Quer saber como é pegar no fogo??\n")) if A == "sim": print("Então pega, tu vai se queimar") elif A == "nem": print("Aí sim hein. Esse é sábio vet")
e3d39fa43383f4a4d94b2a8f742bc4f56905e25c
jdpc02/learnpy
/challenges/ifChallenge.py
269
3.875
4
""" If Challenge """ __author__ = 'dev' NAMED = input("What is your Name? ") AGE = int(input("How old are you {0}?".format(NAMED))) if 18 < AGE < 31: print("Welcome to the holiday") else: print("Hello {0}! Hope you are doing well at {1}".format(NAMED, AGE))
a7942a68a0045336e6df6ad48fd5073c598771c5
jdpc02/learnpy
/tuples.py
1,099
3.578125
4
""" Ordered Sets with Tuples """ __author__ = 'dev' t1 = "a", "b", "c" print(t1) print("a", "b", "c") print(("a", "b", "c")) mylis1 = "This is here", "she did", 8888 mylis2 = "Over that section", "they went", 1234, ((1, "One may"), (2, "Two count"), (3, "Three's a crowd")) print(mylis1) print(mylis2[1]) print(mylis2[...
6c5b67ddce6d75b727eee0084bbe1ab51f100293
jdpc02/learnpy
/challenges/binaryChallenge.py
693
3.765625
4
""" Binary Challenge """ __author__ = 'dev' INPNUM = int(input("Please enter a number between 1 and 65535: ")) KEPTVAL = INPNUM OUTNUM = [] #print("{0:>16b}".format(INPNUM)) while INPNUM >= 1: if (INPNUM % 2) == 1: OUTNUM.insert(0, '1') elif (INPNUM % 2) == 0: OUTNUM.insert(0, '0') INPNUM...
11d66c1abd2ff8f1e5c2cb41914ca859e7af8d12
inventvictor/jolt-jobs-firebase
/models/jobs.py
1,458
3.59375
4
class Jobs(object): """ Parameters: - jobTitle (string) - companyName (string) - location (string) - salary (string) - logoUrl (string) - jobUrl (string) """ def __init__(self, **kwargs): self.jobTitle = kwargs.get('jobTitle') ...
f538be2429efe1e98131e57b7c3750ef62165984
rqewqdd/python-starter
/algorithm/Even_Odd.py
492
4.15625
4
# 정수 num이 짝수일 경우 Even을 반환하고 홀수인 경우 Odd를 반환하는 함수, solution을 완성해주세요. def solution(num): if num % 2 == 0: return "Even" else: return "Odd" # 결과물 num = 2 print(solution(num)) # 다른풀이 def evenOrOdd(num): return num % 2 and "Odd" or "Even" # 삼항연산자 : 연산자(operator)의 피연산자(operand) 개수가 3개라서 "삼항 연산...
dcfe50661554c976c6f5572464c85bd705029bac
rqewqdd/python-starter
/week1/Multiple.py
335
3.625
4
# 2단부터 9단까지 출력 for a in range(2,10): for b in range(1,10): print(a,'*',b,'=',a*b) # dan = int(input()) # # for i in range(1,10): # print(dan,'*',i,'=',dan*i) # input()을 int형태로 처리하지 않으면 5 * 9 = 555555555 처럼 str형태로 처리되어 결과가 나타는걸 볼 수 있었다.
5a85883a5b9992827c6a6b373cb6e591ceb0f865
rqewqdd/python-starter
/algorithm/divisor_sum.py
263
3.84375
4
def divisor(num): sum = 0 for i in range(1,num+1): if num % i == 0: sum += i return sum # 결과물 print(divisor(12)) # 다른풀이 def divisor(num): return num + sum([i for i in range(1, (num // 2) + 1) if num % i == 0])
03bfa1209d9544618e47dc34907e48dae6d70e6f
rqewqdd/python-starter
/week1/example_if4.py
325
3.671875
4
# [문제4] 문자열 분석 # # 다음 문자열을 분석하여 나이가 30미만이고 키가 175이상인 경우에는 YES를 출력하고 아닌 경우에는 NO를 출력하는 프로그램을 작성하시오. # # 나이:30,키:180 age = 30 tall = 175 if age < 30 or tall >= 175: print('yes') else: print('no')
05e1d45ca487293e2201a65e4e722971651c8423
CrypTools/RailfenceCipher
/py/encrypt.py
521
3.640625
4
# ============================================================================== # # Use: # encrypt("Hello World", 4) # => "HWe o!lordll" # # ============================================================================== def encrypt(s,n): fence = [[] for i in range(n)] rail = 0 var = 1 ...
8c650b071c1a4cd8de732c1f07f10080a9f3c6ae
thomasambiz/Piratebartender
/scratch.py
1,414
3.78125
4
import random questions = { "strong": "Do ye like yer drinks strong?", "salty": "Do ye like it with a salty tang?", "bitter": "Are ye a lubber who likes it bitter?", "sweet": "Would ye like a bit of sweetness with yer poison?", "fruity": "Are ye one for a fruity finish?" } ingredients = { "st...
300997717c0b7f904f330da4bcb8737df1c57a40
Fersca/python
/customers.py
261
3.578125
4
import csv #Open de file and store it in memory with open('/Users/Fernando.Scasserra/Downloads/base_extraction.csv', newline='') as csvfile: reader = csv.reader(csvfile, delimiter=',', quotechar='"') for row in reader: print(row) break