blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
db171d3ae18ad50b883f7ed7dc8b262ee334247f | Eunbae-kim/python | /basic11.py | 1,112 | 3.6875 | 4 | # 파이썬
# 함수 Fuction와 모듈 module
# 함수 : 특정한 입력을 받아서 처리를 한 이후에, 특정한 출력을 해줌
# 함수를 이용하면 반복을 줄일 수 있는 장점
def add(a,b):
sum = a + b
return sum
print("1 + 3 = ", add(1,3))
#return 문이 없는 경우
def add(a,b):
print(a + b)
add(4,6)
# 가변인자 : 함수의 매개변수가 가변적일 수 있을 때 사용
def function(*data):
print(data)
function(1,2,3)
#... |
bb78ecd3b33b974d26d1b7fc83f933ef8a660a20 | Eunbae-kim/python | /chapter07_01.py | 3,391 | 3.625 | 4 | #Chapter07_01
#예외 개념 및 처리
# SyntaxError, typeError, nameError, indexError
# 문법적으로는 예외가 없지만, 코드 실행 프로세스(단계) 발생하는 예외도 있음
# 1. 예외는 반드시 처리해야 한다.
# 2. 로그는 반드시 남긴다.
# 3. 예외는 던져진다.
# 4. 예외 무시할 수 있지만, 좋은 방법은 아니ㅏㄷ.
# SyntaxError : 문법 오류
#print('error)
#print('error'))
#if True
# pass
#NameError : 참조가 없을 떄
# a = 10
# b = 1... |
c452668b786727a3438a06c22230e08c3eb01914 | Eunbae-kim/python | /basic9.py | 850 | 4.1875 | 4 | # 파이썬
# 튜플 (Tuple) : 리스트(list)와 비슷하지마, 다만 한번 설정되면 변경 불가
# 튜플은 변경 불과
tuple = (1, 2, 3)
print(tuple ," : tuple type ", type(tuple))
# 리스트는 하나의 원소로 취급가능하기 때문에 리스트를 튜플의 각 원소로 사용가능
list1 = [1,3,5]
list2 = [2,4,6]
tuple2 = (list1, list2)
print(tuple2) #2개의 리스트가 각각 원소로 들어감
print(tuple2[0][1])
#하지만, 튜플은 변경불가능 하기 떄문에 tuple[0]... |
046ec8d5a65e6f793e93f57793edd4d7469b188d | Eunbae-kim/python | /basic2.py | 794 | 3.875 | 4 | # 문자열 자료형의 함수
a = "INTERSTING PYTHON"
print(a)
#특정 문자열을 대체할 떄 : replace
b = a.replace("INTERSTING","love")
print(b)
#문자열에 특정 문자가 몇개 포함되어있는지 알고 싶을 떄 : count
print(a.count('N'))
print(a.count('n')) #파이썬은 대소문자 구분
#특정한 문자의 위치를 반환 : find
print(a.find("PYT")) #시작하는 값을 return해줌
print(a.find("love")) #없는 문자를 찾을 때는 -1을 retu... |
1bcbbf8100ba55c13f4772d23b4956ece040adb0 | CrazyPython/99-python-problems | /99-04.py | 98 | 3.6875 | 4 | # Return the length of a list
list = [0, 1, 2, 3, 4, 5]
def length(list):
return len(list)
|
9d73a041f7b28c140f00aa2d7cf7c8d3f270cb91 | Deepthibr28/software-testing | /tutorials/unittests/python/src/grader.py | 386 | 3.9375 | 4 |
def calculator(grade):
if grade > 90:
return 'A'
elif 80<grade <= 90 :
return 'B'
elif 70<grade <= 80 :
return 'C'
elif 60<grade <= 70 :
return 'D'
def calculate(grade):
if grade > 90:
return 'A'
elif 80 < grade <= 90:
return 'B'
elif... |
39de0dd6e5eec91dccfcc49cbaa45d088816a07e | fxbabin/Piscine_python_django | /d01/ex07/periodic_table.py | 3,348 | 3.53125 | 4 | #! /usr/bin/python3
import sys
def print_header(file):
file.write("<!DOCTYPE html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\"/>\n\t\t<title>periodic table</title>\n\t</head>\n\t<body>\n")
def print_end(file):
file.write("\t</body>\n</html>")
def print_line(out_file, periodic_table, space_1=0... |
d2417f9b2a06ca9447d554ecc34998fac1f1d59d | yossef21-meet/meet2019y1lab1 | /turtleLab1-Yossi.py | 1,457 | 4.5 | 4 | import turtle
# Everything that comes after the # is a
# comment.
# It is a note to the person reading the code.
# The computer ignores it.
# Write your code below here...
turtle.penup() #Pick up the pen so it doesn’t
#draw
turtle.goto(-200,-100) #Move the turtle to the
#position (-200, -100)
#on... |
221fb99b3dcf52ccf43cff5f3d897f448ca3fede | samsonosiomwan/SQL-model-practice | /sqlite/setup.py | 645 | 3.65625 | 4 | from sqlite.interfaces import ToSQLInterface
import sqlite3
import pandas
class SetUpSQL(ToSQLInterface):
'''this class initializies sqlite connection to sqlite3 and creates database if none exists, it has convert_to_sql method which opens csv files and converts it sql'''
def __init__(self):
self.conne... |
4e841521e03d9b05ab438f2c50bfd20aaf72c99d | vt-dataengineer/leetcode | /leetcode_problems/file4/pivot index.py | 670 | 3.6875 | 4 | # Input:
# nums = [1, 7, 3, 6, 5, 6]
# Output: 3
# Explanation:
# The sum of the numbers to the left of index 3 (nums[3] = 6) is equal to the sum of numbers to the right of index 3.
# Also, 3 is the first index where this occurs.
# def one(a):
# nums = [1, 7, 3, 6, 5, 6]
# i = 1
# s = 0
# s1 = 0
# ... |
c680534217d72ebbfe129641a80193f3a1514014 | vt-dataengineer/leetcode | /leetcode_problems/file4/missing numbers in array.py | 267 | 3.625 | 4 | # Input:
# [4,3,2,7,8,2,3,1]
#
# Output:
# [5,6]
l = [1,1]
ll = []
s = sorted(l)
print(s)
for x in s:
if x > len(s):
break
if len(s) == 1:
ll.append(s+1)
else:
for y in range(1,len(s)+1):
if y not in s:
ll.append(y)
print(ll)
|
0a5d2c164e84ea9d620ea68d1b1f33fb5ba3a119 | vt-dataengineer/leetcode | /leetcode_problems/file3/sort colors.py | 390 | 3.828125 | 4 | # Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively.
#
# Note: You are not suppose to use the library's sort function for this problem.
#
# Example:
#
# Input: [2,0,2,1,1,0]
# Output: [0,0,1,1,2,2]
l = [2,0,2,1,3,1,0]
mini = l.count(min(l))
print(mini)
maxi = l.count(... |
c42e00e3703d52b2603d3480d2d5e1ae984e769b | vt-dataengineer/leetcode | /leetcode_problems/file5/list of multiples.py | 178 | 3.90625 | 4 | # list_of_multiples(7, 5) ➞ [7, 14, 21, 28, 35]
ll = []
def list_of_multiples(x,y):
for z in range(1,y+1):
ll.append(x*z)
print(list_of_multiples(7,5))
print(ll)
|
e148cfa990163d8ca46623ad862ac14e2757fd95 | vt-dataengineer/leetcode | /leetcode_problems/file2/test50.py | 326 | 3.71875 | 4 | #1 22 11 2 1 22 """ 1 22 11 2 11 22 ......
#Input: 6
#Output: 3
#Explanation: The first 6 elements of magical string S is "12211" and it contains three 1's, so return 3.
if __name__=='__main__':
a = 1
s ='1221121221221121122'
one = ''
for x in range(0,len(str(a))):
one+=s[x]
print(one.count(... |
73a9eb87144825ce39342bdac12f4f9ef793cd6c | vt-dataengineer/leetcode | /leetcode_problems/file3/plus one.py | 347 | 3.96875 | 4 | # Example 1:
#
# Input: [1,2,3]
# Output: [1,2,4]
# Explanation: The array represents the integer 123.
# Example 2:
#
# Input: [4,3,2,1]
# Output: [4,3,2,2]
# Explanation: The array represents the integer 4321.
l = [4,3,2,1]
z = ''
l1 = []
for x in l:
z = str(z)+str(x)
print(z)
add = int(z)+1
for y in str(add):
... |
e17344a483ada87f2a693a04752428f69e1e2e25 | vt-dataengineer/leetcode | /leetcode_problems/file2/test47.py | 894 | 3.828125 | 4 | #numbers = "0123456789"
#lower_case = "abcdefghijklmnopqrstuvwxyz"
#upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#special_characters = "!@#$%^&*()-+"
if __name__=='__main__':
s = 'aacabdddd23'
lower_case = "abcdefghijklmnopqrstuvwxyz"
upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
numbers = "0123456789"
l... |
2532cce1afad6219915ecec7fb7ab10c4c926cf7 | vt-dataengineer/leetcode | /leetcode_problems/file/test29.py | 261 | 3.578125 | 4 | # Input: 13
# Output: 6
# Explanation: Digit 1 occurred in the following numbers: 1, 10, 11, 12, 13.
if __name__ == '__main__':
a = str(13)
c=0
for i in range(1,int(a)+1):
if '1' in str(i):
c+=1
print(i)
print(c)
|
52dd4ffb2ddb42e58e744b2c8164dbd6a78d4bc7 | vt-dataengineer/leetcode | /leetcode_problems/file4/robot return to origin.py | 661 | 3.921875 | 4 | # Input: "UD"
#The move sequence is represented by a string, and the character moves[i] represents its ith move.
# Valid moves are R (right), L (left), U (up), and D (down).
# If the robot returns to the origin after it finishes all of its moves, return true. Otherwise, return false.
# Output: true
# Explanation: The r... |
2544ba5f06724bbab067a818fb3ef49fb1ffd0c4 | vt-dataengineer/leetcode | /leetcode_problems/test4.py | 341 | 3.546875 | 4 | if __name__ == "__main__":
l = (1,0,1,0,0)
z=0
m =0
last_index = -1
while True:
try:
last_index = l.index(z, last_index + 1)
print(last_index)
if last_index> l.index(1):
m = m +1
print("Max = "+str(m))
except ValueError:... |
fb7c0cebce3fac2963591d30175d6d9f35be7cde | dev-ds/PyPractice | /prisoners.py | 1,096 | 3.890625 | 4 | #!/bin/python3
'''
A jail has N prisoners, and each prisoner has a unique id number, S, ranging from 1 to N.
There are M sweets that must be distributed to the prisoners.
The jailer decides the fairest way to do this is by sitting the prisoners down in a circle (ordered by ascending S),
and then, starting with some... |
26a431a7caa6b98a3f938497b540cfd161382a54 | SamEhret/codeChallenge | /python_code_challenge/src/inputFunctions.py | 1,009 | 3.859375 | 4 | import sys
import re
# Take input or give default input
def getInput():
inputString = input('Please enter the string to process')
if not inputString:
inputString='(id,created,employee(id,firstname,employeeType(id),lastname),location)'
return inputString
# Check that nesting in "()"" is valid
# Str... |
67dafd87e132064d3a492f3e8c9bdde80dae1110 | Katy-Scha/programming_practice | /4 week/N6.py | 459 | 3.96875 | 4 | """ was a[i] before?"""
a = input()
a = a.split()
before = set([])
for i in range(len(a)):
if set([a[i]]) & before != set([]):
print('yes')
else:
before.add(a[i])
print('no')
"""print (bool(a[0] == '1'))
print(before & '1')
a = [1, 2, 3, 1, 2, 3]
before = set([])
for i in range(len(a... |
81f43aec85cede4c308070be22805fed734bf755 | 84436/AI-Project-02 | /src/map_generator.py | 5,173 | 3.515625 | 4 | #!/bin/env python3
# Map generator (standalone): utility for generating random maps
from random import randrange
import os
# Parameters
# No checks will be applied on parameters; please make sure it's sane.
map_size = 10
# count_pit = 10
# count_wumpus = 10
# count_gold = 10
count_pit = randrange(0, 10+1... |
8d888e53b71da82ae029c0ffc4563edc84b8283d | EdwardMoseley/HackerRank | /Python/INTRO Find The Second Largest Number.py | 661 | 4.15625 | 4 | #!/bin/python3
import sys
"""
https://www.hackerrank.com/challenges/find-second-maximum-number-in-a-list
Find the second largest number in a list
"""
#Pull the first integer-- we don't need it
junk = input()
def secondLargest(arg):
dat = []
for line in arg:
dat.append(line)
... |
bbe8b6100246aa2f58fca457929827a0897e9be5 | arickels11/Module4Topic3 | /topic_3_main/main_calc.py | 1,637 | 4.15625 | 4 | """CIS 189
Author: Alex Rickels
Module 4 Topic 3 Assignment"""
# You may apply one $5 or $10 cash off per order.
# The second is percent discount coupons for 10%, 15%, or 20% off.
# If you have cash-off coupons, those must be applied first, then apply the percent discount coupons on the pre-tax
# Then you add tax at... |
51eb05addd6e4abb3363eaaf1eb7ad78cc2506af | Jay-Wang-zechong/Wang-s-python-code | /python抽签/抽签.py | 171 | 3.59375 | 4 | import random
people_num = 7
number = random.randint(1,people_num)
print(number)
people_num = 6
number = random.randint(1,people_num)
print(number)
input("Press <Enter>") |
a6e545b4dbff5c1866ee076535d3b637c8e063b7 | tehologist/x-venture | /version_new/World/player.py | 355 | 3.515625 | 4 | """Player class which represents in game character"""
class player:
"""Initialize name attribute"""
def __init__(self, name, id):
self.name = name
self.id = id
self.location = ""
self.description = ""
self.isPlayer = true
def do_say(self, args):
pass
def... |
27006f8290968a5d89a8d0d25355538212718075 | Manny-Ventura/FFC-Beginner-Python-Projects | /madlibs.py | 1,733 | 4.1875 | 4 | # string concatenation (akka how to put strings together)
# # suppose we want to create a string that says "subscribe to ____ "
# youtuber = "Manny Ventura" # some string variable
# # a few ways...
# print("Subscribe to " + youtuber)
# print("Subscribe to {}".format(youtuber))
# print(f"subscribe to {youtuber}")
adj ... |
0acf51277b792ba4159316f07096297844dbadd0 | dashkazaitseva/yandex.traning | /2 июня. Тестирование/B.py | 158 | 3.65625 | 4 | a = [0, 0, 0]
a[0] = int(input())
a[1] = int(input())
a[2] = int(input())
a.sort()
if (a[2] < a[0] + a[1]):
print("YES")
else:
print("NO")
|
e1f02b9b444ee75a76e85115bef94eda1c17a59f | chrisbryan88/ProjectEuler | /PE6.py | 883 | 3.703125 | 4 | '''
projecteuler.net/problem=6
The sum of the squares of the first ten natural numbers is,
1^2 + 2^2 + ... + 10^2 = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)^2 = 552 = 3025
Hence the difference between the sum of the squares of the first ten natural numbers and the square of t... |
19b1c93472b95b084d5561a79ce1f2c969ebbcdf | Ksenaty/PythonLearning | /Homework/Lesson1/task4.py | 333 | 3.765625 | 4 | user_number = int(input('Введите число>>>'))
max_number = 0
while user_number > 0:
comparing_number = user_number % 10
if max_number < comparing_number:
max_number = comparing_number
user_number //= 10
else:
user_number //= 10
comparing_number = user_number % 10
print(max_number)... |
6d429a601525ddbd21a71d6b0cb2ca251464600a | shirdha/ss | /vowel/largest1.py | 117 | 3.53125 | 4 | a,b,c=map(int,input().split())
if a>=b and a>=c:
print(a)
elif b>=c and b>=-a:
print(b)
else:
print(c)
|
1b00aac23ad6f8c35ac1e5dd520630abc28ababb | shirdha/ss | /factplay.py | 150 | 3.859375 | 4 | n=int(input(""))
fact=1
if(n<=0):
print(fact)
elif(n==1):
print(fact)
if(n>1):
for i in range(1,n+1):
fact=fact*i
print(fact)
|
e6df2e20e5dae1904746a8c676d8d6610f6b74c5 | shirdha/ss | /countdigits_play.py | 137 | 3.890625 | 4 | string=input("")
count1=0
for i in string:
if(i.isdigit()):
count1=count1+1 #count is incremented by one
print(count1)
|
658e3113ab34936c6bd1a276170c5d99da8f3231 | shirdha/ss | /sum.py | 75 | 3.828125 | 4 | n=int(input(""))
sum1=0
for i in range(1,n+1):
sum1=sum1+i
print(sum1)
|
89f89f5427df86d1ee3b38d7c38a1e48863d44cd | nclslmx/Inertial_action_recognition | /model/hierarchical_CNN_linear.py | 20,499 | 3.625 | 4 | import torch
import torch.nn as nn
def weights_init(m):
"""
Standard module's weight initialization
:param m: pytorch module
"""
if isinstance(m, nn.Linear):
nn.init.xavier_uniform_(m.weight, gain=1)
nn.init.constant_(m.bias, 0)
elif isinstance(m, nn.Conv1d):
nn.init... |
65d3041e75c767cd1333a0ab808f13b13b1faa8c | aashurajhassani/OpenCV_basics | /Source_1/08 - Handle Mouse Events in OpenCV.py | 1,350 | 3.5 | 4 | events = [i for i in dir(cv2) if 'EVENT' in i]
# dir is inbuilt method which is going to show all clases functions etc in cv2 package
print(events)
# all the events in cv2 library are shown
# first mouse callback function is created which is called when something is done with the mouse
def click_event(event, x, y, fla... |
0c59e4e602351bc53f8785788263312c77e27233 | aashurajhassani/OpenCV_basics | /Source_1/03 - How to Read, Write, Show Images in OpenCV.py | 1,703 | 3.9375 | 4 | pip install opency-python
# in the terminal window to install opencv package in pycharm
import cv2
# to import the package to the project
# copy any image file to be worked on to the prject folder in pycharm
cv2.imread('image_name(lena.jpg)', 0)
# second argument is a flag that specifies the way to read image files
... |
de25e31fa817bc6347566c021edc50f1868de959 | gohjunyi/RegEx | /google_ex.py | 1,167 | 4.125 | 4 | import re
string = 'an example word:cat!!'
match = re.search(r'word:\w\w\w', string)
# If-statement after search() tests if it succeeded
if match:
print('found', match.group()) # 'found word:cat')
else:
print('did not find')
# i+ = one or more i's, as many as possible.
match = re.search(r'pi+', 'piiig') # fo... |
cd2b1d842bbfdb2bd017da79f87ed0ebf9e49fdd | wasuaje/ondina | /Sistema Deteccion de Somnolencia/Tesis_Ondina/fuzzy/Desfusificador.py | 1,958 | 3.609375 | 4 | # -*- coding: utf-8 *-*
"""
-Obtener la forma geométrica obtenida de la inferencia
-Crear la Clase Mandani y Clase del Japonés
-Centroide por cada tipo de clase
-Generar valor final
"""
class Desfusificador:
def __init__(self,trapecio):
self.trapecio = trapecio
self.centroide = 0
... |
49ead4bb0d12fb53f9cab8a9c974c02a9f9fdebc | haley-harris/belhavencsc | /221/chap8/ex-mcb.pyw | 1,257 | 3.671875 | 4 | # saves and loads pieces of text to clipboard
# commands: python3 ex-mcb.pyw save <keyword> - saves clipboard to keyword
# python3 ex-mcb.pyw <keyword> - loads keyword to clipboard
# python3 ex-mcb.pyw list - loads all keywords to clipboard
# python3 ex-mcb.pyw delete ... |
fa6620b0c37a911279ddc486ea4354d8d439a5b8 | wonhyeongseo/python | /exercises/practice/collatz-conjecture/collatz_conjecture_test.py | 1,040 | 3.640625 | 4 | import unittest
from collatz_conjecture import (
steps,
)
# Tests adapted from `problem-specifications//canonical-data.json`
class CollatzConjectureTest(unittest.TestCase):
def test_zero_steps_for_one(self):
self.assertEqual(steps(1), 0)
def test_divide_if_even(self):
self.assertEqual... |
491454a81d8ee0e33fa142d93260c72e23345631 | ammalik221/Python-Data-Structures | /Trees/Depth_first_traversal.py | 2,866 | 4.25 | 4 | """
Depth First Search implementation on a binary Tree in Python 3.0
Working -
recursion calls associated with printing the tree are in the following order -
- print(1, "")
|- traversal = "1"
|- print(2, "1")
| |- traversal = "12"
| |- print(4, "12")
| | ... |
f01d7fab6569e318399eee144b7310d39433d061 | ammalik221/Python-Data-Structures | /Collections/Queues_using_queue_module.py | 411 | 4.1875 | 4 | """
Queues Implementation in Python 3.0 using deque module.
For implementations from scratch, check out the other files in this repository.
"""
from collections import deque
# test cases
# make a deque
q = deque()
# add elements
q.append(20)
q.append(30)
q.append(40)
# output is - 10 20 30 40
print(q)
# remove el... |
58eed8a3f65600fa30df36a73cae9f8ce355ed20 | eileenjang/algorithm-study | /src/sunwoo/source_code/week9/네트워크.py | 360 | 3.765625 | 4 | def solution(n, computers):
answer = 0
enumerated_link = enumerate(computers)
queue = []
current_queue = [enumerated_link.next()]
while len(current_queue) > 0:
queue += current_queue
return answer
count = [
solution(3, [[1, 1, 0], [1, 1, 0], [0, 0, 1]]),
solution(3, [[1, 1, 0... |
1e4d6472c97160fef43a028d04f001c86825d8ed | eileenjang/algorithm-study | /src/programmers/jichang/week1/test_행렬의덧셈.py | 799 | 3.984375 | 4 | def sum_of_array(arr1, arr2):
"""두 행렬의 덧셈을 구하라.
시간 복잡도:
arr1가 M x N 크기의 행렬이라고 할 떄 O(NM)
"""
return [sum_of_rows_in_arrays(arr1[row], arr2[row]) for row in range(len(arr1))]
def sum_of_rows_in_arrays(row1, row2):
return [row1[row] + row2[row] for row in range(len(row1))]
def test_sum_of_arra... |
8cc1a7bed872b55a22a130af76fc56b93879fb7b | eileenjang/algorithm-study | /src/programmers/jichang/week1/test_다트게임.py | 3,380 | 4 | 4 | # 다트게임 https://programmers.co.kr/learn/courses/30/lessons/17682
import re
exponents = {'S': 1, 'D': 2, 'T': 3}
def dart_game(dart):
"""다트게임의 문자열이 주어지면 총점수를 반환하라.
"""
return mathematical_expression_to_score(
make_mathematical_expression(game_to_token(split_dart_game(dart))))
def mathematica... |
df75c3a26e33098755df0f48694989f809cb61c4 | eileenjang/algorithm-study | /src/programmers/jichang/week2/test_멀쩡한사각형.py | 435 | 3.734375 | 4 | """
솔루션을 봤음
"""
from math import gcd
def available_square(W, H):
return W * H - W - H + gcd(W, H)
def test_available_square():
assert available_square(8, 12) == 80
assert available_square(2, 3) == 2
assert available_square(4, 6) == 16
assert available_square(5, 7) == 24
assert available_squa... |
73c2bcf27da231afe7d9af4425683c006799e7a9 | razzanamani/pythonCalculator | /calculator.py | 1,515 | 4.375 | 4 | #!usr/bin/python
#Interpreter: Python3
#Program to create a functioning calculator
def welcome():
print('Welcome to the Calculator.')
def again():
again_input = input('''
Do you want to calculate again?
Press Y for YES and N for NO
''')
# if user types Y, run the calculate() function
if again_input == 'Y':
c... |
7a484599980c33837ededc64d953b590668bd13f | kdwatt15/simplegames | /Lib/simplegames/chess/game.py | 1,834 | 3.59375 | 4 | from pieces import *
class Board:
def __init__(self, white_type, black_type):
self.white = Player(1, white_type)
self.black = Player(-1, black_type)
self.board = self.init_board()
def __str__(self):
board_string = ''
for row in self.board:
board_string += ' '.join([str(c) for c in row])
board_st... |
e0b39bd95a52671b521c943f15327924377d7c4f | RNHodkinson/Scripts | /PongMain.py | 3,455 | 3.53125 | 4 | # Game of pong | . |
# Using the turtle module, and os module(works with os).
import turtle
import os
# Inherit from the Screen class.
wn = turtle.Screen()
# Set Screen Properties
wn.title("Pong version ..::HC::..")
wn.bgcolor("red")
wn.setup(width=1000, height=700)
wn.tracer(0)
# Score
score_a = 0
score_b = 0
# P... |
7e4e3dcbe4378f252c5a79aeec81a93133e14f45 | AaronMerlosH/Club_de_algoritmia_UPIITA | /fibonacci.py | 630 | 3.875 | 4 | # -*- coding: utf-8 -*-
"""
Programa para obtener serie Fibonacci usando recursividad
CLUB ALGORITMIA UPIITA
Aaron Merlos
"""
def fibonacci(posicion):
if posicion==0:
return 0
elif posicion==1:
return 1
return fibonacci(posicion-1)+fibonacci(posicion-2)
if __name... |
2c33f956faac35d8feccc660255bde6236d33a38 | ludmilai/storage_model | /mttdl2le.py | 4,682 | 3.8125 | 4 | """
Calculates mean time to data lost estimations for disk and latent block failures given the following parameters:
N - total number of disks
C - total number of chunks
n - data blocks tuple length
B - number of disk blocks per disk B=C*n/N
Td - time to failure for the particular disk
Tb - time t... |
d0c4efbc254e8cbf5323da5c0758d6a6f0975611 | yhlhenry/projecteular | /27_Quadratic_primes.py | 691 | 3.546875 | 4 | a_candi = [x for x in range(-1000, 1000) if x % 2 != 0]
b_candi = [x for x in range(-1000, 1000) if x % 2 != 0]
def isPrime(num):
if num > 1:
for i in range(2, num):
if (num % i) == 0:
return False
else:
return True
else:
return False
number_pr... |
951ab4d2b011efdfcc4b7eeb376c0c8076fcc95d | anukulu/100DaysOfCode | /Dhumbal (to be made)/main.py | 2,805 | 3.640625 | 4 | import random
import itertools
class Card:
def __init__(self, name, color):
self.name = name
self.color = color
class Deck:
def __init__(self):
self.newDeck = []
self.colors = ['C', 'D', 'H', 'S']
self.numbers = [i for i in range(1,14)]
def MakeNewDeck(self):
... |
19ebb43dcbe1a3195b0b0cbe7202fa5fec0fd037 | risooonho/RPG | /enemies/__init__.py | 1,664 | 3.609375 | 4 | #!/usr/bin/python3
"""
This is to handle the games enemies
"""
import pygame
class enemies(object):
def __init__(self, pos):
from config import mobs
self.position = (pos[0], pos[1])
self.rect = pygame.Rect(self.position[0], self.position[1], 32, 32)
mobs.append(self)
s... |
4c97f87224677eb2a20c4e469f74a959764c936a | williamsyb/mycookbook | /algorithms/BAT-algorithms/Array & String/L_ 旋转数组中查找最小值.py | 1,254 | 3.90625 | 4 | # coding:utf-8
"""
一、题目
0124567 --旋转--> 4567012 , 最小值 是 0
二、思路
用索引start, end 分别指向首尾元素,元素不重复。
1、若子数组是普通升序数组,则 Array[start] < Array[end]; eg:Array = [4,5,6]
2、若子数组是循环升序数组,前半段子数组的元素全都大于后半子数组中的元素:Array[start] > Array[end]. eg: Array = [7,0,1,2]
三、步骤:
计算中间位置 mid = (start + end) >> 1
1、显然,Array[start...mid] ... |
32948a2bcf2470ffb894d2ad6fc0379c187add89 | williamsyb/mycookbook | /algorithms/BAT-algorithms/The beauty of programming/chapter-4/7-蚂蚁爬树.py | 816 | 3.578125 | 4 | def ant_time(locs, wood_len,speed):
"""
求所有蚂蚁都离开木杆的最短时间和最长时间
:param locs: 蚂蚁的初始位置
:param wood_len: 木杆的长度
:param speed: 蚂蚁爬行速度,厘米/秒
:return: 最短时间 最长时间
"""
min_distance = [] # 存储蚂蚁到木杆 最近 一端的距离
max_distance = [] # 存储蚂蚁到木杆 最远 一端的距离
for loc in locs:
min_distance.append(min(... |
c08cc0a18eaf2d615fafe3ee3a5b35b938b7ff8c | williamsyb/mycookbook | /pydantic_demo/demo.py | 1,317 | 3.5 | 4 | from pydantic import BaseModel, ValidationError, validator
class UserModel(BaseModel):
name: str
username: str
password1: str
password2: str
@validator('name')
def name_must_contain_space(cls, v):
print('name_must_contain_space-v:', v)
if ' ' not in v:
raise ValueE... |
8be14b95e50f530eeaaaf7d9fda8ddc843ba4ded | williamsyb/mycookbook | /algorithms/BAT-algorithms/Tree/分行打印一棵树.py | 1,498 | 3.78125 | 4 | """
一、题目
分行从上之下打印一颗二叉树
例如有如下一棵树:
5
/ \
3 6
/ \ \
2 4 7
打印结果是
5
3 6
2 4 7
二、思路
在层次遍历的基础加以改进
如何实现逐行打印,必须要知道每一行的开始和结束。如何准确地获得该信息是关键。
核心思想:在每一层开始遍历前,队列中存储的就是该行的全部是数据,用size记录,然后一次性全部遍历。
"""
class TreeNode:
def __init__(self, x):
self.v... |
af65af7af55c545222130b1b0330eeb4c26b91d0 | williamsyb/mycookbook | /algorithms/双指针/leetcode-633-两数平方和.py | 711 | 3.84375 | 4 | # -*- coding UTF-8 -*-
# @project : python03
# @Time : 2020/6/3 12:34
# @Author : Yibin Sun
# @Email : sunyibin@orientsec.com.cn
# @File : leetcode-633-两数平方和.py
# @Software: PyCharm
import math
class Solution:
@classmethod
def judge_square_sum(cls, target):
if target < 0:
return F... |
63c41b9812173e85be95f1181a2104085530f525 | williamsyb/mycookbook | /algorithms/bfs_dfs/robots.py | 1,823 | 3.703125 | 4 | """
问题定义
有如下 8 x 8 格子,机器人需要从开始位置走到结束位置,每次只能朝右或朝下走,粉色格子为障碍物,机器人不能穿过,
问机器人从开始位置走到结束位置最多共有多少种走法?
"""
from pprint import pprint
mat = [
[0] * 8,
[0, 0, 1, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 1, 0, 0, 0],
[1, 0, 1, 0, 0, 1, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 0, 1, 0],
[0, 1, 0, 0, 0, 1, 0... |
f19c45f6389c44c162b54b0eb74edb25cfa5da9b | williamsyb/mycookbook | /algorithms/BAT-algorithms/Linklist/删除链表的倒数第 n 个节点.py | 1,055 | 3.5 | 4 | """
题目:
给定一个链表,删除链表的倒数第 k 个节点,并且返回链表的头结点。
示例:
给定一个链表: 1->2->3->4->5, 和 k = 2.
当删除了倒数第二个节点后,链表变为 1->2->3->5.
思路:
第一种:遍历一次,获得链表长度N,则可知 倒数第k个节点 == 顺数第N-k+1个节点,再次遍历,删除即可。 (一共需要两次遍历)
第二种:使用快慢指针遍历,让快指针先走k步,然后快慢指针一起移动,当快指针遍历到末尾,慢指针正好在倒数第k个节点上,删除即可
"""
from Linklist.utils import *
def remove_k_th_from_... |
510499c97a353ae97df9ef7e3e0eae96dd2f382f | williamsyb/mycookbook | /algorithms/BAT-algorithms/Array & String/L_Two sum - 有序数组.py | 993 | 3.90625 | 4 | """
题目:
在有序数组中找出两个数,使它们的和为 target。
思路: 双指针
使用双指针,一个指针指向值较小的元素,一个指针指向值较大的元素。
指向较小元素的指针从头向尾遍历,指向较大元素的指针从尾向头遍历。
遍历过程:
* 如果两个指针指向元素的和 sum == target,那么得到要求的结果;
* 如果 sum > target,移动较大的元素,使 sum 变小一些;
* 如果 sum < target,移动较小的元素,使 sum 变大一些。
"""
def two_sum(nums, target):
size = len(... |
97e8fbbb1cb7c4751ccd8fc65695ec3e2ac7f9f3 | williamsyb/mycookbook | /algorithms/BAT-algorithms/Array & String/L_除自身以外数组的乘积.py | 1,121 | 3.53125 | 4 | """
题目:
给定长度为 n 的整数数组 nums,其中 n > 1,返回输出数组 output ,
其中 output[i] 等于 nums 中除 nums[i] 之外其余各元素的乘积。
示例:
输入: [1,2,3,4]
输出: [24,12,8,6]
说明: 请不要使用除法,且在 O(n) 时间复杂度内完成此题。
思路:
本题难点在于 不许使用除法。
其中 output[i] 等于 nums 中除 nums[i] 之外其余各元素的乘积,
即 output[i] = nums[0] * nums[1] * ... * nums[i-1] * nums[... |
6431a97ffaebaccd2552886ade7d1cb3e1f1a1ad | williamsyb/mycookbook | /algorithms/BAT-algorithms/Array & String/L_最小移动次数使数组元素相等.py | 2,083 | 3.984375 | 4 | """
题目:
给定一个非空整数数组,找到使所有数组元素相等所需的最小移动数,
其中每次移动可将选定的一个元素加1或减1。 您可以假设数组的长度最多为10000。
例如:
输入:
[1,2,3]
输出:
2
说明:
只有两个动作是必要的(记得每一步仅可使其中一个元素加1或减1):
[1,2,3] => [2,2,3] => [2,2,2]
思路:
要想将数组中所有元素都移动为相同的,而且总移动步数还得最小。必须将所有的数往数组的"中位数"移动.
[将所有数往“平均数”移动的想法是错误,平均值容易受到异常... |
706ad16847e812a429f5c26d941a68454f7311ae | williamsyb/mycookbook | /algorithms/BAT-algorithms/Tree/遍历-层次遍历.py | 1,199 | 3.953125 | 4 | """
一、题目
按层次的遍历的方法打印一颗树
例如有如下一棵树:
5
/ \
3 6
/ \ \
2 4 7
打印结果是
5 3 6 2 4 7
二、思路
层次遍历的步骤是:
对于不为空的结点,先把该结点加入到队列中
从队中拿出结点,如果该结点的左右结点不为空,就分别把左右结点加入到队列中
重复以上操作直到队列为空
"""
class TreeNode:
def __init__(self, x):
self.val = x
self.lef... |
89ac7d2b6a35ce2b06c093108b54968f5c026bf5 | williamsyb/mycookbook | /设计模式/singleton02.py | 637 | 3.578125 | 4 | from threading import Thread, Lock
class Singleton(type):
def __init__(cls, *args, **kwargs):
super().__init__(*args, **kwargs)
cls.__instance = None
def __call__(cls, *args, **kwargs):
if cls.__instance is None:
cls.__instance = super().__call__(*args, **kwargs)
r... |
54fc0546510cf9478ab6d933fb1496e886c9d40e | williamsyb/mycookbook | /algorithms/BAT-algorithms/Array & String/S_循环左移.py | 300 | 3.546875 | 4 | """
*例如将abcdef循环左移2位得到 cdefab
*思路:转置 (X’Y')' = YX
* "abcd"[::-1] = "dcba"
"""
def left_roatet_str(str1, m):
return ((str1[0:m])[::-1] + (str1[m:])[::-1])[::-1]
if __name__ == '__main__':
str1 = "abcdef"
print(left_roatet_str(str1, 2))
|
b80078fddc12095b80f7f3c9b99c3905ca1926b5 | williamsyb/mycookbook | /thread_prac/cond2.py | 1,348 | 3.71875 | 4 | import time
from threading import Thread, Condition
li = list(range(1, 101))
cond = Condition()
class Consumer01(Thread):
def __init__(self, name, nums, con):
Thread.__init__(self)
self.name = name
self.nums = nums
self.con: Condition = con
def consumer(self):
self.co... |
5e18167771713cf6b16b8d21f1bd61d8bf33dbb7 | williamsyb/mycookbook | /algorithms/BAT-algorithms/Tree/二叉查找树-从有序链表构造平衡的二叉查找树.py | 1,886 | 4 | 4 | """
一、题目
给定一个单链表,其中的元素按升序排序,将其转换为高度平衡的二叉搜索树。
本题中,一个高度平衡二叉树是指一个二叉树每个节点 的左右两个子树的高度差的绝对值不超过 1。
二、思路
递归大法
利用二分查找的思路,二分建树。
二分的中点是根节点(相对而言的,每个子树都有根节点),左边的序列建立左子树,右边的序列建立右子树
三、本题与“从有序数组中构建二叉查找树”的整体思路是一样的
只是单链表无法直接获得中间节点,必须通过顺序遍历才能得到mid位置的节点。
遍历的方法是用“快慢指针”: 快指针每走两步,慢指针只走1步,这样快指针走到重点时,慢指针在中间。
... |
5938614ce9d3181ed59c2e56e4df3adaa17ab91b | williamsyb/mycookbook | /algorithms/BAT-algorithms/Math/判断一个数是否为两个数的平方和.py | 735 | 4.1875 | 4 | """
题目:
判断一个数是否是两个数的平方和
示例:
Input: 5
Output: True
Explanation: 1 * 1 + 2 * 2 = 5
思路: 双指针
本题是要判断一个数是否等于两个数的平方和 <=等价=> 在自然数数组中,是否存在两个数的平方和是否等于一个数。
所以本题的思路与 “/数组/Two sum - 有序数组”基本一致。
"""
def judge_square_sum(c):
start = 0
end = int(c ** 0.5)
while start <= end:
temp = start... |
ee1e7bff3095782f4886eeefc0558543c091ddc6 | williamsyb/mycookbook | /thread_prac/different_way_kill_thread/de04.py | 1,153 | 4.59375 | 5 | # Python program killing
# a thread using multiprocessing
# module
"""
Though the interface of the two modules is similar, the two modules have very different implementations.
All the threads share global variables, whereas processes are completely separate from each other.
Hence, killing processes is much safer as co... |
f1a08050859a649f0dd7c647078aa1dbfbc0c8b2 | case112/Python_TH | /Beginner/Collections/dungeon_game.py | 9,192 | 3.75 | 4 | # P, but the monster, the door, and the shrine (explained below) are displayed also as M, D, and S respectively.
#The player and monster hp are displayed as numbers, and their hp bars are displayed as Xs and Ys respectively which decrease every -20 hp.
#If the player makes an invalid move, they lose 5 hp.
#If the playe... |
ef74e743d39e57a7540994194602bc0bacb1bd8f | case112/Python_TH | /Beginner/Object_oriented/instances.py | 358 | 3.84375 | 4 | my_list = ["apple", 5.2, "dog", 8]
def combiner(my_list):
strlist = ""
numlist = 0
for items in my_list:
if isinstance(items, str):
strlist += items
else:
numlist += items
print(strlist + str(numlist) )
return strlist + str(numlist)
... |
c8784ad04cef958ae1284cd4ab5d23100a1bc2e7 | case112/Python_TH | /Beginner/Collections/out_of_this_word.py | 2,500 | 4.09375 | 4 | import random
import os
WORDS = (
"treehouse",
"python",
"learner")
def prompt_for_words(challenge):
guesses = set()
print("What words can you find in the word '{}'".format(challenge))
print("(Enter Q to Quit)")
while True:
guess = input("{} words >. ".format(len(guesses)))
... |
e0d1a2a1d9c3bed6d3cecff4a4383e3783c6f6ff | PatMulvihill/MachineLearning-FinancialData | /strategy_learner/StrategyLearner.py | 9,600 | 3.578125 | 4 | """
Template for implementing StrategyLearner (c) 2016 Tucker Balch
"""
"""Author: Lu Wang, lwang496, lwang496@gatech.edu"""
import datetime as dt
import pandas as pd
import util as ut
import random
import numpy as np
import QLearner as ql
class StrategyLearner(object):
# constructor
# Author: Lu Wang lwang... |
14310f84092b572c9b47ea71b2237dc8941c298f | Imsurajkr/Cod001 | /demo_tuples.py | 121 | 3.890625 | 4 | a = b = c = d = 12
print(c)
a, b = 12 , 13
print(a, b)
a, b = b, a
print(" a is {}".format(a))
print("b is {}".format(b)) |
353a3606af9aa9b5c5065edaa2e35d88f9e8ec5f | Imsurajkr/Cod001 | /challenge2.py | 662 | 4.1875 | 4 | #!/usr/bin/python3
import random
highestNumber = 10
answer = random.randint(1, highestNumber)
print("Enter the number betweeen 1 and {}".format(highestNumber))
guess = 0 #initialize to any number outside of the range
while guess != answer:
guess = int(input())
if guess > answer:
print("please Select Lo... |
2b779a564d313cb62050b8447f610aef98a6a91f | BobbyAD/Intro-Python-II | /src/player.py | 1,590 | 3.671875 | 4 | # Write a class to hold player information, e.g. what room they are in
# currently.
from item import Item
class Player:
def __init__(self, name, current_room, items):
self.name = name
self.current_room = current_room
self.items = items
def move(self, d):
if d == 'n' and sel... |
6ca787eac5185c966f539079a8d2b890d9dc6447 | OldPanda/The-Analysis-of-Algorithms-Code | /Chapter_2/2.4.py | 897 | 4.15625 | 4 | """
Random Hashing:
Data structure: a key array X with entries x_i for 0 <= i <= N-1 and a corresponding record array R.
Initial conditions: the number of entries, k, is zero and each key location, x_i, contains the value empty, a special value that is not the value of any key.
Input: a query, q.
Output: a loca... |
a151b862cce83b1f7b7065ba389b4d78ba546e59 | OldPanda/The-Analysis-of-Algorithms-Code | /Chapter_2/2.2.py | 1,185 | 3.640625 | 4 | """
Quicksort:
Input: bound l and r, and an array X with elements x_l-1, ..., x_r+1 where l <= r anf for l <= i <= r, x_l-1 <= x_i <= x_r+1.
Output: a sorted permutation of the array X so that for l-1 <= i <= r, x_i <= x_i+1.
"""
import random
"""
Split:
Input: an array X, a lower limit l, and an upper limit r... |
2ca5b9fd677edf64a50c6687803c91b721bee140 | basakmugdha/Python-Workout | /1. Numeric Types/Excercise 1 (Number Guessing Game)/Ex1c_word_GG.py | 848 | 4.375 | 4 | #Excercise 1 beyond 3: Word Guessing Game
from random_word import RandomWords
def guessing_game():
'''returns a random integer between 1 and 100'''
r = RandomWords()
return r.get_random_word()
if __name__ == '__main__':
print('Hmmmm.... let me pick a word')
word = guessing_game()
gu... |
08ea076be472f843395a37dd56c02885a0072c8c | danebista/Python | /Roshan/5.1.py | 392 | 3.78125 | 4 | import time
running=True
start_time=time.time()
print("start_time{}".format(start_time))
while running:
now_time=time.time()
print("now_time{}".format(now_time))
second_depends=now_time-start_time
print("second_depends{}".format(second_depends))
if second_depends==3:
start_time=now_time
... |
942d67e9bbad4dc5a890de12ef0317b6af4f571f | danebista/Python | /suzan/python3.py | 2,143 | 4.1875 | 4 | #!/usr/bin/env python
# coding: utf-8
# Print formatting
# In[1]:
print ("hurry makes a bad curry")
# In[3]:
print("{1} makes a bad {0}".format("curry","hurry"))
# In[7]:
print("The {e} rotates {a} a {s}".format(e="Earth",a="around",s="Sun"))
# In[8]:
result=9/5
print(result)
# In[9]:
result=100/3
p... |
1ac4b7c404234ef0dc0f1051a7f35308eac85a3d | danebista/Python | /avni/sun.py | 1,038 | 3.90625 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[4]:
for i in range(10):
pass
# In[3]:
for i in range(10):
# In[6]:
for i in range(10):
print(i)
if i==5:
break
# In[8]:
for i in range(10):
if i==5:
continue
print(i)
# Methods vs functions
# In[13]:
a="Ram has a cat"
def... |
56b146eba5579b568901fa1d51d5a494bff47067 | sragha45/helloworld | /p5.py | 233 | 3.90625 | 4 | a=raw_input("Enter number 1:")
b=raw_input("Enter number 2:")
c=raw_input("Enter number 3:")
a = int(a)
b = int(b)
c = int(c)
max=max(a,b,c)
min=min(a,b,c)
num=a+b+c-max-min
print "Descending order is:"
print(max,num,min)
|
804334a8092fd0965ccd8f2455eaed0d27e66ce6 | wso0622/euler1 | /euler1.py | 98 | 3.9375 | 4 | sum =0
for n in range (1, 1000):
if(n%3==0 or n%5==0):
sum += n
print("Sum is", sum)
|
d4751911223fca2a2f47016042b3577af85cd8ba | mouse-pallet/SamplePython | /Exercize10-1.py | 349 | 3.703125 | 4 | class Player:
def __init__(self,name,age,height):
self.age=age
self.name=name
self.height=height
def IncreaseAge(self):
self.age+=1
def PrintInformation(self):
print("This is {0}, he is {1} years old and {2} cm.".format(self.name,self.age,self.height))
player1=Player("Jhon",20,170)
player1.IncreaseAge(... |
68413a9d21e272156d72d840d0e81dfb35676a42 | mouse-pallet/SamplePython | /ForSample2.py | 154 | 4.1875 | 4 | #reverse
l=['hola','Hello','konnitiwa','hallo']
for element in reversed(l):
print(element)
quit()
for i in range(len(l)-1,-1,-1):
print(l[i])
|
f4a8308ad335b1f4e046cf9599012a099955649f | Manasa0704/Codeforces | /133A.py | 146 | 3.921875 | 4 | s=str(raw_input())
#s='Hi!'
i=0
while i<len(s):
if(s[i]=='H' or s[i]=='Q' or s[i]=='9'):
print 'YES'
exit()
else:
i+=1
print "NO" |
272d55e87dbf0a84d33c97647bc55c660b4a6476 | manuhon99/ise | /mongodbConnection.py | 702 | 3.546875 | 4 | '''
Connection data to MongoDB using pymongo lib
'''
import os
from pymongo import MongoClient
def connect_mongo(data, collection, content):
# Making Connection
myclient = MongoClient("mongodb://localhost:27017/")
# database
db = myclient[data]
# Created or Switched to collection
Co... |
125fbbd64d07295817c621b11d4dcb1ad154933b | staminazhu/Scientific-Software-Development-with-Fortran | /old stuff/forpedo/forpedo.py | 8,487 | 3.875 | 4 | #!/usr/bin/env python
import sys
import re
#----------------------------
# General functions
#----------------------------
def combine(*seqin):
"""
Returns a list of all combinations of argument sequences.
For example: combine((1,2),(3,4)) returns [[1, 3], [1, 4], [2, 3], [2, 4]]
"""
... |
5ca81d67c844790fecb6b4636164094e30975d49 | AaayushUpadhyay/python-modules | /Python Tutorial-CSV Module/parse_csv.py | 3,135 | 4.40625 | 4 | # CSV - Comma Separated Values
import csv
# Reading a csv file
# with open('names.csv','r') as csv_file:
# csv_reader=csv.reader(csv_file)
# # .read() return a generator so we have to loop over it
# for line in csv_reader:
# print(line)
# OUTPUT
# ['first_name', 'last_name', 'email']
# ['John', 'Doe', 'john-doe@... |
161e3cbfae915c638f02659e5d93867e465fef06 | nguyenduchuy2017/2017-07-11 | /homework/list_HW-1.py | 440 | 3.75 | 4 | lst_1 = [1, 2, 3, [1, 2], 2, [1, [1, 3]], 20]
print(lst_1)
str_1 = str(lst_1) # Convert to String
str_2 = str_1.replace('[', '') # Delete all unneeded symbols
str_3 = str_2.replace(']', '')
str_4 = str_3.replace(',', '')
str_5 = str_4.replace(' ', '')
lst_3 = [] # Convert "stri... |
04e2d90d3a1e4f801f5885325eea7fdb2f612039 | nguyenduchuy2017/2017-07-11 | /homework/Cross_and_None_game.py | 3,214 | 4.125 | 4 | num_of_rows = int(input('Enter the quantity of rows(colums) :'))
player_1 = input('Player 1, Please, enter your name: ')
player_2 = input('Player 2, Please, enter your name: ')
game_board_coord = {}
GBC = game_board_coord
max_number_way = num_of_rows**2
ways_counter = 0
def game_board_init(num_of_rows):
for x in ra... |
c974e04a9696599ccd0f5efb7dee095163fb1aa3 | RagibRishad/PythonBook | /Chapter2/6.1.py | 121 | 3.625 | 4 |
de main():
y1 = eval(input("amount for yr 1: "))
ir = eval(input("interest: "))
yrs = eval(input("yrs: "))
|
378b15e29b0492c03cdeb813fa8e044dad1185dc | RagibRishad/PythonBook | /Chapter 3/3.6.py | 174 | 3.734375 | 4 |
# 2 points are (x1, y1) and (x2, y2)
def main():
x1 = 5
y1 = 6
x2 = 8
y2 = 9
slope = (y2 - y1)/(x2 - x1)
print("Slope is ", round(slope))
main() |
b5b486ef157b0258d81c58cfef9030821116f318 | kseil/mycode | /mix-list/mixlist01.py | 444 | 3.953125 | 4 | #!/usr/bin/env python3
#make list
my_list=["192.168.0.5", 5060, "UP"]
#print item one from list
print("The first item in the list (IP): " + my_list[0])
#print item two from list
print("The second item in the list (port): " + str(my_list[1]))
#print item three from list
print("The last item in the list (state): " + my... |
96a224d99ebd76fa959e27363cb1a10ebc54f44b | kseil/mycode | /morningproject.py | 165 | 3.8125 | 4 | #!/usr/bin/env python3
items = ['biscuit', 'bed', 'desk', 'biscuit', 'books', 'computer', 'biscuit']
for i in items:
if i == 'biscuit':
print("SLAP!")
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.