blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
ab98e0e4d90fbceb5658021fc1d8057789b738ba | emilianoNM/Tecnicas3 | /Reposiciones/reposicionesIsraelFP/reposicion7Ago18IsraelFP/tresEnterosIsraelFP.py | 537 | 3.734375 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 14 22:04:29 2018
@author: israel
"""
data=[]
def operaciones(data):
#suma=0
#for i in range(0,len(data)): suma=suma+data[i]
print "\nSuma: ",sum(data)
print "Promedio: ", sum(data) / float(len(data))
print "Producto: ", reduce((l... |
8ec249e715d5a21e500a9372aec0cc11f7ab26f6 | westgate458/LeetCode | /P0347.py | 579 | 3.71875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 30 17:59:24 2019
@author: Tianqi Guo
"""
from collections import defaultdict
class Solution(object):
def topKFrequent(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: List[int]
"""
#... |
4ebc1fd17998a8e082ea94f1ad8b79ef47a36324 | emaxwell711/mdn-project | /utilities/SplitBits.py | 354 | 3.71875 | 4 | def SplitBits(bits):
if len(bits) == 32:
five = bits[:5]
four = bits[5:9]
rest = bits[9:]
return five , four , rest
else:
raise ValueError('length of bits must be 32 characters')
sample = '01010101010010101010101011010101'
five , four , rest = SplitBits(sampl... |
0daa43bc84580d93dc7d332c13fa2b77bda32318 | jayshreevashistha/forskml | /Coding Challenge/Day_3/generator.py | 584 | 4.3125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu May 9 10:19:30 2019
@author: computer
"""
sample=input("Enter the numbers").split(",")
print("list:",list(sample))
print("tuple:",tuple(sample))
""""""""""""""""""""""""""""""""""""""""""""""""
# Enter comma separated numbers
user_list = input("Enter comma seperated numb... |
0a479aeb4b613a6241f7c82124dd7e946f84b8be | wagnerwar/4linux-lessons | /animais.py | 355 | 3.71875 | 4 | # !/usr/bin/python
animais = ["gato","cachorro", "passarinho"]
print(animais)
animais.append("boi")
print(animais)
animais.insert(2,"lagarto")
print(animais)
animais.remove("gato")
print(animais)
animais.pop()
print(animais)
animais.pop(1)
print(animais)
print(animais.count("ppp"))
print(animais.index("passarinho"))... |
736447ca94854b573fc7ea9573d8677ca3f9697f | QiTai/python | /processManage/fig18_10.py | 1,184 | 3.515625 | 4 | #using os.pipe to communicate with a child process
import os
import sys
#open parent and child read/write pipes
fromParent, toChild = os.pipe()
fromChild, toParent = os.pipe()
#parent about to fork child process
try:
pid = os.fork() #create child process
except OSError:
sys.exit("Unable to create child process")
... |
5e312df873e2f8b225e0b83b903ffd9fd92753b1 | sparsh-m/30days | /d2_2.py | 824 | 3.609375 | 4 | #https://leetcode.com/problems/pascals-triangle/
"""
1)If num_rows == 0 return 0
2)If num_rows is 1 or 2 return hardcoded solution.
3)If num_rows is greater than zero, for ith row, arr[i][0] = 1 or arr[i][i] = 1
4)arr[i][j] = arr[i-1][j-1] + arr[i-1][j+1]
Time Complexity: O(num_rows^2/2)=O(n^2)
Space Complexity: o(num... |
73f94e8417923e45b6dc13b9a56fa9021c6224ac | Aasthaengg/IBMdataset | /Python_codes/p00007/s152050164.py | 170 | 3.59375 | 4 | n = int(raw_input())
debt=100000
for i in range(n):
debt*=1.05
if debt % 1000 != 0:
debt = (int(debt / 1000)+1) * 1000
else:
debt = int(debt)
print debt |
0606514c7a5bbf6f8205fa3cc41441229ed24d88 | SagnikAdusumilli/csc148 | /exercises/ex6/ex6_test.py | 1,909 | 3.8125 | 4 | """CSC148 Exercise 6: Binary Search Trees
=== CSC148 Fall 2016 ===
Diane Horton and David Liu
Department of Computer Science,
University of Toronto
=== Module description ===
This module contains sample tests for Exercise 6.
Warning: This is an extremely incomplete set of tests!
Add your own to practice writing test... |
cebf0c832c23c3588d3a63382b3eb826214e47d8 | rickhaffey/python-per | /chapter03.py | 24,149 | 4.40625 | 4 | # ## 3. Types and Objects
# every piece of data stored in a py program is an Objects
# each object has a
# - identity (pointer to a loc. in memory)
# - type (class)
# - value
# identity and type can't be changed after instantiation
# if value can be changed, object is mutable, otherwise, it's immutable
# object that... |
a0e5e7e76ed2b3b3b2e4b1b751d809dd2e1e3e3d | munagekar/cp | /leetcode/00001.py | 723 | 3.546875 | 4 | '''
https://leetcode.com/problems/two-sum/
Approach one : nlogn + nlogn
For every number binary search sorted array
Approach two Used: nlogn + n
Two Pointer first,last in sorted array
Approach three: Linear
Use Map, Check if number complement is present else insert number
Eg: If on 2 and target is 7, check for 5.
'... |
a96fd5b24b5dbcfcb1db831f8655511a20fa6ea2 | AlbaGV/Python | /Python/String/string1.py | 327 | 3.953125 | 4 | # Se dice una fruta y luego se pide un numero (desde 1), este numero corresponde a una letra de fruta escrita
fruta=raw_input("Dime una fruta: ")
num1=int(raw_input("Dime un numero:"))
num2=num1-1
long=len(fruta)
if num1>long:
print "Lo siento, la fruta no tiene tantas letras"
elif num1<=long:
print frut... |
04e3bc6388d48c047244e90e7d7365db95bf6522 | savadev/interviewbit | /Arrays/maximum-consecutive-gap.py | 1,647 | 3.78125 | 4 | '''
Given an unsorted array, find the maximum difference between the successive elements in its sorted form.
Try to solve it in linear time/space.
Example :
Input : [1, 10, 5]
Output : 5
Return 0 if the array contains less than 2 elements.
You may assume that all the elements in the array are non-negative integers... |
856ac59798d7d146a2a8250554009189e6cdc4cb | dpezzin/dpezzin.github.io | /test/Python/dataquest/matrices_and_numpy/index_data.py | 923 | 4.3125 | 4 | #!/usr/bin/env python
# The columns are Year, Region, Country, Beverage type, and Number of liters of pure alcohol drunk per person
# The print function below prints the number of liters of pure alcohol vietnamese drank in wine in 1986.
print(world_alcohol[0,4])
# The Beverage type can take the values "Beer", "Wine", ... |
1cad548311a8896ebdc7c873daf2695bce5422f4 | Nepta75/hi-python | /ex03_rps/main.py | 1,330 | 3.515625 | 4 | import random
rpsValues = {
'pierre': 'papier',
'papier': 'ciseau',
'ciseau': 'pierre',
}
def isWin(rpsNamePlayer, rpsNameBot):
win = 'perdu'
if rpsNamePlayer == rpsNameBot:
win = 'null'
return win
if rpsValues.get(rpsNamePlayer) != rpsNameBot:
win = 'gagné'
return win
def game():
rps... |
b8cf7ec765719e0136cd0dcc3377f592d6d06cf9 | harshsinghs1058/python_hackerrank_solutions | /String_Formatting.py | 423 | 3.578125 | 4 | # This code is written by harsh.
def print_formatted(n):
l_bin = len(str(bin(n))[2:])
for i in range(1, n + 1):
print(str(i).rjust(l_bin, " "), end=" ")
print(str(oct(i))[2:].rjust(l_bin, " "), end=" ")
print(str(hex(i))[2:].upper().rjust(l_bin, " "), end=" ")
print(str(bin(i))[2... |
c44b64febe0112bf12beb1de369ec9735c9a1059 | Asi4nn/Pygame-Graphing-Calculator | /analyze.py | 12,349 | 4.15625 | 4 | #--------------------------------------------------------------------------------
# Entering and Analyzing Equation
# Julian and Leo
# Analyses the equations and fingures out what they mean
# Also calculates analyzed equations to graph with
#-------------------------------------------------------------------------... |
c47d6f651d3181107fedb40297d1083ce00b6081 | dmahugh/weather-tracker | /updater.py | 4,437 | 3.625 | 4 | """Gets weather forecasts from OpenWeatherMap API for tracked locations and
stores them in the Cloud SQL database.
Before running this code, open a command window and run this command to launch
the Cloud SQL proxy:
cloud_sql_proxy -instances=<database_instance_connection_string>
"""
import requests
import defaults
fr... |
99dff7e2714dc096b6440f9dbf64ff56e90e5dcb | amymiao/connect-five | /connect_5.py | 5,136 | 3.734375 | 4 | '''
AI Project: Connect 5
Rules:
The game board will be a square board of length n where n is greater than or equal to 5
User will always start
'''
from alphaBeta import *
class Connect5():
game_board = []
game_board_size = 0
def __init__(self, game_board_size):
self.game_board_size = game_b... |
4bf30e0e13d2590adfdcbde3a9bf3f34d4bd6a7c | xiaohanghang/Nabu-MSSS | /nabu/neuralnetworks/models/linear.py | 1,922 | 3.53125 | 4 | '''@file linear.py
contains the linear class'''
import tensorflow as tf
import model
from nabu.neuralnetworks.components import layer
class Linear(model.Model):
'''A linear classifier'''
def _get_outputs(self, inputs, input_seq_length, is_training):
'''
Create the variables and do the forwar... |
9fc8e60744ef76905c0afc6c68c01654a0e557cb | BeatrizInGitHub/python-sci | /sesion_17/poo.4.py | 592 | 3.5625 | 4 | import math
class Robot:
def __init__(self):
self.x = 0
self.y = 0
self.a = 0
def avanzar(self):
d = 1
self.x += d * math.cos(self.a)
self.y += d * math.sin(self.a)
def girar_izq(self):
da = 2 * math.pi / 36
self.a -... |
110b05d0cf7cb14159818b9049fb5605e3eded50 | fijila/PythonExperiments | /test/Closure1.py | 965 | 4.0625 | 4 | #!/bin/python3
import sys
import os
# Add the factory function implementation here
def factory(n=0):
def current():
return n
def counter():
nonlocal n
n+=1
return n
return current,counter
f_current,f_counter, = factory((2))
print(f_current())
print(f_counter())
#------... |
d3a159f9fee02a8da093a71c70ffc32fab228647 | swarnanjali/lakshmi5 | /begqu72.py | 142 | 3.96875 | 4 | ch=input()
vowels={"a","e","i","o","u","A","E","I","O","U"}
if any(char in vowels for char in ch):
print("yes")
else:
print("no")
|
74669ef0faeb8ce659dd2e0bedde52d8b73bc24f | MartaSzuran/Python-for-the-Absolute-Beginner-M.Dawson | /Chapter 4/jumble_letters_2.py | 2,351 | 4.09375 | 4 | # program wymieszane litery
# z krotki kilku słów losowo jest losowane jedno, a następnie miesza się jego litery
# użytkownik zgaduje
# może poprosić o podpowiedz
# jeżeli rozwiąze z podpowiedzią ma mniejsza ilość punktów niz jak bez jej użycia
import random
# sekwencja słow do wyboru dużymi literami ponieważ ma być... |
0832aeacd4fdacfbd4925e90541e086e2e1e9add | danielwilstrop/pythonalgorithms | /radixsort.py | 1,075 | 4.375 | 4 | # Takes numbers in an input list.
# Passes through each digit in those numbers, from least to most significant.
# Looks at the values of those digits.
# Buckets the input list according to those digits.
# Renders the results from that bucketing.
# Repeats this process until the list is sorted.
def radix_sort(list):
... |
03e6daba805291e8befc51a85ddc5d0018628a8c | homo-sapiens94/Bites_of_py | /86/rgb2hex.py | 699 | 3.921875 | 4 | def rgb_to_hex(rgb):
"""Receives (r, g, b) tuple, checks if each rgb int is within RGB
boundaries (0, 255) and returns its converted hex, for example:
Silver: input tuple = (192,192,192) -> output hex str = #C0C0C0"""
code = '0123456789ABCDEF'
lst = ['#']
error_string = f'Value not in ran... |
bc73ae51b097a793d7f25b7fb62fa0eeddc24bf0 | cgxabc/Online-Judge-Programming-Exercise | /Leetcode/ReverseLinkedList copy.py | 661 | 4.21875 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 1 22:04:35 2018
@author: apple
"""
"""
Reverse a singly linked list.
click to show more hints.
Hint:
A linked list can be reversed either iteratively or recursively.
Could you implement both?
"""
#recursively(递归)
def reverseList(head):
new... |
43cdbd05e1ef00d9426d2ba135e3ab19d3b09e8b | zhiyanfoo/courses-scripts | /rename.py | 1,159 | 3.609375 | 4 | import os
# Copy and paste whatever prefix you want to remove to either di_prefix or fi_prefix.
#If you want to remove directory prefix, UNCOMMENT THE LAST LINE. Then run the script.
# File prefixes
# 'MIT18_03S10_'
# 'MIT18_02SC_'
# 'MIT18_06SCF11_'
# 'MIT6_041SCF13_'
# 'MIT18_100BF10_'
# 'MIT18_100CF12_'
# Direc... |
ac236d52e1dd7fb9d8bad9342e9907ffbda5a6bc | PiJoules/Kalman-Filter | /test_voltmeter.py | 2,227 | 3.84375 | 4 | #!/usr/bin/env python
# -*_ coding: utf-8 -*-
import random
import sys
import numpy
import matplotlib.pylab as pylab
from kalman import KalmanFilterLinear
class Voltmeter(object):
"""Measure voltage with a noisy voltmeter."""
def __init__(self, voltage, noise):
self._voltage = voltage
self.... |
010fbdbecfffb9193e48cf6c9bce98c61fdd35a3 | mychristopher/test | /pyfirstweek/第一课时/使用类实例化对象.py | 991 | 4.125 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
"""
格式: 对象名 = 类名(参数列表) #对象名就是变量名
相当于函数,没有参数,小括号也不能省略
访问属性
格式:对象名.属性名
赋值:对象名.属性名 = 新值
访问方法
格式:对象名.方法名(参数列表)
"""
class Person(object):
name = ""
age = 0
height = 0
weight = 0
#方法的参数必须以self当第一个参数,self代表类的实例(某个对象)
def run(self):
print("run")
... |
8345ded7120b46b7e534919ad5d1faa2fd2ac711 | reincarne/python-codes | /xexpression_calculator.py | 2,345 | 4.375 | 4 | def calculate(expression):
if isinstance(expression, int):
return expression
elif type(expression) is tuple or type(expression) is list:
operator = expression[0]
operands = expression[1:]
if operator == 'add':
return sum(calculate(operand) for operand in operands)
... |
ff6b6943210e3fd80e8f34562eecc42d8a7cd1a4 | VithayaMoua/CSP1718 | /DiceSim2.0.py | 722 | 4.21875 | 4 | import random
def roll(sides=6):
num_rolled = random.randint(1,sides) #generate random number between 1 and sides (default to 6)
return num_rolled #return the random number
def main():
sides = 6 #store the number 6 in a variable
rolling = True #store True in a variable
while rolling:
r... |
35b63d0054de47bff22fe06f8472cad99a49ea11 | pedrolucas27/exercising-python | /list03/exer_13.py | 397 | 3.859375 | 4 | #Faça um programa que peça 10 números inteiros, calcule e mostre a quantidade de números pares
# e a quantidade de números impares.
pares = 0
impares = 0
for c in range(1,11):
n = int(input("INFORME O NÚMERO {}:".format(c)))
if n % 2 == 0:
pares += 1
else:
impares += 1
print("QUANTIDADE DE ... |
4bf20b3025ea7b8fdfea6b27e9b0dc127e370675 | smallwat3r/shhh | /tests/test_secret_encryption.py | 965 | 3.53125 | 4 | import unittest
from cryptography.fernet import InvalidToken
from shhh.api.encryption import Secret
class TestSecretEncryption(unittest.TestCase):
"""Encryption testing."""
secret = "I'm a secret message."
passphrase = "SuperSecret123"
encrypted_text = (
b"nKir73XhgyXxjwYyCG-QHQABhqCAAAAAAF... |
2adf8c214ec522dd1e95c1896d4c1edcb740122a | jcravener/PythonWorkroom | /selDividingNumber.py | 731 | 3.703125 | 4 |
def selfdividingnumbers(left: int, right: int):
result = []
subresult = False
for i in range(left, right+1):
si = str(i) #--cast number to str
if "0" not in si: #--ignore if there's a '0' in the number
j = 0
while j < (len(si)):
ij = int(si[j]) #... |
ba5a2e8068babbe0c00bf428394a1a8e72a15534 | thamyresmfs/trabalho-extra | /facil.PY | 180 | 3.734375 | 4 | p = input("informe o preço")
print(p)
d = input("informe o desconto")
print(d)
vf = (float (p) * float(d))/100
print((p),"reais, com",(d),"%","de desconto, deu",(vf),"reais.")
|
08c8077c280217436812cc8ebabddeeb33c91d53 | UltimoTG/Exercism | /python/pangram/pangram.py | 183 | 3.640625 | 4 | def is_pangram(sentence):
alphabets = list(map(chr, range(97, 123)))
for i in alphabets:
if (i not in sentence.lower()):
return False
return True
|
b507265615760ff3a98ac50b944477359a46fde8 | MifARION/Mif_project | /homework_two_mif.py | 1,279 | 4.25 | 4 | #Задание 1
number = float(input('Enter float number: '))
round_one = round(number, 0)
round_two = round(number, 2)
round_three = round(number, 5)
print(f'{round_one} округление до 0, {round_two} округление до 2 цифр после запятой, {round_three} округление до 5 цифр после запятой')
#Задание 2
list_one = [2, 4, 7, 9... |
aedd01b1887a2f953d1036dc1e1a295d7e46c6a8 | kylealbany/Pomodoro-Timer | /Pomodoro.py | 3,650 | 3.734375 | 4 | import time
import Tkinter
# Have to incorporate weekly tracker, load total pomodoros from file and reset weekly
# Add in sounds for starting/completing work and breaks
# Implement a pause function
# Make executable GUI
# In GUI include Start and pause/resume buttons, countdown timer, number of pomodoros, working/shor... |
88a7d1a1abffb3cf57b1884e154adcad1e234812 | mridulrb/Basic-Python-Examples-for-Beginners | /Programs/MyPythonXII/Unit1/PyChap02/vowel.py | 390 | 4.25 | 4 | # File name: ...\\MyPythonXII\Unit1\PyChap02\vowel.py
# Program to find total number of vowels in a string
String = input("Enter a string: ")
String = String.upper()
Slen = len(String)
VOWELS = "AEIOU"
Ctr = 0
for ch in range(Slen):
if String[ch] in VOWELS:
Ctr += 1
if Ctr > 0:
print("Total n... |
bac11844ba0d34f1d3230ec4623550e7c2877818 | florentinap/eGuv | /tema3/backend/domain.py | 948 | 3.578125 | 4 | from urllib.parse import urlparse
def get_subdomain_name(url):
"""
Get the sub domain name (name.example.ro)
:type url: str
:rtype: str
"""
try:
return urlparse(url).netloc
except:
return 'Cannot get sub domain name from %s. Make sure URL is correct.' % (url)
def get_dom... |
3dc0e8e2b15c3cf1a288e2f866ebc13c8635209f | EricMoura/Aprendendo-Python | /Exercícios de Introdução/Ex020.py | 232 | 3.578125 | 4 | import random
a1 = input('Primeiro aluno: ')
a2 = input('Segundo aluno: ')
a3 = input('Terceiro aluno: ')
a4 = input('Quarto aluno: ')
lista = [a1,a2,a3,a4]
random.shuffle(lista)
print(f'Ordem da apresentação: {lista}') |
7acece58b8cd043d9a83dce7bffd7196ade8f5c8 | kampanella0o/python_basic | /lesson8/dict_methods.py | 892 | 3.75 | 4 | a = {'short': 'dict', 'long': 'dictionary'}
#clear - clears the dictionary
# a.clear()
# print(a)
#copy - copies dictionary
# b = a.copy()
# print(b)
# b = dict(a)
# print(b)
#get - get value by key. First parameter is key, the second is default value ("None" by default)
# print(a['long'])
# print(a.get('long'))
# ... |
2c1364d4d5c247f80112598ed4006ba6fd32d0f2 | iliachigogidze/Python | /Cormen/Chapter2/day6/take3/with_imports_sum_of_two_numbers.py | 578 | 3.984375 | 4 | from Chapter2.day4.binary_search import main as binary_search
from Chapter2.day3.merge_sort import main as merge_sort
def main(numbers:list, target_value:int) -> bool:
print(f'Find {target_value} in {numbers}')
sorted_numbers = merge_sort(numbers)
for i in range(2, len(numbers)+1):
indices = sorte... |
54a05c194227dfa49720fce153ace4502f3f6537 | Gokul58/python-program | /armstrong.py | 192 | 3.828125 | 4 | n = int(input("enter the number"))
t = n
r = 0
while(n>0) :
a = n % 10
r = r+a*a*a
n = n//10
if(r==t):
print("armstrong number")
else:
print("not a armstrong number")
|
c07e37ea841d7acd62fee3246b9e967fbe15437f | sdcoffey/leetcode-solutions | /valid_number/tests/valid_number_test.py | 864 | 3.59375 | 4 | import unittest
from valid_number import Solution
class TestValidNumber(unittest.TestCase):
def testValidNumber(self):
table = {
'0': True,
' 0.1 ': True,
'abc': False,
'1 a': False,
'2e10': True,
'.1': True,
... |
0067e653cc27c666a7a611ad1916f5582ad717b7 | green-fox-academy/andrasnyarai | /week-02/d01/odd_even.py | 236 | 4.34375 | 4 | # Write a program that reads a number form the standard input,
# Than prints "Odd" if the number is odd, or "Even" it it is even.
a = input("Insert number here: ")
if int(a) % 2 == 0:
print("Even")
if int(a) % 2 > 0:
print("Odd")
|
ad4944a08f1b9253332a5ed10911b1876352bd47 | axd8911/Leetcode | /mianshi_prep/tracyAMZ/1SearchIn2D_Optimized.py | 499 | 3.625 | 4 | class Solution:
def searchMatrix(self, matrix, target):
"""
:type matrix: List[List[int]]
:type target: int
:rtype: bool
"""
if not matrix:
return False
d1 = len(matrix)-1
d2 = 0
while d1>=0 and d2<len(matrix[0]):
if ma... |
336609775f6d6d74bbb995eabcefba1d9e1b4aaf | tbjohnston/itila | /Hamming Encode 7 4 v3.py | 6,240 | 3.71875 | 4 | # Implement Hamming code algorithms in Python using NumPy
#
# Begun 29 Dec 2012
# Modified 16 Jan 2013
# Modified 17 Jan 2013 - add syndec, better output
# Modified 18 Jan 2013 - use boolean operators
# Modified 20 Jan 2013 - clean up m2mult
#
# This version does right multiplication -> t = G(T)s, where
# G is the gen... |
ed75cb8163c30157788555ab727a48e7597ec210 | samarxie/Python-Machine-Learning-Homework | /20171021/kimmyzhang_20171021_01.py | 646 | 4.09375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Author: Kimmyzhang
@Email: 902227553.com
@File: kimmyzhang_20171021_01.py
@Time: 2017/10/21 21:49
"""
def jump_step_by_recursion(n):
if n == 1 or n == 2:
return n
else:
return jump_step_by_recursion(n - 1) + jump_step_by_recursi... |
6bfff2d988cea9823dd6a6167aea5df8cb84e4ef | morganbarlow/bottegaHomework | /python/feb18.py | 1,881 | 3.984375 | 4 | # - Build 2 python classes.
# - One class must inherit from the other.
# - At least one class must have a __init__ constructor function.
# - At least one class must have a __str__ function.
# - At least one class must have a __repr__ function.
# - Between your two classes, you must have at least 5 instance attributes, ... |
9a00878230dce1f73c66ae529c5212c8da7cc59a | alexandraback/datacollection | /solutions_5751500831719424_0/Python/MrDubious/problem_a.py | 2,684 | 3.59375 | 4 | #!/usr/bin/python
import sys, os, copy
class TestCase:
def __init__(self, strings):
self.strings = strings
def __repr__(self):
return str(self.strings)
def remove_repeats(self, string):
new_str = ''
for char in string:
if len(new_str) > 0 and char == new_str[-1]:
continue
ne... |
f8fd0fc8e0f5fd25f0596c452ea543942e93db74 | mrmukto/Python-Practise | /debugging.py | 105 | 3.515625 | 4 | def add(*y):
sum = 0
for num in y:
sum = sum + num
return sum
print(add(10,20)) |
944ede72f7ee18dd97d0712c409cfea502a3f92c | Lisss13/function | /python/1.py | 1,023 | 3.984375 | 4 | # замыкание
# def foo (x):
# def doo(y):
# return x + y
# return doo
#
# a = foo(5)
#
# print(a(2), a(10))
# ################################################################
# def f (x = 0):
# def ff(*array):
# array = [c * x for c in array]
# return array
# return ff
#
#
# p... |
63d934310b55f2da71aa5dcfd189668f34f478f1 | pdhhiep/Computation_using_Python | /bvec/bvec_add.py | 2,697 | 4.25 | 4 | #!/usr/bin/env python
def bvec_add ( n, bvec1, bvec2 ):
#*****************************************************************************80
#
## BVEC_ADD adds two binary vectors.
#
# Discussion:
#
# A BVEC is an integer vector of binary digits, intended to
# represent an integer. BVEC(1) is the units digit, BVEC... |
cc4586fc69ce57317aa2a78f39159a762dc6bcbd | nbvc1003/python | /ch02/ex10.py | 314 | 3.8125 | 4 |
num1 = 12
num2 = 3.567
s1 = "성공"
# 사칙연산 결과를 출력
print("%d + %0.2f = %0.2f, %s"%(num1, num2, num1+num2, s1))
print("%d - %0.2f = %0.2f, %s"%(num1, num2, num1-num2, s1))
print("%d * %0.2f = %0.2f, %s"%(num1, num2, num1*num2, s1))
print("%d / %0.2f = %0.2f, %s"%(num1, num2, num1/num2, s1))
|
071dbb79685689db1613ef88e6437e9bcbb68c36 | junyechen/PAT-Advanced-Level-Practice | /1042 Shuffling Machine.py | 2,733 | 4.09375 | 4 | """
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid "inside jobs" where employees collaborate with gamblers by performing inadequate shuffles, many casinos employ automatic shuffling machines. Your task is to simulate a sh... |
31e6e9e69cbb37181a63030a6cd705b35308c74d | MaksymKorolyuk/LITS | /test.py | 510 | 3.578125 | 4 | # print('\n'.join([''.join([('Love'[(x-y) % len('Love')] if ((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3 <= 0 else ' ') for x in range(-30, 30)]) for y in range(30, -30, -1)]))
# def fibonacci(x):
# if x < 2: return 1
# return (fibonacci(x - 2) + fibonacci(x - 1))
#
#
# def factorial(x):
# if x < 2:... |
5d6ba773208965b9e04e32b4ab1fa31d3b432974 | rcas99/BeautifulPatternsMIT | /day2/for_loop7.py | 422 | 3.859375 | 4 | """
Conditionals programming exercises
For loop
"""
x = int(input("Escoge un numero positivo 'x': "))
y = int(input("Escoge un numero positivo 'y' que sera el tope de la iteracion: "))
print("La serie del 0 al 50 con saltos 'x' es:")
for number in range(0, 50):
if number % 5 == 0:
print("El numero '{0}'... |
a1acedd55ae57e579110d787922f4fe80ecedd19 | sivant/algorithms | /danidin.py | 2,751 | 3.5 | 4 | import random
class PeopleSet:
def __init__(self, size, force_danidin=False):
self.size = size
self.familiarity_matrix = [[False for i in range(size)] for i in range(size)]
break_point = random.random()
for i in range(size):
for j in range(size):
if ran... |
e2c380d0899447c065fa0460d9acefe785e875b4 | ManasveeMittal/dropbox | /DataStructures/DataStructureAndAlgorithmicThinkingWithPython-master/chapter18divideandconquer/StockStrategyWithDivideAndConquer.py | 2,062 | 3.765625 | 4 | # Copyright (c) Dec 22, 2014 CareerMonk Publications and others.
# E-Mail : info@careermonk.com
# Creation Date : 2014-01-10 06:15:46
# Last modification : 2008-10-31
# by : Narasimha Karumanchi
# Book Title : Data Structures And Algorithmic Thinking With Python
# Warranty ... |
4cfb16fc13e2b8fe30a34c328f95d6495a540620 | gshruti015/pyLab | /lab2/Shruti_Gupta_21.py | 1,670 | 4.3125 | 4 | #!/usr/bin/env python
# coding: utf-8
# 1. Write a program that accepts a sentence from the keyboard, calculate and print out each unique character and its corresponding number of occurrence. Don’t count spaces. For example, if the input sentence is: the world is beautiful! , then the output should be the following:
#... |
362c9381627ded16af35b3e52e890fade50e7a57 | lachlanpepperdene/CP1404_Practicals | /Prac03/asciiTable.py | 554 | 4.09375 | 4 | def get_number(number):
if number > 10 and < 50:
true
get_number()
def main():
value = (input("Enter character: "))
print("The ASCII code for", value, "is", ord(value), )
number = int(input("Enter number between 10 and 50: "))
while get_number():
print("The character for... |
4f9aa88539f5fbacda0182b1d6462c75df52d3db | alessandro-santini/TenNet | /TenNet/tools/HilbertCurve.py | 10,840 | 3.859375 | 4 | """ https://github.com/galtay/hilbertcurve
This is a module to convert between one dimensional distance along a
`Hilbert curve`_, :math:`h`, and n-dimensional points,
:math:`(x_0, x_1, ... x_n)`. The two important parameters are :math:`n`
(the number of dimensions, must be > 0) and :math:`p` (the number of
iterations ... |
1186d2949fe41aebe310d37d6f403127990c3960 | saipraneethyss/HackerRank_Codes | /calendarmod.py | 146 | 3.65625 | 4 | import calendar
dateval = list(map(int,input().split()))
print((calendar.day_name[calendar.weekday(dateval[2], dateval[0], dateval[1])]).upper())
|
4b025fb3cc0b097334cd2e81292f05e4acc0d650 | stevestar888/leetcode-problems | /1431-kids_with_most_candy.py | 1,565 | 3.890625 | 4 | """
https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/
Strat:
For a given kid, we just have to see if their candies + extraCandies is the most (or equal to)
all the other children's. The trick: the kid with the most candy (before extras are added)
will always be the same.
Therefor... |
bfa51ca3ff543d781b78398dd261b5f37b393ba8 | M2401/P1 | /loops/190720_lists/lr_odnomernie_spiski/13/13.2.py | 813 | 3.921875 | 4 | #13.2. Дан одномерный массив из 8 элементов. Заменить все элементы массива меньшие 15 их
# удвоенными значениями. Вывести на экран монитора преобразованный массив.
import random
def cr(a):
for i in range(8):
a.append(random.randint(-15, 30))
def pr(a):
for i in a:
print(i, end=' ')
def comp(... |
e9448a063545847139eca4bf24a741ca2dfeca12 | SpiritFryer/USACO | /numtri_recursive-commented-out-partially.py | 3,287 | 3.578125 | 4 | """
ID: seishin1
LANG: PYTHON3
TASK: numtri
"""
# Needs max_depth > 1. # Recursion depth exceeded for max_depth >= 998.
def dfs_binary_tree(triangle, current_depth, current_index, max_depth, current_sum, max_sums):
if current_depth == max_depth - 1:
# print(' ' * current_depth, current_depth, current... |
5862340d3e5dccc969c45cb9b8866fbfc62f3a64 | rafael1717y/repo-python | /treehouse_python/basico/13. sequences.py | 438 | 4.03125 | 4 | my_name = "Rafael"
groceries = ['roast beef', 'cucumbers', 'lettuce', 'dog food']
for letter in my_name:
print(letter)
"""
index = 1
for item in groceries:
print(f'{index}.{item}')
index+=1
"""
# Enumerate
for index, item in enumerate(groceries, 1):
print(f'{index}.{item}')
# Ranges - 3 argumentos
#... |
787e2f567abf22bc07b8890daf8d0ca4fd676757 | manutdmohit/mypythonexamples | /pythonexamples/findnumberofoccurencesofeachcharacterinstringdictionary.py | 83 | 3.578125 | 4 | word=input('Enter any string:')
d={}
for ch in word:
d[ch]=d.get(ch,0)+1
print(d)
|
d1e5a4e261d513a0427a807ae8a0e86cc220fdfe | joestalker1/leetcode | /src/main/scala/common_lounge/Recursion.py | 385 | 3.65625 | 4 | def f(x, y):
if y == 0:
return 1
a = f(x, y // 2)
if y % 2 == 0:
return a * a
else:
return a * a * x
def f1(x, y):
if y == 0:
return 1
if y == 1:
return x
a = f1(x, y // 2)
if y % 2 == 0:
return f1(x, y // 2) * f1(x, y // 2)
else:
... |
f2867e0033d487aa1dd8157230da44ec2cbf625d | amalshehu/Python-Introduction | /is_int.py | 371 | 4.15625 | 4 | # File: is_even.py
# Purpose: To check a number is an integer or not
# Programmer: Amal Shehu
# Course: Codecademy
# Date: Wednesday 31st August 2016, 05:50 PM
x = raw_input("Enter a number :")
def is_int(x):
# if x - int(x) > 0: #failed
if x % 1 == 0:
... |
a8db26fcde80f2463a9146be7cf31159f11b8a03 | thelsandroantunes/EST-UEA | /LPI/Listas/L2_LPI - repetição e condicionais/exe53.l2.py | 593 | 3.734375 | 4 | # Autor: Thelsandro Antunes
# Data: 13/05/2017
# EST-UEA
# Disciplina: LP1
# Professora: Elloa B. Guedes
# 2 Lista de Exercicios (06/04/2015)
# Questao 53: Escreva um algoritmo que leia 50 numeros e informe:
# (a) O maior valor lido;
# (b) O menor valor lido;
# (c) A media dos valore... |
60886328650bc204134170ed118da7c36e77198d | AndresCallejasG/holbertonschool-higher_level_programming | /0x02-python-import_modules/100-my_calculator.py | 731 | 3.515625 | 4 | #!/usr/bin/python3
if __name__ == "__main__":
import sys
from calculator_1 import mul, div, add, sub
av = sys.argv
argc = len(av)
if argc != 4:
print("Usage: ./100-my_calculator.py <a> <operator> <b>")
exit(1)
else:
a = int(av[1])
b = int(av[3])
if av[2] ==... |
51fd7c6964e3b2647f4d2047557b749d0b7aacea | jgartsu12/my_python_learning | /python_numbers/math_operators.py | 1,101 | 4.21875 | 4 | print('Addition')
get_sum = 100 + 42
print(get_sum) # prints 142, an integer
print('Subtraction')
print(100 - 42.3) # prints 57.7;; integer and floats can work together
print('Division')
print(100 / 42.3) # prints 2.3640661938853281
print(100 / 42) # prints 2.380952380952381
print(100 / 38) # prints 2.631....
... |
f3bab8931de0b2f203b5a25072dd277c69181336 | SuchanRai/10_Question | /9th.py | 148 | 4.0625 | 4 | # to check the leap year
year = int(input('enter the year'))
if (year/4 == 0) & (year/100 != 0):
print('LEAP YEAR')
else:
print('leap year') |
f1135e62c905b285cbff21cb86188101b563840c | RagnvaldIV/AdventOfCode2020 | /Day 3/part2.py | 1,463 | 3.546875 | 4 | # Open file and set up vars
inputTxt = open("Day 3/input.txt", "r")
# Read over file to get size of array
lineLength = len(inputTxt.readline()) - 1
numOfLines = len(inputTxt.readlines()) + 1
slope = [[0 for i in range(lineLength)] for j in range(numOfLines)]
position = 0
treeCount = [0, 0, 0, 0, 0]
inputTxt.seek(0,... |
24e4d2bc5c51bedcee3ba0fbc54896273b096b93 | LokiGizmo/pong | /main.py | 2,822 | 3.640625 | 4 | # simple bong python 3
# cridit @tokyoedtech
# part 1
import turtle
wn = turtle.Screen()
wn.title('pong by gizmo')
wn.bgcolor('black')
wn.setup(width=800, height=600)
wn.tracer(0)
# score
score_a = 0
score_b = 0
# paddle A
paddle_a = turtle.Turtle()
paddle_a.speed(0)
paddle_a.shape('square')
paddle_a.color('red')
p... |
62896e6f9a4169f6f3e952bff0d5b851de1c0661 | MarkiMarki/bio-project | /src/executors/mark/my_databases.py | 5,756 | 3.84375 | 4 | ####################
####################
####################
import sqlite3
def main():
db = sqlite3.connect('test.db') # connects to db in creats file
db.row_factory = sqlite3.row # allows to specify how to return rows from curser
db.execute('drop table if exists te... |
1349b4e71a4fbe0fb6af419e4c4958e60af4364d | vilisimo/ads | /python/leetcode/easy/ex0000_0100/ex0069.py | 929 | 4.34375 | 4 | # Given a non-negative integer x, compute and return the square root of x.
# Since the return type is an integer, the decimal digits are truncated,
# and only the integer part of the result is returned.
# Note: You are not allowed to use any built-in exponent function or operator,
# such as pow(x, 0.5) or x ** 0.5.
... |
90a86804d1f7eec8c3af0eda8be0703d517f1ab4 | AnotherContinent/thinkful | /FizzBuzz.py | 368 | 4.0625 | 4 | import sys
num_input = raw_input("Please enter a number: ")
try:
num_input = int(num_input)
except ValueError:
print("That is not a valid integer.")
else:
for n in range(1,num_input):
if n % 5 == 0 and n % 3 == 0:
print("FizzBuzz")
elif n % 5 == 0:
print("Buzz")
elif n % 3 == 0:
pr... |
87284010352d2f82d2e755374ec58cf9dc751793 | ellyruthsilberstein/data_structures_and_algorithms | /binary_search.py | 393 | 3.984375 | 4 | def binary_search(collection, target):
first = 0
last = len(collection) - 1
while first < last:
midpoint = (first + last) // 2
if collection[midpoint] == target:
return midpoint
elif collection[midpoint] < target:
first = midpoint + 1
else:
last = midpoint - 1
return None
... |
93772026e779b789ae4ebb1fd4b5b7999c546c6b | hire-blac/MyImpracticalPython | /pig_latin.py | 572 | 4 | 4 | '''a simple 'Pig Latin' program
day15 of 100DaysOfCode'''
def main():
'''main function to recieve input form user and
convert to pig latin'''
vowels = ['a', 'e', 'i', 'o', 'u']
message = input('Enter a word or sentence to be translated to Pig Latin:\n')
translation = ''
for word in message.split():
if len(wo... |
cabfd32db867ec8ecef307baed784d5c56afe565 | TadasRad/Python | /Python Scripting Academy Unit 3/Module 4/sort_numbers.py | 1,177 | 4.5 | 4 |
# [ ] Write a program that reads an unspecified number of integers from the command line,
# then prints out the numbers in an ascending order
# The program should have an optional argument to save the sorted numbers as a file named `sorted_numbers.txt`
# The help message should look like:
'''
usage: sort_numbers.py [... |
e2914f0e3ee25f38101b484bf719b61b56cc3a47 | aerospaceresearch/orbitdeterminator | /orbitdeterminator/util/state_kep.py | 2,188 | 3.625 | 4 | '''
Takes a state vector (x, y, z, vx, vy, vz) where v is the velocity of the satellite
and transforms it into a set of keplerian elements (a, e, i, ω, Ω, v)
'''
import numpy as np
import math
def state_kep(r, v):
'''
Converts state vector to orbital elements.
Args:
r (numpy array): position vec... |
12628120accf8502666276f71d49128e76983a26 | Akashgiri1020/adventure-game | /Adventure game/game.py | 4,532 | 3.96875 | 4 | import time
import random
weapon = random.choice([" Mjölnir hammer","storm breaker"])
items = []
stone=[]
def print_pause(string):
print(string)
time.sleep(2)
def restart_game():
if weapon in items:
items.remove(weapon)
print_pause("GAME OVER\n")
response = input("Wou... |
74cda001f7e8cb6cd942c1da39e983819ed617dc | mridulrb/Basic-Python-Examples-for-Beginners | /Programs/MyPythonXII/Unit1/PyChap03/rowm.py | 622 | 4.25 | 4 | # File name: ...\\MyPythonXII\Unit1\PyChap03\rowm.py
# Initializing the two dimensional array
A = [[20, 40, 10],
[40, 50, 30],
[60, 30, 20],
[40, 20, 30]]
print("The original array is...")
for r in range(0, 4):
print(" "*10, end="")
for c in range(0, 3):
print (A[r][c], en... |
29cd138c3acb8084be4e21716252ee099cbc2729 | alzaia/applied_machine_learning_python | /logistic_regression/logistic_regression_fruits_dataset.py | 1,801 | 3.75 | 4 | # Binary logistic regression with fruits dataset (apple vs others)
import numpy as np
import pandas as pd
import seaborn as sn
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
# prepare fruits dataset using only 2 features
fruits... |
2821053556785839a3add2a8258ca8a01314045d | kundan-git/apache-spark-pyspark-sql | /national_names_analysis/national_names_analysis_2.py | 940 | 3.609375 | 4 | from pyspark.sql import Row
from pyspark import SparkContext
from pyspark.sql import SQLContext
if __name__=="__main__":
# Create Spark Context
sc = SparkContext("local[2]","Application")
sqlContext = SQLContext(sc)
filepath = "C:\\Users\\6910P\\Google Drive\\Dalhousie\\term_1\\data_management_analytics\\assignme... |
f492c19d1cdc04474d9531e265c2bdd048e09668 | seyedsaeidmasoumzadeh/Fuzzy-Q-Learning | /src/fuzzy_inference/fuzzyset.py | 1,484 | 3.5 | 4 | class Trapeziums(object):
def __init__(self, left, left_top, right_top, right):
self.left = left
self.right = right
self.left_top = left_top
self.right_top = right_top
def membership_value(self, input_value):
if (input_value >= self.left_top) and (input_value <= self.rig... |
825f5fe407580e4af4e3b2db23f692673128c4de | RiyazShaikAuxo/datascience_store | /2.numpy/sharingsamememory.py | 459 | 3.546875 | 4 | import numpy as np
a=np.arange(10)
print(a)
b=a
print(b)
#changing the one value in b
b[0]=11
print(b)
#a also changing
print(a)
# to Check whether a,b sharing same momory
samememory=np.shares_memory(a,b)
print(samememory)
# To overcome this we will use copy method
c=np.arange(10)
print(c)
#instead d=c use copy
d=... |
c20978c61078836b5b4ad1aed90a381fdb90ab5e | monster80s/Time-Series-ML | /LSTM.py | 10,279 | 3.546875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 12 11:36:35 2018
@author: estebanlanter
"""
# load and plot dataset
from pandas import DataFrame
from pandas import read_csv
from pandas import datetime
from sklearn.preprocessing import MinMaxScaler
from matplotlib import pyplot
import os
os.chdir... |
dbfde758baf733094acb16d07cd13d8402023b48 | crypticani/Python-MiniProjects | /tictactoe.py | 4,005 | 3.765625 | 4 | def print_field(board):
print('---------')
for n in range(3):
row = '| '
for m in range(3):
row = row + board[m][n] + ' '
print(row + '|')
print('---------')
def evaluate_game(board):
win_x = 0
win_o = 0
play_x = 0
play_o = 0
for n in range(3):
... |
846a357dc1244cfe404871b2234438e81e92fe43 | AuroraBoreas/python_advanced_tricks | /python-dict/py_05_dict.py | 127 | 3.65625 | 4 | mylist1 = "hello world I love python".split(" ")
mylist2 = [1, 2, 3, 4, 5]
mydict = dict(zip(mylist1, mylist2))
print(mydict)
|
6b8f9b0e5a7fa8cd6fd2795a4ddc10c25260ecf9 | joseangel-sc/CodeFights | /Tournaments/sumUpNumbers.py | 101 | 3.53125 | 4 | def sumUpNumbers(s):
s = re.split("\D",s)
s = [int(i) for i in s if i!=""]
return sum(s)
|
b30a6e6fb047a40af92691e398bb6d13493f3b9c | somodis/ClassRoomExamples | /SOE/ProgAlap2/20210317_tkinter/demo.py | 520 | 4.28125 | 4 | from tkinter import *
def button_clicked():
print("click")
Label(frame,text="inserted by click on button").pack(side="bottom")
window = Tk()
window.title('Demo GUI application')
frame = Frame(window, bg="green")
frame.pack(side="top")
button=Button(frame,text="This is an example button",command=button_click... |
bb3b4698a8522170a699792b066a326002e81b89 | gabrypol/algorithms-data-structure-AE | /nth_fibonacci.py | 1,698 | 4.28125 | 4 | '''
The Fibonacci sequence is defined as follows: the first number of the sequence is 0, the second number is 1, and the nth number is the sum of the (n - 1)th and (n - 2)th numbers. Write a function that takes in an integer n and returns the nth Fibonacci number.
Important note: the Fibonacci sequence is often define... |
70024981b57ac62a4ad40c224f42e41cd812371b | kluitel/codehome | /src/map.py | 164 | 3.875 | 4 | #! /usr/bin/python
# map will iterate trough the function
def mult(val):
return val * 2
my_list = [0,1,2,10,100,1000]
iter = map(mult,my_list)
print(list(iter)) |
5f9685fe4c114baf6b4fdccb9ada74499a5d56c6 | chriswebb09/OneHundredProjects | /Text/check_palindrome.py | 416 | 4.125 | 4 | #!/usr/bin/env python*
# -*- coding: UTF-8 -*-
#Python 2.7
def is_palindrome(new_string):
if new_string[::-1] == new_string:
return "{} confirmed as palindrome".format(new_string)
else:
return "{} is not a palindrome".format(new_string)
if __name__ == "__main__":
user_string = raw_input("... |
f38f69826d52dd548c95233c3df773343cc7fd34 | sandeepvempati/lpthw_examples | /ex25p.py | 1,371 | 4.25 | 4 | def break_words(stuff):
print "This function will break the words for us"
words = stuff.split(' ')
return words
#print break_words("break the words")
def sort_words(words):
print "sort the words"
return sorted(words)
#print sort_words("I am good boy")
def print_first_word(words):
print "pri... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.