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 |
|---|---|---|---|---|---|---|
0ce4545342bbe298c2abb56c4d1939d34fdb824f | edu-athensoft/ceit4101python | /stem1400_modules/module_4_function/func4_yield/yield_1.py | 142 | 3.703125 | 4 | """
yield
"""
def func():
for i in range(0, 3):
yield i
f = func()
print(f.__next__())
print(f.__next__())
print(f.__next__()) |
25c1b1b7ab2738efe423189b11c2f3c135268f32 | edu-athensoft/ceit4101python | /stem1400_modules/module_6_datatype/m6_5_set/set_enumerate.py | 303 | 3.578125 | 4 | grocery = ['bread', 'milk', 'butter']
enumerateGrocery = enumerate(grocery)
print(type(enumerateGrocery))
print(enumerateGrocery)
my_list = list(enumerateGrocery)
print(my_list)
print(my_list[0])
# changing the default counter
enumerateGrocery = enumerate(grocery, 10)
print(list(enumerateGrocery)) |
44620a6014a1bbec50a5a9878da6e1e262e59058 | edu-athensoft/ceit4101python | /stem1400_modules/module_4_function/old/demofunc4.py | 142 | 3.71875 | 4 | def absolute_value(num):
if num >= 0:
return num
else:
return -num
print(absolute_value(1))
print(absolute_value(-1)) |
81f23308aec6009c2e7382690b07644e1cd94a27 | edu-athensoft/ceit4101python | /stem1400_modules/module_6_datatype/m6_2_list/list11_sort.py | 459 | 4.0625 | 4 | # list sorting
my_list = ['p','r','o','g','r','aa','m','i','z','ab']
my_list.sort()
print(my_list)
my_list = ['p','R','A','g','r','aa','m','i','r','ab']
my_list.sort()
print(my_list)
my_list = [4,5,76,7,2,6,8,0]
my_list.sort()
print(my_list)
# my_list = [3,'a',2,'c',1,'b'] # TypeError
# my_list.sort()
# print(my_l... |
d03226e337324a01aa5fe362274e19bb427cb84e | edu-athensoft/ceit4101python | /stem1400_modules/module_9_datetime/s91_datetime/s6_formatting/datetime_2_str2datetime.py | 241 | 3.578125 | 4 | """
1.6.2 strptime() - string to datetime
"""
from datetime import datetime
date_string = "21 June, 2018"
print("date_string =", date_string)
date_object = datetime.strptime(date_string, "%d %B, %Y")
print("date_object =", date_object)
|
b3efbaa6ed31b820bbae8c9c101736af4d83060a | edu-athensoft/ceit4101python | /stem1400_modules/module_3_flowcontrol/c2_for/forloop_4.py | 319 | 3.9375 | 4 | # get the summary of a number list
"""
round 0: numbers[0]+ sum -> sum
round 1: numbers[1]+ sum -> sum
...
round i: numbers[i]+ sum -> sum
...
round 9: numbers[9]+ sum -> sum
get sum
"""
numbers = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
sum = 0
for item in numbers:
sum += item
print("sum=",sum)
|
40ca519174301d11d283c21c313ec9e8be9f629f | edu-athensoft/ceit4101python | /demo/demo_game/genshin/genshinimpact.py | 3,075 | 3.8125 | 4 | """
"""
class Item:
def __init__(self, point, quantity):
self.point = point
self.quantity = quantity
def totalpoints(self):
return self.point * self.quantity
def getqty(self):
return self.quantity
def getpoint(self):
return self.point
class A(Item):
de... |
ab4993ef43f06fb461be841906b9789cf277bae7 | edu-athensoft/ceit4101python | /stem1400_modules/module_6_datatype/m6_4_string/string_demo/string_18_istitle.py | 300 | 4 | 4 | """
istitle()
returns True if the string is a titlecased string.
If not, it returns False.
"""
s1 = 'Python Is Good.'
print(s1.istitle())
s1 = 'Python is good.'
print(s1.istitle())
s = 'This Is @ Symbol.'
print(s.istitle())
s = '99 Is A Number'
print(s.istitle())
s = 'PYTHON'
print(s.istitle()) |
a37e62a02424d25811b8844cba80fa52198a655e | edu-athensoft/ceit4101python | /evaluate/evaluate_1_exercise/m9_datetime/question_7.py | 647 | 4.03125 | 4 | """
Write a Python program to get a week number of a year with a given date.
Sample Date : 2015, 6, 16
Expected Output : 25
https://stackoverflow.com/questions/2600775/how-to-get-week-number-in-python
datetime.date has a isocalendar() method, which returns a tuple containing the calendar week
In Python 3.9+ isocalend... |
389fe33a194dba13625e6e18203f9618ddd18e98 | edu-athensoft/ceit4101python | /stem1400_modules/module_10_gui/s04_widgets/s0406_scale/scale_01.py | 736 | 4.0625 | 4 | """
Scale
basic usage of Scale
get value via Scale object
"""
from tkinter import *
def printValue():
print("print value 1",scale1.get())
def printValue2():
print("print value 2",scale2.get())
# main program
root = Tk()
root.title("Python GUI - Scale")
root.geometry("640x480")
# label
label = Label(ro... |
0e5ff42c431e410a319b60bfd342a3132b128d59 | edu-athensoft/ceit4101python | /stem1400_modules/module_12_oop/old/s1_class_instance/myclass2.py | 398 | 3.640625 | 4 | # define a class
# create instance
class Employee:
pass
emp1 = Employee()
emp2 = Employee()
print(emp1)
print(emp2)
emp1.first = "Athens"
emp1.last = "Zhang"
emp1.email = "athens314@hotmail.com"
emp1.pay = 90000
emp2.first = "Lada"
emp2.last = "Zhang"
emp2.email = "lada314@gmail.com"
emp2.pay = 96300
emp2.a... |
c62f384b9f938f4ff0fcc96d8aec20ac81af479e | edu-athensoft/ceit4101python | /stem1400_modules/module_6_datatype/m6_7_array/array_2_add.py | 725 | 4.21875 | 4 | """
Python array
Adding Elements to a Array
typecodes = 'bBuhHiIlLqQfd'
souce: https://www.geeksforgeeks.org/python-arrays/
"""
import array as arr
a = arr.array('i', [1, 2, 3])
print("Array before insertion : ", end=" ")
for i in range(0, 3):
print(a[i], end=" ")
print()
# inserting array using
# insert() fu... |
841f27bafffc23c57df8d9dcf096fc1a0c1f2c86 | edu-athensoft/ceit4101python | /stem1400_modules/module_6_datatype/m6_2_list/list16_count_num.py | 110 | 3.578125 | 4 | """
count numbers
"""
my_list = ['p', 'R', 'A', 'g', 'r', 'a', 'm', 'i', 'r', 'a']
print(my_list.count('a')) |
13f90032c463121cc3494f8d168ae637ca43ebbb | edu-athensoft/ceit4101python | /stem1400_modules/module_6_datatype/m6_4_string/string_demo/string_11_isdecimal.py | 558 | 4.3125 | 4 | """
string method - isdecimal()
True - if all characters in the string are decimal characters.
False - if at least one character is not decimal character.
"""
str1 = "1234556"
print(str1.isdecimal())
str1 = "-1234556"
print(str1.isdecimal())
str1 = "123.4556"
print(str1.isdecimal())
str1 = "123abc"
print(str1.isde... |
e73de6158e3b31f0806f32c2286dd181688a96c5 | edu-athensoft/ceit4101python | /stem1400_modules/module_12_oop/old/intro/app2.py | 492 | 3.703125 | 4 | from oop.intro.Question import Question
question_prompt = [
"sadfasdfas1",
"asdfasdfa2",
"kjsdjfasjdf3"
]
questions = [
Question(question_prompt[0],"a"),
Question(question_prompt[1],"b"),
Question(question_prompt[2],"c")
]
def run_test(questions):
score = 0
for q in questions:
... |
3b9d9a78cbbb8696f5b0b466a85c4eabfb90b356 | edu-athensoft/ceit4101python | /stem1400_modules/module_7_exception/builtin_error_3_eof.py | 213 | 3.75 | 4 | """
built-in error
EOFError
press Ctrl+D to generate an EOFError
"""
# n = int(input())
# print(n * 5)
try:
n = int(input())
print(n * 5)
except EOFError as e:
print(e)
# EOF when reading a line
|
a6ac299c82f57ddd2e84f6c72c0b6cbee52355e6 | edu-athensoft/ceit4101python | /evaluate/evaluate_1_exercise/m9_datetime/question_10.py | 209 | 4.03125 | 4 | """
Write a Python program to convert a string to datetime.
datetime.strptime()
"""
from datetime import datetime
date_object = datetime.strptime('Jul 1 2014 2:43PM', '%b %d %Y %I:%M%p')
print(date_object)
|
0b016c5325431ae9917bdbe5839355adc5a6d370 | edu-athensoft/ceit4101python | /stem1400_modules/module_10_gui/s04_widgets/s0403_entry/entry_08_textvariable.py | 818 | 3.5 | 4 | """
textvariable
change value of Entry by set()
reference: https://blog.csdn.net/weixin_42272768/article/details/100592533
"""
from tkinter import *
def set_entry():
content1 = txt.get()
print("text at original entry = ",content1)
txt2.set(content1)
root = Tk()
root.title("Python GUI - Entry")
root... |
78af616cc5ff2c67633699e6b6cb6f0a55111b77 | edu-athensoft/ceit4101python | /stem1400_modules/module_10_gui/s07_event/s074_misc/bind_multi_event.py | 405 | 3.578125 | 4 | """
Binding multiple events
"""
from tkinter import *
def click1():
print("1. Command event handler")
def click2(event):
print("2. Bind event handler")
root = Tk()
root.title("Event Handling | Unbind")
# root.geometry("640x480")
btn = Button(root, text="Multiple Events", command=click1)
btn.pack(anchor=... |
36e3f7a4d3cc8ea07a32d17479e4163ca68519d4 | edu-athensoft/ceit4101python | /stem1400_modules/module_8_fileio/filedir_5_dir_list.py | 345 | 3.65625 | 4 | """
python dir
Changing Directory
"""
import os
d1 = os.getcwd()
print(d1)
# change dir
os.chdir('/')
# case 1. list in current direction
dirlist = os.listdir()
print(dirlist)
# case 2. list in specified direction
sourcedir = 'D:\\workspace\\pycharm201803\\ceit4101python\\module_8_fileio'
dirlist = os.listdir(sou... |
d7b03b7b99702e4b3723737743de3188aefabb3d | edu-athensoft/ceit4101python | /evaluate/evaluate_1_exercise/m6_random/password_generator_2.py | 720 | 3.921875 | 4 | """
password generator
"""
import string
import random
def get_valid_chars():
LETTERS = string.ascii_letters
DIGITS = string.digits
SYMBOLS = string.punctuation
# removing quote, and double quote
SYMBOLS = SYMBOLS.replace('\'', '')
SYMBOLS = SYMBOLS.replace('\"', '')
return LETTERS + ... |
c7af5a07c4e7a160465fe50fed32c1f63aca7a56 | edu-athensoft/ceit4101python | /stem1400_modules/module_4_function/old/demofuncarg1.py | 228 | 3.515625 | 4 | def greet(name,msg):
"""This function greets to
the person with the provided message"""
print("Hello",name + ', ' + msg)
# greet("Monica")
# greet("Monica","Good morning!")
greet()
# greet("Monica","Good morning!")
|
2262a62aaf3645f863af9aa1ad349894473f5bfe | edu-athensoft/ceit4101python | /stem1400_modules/module_13_adv_features/adv_03_decorator/func_7_decor.py | 499 | 3.78125 | 4 | """
decorator with parameters
2.4.1.5 Decorators
Decorators can accept their own attributes
"""
def mydecor(myparam):
def wapper(myfunc):
def inner_wapper(*args, **kwargs):
print("before " + str(myparam))
myfunc(*args, **kwargs)
print("after")
return inner_wap... |
efa832f38aeb306d6c721ba97ab39cc0746ff6c2 | edu-athensoft/ceit4101python | /stem1400_modules/module_3_flowcontrol/c2_for/forloop_5_nested.py | 946 | 4.25 | 4 | # print out a matrix
"""
out put like
11,12,13
21,22,23
31,32,33
(11,12,13)
(21,22,23)
(31,32,33)
matrix = ((11,12,13),(21,22,23),(31,32,33))
loop for each row
round 0: (11,12,13) -> row 0 -> matrix[0]
Loop for each column
round 0: 11 -> matrix[0][0]
round 1: 12 -> mat... |
9d2713c81854199a30e3aca05079683b790e075d | edu-athensoft/ceit4101python | /stem1400_modules/module_4_function/func1_define/function_5_howitworks.py | 251 | 4.0625 | 4 | """
how does a function work?
"""
def foo1():
print("1111")
print("1112")
print("1113")
print("1114")
print("1115")
a = 1
b = a+1
print(b)
return b
print("== start ===")
result = 0
foo1()
print("== end ===")
|
a5c1e519472946bf4fa0f8102410071ff3135f9f | edu-athensoft/ceit4101python | /stem1400_modules/module_13_adv_features/adv_03_decorator/func_13_decor_class.py | 187 | 3.890625 | 4 | """
"""
class Car:
def __init__(self, VIN):
self.mileage = 0
self.VIN = VIN
car = Car('ABC123')
print('The mileage is', car.mileage)
print('The VIN is', car.VIN)
|
4543ea3f1dc6e723d7dfc265b3fe856dc787f186 | edu-athensoft/ceit4101python | /stem1400_modules/module_14_regex/s3_re/regex_9_search.py | 266 | 4.1875 | 4 | """
regex
"""
import re
mystr = "Python is fun"
pattern = r'\APython'
# check if 'Python' is at the beginning
match = re.search(pattern, mystr)
print(match, type(match))
if match:
print("pattern found inside the string")
else:
print("pattern not found")
|
82f0f9d3939afe24a0cc64df773f8e38d07c9d64 | edu-athensoft/ceit4101python | /stem1400_modules/module_14_regex/s3_re/regex_2.py | 347 | 3.90625 | 4 | """
regex
re.findall()
Calculating average score
"""
import re
mystr = """
zhangsan 100
lisi 90
wangwu 80
zhaosi 85
"""
pattern = r"\d+"
results = re.findall(pattern, mystr)
total = 0
for item in results:
print(item)
total += int(item)
num = len(results)
print(f"total is {total}")
avg = total/num
print(f... |
4e0a528f06a8d9dfc52991ef8fcfcfe8131cda4b | edu-athensoft/ceit4101python | /stem1400_modules/module_12_oop/oop_08_encapslution/demo2_house/house.py | 864 | 3.875 | 4 | """
project: Just moved in
"""
class House:
def __init__(self, house_type, area):
self.house_type = house_type
self.area = area
self.free_area = area # no need to pass
self.item_list = [] # no need to pass
def __str__(self):
s = "House information:\n" \
... |
ce0daf0a0df9a4c9a1381698976eb2577221015e | edu-athensoft/ceit4101python | /stem1400_modules/module_10_gui/s04_widgets/s0401_label/label_9_bitmap_list.py | 775 | 3.796875 | 4 | """
Tkinter
place a label widget
bitmap
display all built-in bitmaps
"""
from tkinter import *
root = Tk()
root.title('Python GUI - Label bitmap')
root.geometry("{}x{}+200+240".format(640, 480))
root.configure(bg='#ddddff')
label1 = Label(root, bitmap='error')
label2 = Label(root, bitmap='hourglass')
label3 =... |
7f56bbfd9bfd0e842a14ed50f045dba45a0957ec | edu-athensoft/ceit4101python | /stem1400_modules/module_2_basics/c7_2_output_formatting/output_formatting.py | 258 | 4 | 4 | print('I love {0} and {1}'.format('bread','butter'))
# Output: I love bread and butter
print('I love {1} and {0}'.format('bread','butter'))
# Output: I love butter and bread
print('Hello {name}, {greeting}'.format(greeting = 'Goodmorning', name = 'John'))
|
0d3f250ba8d881ab75e3f043e905ec3425424496 | edu-athensoft/ceit4101python | /evaluate/evaluate_2_quiz/stem1401_python1/quiz313/q6.py | 1,290 | 4.4375 | 4 | """
Quiz 313
q6
A computer game company is developing a 3A-level role-playing game.
The character you are controlling will receive equipment items of
different tiers while adventuring in the big world. The system will
display different background and text colors according to the level
of the item to distinguish them. ... |
87fad677dc1b5e09dd3e3f8e04b06b1c72173360 | edu-athensoft/ceit4101python | /stem1400_modules/module_2_basics/c6_type_convertion/literal_special.py | 121 | 3.5625 | 4 | # literal special
# None
food = None
print(food)
# test None equals to another None?
a1 = None
a2 = None
print(a1==a2) |
5ff8ad92fce6386d8bb162b2b2c4030d4de66a5c | fish-ball/Codeforces | /0059A.py | 188 | 3.53125 | 4 | # Too simple..
import sys
s = sys.stdin.readline().strip()
cnt = 0
for c in s:
if c.isupper():
cnt += 1
else:
cnt -= 1
print(s.upper() if cnt > 0 else s.lower()) |
6a25fcdcf35289253e56969d8bf52a7245bf8e03 | fish-ball/Codeforces | /0343B.py | 145 | 3.65625 | 4 | l = []
for c in input():
if len(l) > 0 and l[-1] == c:
l.pop()
else:
l.append(c)
print('Yes' if len(l) == 0 else 'No')
|
8190aaf6b7bd8b5a130757fcd5587f8208044104 | C-milo/georgian-data-programing | /midTerm/question27.py | 606 | 3.890625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jun 20 19:11:30 2019
@author: akmil
"""
'''
Create an iPython notebook, answer the following question and upload the notebook.
A Prime Number is: a whole number that cannot be made by multiplying other whole numbers.
Create a python class to count the number of prime numbe... |
5c29b88507b575a06887bc7998b35a73889f455d | C-milo/georgian-data-programing | /Assignment5/sqllite_exercise.py | 3,606 | 3.953125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Jun 17 19:39:15 2019
@author: Nuthan
"""
'''
Using Python and SQLite (or SQL server if you desire) create a groups database
Create two tables one that contains the names and IDs of your group members and one that contains course names and course IDs
Create a one to many rela... |
19ce2d7d5d89a9473e464b0e3eb8bf04dd4976c5 | Mart1nDimtrov/Math-Adventures-with-Python | /05. Transforming Shapes with Geometry/color_grid/color_grid.pyde | 760 | 3.859375 | 4 | def setup():
size(600,600)
colorMode(HSB)
# draw a colorful interactive grid
def draw():
background(0)
for x in range(0,20):
for y in range(0,20):
d = dist(30*x,30*y,mouseX,mouseY)
fill(0.5*d,255,255)
rect(x*30,y*30,25,25)
# draw a colorful gri... |
92d6114c1a38dc82151a67729905a625ef3f18ff | Mart1nDimtrov/Math-Adventures-with-Python | /01. Drawing Polygons with the Turtle Module/triangle.py | 373 | 4.53125 | 5 | # exerCise 1-3: tri anD tri again
# Write a triangle()
# function that will draw a triangle of a given “side length.”
from turtle import *
# encapsulate with a function
def triangle(sidelength=100):
# use a for loop
for i in range(3):
forward(sidelength)
right(120)
# set speed and shape
shape... |
05f95a558ed67f71db5d9a56da4313ea87a45eba | Mart1nDimtrov/Math-Adventures-with-Python | /04. Transforming and Storing Numbers with Algebra/plug.py | 155 | 3.90625 | 4 | def plug():
'''Find the number x the solves the equation'''
for num in range(-100,101):
if (num * 2) + 5 == 13:
print(f"x: {num}")
print(plug())
|
c0b4d3e1ba76eeb61873cbae879f2906d86a33c6 | Mart1nDimtrov/Math-Adventures-with-Python | /02. Making Tedious Arithmetic Fun with Lists and Loops/string_operations.py | 158 | 3.78125 | 4 | message = "hello"
# multiply
print(message*4)
# add
print(message+message)
# compare
print(message==message)
print(message>message)
print(message<=message) |
fe80157b84f5c3ed5aa7e228e59594882fc24589 | Mart1nDimtrov/Math-Adventures-with-Python | /07. Complex Numbers/complex.py | 457 | 3.921875 | 4 | from math import sqrt
def cAdd(a,b):
'''Returns the sum of two complex numbers'''
return [a[0]+b[0],a[1]+b[1]]
def cMult(u,v):
'''Returns the product of two complex numbers'''
return [u[0]*v[0]-u[1]*v[1],u[0]*v[1]+u[1]*v[0]]
def magnitude(z):
return sqrt(z[0]**2 + z[1]**2)
u = [1,2]
v = [3,4]
print(cAdd(u,v... |
53be109056c5c79f883c3c8f8988ebf27c8f4199 | Mart1nDimtrov/Math-Adventures-with-Python | /08. Using Matrices for Computer Graphics and Systems of Equations/gauss.py | 1,098 | 3.953125 | 4 | def gauss(A):
'''Converts a matrix into the identity
matrix by Gaussian elimination, with
the last column containing the solutions
for the variables'''
m = len(A)
n = len(A[0])
for j,row in enumerate(A):
#diagonal term to be 1
#by dividing row by diagonal term
if row[j] != 0: #diagonal entry can't be zero
... |
53149ba058cfe772da7146ce3d62c6ffb46e6fe3 | johndrulea/Python-Labs | /Calc.py | 972 | 4.03125 | 4 |
def seperator():
print("-" * 50 )
print("inside")
def print_menu():
seperator()
print('Welcome to Python')
seperator()
print('[1] -Add')
print('[2] - Subtract')
print('[3] - Multiply')
print('[4] - Divide')
def sum(num1, num2):
return num1 + num2
def sub(num1... |
e964ec1453df062fe7dfaf186d7e9c0bd4b5a607 | navraj703/Hacker_Rank_Pyhton | /strings/alphabet_rangoli.py | 796 | 3.703125 | 4 | if __name__ == '__main__':
start = 97
end = 97
def print_line(n, i):
length = 4 * n - 3
diff = int(length / 2)
cp = 97 + n - 1
for j in range(length):
if (j % 2) != 0:
print('-', end="")
elif j <= diff + 2 * i and j >= diff - 2 * i:
... |
b320970476eae3d1644cf70cbc0e663c29ac825a | navraj703/Hacker_Rank_Pyhton | /sets/difference_operation.py | 246 | 3.640625 | 4 | # Enter your code here. Read input from STDIN. Print output to STDOUT
if __name__ == '__main__':
n_a = input("")
a = set(input().split(" "))
n_b = input("")
b = set(input().split(" "))
res = len(a.difference(b))
print(res) |
eac83c6d704615594f17cdde6e317567a2bc04a5 | wsilverio/puma | /2_ordena_localiza/main.py | 1,145 | 3.828125 | 4 | import sys
tam = len(sys.argv)-1
if tam < 2:
print "Quantidade invalida de parametros."
exit(1)
def ordena(lista):
tam = len(lista)
for j in xrange(0,tam-1):
for i in xrange(0,tam-j-1):
if lista[i] < lista[i+1]:
aux = lista[i+1]
lista[i+1] = lista[i... |
e8b911a5f1a2d7b8569d3636cc5bcc2b1d5382a1 | BH909303/py4e | /ex6_1.py | 490 | 4.1875 | 4 | '''
py4e, Chapter 6, Exercise 1: Write a while loop that starts at the last
character in the string and works its way backwards to the first character in
the string, printing each letter on a separate line, except backwards.
William Kerley, 21.02.20
'''
fruit = 'banana'
index = len(fruit)-1 #set... |
d59c1b61f2f05850906ac5b6d6ed3f7966f9de55 | BH909303/py4e | /ex5_1.py | 922 | 3.84375 | 4 | '''
py4e, Chapter 5, Exercise 1: Write a program which repeatedly reads numbers
until the user enters "done". Once "done" is entered, print out the total,
count, and average of the numbers. If the user enters anything other than a
number, detect their mistake using try and except and print an error message
and ski... |
632665446d889f74a1944ed7abe53f55b10132fb | norhther/interviewProblems | /intersection_linked_list.py | 1,208 | 3.953125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Oct 11 21:04:29 2020
@author: norhther
Hi, here's your problem today. This problem was recently asked by Apple:
You are given two singly linked lists. The lists intersect at some node. Find, and return the node. Note: the lists are non-cyclical.
Example:
A = 1... |
912b081702bb223da7d78d1920289f9e51159138 | Diefex/Modelos2 | /Python/Caracol2.py | 505 | 3.796875 | 4 | def unroll(M, y):
if y > 0:
for i in M[0][0:y]: print(i)
for i in [e[-1] for e in M[0:y]]: print(i)
for i in reversed(M[y][1:y+1]): print(i)
for i in reversed([e[0] for e in M[1:y+1]]): print(i)
unroll([e[1:y] for e in M[1:y]], len(M)-3)
else:
for i in M:
... |
ae90795d64e18efd505c7faac5b4cc53b7230037 | melaniebrd/information-retrieval | /graph_representation.py | 1,052 | 3.671875 | 4 | from math import log
import matplotlib.pyplot as plt
def show_frequency_by_rank(vocabulary_with_frequencies):
if "" in vocabulary_with_frequencies:
del vocabulary_with_frequencies[""]
ordered_term_values = sorted(vocabulary_with_frequencies, key=vocabulary_with_frequencies.get)
# Normal values
... |
7217f34653c030e69e4938f79f445a34792f3fff | chalapathyj/Pyhton_training | /eye/bkup.py | 2,267 | 3.53125 | 4 | one_dict = {1: "One", 2: "Two", 3: "Three", 4: "Four",
5: "Five", 6: "Six", 7: "Seven", 8: "Eight", 9: "Nine"}
ten_dict = {10: "Ten", 11: "Eleven", 12: "Twelve", 13: "Thirteen",
14: "Fourteen", 15: "Fifteen", 16: "Sixteen", 17: "Seventeen",
18: "Eighteen", 19: "Nineteen", 20: "Tw... |
dd44e068cfe1190cd97d23efe1ee395787dd91a4 | chalapathyj/Pyhton_training | /List_comprehension.py | 467 | 3.765625 | 4 | #simple loop
s = [x for x in range(10)]
print (s)
#applying condition similar to map
s1 = [x*2 for x in range(5)]
print (s1)
#applying condition and setting delimiter (both map and filter)
s2 = [x**2 for x in range(10) if x % 2 != 0]
print (s2)
#nested for loops
s3 = [x+y for x in 'apple' for y in 'oran... |
3717d638fed2617a351f081a4c880c5d2ffcb6b6 | kululu-driod/Excel_Table_Cleanup | /direct_conversion.py | 9,213 | 3.921875 | 4 | import csv
import re
import argparse
from config import *
""" The following code splits the lines, clean up headers/footers and remove keywords from an csv input file"""
""" Author: Y, 2020"""
# TODO table head rip
# TODO splitting table
# TODO if something is in column 1, and they are all just alphabets of more th... |
c3ecdfb13745c5f604d70a86cd0f10da309d4b81 | wujinhang/Python | /09day/01ffor循环.py | 222 | 3.78125 | 4 | a = int(input("输入初始值"))
b = int(input("输入终止值"))
c = 0
if a < b:
for i in range(a,b+1):
print(i)
c = c + i
else:
print("输入有误")
print(c)
sum1 = 0
while a <= b:
sum1 = sum1 + a
a+=1
|
45a3a6dbbbaa8b2057488695173f2164a93f0f97 | wujinhang/Python | /07day/tz.py | 426 | 3.90625 | 4 | high = float(input("请输入你的身高"))
体重 = float(input("请输入你的体重"))
tizhong = float(体重/(high**2))
print("你的tizhong指数为:%d"%tizhong)
if tizhong <= 18.5:
print("过轻")
elif (tizhong >= 18.5 and tizhong <= 25):
print("正常")
elif (tizhong >= 25 and tizhong <= 28):
print("过重")
elif (tizhong >= 28 and tizhong <= 32):
print("肥胖")
el... |
cad395031dac0cd700e7f637c6003d5350417635 | datahaven/Project-Euler | /Euler_058.py | 1,248 | 3.71875 | 4 | # Project Euler 58
# Adrian Dale
# 02/06/2011
#
# You are the 10050th person to have solved this problem.
#
# Answer 26241
#
import sys
# I borrowed the prime code - doesn't look horribly efficient,
# but I'm sure it'll do. I halved the run time from 14s to 7s
# by altering it to step through sieve in 2's
# prime num... |
5b075f681dc6fb9840299246b2dc4ac920737e78 | mottetts/numeroll | /numeroll.py | 3,132 | 4.0625 | 4 | from random import randint,choice
def CPUturn(number, slotcheck, rng):
slot_list = []
for i in range(0,5):
if slotcheck[i] == 0:
slot_list.append(i)
#print("Adding", i, "to slot list")
rand_slot = choice(slot_list)
#print("CPU's available slots: ", slot_list)
#print(... |
b34ea93ab82109b8efa11936f1849f59d6155e50 | CKanan/LinearProgramming | /LP_Convertor.py | 3,951 | 3.640625 | 4 | from functions import *
# Open a file
try:
file = open('LP.txt', 'r');
except IOError:
print("The file you wanted to open, it doesn't exist..")
exit (1)
# Reads the file in lines
f = file.readlines();
# Close opened file
file.close()
# Create list
newList = []
# Append f list to newlist and \n to make... |
9028b5073c028da7d969bf6cb467ef8f1d5509a7 | mike292/PythonGame | /oop2.py | 693 | 4.0625 | 4 | #CLASS METHODS
class Person:
number_of_people = 0 #Class Attribute
def __init__(self, name):
self.name = name
# Person.number_of_people += 1 #Calls the class attribute and Increments the class attribute everytime an instance is made
Person.add_person() #Calling the class method
@c... |
c27e2937513bd706464c8ffc73399a5422612830 | bhavinbhuta/escape-maze | /escape.py | 8,661 | 3.828125 | 4 | """
This file solves the 'Escape the ice problem.
The encoding of the pond needs to be given in a seperate file and the name of
that file should be given in FILENAME constant
"""
from graph import Graph
from vertex import Vertex
# Name of file
FILENAME = "test1.txt"
# No. of rows
ROW = 0
# No. of columns
COLUMN = ... |
33d732ec68db45db930131be08f29656dbdc5e38 | jasonbohne123/elliptical-curves | /Tate height.py | 989 | 4.0625 | 4 | import Elliptic03,numpy
#imports essential packages
curve = Elliptic03.Curve("y**2 == x**3-2*x+2", -2, 2) #sets elliptical curve
P = Elliptic03.Point(curve, 1, 1) #sets point of infinite order
n=25 #sets how far we want to calculte height of point
error=0.001 #sets error to determine how much the value stabalizes
def... |
e1f0cf8b850e98d0588fa85023369bc459fca07e | D3migod/Combinatorial-Optimization | /task1/transportationSystem.py | 3,331 | 3.8125 | 4 | import math
# Система непересекающихся множеств
parents = [] # Массив родителей для каждой из вершин
ranks = [] # Ранг для эвристики присоединения меньшего множества к большему
# Поиск и простановка родительской вершины
def find(city):
if parents[city] == city:
return city
else:
parents[city] ... |
05111315ee46c099c2a926c66d58fb27c3916add | mchrupcala/Graphs | /projects/ancestor/ancestor.py | 4,551 | 3.90625 | 4 | ##When I'm done I want to try using a full graph class for more practice
#All my tests are passing...but they won't if I take on harder graphs....because I'm not resetting current & ancestor_paths like I meant to...they should reset every new path...and ancestor_ath should be a list of different-length paths. Not sure ... |
385559acd2c5952444fb06046b58ed496639512b | manikarnika132/python-player-codes | /romanchk.py | 232 | 3.53125 | 4 | x=raw_input('enter a roman numeral\n')
num=0
for str in x:
if(str=='I'): num+=1
if(str=='V'): num+=5
if(str=='X'): num+=10
if(str=='L'): num+=50
if(str=='C'): num+=100
if(str=='D'): num+=500
if(str=='M'): num+=1000
print num
|
7bc10187343ddd09480c96a650ab9327e8afa7b5 | Kiiiiii123/CodeGym | /剑指Offer-Python版本/A11.二进制中1的个数.py | 1,803 | 3.84375 | 4 | '''
题目:输入一个整数,输出该数二进制表示中1的个数。其中负数用补码表示。
'''
'''
方法一:会陷入死循环,先判断该数最低位是不是1,是则count加一右移,否则直接右移,直至该数变为0 。将该数与1相与判断最低位是否为1,结果为1说明最低位为1,否则为0.这种解法有一个明显缺点:当输入为负数时,由于负数在计算机中用补码表示,最高位是符号位1,因此不断右移的过程中最高位不断补1,造成死循环。
'''
class Solution:
def NumberOf1(self, n):
# write code here
count = 0
while n:
... |
6dcbcbe0a304903f473fe7273d60f4606c720a8c | Kiiiiii123/CodeGym | /公司笔试训练/华为/题1.py | 574 | 3.875 | 4 | '''
题目:输入输出格式为:第一个字符为输入或输出字符的长度(包含该位置),随后的字符中若出现‘A’,则在输出中将它替换成‘12 34’,;若出现‘B’,将它替换成‘AB CD’;其他字符保持不变。
示例:输入:8 1 2 3 4 5 6 A 输出:9 1 2 3 4 5 6 12 34
'''
'''
方法: 使用res模块进行字符串字符替换
'''
import re
if __name__=='__main__':
result=input()
first=0
if 'A' in s:
s=re.sub('A','12 34',s)
s=re.sub('B','AB CD',s)
first... |
4d8029e1c2ac5cbad36e1ac25abf507d119ba885 | Kiiiiii123/CodeGym | /剑指Offer-Python版本/5.用两个栈实现队列.py | 996 | 3.796875 | 4 | '''
题目:用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。
'''
'''
方法:两个栈stack1和stack2, push的时候直接push进stack1,pop时需要判断stack1和stack2中的情况。如果stack2不为空的话,直接从stack2中pop,如果stack2为空,把stack1中的值push到stack2中,然后再pop stack2中的值。
运行时间:25ms
占用内存:5860k
'''
class Solution:
def __init__(self):
self.stack1=[]
self.stack2=[]
... |
51f8f60574714414f2144e4bc77ff52a7fcf8694 | GregorySkir/Gkime | /24.py | 99 | 3.71875 | 4 | s1 = 'apple'
s2 = 'p'
m=s1.count(s2)
if (m<1):
print('-2')
else:
print(s1.find(s2,2)) |
e253e1e28dbd94b9aeeb42992dcab084267b70fd | GregorySkir/Gkime | /45.py | 162 | 4.25 | 4 | def invert_dict(my_dict):
d={}
for k, v in my_dict.items():
d[v]=k
return d
my_dict = {1: "a", 2:"b", 3:"c"}
print(invert_dict(my_dict)) |
cdb0240185da06bf503e20193ea9cc817b7290c0 | GregorySkir/Gkime | /22.py | 99 | 3.65625 | 4 | N=10
my_nums = list(range(N))
print(my_nums[1:len(my_nums):3])
my_nums.reverse()
print(my_nums) |
e858f34a2691f393c51a5f37a1fabf2323b42f7b | TomOrth/Exercism-Solutions | /python/robot-name/robot_name.py | 478 | 3.578125 | 4 | import random
import string
class Robot(object):
def __init__(self):
self.past_names = set()
self.reset()
def reset(self):
temp = random.choice(string.ascii_uppercase) + random.choice(string.ascii_uppercase) + random.choice(string.digits) + random.choice(string.digits) + random.choice(st... |
12c7b8754ba01b80915b752b4a78a1253b32046d | SOBIGARANI/python | /leap.py | 90 | 3.6875 | 4 | l=int(input())
if ((l%4==0 and l%100!=0) or l%400==0):
print("yes")
else:
print("no")
|
ceedc4cf9059a26d9544f553148abac5a5d39d2a | AccentsAMillion/Python | /Ten Real World Applications/Python Basics/Functions and Conditionals/PrintReturnFunction.py | 396 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Mar 30 09:28:25 2020
@author: Chris
"""
#To create functions in python it starts with def function():
# Division (/) Function calculating the sum of myList taking in 3 parameters
def mean(myList):
print("Function mean started!")
the_mean = sum(myList) / len(myList)
... |
819700dc73c3b80b3ed89e0e7d66ad66b6670f0d | AccentsAMillion/Python | /Ten Real World Applications/Python Basics/DataTypeOperations/ListIndexing.py | 1,282 | 3.59375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Mar 29 08:29:19 2020
@author: Chris
"""
# Basic Tempurature lists
tempuratures = [110, 88.7,-50]
# This is a way to access index using attributes
print(tempuratures.__getitem__(0))
print(tempuratures.__getitem__(1))
print(tempuratures.__getitem__(2))
# The above method is ... |
6361d6afe586acf4ca109439a1be4466d6b95514 | AccentsAMillion/Python | /Ten Real World Applications/Python Basics/DataTypeOperations/StudentgradeArray.py | 262 | 3.796875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Mar 29 07:04:30 2020
@author: Chris
"""
# Creating a List of Students using an array variable = []
student_grades =[97, 88.5, 100, 48.2, 92.3]
print(student_grades)
print(student_grades[0])
print(student_grades[3])
|
2120beb1794243d85f0f5575ee201ae3b2b1f04c | AccentsAMillion/Python | /Ten Real World Applications/Python Basics/DataTypeOperations/AlgorithmCalculations.py | 525 | 3.84375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Mar 29 07:04:30 2020
@author: Chris
"""
# Creating a List of Students using an array variable = []
student_grades =[97, 88.5, 100, 48.2, 92.3]
# Takes the total sub function of student_grades and gives it to the variable mySum
mySum = sum(student_grades)
# Uses the length ... |
cb12aca17df00ff174aa59c48f720b77c23e9026 | andrei-chirilov/ICS3U-assignment-05b-Python | /reverse.py | 406 | 4.1875 | 4 | #!/usr/bin/env python3
# Created by: Andrei Chirilov
# Created on: November 2019
# This program reverses a digit
import math
def main():
number = int(input("Enter a number: "))
result = ""
if number == 0:
print(0)
exit(0)
while number != 0:
result += str(number % 10)
... |
6225b666cdc6bf3640e87972b3bff85723078da1 | seaweedy/python | /HelloPython/day01/MyFor.py | 100 | 3.921875 | 4 | # for i in range(5):
# print(i)
for i in range(1,10):
print("2*{}={}".format(i,i*2))
|
06c1efe65c74eca5ff0dd7a36d76908ae1c97508 | Dawnstar2018/record | /replace_blank.py | 736 | 3.75 | 4 | #replace blank
def replace_blank(strs,max_len):
if len(strs)==0 or max_len == 0:
return False
else:
blank_num = strs.count(' ')
original_len = len(strs)-1
strs += (""for i in range(2*blank_num))
after_len = len(strs)-1
if after_len > max_len:
return Fa... |
9ca29631af7bc11b2128efe122862904346a05ec | oscarmrt/holbertonschool-higher_level_programming | /0x01-python-if_else_loops_functions/8-uppercase.py | 241 | 4.28125 | 4 | #!/usr/bin/python3
def uppercase(str):
for characters in str:
if ord(characters) >= 97 and ord(characters) <= 122:
characters = chr(ord(characters) - 32)
print('{:s}'.format(characters), end='')
print('')
|
06c8e528a0dd1e74d74294b23f92b4fd09677bb8 | zhengxiang1994/seabornDemo | /categorical_scatter_plot.py | 990 | 3.625 | 4 | # -*- coding: utf-8 -*-
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style="ticks", color_codes=True)
tips = sns.load_dataset("tips")
# print(tips)
# a simple example
# sns.catplot(x="day", y="total_bill", data=tips)
# The jitter parameter controls the magnitude of jitter or disables it altogether
#... |
a9cb976e2cc5bf23826d5e2a0cd2b38c02c74195 | Usefulmaths/Q-Learning | /q_learning.py | 7,846 | 3.625 | 4 | import numpy as np
import random
import gym
import torch
import torch.nn as nn
class PolicyNetwork(nn.Module):
'''
A class that represents the policy network, takes in a
state and produces the action-values of taking each
valid action in that state.
'''
def __init__(self, state_space, action... |
cfd1827b7a88c813288c48e16ce5805df24775c4 | ZehFuge/TicTacHoe | /TicTacHoe/TicTacHoe.py | 20,854 | 3.625 | 4 | """
Problem 1.1: Done
Already set tileState can be overwritten.
### Solution ###
An if-statement in the changeState() function checks, if the chosen tile is blank.
If not, the function does nothing. The player state also doesn't change.
### End ###
Problem 2.1: Done
There is no win cond... |
b81d2d70877c73b6a4a4329669bffa749cfcf889 | GeoThings/vector-datasource | /vectordatasource/util.py | 358 | 3.84375 | 4 | def to_float(x):
"""
attempts to convert x to a floating point value,
first removing some common punctuation. returns
None if conversion failed.
"""
if x is None:
return None
# normalize punctuation
x = x.replace(';', '.').replace(',', '.')
try:
return float(x)
e... |
d931f1d3d61b61b6e06c8638ad5c0210a3906725 | learsixela/logicaDiurno | /venv/operadores.py | 351 | 4.0625 | 4 | print("Operadors aritmeticos")
#+, -, *, /, %, //, **
suma = 2+3
resta = 6-3
multi= 2*5
division= 7/3
resto = 7%3 #resto de la division
parteEntera= 7//3 #parte entera de la división
elevado = 3**4 #numero elevado a otro numero
#print
print("La suma",suma)
print(resta)
print(multi)
print(division)
print(resto)
print... |
181a7912a6a44a3887ee28c1a1af3276c9ca1609 | learsixela/logicaDiurno | /Funciones.py | 1,913 | 4.21875 | 4 |
#funcion
def funcionSaludo():
mensaje()
print("Esta es un mensaje desde otra funcion")
def mensaje():
print("mensaje")
print("mensaje2")
print("mensaje3")
print("***********")
#llamado a la funcion
#mensaje()
#funcionSaludo()
#mensaje()
def funcionSuma():
numero3 = 3
numero4 = 4
... |
37614a1f4ece39402e14fd4c73725151f8968339 | learsixela/logicaDiurno | /20201013_arreglos3.py | 1,321 | 4.15625 | 4 | #key, o palabra clave
#Diccionarios
numeros = {
"uno": 1,
"doscientos":200,
"gato":1234,
}
print(numeros["uno"])
print(numeros["doscientos"])
print(numeros["gato"])
print()
#agregar contenido a numeros
#crear variable para diccionario numeros
print(numeros)
numeros["cuatro"] = 4
print(numeros["cuatro"])
... |
9bfb3b976beb8b449b36700df4df392ebc6f888e | Herbert-CN/python_datastructure | /backtrack/myReturn.py | 648 | 3.640625 | 4 | def function1(n: int):
if n <= 1:
return 1
else:
return n * function1(n-1)
def function2(n: int):
if n <= 1:
return 1
else:
n * function2(n-1)
def function4(n: int, result):
if n <= 1:
if 1 not in result:
result.append(1)
return 1
el... |
d3b87882ca32951d5a97d626701bcddbf0d7aa27 | Herbert-CN/python_datastructure | /backtrack/new_queen.py | 1,460 | 3.609375 | 4 | class Solution:
count = 0
grid = [[" " for _ in range(8)] for _ in range(8)]
result = []
def findQueen(self, curRow: int):
if curRow == 8:
self.count += 1
self.printQueen()
self.result.append(self.grid)
return
for col in range... |
d103d64085499575726a5ebdb373ef8705f46b28 | Herbert-CN/python_datastructure | /convert_sql.py | 1,016 | 3.734375 | 4 | class Solution:
def convertSQL(self, rawString: str) -> str:
rawList = rawString.split()
result = []
counting_start = False
for element in rawList:
if element == 'or' and not counting_start:
temp = result.pop()
result.append('(')
... |
4af94e2fdf4bbae9ee500040c9d71e2e6bf3c33f | LemonPi/Pathtreker | /route.py | 1,944 | 3.6875 | 4 | import queue
import networkx
from math import radians, sin, cos, sqrt, asin
from util import hav
def shortest_path(g, source, dest):
"""Return single source single destination shortest path using A* search.
Haversine distance is used as heuristic.
Arguments:
g -- networkx graph loaded from shapefile
source ... |
d8ccb7868711d92888cf821e69d1df4a72262849 | enoch-chang/Pressure-Transducer-Processing | /pressure_processor.py | 4,981 | 3.8125 | 4 | """
Author: Enoch Chang
This script contains various functions to process the data, including:
- Modification of time values
- Modification of data range
- Graphical representation of data
- Prepare modified data sets for export
"""
import matplotlib.pyplot as plt
import file_io
from datetime import datetime
import h... |
9e537f63159ee8e7fd8f750a08e352b309354021 | AstroinformaticsAU/AI2013 | /python-db/tutorial.py | 1,056 | 3.515625 | 4 | #!/usr/bin/env python
import sqlite3
catalogue = []
# read file and store as lists (rows) of lists (columns)
with open('hipass.txt','r') as f:
for i, line in enumerate(f):
#ignore header
if i == 0:
continue
# ignore comments
line = line.strip()
if line.startswi... |
623e5fe04f4645ea22bd7879011231da591e0170 | a-carrasquillo/Tic-Tac-Toe-Game | /milestoneproject1.py | 7,291 | 4.09375 | 4 | #imports
#needed to shuffle the turns
from random import shuffle
#needed to clear the screen
from os import system, name
# import sleep to stop for some time period
from time import sleep
#Global Variable
continuetoplay = True
#function to print the board
def printboard(board):
""" Function to print the... |
d03cc6651d511fefa6af2adea4aa722df253f99d | gauthamikuravi/Python_challenges | /Leetcode/shift_zeros.py | 1,106 | 4.21875 | 4 |
#######################################################
#Write a program to do the following:Given an array of random numbers, push all the zeros of a given array to the start of the array.
# The order of all other elements should be same.
#Example
#1: Input: {1, 2, 0, 4, 3, 0, 5, 0}
#Output: {0, 0, 0, 1, 2,... |
53a16f0432aa40c042ddb70f4bfc0b09a97227dc | sk1z0phr3n1k/Projects | /python projects/mbox.py | 1,483 | 4.15625 | 4 | # Author: Mark Griffiths
# Course: CSC 121
# Assignment: Lab: Lists (Part 2)
# Description: mbox module
# The mbox format is a standards-based email file format
# where many emails are put in a single file
def get_mbox_username(line):
"""
Get mbox email username
Parse username from the start of an email
... |
fe5c8312a0736807bff35a2792543e7f7f5b0891 | lillirodriguez/cscampfinal2018 | /finalproject.py | 6,097 | 3.90625 | 4 | # Vassar CS Camp
# Name: Maimuna Touray
# Filename: fiction.py
"""
Title for your adventure: The Coach.
Notes on how to "win" or "lose" this adventure:
To win, choose the table.
To lose, choose the door.
"""
import time
""" this function runs one session of interactive fiction
Well, it's "fiction," depe... |
64e181d14be588e6fd19c11d7cf63ed504b753ba | abhijeetknayak/CSES-Problem-Set | /Python/Two-Knights.py | 535 | 3.625 | 4 | def get_ways_knights(n):
ways = 0
print(ways) # For n = 1
for i in range(2, n + 1):
ways = i**2 * (i**2 - 1) // 2
if i > 2:
ways -= 2 * 2 * (i - 1) * (i - 2)
print(ways)
def get_ways_pawn(n):
ways = 0
print(ways) # For n = 1
for i in range(2, n ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.