blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
f84b1ee9b4b674ea912c1ea342869972b6b63838 | chords-app/chords-app.github.io | /Python/שבוע 1/מעבדה שבוע 1/W1LAB1Q3.py | 73 | 3.5625 | 4 |
#W1LAB1Q3
a = int(input('Enter two digit number '))
print(a%10,a,sep="") |
2f5b8a2988be72d16004e30896cedcabfdeab0d3 | the-polymath/Python-practicals | /Practical 4/prac_4_8.py | 489 | 4.28125 | 4 | # 4.8 Write a Python program to overload + operator.
class add:
def __init__(self, a):
self.a = a
def __add__(self, other):
return self.a + other.a
obj1 = add(int(input("Enter a number : ")))
obj2 = add(int(input("Enter a number : ")))
obj3 = obj1 + obj2
print("Adding numbers using operator o... |
599bf13e85e44ce0b5132c83cea6cf26cb6bf6ca | shubee17/HackerEarth | /Searching/monk_takes_a_walk.py | 1,070 | 4.09375 | 4 | """
Today, Monk went for a walk in a garden. There are many trees in the garden and each tree has an English alphabet on it. While Monk was walking, he noticed that all trees with vowels on it are not in good state. He decided to take care of them. So, he asked you to tell him the count of such trees in the garden.
No... |
31cfeedc6d91a4ef7f064f4e99ad70eed9ebf97b | Zahidsqldba07/competitive-programming-1 | /Codechef/DSA_Learning_Series/FCTRL.py | 674 | 3.78125 | 4 | from math import log
T = int(input())
powers_of_5 = [1]
for testcase in range(T):
N = int(input())
k = int(log(N, 5))
zeros_count = 0
# so, there can be max k^th power of 5 in all the numbers up to N, i.e., in
# the factorial of N
for i in range(1, k + 1):
if len(powers_of_5) > i:
... |
fd3f470851b944845335d1276d2888de5be8d6c8 | hitochan777/kata | /leetcode/python/product-of-array-except-self.py | 581 | 3.578125 | 4 | from typing import List
class Solution:
def productExceptSelf(self, nums: List[int]) -> List[int]:
result = [1] * len(nums)
multiplied = 1
for i in range(len(nums)-1):
multiplied *= nums[i]
result[i+1] *= multiplied
multiplied = 1
for i in range(len(... |
ec8086e41dd7981ccc6cafa0f9a5d0285d0b370d | da-ferreira/uri-online-judge | /uri/2584.py | 308 | 3.703125 | 4 |
from math import tan, radians
casos = int(input())
for i in range(casos):
lado = int(input())
lado /= 2
altura_triangulo = lado / tan(radians(36))
area_triangulo = 1/2 * lado * altura_triangulo
area_pentagono = area_triangulo * 10
print(f'{area_pentagono :.3f}')
|
e9851f630fded478877776e8ff270fb0ad397f02 | inwk6312fall2018/programmingtask2-TawsifAhmad | /task1.py | 793 | 3.90625 | 4 | def crime_list(): # main function
fin = open("Crime.csv","r") # reading data from csv file
my_dic = dict()
my_list = []
my_list2 = []
for line in fin:
line=line.strip()
line2 = line.split(',')
my_list.append(line2[-1])
my_list2.append(line2[-2]) #appending data (only crime name data to li... |
d66df55d20e7ce1fc6094219dadafd4372302cab | Genora51/Bitwise | /blib/classbit.py | 1,920 | 3.65625 | 4 | class Bit(object):
def __init__(self, binst):
self.st = binst
def __getitem__(self, index):
if index >= len(self.st):
return Bit('0')
else:
return Bit(self.st[-1 - index])
def __add__(self, bit):
ast = self.st + bit.st
return Bit(... |
da414cc2f334962fe35018b8c581b70f43ed66f8 | pdhummel/corridor | /Space.py | 920 | 3.59375 | 4 | class Space:
def __init__(self):
self.occupied_by_player = None
self.top_has_wall = False
self.bottom_has_wall = False
self.left_has_wall = False
self.right_has_wall = False
self.x = -1
self.y = -1
def clone(self):
s = Space()
... |
48eded567d82f199b1ca5510c99186c0e96fa476 | chuusan/DSCI_522_GROUP_311 | /src/data_download.py | 1,858 | 4.09375 | 4 | # author: Group 311 - Tao Huang, Xugang(Kirk) Zhong, Hanying Zhang
# date: 2020-01-19
'''This script downloads data file from a url and writes it to local.
This script takes a URL and a local file path as the arguments.
The URL used for this file should be ended with '.csv', here is an example:
"https://archive.ics.... |
f50f64565b816b0223de74b1be33c87d9d82cbbd | ActonLeBrein/data-structures | /LinkedList__Intersection_Union.py | 2,228 | 3.828125 | 4 | class Node:
def __init__(self,data,next=None):
self.val=data
self.next=next
def getData(self):
return self.val
def setData(self,data):
self.val=val
def getNextNode(self):
return self.next
class LinkedList:
def __init__(self,head=None):
... |
a1499442cb6f595070059551854c3cd653fc8245 | altvec/MITx6.00.1x | /week2/paying_the_minimum.py | 811 | 3.828125 | 4 | # Test 1
balance = 4213
annualInterestRate = 0.2
monthlyPaymentRate = 0.04
# Output should be:
# Month: 1
# Minimum monthly payment: 168.52
# Remaining balance: 4111.89
# ...
# Month: 12
# Minimum monthly payment: 129.0
# Remaining balance: 3147.67
# Total paid: 1775.55
# Remaining balance: 3147.67
monthlyInterestRate... |
ca0319691a0ee146317fea935cea65c3e80d5a89 | iMaureen/practice-deeplearning | /Part 1: Predicting House Prices/part1.py | 3,960 | 3.765625 | 4 | #!/usr/bin/env python
# coding: utf-8
'''
Author: Maureen Rojsutivat
Source: https://github.com/josephlee94/intuitive-deep-learning
'''
# In[1]:
import pandas as pd
df = pd.read_csv('/Users/mrojsutivat/Documents/COD Advanced Python/practice-deeplearning-master/Part 1: Predicting House Prices/housepricedata.csv')
pri... |
d2fc00abc1e76994cb92974b4d7cd17a56644fbb | miriam1506/PEP21G02 | /modul4/app2.py | 1,387 | 3.671875 | 4 | multi_dimensional_list = [[1, [2, [3]]], [4, [5, [6]]], [7, [8, [9]]]]
#met1
fin_list=[]
for i in multi_dimensional_list:
list2=i
fin_list.append(list2.pop(0))
for j in list2:
list3=j
fin_list.append(list3.pop(0))
for k in list3:
list4=k
fin_list.append(list4.... |
b51b9f47b8f4d10bfee6015909cfd4726878fec6 | ErenBtrk/Python-Fundamentals | /Python Object-Oriented Programming/6-QuizApplication.py | 2,275 | 3.78125 | 4 | # Question Class
class Question:
def __init__(self,text,choices,answer):
self.text = text
self.choices = choices
self.answer = answer
def checkAnswer(self,answer):
return self.answer == answer
q1 = Question("Which is the best programming language?",["C#","Python","Javascri... |
3ff2bd19b1bfdf023fe9f1f30ac5550309df0e40 | amora2860/learning_python | /strings_and_lists.py | 1,859 | 4.1875 | 4 | # Name:
# Section:
# strings_and_lists.py
# ********** Exercise 2.7 **********
def sum_all(number_list):
# number_list is a list of numbers
total = 0
for num in number_list:
total += num
return total
# Test cases
print("sum_all of [4, 3, 6] is:", sum_all([4, 3, 6]))
print("sum_all of [1, 2,... |
e9c636963bcce1d2d483e63e32ed44dd2cd2ed91 | zaghir/python | /python-opencv/image_contours.py | 2,840 | 3.765625 | 4 |
"""
Created on Thu Dec 10 22:51:52 2020
@author: yzaghir
https://docs.opencv.org/master/d4/d13/tutorial_py_filtering.html
Image Contours
Find and draw contours
En traitement d'image et en vision par ordinateur, on appelle détection de contours les procédés permettant de repérer les points d'une image matricielle ... |
bcd3885085f5b0bbdd866ca7c674b0cc32b740a1 | ArmstrongSubero/Python-Programs | /Python and Arduino/06_Graph.py | 481 | 3.546875 | 4 | import numpy as np
import matplotlib.pyplot as plt
x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]
z = [2, 0, -2, -4, -6]
plt.plot(x, y, 'bo') # blue dots
plt.plot(x, y, 'r-', label = "y = 2x") # red line
plt.plot(x, z, 'g--', label = "y = -x + 4") # green dotted line
plt.plot(x, z, 'g^') # green triangles
plt.ax... |
e21d3b27ad5666c1791165c5e44bedadb39915b5 | ioahKwon/PythonforEngineering | /2015312904_Week 12.py | 2,554 | 3.671875 | 4 | '''
Date : 2019. 11. 24.
Subject : Processing Data 2
Student ID : 2015312904
Name : 권준우 (Kwon Joon Woo)
'''
# assignment_01
a=(input("Enter the first set in CSV format: "))
b=(input("Enter the second set in CSV format: "))
a=set(a.split(","))
b=set(b.split(","))
print('First set:', a)
print('Secon... |
e592f6ceb4a664cc48311bf0891fc16be4b85528 | DeshawnN/python-progs | /word_counter.py | 1,123 | 4.125 | 4 | #This Program can count the number of words in a string or a .txt file.
word_count = 0
def main():
global word_count
word_count = 0
print 'Please enter a String or filename'
print 'If the file isn\'t in the same directory as the program, be sure to enter the full path! (e.g. C:/xxxx.txt, or E:/xxxxxxx/xxxx.txt'
... |
d0cfb30b0fec64cd0eb6467004b9dc1093378e83 | demosdemon/rando | /rando/__init__.py | 1,591 | 4.03125 | 4 | #!/usr/bin/env python
import random
class Rando(object):
def __init__(self, weights, rng=random.random):
"""Initialize the Rando class.
:param weights: A sequence of (Item, Weight) tuples. Items of equal weight are
selected in ascending order.
:type weights: Sequence[Tuple[An... |
b211e2ed368bd51aaa0ea2f42cf159b42bbe07a2 | roxanavasile/Python | /lesson12/problem1.py | 297 | 3.515625 | 4 | import random
list1=[]
for count in range(10):
numbers=random.randint(1,4)
list1.append(numbers)
print(list1)
print('\n')
list2=[]
list2=[]+list1
print(list2)
print('\n')
list3=[]
for item in list1:
list3.append(item)
print(list3)
print('\n')
list4=[]
list4=list1[:]
print(list4)
|
e5b9ea6522a7a7479d861bc73f23510a4363b128 | ParthShinde2004/PythonChallenges | /AS259_BinomialTheormCal.py | 352 | 3.78125 | 4 | import math
print("(a+bX)^c")
a = int(input('a ='))
b = int(input('b ='))
c = int(input('c ='))
x = 2
expansion = str(a**c) + ' + ' + str(b*c) + 'x'
while x < (c+1):
nCr = (math.factorial(c)) / ((math.factorial(x)) * (math.factorial(c-x)))
expansion = expansion + ' + ' + str((c**x) * int(nCr)) + 'x^' + str(x)... |
574a72fdd754a2ef96da9c12594d23c0f217a26f | Esk3tit/cs362-extra-credit | /test_two_sum_pytest.py | 445 | 3.578125 | 4 | import two_sum
# Just make test functions directly with simple assert statements
def test1():
assert two_sum.two_sum([2, 7, 11, 15], 9) == [2, 7]
assert two_sum.two_sum([3, 3], 6) == [3, 3]
# Invalid input tests (but this time we check such that the invalid inputs actually meet conditions)
# and therefore p... |
dfe395808ebaf13842bb377f9bf191c42a103a26 | Laura-Puckett/INF502 | /assignment3.py | 10,276 | 4.0625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
## part 1
def inputValues():
walletList = []
for i in range(5):
value = float(input('Enter the amount of money: '))
walletList.append(value)
return walletList
def printSummary(walletList):
maxValue = max(walletList)
mi... |
ab4e10ca1bb7076a0b8c869d75a3588eba21c517 | vmakksimov/PythonFundamentals | /ListAdvanced/6. Group of 10's.py | 448 | 3.5 | 4 | list_of_numbers = [int(el) for el in input().split(', ')]
max_number = max(list_of_numbers)
group = 10
while len(list_of_numbers) > 0:
nums_group = []
for num in list_of_numbers:
if num in range(group - 10, group + 1):
nums_group.append(num)
for number in nums_group:
if number i... |
baf779e891335af4d699675d66020e1ae05d1c44 | bransfieldjack/Practical_Python | /test_boggle.py | 4,944 | 3.8125 | 4 | import unittest #Imports unittest framework
import boggle #imports from boggle.py
from string import ascii_uppercase #Imports the ascii characters a-z
class TestBoggle(unittest.TestCase): #Creates the TestBoggle class, test suite for Boggle.
"""
Our test suite for boggle solver
"""
def test_can_creat... |
8b6c8b1d8844af376ca34e3b487510faa56a1dfd | Segmev/AdventOfCode2020 | /day3/main.py | 896 | 3.5 | 4 |
class Map:
def __init__(self, path) -> None:
self.content = []
self.rowsCount = 0
f = open(path, 'r')
for l in f:
self.rowsCount += 1
self.content.append(l[:-1])
def rowsCount(self):
return self.rowsCount
def rowsLen(self):
retur... |
d037a38487a9196066d09ccc8448f9480014c55a | mohamedmohsen20/python | /sec4-DataTypesVariables/HomeWork/easyChallange/Specialconcatenation.py | 310 | 4.15625 | 4 | '''
Write a program that read 3 strings.
-For simplicity let’s say input is 3 letters A, B and C
The output is A’B”C repeated 10 times
-A’B”CA’B”CA’B”CA’B”CA’B”CA’B”CA’B”CA’B”CA’B”CA’B”C
'''
a,b,c=input("Enter 3 strings: ").split()
s=a+"'"+b+"\""+c
print(s*10) |
0c180ecf1a0d156c2d5822598bc6d091bf7c78f8 | sunilhector/Design-2 | /implementQueueUsingStack.py | 1,104 | 4.1875 | 4 |
class MyQueue(object):
def __init__(self):
self.queueinstack=[]
self.queueoutstack=[]
"""
Initialize your data structure here.
"""
def push(self, x):
while(self.queueinstack):
top =self.queueinstack.pop()
self.queueoutstack.append(top)... |
78f23a3fc24f2167cf657f4457ffc8c95b337623 | Plasmoxy/MaturitaInformatika2019 | /python/gui/nahodne_stvorce.py | 449 | 3.515625 | 4 | from tkinter import *
from random import randint
WIDTH = 500
HEIGHT = 500
root = Tk()
c = Canvas(root, width=WIDTH, height=HEIGHT)
for i in range(1, 11):
a = randint(30, 100)
x = randint(0, WIDTH-a) # neklipuj mimo obrazovky
y = randint(0, HEIGHT-a) # neklipuj mimo obrazovky
c.create_rectangle(x, y,... |
45f53b173fa2871e7f4594d897ee367ec67ad5b3 | jirayasama89/Universidade | /Métodos numéricos/Trabalho 1/questao9.py | 558 | 3.53125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Sep 20 12:45:52 2016
@author: Caio Cid Santiago
"""
def f(x):
return ((x)**3)- 7*((x)**2)+ 8*(x) - 0.35
def deriv(f,x,delta):
return (f(x + delta*x) - f(x)) / delta*x
def ModifiedSecant(f,x,delta,tol):
i = 1
xns = x - (f(x)/deriv(f,x,delta))
... |
6efbb7e046632b3ec3193e0455b373188c623d2f | swigder/pos_tagger | /pos_tagger/hidden_markov_model.py | 5,357 | 3.765625 | 4 | from utilities.utilities import binary_search
class HiddenMarkovModel:
"""
Implementation of a Hidden Markov Model given counts of hidden states and observations as seen in training data
"""
START = "<START>"
def __init__(self, hidden_bigram_frequencies, observation_frequencies, state_counts, ob... |
6c908f73930344a8a3fd56578beb89a427b75a0f | bishajitchakraborty/Python_Basic | /String.py | 224 | 4 | 4 | print("Enter your input:")
string=str(input())
print(string)
print(string[0])
print(string[3])
print(string[:4])
print(string[1:4])
print(string)
print(string[-3:])
print(string[-4:-1])
print(string[::-1])#reverse order
|
4cba62d7ab54a80e6c1ada200107eddda0460eba | dfeusse/codeWarsPython | /08_august/26_palindromeChecker.py | 928 | 3.953125 | 4 | '''
According to wiki palindrome is a word, phrase, number, or other sequence of characters which
reads the same backward or forward. Allowances may be made for adjustments to capital letters,
punctuation, and word dividers.
Famous examples include "A man, a plan, a canal, Panama!", "Amor, Roma", "race car"
and "No... |
7464c2f4354d1c83e602e7c77bb16e2b259a5623 | XinZhaoFu/leetcode_moyu | /771宝石与石头.py | 827 | 3.921875 | 4 | """
给定字符串J 代表石头中宝石的类型,和字符串 S代表你拥有的石头。 S 中每个字符代表了一种你拥有的石头的类型,你想知道你拥有的石头中有多少是宝石。
J 中的字母不重复,J 和 S中的所有字符都是字母。字母区分大小写,因此"a"和"A"是不同类型的石头。
示例 1:
输入: J = "aA", S = "aAAbbbb"
输出: 3
"""
class Solution(object):
def numJewelsInStones(self, jewels, stones):
"""
:type jewels: str
:type stones: str
... |
72fabb55566007b51f47d8efb4f2360b98803e1a | GalyaBorislavova/SoftUni_Python_Fundamentals_January_2021 | /5_List Advanced/Exercises and More Exercises/07. Decipher This.py | 554 | 3.75 | 4 | words = input().split(" ")
decipher = ""
for word in range(len(words)):
current = words[word]
new_word = []
nums_in_word = ""
for letters in range(len(words[word])):
if current[letters].isnumeric():
nums_in_word += current[letters]
else:
new_word.append(current[l... |
bacf84bd3a1bd104ca13a8a3c41b0bb9dd295dcb | cIvanrc/problems | /ruby_and_python/8_math/random_serie.py | 237 | 4.03125 | 4 | # write a python program to generate a series of unique random numbers
import random
n = int(input("Say a number: "))
choices = list(range(n))
a = random.shuffle(choices)
print(choices.pop())
while choices:
print(choices.pop())
|
7460da6a85c46b93c0381d547ac9d8772a6b0591 | Egor-05/Yandex2 | /3/2dop.py | 3,413 | 3.5625 | 4 | from itertools import product
class Bell:
def __init__(self, *args, **kwargs):
self.args_positional = []
for arg in args:
self.args_positional.append(arg)
self.args_named = {arg: kwargs[arg] for arg in sorted(kwargs)}
def print_info(self):
result = ''
for i... |
ff84cc66b24e7d0a60d97339dc43a8d6754220c8 | twok020101/Password_Manager | /Main.py | 7,278 | 3.734375 | 4 | import finder
import adder
import updater
import deleter
import displayer
import getpass
import sys
import key_manager
import os
from easygui import passwordbox
def password_validator(password):
_PASSWORDMAIN = "Password" #change root password
if password == _PASSWORDMAIN:
return "Acces... |
54222ed90f522b4538ef709c4d7ade0a1d2af8bb | ShashankPatil20/Crash_Course_Python | /Week_2/Conditions_Quiz.py | 2,025 | 4.21875 | 4 | """Question 2
Complete the script by filling in the missing parts. The function receives a name,
then returns a greeting based on whether or not that name is "Taylor".
"""
def greeting(name):
if name == "Taylor":
return "Welcome back Taylor!"
else:
return "Hello there, " + name
print(greeting("Taylor"))
p... |
ef97d9c62ca29aa6f9da671b1e825ac0682459c6 | allensallinger/compsci | /reverse_string.py | 497 | 4.25 | 4 | # reverse_string.py
# given a string return the string with the words reversed
def main():
print("main")
a = 1
s0 = "The cat ate the mouse"
print("Input::: " + s0)
ts0 = "ehT tac eta eht esuom"
assert( ts0 == reverse_string(s0))
def reverse_string(s):
alpha = "abcdefghijklmnopqrstuvwxyz";
reversed_... |
728ee7df6d99cf76a87eaf551836a02cf786705e | andjelao/Zbirka1 | /str3_zad1.py | 241 | 3.625 | 4 | # stampa da li je uneseni broj djeljiv sa 3
n = int(input("Unesite zeljeni broj: "))
def djeljiv_sa_3(n):
if n % 3 == 0:
print("Broj je djeljiv sa 3. ")
else:
print("Broj nije djeljiv sa 3. ")
djeljiv_sa_3(n) |
3a55a9f7fb3b5d0778081db8ebebc704af24d9f1 | daniel-reich/ubiquitous-fiesta | /HpJCBwggQMDLWTHsM_10.py | 142 | 3.6875 | 4 |
def average_word_length(txt):
lengths = [len(word.rstrip(',.!?')) for word in txt.split()]
return round(sum(lengths) / len(lengths), 2)
|
f3a1737de20e6ab7ecbb95120fbcca9a0cf24d9b | PrateekKumarSingh/Data-Structures-and-Algorithms | /data structures/linked list/doubly-linked-lists.py | 2,778 | 4.0625 | 4 | class Node(object):
def __init__(self, data, next = None, prev = None):
self.data = data
self.next = next
self.prev = prev
def getNode(self):
return "{} -> {}".format(self.data, self.next)
class DoublyLinkedList(object):
def __init__(self):
self.head = None
def... |
6710867e20705f0b7eef83713f6bbd7c2692847a | LDZ-RGZN/b1804 | /1804/二/day7/私有.py | 800 | 3.90625 | 4 | class People:
def __init__(self,name,salary):
self.__name = name #私有化属性,只能自己访问
self.salary = salary
def get_name(self):
return self.__name
def set_name(self,n): #?set 更改
self.__name = n
return self.__name
def get_salary(self): #获得
return self.sala... |
394416fde3f67b032794986ee3cfb40fa9afd653 | RizkyKhapidsyah/PackingNilaiKeDalamList__PY | /Program.py | 120 | 3.609375 | 4 | a = 10
b = 20
c = 30
d = [None] * 3
d[0] = a
d[1] = b
d[2] = c
print(f'a = {a}, b = {b}, c = {c}')
print(f'd = {d}')
|
77e4538179d2bbf2c0d1b422f0407fb1496bad74 | jre233kei/procon-atcoder | /ABC120/D.py | 952 | 3.5 | 4 | n, m = map(int, input().split())
cons = []
for i in range(m):
a, b = map(int, input().split())
cons.append([a, b])
cons.append([b, a])
cons = cons[::-1]
def is_connected(a, b, closed):
if [a, b] in cons:
return 1
if [b, a] in cons:
return 1
open = []
for c in cons:
... |
e689e3248f425e4373bdb9d82dd6780ab0b3d491 | AlbertoMorillo/TecnicaDeProgramacion | /MateriaHome.py | 2,268 | 3.5625 | 4 | from conexionMateria import MateriaDAO
import funcionesMateria
def MateriaHome():
continuar = True
while(continuar):
opcionCorrecta = False
while(not opcionCorrecta):
print("##### Menu principal ####")
print("1 ##### Listar materias ####")
print("2 ##### Regi... |
62dd6dfe195c916f54a33d8e266a4b6464a80750 | MarcusPlieninger/codility | /ch1_BinaryGap.py | 559 | 3.515625 | 4 | def solution(N):
# set up variables to store
max_gap = 0
current_gap = 0
# skip trailing zeros until hit 1
while N > 0 and N%2 == 0:
N //=2
# gap tracker: count, compare
while N > 0:
if N%2 == 0:
current_gap +=1
elif current_gap > max_gap:
m... |
097c073e349213c8d3eeba8ca33e670365f98933 | dianatibre/University | /Year1Sem1/FundamentalsOfProgramming/Battleship/board2.py | 694 | 3.65625 | 4 | from texttable import Texttable
class Board:
def __init__(self):
self._data = [0] * 36
def set_square(self, row, col, value):
self._data[row * 6 + col] = value
def draw(self):
board = Texttable()
for i in range(7):
row = []
for j in range(7):
... |
a20d67a2c316a9ac7c0da4a542bc69cc9d7b0c39 | Kcheung42/Leet_Code | /Design/0535_encode_and_decode_tiny_url.py | 2,188 | 3.71875 | 4 | # **************************************************************************** #
# #
# ::: :::::::: #
# 535_Encode_and Decode_TinyURL.py :+: :+: :+: ... |
af1721853d3df24ee2ce2a970db547ce81903ad4 | bmadren/MadrenMATH361B | /IntroToProgramming/PartialProd_Madren.py | 783 | 3.53125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Feb 4 22:08:34 2019
@author: benma
"""
#%%
import numpy as np
N = 50
x = np.zeros([N])
term = 1
for nn in range(2, N):
term *= (nn**3 - 1)/(nn**3 + 1)
x[nn] = term
print("The first 15 terms are ", x[:15], " and the last 15 terms are ", x[-15:])
#%%
import nump... |
f5d7fb51d6c48345c2a72dc41b287160cad3db75 | xpessoles/Informatique | /Exercices/01_python_bases/PYB-523/PYB-523-cor.py | 1,904 | 3.859375 | 4 | def reste_a_payer(p,t,m,d):
"""p = montant du pret en euros
t = taux mensuel
m = mensualites
d = duree en annees
Calcule le montant restant a payer a l'echeance du pret"""
dette = p
for mois in range(d*12):
# Inv : dette est dû au début du mois
dette = dette*(1+... |
f3b7ac3a60eebfe13172f554c1a653d11dd188bd | yushu-liu/30daysofCode | /binaryday10.py | 339 | 3.640625 | 4 | def day10(num):
empty = []
arr = []
while num > 0:
c = chr(ord('0') + int(num & 1))
num >>= 1
arr.append(c)
print arr
count = 0
while (count < len(arr)):
if arr[count] == 1 and arr[count + 1] != 0:
empty.append(arr[count])
count = count + 1
... |
735dfccba77ea551f191d4fd0ecdfe9ff80ce23a | Raindeca/Python-Trial-Error | /LinierProgramming/calculation.py | 1,401 | 3.578125 | 4 | from pulp import *
from problem import Problem
class Calculation:
def __init__(self, tujuan, kendala):
self.tujuan = tujuan
self.kendala = kendala
def calculation(self):
# Mengerjakan Formulasi LP dengan 2 variabel
prob = LpProblem("Maximize Case", LpM... |
4351d27fb5eed7b4818b5797570be9dc79647425 | lseguin42/Mower | /main.py | 1,059 | 3.625 | 4 | #!/usr/bin/env python
from Map import Map
from Mower import Mower
### MAIN ###
from sys import stdin, exit
mapSize = stdin.readline().strip().split(' ');
if len(mapSize) != 2:
raise Exception('map size definition error');
map = Map(int(mapSize[0]), int(mapSize[1]));
mowers = [];
line = stdin.readline();
while... |
7c2c62dc832c62ae5294072ba32f72b2979a4ad2 | topmillerm2/bootcamp_projects_and_assignments | /Python_stack/python_fundamentals_oop/animal.py | 1,081 | 3.921875 | 4 | class Animal(object):
def __init__(self, name):
self.name = name
self.health= 100
def walk(self):
self.health-=1
return self
def run(self):
self.health -= 5
return self
def display_health(self):
print "Health:{}".format(self.health)
return ... |
1e6db308a52e917738c897b7457e9ce535834852 | DanilKlukanov/Dynamic-programming-languages | /Functions/PAROL'.py | 816 | 4.125 | 4 | stroke = input()
######OK
if len(stroke) < 6:
print('Недопустимый пароль')
######
elif stroke.isalpha() == True and stroke.islower() == True or stroke.isupper() == True and stroke.isalpha() == True :
print('Ненадежный пароль')
elif stroke.isdigit() == True:
print('Ненадежный пароль')
elif stroke... |
417b90b7425f551e480d6123d29eb14f19f55cb0 | LucasMoretti8/PythonExercicios | /ex071.py | 359 | 3.8125 | 4 | valor = int(input('Insira o valor a ser sacado: R$'))
a = 0
b = 0
c = 0
d = 0
while valor >= 50:
valor -= 50
a += 1
while valor >= 20:
valor -= 20
b += 1
while valor >= 10:
valor -= 10
c += 1
while valor > 0:
valor -= 1
d += 1
print('Notas de R$50: {}\nNotas de R$20: {}\nNotas de R$10: {... |
0bd4327595c00ded7c2c73e63a779b1fd10b01f9 | kruart/coding_challenges | /hackerRank/data_structures/SparseArrays/sparse-arrays.py | 733 | 3.578125 | 4 | # https://www.hackerrank.com/challenges/sparse-arrays/problem
def matchingStrings(strings, queries):
d = {q: 0 for q in queries} # dict
for s in strings:
if s in queries:
d[s] += 1
return [d[q] for q in queries]
if __name__ == '__main__':
arr1 = matchingStrings(["aba", "baba", "ab... |
ac3ba5e826ca064b397651cfb6be0a3ec48b7887 | mikeodf/Python_Graphics_Animation | /ch7_prog1_mybridge_stick_man_walking_1.py | 12,134 | 4 | 4 | """
Program name:muybridge stick_man_walking_1.py
Objective: Demontrate animation code for stick man trajectories to produce motion animation.
Keywords: canvas, stick man, walking, animation
============================================================================79
Comments: Use the time trajectories of joint pos... |
bce0a007afb0200203d528b9471ceb9a764c447b | jovenan/Exercicios-python | /Menu_opcoes.py | 682 | 3.875 | 4 | from time import sleep
print('Calculadora com menu.')
num1 = int(input('Digite um numero: '))
num2 = int(input('Digite um numero: '))
op = ""
while op is not 4:
op = int(input('Digite uma das opções:\n[ 1 ] somar\n[ 2 ] multiplicar\n[ 3 ] maior\n[ 4 ] sair do programa\n'))
if op == 1:
result = num1 + nu... |
913f5f1d69c83a48096ed2c72049f420db8587ec | klbinns/project-euler-solutions | /Solutions/Problem15.py | 526 | 3.640625 | 4 | '''
Problem 15:
Starting in the top left corner of a 2×2 grid,
and only being able to move to the right and down,
there are exactly 6 routes to the bottom right corner.
How many such routes are there through a 20×20 grid?
'''
# cache previously traversed paths
cache = {}
def num_of_routes(x, y):
if x == 0 or y ==... |
4978c87aaabe781c04091934688f14707137dd15 | antoniopaolillo/antoniopaolillo.github.io | /trybe-exercises/block36/36.4/script_request.py | 1,358 | 3.515625 | 4 | import requests
# # Requisição do tipo GET
# response = requests.get("https://www.betrybe.com/")
# print(response.status_code) # código de status
# print(response.headers["Content-Type"]) # conteúdo no formato html
# # Conteúdo recebido da requisição
# print(response.text)
# # Bytes recebidos como resposta
# prin... |
fbb15dcfc07e556ab3d024e9226a130494452de5 | mnoiseless/tasks | /Fib.py | 369 | 3.828125 | 4 |
def fib1(n): # через цикл
fib1 = [0, 1]
for i in range(2,n+1):
fib1.append(fib1[i-1]+fib1[i-2])
return fib1[n]
n = int(input('Введите n '))
print(fib1(n))
def fib2(n): # рекурсивно
if n < 2:
return n
else:
return fib2(n-1)+fib2(n-2)
n = int(input('Введите n '))
... |
10ab9c250d7703399a1d2721d745c06b26f96c1c | JADSON-ANDRE/Python | /Exercícios/conversorSeg.py | 329 | 3.59375 | 4 | segundos = input("Entre com o valor em segundos: ")
s = int(segundos)
dia = s // 86400
restoSegundos = s % 86400
horas = restoSegundos // 3600
restoSegundos = s % 3600
minutos = restoSegundos // 60
restoFinal = restoSegundos % 60
print("", dia, "dias,", horas, "horas,", minutos, "minutos e", restoFinal, "se... |
da2c95cb95a2b6ccbaf0cbc4c9c178fea0570e22 | Gor02/Python-HW | /Python HW 3/Python HW3.py | 4,066 | 3.984375 | 4 | # Problem 1
# Construct a Dictionary cities_AM that corresponds to largest 5 Armenian cities their population, say, for Yerevan,
# the population is 1077.6 (in thousands).
# cities_AM = {"Yerevan": 1077.6,
# "Vagharshapat": 46.4,
# "Kapan": 42.5,
# "Vanadzor": 79.3,
... |
8e525c2fe50607fbc5ca7cc70c26b5b9cfd0a2bc | AnPanian/Python | /turtle-practice.py | 398 | 3.546875 | 4 | import turtle
shelly = turtle.Turtle()
shelly.shape('turtle')
for i in range (4):
shelly.forward(100)
shelly.left(90)
print (i)
shelly.begin_fill()
shelly.color('red')
for i in range (4):
shelly.forward(100)
shelly.left(90)
print (i)
shelly.end_fill()
shelly.reset()
for i in range (50):
for n in range (4):
... |
f6234b9f57277ffd4c8689697c408c9796232bbe | asthakur1805/Arithmetic-Formatter | /arithmetic_arranger.py | 3,271 | 3.640625 | 4 | def arithmetic_arranger(problems,*args):
# Error handling for more than five problems
if len(problems) > 5:
return 'Error: Too many problems.'
operand1_list = list()
operator_list = list()
operand2_list = list()
max_width_list = list()
if len(args) == 1:
result_list =... |
ec4ce996cee759b2571a710fe31727a1da50dcf0 | hcxie20/Algorithm | /086_Partition_list.py | 795 | 3.84375 | 4 | # Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def partition(self, head: ListNode, x: int) -> ListNode:
if not head:
return head
dumb_small = ListNode(None)
dumb_big = ListNod... |
2920bd5590bb10477b677cbbbdccc3e7eeb9b32f | DylanTrull/cs362HW4 | /Average List/AverageTest.py | 402 | 3.5625 | 4 | import unittest
import Average
list = [1,2,3,4,5,6,7,8,9,10, 11] ## should average of 6
class TestAverage(unittest.TestCase):
def test_average(self):
self.assertEqual(Average.Average(list), 5)
def test_listNotEmpty(self):
self.assertIsNotNone(Average.Average(list))
def test_listNotEqual(self):
self.asse... |
252a572acf745ebbafa716cf844742eb345a8a31 | hasbycs/Loker-App | /loker.py | 1,025 | 3.890625 | 4 | def testing(loker):
floor = 1
nine = True
three = False
seven = False
two = False
array = []
if loker.isdigit():
for i in range(1,int(loker)+1):
array.append(i)
if int(loker) == i:
return 'loker ' + str(loker) + ' terdapat di lantai ' + str(floor)... |
4319ad0e8904113b3b8f5e22af225e91484738fa | alexnad/Programing-101-week0 | /solutions/matrix_bombing_plan.py | 1,046 | 3.578125 | 4 | def valid_index(matrix, index, bomb_place):
valid_row_index = index[0] >= 0 and index[0] < len(matrix)
valid_column_index = index[1] >= 0 and index[1] < len(matrix[0])
return valid_column_index and valid_row_index and index != bomb_place
def detonate(element, amount):
if element <= amount:
... |
dda8b2524c9c90f9099ce36093abf343bc355260 | Geeky-har/Python-Files | /dunder_meth.py | 2,049 | 4.3125 | 4 | # -------------------------dunder methods and operator overloading------------------------
# class Employee:
# def __init__(self, name, salary, designation):
# self.name = name
# self.salary = salary
# self.designation = designation
#
# def __repr__(self): # this executes when the ... |
33adc5cb23d07492ee2e2663b33e79d131ecc247 | Raushan-Raj2552/URI-solution | /1035.py | 194 | 3.640625 | 4 | a,b,c,d=(input().split())
A=int(a)
B=int(b)
C=int(c)
D=int(d)
if D>A and B>C and C+D>A+B and C>0 and D>0 and A%2==0:
print('Valores aceitos')
else:
print('Valores nao aceitos')
|
836bd4dc3c87a270cbe044ab44f2c61c28ce98bf | ricardoquijas290582/PythonCourse | /tarea/longest_word.py | 143 | 3.921875 | 4 | words = [
"jjdjddjjdjd",
"jdjd",
"kdsjsf"
]
print(words)
longest = max(words, key=len)
print("La palabra mas larga es:",longest)
|
7bbc29b4920ac8b27091fbb8b0f30413a6e76413 | andreanndrade10/python-algorithms | /python_exercises/array_pair_sum.py | 486 | 4.0625 | 4 | '''
Given an integer array, output all the unique pairs that sum up to a specific value 'k'
Example: pair_sum([1,3,2,2],4)
would return 2 pairs: (1,3) and (2,2)
'''
def pair_sum(vector, k):
sum = 0
for i in vector:
temp_vector = vector
a = temp_vector.pop(i)
for j in temp_vector:
... |
c903b58d0189c90590ca198e3e88a28f35a5f20f | fouad89/algorithms_python | /08-number_line_jumps.py | 967 | 4.09375 | 4 | # ----------------------------------------------------------------
# You are choreographing a circus show with various animals. For one act, you are given two kangaroos on a number line ready to jump in the positive direction (i.e, toward positive infinity).
# The first kangaroo starts at location x1 and moves at a ra... |
073fcb36ea9d6731e1b3ea48e982900c781069a6 | Tiberius24/Python_Training | /3Nplus1 Lab.py | 1,197 | 3.65625 | 4 | import turtle
def moveTurtle(k, m):
k.lt(90)
k.fd(m)
k.rt(90)
k.fd(5)
x = k.xcor()
y = k.ycor()+2
if m > 100:
k.pu()
k.goto(x,y)
k.write(m, align="center", font=("Arial", 10))
y = k.ycor() - 2
k.goto(x,y)
k.pd()
k.fd(5)
... |
1dfc0d20c7252ef8c683fce6a1ced0faa6aa138e | xioperez01/holbertonschool-higher_level_programming | /0x0B-python-input_output/4-append_write.py | 299 | 4.25 | 4 | #!/usr/bin/python3
"""
Module 4-append_write.py
"""
def append_write(filename="", text=""):
""" Appends a string at the end of a text file and
Returns the number of characters added
"""
with open(filename, mode="a") as f:
chars_added = f.write(text)
return chars_added
|
3b3d25ef55d1664a3edddb74898d648e04c248fc | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/steve-long/lesson01-enviro/activities-exercises/task-2-puzzles/list1.py | 6,538 | 4.09375 | 4 | # Python210 | Fall 2020
# ----------------------------------------------------------------------------------------
# Lesson01
# Task 2: Puzzles (http://codingbat.com/python) (list1.py)
# Steve Long 2020-09-15
# python /Users/steve/Documents/Project/python/uw_class/python210/lessons/lesson01-enviro/list1.py
# first_l... |
17aea703f0b7dbe59cbe0041a50ce39541afb30d | bregneM/PR | /22.10.2.py | 252 | 4.0625 | 4 | #Программа вычисляет произведение 2 целых чисел.
#числа-целые. запрещается использовать *
b=int(input())
a=int(input())
i=0
k=0
while(i<b):
k+=a
i+=1
print(k)
|
8a7ccfcf83e99150151fa6f92aeb43acda1d7b9f | Geeky-har/Python-Files | /Practice_Set/palindromifyList.py | 700 | 3.859375 | 4 | def isPal(a):
return str(a) == str(a)[::-1]
if __name__ == "__main__":
size = int(input("Enter the size of the initial list: "))
lst = []
print(f"Enter {size} elements in the list:")
for i in range(size):
item = int(input())
lst.append(item)
print("The next Palindromes of the... |
41d83739d4eb898d1a27ea8d93101b19fbbab1b5 | Diogogrosario/FEUP-FPRO | /RE08/manipulator.py | 672 | 3.859375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 22 09:05:09 2018
@author: diogo
"""
def manipulator(l,cmds):
final = ""
for i in cmds:
com = i.split()
if com[0] == "insert":
l.insert(int(com[1]),int(com[2]))
elif com[0] == "print":
final +=... |
46d20cef9f9b3ca372a145527e05f12fe7b4af59 | sandeepkumar8713/pythonapps | /04_tree/19_top_view_of_binary_tree.py | 2,054 | 4.40625 | 4 | # https://www.geeksforgeeks.org/print-nodes-top-view-binary-tree/
# Question : Top view of a binary tree is the set of nodes visible when the tree is viewed from the top.
# Given a binary tree, print the top view of it. The output nodes can be printed in any order.
#
# 1
# / \
# 2 3
# \
... |
10e843699a8ff74f24d5c1f73f1670b6fc150dbb | margaritagirl/LinearRegression | /linear regression.py | 2,510 | 4.3125 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Simple linear Regression
# A simple linear regression asuumes a linear relationship between an input variable X and an output variable Y
# The value of Y is depended on the value of X, Hence
# Y is the dependent variable
# X is the independent variable
# Mathematically 'linear... |
d8d8c2c570137c84d2678d13d0eeab5a43ae922d | saifazmi/learn | /languages/python/sentdex/intermediate/4_listCompAndGenExp.py | 840 | 4.5 | 4 | # List comprehension and generator expressions
'''
' One of the most common generator is range()
' This doesn't generate a list of the given size but rather creates a
' stream of that size without commiting it to memory. But this makes it
' slower compared to list comprehension
'''
'''
' List comprehension on the oth... |
ab0a9bc482e0034a83e008318732b818c757aa0b | smreferee/Lame-Game | /Lab2_Richard_Nolan.py | 823 | 4.34375 | 4 | ################################################
#This is Lab 2 for COSC 1336 by Richard Nolan #
#The program will display program information, #
#ask and display the user name, display a menu,#
#and finally confirm the menu choice. #
################################################
#Introduction to... |
ded8382743996a354640e96e2ac71c7eef878e09 | XHaotaX/homework | /psevdoPython.py | 7,422 | 3.5 | 4 | from collections import deque
##27.02.2020 09:55 как же сдесь мало кометраиев
## нужно больше крови
class Player:
card=[]
state=0
bet=0
wallet=1500##кошелек
id
def main():
gg=[[2, 12], [1, 5], [3, 12], [4, 12], [1, 12], [2, 8], [1, 2], [4, 5], [2, 9], [2, 7], [2, 4]]
arou... |
63a729ac31967f983d8ba9c7d99bea830d64caf3 | simofleanta/Coding_Mini_Projects | /mini coding projects/sample_countries.py | 1,580 | 3.984375 | 4 | import pandas as pd
import pandas as DataFrame
import seaborn as sns
import matplotlib.pyplot as plt
"""Analyze and visualize population in coauntries. Data is a fake sample data from google
data on a certain country and population slicing
data on a certain country and population slicing
extract population column and... |
d48def05b15c78ba9d1a687f0f50daf274b96510 | nuxeo-cps/products--CPSBlog | /skins/cpsblog/getBlogEntryDaySeparators.py | 909 | 3.546875 | 4 | ##parameters=items
# $Id$
"""Returns day_separators list containing ids of blog entry proxies which marks
first objects in group of objects posted in the same year-month-day.
Lets say we have items sorted on creation date in reverse order and containing:
[test5, test4, test3, test2, test1]
test5, test4 are posted on J... |
3f9a979525fce9b4679ea64e6f06e1404736375e | Soloman-IT/Project | /ships.py | 630 | 3.578125 | 4 | list_ship = []
class Ship():
def __init__(self, length,name):
self.length = length
self.name = name
sh_1_1 = Ship(1,"sh_1_1")
list_ship.append(sh_1_1)
sh_1_2 = Ship(1,"sh_1_2")
list_ship.append(sh_1_2)
sh_1_3 = Ship(1,"sh_1_3")
list_ship.append(sh_1_3)
sh_1_4 = Ship(1,"sh_1_4")
list_ship.append(sh_... |
f08c0e824cd2c2d109bc58ec9b22ba692a386275 | keeganosler/Random-Number-Generator-Library | /Python/linear_congruence.py | 369 | 3.75 | 4 | # this program generates random numbers using the linear congruence method
def linear_congruence(seed, mod, mult, inc, num):
random_nums = []
random_nums.append(seed)
for i in range(0,num):
print(i)
q = (mult*seed) + inc
seed = q % mod
random_nums.append(seed)
return ran... |
5836e7a7364c05cb904ceb076134479f1927965d | robertdave/code | /integral_riemann.py | 554 | 3.625 | 4 | # Soma de Rieman
import math
from calcula_polinomios import leitura_px,fx
#import calcula_polinomios as pol
def soma_rieman():
print('Polinomios - Soma de Rieman')
grau = int(input('Grau do px: '))
px = leitura_px(grau)
print(px)
a = float(input('a='))
b = float(input('b='))
... |
33a51f75a03ca6c6ab217f0bcd6de7340c09347d | Eroica-cpp/LeetCode | /018-4Sum/solution01.py | 3,418 | 3.625 | 4 | #!/usr/bin/python
# ==============================================================================
# Author: Tao Li (taoli@ucsd.edu)
# Date: Jun 19, 2015
# Question: 018-4Sum
# Link: https://leetcode.com/problems/4sum/
# ==============================================================================
# Given an... |
b05bed5540d0eb2cd6a32b8dd46c111a2a0815f6 | maq-622674/python | /最近项目要做的功能/判断两个列表的内容是否相等.py | 567 | 3.953125 | 4 | '''
列表长度相等的时候
'''
data=['a','b','c']
data1=['a','b','c']
if(data==data1):
print("data和data1两个列表内容相等")
data2=['a','b','c']
data3=['a','b','d']
if(data2==data3):
print("data2和data3两个列表内容相等")
else:
for i,j in zip(data,data1):
print("data2的数据:",i)
print("data3的数据:",j)
# data... |
d61c04814a92920e4f851ddba30dc35898827b14 | zaoyuaner/Learning-materials | /python1812/python_1/7_字符串_编解码/代码/09_替换replace.py | 615 | 4.25 | 4 | # 替换
# .replace(old,new,maxCount) 使用new替换old,可以指定替换次数
str1 = "this is a test test test"
print(str1.replace("test","school")) # 不带次数则替换所有
print(str1.replace("test","exam",2))
# .maketrans() translate 翻译. 可以使用映射表进行简单加密
# str.maketrans() # 创建一个翻译表,字符映射表
table = str.maketrans("hlo","abc") # hlo翻译成了ASCII码,对应123
... |
1422716fbf03c44ef6ff84a50b12827f6eb3d66d | bineeshpc/problemsolving | /unixtools/sort.py | 745 | 3.578125 | 4 | #! /usr/bin/env python
import sys
import six
import argparse
def parse_cmdline():
parser = argparse.ArgumentParser(
description='Unix like sort tool, does not use disk space')
parser.add_argument('--filename',
type=str,
help='name of the file',
... |
2d9aa5c0cd1042985f68bcb1b78403d1b74aa67f | tsu-nera/AOJ | /Volume100/10011.py | 146 | 3.671875 | 4 | n = int(input())
array = list(input().split())
array.reverse()
for i in range(n - 1):
print(array[i] + " ", end = "")
print (array[n - 1])
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.