blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
0e98f845ba6130c720987557db74c04b639ea339 | ellenne/NaturalProcessesSimulation | /Code/piles.py | 1,530 | 4.09375 | 4 | '''
Suppose you have 10 piles of 10 coins each.
Say now that you are playing the following game. At each turn you pick a coin from each pile and move it in
a randomly selected pile (it can be any of the piles). You can repeat the process an arbitrary amount of times.
If a pile becomes empty, you cannot move a coin b... |
fae62ae46755e7aa675c4518aa7f88cf2c46e202 | jacquerie/leetcode | /leetcode/0415_add_strings.py | 674 | 3.734375 | 4 | # -*- coding: utf-8 -*-
import itertools
class Solution:
def addStrings(self, num1, num2):
def toInt(c):
if c is None:
return 0
return int(c)
result = []
carry = 0
for d1, d2 in itertools.zip_longest(reversed(num1), reversed(num2)):
... |
447c6111bbd32af813f75967e86d88ece1e91d71 | gomtinQQ/algorithm-python | /codeUp/codeUpBasic/1559.py | 325 | 3.53125 | 4 | '''
1559 : [기초-함수작성] 함수로 두 정수의 합 리턴하기
int 형 정수 두 개를 입력 받아
두 수를 합한 결과를 출력하시오.
단, 함수형 문제이므로 함수 f()만 작성하여 제출하시오.
'''
def f(x,y):
return x+y
x, y = input().split()
x = int(x)
y = int(y)
print(f(x,y)) |
60ee7c922021ad82392c650099eaa7ed55f54221 | GetulioCastro/codigo_livro_aprenda_python_basico | /13-programacao-orientada-a-objetos/13-programacao-orientada-a-objetos.py | 2,080 | 4.71875 | 5 | # Código utilizado no livro Aprenda Python Básico - Rápido e Fácil de entender, de Felipe Galvão
# Mais informações sobre o livro: http://felipegalvao.com.br/livros
# Capítulo 13: Programação Orientada a Objetos
# Definindo nossa primeira classe
class Usuario:
contador = 0
def __init__(self, nome, email):
se... |
9d873abe33a4701e57ba5c2fb4637546fd9a6d60 | liseyko/CtCI | /leetcode/p0258 - Add Digits.py | 725 | 3.703125 | 4 | class Solution:
# If an integer is like 100a+10b+c, then (100a+10b+c)%9=(a+99a+b+9b+c)%9=(a+b+c)%9
def addDigits(self, num):
if not num: return 0
return num % 9 or 9
def addDigits(self, num):
"""
:type num: int
:rtype: int
"""
if num > 9:
... |
391ea1540ed0bd71e1edfd4c0858c9110c1a796d | jastination/software-engineering-excercise-repository | /seer_python/dp/MaxArithmeticProgression.py | 442 | 3.703125 | 4 | '''
Created on May 20, 2012
@author: Jason Huang
'''
#Given an array of integers A, give an algorithm to find the longest Arithmetic progression in it, i.e find a sequence i1 < i2 < < ik, such that
#A[i1], A[i2], , A[ik] forms an arithmetic progression, and k is the largest possible.
#The sequence S1, S2, , ... |
eab16b6733c4ae405703473bde9d41672d4b521d | Matt-Robinson-byte/DigitalCrafts-classes | /python102/leetspeak.py | 408 | 3.5625 | 4 | def leetspeak():
phrase = (input("Input to translate: ").upper())
new_phrase = ""
letter = [""]
i = 0
j = 0
while i < len(phrase):
while j < len(letter):
if phrase[i] == letter[j]:
new_phrase.append(number[j])
else:
new_phrase[i] ... |
ace985e211c588092e87107c78d376aa9f514b2c | henrany/BCC | /programming languages/EX5/05.py | 1,809 | 4.03125 | 4 | class Animal:
atrb_animal = 0
def __init__(self , nome):
self.nome = nome
def __str__(self):
return self.nome + " eh um animal"
def comer(self):
print(self.nome + ", que eh um animal , esta comendo.")
class Mamifero(Animal):
def __str__(self):
return(self.nom... |
95815e138b1b86084e242d9499baef5767a0c655 | CUGshadow/Python-Programming-and-Data-Structures | /Chapter 01/Exercise01_17.py | 364 | 4.125 | 4 | """
(Turtle: draw a line)
Write a program that draws a red line connecting two points (−39, 48)
and (50, −50) and displays the coordinates of the two points
"""
import turtle
turtle.penup()
turtle.goto(-39, 48)
turtle.write('(-39, 48)')
turtle.pendown()
turtle.color('red')
turtle.goto(50, -50)
turtle.color('black')
t... |
989796f90b0e9c18b7b65b0f5912ec7c3606aa28 | theeric80/LeetCode | /medium/surrounded_regions.py | 2,319 | 3.5625 | 4 |
class Solution(object):
def solve(self, board):
"""
:type board: List[List[str]]
:rtype: void Do not return anything, modify board in-place instead.
"""
if not board: return
m, n = len(board), len(board[0])
for i in xrange(m):
if board[i][0] == '... |
12ea8621138a409842f1418a1535de76e9c66084 | wjsc/python-flask-api-example | /my_math.py | 117 | 3.625 | 4 | sum = lambda x, y: x + y
minus = lambda x, y: x - y
def mult(x, y):
return x*y
def divide(x, y):
return x/y |
55619dd38c49bba77442742f2e83aaca58a8a1de | DhivyaKavidasan/python | /problemset_3/q9.py | 337 | 4.0625 | 4 | '''
function called is_sorted that takes a list as a parameter and returns True if the list is sorted in ascending order and False otherwise
submitted by : dhivya.kavidasan
date: 05/12/2017
'''
def is_sorted(s):
j=0
for i in s:
if s[j+1] >= s[j]:
return True
else:
return False
s = '122'
pr... |
32503914dd6ad35fe5812d09ddadab0349833f29 | santhoshkalisamy/daily_coding_problem_java_solutions | /Python/src/Test.py | 312 | 3.515625 | 4 | def pair(a,b):
def pair(calc):
return calc(a,b)
return pair
def add(pair):
def calc(a,b):
return a+b;
return pair(calc)
def mul(pair):
def calc(a,b):
return a*b;
return pair(calc)
if __name__ == '__main__':
print(mul(pair(5,10)))
print(add(pair(5,10)))
|
0558835ce983d908544082481ba794108eca2894 | csitedexperts/DSML_MadeEasy | /Clustering K-Means/00Develope and Verify a K-Means++ Clustering Model with a Randomly Generated Dataset in Python.py | 2,254 | 3.515625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Apr 24 08:51:47 2019
@author: mhossa12
"""
## https://www.kaggle.com/andyxie/k-means-clustering-implementation-in-python
# Import necessary libraries
from copy import deepcopy
import numpy as np # linear algebra
from matplotlib import pyplot as plt
# Set three centers, the mo... |
b64c6edf2ad59fb6801fabaf29f452d76040ab40 | hyu-likelion/Y1K3 | /week1/sunwoong/hard_problem3.py | 365 | 3.703125 | 4 | word = list(input().lower())
words = [0 for i in range(26)]
largestNum = 0
largestChar = ''
for i in range(0, len(word)):
index = ord(word[i])-97
words[index] += 1
if words[index] > largestNum:
largestNum = words[index]
largestChar = word[i]
elif words[index] == largestNum:
larg... |
025306072a39c2cd9175e6542a616c5a8f986e60 | mancuzzo-x2/Guess-The-Number | /GuessTheNumber.py | 1,873 | 3.734375 | 4 | import random
class GTNum:
def __init__(self, range = 20, guess = 0):
self.range = range
self.guess = guess
def Set_range(self):
self.range = input("Insert an integer >= 0: ")
def Set_guess(self):
self.guess = input("\nGuess a number between 0 and " + str(self.range) + ": ")
def Get_guess(self):
... |
cecd81f2b82daf735997e2c0b3027754c23e81ce | pgenkin/geekbrains | /task5_2.py | 250 | 3.765625 | 4 | my_file = open('file5_2.txt', 'r')
for line in my_file:
print("There are", line.count(' ') + 1, "words in the line.")
my_file.seek(0)
total_lines = len(my_file.readlines())
print("There are", total_lines, "lines in the file.")
my_file.close()
|
4950810e0244711c1d687601f7aa7a7eacb2e555 | seongkyun/DRFBNet300 | /lib/functions.py | 3,087 | 3.5625 | 4 | def th_selector(over_area, altitude):
if altitude <= 10:
th_x = over_area // 2 # 40
th_y = over_area // 4 # 20
return th_x, th_y
elif altitude <=20:
th_x = over_area // 8
th_y = over_area // 20
return th_x, th_y
else:
th_x = over_area // 20
th_... |
f65ac732674787e00f845dae8de9c4ce1e9a0ab8 | adriangalende/ejerciciosPython | /findTheVowels.py | 410 | 3.734375 | 4 |
#vowels = a e i o u y
def vowel_indices(word):
word = word.lower()
position = []
index = 1
vowels = 'aeiouy'
for letter in word:
if letter in vowels:
position.append(index)
index += 1
return position
#casos Test
print(vowel_indices('YoMama'))
#vowel_indices('S... |
39c7e9b34f702ea2d90b980750919d94da86557e | mikekulinski/DailyCodingProblem | /day24.py | 2,351 | 3.90625 | 4 | class BinaryTreeNode():
def __init__(self, name, left = None, right = None):
self.name = name
self.locked = False
self.parent = None
self.set_left(left)
self.set_right(right)
def __str__(self):
return "<Name: " + self.name + ", Locked: " + str(self.locked) + ">"
... |
f5e001e6e7deead6c95f89a12bcfc357f9724b79 | oqolarte/python-noob-filez | /add_remove_dots.py | 876 | 4.25 | 4 | # Adding and removing dots
# Write a function named add_dots that takes a string and adds "." in between each letter.
# For example, calling add_dots("test") should return the string "t.e.s.t".
# Then, below the add_dots function, write another function named remove_dots that removes all dots from a string.
# For examp... |
d046ca56efde7a13fa3b7ccd375abba66a9ee23f | MotownMystery/Exercises-for-Programmers-57-Challenges-Python | /ee44.py | 657 | 3.78125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Dec 18 09:00:32 2017
@author: christophernovitsky
"""
Data = [{"name" : "widget", "price" : 2, "quantity" : 5},
{"name" : "thing", "price" : 15, "quantity" : 5},
{"name" : "doodad", "price" : 5, "quantity" : 10}]
X = [d["name"] for d i... |
79ed6b508574bedd4830e0ccfa6602f64d5046cb | Btrenary/Module6 | /more_functions/function_parameter_assignment.py | 268 | 4 | 4 | """
Author: Brady Trenary
function takes in a string and a number, then multiplies the string by the number
"""
def multiply_string(message, n):
result = message * n
print(result)
return result
if __name__ == '__main__':
multiply_string('Chemistry', 5)
|
0a9aa6be8f756cbd3de3d293d53361e96e8712fc | sivarre/PythonPractise | /PythonScriptPractise/For_Loop.py | 210 | 3.953125 | 4 | print(list(range(5)))
for i in range(5):
print("Hello World",i)
mylist = [10,100,1000]
for jj in mylist:
print("jj value is :",jj)
#2*1=2
a=2
for i in range(10):
b=a*i
print(a," * ",i,"=",b)
|
8328a32129a2a9cbb7e2ab1a943a531f4808f36c | BeijiYang/algorithmExercise | /binaryTreeLeafsSum.py | 503 | 3.828125 | 4 | class TreeNode:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
node3 = TreeNode(3)
node1 = TreeNode(1)
node6 = TreeNode(6)
node4 = TreeNode(4)
node3.left = node1
node3.right = node6
node6.left = node4
def getTreeLeafsSum(node):
if node is None:
... |
d20d9f091a3b4799ed8b7d48e994be2a5c32b66a | monteua/Python | /List/14.py | 153 | 3.921875 | 4 | '''
Write a Python program to shuffle and print a specified list.
'''
import random
lst = [1, 2, 3, 4, 5, 6, 7, 8, 9]
random.shuffle(lst)
print (lst)
|
934245c0e0a0c8e8c2898e2f0341b6416e6a89e3 | anshu-gautam/python_learning | /pattern_printing.py | 224 | 3.921875 | 4 | # # for i in range(1, 9):
# # print(i*"*")
#print this pattern horizontally
# *
# **
# ***
# ****
# *****
# ******
# *******
# ********
max = 9
for x in range (1 , 10):
print ((max - 1)* " " , x * "*")
max = max - 1 |
cf0b924d58ae073f52922cdaa91df60550f38349 | ashlin-k/MIT-CompBio | /Projects/M1/exact_matching.py | 2,268 | 3.65625 | 4 |
# This program will find an exact number of matches of an M-length
# pattern, P, in a N-length string, T, in linear time, O(N) using the
# Z algorithm, Boyer-Moore and Knuth-Morris-Pratt (KMP)
# Based of of Lecture 3 in the MIT CompBio lecture series
# https://ocw.mit.edu/courses/electrical-engineering-and-computer-... |
6f61d70d2b8dd7424022afe61234b0d7bd20689b | ggibson5972/Kattis | /sibice.py | 390 | 3.921875 | 4 | #read in the number of matches and the dimensions of the box
N, W, H = map(int, raw_input().split(" "))
#calculate diagonal of box (pythagorean theorem)
d = int((W ** 2 + H ** 2) ** 0.5)
while N > 0:
#read in length of each match
L = input()
#check if match is smaller than the longest part of box
if in... |
6870e1333b4d201161560e8629787e4064882b2c | MaksymSkorupskyi/HackerRank_Challenges | /Strings/Find a string.py | 705 | 4.15625 | 4 | """Find a string
https://www.hackerrank.com/challenges/find-a-string/problem
In this challenge, the user enters a string and a substring.
You have to print the number of times that the substring occurs in the given string.
String traversal will take place from left to right, not from right to left.
NOTE: String letter... |
8d29852ae236a60eedb362ede030781b53b46c4a | Surgeon-76/KaPythoshka | /Stepik/13_function/is_valid_triangle/my.py | 381 | 4.03125 | 4 | # объявление функции
def is_valid_triangle(side1, side2, side3):
if (side1 < (side2 + side3)) and (side2 < (side1 + side3)) and (side3 < (side1 + side2)):
return True
else:
return False
# считываем данные
a, b, c = int(input()), int(input()), int(input())
# вызываем функцию
print(is_valid_tria... |
ec07b68f138db4ba0a2722cb569ba1086d1c0076 | jeffrey-hong/interview-prep | /Daily Coding Problem/Problem21.py | 980 | 3.859375 | 4 | def lecture_rooms(intervals):
# Given an array of time intervals (start, end) for classroom lectures (possibly overlapping),
# find the minimum number of rooms required.
# For example, given [(30, 75), (0, 50), (60, 150)], you should return 2.
start = sorted(start for start, end in intervals)
end = sorted(end fo... |
4d3e36d51bbbf6e860bada70f1b831ef3dd53c7b | jaeyun95/Baekjoon | /code/2750.py | 3,107 | 3.6875 | 4 | #(2750) 수 정렬하기
number = int(input())
input_list = []
for _ in range(number):
input_list.append(int(input()))
## using python function
#input_list = sorted(input_list)
## bubble sort
'''
for i in range(len(input_list)-1):
for j in range(len(input_list)-i-1):
if input_list[j] > input_list[j+1]:
... |
78d37228503a9e325ba70c204c471bfbb66ee468 | KarAbhishek/MSBIC | /Practice/quick_select.py | 929 | 3.609375 | 4 | from random import random
def partition1(arr, left, right, pivotIndex):
arr[right], arr[pivotIndex] = arr[pivotIndex], arr[right]
pivot = arr[right]
swapIndex = left
for i in range(left, right):
if arr[i] < pivot:
arr[i], arr[swapIndex] = arr[swapIndex], arr[i]
swapInde... |
a16f5a8aa07f425e0ef7746472fbe1a6f8865b8b | bersavosh/P4J | /P4J/math.py | 1,883 | 3.65625 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import division
import numpy as np
"""
Computes a given quantile of the data considering
that each sample has a weight.
x is a N float array
weights is a N float array, it expects sum w_i = 1
quantile is a float in [0.0, 1.0]
"""
def wei... |
568fff18a0dba36d574ed7366aa60be03b9d4e67 | dariusciupe/adventofcode | /2016/Day2/day1.py | 667 | 3.90625 | 4 | def get_digit(cmd, start):
digit = start
for c in cmd:
if c == 'U':
digit = digit - 3 if digit - 3 > 0 else digit
elif c == 'D':
digit = digit + 3 if digit + 3 < 10 else digit
elif c == 'L':
digit = digit - 1 if (digit - 1) % 3 != 0 else digit
... |
e3312cc8039fc82d9d8618559483340c20fd33a3 | eggypesela/freecodecamp-exercise-scientific-computing | /Exercise Files/boilerplate-time-calculator/time_calculator.py | 2,697 | 3.96875 | 4 | #!/usr/bin/env python3
#created by Regina Citra Pesela (reginapasela@gmail.com)
def add_time(start, duration, currentDay = ""):
#clean start time data into variables
startHour, startMinute, startAMPM = int(start.split(":")[0]), int(start.split(":")[1][:2]), start.split(" ")[1]
#clean duration time ... |
f260d0c7c4897f90526a281e9ad0c36bb2972094 | KevinVuongly/ProgrAmsterdam | /src/classes/Heuristics.py | 2,604 | 3.984375 | 4 | from classes.Board import Board
class Heuristic:
""" A class that has all the heuristics made for the rush hour game"""
def __init__(self, board):
""" Takes all information of the board with it's state as the beginning of the game.
Args:
board (class): Containing all information o... |
be0542fec6087ba04f673b7eaebd7bdfa1a598fd | Fullstack-Datascientist-BootCamp/ipdb | /step.py | 478 | 3.5625 | 4 | def subroutine(x, y):
return x*y
def wrapper(x):
# now you are here. press c
return x
if __name__ == "__main__":
a = 3
b = 5
# put break point on line 14 and 16
# press "s"
import ipdb; ipdb.set_trace() # BREAKPOINT
subroutine(wrapper(a), b)
import ipdb; ipdb.set_trace() # BRE... |
776464e4b021493ef41d644da3eb3ab5728b1913 | cybersp/TensorBase | /tensorbase/base.py | 39,318 | 3.71875 | 4 | #!/usr/bin/env python
"""
@author: Dan Salo, Nov 2016
Purpose: To facilitate data I/O, and model training in TensorFlow
Classes:
Data
Model
"""
import tensorflow as tf
import numpy as np
import logging
import math
import os
from tensorflow.python import pywrap_tensorflow
import sys
class Data:
"""
A... |
b819d9d113e99285b7340e18e712e4c90745804f | georgelzh/Cracking-the-Code-Interview-Solutions | /recursionAndDynamicProgramming/recursiveMultiply.py | 2,225 | 4.09375 | 4 | """
Recursive Multiply: Write a recursive function to multiply two positive integers without using the
*operator.You can use addition, subtraction, and bit shifting, but you should minimize the number
of those operations
Hints: #166, #203, #227, #234, #246, #280
"""
"""
# solution 1
def minProduct(a, b):
print(a,... |
104de4a5244ef809fe899336f0f5ad62c5eadbed | turing-20/python-cte | /runner up score.py | 634 | 4.21875 | 4 | """Given the participants' score sheet for your University Sports Day, you are required to find the runner-up score. You are given scores. Store them in a list and find the score of the runner-up.
Input Format
The first line contains . The second line contains an array of integers each separated by a space.
Cons... |
0a12025c334eeb34cdf57b20b14f544476bd7f3a | akomawar/Python-codes | /Practise_Assignments/function.py | 289 | 4.03125 | 4 | def addition():
n1=int(input("Enter 1st no.: "))
n2=int(input("Enter 2nd no.: "))
print("Addition of 1st and 2nd is: ", n1+n2)
def subtraction():
n1=int(input("Enter 1st no.: "))
n2=int(input("Enter 2nd no.: "))
print("Subtraction of 1st and 2nd is: ",n1-n2)
|
928b161b7ade43d615f1020cb6afa7d50a50f5b7 | markogolub/LP | /ColoringAreaAbove.py | 1,033 | 3.5625 | 4 | import pylab as plt
import numpy as np
# Format of (in)equation is 'y (<, >)= ax + b'.
# Will be added later for the user to enter the (in)equations.
# Linear problem:
# 1) X + 2Y >= 16
# 2) -5X + 3Y >= 45
# X,Y >=0
# Express (in)equations to this format:
# 1) Y >= -1/2X + 8
# 2) Y >= 5/3X + 15
# Range ... |
3ccf57f03283f69117e6b4b689aeeec1ddcceac7 | kapoor-rakshit/Miscellaneous | /py_deque.py | 1,143 | 4.09375 | 4 |
# REFERENCE : https://www.hackerrank.com/challenges/py-collections-deque/problem
# collections.deque()
# A deque is a double-ended queue.
# It can be used to add or remove elements from both ends.
# Deque support thread safe, memory efficient appends and pops from either side of the deque with approximately the sa... |
fe9f050ee46c21860ed7e6da785cd3f6880a844b | UWPCE-PythonCert-ClassRepos/SP_Online_Course2_2018 | /students/wwhite/Lesson01/spotify_danceability.py | 816 | 3.609375 | 4 | #!/usr/bin/env python
"""
Get artists and song names for for tracks with danceability scores over 0.8 and loudness scores below -5.0.
In other words, quiet yet danceable tracks.
Also, these tracks should be sorted in descending order by danceability so that the most danceable tracks are up top.
"""
import pandas as p... |
68031570a218601818104ad6debc3697b270ab17 | krstoilo/SoftUni-Basics | /Python-Basics/conditional_statements/toy_store.py | 684 | 3.640625 | 4 | trip_price = float(input())
puzzles = int(input())
dolls = int(input())
teddy_bears = int(input())
minions = int(input())
trucks = int(input())
puzzles_sum = puzzles * 2.60
dolls_sum = dolls * 3
teddy_bears_sum = teddy_bears * 4.10
minions_sum = minions * 8.20
trucks_sum = trucks * 2
total = puzzles_sum + dolls_sum +... |
97c3cf09375237db11e94f10fbca8e32025386db | longyueying/LeetCode | /113.py | 783 | 3.515625 | 4 | class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def pathSum(self, root, sum):
"""
:type root: TreeNode
:type sum: int
:rtype: List[List[int]]
"""
self.res = []
nums = []
... |
ad3de89487692604ac6616381c3e6f9f4d2b82e1 | nomad-vino/open-tamil | /solthiruthi/datastore.py | 4,772 | 3.53125 | 4 | ## -*- coding: utf-8 -*-
## (C) 2015 Muthiah Annamalai,
##
from __future__ import print_function
import abc
import sys
import codecs
import argparse
from tamil import utf8
from pprint import pprint
PYTHON3 = (sys.version[0] == '3')
class Trie:
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def add(... |
06328b450d81cdd19ee270573a0b660fea083cbd | wrojek0/python | /zadania5/frac.py | 2,405 | 3.515625 | 4 |
def add_frac(frac1, frac2): # frac1 + frac2
res = []
if frac1[1] == frac2[1]:
res.append(frac1[0]+frac2[0])
res.append(frac1[1])
reduce(res)
return res
else:
common_denominator(frac1,frac2)
res.append(frac1[0]+frac2[0])
res.append(frac1[1]... |
935c2ac94b28e2b188cc168a173825fbf6ea2c82 | DougOliver12/My-Python-Code | /Admissions/Admissions.py | 3,129 | 4.4375 | 4 | #!/usr/bin/python
# William Thing
# April 20, 2014
# Admissions
#
# This program will compare two different applicants
# taking in either their ACT or SAT score and overall
# GPA to determine which applicant is more competitive.
# Prints the introduction of the Admissions program
def intro_to_program():
print("Thi... |
ddfca1b5bbaba0763299f45b4d5a2e589e9fb963 | PauloGLemos/VScodeBlueedytech | /Lista de exercícios 24.05 - 4.py | 1,495 | 4.0625 | 4 | #04 - Utilizando funções e listas faça um programa que receba uma data no formato DD/MM/AAAA e devolva uma string no formato D de mesPorExtenso de AAAA.
# Valide a data e retorne NULL caso a data seja inválida.
def Data():
Dia= int(input("Digite o Dia " ))
Mes= int(input("Digite o Mes " ))
Ano= int(input(... |
13e8e3810d92c090a5a3a96a49e2d2e21c8aa7dc | NathanaelV/CeV-Python | /Aulas Mundo 3/aula16_tuplas.py | 1,775 | 4.15625 | 4 | # Challenge 72 - 77
lanche = ('Hamburguer', 'Suco', 'Pizza', 'Pudin', 'Batata Frita')
# Posso criar puplas sem usar parenteses
# Semelhante ao fatiamento de strings
print(lanche)
print('lanche[1]: ', lanche[1])
print('lanche[-1]: ', lanche[-1])
print('lanche[1:3]: ', lanche[1:3])
print('lanche[-2:]', lanche[-2:])
# N... |
d751c9e87b4eef17e1c0af8b15fdeb884fdf7e99 | PhamQuocDatAI/TOAN-KHDL | /Toán 2.py | 716 | 3.75 | 4 | import numpy as np
import random
n = int(input("Nhập giá trị n: "))
# Tạo ma trận số nguyên cấp n ngẫu nhiên trong phạm vị cho trước
A = np.random.randint(-10, 10, (n, n))
print(A)
# Tính detA
print("Hạng của ma trận A: ", int(np.linalg.det(A)))
# Tính A^2, A^3
print("A^2 = ", A@A)
print("A^3 = ", (A@A)@A)
# Viết 1 hà... |
fb84ef210f3914e4441713f73c3c0ccfa748fcc0 | medmaster0/LonelyCiv | /Civ2/stonez/STONEZ.py | 2,151 | 3.78125 | 4 | #generates random 16 bit patterns of stonez
#smooth gentle formation
#I'm DRUNK when i wrote this!
import random
#GLOBALS
size = 16
#function to print out 2d list line by line
def print2D(list2d):
for row in list2d:
print row
#16 bits
def generateStone():
stone = [] #a 2D list for the pattern
#initialize list
... |
b834992f30616cbfb52101bd9bedc80756711f17 | yrunts/python-training-lessons | /lesson3/task1.py | 4,063 | 4.3125 | 4 | #coding: utf-8
"""Solution to task 1 from lesson 3."""
def test():
"""Prints strings in different representation."""
print 'It\'s a test python string\nwith a "newline" character.'
print r'It\'s a test python string\nwith two backslashes an no "newline" ' \
r'character.'
print '''It's a test... |
55cb84b927d1d48bfa4c6b729863fdec602e94d2 | imbiginjapan/python_crash_course | /employee_test.py | 515 | 3.875 | 4 | import unittest
from employee import Employee
class TestEmployee(unittest.TestCase):
def test_give_default_raise(self):
employee = Employee("John","Smith",50000.00)
salary = employee.salary
employee.give_raise()
self.assertEqual(employee.salary, salary + 5000.00)
def test_give_custom_raise(self):
empl... |
70c7941ea5f40325bd1bc3c8c29807672a326a35 | tz-earl/partition-list | /partition-list.py | 3,796 | 3.859375 | 4 | from list_to_linked import ListNode, list_to_linked, linked_to_list
class Solution:
def partition_1(self, head: ListNode, x: int) -> ListNode:
# Maintain two refs p1 and p2 that form the boundary of the partitioning
# between nodes smaller than x and nodes equal to or greater than x.
# p1 ... |
9ff599334a46ee03743fd4988149affe93705b0f | JaviCeRodriguez/Procesamiento_De_Imagenes | /python/Unidad_2/ej9.py | 1,359 | 3.671875 | 4 | # Aplique a una imagen grayscale la transformación apropiada para que su
# histograma se comprima a un cierto rango definido por el usuario (shrinking).
import numpy as np
import matplotlib.pyplot as plt
from skimage import img_as_float
from skimage.color import gray2rgb
from skimage.io import imread
from skimage.exp... |
aed5f4205af50a9b80fa3ff42e4646a4ede8a6e8 | francistianlal/Codability-test | /Ex 3.1 frogjump.py | 636 | 3.703125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue May 5 20:16:37 2020
Frog jump problem
@author: frank
"""
import unittest
Element_range = range(1,int(1e9+1))
def solution(X,Y,D):
if X not in Element_range or Y not in Element_range or D not in Element_range :
raise TypeError('element not in range'... |
c616b111409aa727d88719c5421c2f6988a0a42c | elvisestevan/thirty-days-code-challenge | /20-sorting.py | 587 | 3.828125 | 4 | #!/bin/python3
import sys
n = int(input().strip())
a = list(map(int, input().strip().split(' ')))
# Write Your Code Here
def swap(list_sort, i, j):
aux = list_sort[i]
list_sort[i] = list_sort[j]
list_sort[j] = aux
numberOfSwaps = 0
for i in range(n):
for j in range(n - 1):
if (a[j]... |
855149379fd695bba0b7a73f030fb68ed24d3575 | raythurman2386/cs-algorithms | /single_number/single_number.py | 705 | 4 | 4 | '''
Input: a List of integers where every int except one shows up twice
Returns: an integer
'''
def single_number(arr, cache={}):
# Your code here
# use dict to keep track of each number
# track how many times that number is seen
# return the number from the dict whose value is 1
# INITIAL IMPLEME... |
f41363225d12dd535fcef03e0a5c381a9dea06b7 | SamJ2018/LeetCode | /python/python语法/pyexercise/Exercise05_13.py | 234 | 3.640625 | 4 | count = 1
for i in range(100, 201):
if not (i % 5 == 0 and i % 6 == 0) and (i % 5 == 0 or i % 6 == 0):
if count % 10 != 0:
print(i, end = " ")
else:
print(i)
count += 1
|
f4cfb676f920816104d9e16023dbdc4eecf79b3e | Raushan-Raj2552/URI-solution | /1064.py | 149 | 3.765625 | 4 | a = 0
b = 0
for i in range(6):
c = float(input())
if c>0:
a+=c
b+=1
print(b,'valores positivos')
print('%0.1f'%(a/b)) |
71afaf6dd42d966529ccc606614bf35256ef32e3 | Chock-Chaloemchai/workshop2 | /string/f_string.py | 138 | 3.90625 | 4 | name = "chock"
age = 21
result = f"My name is {name}, and I am {age}"
print("result", result) # Output : My name is chock, and I am 21
|
558f365aaaf57b81b172c0ee37e7960679c633d9 | GVargas/mtec2002_assignments | /class9/labs/boat/draw_boat.py | 642 | 3.828125 | 4 | """
"""
import turtle
boat_color = ()
while True:
print "Pick a color for your boat"
user_input = raw_input(">")
turtle.color(user_input)
turtle.forward(150)
turtle.left(45)
turtle.forward(100)
turtle.right(45)
turtle.forward(50)
turtle.left(90)
turtle.forward(20)
turtle.left(90)
turtle.forward(150)
turt... |
8249c21b34838733418789faab22966b04e73411 | Fondamenti18/fondamenti-di-programmazione | /students/1811200/homework01/program01.py | 1,527 | 3.96875 | 4 | '''
Si definiscono divisori propri di un numero tutti i suoi divisori tranne l'uno e il numero stesso.
Scrivere una funzione modi(ls,k) che, presa una lista ls di interi ed un intero
non negativo k:
1) cancella dalla lista ls gli interi che non hanno esattamente k divisori propri
2) restituisce una seconda l... |
f16a8c25e4cb931789a06a386b55871f53e5097a | ropable/algorithmic_toolbox | /course1/fibonacci_sum_last_digit.py | 1,090 | 4.0625 | 4 | # python3
import sys
def fibonacci_sum_naive(n):
"""Stupid example solution.
"""
if n <= 1:
return n
previous = 0
current = 1
sum = 1
for _ in range(n - 1):
previous, current = current, previous + current
sum += current
return sum % 10
def fib_matrix(n):
... |
94802b1a1e4f163ad00bc1b4967e318107f3eb21 | jsmcmahon56/DAEN-500-Final | /main.py | 915 | 4.1875 | 4 | ##Jim McMahon
##DAEN 500 Final
##Problem 2
#this is the class that will manipulate the input string
class StringManipulator:
def __init__(self, currString = ''):
self.currString = currString
#method for getting user string input
def getString(self):
print('Enter a string')
... |
820ba3e9dbdf965eef188ad3170ef1fa5a3c1b12 | tinnan/python_challenge | /06_itertools/055_maximize_it.py | 619 | 3.796875 | 4 | """
You are given a function f(X) = X^2.
You are also given K lists. The ith list consists of Ni elements.
You have to pick exactly one element from each list so that the equation below is maximized:
S = (f(X1) + f(X2) + ... + f(Xk))%M
Xi denotes the element picked from the ith list . Find the maximized value Smax ... |
92df996b2aef01246bdae61f409224303d0ed8ad | Adityaar/Python | /permutateString.py | 217 | 3.765625 | 4 | def permutate(s):
res = []
if len(s) == 1:
res = [s]
else:
for i in range(len(s)):
#swap(s,i,j)
def permutateWrapper(l):
print permutate(l[1:])
|
86f57bf085df75f8c5fd52bb778a93cf729d195d | ntupenn/exercises | /medium/271.py | 1,485 | 3.65625 | 4 | """
Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list of strings.
Machine 1 (sender) has the function:
string encode(vector<string> strs) {
// ... your code
return encoded_string;
}
Machine 2 (receiver) has the fun... |
976ce426a93a3b267b4bcc563e427e06e0da0cac | zeroWin/Python | /Core python programming(2th)/Chapter 3/3_10_makeTextFile.py | 654 | 3.90625 | 4 | 'makeTextFile.py -- create text file'
import os
# Get filename
while True:
try:
fname = input('Enter file name: ')
fobj = open(fname,'r')
except IOError as e:
# Get file context(text) lines
all = []
print("Enter lines('.' by itself to quit).")
# loop until user terminates input
while True:
entry =... |
4b0f5ed3e626b31b913e93bb5ac9fd055f9ad618 | Surgeon-76/KaPythoshka | /Stepik/13_function/good_password/my.py | 376 | 3.859375 | 4 | # объявление функции
def is_password_good(password):
return len(password) >= 8 and password.islower() == False and password.isupper() == False and (password.isalnum() == True and password.isalpha()== False
and password.isdigit() == False)
# считываем данные
txt = input()
# вызываем функцию
print(is_password_g... |
561840cab2e44fa1a0a95ae258720ebcf641179b | gauravssnl/Data-Structures-and-Algorithms | /python/Data Structures and Algorithms in Python Book/stacks/reverse_file_contents.py | 600 | 3.921875 | 4 | from arraystack import ArrayStack
def reverse_file(filename):
"""Overwrite a given file with contents line-by-line in reversed order"""
S = ArrayStack()
original = open(filename)
for line in original:
S.push(line.rstrip('\n')) # we will re-insert newlines while writing
original.c... |
d48ec6af2efa44bcec307523aa8fccd0816f0c35 | dcoats14/Portfolio | /Blackjack/gameFunction.py | 1,253 | 3.671875 | 4 | def die(self):
print("Your pet has died, you probably shouldn't own a pet in real life.")
self.isAlive = False
def ask_yes_no(question):
response = None
while response not in ("y","n"):
response = input(question).lower()
return response
def setName(self, name):
if len(name) > 4 or len... |
09acd830d15808cf6bb5e0501a9d7b1e77ac9022 | shaunagm/personal | /project_euler/p21-30/problem_25_1000_digit_fibionacci_number.py | 640 | 4.0625 | 4 | # The Fibonacci sequence is defined by the recurrence relation:
# Hence the first 12 terms will be:
# F1 = 1
# F2 = 1
# F3 = 2
# F4 = 3
# F5 = 5
# F6 = 8
# F7 = 13
# F8 = 21
# F9 = 34
# F10 = 55
# F11 = 89
# F12 = 144
# The 12th term, F12, is the first term to contain three digits.
# What is the first term in the Fib... |
6b9409d8dcedd4a6dd9bf7a68a431d1257ecc41e | Monichre/Simple-Flask-App | /server.py | 1,100 | 3.578125 | 4 | from flask import Flask
from flask import render_template
# from flask import request # -- We can also lose this as well
app = Flask(__name__)
# -- Here we are adding routes to a function we've called index -- literally only because its the landing page -- It's actually a view
# -- You can add multiple routes to a ... |
4963b9cb189e0a093df3d327f71ee5a2509f2887 | youthinnovationclub/2020Moonhack | /Moonhack2020-Python YCIC Ray Tang.py | 2,870 | 4 | 4 | #!/bin/python3
import random
events = [
("You are beginning to smell.Would you like to take a shower?(type yes or no,then hit[ENTER]):",-200,0),
("You hear a hissing sound coming from a pipe.Would you like to investigate?(type yes or no,then hit[ENTER]):",-10,-500),
("A lump of ice has fallen from the sky nearb... |
e92a1e16e5a0a6b16e51dd9a5122b5726ea3d5fa | BrothSrinivasan/leet_code | /inheritance/inheritance.py | 4,282 | 4.1875 | 4 | # Author: Barath Srinivasan
# Design the class structure for a banking system using object-oriented principles
# Your design must have at least 5 classes
# Each class must have at least 2 variables and 2 functions (doesn't need to be implemented, just declared)
# You must also use 1 enum
# Possible Clarifying Questio... |
53a3084e98ebf7cf8c9f3bb21043e9c70e1fd723 | JeffersonYepes/Python | /Challenges/Desafio005.py | 138 | 3.90625 | 4 | n = int(input('Type a number: '))
print('The Predecessor of {} is {}!'.format(n, n-1))
print('The Successor of {} is {}!'.format(n, n+1))
|
1e84685b98dee118455ebc79b0a56a6f461f976b | beebel/HackBulgaria | /Programming0/week3/4-Problems-Construction/solutions/5. fibonacciNum/fib_number.py | 467 | 3.84375 | 4 | def fib_number(n):
result = [1, 1]
if n == 1:
result.pop()
elif n == 2:
None
else:
for i in range(2, n):
nextNum = result[i - 2] + result[i - 1]
result.append(nextNum)
return result
def printResultAsOneNum(lst):
for e in lst:
print(e, end... |
c124cbe1ded5cec1f5c07eaef3edcc917d87d694 | imulan/procon | /atcoder/abc153/d.py | 93 | 3.609375 | 4 | h = int(input())
ans = 0
x = 1
while h > 0:
ans += x
x *= 2
h //= 2
print(ans)
|
750e5147e1675bf0168e4fd9aa5dcbad5dd0bd27 | bcveber/COSC101 | /lab5/lab5_c.py | 758 | 4.25 | 4 | #Appropriate variables
lot_number = 0
def lotnumber ():
'''
Prompts the user for the lot number. If the lot number does not equal 0, then
it will do the show_tax.
'''
lotnuminput = int(input("Enter the lot number: "))
while lotnuminput != 0:
show_tax()
lotnuminput = int(input("E... |
fdb1e970c534ae43d1ca817b9d15573cfd05e5ed | TCmatj/learnpython | /6-2_numbers.py | 197 | 3.625 | 4 | # TC2020/9/28/21:59
numbers = {'originyyx':5,'baby':0,'annan':7,'me':9,'huangliang':7}
for name,number in numbers.items():
print(name.title() + '最喜欢的数字是: ' + str(number) + '.')
|
d769092a52c20b982f5d39d42fc9e7045f54f5a0 | GeovaniSTS/PythonCode | /49 - Classificação_Triângulos.py | 253 | 4.03125 | 4 | L1 = float(input())
L2 = float(input())
L3 = float(input())
if L1 == L2 and L1 == L3 and L2 == L3:
print('equilatero')
else:
if L1 == L2 or L1 == L3 or L2 == L3:
print('isosceles')
if L1 != L2 and L1 != L3 and L2 != L3:
print('escaleno') |
9d3600eda65412ab4eddb5c271790bb9afe8ea7f | andre-Hazim/Unit_1-04 | /circumference_calculator.py | 459 | 3.609375 | 4 | '''
Created By: Roman Beya, Raymond Octavius, Andre Hazim
Created For: ICS3U
Created On: 25-Sep-2017
Calculates the circumference of a circle given the radius inputted by a user
'''
import ui
def calculate_on_touch_up_inside(sender):
# input
radius = int(view['radius_textfield'].text)
# process
circumference = 3.1... |
b0d92ec5bd20e7747c95fe6f9344b148a3b870b1 | CivilizedWork/Tommy-J | /Day_05/5thday2.py | 263 | 3.859375 | 4 | def eval_loop(end_string):
while True:
get_string = input('>>>')
if get_string != end_string:
last_answer = eval(get_string)
print(last_answer)
else:
break
print(last_answer)
eval_loop('done')
|
963ac486768b18d278a18e947a424cd01fdb124a | Mikemraz/Data-Structure-and-Algorithms | /LeetCode/search a 2d matrix.py | 1,581 | 3.984375 | 4 | def searchMatrix(matrix, target):
# write your code here
if len(matrix)==0:
return False
row_number = len(matrix)
column_number = len(matrix[0])
if target<matrix[0][0]:
return False
if target>matrix[row_number-1][column_number-1]:
return False
# compare first element ... |
8742647b84da22eebd6a0305e37eb8a3f9efd1aa | RawalD/Python-Data-Structures | /Anagram/anagram.py | 1,558 | 3.984375 | 4 | def anagram(one, two):
# Removes spaces and lower cases
one = one.replace(" ", "").lower()
two = two.replace(" ", "").lower()
# If length of the first is not the same as the second immediate return False
if len(one) != len(two):
return False
else:
# Create counter variable and... |
8c2409d7aa5b38bbe94384871a368246df9d0326 | AVatch/ascii-image-service | /ascii.py | 2,555 | 3.796875 | 4 | import os
import datetime
from PIL import Image, ImageDraw
ASCII_CHARS = [ '#', '?', '%', '.', 'S', '+', '.', '*', ':', ',', '@']
def scale_image(image, new_width=100):
"""Resizes an image preserving the aspect ratio.
"""
(original_width, original_height) = image.size
aspect_ratio = original_height/fl... |
546cdd91ed2ec01d9c548267fe8132f51d8152c2 | HystericHeeHo/testingPython | /tstp/ch8chal2.py | 134 | 3.59375 | 4 | import cubed
x = input('Please Choose a number: ')
try:
cubed.cubing(x)
except ValueError:
print('Please Choose a number.')
|
31c97cbad1b3ce42e8d871ae2ad40b7bc2edfbb6 | AhmedOmi/holbertonschool-higher_level_programming | /0x01-python-if_else_loops_functions/5-print_comb2.py | 117 | 3.640625 | 4 | #!/usr/bin/python3
for count in range(100):
print("{:02d}".format(count), end="\n" if count == 99 else ", ")
|
1302c6d53ae147160fcf056c0b7181e672a30df2 | stratos-gounidellis/algorithmsAssignments | /Gale-Shapley_StableMatchingAlgorithm/stable_marriage.py | 4,739 | 3.578125 | 4 | import json
import sys
import os.path
# this method returns a dictionary with
# the names and the preferences of the men/women
def parse_json(choice, filename):
dictionary = {}
f = open(filename, 'r')
j = json.load(f)
f.close()
j_string = json.dumps(j, sort_keys=True, indent=4)
data = json.loa... |
4529492766cca8166b8ad0e3fc05aacf2294876f | loghmanb/daily-coding-problem | /problem092_airbnb_courses_order.py | 1,955 | 3.65625 | 4 | '''
This problem was asked by Airbnb.
We're given a hashmap associating each courseId key with a list of courseIds values, which represents that the prerequisites of courseId are courseIds.
Return a sorted ordering of courses such that we can finish all courses.
Return null if there is no such ordering.
For example... |
f40991d02d3ccd34760273a2869fa793b11e8ea6 | Reikenzan/Some-Python | /HomeWork/hw43.py | 1,685 | 4.625 | 5 | """Implement the following pseudocode to draw a checkered flag to the screen.
1. Ask the user for the size of the checkered flag (n).
2. Draw an n x n grid to the screen.
3. For i = 0,2,4,...,n*n-1:
4. row = i // n
5. offset = row % 2
6. col = (i % n) + offset
7. fillSquare(row,col,"black")... |
e5174f9fde2deb27fc93d50a0b8769e2594d2361 | P-N-S/SVP-CPro | /StringAlgo.py | 1,152 | 4.40625 | 4 | # https://www.geeksforgeeks.org/python-program-to-check-if-given-string-is-pangram/
# Python program to check if given string is pangram
# A pangram is a sentence containing every letter in the Enlish Alphabet
import string
# Approach 1
def isPangram_Naive(str):
print("isPangram_Naive() - start | 17:15 19F19")
... |
1238ce8f38ee61d899afa1623fcc263ba47717cf | Yamievw/class95 | /python/read_data.py | 5,332 | 3.640625 | 4 | # This file reads in the data and fills two lists: one with
# students and one with courses. This data can be readily used
# by importing this module.
import csv
import math # for ceil.
class Course():
def __init__(self, name, components, registrants):
self.name = name
# a dictionary w... |
367b068c671e5e49a8e5bd2072ef01796d05cf74 | Rehan710/Udacitybikeshare | /bicyle.py | 4,469 | 4.125 | 4 | import time
import pandas as pd
import numpy as np
CITY_DATA = { 'chicago': 'chicago.csv',
'new york city': 'new_york_city.csv',
'washington': 'washington.csv' }
def get_filters(city, month, day):
print("\nRehan's stats for bikeshare\n")
print('Hello! Let\'s explore some US bikeshare ... |
0f8c3cb2cfb120c148da7746d81d845155467d2a | Hatim0110/Python_revision_tasks | /11-18/task1-2/main.py | 376 | 4.09375 | 4 | name = input("what's your name? ")
age =int(input("How old are you? "))
country = input("where are you from? ")
quots = '\ """"'
#print(f'"Hello \'{name.title()}\', How You Doing {quots} Your Age Is "{age}"" + Your Country Is: {country.title()}')
print(f'"Hello \'{name.title()}\', How You Doing \ \n{quots[1:-1]} Your A... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.