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 |
|---|---|---|---|---|---|---|
8f3849b69bd789fcba2723fce88031eb0aa0a34d | CtrlLNJ/sanke_game | /snake game/snakegame.py | 10,669 | 3.8125 | 4 | from york_graphics import *
from random import randint
import time
import sys
windowWidth = 400
windowHeight = 400
cellSize = 20
head = 0
# Design the interface when playing the game
def interface():
setLineThickness('0.5')
setLineColour('white')
for m in range(0,400,20):
moveTo(m,0... |
1975d69eb04d4433878d03fb6e8593ec6288a0f6 | luciavicario/KATAS | /2020-hackathon-zero-python-retos-pool-19-master/src/kata2/rpg.py | 497 | 3.546875 | 4 | #!/usr/bin/python
import random
import string
def RandomPasswordGenerator(passLen = 10):
total_posibilities = string.ascii_letters + string.digits + string.punctuation
print (total_posibilities)
password = ""
for positions in range(passLen):
password = password + random.choice(total_posibilit... |
ec53e4e26693c8d35402eff49755aa751451e54c | r-chaudhary/Tic-Tac-Toe | /TicTacToe.py | 3,102 | 3.90625 | 4 | #
# File : TicTacToe.py
#
# Author : Rahul Chaudhary
# Email : r.chaudhary@outlook.in
# Date : 14-March-2020
#
# Summary of File:
# This file contains the code of Tic Tac Toe Game.
# It contains the Main Menu of the game.
#
from Player import Player
import UI
from Game import Game
import os... |
ec41a78f0f0bc8e53345dc6952ee2b82c972d80c | sagarchand9/NN_IITK | /DEMO_1/p/q5/q5.py | 5,379 | 3.6875 | 4 | #################################
#Author: Pawan Harendra Mishra
#EE671A: Neural Networks
#Question 1: Self Organizing Map
#and Collective Response Model
#################################
from numpy import *
from matplotlib.pyplot import *
#training data from csv file
data = genfromtxt("data1.csv", delimiter = ',')
... |
0e1e1bf5dbd1c0de6c655f1903ba647fdcf62816 | sagarchand9/NN_IITK | /DEMO_1/p/q1.py | 2,722 | 4.0625 | 4 | #################################
#Author: Pawan Harendra Mishra
#EE671A: Neural Networks
#Question 1: Backpropagation with
#momentum
#################################
from numpy import *
from matplotlib.pyplot import *
#training data from csv file
data = genfromtxt("data1.csv", delimiter = ',')
#global parameters
l... |
c58695994db70c47a5736394292f718cd73c1ff2 | vanhungbkcbg1/learning_python | /ListComprehension.py | 924 | 3.78125 | 4 | list=[x for x in range(0,10,1)]
dict={x:x for x in range(0,10,1)}
sets={x for x in range(0,10,1)}
print dict
print list
print sets
# with condition
list=[x for x in range(0,10,1) if x>5]
print list
# If you don’t need the value from the list, it’s conventional to use an underscore as the
# variable
list=[0 f... |
62defd460d36474e3e1612e78f289732c3f75b76 | jyotinlad/code-concepts | /python/sort/merge_sort.py | 792 | 4.09375 | 4 | def merge_sort(arr):
if not len(arr) > 1:
return arr
middle = int(len(arr) / 2)
print(middle)
left = arr[:middle]
right = arr[middle:]
print(left)
print(right)
left = merge_sort(left)
right = merge_sort(right)
new_arr = []
while True:
if not left:
... |
bd738de7875f7578ae4dfa4cda95f6b5e05ef70c | youaresoroman/pp1 | /04-Subroutines/duringclass/13.py | 210 | 3.59375 | 4 | def suma(table):
sum = 0
print('Tablica:', end=' ')
for element in table:
print(element, end=' ')
sum += element
print(f"\nSuma wartości: {sum}")
suma([4, 3, 7, 1, 3])
|
29e8a4c9efc1b054dedbb984dc5b3fffd7e15d42 | youaresoroman/pp1 | /05-ModularProgramming/duringclass/4.py | 255 | 3.6875 | 4 | import math
x, y = 4, 8
print(f'x^y: {math.pow(x,y)}')
print(f'Pierwiastek z x o podstawie y: {math.pow(x,(1/y))}')
print(f'Pole koła o promieniu y: {math.pi*y**2}')
print(f'Silnia y: {math.factorial(y)}')
print(f'Najniższa całkowita: {math.ceil(x)}') |
7de6a97526f6afe4e31be3a7e121577fc9a12725 | youaresoroman/pp1 | /04-Subroutines/afterclass/34.py | 185 | 3.703125 | 4 | def fib(n):
if n > 2:
return fib(n-2)+fib(n-1)
elif n == 2:
return fib(1)+1
elif n == 1:
return 0
for x in range(1, 20):
print(fib(x), end=' ') |
e0954a6c523d367ceb902388f631074493f0f5f8 | youaresoroman/pp1 | /05-ModularProgramming/duringclass/shapes.py | 243 | 3.6875 | 4 | import turtle as turtle
def drawSquare(x, y, n):
turtle.color('red', 'yellow')
turtle.speed(0)
turtle.penup()
turtle.setpos(x,y)
turtle.pendown()
for i in range(0, 4):
turtle.forward(n)
turtle.right(90) |
56340d24d4622d38107605c8ae069e1924e23455 | youaresoroman/pp1 | /07-ObjectOrientedProgramming/duringclass/10.py | 335 | 3.703125 | 4 | from class_point import Point
from math import sqrt
def distance(pon1,pon2):
if pon1 == pon2:
return 'Points are in same spot'
else:
length = sqrt((pon1.x-pon2.x)**2 + (pon1.y - pon2.y)**2)
return length
p1 = Point(4, 3)
p2 = Point(4, 3)
p3 = Point(4, 5)
print(distance(p1,p2) + '\n',di... |
d60d52d04ae979f16b2cf06c5e7df61d97d2c3b8 | youaresoroman/pp1 | /02-ControlStructures/duringclass/9.py | 100 | 3.5 | 4 | x = int(input('Podaj Liczbe: '))
if x%2 == 0:
print('Parzysta')
else:
print('Nieparzysta')
|
491274bb76dd5ad1cbcba5c001a02e2fd7581d0c | youaresoroman/pp1 | /09-DefensiveProgramming/duringclass/10.py | 352 | 3.71875 | 4 | def checkFile(filename):
try:
file = open(filename, "r")
output = []
for line in file:
output += line
file.close()
return output
except FileNotFoundError:
print('Not exist.')
except IOError:
print('Reading error.')
pri... |
644e031b5d428697ec2c2a9ac52d22d2797c3bb3 | lyb1527/BinarySearch | /last_position_of_target.py | 692 | 3.546875 | 4 | class Solution:
# @param An integer array sorted in ascending order
# @param An interger, the target
# @return an integer, the index
def lastPosition(self, alist, target):
if not alist or target is None:
return -1
start = 0
end = len(alist) - 1
while start +... |
abe72a62c3a26f01f3b3eaabaab465f320be85ee | NicholasTing/Kattis | /bus_number.py | 159 | 3.640625 | 4 | number = int(input())
check = number / 2
cube_list = []
for i in range(number):
cube_list.append(i*i)
index = 1
while index != check:
index += 1 |
c004ca06c9ba6a9acca1d4cee0d1533c8976ee14 | NicholasTing/Kattis | /Alphabet_Spam/alphabet_spam.py | 366 | 4.09375 | 4 | word = input()
white = 0
lower = 0
upper = 0
symbols = 0
for letter in word:
if letter == '_':
white += 1
elif letter.islower():
lower += 1
elif letter.isupper():
upper += 1
else:
symbols += 1
total = white + lower + upper + symbols
print(white/total)
print(lower/t... |
b2b6800e1ec06ce50423c78fa093ee35449c364b | xujiawei111/ggg | /python_unit/test_demo.py | 277 | 3.640625 | 4 | # -*-coding:UTF-8 -*-
# def fun(x):
# return x
# def test_one():
# assert fun(3)==3
# 加上类的玩法
class Testgoods():
def fun(self,x):
return x
def test_one(self):
assert self.fun(3)==5
good=Testgoods()
good.test_one()
|
9d11b885c5188412b5ed481fea5a49878ae3753e | sangzzz/AlgorithmsOnStrings | /week3&4_suffix_array_suffix_tree/01 - Knuth Morris Pratt/kmp.py | 905 | 4.1875 | 4 | # python3
import sys
def find_pattern(pattern, text):
"""
Find all the occurrences of the pattern in the text
and return a list of all positions in the text
where the pattern starts in the text.
"""
result = []
# Implement this function yourself
text = pattern + '$' + text
s = [0 f... |
c57dd826358b1f0bf0d32a4ba4ca230a41ee204b | binerlin/practice | /payoff3.py | 883 | 4.09375 | 4 | #!usr/bin/eny python3
# -*- coding: utf-8 -*-
def fastpay(balance, annualInterestRate, accuracy=0.01):
'''
Function to get the lowest payment that accuracy is 0.01
Example:
>>> fastpay(320000, 0.2)
Lowest Payment: 29157.09
>>> fastpay(999999, 0.18)
Lowest Payment: 90325.03
'''
rate = annualInterestRate / 12
... |
834f97d354970ec630a17b7e82600c7b99066a86 | derSilberWulf/ImageConverter | /imageModCLI/imageModder.py | 6,586 | 3.625 | 4 | import cv2
import numpy
class ImageModder:
"""This class opens an image and uses openCV to apply various effects to
the image."""
def __init__(self, filepath=None):
"""init method includes an optional filepath argument to open an image file as is"""
self.original_img = None
if(not ... |
a8519ddb9990cd2e4f899603e463fac1a991b328 | stuymmillar/SoftDev | /17_db-nmcrnch/db_builder.py | 1,769 | 3.65625 | 4 | # Taxes - Max Millar and Tim Marder
#SoftDev1 pd6
#K#16 -- No Trouble
#2018-10-04
import sqlite3 #enable control of an sqlite database
import csv #facilitates CSV I/O
DB_FILE="discobandit.db"
db = sqlite3.connect(DB_FILE) #open if file exists, otherwise create
c = db.cursor() #facilitate db op... |
60dcba72cc85538aab4f58ddcd1a989e940f9522 | bhargav-makwana/Python-Corey-Schafer | /Practise-Problems/leap_year_functions.py | 654 | 4.3125 | 4 | # Program : Finding the days in the year
# Input : days_in_month(2015, 3)
# Output :
# Numbers of days per month. 0 is used as a placeholder for indexing purposes.
month_days = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
def is_leap(year):
""" Return True for leap years, False for non-leap years"""
... |
a4ed602c62f4a72a2fed370893c10ad0ab5a9dd9 | browngirlangie/Unit3Lesson14 | /Lesson 14/Problem 1/problem1.py | 3,294 | 4.0625 | 4 | import random
import time
print('*' * 100)
print("Let's Play Rock, Paper, Scissors!!!")
print()
choice = input("Choose one: rock, paper or scissors: ")
choice = choice.lower()
computer_choice = random.choice(['rock', 'paper', 'scissors'])
print()
print("Rock...")
time.sleep(1)
print("Paper...")
time.sleep(1)
print... |
19ced03aa7182ed00797080dfb490d7e6a626f4d | jesuswr/cp-codes-and-problems | /131A.py | 490 | 3.59375 | 4 | a=input()
cont=0
cont3=0
cont1=0
if a==a.upper():
cont=1
a=list(a)
if cont==0:
if a[0]==a[0].lower():
for i in range (1,len(a)):
if a[i]==a[i].upper():
cont1+=1
else:
cont1=-3
break
if cont1==len(a)-1:
cont=1
if cont==1:... |
cb3b01e172aec82302439016f6c624498a7d8277 | jesuswr/cp-codes-and-problems | /102920/gen.py | 98 | 3.5 | 4 | n = int(1e6)
d = int(1e10)
print(n,d)
for i in range(n):
print(int(-1e16), end = ' ')
print() |
355aebc9e86c8137cb8b96610b3af0283275b0c1 | jesuswr/cp-codes-and-problems | /103438/gen.py | 141 | 3.75 | 4 | import random
N = 3000
print(N)
for i in range(N):
print(random.randint(1,20), end =' ')
print()
for i in range(N-1):
print(i+1,i+2) |
a958f08f3221e103e71f78913b08cdefa61c883f | alyson-singleton/machine.learning | /hw5/stencil/models.py | 4,619 | 3.859375 | 4 | import numpy as np
import matplotlib.pyplot as plt
import random
class RegularizedLogisticRegression(object):
'''Implements regularized logistic regression for binary classification.
The weight vector w should be learned by minimizing the regularized risk
log(1 + exp(-y <w, x>)) + \lambda \|w\|_2^2. In other words... |
7eb795b0920e210e7ff11317e1ba199129013837 | HypeDis/DailyCodingProblem-Book | /Email/81_digits_to_words.py | 1,058 | 4.21875 | 4 | """
Given a mapping of digits to letters (as in a phone number), and a digit string, return all possible letters the number could represent.
You can assume each valid number in the mapping is a single digit.
For example if {“2”: [“a”, “b”, “c”], 3: [“d”, “e”, “f”], …} then “23” should return [“ad”, “ae”, “af”, “bd”, ... |
6bf286796689b8d23170d725eedf9656261222bf | HypeDis/DailyCodingProblem-Book | /Email/04_first_missing_positive_integer.py | 1,283 | 3.953125 | 4 | """
Given an array of integers, find the first missing positive integer in linear time and constant space.
In other words, find the lowest positive integer that does not exist in the array.
The array can contain duplicates and negative numbers as well.
For example, the input [3, 4, -1, 1] should give 2. The input [... |
a4450612113faaf8813c6163c461fc483f05bb63 | HypeDis/DailyCodingProblem-Book | /Chapter-5-Hash-Table/5.2-Cut-Brick-Wall.py | 972 | 4.125 | 4 | """
A wall consists of several rows of bricks of various integer lengths and uniform height. Your goal is to find a vertical line going from the top to the bottom of the wall that cuts through the fewest number of bricks. If the line goes through the edge between two bricks, this does not count as a cut.
"""
from col... |
65098a109657d0ccd2f37260e9dcee0676ff3e7c | HypeDis/DailyCodingProblem-Book | /Email/22_construct_sentence.py | 1,145 | 4.09375 | 4 | """
Given a dictionary of words and a string made up of those words (no spaces),
return the original sentence in a list. If there is more than one possible reconstruction,
return any of them. If there is no possible reconstruction, then return null.
For example, given the set of words 'quick', 'brown', 'the', 'fox... |
cf73301d9bfa024bde8203be570ed773f48c1423 | HypeDis/DailyCodingProblem-Book | /Email/35_RGB_sort.py | 1,426 | 3.859375 | 4 | """
Given an array of strictly the characters 'R', 'G', and 'B',
segregate the values of the array so that all the Rs come first,
the Gs come second, and the Bs come last. You can only swap elements of the array.
Do this in linear time and in-place.
For example, given the array ['G', 'B', 'R', 'R', 'B', 'R', 'G'],... |
492eb9203b0be0be9bc93936c2fa8f2ec3b31b82 | HypeDis/DailyCodingProblem-Book | /Email/48_reconstruct_tree.py | 3,527 | 3.9375 | 4 | """
Good morning! Here's your coding interview problem for today.
This problem was asked by Google.
Given pre-order and in-order traversals of a binary tree, write a function to reconstruct the tree.
For example, given the following preorder traversal:
[a, b, d, e, c, f, g]
And the following inorder traversal:
[d... |
d55b9ee9e3f71c1cb4a702822b4e597c6166a880 | HypeDis/DailyCodingProblem-Book | /Email/71_rand7_to_rand5.py | 658 | 3.859375 | 4 | """
Using a function rand7() that returns an integer from 1 to 7 (inclusive) with uniform probability, implement a function rand5() that returns an integer from 1 to 5 (inclusive).
"""
from random import randint, random
def randInit(range):
def rand():
return randint(1, range)
return rand
rand7 =... |
1370dcc86ace18a73d8e63f306a5715e112788bb | HypeDis/DailyCodingProblem-Book | /Email/30_collecting_rain_water.py | 1,780 | 3.96875 | 4 | """
You are given an array of non-negative integers that represents a two-dimensional
elevation map where each element is unit-width wall and the integer is the height.
Suppose it will rain and all spots between two walls get filled up.
Compute how many units of water remain trapped on the map in O(N) time and O(1)... |
a18a302670bdb1c93bcf41783c1f3763d261c716 | HypeDis/DailyCodingProblem-Book | /Chapter-3-Linked-Lists/3.1-Reverse-Linked-List.py | 987 | 4.125 | 4 | from classes import LinkedList
myLinkedList = LinkedList(10)
def reverse(self):
self.reverseNodes(None, self.head)
LinkedList.reverse = reverse
def reverseNodes(self, leftNode, midNode):
# basecase reach end of list
if not midNode.next:
self.head = midNode
else:
self.reverseNodes... |
e3933c8422621cc69a76c38c56832a4776a372b5 | HypeDis/DailyCodingProblem-Book | /Chapter-6-Trees/6.4-Minimum-Sum-Level.py | 796 | 3.78125 | 4 | # find the level with the smallest sum in a binary tree
import collections
deque = collections.deque
defaultdict = collections.defaultdict
from TreeNode import Node
root = Node(1)
root.left = Node(-10)
root.right = Node(5)
root.left.left = Node(-11)
root.left.right = Node(-1)
root.right.left = Node(4)
root.right.rig... |
12733ff8e9cf4556ac011aed6bf25be827b947f3 | HypeDis/DailyCodingProblem-Book | /Email/70_perfect_number.py | 652 | 3.859375 | 4 | """
A number is considered perfect if its digits sum up to exactly 10.
Given a positive integer n, return the n-th perfect number.
For example, given 1, you should return 19. Given 2, you should return 28.
"""
# 19, 28, 37, 46, 55, 64, 73, 82, 91
# 109, 118, 127, 136, 145, 154, 163, 172, 181, 190
def getPerfect... |
7299c9592a6e61e6e3a4bbec5a38cb12c9f310b0 | HypeDis/DailyCodingProblem-Book | /Chapter-3-Linked-Lists/classes.py | 784 | 3.875 | 4 | class LinkedList:
def __init__(self, val=None):
if not val:
self.head = None
else:
self.head = Node(val)
def insert(self, val):
if self.head == None:
self.head = Node(val)
else:
self.insertNode(self.head, Node(val))
return ... |
7efb91bdcc88df5085f86b2326a94a21d8c991d6 | xuefeihexue/IPND_project4 | /media.py | 1,193 | 3.765625 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import webbrowser
# Crete a Movie class
class Movie:
def __init__(
self,
movie_title,
movie_storyline,
poster_image,
trailer_youtube,
):
''' When a initial function is called, it will create a new space for the mov... |
a717b09b4d4d486e3a05b5a9046fe396a9d65959 | Jorza/pairs | /pairs.py | 1,367 | 4.28125 | 4 | def get_pair_list():
while True:
try:
# Get input as a string, turn into a list
pairs = input("Enter a list of integers, separated by spaces: ")
pairs = pairs.strip().split()
# Convert individual numbers from strings into integers
for i in r... |
c2929a7def582ca5609370ed72df7cd4b12d389a | avfranco4/Tarea | /VerficaNumb.py | 600 | 3.8125 | 4 | if __name__ == '__main__':
c = int()
n = int()
num = int()
sp = int()
so = int()
sn = int()
spo = int()
c = 1
n = 1
num = 0
sp = 0
so = 0
sn = 0
spo = 0
print("Ingrese el limite de numeros a verificar")
n = int(input())
while (c<=n):
print("Ingrese el numero a verificar")
num = int(input())
if (n... |
e777c32e5260b5d7ecf7212d9af60a182475efba | Cfffdy/Hillel_python | /main.py | 1,000 | 3.96875 | 4 | # 1
a = int(input("Машина проезжает за день км:"))
b = int(input("Дан маршрут длиною в км:"))
c = int(b/a)
print("Вывод:нужно {} дней, чтобы проехать данный маршрут".format(c))
# 3
print("Введите любые три числа:")
ara = int(input())
aba = int(input())
aca = int(input())
if ara>aba and ara>aca:
print("{} это максим... |
187bbd19bb6d28dda5c9403dc32080273a389bd3 | sviridovt/WIE | /server/libs/EncryptedServerSocket.py | 1,602 | 3.578125 | 4 | import socket
from KeyChain import KeyChain
from communication import sendEncData, readEncData
from communication import sendEncFile, storeEncFile
printDebug = True
# this class defines an encrypted socket for a client
class EncryptedServerSocket:
def __init__(self, host, port):
# this stores the RSA keys for e... |
ddf48fd77624f2d6c521583d5a7ce4bbd81a8572 | RajaSekhar101/python_repo | /str_rev.py | 164 | 4.03125 | 4 | a=input("Enter a String:")
n=len(a)
if n%4==0:
b=a[::-1]
print("Reversed String is ",b)
else:
print("String length is not a multiple of 4 ")
|
949826199bdcb19d5f90b9580f6a30adc6c82b6c | RajaSekhar101/python_repo | /salary.py | 109 | 3.6875 | 4 | s=int(input("Enter basic Salary: "))
HRA=s*(10/100)
TA=s*(5/100)
print("The total salary is: ",(s+HRA+TA)) |
fea507b9dd8b3a8718bc9dab8e1ccd372e74ba1d | RajaSekhar101/python_repo | /execute.py | 229 | 3.71875 | 4 | import time
def sums(n):
count=0
start_t=time.time()
for i in range(0,n):
count=count+1
end_t=time.time()
return end_t
n=int(input("Enter Number:"))
print("Time taken to execute is: ",sums(n)) |
0aa00b56351e8ff2480ac51dd2e8ea7ac73e74d7 | wasif-balol/saylani-python | /Practise/Assignments/2.py | 179 | 3.9375 | 4 | character=int(input("Enter num of words"))
list=[]
for variable in range(0,character):
variable=input()
list.append(variable)
print(list)
print(list[len(list):0:-1]) |
d980bceca8faed7da52adda27bdc62bb867ec2b3 | wasif-balol/saylani-python | /Practise/dictionaries/6_5.py | 248 | 4 | 4 | rivers={'nile':'egypt','arabian sea':'sindh','ravi':'jehlum'}
for key,value in rivers.items():
print(key+" river runs through "+value)
for key in rivers.keys():
print("\n"+key)
for value in rivers.values():
print("\n"+value) |
7f5344ec72d9ee1dfb73a10c5c09c50a9b3987b9 | henrikgruber/PythonSIQChallenge | /#2 Put your solutions here/Test.py | 242 | 3.59375 | 4 | #Aufgabe 1 17.05 Friederike
zahl1 = input("hallo, sag mir eine erste Zahl")
zahl2 = input("hallo sag mir eine zwiete zahl")
zahl3 = input("hallo sag mir eine dritte zahl")
result = int(zahl1)+int(zahl2)+int(zahl3)
print(result)
|
3c0042882117531431b5d27506e5bf602c92e3d3 | henrikgruber/PythonSIQChallenge | /Skill2.3_Friederike.py | 936 | 4.53125 | 5 | # Create 3 variables: mystring, myfloat and myint.
# mystring should contain the word "hello.The floating point number should be named myfloat and should contain the number 10.0, and the integer should be named myint and should contain the number 20.
# Finally, print all 3 variables by checking if mystring equals to ... |
b44f4f5367ae2c8cb39de98e003dc9454d82970a | henrikgruber/PythonSIQChallenge | /#2 Put your solutions here/Skill4.3_Vanessa.py | 1,028 | 4.78125 | 5 | #In this exercise, you will need to add numbers and strings to the correct lists using the "append" list method.
# Create 3 lists: numbers, strings and names
numbers = []
strings = []
names = []
# Add the numbers 1,2, and 3 to the "numbers" list, and the words 'hello' and 'world' to the strings variable
numbers.appe... |
28427a10f91a42216e0ee4d948287d4dfac5a230 | henrikgruber/PythonSIQChallenge | /#2 Put your solutions here/Skill2.1_Nadine.py | 460 | 3.890625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu May 14 08:48:26 2020
@author: nadine.spormann
"""
try:
number = float(input("Please enter any number: "))
if number < 100:
print("Your number is smaller than 100")
elif number > 100:
print("Your number is higher than 100")
elif... |
b659d2d761ee8c0df61154e0497ddcf5a1fe2a80 | henrikgruber/PythonSIQChallenge | /#2 Put your solutions here/Skill 2.3 Tamina.py | 777 | 4.40625 | 4 | # Create 3 variables: mystring, myfloat and myint.
# mystring should contain the word "hello.The floating point number should be named myfloat and should contain the number 10.0, and the integer should be named myint and should contain the number 20.
# Finally, print all 3 variables by checking if mystring equals to "... |
5f0796de207ac892c7db0a2885170051671349f2 | henrikgruber/PythonSIQChallenge | /#2 Put your solutions here/Skill1.4_Nadine.py | 822 | 3.875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed May 13 16:35:19 2020
@author: nadine.spormann
"""
# 0 — Sunday --> Rest: 3
# 1 — Monday --> Rest: 4
# 2 — Tuesday --> Rest: 5
# 3 — Wednesday--> Rest: 6
# 4 — Thursday --> Rest: 0
# 5 — Friday --> Rest: 1
# 6 — Saturday --> Rest: 2
# January 1 was Thursd... |
1b65e04c12a9b0c1df4be645bb0b841c96a67277 | henrikgruber/PythonSIQChallenge | /#2 Put your solutions here/Skill1.4_Vanessa.py | 512 | 4.25 | 4 | # This program finds the number of day of week for K-th day of year
print("Enter the day of the year:")
K = int(input())
a = (K % 7) + 3
if a == 0:
print("This day is a Sunday")
if a == 1:
print("This day is a Monday")
if a == 2:
print("This day is a Tuesday")
if a == 3:
print("... |
323b4035b5ac39975d5254603cf83b450e75ac55 | MagicCubeProject/MagicCubeLib2 | /Enumerations/cellPosition.py | 736 | 3.578125 | 4 | from enum import Enum
class CellPosition(Enum):
CENTER = 0
NORTH = 1
NORTH_EAST = 2
EAST = 3
SOUTH_EAST = 4
SOUTH = 5
SOUTH_WEST = 6
WEST = 7
NORTH_WEST = 8
def isEdge(self):
if(self.value%2==1):
return True
else:
... |
92a714dba98d3c0ae637a710d9c336e705664aba | TasosPateritsas/MachineLearningAlgorithms | /Exercise_4/SimpleNeuralNetwork/python/logisticRegression.py | 3,736 | 3.640625 | 4 | from __future__ import print_function
import numpy as np
import matplotlib.pyplot as plt
# Load data
fid = open('exam_scores_data1.txt', 'r')
lines = fid.readlines()
fid.close()
input_list = []
target_list = []
for line in lines:
fields = line.rstrip().split(',')
input_list.append([float(fields[0]), float(f... |
5f43a09767a524d7cfd203a8941ab2c8999d7489 | bigzlyn/python | /turtle.py | 446 | 3.609375 | 4 |
# 海龟画图
import turtle
try:
t = turtle.pen()
turtle.bgcolor("black")
side2 = 2
colors = ["red", "yellow", "blue", "orange"]
for x in range(360):
turtle.pencolor(colors[x % side2])
turtle.forward(x)
turtle.left(360 / side2 + 1)
turtle.width(x * side2 / 200)
# turtl... |
de502d142b54a51c23332bc7b7ece9788f161006 | UkraintsevAleksey/pythonProject | /1.py | 460 | 3.859375 | 4 | # Поработайте с переменными, создайте несколько, выведите на экран,
# запросите у пользователя несколько чисел и строк и сохраните в переменные, выведите на экран.
a = input('Введите целое число ')
b = input('Введите строку ')
c = input('Введите дробное число ')
print(a, b, c)
|
db9b4f652c9e546fad8001eed90a20ae36e74602 | pscollins/optiver-takehome | /pizza.py | 2,520 | 3.578125 | 4 | import csv
from sys import argv
from operator import attrgetter
from collections import namedtuple
BAKE_TIMES = {
'0': 60,
'1': 15
}
OVEN_COUNT = 3
class Clock:
def __init__(self):
self.time = 0
class Oven:
def __init__(self, clock):
self.cooking = None
self.finishing_at = 0... |
0442988931d3465c6d35e887a96f8a585caaec81 | HelgeS/INF5860_week7 | /nncost.py | 1,297 | 4.0625 | 4 | import scipy.io as sio
import numpy as np
import math
import matplotlib.pyplot as plt
def sigmoid_func(z):
return float(1) / (1 + math.e**(-z))
def sigmoidGradient(z):
# COmpute the gradient of the sigmoid function
return sgrad
def nnCostFunction(Theta1, Theta2, input_layer_size, hid... |
364341e055538b367469d9075147b32a326b1cbf | janettem/Coding-Challenges | /finding_adjacent_nodes/finding_adjacent_nodes.py | 879 | 4.15625 | 4 | def are_adjacent_nodes(adjacency_matrix: list, node1: int, node2: int) -> bool:
if adjacency_matrix[node1][node2] == 1:
return True
return False
def test():
adjacency_matrix1 = [[0, 1, 0, 0], [1, 0, 1, 1], [0, 1, 0, 1], [0, 1, 1, 0]]
adjacency_matrix2 = [
[0, 1, 0, 1, 1],
[1, ... |
aac45822df5d18537f0dcc3826721f5fa048448a | wscott1541/ProEvolutionFootball | /vert.py | 10,583 | 3.640625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu May 14 11:48:34 2020
@author: WS
"""
#import AmericanFootballFunctionsv5 as AFF
import random
#import matplotlib.pyplot as plt
from math import pi
import play_functions as pf
import game_inputs as gi
def rb_inputs(offense):
choice = input(f"... |
329b82908a5602f2d6512e6539d8d1d3f8b79015 | Allen-xmz/robot_examples | /test_samples/util.py | 168 | 3.546875 | 4 | from datetime import datetime
def get_current_time():
now = datetime.now()
now_time = now.strftime("%Y-%m-%d-%H-%M-%S")
print(now_time)
return now_time |
3d5aae9cf780b1cbb6941b0eca00d6a084173271 | erick1984linares/t10_linares_rojas | /Linares-/app6.py | 997 | 3.53125 | 4 | import libreria
def agregarcurso():
curso=libreria.pedir_curso("Ingrese curso:")
nombre_del_alumno=libreria.pedir_nombre("ingrese nombre del alumno:")
promedio=libreria.pedir_numero("ingrese promedio:", 0, 20)
creditos_del_curso=libreria.pedir_numero("ingrese creditos:", 1, 4)
contenido=curso + "-... |
a33b0e973332c01f7518433a0185ed8cb689170e | erick1984linares/t10_linares_rojas | /rojas/app14.py | 1,707 | 3.59375 | 4 | from Rojas import libreria
def agregrrr():
nombre=libreria.pedir_nombre("nombre del recordatorio: ")
mensaje=input("ingrese el mensaje: ")
contenido=str(nombre) + "->" + str(mensaje)+"\n"
libreria.guardar_datos("reminders.txt", contenido, "a")
print("Datos guardados")
def ver_info():
datos = ... |
f2fa7c730c37f261338082e342ef07597d17a626 | turenc/workspace | /framework-learning/pythonWorkspace/chapter06-OOP/demo04.py | 757 | 3.578125 | 4 | # -*- coding: utf-8 -*-
# @Author: gaopeng
# @Date: 2017-01-24 13:36:13
# @Last Modified by: gaopeng
# @Last Modified time: 2017-01-24 13:53:51
# 获取对象信息
print(type(123))
print(type('123'))
print(type(None))
# 通过type来判断继承关系 就不太好判断了要通过isinstance
class Animal(object):
pass
class Dog(Animal):
... |
4376ddc2053f3c4d9dab852d5e682edcfe24dc45 | turenc/workspace | /framework-learning/pythonWorkspace/chapter06-OOP/demo02.py | 847 | 4.03125 | 4 | # -*- coding: utf-8 -*-
# @Author: gaopeng
# @Date: 2017-01-24 11:05:39
# @Last Modified by: gaopeng
# @Last Modified time: 2017-01-24 11:14:36
class Student(object):
def __init__(self, name, score):
self.__name = name
self.__score = score
def print_score(self):
print ('%... |
4f377d718331ad4c3063e2c4a2b4b7b9e4c73fbc | doctriam/python | /tutorials/helloworld.py | 2,145 | 3.796875 | 4 | """
AUTHOR: Kenneth Haynie, Jr.
TITLE: helloworld.py
VERSION: 1.0
VERSION NOTES:
LearnPython.org tutorials through String Formatting;
created endproc() function to clean up and simplify the continue prompt;
comment changes for testing git/github
DESCRIPTION: Walkthroughs of python tutorials from learn... |
e5c9c8f0adcf0b68cccd0394d6a26aeb62852826 | pombredanne/Rusthon | /regtests/c++/cyclic.py | 1,252 | 3.578125 | 4 | '''
detect cyclic parent/child, and insert weakref
'''
class Parent:
def __init__(self, y:int, children:[]Child ):
self.children = children
self.y = y
def create_child(self, x:int, parent:Parent) ->Child:
child = Child(x, parent)
self.children.push_back( child )
return child
def say(self, msg:string):
... |
951f772736dd72ae1eeb896834397b25306c19c9 | pombredanne/Rusthon | /regtests/list/loop.py | 246 | 3.71875 | 4 | from runtime import *
'''
simple for loop
'''
def main():
a = [1,2,3]
y = 0
for x in a:
y += x
assert( y==6 )
b = range(3)
z = 0
for x in b:
z += x
assert( z==3 )
w = 0
for i in a:
for j in b:
w += 1
assert( w==9 )
main()
|
104cac426e6ee89098b5bb08a3be76681838aa3d | pombredanne/Rusthon | /regtests/list/mul.py | 217 | 3.90625 | 4 | from runtime import *
"""list multiplication"""
def main():
a = ['hi']
print a
with operator_overloading:
b = a * 2
print b
assert( len(b)==2 )
assert( b[0]=='hi' )
assert( b[1]=='hi' )
print 'ok'
main()
|
3cb239f47f3fadb2f9165a5680f6df6bc0403239 | pombredanne/Rusthon | /regtests/c++/if_else.py | 74 | 3.640625 | 4 | '''
simple if/else
'''
def main():
a = 'x'
if a == 'x':
print('ok')
|
fa379b0208543d28dc268c84aeeb07362cd50a4c | pombredanne/Rusthon | /regtests/c++/returns_array2D.py | 271 | 3.765625 | 4 | '''
returns array of arrays
'''
def make_array() -> [][]int:
arr = [][]int(
(1,2,3),
(4,5,6,7,8)
)
return arr
def test_array( arr:[][]int ):
print( arr[0][0] )
def main():
a = make_array()
print( len(a))
print( len(a[0]) )
print( len(a[1]) )
test_array(a) |
6fe7fd5850c13122fcb7354da86d0f16b0f25504 | pombredanne/Rusthon | /regtests/rust/simple_subclass.py | 806 | 3.609375 | 4 | '''
simple subclass
'''
class A:
def __init__(self, x:int, y:int, z:int):
self.x = x
self.y = y
self.z = z
def mymethod(self, m:int) -> int:
return self.x * m
class B(A):
def __init__(self, s:string):
A.__init__(self, 4, 5, 6)
let self.w : string = s
let self.x : int = 1
def method2(self, v:stri... |
d42b959e448133ca39a6798c38daa06c90bb86d1 | pombredanne/Rusthon | /regtests/c++/returns_subclasses.py | 1,443 | 4.125 | 4 | '''
returns subclasses
'''
class A:
def __init__(self, x:int):
self.x = x
def method(self) -> int:
return self.x
class B(A):
def foo(self) ->int:
return self.x * 2
class C(A):
def bar(self) ->int:
return self.x + 200
class D(C):
def hey(self) ->int:
return self.x + 1
def some_subclass( x:int ) ->A:
... |
7984dff1037c442f21dcda05b091b656ff1da3b8 | pombredanne/Rusthon | /regtests/go/generics_methods.py | 564 | 3.65625 | 4 | class G:
def method(self):
print 'calling G.method'
print 'hi'
class H( G ):
def method(self):
print 'calling H.method'
print 'world'
class A:
@generic
def __init__(self, a:G):
print 'A.__init__'
print(a)
self.x = a
def call(self):
print 'A.call'
self.f( self.x )
@generic
def f(self, a:G):
... |
18ba08aafe6e41ffc56007c4109c348e8599e8a2 | pombredanne/Rusthon | /regtests/go/generics_subclasses.py | 514 | 3.90625 | 4 | '''
generics classes with common base.
'''
class A:
def __init__(self, x:int):
self.x = x
def method1(self) -> int:
return self.x
class B(A):
def method1(self) ->int:
return self.x * 2
class C(A):
def method1(self) ->int:
return self.x + 200
@generic
def my_generic( g:A ) ->int:
return g.method1()
... |
92d9f6a54f3a13e6c34af9b5f45cc3c50f5106de | pombredanne/Rusthon | /regtests/list/set_slice.py | 817 | 3.625 | 4 | from runtime import *
"""list slice set"""
def main():
a = list(range(10))
for v in a: print v
a[ 2:4 ] = 'Y'
print a
print '------------'
for v in a:
print v
assert( a[0]==0 )
assert( a[1]==1 )
assert( a[2]=='Y' )
assert( a[3]==4 )
assert( a[4]==5 )
assert( a[5]==6 )
assert( a[6]==7 )
assert( a[7]... |
8b8a0b92e6e0697c486e0cdda96874934e4e48f0 | Sadashiv/interview_questions | /python/string_set_dictionary.py | 2,945 | 4.34375 | 4 | string = """
Strings are arrays of bytes representing Unicode characters.
Strings are immutable.
"""
print string
#String Operations details
str = "Hello Python"
str1 = "World"
print "String operations are started"
print str.capitalize()
print str.center(20)
print str.count('o')
print str.decode()
print str.encode()
... |
0e2ee9fedbecfdf3f8307912a99f253e1c760265 | Sadashiv/interview_questions | /python/magic_or_dunder.py | 1,025 | 3.765625 | 4 | class Employee(object):
raise_amount = 1.04
num_of_emp = 0
def __init__(self, first, last, native, amount):
self.first = first
self.last = last
self.native = native
self.amount = amount
Employee.num_of_emp += 1
def fullname(self):
return '{} {}'.format(s... |
639987ee043693f782cabe5c244a7575d0384367 | SachaGoldman/p_n-q_n | /Polynomial_Creater.py | 4,466 | 4.28125 | 4 | from typing import List, Tuple
class Term:
"""A term in the form coef*x**degree
"""
coef: int
degree: int
def __init__(self, degree: int, coef: int):
"""An initializer for the Term class
"""
self.degree = degree
self.coef = coef
def __eq__(self, item) -> bool:... |
79bfc19380e105a1e6faf0023b4e2a47d680f37f | EconClass/CS_2_Tutorials | /tweet_lists.py | 2,406 | 3.65625 | 4 | import string
def histogram_list_of_lists(file_name):
file = open(file_name,'r')
read_words = file.readlines()
file.close()
words = list()
# table = {"--": " ", "-": None}
for line in read_words:
mapped = line.replace("--", " ")
split_line = mapped.rstrip().split(" ")
fo... |
9d03ed28cbaa4edebd1b3014549646005cd55122 | adityaekbote/6.189 | /Assignments/6.189 Homework 3/queue.py | 707 | 3.90625 | 4 | # Name: Tyler Brown
# Section:
# queue.py
# ********** Exercise 3.6 **********
class Queue:
# A class the represents a queue
def __init__(self, line = 0):
#initialization method
#Make 2 object methods
self.line = line = []
def insert(self, line):
print sel... |
8c396b048a3f71f3433cb34a0d23ac0587ce2bb9 | adityaekbote/6.189 | /Assignments/6.189 Homework 1/rps.py | 1,253 | 4.09375 | 4 | ##Exercise 1.7 - Rock, Paper, Scissors
#Create a truth table:
###################################
# Player 1 # Player 2 # Result
# # # # # # # # # # # # # # # # # #
# Rock # Rock # Tie
# Rock # Scissors # Player 1
# Rock # Paper # Player 2
# Scissors # Scissors # Tie
# Scissors # Paper # Pl... |
141f5d9eeb1020a83a79299fc7d3b93637058c83 | capncrockett/beedle_book | /Ch_03 - Computing with Numbers/sum_a_series.py | 461 | 4.25 | 4 | # sum_a_series
# A program to sum up a series of numbers provided from a user.
def main():
print("This program sums up a user submitted series of numbers.")
number_count = int(input("How many numbers will we be summing"
"up today? "))
summed = 0
for i in range(num... |
80f931032dd8fbee7d859a1f04b9d2707d233227 | capncrockett/beedle_book | /Ch_03 - Computing with Numbers/triangle_area.py | 492 | 4.3125 | 4 | # triangle_area.py
# Calculates the area of a triangle.
import math
def main():
print("This program calculates the area of a triangle.")
print()
a = float(input("Please enter the length of side a: "))
b = float(input("Please enter the length of side b: "))
c = float(input("Please ent... |
c49fa6a25c5778001e65955210fe65764e8b9880 | capncrockett/beedle_book | /Ch_04 - Objects and Graphics/futval_graph_2.py | 1,705 | 3.8125 | 4 | # futval_graph.py
from graphics import *
def main():
# Create a graphics window with labels on left edge
win = GraphWin("Investment Growth Chart", 640, 480)
win.setCoords(-1.75, -200, 11.5, 10400)
Text(Point(5, 9600), "Principal:").draw(win)
Text(Point(5.1, 8700), " APR:").draw(w... |
cd7081786262b8ae8b2a44d4c98f65732c883860 | capncrockett/beedle_book | /Ch_06 - Functions/draw_face_func.py | 2,586 | 3.6875 | 4 | # # draw_face_func.py
# from graphics import *
#
#
# def draw_face(center, size, win):
# """Draws a face.
#
# :param center: Graph Point
# :param size: int
# :param win: GraphWin
# :return: A window with a face.
# """
# cen_x = center[0]
# cen_y = center[1]
#
# # draw ... |
ea0ffbdd2d92f203eb7b792eca4ece4906fd82e5 | capncrockett/beedle_book | /Ch_10 - Defining Classes/five_click_house_button.py | 2,244 | 3.84375 | 4 | # five_click_house.py
# A program that allows the user to draw a house in five clicks.
from graphics import *
from button import Button
from random import randint
def main():
# draw window and set coords
win = GraphWin("Five Click House", 600, 600)
win.setCoords(0, 0, 10, 10)
win.setBackg... |
3ad4816268e5cc51ebf581ffe16f7cd40fcbbfd3 | capncrockett/beedle_book | /Ch_04 - Objects and Graphics/circle_intersection.py | 2,739 | 3.828125 | 4 | # circle_intersection.py
from graphics import *
import math
def main():
win = GraphWin("Circle Intersection", 600, 600)
win.setCoords(-14, -14, 14, 14)
win.setBackground("white")
# draw grid lines
x_axis = -10
for y_lines in range(21):
vert_lines = Line(Point(x_axis, -1... |
e585ebdfda2e83cc670fb95501f79e36877a872b | capncrockett/beedle_book | /Ch_04 - Objects and Graphics/line_segment_info.py | 2,519 | 4.09375 | 4 | # line_segment_info
# This program allows the user to draw a line segment and then displays
# some graphical and textual information about the line segment.
from graphics import *
import math
def main():
win = GraphWin("Line Segment Info", 600, 600)
win.setCoords(-14, -14, 14, 14)
win.setBackg... |
b30b0e17c9c907d54c1d4e99b68c0580a00808c4 | capncrockett/beedle_book | /Ch_07 - Decision Structures/valid_date_func.py | 1,101 | 4.46875 | 4 | # valid_date_func.py
# A program to check if user input is a valid date. It doesn't take
# into account negative numbers for years.
from leap_year_func import leap_year
def valid_date(month: int, day: int, year: int) -> bool:
days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
if 1 ... |
1b3ed3b2c52e79211cf2349b72d801cfe4ad4300 | capncrockett/beedle_book | /Ch_06 - Functions/str_to_num.py | 843 | 3.9375 | 4 | # # str_to_num.py
# # Function to convert strings to ints.
#
# def to_numbers(str_list):
# """Converts string numbers to int. Returns new list."""
# int_list = []
# for i in str_list:
# int_list.append(int(i))
# return int_list
#
#
# def test():
# string_list_1 = ['1', '2', '3'... |
b19f9c63a4c64753fc1c46a61177d05a0e08570b | capncrockett/beedle_book | /Ch_06 - Functions/sum_time.py | 545 | 4.25 | 4 | # sum_time.py
def sum_up_to(n):
summed = 0
for i in range(1, n + 1):
summed += i
print(f"The sum is {summed}.")
def sum_up_cubes(n):
summed = 0
for s in range(1, n + 1):
summed += s ** 3
print(f"The sum of the cubes is {summed}")
def main():
print("This ... |
05dfabf942d5223012b1797c3edfeb0bab6a4eca | capncrockett/beedle_book | /Ch_09 - Simulation and Design/blackjack.py | 2,106 | 3.78125 | 4 | # blackjack.py
from random import *
# Things to learn from this: I took too many turns trying to make functions.
# This was very unnecessary. The solution code seemed to write from a top
# down kind of approach. As factors presented themselves they were dealt with.
# Mine rambled and tried to incorporate too man... |
cd407e24b339ed7a4c42847457e538505cbcd63f | capncrockett/beedle_book | /Ch_02 - IDLE Examples/distance_converters.py | 575 | 4.34375 | 4 | # This program converts distances
def kilometers_miles():
print("This function converts kilometers to miles.")
kilometers = eval(input("Enter the distance in kilometers: "))
miles = kilometers * 0.62
print("The distance in miles is", miles)
def fahrenheit_kelvin():
print("This func... |
5c05feac6d95a6375275bc8ddb69d96fcd253f9b | capncrockett/beedle_book | /Ch_07 - Decision Structures/pay_rate_calc.py | 583 | 4.25 | 4 | # pay_rate_calc.py
# Program to calculate an employees pay rate, including overtime.
def main():
hours = eval(input("Enter employee total hours: "))
pay_rate = eval(input("Enter employee pay rate: "))
if hours <= 40:
pay = pay_rate * hours
print(f"Total pay = ${pay:0.2f}")
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.