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 |
|---|---|---|---|---|---|---|
7393cde21cca4afe07f1a6179bb9361929943018 | vishal2develop/Coding-Problems | /max_distance.py | 743 | 3.921875 | 4 |
#Given an array with repeated elements, find the maximum distance between two occurrences of all the elements in the array.
def maxDistance(arr):
n=len(arr)
# Used to store element to first index mapping
mp = {}
# Traverse elements and find maximum distance between
# same occurrences with the ... |
76d7b92015e0a39288db83be104d3fac2b7428ac | licong88/mtx_test | /helloworld.py | 1,410 | 3.84375 | 4 | # print("Hello world!")
"""
自我介绍
我的名字:
工作地址:
通过python训练营学到什么:
最后打印出来
print()
"""
# print("自我介绍")
# print("我的名字:Iris")
# print("工作地址:广东深圳")
# print("通过python训练营学到什么:了解自动化")
# print("""
# 自我介绍
# 我的名字: Iris
# 工作地址:广东深圳
# 通过python训练营学到什么::了解自动化
# """)
#
# print(
# '''
# へ /|
# /\7 ∠_/
# / │ / /
# │ Z ... |
20e60f62e4865b7a1beb1cdd67330159ebbba35c | LesterZ819/PythonProTips | /PythonBasics/Lists/CreatingLists.py | 534 | 4.15625 | 4 | #You can create a list of values by putting them in [brackets] and assigning them a variable.
#For example:
varialble = [item1, item2, item3, item4]
#lists can contain any time of value, or multiple value types
#Example list containing floats or real numbers.
float = [1.25, 15.99, 21.33]
#Example of a list con... |
70d9789e362726cd086f0d732bb99398e7782d87 | bizuetcollazo05/practica_2.2_josebizuetcollazorubio | /proyecto2.2_JOSEBIZUETCOLLAZORUBIO.py | 2,703 | 4.09375 | 4 | #NOMBRE:JOSE BIZUET COLLAZO RUBIO
#CARRERA:INFORMATICA
#MATERIA:DESAROLLO DE APLICASIONES
#EJERCISIO O PRACTICA: PRACTICA_2.2_JOSEBIZUETCOLLAZORUBIO
fecha=input("fecha(formato ´dia, DD/MM´):")#(ESTO SE CONSIDERA COMO UN ESTRIN LITERAL )aqui indico que ingrese DOS DIGITOS PARA EL DIA Y DOS PARA EL MES
fecha=fecha.lower... |
74b9a9276cee8f289fc0ce6be0010943caec5b0d | alexisk1/hackerRank | /DP/coinchange/pp.py | 404 | 3.671875 | 4 | import math as m
check=0
def recursion(sum_a,lower,X,N):
global check
for i in range(lower,int(m.sqrt(float(X)))):
sum_b=sum_a+i**N
print(sum_b)
if(sum_a<X):
check=check+recursion(sum_b,i,X,N)
elif(sum_a==X):
check=check+1
else:
return
... |
0f4d3b9268c19cf3aae598d7c475298b748c131f | le-ann/2017pange_hgt | /scripts/fasta_title_counter.py | 181 | 3.734375 | 4 | #!/usr/local/bin/python3.5
import sys
file = open(sys.argv[1],'r')
title=0
for line in file:
for x in line:
if x == ">":
title+=1
print("The number of titles is", title)
|
b32f2c2b15815e68df3a5cae9d0b600653ddd48d | le-ann/2017pange_hgt | /scripts/rdmfilegen.py | 585 | 3.921875 | 4 | #!/usr/local/bin/python3
import csv
import random
file_list = [] #empty list
with open("roaryfile.txt", "r") as roaryfile: #opens up the file as a readable, CSV file
file_reader = csv.reader(roaryfile, delimiter=",") #csv reader
for row in file_reader:
file_list.append(row[0]) #ad... |
99d3a246ee13ead616b3bca57f3bf81104530350 | seafoodfriedrice/thinkful-python | /fizz_buzz/fizzbuzz_challenge.py | 361 | 3.890625 | 4 | import sys
if len(sys.argv) > 1:
n = int(sys.argv[1])
else:
n = int(raw_input("Enter a number: "))
print "Fizz Buzz counting up to {0}".format(n)
for i in range(1, n+1):
if (i % 3 == 0) and (i % 5 == 0):
print "Fizz Buzz"
elif (i % 3 == 0):
print "Fizz"
elif (i % 5 == 0):
... |
6e6adc146d56ace8f75aa3f7a5fcb18bcbdb39b6 | brahim024/Principles-of-Algorithm-Design | /binary-search/bs.py | 304 | 3.96875 | 4 | def binary_search(list,item):
low=0
high=len(list)-1
while low <= high:
mid=(low+high)
guess=list[mid]
if guess== item:
return mid
if guess > item:
high =mid-1
else:
high=mid +1
return None
my_list=[-1,0,1,3,5,7,8]
print(binary_search(my_list,3))
print(binary_search(my_list,-1)) |
9f13a8c2f6f5d0f9095da83f175c15a51108096c | LukeBecker15/learn-arcade-work | /Lab 06 - Text Adventure/lab_06.py | 2,656 | 4.15625 | 4 | class Room:
def __init__(self, description, north, south, east, west):
self.description = description
self.north = north
self.south = south
self.east = east
self.west = west
def main():
room_list = []
room = Room("You are in the entrance to the Clue house.\nThe p... |
ee57d072273bd0e0ebeda14caf3db689d0b0ec58 | LukeBecker15/learn-arcade-work | /Lab 09 - Sprites and Walls/lab_09.py | 13,074 | 4.15625 | 4 | """
Use sprites to scroll around a large screen.
Simple program to show basic sprite usage.
Artwork from http://kenney.nl
If Python and Arcade are installed, this example can be run from the command line with:
python -m arcade.examples.sprite_move_scrolling
"""
import arcade
import os
SPRITE_SCALING = 0.5
SCREEN... |
0a62603b2b15c4a427d4a60b7a9d41d270f301dc | Eduzyolo/SNAKE_python | /snake - foto.py | 6,526 | 3.546875 | 4 | import turtle
import time
import random
# center x game = -5
# center y game = 185
# angle down SX: -150,76
# angle down DX: 140,76
# angle up SX: -150,294
# angle up DX: 140,294
#varibles
delay = 0.1
SIZE = 10
gss = {#game screen size
"x_DX": -150,
"y_DX": 76,
"x_SX": 140,
"y_SX": 294,
"x_CE": 0... |
c5fd56e26412e9b60b3c3072f75c768b800cdd6f | Ramcr32/reverse-world-in-string---python | /main.py | 375 | 3.78125 | 4 | input1=input("enter the sentence:").split(' ')
# print(input1)
output_list=[]
for i in range(len(input1)):
output1=input1.pop()
# print(type(output1))
output1 = output1[::-1]
# print(type(output1))
# print(output1)
output_list.insert(0,output1)
i+=1
continue
# print(output_list)
position... |
3e3f57172738142ea7af70ec8b581113979540e9 | ixxra/projecteuler | /problem025/problem25.py | 1,053 | 3.90625 | 4 | #!/usr/bin/env python2
import numpy as np
MAX_DIGITS = 1001
def bignum():
return np.zeros(MAX_DIGITS, dtype='int8')
def bignum_sum(num1, num2, num3):
carry = 0
for i in range(MAX_DIGITS):
res = num1[i] + num2[i] + carry
num3[i] = res % 10
carry = res / 10
def bignum_digits(nu... |
2308b5527402b2030fff570af4afac412558b6ca | ixxra/projecteuler | /problem056/problem56.py | 480 | 3.640625 | 4 | #!/usr/bin/env python2
import itertools as it
from time import time
def digital_sum(n):
return sum([int(d) for d in str(n)])
a = b = range(100)
t0 = time()
total1 = max(map(digital_sum, map(lambda (p, q): p**q, it.product(a, b))))
t1 = time()
print '{t}s with functional programming'.format(t=t1 - t0)
t0 = t... |
167e9a7f7d212516e4b723045355852e1b4afc7d | ixxra/projecteuler | /problem052/problem52.py | 376 | 3.578125 | 4 | #!/usr/bin/env python2
from time import time
t0 = time()
def multiples(x):
return [ k * x for k in (2, 3, 4, 5, 6)]
def test(x):
s = set(str(x))
for n in multiples(x):
if set(str(n)) != s:
return False
return True
for x in range(1, 1000000):
if test(x):
print x
... |
26be1794ebca585cc0d8a480fab2be1ca22b3c3f | ixxra/projecteuler | /problem041/problem41.py | 603 | 3.765625 | 4 | #!/usr/bin/env python2
from itertools import permutations
from math import ceil, sqrt
def isprime(p):
if p == 1:
return False
if p == 2:
return True
if p % 2 == 0:
return False
for d in xrange(3, int(ceil(sqrt(p))) + 1, 2):
if p % d == 0:
return False
... |
70cdaeabca7ccf83ff08848b7270f1a473a740f5 | mrithunjaybr/Hashing-2 | /LongestPalindromeInAString.py | 770 | 3.765625 | 4 | // Time Complexity : O(n)
// Space Complexity : O(n)
// Did this code successfully run on Leetcode : Yes
// Any problem you faced while coding this : No
// Your code here along with comments explaining your approach
class Solution:
def longestPalindrome(self, s: str) -> int:
di={}
count=0
... |
080ccc30b5c64d5f93223116ead45dd33e6afc44 | aiqingr/moreDjangoinVirtualEnv | /firstVirtualEnv/libraryLearning/file_object/file_object_write.py | 688 | 3.703125 | 4 | # If the doc is existing, it will overwrite the content
# If the doc is not existing, it will create a new doc
# with open('testing2.txt', 'w') as f:
# f.write('Test')
# f.seek(0)
# f.write('R')
# The way to copy content to a new doc
# with open('testing.txt', 'r') as rf:
# with open('testing_copy.txt'... |
f12e43f9e797e4596f8b4302de34e93dc31453a5 | ITC-Vanadzor/ITC-7 | /Hasmik_Kirakosyan/Homework/sphinxAndSingleton/brandDoc/brand.py | 618 | 3.828125 | 4 | #!/usr/bin/python
# Templete checker modul
import re
def check(line, exp, message):
'''
This method check brand information templete
:param line: line to check. It can be brand name version or made in country
:param exp: regular expression that will match with line
:param message: error message for e... |
10e07f7d27a9e2e1f83307aa8f7a5453219f5fdf | ITC-Vanadzor/ITC-7 | /Hasmik_Kirakosyan/Homework/Python/classElipse.py | 2,013 | 3.90625 | 4 | #! /usr/bin/python
import math
# ******************class point********************
class point:
def __init__(self, x1, y1):
self.x = x1
self.y = y1
# ******************class ellipse*******************
class ellipse:
__ifEllipse = true
# constructor
def __init__(self, point0, pointX, pointY):
self.centre... |
a6dd2a94a3fb2aada11c5bed7c41eded517ea7f5 | ITC-Vanadzor/ITC-7 | /Hakob_Torosyan/Homework_python/Strings_filter.py | 304 | 3.90625 | 4 | #!/usr/bin/python
list = ['@', '#', '$', '%', '&'] #list of symbols wich will be deleted
string = raw_input("Import string: ")
str = "" #new string wich have not symbols from list
for element in string:
if element not in list:
str = str + element
print("Cleared string: ")
print(str)
|
48297d4dd69344fb52b25d65851b16dbafdb01e8 | ITC-Vanadzor/ITC-7 | /Edgar_Hakobyan/Homework/python/ellipse.py | 871 | 3.59375 | 4 | import math
class ellipse:
def __init__(self,coord):
self.big_semiaxis = (math.sqrt(math.pow(coord[2]-coord[0],2) + math.pow(coord[3]-coord[1],2)))/2
self.small_semiaxis = (math.sqrt(math.pow(coord[6]-coord[4],2) + math.pow(coord[7]-coord[5],2)))/2
def area(self):
s = math.pi * self.bi... |
7bd074d3258a40faf07dc9fd29599801ce800450 | ITC-Vanadzor/ITC-7 | /Jirayr_Stepanyan/Homework/sphinx/arg_calc.py | 1,315 | 3.953125 | 4 | #!/usr/bin/python
import sys, argparse
def add(a, b):
"""
:param name: a
:param type: float
:param name: b
:param type: float
:returns: float
"""
return a + b;
def sub(a , b):
"""
sub function
:param name: a, b
:param type: float
:returns: float
"""
return a - b;
def ... |
51ed93d2a1e78048918aeec4d0ec04dcd4a567f9 | ITC-Vanadzor/ITC-7 | /Meruzh_Janoyan/Homeworks/python/calc.py | 316 | 3.921875 | 4 | #!/usr/bin/python
import sys
first=float(sys.argv[1])
second=float(sys.argv[3])
operator=sys.argv[2]
result=0
if operator=='+':
result=first+second
elif operator=='-':
result=first-second
elif operator=='x':
result=first*second
elif operator=='/':
result=first/second
print first,operator,second," = ",result
|
6e893b1282981ef49628edbd8dc6e01f78ddd5de | gangwarily/deep-learning-projects | /a_linear_regression/05_systolic_multi_linear_regression.py | 1,227 | 3.75 | 4 | # provided by Lazyprogrammer.me
# https://deeplearningcourses.com/c/data-science-linear-regression-in-python
# need to sudo pip install xlrd to use pd.read_excel
# data is from:
# http://college.cengage.com/mathematics/brase/understandable_statistics/7e/students/datasets/mlr/frames/mlr02.html
# The data (X1, X2, X3) a... |
ec2e716c69e0a72387b7306a7297b09caa35c100 | JiayingGaoo/lc | /Search_Insert_Position.py | 674 | 3.8125 | 4 | class Solution:
def searchInsert(self, nums: list, target: int) -> int:
i = 0
if target < nums[0]:
return 0
if target == nums[0]:
return 0
if target > nums[-1]:
return len(nums)
if target == nums[-1]:
return len(nums) - 1
... |
2d02c67d12e860c546990738ff81c9bdfef86ac4 | JiayingGaoo/lc | /Generate_Parentheses.py | 2,179 | 3.71875 | 4 | class Solution:
def add_one_parentheses_at_current_str(self, input_parentheses: str) -> list:
len_str_input = len(input_parentheses)
print(len_str_input)
output_parentheses_str_list = []
for i in range(len_str_input):
_s = ''
for j in range(i):
... |
8cc94ac3dd69bca1de3f88d27e835c752aa49a75 | Lukas-Justen/Law-OMNI-BERT-Project | /src/text_utilities.py | 915 | 3.890625 | 4 | # Text utilities for calculations support.
import nltk
from collections import Counter
def get_word_list(text_block):
return nltk.word_tokenize(text_block.lower())
def get_unique_words(word_list):
return list(set(word_list))
def calc_word_freq(word_list):
return Counter(word_list)
def get_metrics(text_b... |
7947634bf956c047137997d2c9cb2c83e2f646a9 | sez07/hangman | /hangman/hangman.py | 2,918 | 4 | 4 | import random
def hangman():
list_of_words=['newyork','chicago','houston','philadelphia','dallas','atlanta','fresno','columbus','indianapolis','portland','miami','orlando','greensboro']
word=random.choice(list_of_words)
turns=10
guessmade=''
valid_entry=set('abcdefghijklmnopqrstuvwxyz')
while ... |
183d3360519f1935140cefd8830662d0f168e6ae | DhirajAmbure/MachineLearningProjects | /PythonPracticePrograms/factorialOfNumber.py | 1,225 | 4.28125 | 4 | import math as m
def findfact(number):
if number == 1:
return number
elif number != 0:
return number * findfact(number - 1)
number = int(input("Enter number to find Factorial: "))
if number < 0:
print("factorial can not be found for negative numbers")
elif number ==0:
... |
10c2aad03f067a749d7a3831b56740476f7081e3 | layaxx/project_euler | /025_1000digit-fibonacci-number.py | 306 | 3.796875 | 4 | # What is the index of the first term in the Fibonacci sequence to contain 1000 digits?
def solve():
limit = 1000
fib1 = 1
fib2 = 1
count = 2
while(len(str(fib2)) < 1000):
tmp = fib1
fib1 = fib2
fib2 = fib1 + tmp
count += 1
print(count)
solve() |
0f23395e0b0de2da55eab6e2873d90853489798f | layaxx/project_euler | /022_names-scores.py | 988 | 3.921875 | 4 | """ begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obtain a name score.
For example, when the list is sorted into alphabetical order, COLIN, which is worth 3 + 15 + 12 + 9 + 14 = 53, is the 938th name i... |
1513bc728b1079b9e7ffbcd47e06d33b02f52ca3 | layaxx/project_euler | /001_multiples-of-3-and-5.py | 101 | 3.859375 | 4 | output = 0
for x in range(1,1000):
if x % 5 == 0 or x % 3 == 0:
output += x
print(output) |
616450ff979357fd91d216783a7723df4a835dc8 | layaxx/project_euler | /017_number-letter-counts.py | 463 | 3.84375 | 4 | # If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?
from num2words import num2words
def solve(limit):
result = 0
for number in range(1, limit + 1):
result += getNumberOfLettersIn(number)
#print(getNumberOfLettersIn(number))
... |
4318daad6d05bf2528b5025bab4974939267bf07 | Ladydiana/LearnPython | /CompoundDataStructures.py | 1,229 | 4.25 | 4 | # -*- coding: utf-8 -*-
"""
COMPOUND DATA STRUCTURES
"""
elements = {"hydrogen": {"number": 1,
"weight": 1.00794,
"symbol": "H"},
"helium": {"number": 2,
"weight": 4.002602,
"symbol": "He"}}
h... |
18a845aa39833a9b137bd19759c543a8a77054b6 | Ladydiana/LearnPython | /ListComprehensions.py | 959 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""
LIST COMPREHENSIONS
"""
#capitalized_cities = [city.title() for city in cities]
squares = [x**2 for x in range(9) if x % 2 == 0]
print(squares)
#If you would like to add else, you have to move the conditionals to the beginning of the listcomp
squares = [x**2 if x % 2 == 0 else x ... |
1a4584feb95da66abab5d2b0cb40664f2eab59dc | Ladydiana/LearnPython | /LambdaExpressions.py | 872 | 4.1875 | 4 | # -*- coding: utf-8 -*-
"""
LAMBDA EXPRESSIONS
---You can use lambda expressions to create anonymous functions.
"""
multiply = lambda x, y: x * y
print(multiply(4, 7))
"""
QuUIZ - Lambda with Map
"""
numbers = [
[34, 63, 88, 71, 29],
[90, 78, 51, 27, 45],
[63,... |
e6f698776d32584b6ddfb20b071e687911f84507 | gahan9/PyCUDA | /hello_gpu.py | 1,116 | 3.96875 | 4 | """
https://documen.tician.de/pycuda/tutorial.html
"""
# Import and initialize PyCuda
import pycuda.driver as cuda
from pycuda.compiler import SourceModule
import pycuda.autoinit # optional use >> reason: initialization, context creation, and cleanup can also be performed manually
import numpy # utilized to transfer... |
db1d92428eb0bc9e57a3dd37b557e22f13a00a93 | Ic4r0/advent_of_code2019 | /day_1/part_2.py | 827 | 3.71875 | 4 | """--- Day 1: The Tyranny of the Rocket Equation - Part Two---"""
import os
dirname, _ = os.path.split(os.path.abspath(__file__))
file_path = dirname + "\\input"
# Open the input file
with open(file_path) as file:
# Create a list where each element of it is a mass value
list_of_mass = [int(line) for line in ... |
edeb501a9bfe89ab9691768e5740c6bdd10a4023 | shersingh7/working_with_directories | /main.py | 215 | 3.53125 | 4 | from pathlib import Path
# path = Path("new_dir")
# # create dir
# path.mkdir()
# # create remove
# path.rmdir()
path = Path()
# prints all the files in current dir
for file in path.glob('*.*'):
print(file)
|
35c5d9982298f529018ee1a449ed45b2f881e51f | Sadiya94/test_sadiya | /src/python/utils/csv2text.py | 639 | 3.734375 | 4 | ''' This python program should read each line of essays.csv and save it as a separate file with a the name essay<line_number>.txt
That is, the first line should be saved as essay1.txt, the second line as essay2.txt, etc.
'''
filename = r'/Users/sadiyasultana/Desktop/research_files/test_sadiya/test/essays.csv'
f = op... |
1fb54f4eb862d8b602cc48c96fa6018bd2523323 | kdazzle/py-neorm4j | /neorm4j/fields.py | 3,361 | 3.65625 | 4 | class Field(object):
pass
class Property(Field):
def __init__(self, index=False, *args, **kwargs):
"""
:param index: set to True if you want the Property to be an index.
Defaults to false.
"""
self.index = index
def is_index(self):
"""
Is this ... |
7d547d8255b0205462e879f3c135ec163d26e59c | imtiaz-abdullah/Python | /main.py | 3,013 | 4 | 4 | """
#1)
temps = 6.892
distance = 19.7
vitesse = distance / temps
print("La vitesse est de",vitesse)
print("%.1f" % vitesse)
#2)
nom=str(input("saisir nom :"))
age=int(input("saisir age :"))
print(nom, age)
#3)
import math
flottant = float(input("Saisir la valeur du flottant :"))
if flottan... |
18a7c2e4d2f7e58ccbf76ecc81dd25ba0c3e5891 | pe-perry/online_learning | /q_learning/path_finding.py | 2,548 | 3.546875 | 4 | """
Q-Learning in Python - Path Finding
Ref:
http://mnemstudio.org/path-finding-q-learning-tutorial.htm
"""
import numpy as np
class Path(object):
def __init__(self, path):
self.path = path
def __repr__(self):
return " -> ".join([str(x) for x in self.path])
def __str__(self):
... |
59d394ef28bc493ad0a66296b55f6435241e05f0 | WickedWahine/melon-delivery-report | /produce_summary.py | 1,243 | 4.09375 | 4 | def melon_delivery_report(file_name):
'''Create a report of melons delivered'''
#The 3 log files where data is stored
files = {
"um-deliveries-20140519.txt": 1,
"um-deliveries-20140520.txt": 2,
"um-deliveries-20140521.txt": 3
}
#Check that the file name argument is valid
... |
e5f63dd75eadec1499cb15037c3b4623ace06b76 | abhi472/Pluralsight | /Chapter5/classes.py | 1,035 | 4.1875 | 4 | students = []
class Student:
school_name = "Sumermal Jain Public School" # this is similar to a static variable but unlike java we do not need to have a static class for static variables we
# can have a class instance just like school_name for static call of it
... |
823fb12f33cb3e092f960cd7d3233b5befc57940 | abhi472/Pluralsight | /Chapter3/loop.py | 102 | 3.765625 | 4 | names = ["mark", "katrina", "hamill"]
for name in names:
print("this is name {0}".format(name))
|
62eadc4c3eb829a71a0a2fd24282da4a2c8f3232 | abhi472/Pluralsight | /Chapter3/rangeLoop.py | 444 | 4.375 | 4 | x = 0
for index in range(10): # here range creates a list of size 10(argument that has been passed)
x += 10
print("The value of X is {0}".format(x))
for index in range(5, 10): # two args mean list start from 5 and goes till 9
x += 10
print("The value of X is {0}".format(x))
for index in range(5, 10,... |
0f72b2329c62d8d3b6134e36a218b0643588890a | abhi472/Pluralsight | /ProjectEuler/ProjectE_7.py | 677 | 3.875 | 4 | # By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
#
# What is the 10 001st prime number?
import time, math
def isPrime(i):
if i == 2 or i == 3:
return True
else:
if (i % 2) == 0:
return False
else:
for j in ra... |
a409054717c53d71a9b492e5818a1fc7f39c5dc9 | SathishMuruganS/LeetCodingChallengeSeptember2020 | /LargestTimeForGivenDigits.py | 1,023 | 3.78125 | 4 | '''
Given an array of 4 digits, return the largest 24 hour time that can be made.
The smallest 24 hour time is 00:00, and the largest is 23:59. Starting from 00:00, a time is larger if more time has elapsed since midnight.
Return the answer as a string of length 5. If no valid time can be made, return an empty stri... |
517716c5e73ae50a05af17d97fe3ecbe038c34d3 | Creinosoc/Tarea3-ClienteServidor-Python | /juego quemado.py | 1,560 | 4.0625 | 4 | import time
import random
print(" _____________________________________________")
print("|_____________________________________________|")
print("| Bienvenido al juego del quemado :) !!! |")
print("|_____________________________________________|")
print(">> Adivina la palabra antes de morir quemado wajaja!")
tim... |
439b9055dc6aea857040e4c7ab544d16aea8164b | kkellner/rpi-fountain | /sandbox/sonar.py | 1,797 | 3.515625 | 4 | #!/usr/bin/python3
import RPi.GPIO as GPIO
import os
import time
# Define GPIO to use on Pi
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO_TRIGGER = 23
GPIO_ECHO = 22
TRIGGER_TIME = 0.00001
MAX_TIME = 0.004 # max time waiting for response in case something is missed
GPIO.setup(GPIO_TRIGGER, GPIO.OUT) # Trigge... |
45a79aaf54da6f276d78b8ce02394d75adb48ae6 | MScodi/MusicPlayer_python | /Music_Player.py | 4,155 | 3.796875 | 4 | from tkinter import *
import pygame
import os
# Building Constructor for Title and geometry for window and initiate pygame and pygame mixer
class MusicPlayer:
def __init__(self,root):
self.root=root
#Title of the Window
self.root.title("MusicPlayer")
#Window Geometry
self.root.geom... |
c5f3a449b0a84d29787adc5ecbd2438fe616aed2 | lampubolep/HackerRank30days | /day3.py | 458 | 4.3125 | 4 | # receiving input integer
n = int(input())
# if n is odd, print Weird
if (n % 2) != 0:
print("Weird")
# if n is even and in the inclusive range of 2 to 5, print Not Weird
elif (n%2 == 0 and n>=2 and n<=5):
print("Not Weird")
#if n is even and in the inclusive range of 6 to 20 print Weird
elif (n%2 == 0 and n>=6 an... |
4694e6a25bd833c8b193fef2f8a68b391c7d7124 | schaffyt/Machine-Learning | /Assigment 5/InfoGain.py | 1,485 | 3.578125 | 4 | """
Adam Schaffroth
CPSC 392 Linstead Section 1
10/18/18
"""
import math
#valueSplit is a list of 2 items. The first is number of positive examples,
#the second is the number of negative examples
def calcEntropy(valueSplit):
h = 0.0
#fill this in
p0 = valueSplit[0]/(valueSplit[0] + valueSplit[1])
p1 ... |
80b8be8ba4fabddfcffaf7d8a69039c83679938f | JubindraKc/python_assignment_dec15 | /#4_firstname_lastname_split.py | 503 | 4.28125 | 4 | def full_name():
print("your first name is ", first_name)
print("your last name is ", last_name)
choice = input("will you include your middle name? y/n\n")
name = input("please enter your full name separated with whitespace\n")
if choice == 'y':
first_name, last_name, middle_name = name.split(" ... |
661d9176b17860797663e2a0dc9c609003031032 | Verachidera/function | /conditional statement vera py.py | 364 | 3.890625 | 4 | #grade checking
#70 - 100 =A
#60 - 69=B
#50 - 59=C
#45 - 49=D
#40 - 44=E
#0 - 39=F
if(x>70 and x <=100):
print("A")
elif(x<=69 and x>=60):
print("B")
elif(x<=59 and x>=50):
print("C")
elif(x<=49 and x>=45):
print("D")
elif(x<=44 and x>=40):
print("E")
elif(x<=39 and x>=0):
pr... |
3788b7a6e28a33af11d25a8f0eea27553219a2b7 | EdwinSmartBoy/py_reptile | /reptile/re_example/re_demo.py | 1,623 | 3.609375 | 4 | # -*- coding: utf-8 -*-
"""
-----------------------------------------
IDEA Name : PyCharm
Project Name : py_reptile
-----------------------------------------
File Name : re_demo
Description : re模块的高级用法
Author : Edwin
Date : 2018/1/11 23:07
---------------------------------------... |
5d0666b3e65bc81d9810be718149157a42761361 | Smrity01/networks | /selectiveRepeatFinal.py | 7,472 | 3.90625 | 4 | '''
Program : Selective Repeat Protocol
'''
# Importing necessary libraries
from tkinter import *
import time
# -----------------------------------------------------------------------------
# Functions Definitions
def draw_frame(x1,x2,index,color):
'''
Drawing a rectangular frame to show t... |
356cef422d80f45fbd6ba700d7584ab1abde287b | jjasont/PH4505_Homework | /PH4505-Homework4_IsingModel/PH4505 Homework 4 - Jason - New.py | 15,248 | 3.5625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Apr 13 09:30:23 2018
2D Ising Model
Question 1 (20/20)
Good job!
@author: Jason Tanuwijaya
"""
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(color_codes=True)
nbor = [[-1,0], [1,0], [0,-1], [0,1]] #[increase for i, increase for j]
# calculat... |
48d8c9acfbbe437a075f8850b40559cc5a7d52d7 | simonechen/PythonStartUp | /ex1.py | 407 | 4.1875 | 4 | # print("Hello World!")
# print("Hello Again")
# print("I like typing this.")
# print("This is fun.")
# print("Yay! Pringting.")
# print("I'd much rather you 'not'.")
print('I "said" do not touch this.') # ' "" '
print("I'm back.") # Terminate
print("-how to make my script print only one of the lines?")
print("-one way... |
48bcb4c1c7e29d4185555c559d565c949e9c4617 | queeniekwan/mis3640 | /session05/mypolygon.py | 1,526 | 4.28125 | 4 | import turtle
import math
# print(andrew)
# draw a square
# for i in range(4):
# andrew.fd(100)
# andrew.lt(90)
def square(t, length):
for i in range(4):
t.fd(length)
t.lt(90)
def polyline(t, n, length, angle):
"""
Draws n line segments with given length and angle (in degrees) be... |
57629ce5b3adbfeb89b532c2b2af3b4977815c26 | queeniekwan/mis3640 | /session13/set_demo.py | 540 | 4.3125 | 4 | def unique_letters(word):
unique_letters = []
for letter in word:
if letter not in unique_letters:
unique_letters.append(letter)
return unique_letters
print(unique_letters('bookkeeper'))
# set is a function and type that returns unique elements in an item
word = 'bookkeeper'
s = set(w... |
bf45c6e81a4b52170943cacc6962b39e5fe2e544 | queeniekwan/mis3640 | /session11/dictionary_demo.py | 1,113 | 3.9375 | 4 | names = ['sean', 'queenie', 'chris']
scores = [90, 100, 80]
def find_score(name, score):
return score[name.index('chris')]
print(find_score(names, scores))
# how to create a dictionary
grades = dict()
# grades = {}
grades['queenie'] = 100
print(grades)
grades = {'sean':95, 'queenie':100, 'chris':90}
print(len... |
7de0c5510bda333a89d6050e9cd4bfaa1635d7d3 | queeniekwan/mis3640 | /session07/iteration_demo.py | 1,055 | 3.828125 | 4 | # for loop
current_sum = 0
for i in range(0, 101, 2):
print(f'The value of i is {i}')
current_sum = current_sum + i
print(f'Currently, the sum is {current_sum}')
print()
# while loop 1
def countdown(n):
while n > 0:
print(n)
n = n - 1
print('Blastoff!')
# countdown(10)
# whil... |
ce7990693175eab9465ba280d06b8ec38e7c22a0 | queeniekwan/mis3640 | /session05/ex_05.py | 1,732 | 4.125 | 4 | import turtle
import math
from turtle_shape import circle, arc, polygon, move
def circle_flower (t, r):
"""
Draws a circle flower, t is a turtle, r is the radius of the circle
"""
for _ in range(6):
arc(t,r,60)
t.lt(60)
arc(t,r,120)
t.lt(60)
def yinyang (t):
"""
... |
015fdf447eeac730ee95921dab057a8366aa5441 | timothyfranklinpowers/ciss441 | /A1processdata.py | 759 | 3.5 | 4 | # Assignment: A1
# Name: Timothy Powers
import csv
import json
row_count = 0
terrorism_data = []
# importing the csv file: each row is a list
with open('terrorism.csv', 'r') as csvfile:
terrorism_stream = csv.DictReader(csvfile, delimiter=',', quotechar='"')
# moves over the data by row
for terror... |
3c6943ddaa8d8ecd4d31bf711238b53325d1081c | MariaDashkova/pythonProject | /main.py | 1,856 | 3.71875 | 4 | # 1.
# Вх: список строк, Возвр: кол-во строк
# где строка > 2 символов и первый символ == последнему
from typing import List, Tuple
def me(words):
if len(words) != 0:
count = 0
sp = words.split()
for st in sp:
if (len(st) > 2) & (st[0] == st[len(st) - 1]):
count... |
4babb313798da7167ba3ffbf63c6ce25ee2528c5 | sayaliupasani1/Learning_Python | /basic_codes/list1.py | 899 | 4.15625 | 4 | fruits = ["Mango", "Apple", "Banana", "Chickoo", "Custard Apple", "Strawberry"]
vegetables = ["Carrots", "Spinach", "Onion", "Kale", "Potato", "Capsicum", "Lettuce"]
print (type(fruits))
print(fruits)
#fruits.extend(vegetables)
#print(fruits)
#fruits.extend(vegetables[1])
print (fruits)
fruits.extend(vegetables[1:3])
... |
acf185f967bab8d3111bc6960294ea116d48cb1a | elkin5/curso-python-azulschool | /src/examples/ejericiosE2cadenas.py | 656 | 4.21875 | 4 | '''1.- Dada la cadena “El veloz murciélago hindú comía feliz cardillo y kiwi”, imprimir su variante justificada a la derecha rellenando con ‘>’, a la izquierda rellenando con ‘<‘ y centrada en 60 caracteres con asteriscos utilizando métodos de cadenas.'''
string = "El veloz murciélago hindú comía feliz cardillo y kiwi... |
eae58b8d9627cd89c9e307b1bcd4c6d1f60ce02e | elkin5/curso-python-azulschool | /src/examples/ejArgsVariables.py | 717 | 3.640625 | 4 | def suma(*args):
num = 0
for arg in args:
num += arg
return num
def producto(*args):
num = 1
for arg in args:
num *= arg
return num
OPERACIONES = {
"suma": suma,
"producto": producto,
}
def operacion(*args, **kwargs):
return OPERACIONES.get(kwargs.get("operacion"))... |
ae5a715067594cf95bb4e2e39f312f05fa2b82d7 | SophieLi0720/Calculator | /calculator_gui_creator.py | 4,351 | 3.796875 | 4 | from tkinter import *
from tkinter.ttk import *
B_ROWS = 5
B_COLUMN = 4
KEYS = [['AC', '+/-', '%', '/'],
['7', '8', '9', '*'],
['4', '5', '6', '-'],
['1', '2', '3', '+'],
['0', '.', '=', None]
]
class Calculator:
"""This class created the calculator window, display section... |
9e92a29c393dba24de10935ebf7c6ec0b6047d46 | LOLgabbthinksimdog/youchoose | /models/create.py | 823 | 3.609375 | 4 | import sqlite3
import os
db_file = "{}/data.db".format(__file__[::-1].split("/",1)[1][::-1])
print("creating db at {}".format(db_file))
os.system("rm " + db_file.replace(" ", "\ "))
db = sqlite3.connect(db_file)
cur = db.cursor()
cur.execute("""CREATE TABLE videos (
id INTEGER,
category TEXT NOT NULL,
lik... |
d3b6422d5771037d65dea3d9726a543f87c4ba98 | JamesK3/DirtyToDo-CLI | /entryMgmt.py | 147 | 3.6875 | 4 | #!/usr/bin/env python3
import re
def list():
tellMe = "blue"
while not re.search(r"x",tellMe):
tellMe = input("How you doin!?!")
|
87847404c3c40ae9c513c6b598ea56fc1d77faff | Wheelspawn/Python-Data-Structures | /Stack.py | 313 | 3.609375 | 4 | class Stack(object): # FILO-enforced list
def __init__(self,stack=[]):
self.stack=stack[:]
def push(self, v):
self.stack.append(v)
def pop(self):
v = self.stack[-1]
self.stack.remove(self.stack[-1])
return v
def peek(self):
return self.stack[-1]
|
6b77f680f49f03e939f5bb68c04dcdb3f720bcec | aroulin/binary-analysis | /python/unix-passwd-dict-crack.py | 1,192 | 3.78125 | 4 | import crypt
import string
def testPass(cryptPass, dictFile):
"""
Crack linux /etc/shadow password a dictionary file
:param str cryptPass: password in linux /etc/passwd format
e.g., $6$salt$hashed_password
:param str dictFile: dictionary file
Prints the cracked password, ... |
ff735eb4017cf74380938fd3f1404b34a209934f | mseverinov/Uno | /probability v2.py | 816 | 3.65625 | 4 | n = 25 #number of success cards in pool
N = 108 #total number of cards in pool
M = 7 #hand size
m = 7 #number of success in hand
def handProb(m, M, n, N):
"""Probability the m success are in opponent's hand
m := number of success cards drawn
M := hand size
n := # of success cards in pool
N := # of... |
ab3d969e9b560e7145ab7e006f3f4926c6d04821 | Satyabratadas/Python_mini_Project | /star.py | 349 | 4 | 4 |
def star(a,b):
if b == True:
c = 1
while c <= a:
print(c * '*')
c = c+1
else:
while a > 0:
print(a * '*')
a = a-1
if __name__ == '__main__':
x= int(input("enter the number of line you print: "))
y = bool(int(input("enter 0 to fals... |
33254dc36c82a377fa9edad72cfbee29ae3e7e09 | MasayaGit/atcoder | /src/ABC_179/A.py | 179 | 3.5 | 4 | import sys
input = sys.stdin.readline
S = input()
S = S.replace('\n','')
s_list = list(S)
if s_list[-1] == "s":
new_S = S + "es"
else:
new_S = S + "s"
print(new_S) |
7693ec8848f94f4375fa79e2d216744c71d4f56f | michaelpeng/anagramsgalore | /anagramlist.py | 1,251 | 4.3125 | 4 | """
Given a list of strings, tell which items are anagrams in the list, which ones are not
["scare", "sharp", "acres", "cares", "ho", "bob", "shoes", "harps", "oh"]
return list of lists, each list grouping anagrams together
"""
"""
Function to check two strings are anagrams of each other
'scare'
'acres'
True
"""
de... |
3b1c5e825adc3557e4265a83d2ecbc0c2f5248c5 | JoaoGabrielDamasceno/Estudo_Python | /coleção/counter.py | 928 | 3.890625 | 4 | """
Passado uma lista/tupla/dicionario(qualquer iteravel, string tb), verifica a quantidade de vezes dos elementos -> qtd vai ser o valor e o elemento a chave
"""
from collections import Counter
lista = [1,2,3,4,4,42,2,2,342,5,1,1,23,4,5,6,5,6,7,8]
rest = Counter(lista)
print(rest)
#EXEMPLO INTERESSANTE
texto = """... |
c6e031a8b5ac5fdb3b2d48a9b21ad676a03408c1 | JoaoGabrielDamasceno/Estudo_Python | /funções/kwargs.py | 570 | 3.625 | 4 | """
**kwarg
->Ao contrário do *args, tranforma os parametros extras em um dicionario
"""
def cores_favoritas(**kwargs):
for chave, valor in kwargs.items():
print(f'{chave.title()} gosta de {valor}')
cores_favoritas(marcos = 'vermelho')
"""
NAS FUNÇÕES DEFINIR OS PARAMETROS NESSA ORDEM
1° PARAMETROS OBR... |
892c41dc875283db6c1a049e07277ef7365b5d41 | JoaoGabrielDamasceno/Estudo_Python | /coleção/deq.py | 208 | 3.5625 | 4 | """
DEQ -> lista de alta perfomace
"""
from collections import deque
deq = deque('geek')
print(deq)
#ADICIONANDO NO COMEÇO
deq.appendleft('a')
print(deq)
#REMOVENDO DO COMEÇO
deq.popleft()
print(deq) |
097e582da15e74f03d068917779f50f5560b845e | JoaoGabrielDamasceno/Estudo_Python | /Iteradores e Geradores/iterator_iterable.py | 358 | 4.375 | 4 | """
Iterator -> Objeto que dá para ser iterável e retorna um dado.
-> Se consegue usar a função next()
Iterable -> Função que retorna um iterável
-> Retornará um objeto quando a função iter() for chamada
lista = [1,2,3]
- O pyhton pega essa lista e faz iter(lista) num laço de repetição
- A cada pass... |
952032c3f166d4466cbf50864621a0c8e26b51b5 | JoaoGabrielDamasceno/Estudo_Python | /Variaveis/booleano.py | 237 | 3.5625 | 4 | """
VERDADEIRO OU FALSO ---> True ou False
"""
ativo = True
logado = False
print(ativo)
print(not ativo)
# OR (ou um ou outro deve ser verdadeiro)
print(ativo or false)
#AND (dois precisam ser verdade ou falso)
print(ativo and logado) |
3e09d451edaff7b0876ac743b2ddd42a82f5305e | JoaoGabrielDamasceno/Estudo_Python | /Lambdas/any_all.py | 419 | 4.03125 | 4 | """
ANY E ALL
All -> retorna se TODOS os elementos do iteravel são True ou o iteravel está vazio (vaio é false mas o all faz como se fosse true)
ANY -> retorna se ALGUM elemento do iteravel for True e se for vazio sera False
"""
print(all([0,1,2,3,4,5]))
print(all([1,2,3,4,5]))
nomes = ['Joao', 'Juliana', 'Joaquim']... |
3553a31fc70ad0b2415fbdebfcf40aed10723247 | bitacademy-howl/python | /1. basic/Function/func_ex.py | 2,703 | 3.71875 | 4 | # func_ex.py
# 함수에 관한 코드
def dummy():
pass #구현은 나중에, 그냥 비워두면 python이 내부 블럭을 찾을 수 없다
def print_hello():
print("Hello Python")
def times(a, b):
return a*b
def do_nothing():
return
# 함수의 호출
dummy() # 리턴값이 없는 경우
print_hello()
print(times(10,10))
print(do_nothing())
# 여러 개의 값을 반환
def ... |
546b657b186fa88b2a1f9051eebc38b79fab8c47 | bitacademy-howl/python | /z. practice/Practice01.py | 334 | 3.9375 | 4 | while True:
a = input("수를 입력하세요 : ")
print(a, type(a))
if a.isdigit():
a = int(a)
if(a%3 == 0):
print("3의 배수입니다.")
break
elif(a%3 != 0):
print("3의 배수가 아닙니다.")
else:
print("숫자만 입력가능합니다.") |
14824da26bb4e6bbc573b79dcb306e147cc927d3 | bitacademy-howl/python | /1. basic/Quiz02/quiz02_1_teacher.py | 341 | 3.6875 | 4 | # 수를 입력 받음
while True:
num = input("수를 입력 하세요 : ")
if num.isdigit():
break
print("정수가 아닙니다. 다시 입력하세요.")
total = 0
to = int(num)
for i in range(1, to + 1):
if i % 3 == 0:
total += i
print("1부터 {}까지 3의 배수의 합 = {}".format(to, total))
|
9fd7bffd0ef5045ff3f9743d4ec55b3391d75feb | bitacademy-howl/python | /1. basic/Quiz02/quiz02_3_teacher.py | 317 | 3.546875 | 4 | def summary(*args):
data = []
total = 0
for arg in args:
if isinstance(arg, (int, float)):
data.append(arg)
total += arg
return total, max(data), min(data), total / len(data)
total, maxval, minval, avg = summary(80, 75, 90, 95, 85)
print(total, maxval, minval, avg)
|
53cb5b2bf689b3d6eb718602474883801995a6ba | bitacademy-howl/python | /1. basic/practice/practice01_1/keyboardIn.py | 957 | 3.796875 | 4 | # 키보드 입력을 받아 비교 및 예외처리,
# 필터링을 담당하는 클래스 등을 정의
class getKeyinput:
args = print("입력 : ")
i
return args
class ExceptionHandler:
def isNumber(args):
try:
args.
class Point:
instance_count = 0 # 클래스 영역
#생성자
def __init__(self, x = 0, y = 0):
self.x, self.y = ... |
d719bcce8fd2187281020d1a0376feed143594dc | bitacademy-howl/python | /1. basic/Collection/tuple_ex.py | 835 | 3.71875 | 4 | # tuple_ex.py
# 튜플
# 시퀀스형, 변경불가 자료형
# 튜플 생성 : ()
t = (1, 2, 3)
print(t, type(t))
#()를 생략해도 튜플로 인식
t = 1, 2, 'Python'
print(t, type(t))
# 연결 : +
t2 = t + (1, 2, 5)
print("t2 : ", t2)
# t3 = t + 1, 2, 5
# print("t3 : ", t3)
# 반복 : *
print(t*3)
# 인덱싱과 슬라이싱 가능
# t2에서 'python', 3, 4를 추출해 봅시다.
print(t2[2:5])
# 길이를 얻어옵... |
c8d8193fa038b5edf51e0b120784be67a2515314 | jasonforever365/python-file | /如何建立excel表格.py | 392 | 3.875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Jan 17 20:26:11 2021
@author: zhou jian
"""
import pandas as pd
s1 = pd.Series([1,2,3],index=[1,2,3],name='A')
s2 = pd.Series([10,20,30],index=[1,2,3],name='B')
s3 = pd.Series([100,200,300],index=[1,2,3],name='C')
df = pd.DataFrame({s1.name:s1, s2.name:s2, s3.name:s3})
#d... |
9712cdffad9097498461df502949ef2b392a02f9 | MatFix/Analysis_package | /batchRenamer.py | 1,729 | 3.953125 | 4 | #! /usr/bin/env python3
'''Rename the .omf files in a directory to the format A_{ii}.ovf, where
ii is an increasing counter
Args:
-r <DIR> : renames the .ovf files in <DIR>
no arg : renames all .ovf files in the current directory
Notes:
If no <DIR> is set it defaults to the current working ... |
7a84881b612e947b5888ae5750550d39d2417739 | amen619/python-core-tutorials | /lesson.01/deposit.py | 467 | 3.984375 | 4 | # Пользователь вводит ежемесячный взнос и на сколько месяцев он
# хочет оставить деньги в банке
# Сколько денег у него будет в конце ?
month_count = int(input('Ежемесячный вклад: '))
monthly_amount = int(input('Срок вклада: '))
total_fee = month_count * monthly_amount
print('Общая сумма сбережений: ', total_fee)
|
d67bbaa3f7f219fa075a3f36c9d007efc9b8dea4 | amen619/python-core-tutorials | /lesson.06/even.py | 157 | 3.75 | 4 | # Распечатать четные числа от 1 до 100
index = 2
while index <= 100:
if index % 2 == 0:
print(index)
index += 1
|
d1c1453c0bef8d41adc16cae7f84caf5042d19e7 | amen619/python-core-tutorials | /lesson.15/functions.py | 907 | 4.09375 | 4 | # print('')
# max([1, 3])
# [1, 3].sort()
# [1, 3].reverse()
# [1, 3].append(3)
# len('test')
# def count_number_occurrences(number, numbers):
# counter = 0
# for num in numbers:
# if number == num:
# counter += 1
#
# print(counter)
#
#
# number = int(input('Enter the searched number: ... |
307dcc5caf6703def282225461c8cec51c82bcc9 | amen619/python-core-tutorials | /lesson.02/homework_explanation.py | 273 | 4 | 4 | distance = int(input('distance: '))
gasoline_consumption = int(input('gasoline consumption: '))
gasoline_price = 0.9
summary = gasoline_price * (distance * gasoline_consumption) / 100
print('Summary: ', summary)
# 100 km - gasoline_consumption
# distance - x litrov
|
7b00c46da5f52cc178899727edc8cdc65279418c | amen619/python-core-tutorials | /lesson.15/homework.py | 2,042 | 3.796875 | 4 | # 5. Ölçüsü 9 olan massiv yaradın.
# Massivdəki rəqəmlərin yerlərini tərsinə çevirən program
# yazın. (0-cı indeksi 9-la, 1-i 8-lə və s.)
# [0, 12, 32, -45, 65, 7, 23, 1, 6]
# [6, 1, 23, 7, 65, -45, 32, 12, 0]
# 0 - 8
# 1 - 7
# 2 - 6
# 3 - 5
# 4 - 4 (9 // 2) нужно остановиться на 4ом индексе
# индекс элемента слева б... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.