blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
3863244f7657b1e117f50bd79f5fe6ddf8799daa | slyons777/Digital-Crafts-Classes | /programming101/errorhandles.py | 168 | 4.09375 | 4 | try:
num = int(input("Enter a number: \n"))
while num > 0:
num -=1
print(num)
except ValueError:
print("You did not enter a number.")
|
9416fc7f286feaf295b1bfd461a442199ac319e5 | DanielAShurmer/PythonBootcamp | /Exercises/FindSumOfUniqueNumbers.py | 634 | 3.984375 | 4 | ListOfValues = []
CompleteList = []
FirstEntry = input("Enter Value 1:")
ListOfValues.append(FirstEntry)
CompleteList.append(FirstEntry)
ProposedEntry = input("Enter Value 2:")
if ProposedEntry in CompleteList:
ListOfValues.remove(ProposedEntry)
else:
ListOfValues.append(ProposedEntry)
CompleteList.append(Propose... |
28ae80c50e2f4e169209d0da9350c51ab1a7388c | kuchunbk/PythonBasic | /9_date_time/Sample/date-time_ex1.py | 1,514 | 4.21875 | 4 | '''Question:
Write a Python script to display the various Date Time formats.
'''
# Python code:
import time
import datetime
print("Current date and time: " , datetime.datetime.now())
print("Current year: ", datetime.date.today().strftime("%Y"))
print("Month of year: ", datetime.date.today().strftime("... |
0cec90b506d8908a9d3d3ea7d54b9cbe92baed75 | agoncecelia/datascience | /user_input.py | 193 | 4.15625 | 4 | name = input("Please tell me your name: ")
age = int(input("Please tell me your age: "))
print("You are " + name + " and your age is: " + str(age))
if age > 18:
print(name + " can drive")
|
08b5ed69357a7a007665d5b48c38341a74c628a2 | Strigalet/Python | /Curse_work/Cursed_Newton.py | 2,724 | 3.5625 | 4 | import re
def coefs():
global n
cfs = []
try:
n = int(input("Enter the order of your polynomial: "))
except ValueError:
print("Enter the correct data")
return coefs()
if n < 0 or n >50 :
print("Enter the correct data")
return coefs()
i = n
while len(c... |
57ac2bb6d0ac6cea0ed8c5c51574cd93c422428c | ao9000/tic-tac-toe-ai | /game_interface/pygame_class/textbox.py | 3,829 | 3.78125 | 4 | """
This is a class made from Pygame.font object
Pygame.font object is for creating text in textboxes in the pygame window
More documentation can be found at the pygame official documentation
https://www.pygame.org/docs/ref/font.html
"""
import pygame
from game_interface.color import color_to_rgb
cl... |
5b5d91eed09f373044b8f7431d4f6a6da7e0b339 | magmom7/algo | /queue/deque.py | 250 | 3.671875 | 4 | from collections import deque
n = int(input())
cards = deque(list(range(1, n+1)))
res = []
while cards:
card = cards.popleft()
res.append(card)
if cards:
card = cards.popleft()
cards.append(card)
print(res)
|
d1c9de4204c1c000b1313d7de5b63aa2057010ed | AbdulrahmanIbraheem/chapter4-loops-problems | /Ocean Levels2.py | 529 | 4.375 | 4 | # 3. Ocean Levels
# Assuming the ocean’s level is currently rising at about 1.5 millimeters per year, write
# a program that displays a table showing the number of millimeters that the ocean will
# have risen each year for the next 25 years.
print("year\t\t\t\t\t\tocean level".title() )
print("----------------... |
d26d0bc9ee190e99251454963dd066f1f4d69e14 | yuchitoto/CUHK-CSCI-2017-2021-Course-Source-Repository | /CSCI 3320/2020_sem2/program_asgn/asgn2_2020/ex2.py | 5,211 | 3.640625 | 4 | import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import make_blobs
from sklearn.model_selection import train_test_split
# Calculate the Gini index for a split dataset
def gini_index(groups, classes):
# Input: groups: atuple of left dataset and right dataset after the split
# clas... |
b1da275d883985a69dc84cd9ff41710b6a98cc3d | mtjuney/simples | /other/test_dorasure.py | 630 | 3.5 | 4 | import random
def dice(plus=False):
success_count = 0
d = random.randint(1, 6)
if d >= 4 or (plus and d >= 2):
success_count += 1
if d == 6:
success_count += dice(plus=True)
elif d == 1:
success_count -= 1
return success_count
def role(num):
success_count... |
6583ff0f0c9c3bfbe4ca3dfafded82716badcd16 | faculty-of-unnatural-sciences/29-02 | /AV1DSIO-4.py | 163 | 3.640625 | 4 | a = int(input('Prvi unos: '))
b = int(input('Prvi unos: '))
#print prije swapa za test
print(a)
print(b)
a,b=b,a
#print poslije swapa za test
print(a)
print(b)
|
acc8860470b0001df7b8ae5651c2f43957062c25 | AtilaCosta87/Python | /cursopython/pythonteste/aula21ambiente02.py | 485 | 4.125 | 4 | def soma(a=0, b=0, c=0):
"""
-> Faz a soma de três valores e mostra o resultado na tela.
:param a: O primeiro valor
:param b: O seguando valor
:param c: O terceiro valor
Função criada por Átila Costa na aula do canal CursoemVideo
"""
s = a + b + c
print(f'A soma vale {s}', end='')
... |
cf50d37f3f39747471bd2b01b00c2854a4930cee | ManojKrishnaAK/python-codes | /FILES/filecopy1.py | 318 | 3.765625 | 4 | #filecopy1.py
import os
sfile=input("Enter Source file Name:")
dfile=input("Enter Dest. file Name:")
if (os.path.isfile(sfile)):
sp=open(sfile,"r")
dp=open(dfile,"w")
data=sp.read()
dp.write(data)
print("souce file data copied into dest file:")
sp.close()
dp.close()
else:
print("source file does not exists")
|
f331ad55f2bab5a28b07d2799f1d29fd263d2e4f | DamonOuyang/Python-Learning | /classOOb/serverce.py | 1,161 | 3.546875 | 4 | '''
#!/usr/bin/python3
# 文件名:server.py
# 导入 socket、sys 模块
import socket
import sys
# 创建 socket 对象
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# 获取本地主机名
host = socket.gethostname()
port = 9999
# 绑定端口
serversocket.bind((host, port))
# 设置最大连接数,超过后排队
serversocket.listen(5)
while True:
# 建立客户端... |
1b78b93e78d9452a84d27ceecf0c1c695736e3e4 | camagar/holbertonschool-higher_level_programming | /0x04-python-more_data_structures/1-search_replace.py | 206 | 3.875 | 4 | #!/usr/bin/python3
def search_replace(my_list, search, replace):
if my_list is None:
return None
new_list = list(map(lambda i: replace if i == search else i, my_list))
return (new_list)
|
fcc6eac74883cf64a19b5a829d4589521435c2cc | hrshenk/advent_of_code_2016 | /01/challenge_1.2.py | 1,121 | 3.59375 | 4 | file = open('input.txt', 'r')
directions = file.read().split(', ')
direction = 0 # 0 is North, 1 is East, 2 is South, 3 is West
coordinates = [0, 0]
history = {}
for d in directions:
#determine how many blocks we'll travel in this instruction
blocks = int(d[1:])
#determine the direction we'll be facing
... |
aafd0f721abd1d1d3c4f2b3c5780bcf977cfd4e7 | ubcweicai/python-tutorial | /Excel.py | 455 | 3.65625 | 4 | class Solution(object):
def convertToTitle(self, n):
"""
:type n: int
:rtype: str
"""
tuple1 = ('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z')
result = ''
while n > 0:
get = (n-1) % 26
... |
8530132eea44fdb8a300c1daefe9692dd1d92d43 | dimaggiofrancesco/Sudoku-checker | /Sudoku checker.py | 2,482 | 3.734375 | 4 |
DESIRED_SUM = 1+2+3+4+5+6+7+8+9
INVALID_GRID = [[1,2,3,4,5,6,7,8,9],
[1,2,3,4,5,6,7,8,9],
[1,2,3,4,5,6,7,8,9],
[1,2,3,4,5,6,7,8,9],
[1,2,3,4,5,6,7,8,9],
[1,2,3,4,5,6,7,8,9],
[1,2,3,4,5,6,7,8,... |
bf06c02d8a46d84571dea8cbaff7469074b5130c | nivlab/NivLink | /nivlink/screen.py | 9,927 | 3.671875 | 4 | import numpy as np
def _ellipse_in_shape(shape, center, radii, rotation=0.):
"""Generate coordinates of points within ellipse bounded by shape.
Parameters
----------
shape : iterable of ints
Shape of the input image. Must be length 2.
center : iterable of floats
(row, column)... |
4e8cc3b97d68a03e8059a0f25aaebd0b1088a320 | nekapoor7/Python-and-Django | /IMP_CONCEPTS/Python Tutorial/facade_designpattern.py | 1,063 | 3.5625 | 4 | class Sensor(object):
def __init__(self):
pass
def sensorON(self):
print("Sensor is ON")
def sensorOFF(self):
print("Sensor is OFF")
class Smoke(object):
def __init__(self):
pass
def smokeON(self):
print("Smoke is ON")
def smokeOFF(self):
pri... |
51414d39c94ab8e44ba3d42cf72629c9b3cabb1a | gary-loayza/Big-Data-with-Spark-and-Python | /Basics/friends-by-age.py | 1,119 | 3.71875 | 4 | from pyspark import SparkConf, SparkContext
conf = SparkConf().setMaster("local").setAppName("FriendsByAge")
sc = SparkContext(conf = conf)
# Function for parsing each string/row from raw data
def parseLine(line):
fields = line.split(',')
age = int(fields[2])
numFriends = int(fields[3])
return (age, n... |
da70ea636266a71d44ec0accd528ab72c2f2f3de | varfgehu/data_structures | /algorithms/count_constants_in_string.py | 1,128 | 4.15625 | 4 | """
Given a string, count the number of constants.
Note a constant is a letter that is not a vowel.
a letter that is not a, e, i, o, or u.
"""
input_str_1 = "abc de"
input_str_2 = "GerGoVarFalvI"
def prepare_string(str):
str = str.lower()
str = str.replace(" ", "")
return str
def count_constants(input_s... |
4439d7172aa52d5be811fa29a2f621ea92ac1f8d | Vincetroid/learning-python | /rest_apis_with_flask_and_python/advanced-set-operations.py | 392 | 3.984375 | 4 | #difference
friends = {"Bob", "Anne", "Rolf"}
abroad = {"Bob", "Anne"}
local_friends = friends.difference(abroad)
print(local_friends)
#union
two_fruits = {"Orange", "Tangerine"}
one_fruit = {"Apple"}
shake = two_fruits.union(one_fruit)
print(shake)
#intersection
art = {"Bob", "Jen", "Rolf", "Charlie"}
science = {"B... |
f689904c908a8ebafb8a8b9a39c6cfa349cd3ec3 | Miguelflj/Prog1 | /sala/tabuada.py | 223 | 3.8125 | 4 |
def main():
print "TABUADA DE MULTIPLICAMENTO"
for i in range(1,10):
for j in range(1,11):
mult = i * j
print str(i) + "X" + str(j) + " = " + str(mult)
print"\n"
main() |
b75c2e722a873313f355db3d20ebeba177d95d62 | maryb0r/geekbrains-python-hw | /lesson03/example01.py | 740 | 4.21875 | 4 | # Реализовать функцию, принимающую два числа (позиционные аргументы) и выполняющую их деление.
# Числа запрашивать у пользователя, предусмотреть обработку ситуации деления на ноль.
def div(arg1, arg2):
if arg2 == 0:
return "Деление на ноль!"
return f"{arg1} / {arg2} = {arg1 / arg2}"
try:
... |
b5ae191065681d283f1aed12160d96c0ba869eaf | DiegoT-dev/Estudos | /Back-End/Python/CursoPyhton/Mundo 01/Aulas/Aula09.py | 236 | 3.875 | 4 | frase = 'Curso em Vídeo Python'
#print(frase[::3])
#print(frase.count('o'))
#print(frase.upper().count('o'))
#print(len(frase))
#print(frase.replace('Vídeo','Android'))
#frase = frase.replace('Python','Android')
#print(frase.split())
|
9f21505ea472185fa6c720a98650bcecaf6f4aea | jalexanderbryant/python-practice | /data_structure_and_algorithms/sllist/sllist.py | 5,583 | 4 | 4 | class SingleLinkedListNode(object):
def __init__(self, value, next):
self.value = value
self.next = next
def __repr__(self):
nval = self.next and self.next.value or None
return f"[{self.value}:{repr(nval)}]"
class SingleLinkedList(object):
"""
Single Linked List defini... |
85027db64fd2b62c1e9e3ba6f674df7e8bd5f958 | suresh-kasipandy/Python-Machine-Learning-Code | /PML/ch4. Building Good Training Sets - Data Preprocessing/DFfromCSV.py | 1,155 | 3.796875 | 4 | import pandas as pd
from io import StringIO
csv_data = '''A,B,C,D
1.0,2.0,3.0,4.0
5.0,6.0,,8.0
10.0,11.0,12.0,'''
"""If you are using Python 2.7 you need to convert the string to unicode:
csv_data = unicode(csv_data)"""
#StringIO allows us to read the string csv_data as if it were regular local csv file
... |
c311678850282127bc82fcfd84a21c9b6bff44d3 | ApoorvaJu08/Python | /python basics/no_of_word_string.py | 95 | 3.828125 | 4 | s = input("Enter a line: ")
print("Number of words in the line are %d" % (len(s.split(" "))))
|
6859354ae720cda4db612eb7e5a9d3db38b90431 | foureyes/csci-ua.0479-spring2021-001 | /assignments/hw05/wordsy.py | 4,361 | 4.625 | 5 | """
wordsy.py
=====
This file will be used as a module in another file. Implement two functions (there's a third one that's optional).
1. shuffle
2. scramble_letters
3. sort_words_by_length (optional)
shuffle(lst)
-----
parameters:
* lst - a list of values (any values)
return:
* None (does not return anyth... |
2472431fb85f89a1d5bc50046699a0f171b245fb | pravsp/problem_solving | /Python/ReverseString/revString.py | 465 | 3.8125 | 4 | import math
class RevString:
def reverseString(self, s: list) -> None:
"""
Do not return anything, modify s in-place instead.
"""
mid_point = math.ceil(len(s)/2)
for i in range(mid_point):
tmp = s[i]
s[i] = s[-i-1]
s[-i-1] = tmp
if __name... |
a5ec1ed495bd577740df988e2312ad050ddf3085 | sankeerthankam/Code | /Leetcode/Problemsets/Facebook/Telephone/125. Valid Palindrome.py | 267 | 3.78125 | 4 | # Approach 1:
# COnvert the sentence to lower case and strip the trailing and leading spaces
# Using regex, replace special characters with empty string
def isPalindrome(s):
s = s.strip().lower()
import re
s = re.sub('[^a-z0-9]+', '', s)
return s[::-1] == s
|
2f6872afd069e2a37a13aeda2789f5132eb5be98 | nmaryala/rl-framework-687-public | /rl687/environments/gridworld.py | 4,500 | 3.90625 | 4 | import numpy as np
from .skeleton import Environment
np.random.seed(0)
class Gridworld(Environment):
"""
The Gridworld as described in the lecture notes of the 687 course material.
Actions: up (0), down (1), left (2), right (3)
Environment Dynamics: With probability 0.8 the robot moves in th... |
12eb23d9c7ab120fcdf7d4efd91346b53859ad88 | NehaAgarwal2598/Codeforces | /Magic Grid.py | 201 | 3.71875 | 4 | import itertools
N = int(input())
indices = list(itertools.product(range(N), range(N)))
print(indices)
'''
def magic(n):
for i in range(n**2):
n = int(input())
magic(n)
'''
|
bd7e49935619cbf1a5392571f9440810c6fac5ed | Oskhee/number-guessing-game | /number_guessing_game.py | 1,571 | 4.0625 | 4 | import random
def generate_random_value(first_number, last_number):
return random.randint(first_number, last_number)
def start_game():
random_value = generate_random_value(1, 10)
print("------------------------------------")
print("Welcome to the Number Guessing Game!")
print("------------------... |
4ba0656034bdc0173432a24fba3b34f74937171e | keitho18/tkinter_freecodecamp_course | /tkinter_tutorials/helloworld.py | 200 | 3.859375 | 4 | from tkinter import *
root = Tk()
#Creating a label widget
myLabel = Label(root, text="Hello World")
#Putting the widget into the GUI
myLabel.pack()
#We need a continual loop
root.mainloop() |
9debde8aef177c053c375a99643ef8d5ac616c6c | shen-huang/selfteaching-python-camp | /19100205/Ceasar1978/d6_exercise_stats_word.py | 1,870 | 3.890625 | 4 |
# 统计输入文本中英文单词的词频:
def stats_text_en(text):
text = text.replace('.', '')
text = text.replace('!', '')
text = text.replace('--', '')
text = text.replace('*', '')
text = text.replace(',', '')
text = text.replace('(', '')
text = text.replace(')', '')
text = text.replace(';', '')
te... |
33702d83530dab8054d86110e06c1ee76ec6403f | yaroslavrosokha/sfem | /input/strategies.py | 10,299 | 3.84375 | 4 | # Example strategies file
import numpy as np
import sys
""" This file contains strategy definitions. Each strategy function takes two lists/arrays as arguments.
The first argument is the list of actions. Action are either 1 (=Cooperate) or 0 (=Defect).
The second argument is the list of periods. ... |
9fa639e216dfd1e57087c76712646b2675ebec0c | Devany28/AprendiendoPython- | /Nombre.py | 558 | 4.125 | 4 | #PROGRAMA NOMBRE
#Arevalo Chavez Devany Yazmin
#Fecha de creacion: 25/09/2019
#Declaramos dos variables con la funcion input pidiendo al usuaro su nombre y sus apellidos
Nombre = input("Ingresa tu nombre \n")
Apellidos = input("Ingresa tus apellidos \n")
#Al colocar las " " se realiza la concatenacion (une la... |
15933f3f3dad6294e1e95357ab58a1907dfc9f0f | akash-potdar7/python-tuto | /strings/substr_in_string.py | 302 | 3.890625 | 4 | def count_substring(string, sub_string):
return string.count(sub_string)
def substring_occurances(string, sub_string):
occ = 0
sub_len = len(sub_string)
s_len = len(string)
for i in range(s_len):
if string[i : i+sub_len] == sub_string:
occ += 1
return occ
|
99c5d70b8be180da8c5c1d82b50ca73bfc0e1ed0 | viniciusvieir/DIT-pythonlabs | /lab2/cube.py | 380 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Jan 29 15:18:19 2018
@author: D16129083
"""
"""
EXERCISE 2
The value that surface area and volume are equals is 6.
"""
width = input('Type the width of the cube: ')
volume = float(width) ** 3
surface_area = 6 * float(width) ** 2
print('The volume of the cube is', volu... |
d14a12dab6925805f78049447a6a02dd03589c16 | rpinnola47/PYTHON | /TP 7 Fdla/EJERCICIO 7.py | 831 | 3.671875 | 4 | año=[0,0,0,0,0,0,0,0,0,0,0,0]
#meses es para el print del final
meses=["Enero","Febrero","Marzo","Abril","Mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre"]
legajo=int(input("ingrese el numero de legajo"))
maximo=0
while legajo!=-1:
dia=int(input("ingrese el dia "))
mes=int(in... |
92331e2e6f98a84b6459ad8f15f94358eda21338 | jumpmanhou/python-learning | /workspace/新建文件夹/Leetcode/easy/test1.py | 480 | 3.75 | 4 | def stringEnoc(s):
ls = list(s)
for i in range(len(ls)//2):
if ls[i] == 'a':
ls[i] = 'z'
else:
ls[i] = chr(ord(ls[i])-1)
if ls[len(ls)-1-i] == 'z':
ls[len(ls)-1-i] ='a'
else :
ls[len(ls)-1-i] = chr(ord(ls[len(ls)-1-i])+1)
... |
28e03229d981993c56fab5c1ee044c48d2e30d23 | sruthi0199/string-exercise | /Exercise #10.py | 119 | 3.546875 | 4 | s1=input("Enter a sentence:")
lis=[]
lis=s1.split(" ")
temp=lis[0]
lis[0]=lis[1]
lis[1]=temp
s1=" ".join(lis)
print(s1) |
01805ab98193e9b3e48ad280cbab5b6c604a43ee | nickfang/classes | /projectEuler/webScraping/problemTemplates/079.py | 635 | 3.671875 | 4 | # Passcode derivation
#
#A common security method used for online banking is to ask the user for three random characters from a passcode. For example, if the passcode was 531278, they may ask for the 2nd, 3rd, and 5th characters; the expected reply would be: 317.
#The text file, <a href="project/resources/p079_keylog.... |
f03d6532b2443182dfaf8d4a1ee12de9004697b0 | xuchef/GameOfLife | /format.py | 1,485 | 4.46875 | 4 | # Project - Conway's Game of Life
# Functions to format matrices
# Michael Xu
# May 19, 2020
# pyperclip module to copy strings to clipboard
import pyperclip
def to_grid(matrix):
"""
Formats a matrix as a grid.
Prints the grid and copies it to clipboard.
Args:
matrix (matrix): two dimen... |
c708fa632221a7cf5fbcf14e7a4c8e16ec76fd10 | MatiasPineda/projecteuler | /problems/problem12.py | 766 | 3.8125 | 4 | from math import sqrt
def n_th_triangular_number(n):
return (n*(n+1))//2
def factors(number: int) -> dict:
f = {}
i = 2
while number > 1 and number >= i:
if number % i == 0:
if i not in f:
f[i] = 1
else:
f[i] += 1
number //= i... |
b5725dff2d587aa90eea951f42688e07184d9679 | XingyuJin/LeetCode-Practice | /Array/minWindow.py | 1,091 | 3.765625 | 4 | """
@Description
Given a string S and a string T, find the minimum window in S which will
contain all the characters in T in complexity O(n).
@Author: Xingyu Jin
@Performance(on average):
Rumtime: 92 ms Memory: 14.6 MB
"""
def minWindow(s: str, t: str) -> str:
desired_count = {}
for c in t:
desired_... |
fb1941e7011d9c77dd8dc134cf0ea84b27205c04 | vigneshwaran444/python-folders | /2020/Linear-Regression/two_var_regression.py | 462 | 3.703125 | 4 | import pandas as pd
from sklearn.linear_model import LinearRegression
import matplotlib.pyplot as plt
#read data
dataframe = pd.read_csv('data/bmi_and_life_expectancy.csv')
x_values = dataframe[['BMI']] #training data
y_values = dataframe[['Life expectancy']] #target values
#train model on data
model = LinearRegressi... |
92e76e16666d49f52f636127298d5bb1bda30c71 | jfi1509/Python-Practice | /snippets/sort.py | 1,474 | 4.1875 | 4 | # Bubble sort
def bubble_sort(elements):
size = len(elements)
for i in range(size-1):
# flag to check for already sorted numbers
swapped = False
for j in range(size-1-i):
if(elements[j] > elements[j+1]):
# sort the numbers
elements[j+1], eleme... |
e6c8aff9e6287da6cf3210950e1722b7dc154c59 | IrinaMandarina/final_project | /platforms_module.py | 1,828 | 3.6875 | 4 | import pygame
from pygame.draw import *
import random
class Platform(pygame.sprite.Sprite):
def __init__(self, screen, x, y, l):
pygame.sprite.Sprite.__init__(self)
self.x = x
self.y = y
self.l = l
self.screen = screen
self.rect = pygame.Rect(self.x, self.y - 15, sel... |
a22b72f3934f0ac1fd92f4564ef072fdcffd5d36 | Kolaposki/ProjectEuler | /Solutions/p4.py | 747 | 4.0625 | 4 | """
name='p4',
project='Project Euler'
date='1/9/2020',
author='Oshodi Kolapo',
"""
"""
A palindromic number reads the same both ways. The largest palindrome made
from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-dig... |
7e4d7ce152ad89b4951c16c91bae9c240a2c2d4a | dean-shaff/poems | /texts/script.py | 692 | 3.890625 | 4 | # -*- coding: utf-8 -*-
"""
This code takes the English dictionary, separated into syllables,
and replaces all the weird yen characters with plus signs.
It also makes a copy of the dictionary with no syllable indication.
"""
filename2 = "mhyph.txt"
filename3 = "msyll.txt"
filename4 = "mdic.txt"
def make_dic(target_... |
f203c0e2bef620f638405245554dd7e916ba4ada | arunkumar-vg/HackerRank-ProjectEuler-Solved-Programs | /Project Euler #16: Power digit sum.py | 195 | 3.65625 | 4 | n=int(input())
for i in range(0,n):
val=int(input())
power=pow(2,val)
rem=0
sum=0
while(power!=0):
rem=power%10
sum+=rem
power//=10
print(sum)
|
be27bbc571f36f2f6bcf068bf8dfd8006d9a7e04 | laurelkorwin/hackbright-week2-assessment-classes | /assessment.py | 4,566 | 4.75 | 5 | """
Part 1: Discussion
1. What are the three main design advantages that object orientation
can provide? Explain each concept.
Abstraction: You can hide away the "how" of why things work, and interact easily
with your classes/instances
Encapsulation: You put all the data related to a "thing" o... |
c5b847e78cb9ae5a1121a3d9f351fa86d8c3f1b5 | rzuniga64/python | /udemy/lesson11_exceptionhandling/try.py | 383 | 4.15625 | 4 | try:
print("Enter a numerator: ")
numerator = int(input())
print("Enter a denominator: ")
denominator = int(input())
quotient = numerator / denominator
print(quotient)
except ZeroDivisionError:
print("Cannot divide by zero.")
print("Enter a new denominator: ")
denominator = int(input... |
4ca85c58751e729f38c017907ddbf764860b1389 | florimondmanca/tower-defense | /isometric/isosprite.py | 3,823 | 3.59375 | 4 | import pygame
import constants as cst
from . import isoutils
import gui
class IsoSprite(pygame.sprite.Sprite):
"""
A basic class which implements isometric perspective into the pygame.sprite.Sprite class.
IsoSprite(path_to_image, tile_pos) -> IsoSprite
Methods:
display(screen): Displays the spr... |
b5c7546e66c9fb8db412abfea70198bf4ecf30e5 | edu-athensoft/ceit4101python_student | /ceit_190910_zhuhaotian/py1108/flowctrl_03_if_elif_else.py | 372 | 4.09375 | 4 | # case 1
is_sunny = True
has_money = True
if not is_sunny:
print("I stay at home")
elif has_money:
print("I go shopping")
else:
print("I stay at home")
# case 2
number = 6
if number < 3:
print("{} is a small number".format(number))
elif number < 6:
print("{} is a medium number".format(number))
e... |
2dee698b2dd762d70bda8fc4dc13bbba02986c96 | parvatalaprasanth/Practice-Python | /goldmine.py | 784 | 3.703125 | 4 | # Python program to solve
# Gold Mine problem
MAX = 100
# Returns maximum amount of
# gold that can be collected
# when journey started from
# first column and moves
# allowed are right, right-up
# and right-down
def getMaxGold(gold, m, n):
dp={}
def get(gold,i,j):
if i<0 or i>=m:
return 0... |
77f08ec2d561100e61fdd01239dda321f6dd1ab4 | bigdata202005/PythonProject | /Day05/Ex09.py | 638 | 3.734375 | 4 | # 스레드 : 실행흐름이 여러개인 프로그램
# 다음은 스레드 프로그램이다
import time
import threading # 스레드를 생성하기 위해서는 threading 모듈이 필요하다.
def long_task(): # 5초의 시간이 걸리는 함수
for i in range(5):
time.sleep(1) # 1초간 대기한다.
print("실행 : {}회".format(i+1))
print("시작!!!")
threads = list()
for i in range(5):
t = threading.Thread(t... |
c4f264b88df3ab2360ef9511773702d883093c21 | rahuljamadagni147/PYTHON | /print_a_table_from_UI_using_functions.py | 158 | 3.875 | 4 | def table(x):
for i in range(1,11):
print(x, "X" ,i, "=" , x*i)
a=(int(input("Enter a number to get a table: ")))
table(a)
|
e4eb1081e5911e049c391b0db319856a522684aa | leksiam/PythonCourse | /Practice/RyzhovD/RyzhovDenis_2_comparator_ret.py | 499 | 4.15625 | 4 | def compare_and_return(x,y):
if x>y:
return x
else:
return y
# If You want to input variables from keyboard
# def compare_and_return(x, y):
# if float(x) > float(y): # change str type to float
# return x
# else:
# return y
# x = input('enter first number: x = ')
# y = i... |
2c554925ba890e20f8f48f5a4acc09b7ff1bf7df | sfeng77/myleetcode | /splitArrayLargestSum.py | 1,414 | 3.890625 | 4 | # Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorithm to minimize the largest sum among these m subarrays.
#
# Note:
# If n is the length of array, assume the following constraints are satisfied:
#
# 1 <= n <= 100... |
6a189f22435af2419e29ab25debf25982854c8c4 | matthewT53/Scripting | /lab06/echon.py | 768 | 4.3125 | 4 | #!/usr/bin/python
import sys
import re
# Demonstrate traversing through arguments
# for arg in sys.argv:
# print arg
argumentList = sys.argv
#print argumentList
#print len(argumentList)
# check if the user supplied the correct number of arguments
if len(argumentList) != 3:
sys.exit("Usage: ./echon.py <number o... |
7e084ac3e79caf5c05c5a7481062d40d3cf1a97f | zhangx21/istm-6212 | /stopwords.py | 459 | 4.125 | 4 | """
A filter removes English stopwords.
"""
import fileinput
import a
def process(line):
""" split lines into one word per line, Then remove the stop words."""
line = a.findall(r'\w+',line)
stopwords = ['and','the','to','a','e','i','o','u','t','s','of','her','it','in','you','that']
for word... |
c38eac0e2a71608670442f81713fb69834edb75f | Mabozaid0X1/Intro_to_programming_udacity_projects | /3.Adventure Game/adventure_game.py | 4,148 | 4.0625 | 4 | import time
import random
def print_pause(message_to_print):
print(message_to_print)
time.sleep(3)
enemy = ["troll", "dragon", "gorgon", "fairie", "pirate"]
wicked = random.choice(enemy)
def intro():
print_pause(
"You find yourself standing in an open field, "
"filled w... |
4418fa6ba1f0b6181c44240808cab19c645da143 | kate-bahdanovich/Python_hometasks | /Homework_5/input_class.py | 1,147 | 4.15625 | 4 | import datetime
class InputClass:
@staticmethod
def choose_event():
# read user choice from console
ans = input("choose event to input: 1 - for news, 2 - for advertising, 3 - for comment, 4 - to close the program =>")
while ans not in ("1", "2", "3", "4"):
ans = in... |
bf40ca6fed53cabea725bda25f73b0b2c92b66d3 | Doun2017/PythonStudyCode | /python_crash_course/chapter4/e4_1.py | 384 | 3.921875 | 4 | #4-1
names = ["boluo pisa", "niurou pisa", "haixian pisa", "liulian pisa"]
for pisa in names:
print("I like "+pisa)
print("I really love pizza!")
#4-2
pet_names = ["jinmao", "中华田园犬", "哈士奇", "泰迪犬"]
for dog in pet_names:
print("I like " + dog)
print("Any of these animals would make a great pet!")
numbers = list(range... |
19d237bd57ce95860888d5f5a02e743b1eacd74e | GiancarloCatafesta/Gian | /Exercicio 21 a 27.py | 1,501 | 4 | 4 | # Exercicio 22
'''noms = input('Digite um nome: ')
tt1 = noms.split()
tt2 = ''.join(tt1)
print('Seu nome em maiusculo é {}'.format(noms.upper()))
print('Seu nome em minusculo é {}'.format(noms.lower()))
print('Seu nome ao tem {}'.format(len(tt2)))
print('Seu primeiro nome é {}'.format(len(tt1[0])))'''
# Exercicio 23
'... |
26ddc2470a6671a3413205d5c02dce783b6d489d | xlistarer/homeworkfile | /main.py | 1,864 | 4.09375 | 4 | # This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
'''
Task 1
Files
Write a script that creates a new output file called myfile.txt and writes the string "Hello file world!"... |
9fcd90d7f40843922c803cb321758424cf8bfbe1 | ehsanyousefzadehasl/PF | /Season 2/5-more_divisors.py | 780 | 3.703125 | 4 | def divisorCounter(inNumber):
#print('entered')
iterator = 1
numOfDivisors = 0;
while(iterator <= inNumber):
if(inNumber%iterator == 0):
numOfDivisors = numOfDivisors + 1;
iterator = iterator + 1;
return numOfDivisors;
inNumList = list();
for iterator in range(20):
inNumList.append(int(input()));
numOfDi... |
15d1e30f448ec92ec5af2043b566ca8aeaa7038e | rohith2334/hackerrank | /python/Strings/Merge the Tools!.py | 402 | 3.65625 | 4 | def merge_the_tools(s, k):
# your code goes here
temp = []
count = 1
for i in range(len(s)):
if s[i] not in temp:
temp.append(s[i])
if count == k:
print(''.join(temp))
temp = []
count = 1
else:
count += 1
if __name__ =... |
36ee04c062692703c61c1aba045c5ab87800294f | muhammadrifky51/Alprog | /Soal Nomor 4 tugas baru.py | 314 | 3.8125 | 4 | angka1=input("Masukkan bilangan pertama : ")
angka2=input("Masukkan bilangan kedua : ")
hasil=str(angka1*angka2)
cekhasil=reversed(hasil)
print("\n")
if list(hasil)==list(cekhasil):
print("bilangan %s adalah bilangan palindrome")%(hasil)
else:
print("bilangan %s bukan bilangan palindrome")%(hasil) |
c71c50b659c967ef02bc7a2e9e088c63345fee31 | zevgenia/Python_shultais | /Course/p_types/example_27.py | 242 | 3.859375 | 4 |
import fractions
f = fractions.Fraction(2, 3)
print(f + 1)
import fractions # подключение рациональных, дробрых чисел
f = fractions.Fraction(2, 3)# числитель 2 знаменатель 3
print(f) |
c6074169448e4eb277913221835c5157ff7c0a6d | Abir-Al-Arafat/PythonCodes | /large.py | 178 | 4.25 | 4 | #Finding the largest value from the list of values
largest = -1
for num in [9,2,11,15,72,71,20]:
if num>largest:
largest=num
print(largest,num)
print("after",num) |
1c4565d8dfe214b3dc432ff7911da404c5f6fef7 | LuluwahA/100daysofcode | /Day 7.py | 221 | 3.953125 | 4 | print("hello")
print('hello')
x="hello"
print(x)
a= """hi there
this in not
my first python code
bye now, we will meet again. """
print(a)
x="hello, world!"
print(x[1])
b= "hello there"
print(b[2:5])
|
6e3a9dff57f2bc2837e9145bac5953ef322d8cbb | Tananiko/python-training-2020-12-14 | /functions.py | 644 | 3.5 | 4 | # Fgv. deklaráció
# Formális paraméter = adott függvény lokális változója
def print_three_times(times=3, message="Python"):
"""Kiirja haromszor, hogy Python"""
# i változó is a függvény lokális változója
for i in range(times):
print(message)
def add(n, m):
print_three_times(n + m, "osszeadas!... |
1ca8aa74ea47ae0abb098cedbab618a24fc079cf | thakurutkarsh22/Hacktober-Open | /tictactoe.py | 1,678 | 4.125 | 4 | global board
board = [[" "," "," "],[" ", " ", " "],[" ", " ", " "]]
player = "X"
'''
TO Print the board in a visually pleasing way
'''
def printBoard(board):
for line in board:
print(line)
'''
To Take in user input and replace the appropriate space
'''
def makeMove():
global player
x = in... |
6ac350585e4d005c3b0f18692418389ee9cf5a41 | Aasthaengg/IBMdataset | /Python_codes/p00003/s081193036.py | 413 | 3.671875 | 4 |
def check(a, b, c):
a2 = a ** 2
b2 = b ** 2
c2 = c ** 2
if (a2 + b2) == c2:
return True
else:
return False
n = int(input())
for c in range(n):
line = input()
datas = map(int, line.split())
li = list(datas)
a = li[0]
b = li[1]
c = li[2]
if check(a, ... |
fc55c1a9414bda312dad09900ded7aa3d025c6ba | Marcoakira/Desafios_Python_do_Curso_Guanabara | /Mundo3/Desafio106.py | 893 | 3.65625 | 4 | # Desafio106 o programa imprime o interative Help
#Funcções
def menu_bonito(nome_que_vai_no_menu):
print(f'\033[1:32:40m{"#"* len(nome_que_vai_no_menu)}####\033[m')
print(f' {nome_que_vai_no_menu}')
print(f'\033[1:32:40m{"#"* len(nome_que_vai_no_menu)}####\033[m')
print()
def menu_bonito2(nome_que_... |
84c511861189cf75d7fe76f3a361032a359a2f71 | vovakpro13/PythonLabs | /Lab_5/task_2.py | 873 | 3.59375 | 4 | import random
db = [
{
'last_name': 'Попов',
'phone_number': '+3806642342'
},
{
'last_name': 'Кукурудза',
'phone_number': '+38067686456'
},
{
'last_name': 'Колос',
'phone_number': '+380084003132'
},
{
'last_name': 'Федун',
'pho... |
0b97bd7ca654f32880df38118cfaa96de85516a2 | candyer/leetcode | /2021 May LeetCoding Challenge/10_countPrimes.py | 826 | 3.953125 | 4 | # https://leetcode.com/explore/challenge/card/may-leetcoding-challenge-2021/599/week-2-may-8th-may-14th/3738/
# Count Primes
# Count the number of prime numbers less than a non-negative number, n.
# Example 1:
# Input: n = 10
# Output: 4
# Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7.
#... |
442a60add5e0560cb7c21c523fe1586e5f59c0e0 | valexandersaulys/coding-puzzles | /p17-clone-graph.py | 457 | 3.671875 | 4 | #! usr/bin/python3
"""
Clone an undirected graph. Each node in the graph contains a label
and a list of its neighbors.
Nodes are labeled uniquely. We use '#' as a separator for node
label and each neighbor of the node. As an example, consider the
serialized graph {0, 1, 2#1, 2#2, 2}
undirected_graph = {
#node: [l... |
26ea9be8559f7e6b72f80f013250798d1ed343e5 | SSteve/AdventOfCode | /Advent2016/7.py | 2,488 | 3.5 | 4 | from collections import namedtuple
from typing import Iterable
TEST = """abba[mnop]qrst
abcd[bddb]xyyx
aaaa[qwer]tyui
ioxxoj[asdfgh]zxcvbn
abcd[bddb]xyyp"""
TEST2 = """aba[bab]xyz
xyx[xyx]xyx
aaa[kek]eke
zazbz[bzb]cdb"""
AbaPattern = namedtuple('AbaPattern', ['a', 'b'])
def SplitSequences(ip: str) -> list[str]:
... |
6a739cdbaab98978e1e6ef982fc8fa310569bfd2 | wheejuni/algorithm_bootcamp | /연습문제/summercoding/numbergame.py | 444 | 3.578125 | 4 | def solution(A, B):
ateam_numbers = sorted(A)
bteam_numbers = sorted(B)
if bteam_numbers[-1] <= A[0]:
return 0
return find_bigger(ateam_numbers, bteam_numbers)
def find_bigger(a_array, b_array):
winning_point = len(b_array)
for i in range(len(b_array)):
if a_array[i] >= b_... |
85dd8684eb4dd81c10cf6056048eb2f87f42a55c | anthonylopez15/py-ex | /loops ex.py | 745 | 3.71875 | 4 | produtos = []
resposta = 's'
total = 0
valide_preco = False
while resposta == 's':
produto = input('Nome do produto: ')
while valide_preco == False:
preco = input('Digite o preco do produto: ')
try:
preco = float(preco)
if preco <= 0:
print('O preco pre... |
9dbfefd416fc5ec56a76f303c9dccbd4fa938a02 | B2SIC/python_playground | /programmers/School/A/LCT_A1.py | 221 | 3.53125 | 4 | def solution(num_list):
re_list = []
t_list = sorted(num_list)
re_list.append(t_list[-1])
re_list.append(num_list.index(t_list[-1]))
return re_list
print(solution([3, 29, 38, 12, 57, 74, 40, 85, 61])) |
df1d2d4b7981c392590d1ffd157d07afc7209992 | varshini-07/python | /sum.py | 149 | 3.859375 | 4 | #sum of 10 nos
n=int(input("enter the number:"))
result=0
for i in range(1,n):
print("adding no: ",i)
result=result+i
print(result) |
0565d35606965d4cfcda6722d20102405786e85d | pallavi-ghimire/python_class_dec12 | /class_work.py | 229 | 3.84375 | 4 | x = [3,4,1,'a','b']
(x.index('a'))
y = ['p','q']
x.extend(y)
print(x)
x.pop()
print(x)
x.append('xyz')
print(x)
#sorting can not take place in the given list
x.remove(1)
print(x)
print(88 in x)
print(len(x)) |
71caf1d2bee6b6a362167f8eebf0f99114e52c49 | Sai-Sindhu-Chunduri/Python-programs | /sieveoferatosthenes.py | 437 | 4.3125 | 4 | '''Given a number n, print all primes smaller than or equal to n. It is also
given that n is a small number.
For example, if n is 10, the output should be “2, 3, 5, 7”. If n is 20,
the output should be “2, 3, 5, 7, 11, 13, 17, 19”. '''
n=int(input())
nonprimes=[]
for i in range(2,n+1):
if i not in nonprime... |
c0fe835fe6c132c59a6e30ae71dcb2bd825d2725 | sashaaero/PythonCourse | /Yolkin/POSYolkin.py | 1,534 | 3.5 | 4 | class Ex_buro:
def __init__(self, name, ad):
self.name = name
self.ad = ad
self.ships = []
self.guides = []
self.excursions = []
def __str__(self): # privet
return f'Бюро параходных экскурсий "{self.name}", наш адрес: "{self.ad}"'
def add_ship(self, ship):
... |
68ab04a6d573baec4322c474907e13e13eff2b5f | navyad/python-labs | /descriptor_1.py | 522 | 3.9375 | 4 | class NoneNegative(object):
def __init__(self, default):
self.val = default
def __get__(self, obj, obj_type):
print "get:"
return self.val
def __set__(self, obj, val):
if val < 0:
raise ValueError("Negative not allowed")
self.val = val
print "set... |
45e58b898f049c21c5d4272bd654a2a370791432 | ajaygalagali/codes_python_for_everybody_coursera | /assignment_5.2.py | 589 | 3.859375 | 4 |
minNumber = 0
maxNumber = 0
i = 0
flag = True
while flag is True:
try:
number = input("Enter number :")
except:
pass
if number == "done":
print(maxNumber)
print(minNumber)
flag = False
elif number.isdigit():
if i == 0:
minNumber = int(numbe... |
58329bb0bce1640ef4c41202dab16c3dd9304929 | GiacomoPinardi/project-euler | /problem0058.py | 1,131 | 3.890625 | 4 | # www.github.com/GiacomoPinardi/project-euler
# Starting with 1 and spiralling anticlockwise in the following way,
# a square spiral with side length 7 is formed.
# 37 36 35 34 33 32 31
# 38 17 16 15 14 13 30
# 39 18 5 4 3 12 29
# 40 19 6 1 2 11 28
# 41 20 7 8 9 10 27
# 42 21 22 23 24 25 26
# 43 44 45 46 47 ... |
e0966e366277f039eca871c0612b3a285b323e1c | MikhaelBelmiro/Training | /insertion_sort.py | 1,040 | 4.28125 | 4 | import sys
def insertion_sort(x:list, method:str):
available_method = ['increasing', 'decreasing']
if method not in available_method:
raise ValueError('method argument should be on of [\'increasing\', \'decreasing\'')
if method == 'increasing':
for j in range(1, len(x)):
te... |
3c199eda428cdd28823a93db443d11fc216363b3 | LunaCelestine/Project_Euler__1 | /EulerProject_1.py | 534 | 4 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat May 18 16:48:29 2019
@author: AdrielleTheSlayer
"""
max = 1000
def count_by_three(max):
i = 3
results = []
while i < max:
results.append(i)
i += 3
return results
def count_by_five(max):
k = 5
results = []
while k < max:
... |
5aba59686cf7d484f984d85866d5ad233409d390 | sandeepkumar8713/pythonapps | /24_fourthFolder/11_merge_overlapping_intervals.py | 2,637 | 3.84375 | 4 | # https://leetcode.com/problems/merge-intervals/
# Question : Given a set of time intervals in any order, merge all overlapping intervals
# into one and output the result which should have only mutually exclusive intervals.
# Let the intervals be represented as pairs of integers for simplicity.
# For example, let the g... |
dd8dede4f1514190bb0574fe2db2b79fb5569188 | Anirudh-thakur/LeetCodeProblems | /Contest/SameTree.py | 1,048 | 3.828125 | 4 | #https: // leetcode.com/problems/same-tree/
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution(object):
def isSameTree(self, p, q):
"""
:type... |
756b2510c317d397040aecd853f587d276af1de7 | ksanman/EvTripScheduler | /trip_scheduler/trip_builder/vehicle/vehicle.py | 760 | 3.625 | 4 | import abc, six
@six.add_metaclass(abc.ABCMeta)
class Vehicle():
""" Base Class to model an electric vehicle.
"""
def __init__(self, batteryCapacity, timeBlockConstant):
self.BatteryCapacity = batteryCapacity
self.TimeBlockConstant = timeBlockConstant
@abc.abstractmethod
... |
2a77729a40ce400d81904630658c144d53b86167 | adeen-s/AdventOfCode-2017 | /day4-2.py | 481 | 3.65625 | 4 | passphrases = []
valid = 0
anagrams = 0
while True:
passphrase = input()
if passphrase:
passphrases.append(passphrase)
else:
break
for passphrase in passphrases:
anagrams = 0
li = [s for s in passphrase.split()]
if len(li) != len(set(li)):
continue
for s in li:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.