blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
cd64a6e20458d824b471fa58bc96874f8e8cafe0 | IvanWoo/coding-interview-questions | /puzzles/capacity_to_ship_packages_within_d_days.py | 2,028 | 4.3125 | 4 | # https://leetcode.com/problems/capacity-to-ship-packages-within-d-days/
"""
A conveyor belt has packages that must be shipped from one port to another within days days.
The i-th package on the conveyor belt has a weight of weights[i]. Each day, we load the ship with packages on the conveyor belt (in the order given ... |
d94f9c45aa6ea2140f01f0ceb835947a796a0c86 | yunai39/turbo-happiness | /bin/charriot.py | 1,525 | 3.609375 | 4 | from motor import Motor
"""
Class chariot
Un chariot est composé de deux moteur
Ces deux moteur permettent d'avance, de reculer, de tourné etc...
"""
class Chariot:
def __init__(self, rightMotor: Motor, leftMotor: Motor):
self.rightMotor = rightMotor
self.leftMotor = leftMotor
s... |
0793ae185fa90a80092cc52cbb0fccb8f47ca35d | appratt/python | /ex16.py | 1,965 | 4.53125 | 5 | # Exercise 16
# this is a very simple text editor to practice file manupulation commands
# import the argv module from the sys module
from sys import argv
# unpacks the argv into script and filename
# 'script' indicates the program itself. 'filename' is a string that here takes the name of an existing .txt file or c... |
499cf4a792f58dce8e2669decc6433f1dafdb074 | WwwYiNan/Test100 | /Example/Example10.py | 292 | 3.625 | 4 | vec1 = [2, 4, -6]
vec2 = [1, -3, -7]
print([x*y for x in vec1 for y in vec2])
print([x+y for x in vec1 for y in vec2])
print(x**2 for x in vec1)
print(x*2 for x in vec2)
print([vec1[i]*vec2[i] for i in range(len(vec1))])
dict = {'Name': 'Runoob', 'Age': 7, 'Class': 'First'}
print(str(dict))
|
364139a1c7c0a4a56982e21f53f2d09d41a5356a | sbtries/Class_Polar_Bear | /Code/James/Python/rps_version_2.py | 1,133 | 3.9375 | 4 | '''
___________________________________________________________________________
Project: Full Stack Evening Boot Camp - Python Lab (05 Rock Paper Scissors)
Version: 1.0
Author: James Thornton
Email: James.ed.thornton@gmail.com
Date: 27 SEP 2021
_____________________________________________________________________... |
42a52e0d3c69bbcdf002301575cd1676560d5f41 | tommidavie/Practise-Python | /lists.py | 3,383 | 4 | 4 | import random
# Just for the shuffle
def get_integer(m):
my_integer = int(input(m))
return my_integer
def get_string(m):
my_string = input(m)
return my_string
def print_at_index(L):
my_index = get_integer("Please choose index -> ")
print(L[my_index])
def print_list(L):
for x in L:
... |
24e93e8e55df95a3636cb4cec1f3150e2e2ee5b9 | MAPLE-Robot-Subgoaling/IPT | /data/HW4/hw4_438.py | 437 | 4.21875 | 4 | def main():
height = int(input("Please enter the starting theight of the hailstone: "))
print("Hail is currently at height", height)
while height != 1:
if height%2 != 0:
height = (height*3)+1
print("Hail is currently at height", height)
if height%2 == 0:
heigh... |
ba8c51bacf7b0656198099214566070e8414ce6e | VaibhavBiturwar/Image-processing | /demo.py | 838 | 3.703125 | 4 | import cv2
# returns a 3D array for colored image ->second parameter 1
# 2D array for grayscale image -. second parameter 0
# Numpy_array imread( File_location , 0-1)
# img = cv2.imread("C://Users//lenovo//Desktop//OpenCV//image.png", 1)
# print(img)
# print(type(img))
# TO GET THE SIZE OF THE IMAGE
# print(img.shap... |
511d03e7316a95f2e2af9eac9364df5004c67b0c | lientdang/Cheldarr | /familytree/familytree.py | 1,143 | 4.03125 | 4 | class Familytree:
def __init__(self, first, last, age, gender, birth_month, birth_day, birth_year, mother_first, mother_last, father_first, father_last, is_grandkid):
self.first = first
self.last = last
self.name = 'Name: ' + first + ' ' + last
self.age = age
self.gender = 'G... |
2fe8af8c093e88b7756406121d12da6e1791b836 | Shad87/python-programming | /UNIT-1/list.py | 2,114 | 4.25 | 4 | '''
#declare an empty list
classmates = []
#add items to lsit
classmates.append("Sue")
classmates.append("Shad")
classmates.append("Aaron")
classmates.append("Chinonso")
classmates.append("Eva")
classmates.append("Jeremy")
classmates.append("Dan")
classmates.append("Mayank")
classmates.append("Eva")
classmates.append... |
e74115764dbcd0b592982ca6565fdd1259c80b51 | teyrana/py_opt_talk | /_6_CPython_cffi/profile.py | 1,796 | 3.59375 | 4 | #!/usr/bin/env python3
import time
import random
import _bst.lib as bst
def create_tree():
"""This method creates a fully-populated binary-search-tree of depth 4, on the numbers: [0, 30]"""
#
# ___________________15_____________________
# / ... |
e5a4be87f737a773e6168e7512e24d3cb11e88d0 | SuperSpy20/Python-Projects | /midpoint.py | 611 | 3.96875 | 4 | try:
c_1 = input('What is the coordinate of the first point?\n').split(',')
c_2 = input('What is the coordinate of the second point?\n').split(',')
p = list(map(float, c_1))
q = list(map(float, c_2))
except:
print('\n\nYou must input a correct coordinate!')
exit()
def midpoint(p, q... |
ebed6082f15d1407b1f687d627d5107626c2838a | mishrakeshav/Competitive-Programming | /binarysearch.io/tree_sum.py | 433 | 3.515625 | 4 | # class Tree:
# def __init__(self, val, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def solve(self, root):
# Write your code here
def cal(root):
if root is None:
return 0
else:
... |
bcbf9311070baad1485be2b405c7f31a18ad4077 | joker2009/Python_learn | /0409.py | 624 | 3.625 | 4 | __author__ = 'Joker'
"""请定义一个函数quadratic(a, b, c),接收3个参数,返回一元二次方程:
ax2 + bx + c = 0
的两个解。"""
def quadratic(a, b, c):
if not isinstance(a, (int, float)):
raise TypeError('参数类型错误')
if not isinstance(b, (int, float)):
raise TypeError('参数类型错误')
if not isinstance(c, (int, float)):
rai... |
9b72b95da974d53657351e687c6146a97ef1fea2 | IliasOu/programming1 | /les 4/Input and Output.py | 234 | 3.578125 | 4 | uurloon = input('Hoeveel verdien je per uur: ')
werkuren = input('Hoeveel uur heb je gewerkt: ')
salaris = float(uurloon) * float(werkuren)
overzicht = str(uurloon) + ' uur werken levert ' + str(salaris) + ' Euro op.'
print(overzicht) |
37c2f2dd81357d86813fc06f9baf9a682670b814 | 2018-B-GR1-Python/O-a-Salazar-Christian-David | /01_Python.py | 1,230 | 4 | 4 | #!/usr/bin/env python
print("hola mundo")
edad: int = 20
sueldo = 1.02
print(edad + int(sueldo))
nombre = "Christian"
apellido = "Oña"
apellido_materno = """Salazar"""
print(nombre == apellido)
print(apellido == apellido_materno)
print(apellido_materno)
print(int(True))
print(int(False))
print(str(True))
prin... |
05fd6cb93113604d6762829193a3db49517d5302 | seanmenezes/python_projects | /basic/classes/Account.py | 987 | 3.859375 | 4 | class Account:
def __init__(self,title = None, balance=0):
self.__title = title
self.__balance = balance
def getBalance(self):
return self.__balance
def deposit(self,amount):
self.__balance += amount
def withdrawal(self,amount):
self.__balance -= am... |
c50d9ba3543be51bd6da22321dad6ce830f86eb6 | ahmedsalah52/Self_Driving_Car_Course | /Python/q15.py | 149 | 4.125 | 4 | file_name = input("please enter the file name \n")
file = open(file_name,'r')
for word in file.read().split():
print(word.upper())
file.close() |
7f60151fd1f509949c3e925abe92e9e17c425059 | shobhitmishra/CodingProblems | /LeetCode/Session3/PathSumIII.py | 1,007 | 3.625 | 4 | class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def pathSum(self, root: TreeNode, sum: int) -> int:
if not root:
return 0
return self.pathSumHelper(root, 0, sum) + self.pathSum(root.left, sum)... |
9388143b9dff7b19f45f4b3b7046af13b623067d | forthing/leetcode-share | /python/062 Unique Paths.py | 878 | 4.125 | 4 | '''
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).
The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).
How many possible unique paths are there... |
dfd24c5c0858b9083324bffa69c131a92d186f21 | nikostsio/Project_Euler | /euler57.py | 460 | 3.625 | 4 | # I'm gonna calculate the square root of 2
# Pretty exciting!!
def main():
lst = [(3,2), (7, 5)]
counter = 0
for i in range(1000):
# I noticed a pattern in the first few fractions the problem gave, so I tried them and they seem to work!
denom = lst[-1][1]+lst[-1][0]
numer = lst[-1][1]+denom
if len(str(numer... |
06843b90384807e59230b97371a52e336f59e4bb | AdamMatheus/python-project | /python7/lambda_builtin_map.py | 541 | 3.875 | 4 | # letter1=["o",'s','t','t']
# letter2=['n','i','e','w']
# letter3=['e','x','n','o']
# num=map(lambda x,y,z:x+y+z,letter1,letter2,letter3)
# print(list(num))
# nums1=[9,6,7,4]
# nums2=[3,6,5,8]
# ort=map(lambda x,y:(x+y)/2,nums1,nums2)
# print(list(ort))
# kelime=["ali veli deli","mehmet aganin kuzeni","cemilin-bacisi... |
7a80bc4c61b30903e69c7e3b2f10e78d3362b9d4 | sanketgadiya/PYTHON-ETHANS | /solutions/hotel.py | 937 | 3.890625 | 4 | def print_header():
print "#"*30+"\n MENU \n"+ "#"*30
def print_menu_item(item,price,total_gap=30):
total_char = len(item) + len(str(price)) + 2
h_needed = total_gap - total_char
print item + " " +"-"*h_needed + " " + str(price)
def print_menu(menu_dict=''):
print_header()
for item in menu_dic... |
e7bda1c21c77f70c03b2012f323847af03ea4101 | mveselov/CodeWars | /katas/kyu_6/triple_trouble.py | 329 | 3.75 | 4 | def chunks(string, size):
result = set()
for a in xrange(len(string) - (size - 1)):
current = string[a:a + size]
if len(set(current)) == 1:
result.add(current[0])
return result
def triple_double(num1, num2):
return 1 if chunks(str(num1), 3).intersection(chunks(str(num2), 2)... |
c3ce4f991aa7f4a0ff59188126e4feff753df4e3 | gus07ven/CCIPrac | /Leet303_2.py | 485 | 3.640625 | 4 | from typing import List
class Leet303_2:
def __init__(self, nums: List):
self.sums = [0] * (len(nums) + 1)
for i in range(0, len(nums)):
self.sums[i + 1] = self.sums[i] + nums[i]
def sum_range(self, i: int, j: int) -> int:
return self.sums[j + 1] - self.sums[i]
if __name... |
44bac80f20ccc0a2ca05a25855032040716a9c88 | kriti-ixix/python-ms | /python/basic list.py | 1,581 | 4.03125 | 4 | '''
stdNames = ['abc', 'xyz', 'pqr']
print(stdNames)
# adding a element in list
stdNames.append('fgh')
print(stdNames)
# Acessing a element
print(stdNames[2])
# Searching a element
if 'x' in stdNames:
print('Fount it')
else:
print('Not found')
# CHanging a value
stdNames[1] = 456
print(stdNames)... |
46573216a99963b48326ebf474be6ed4182591ca | ManaliKulkarni30/MachineLearning_CaseStudues | /Iris3.py | 1,422 | 3.53125 | 4 | ###########################################################################
#
#Author:Manali Milind Kulkarni
#Date:28th March 2021
#About: Applying Decision Tree Algorithm on Iris Dataset
#
###########################################################################
#Required imports
from sklearn.datasets impo... |
2edeb82edf25a00fe45fd3f87bc31863e091c3a9 | yuryanliang/Python-Leetcoode | /recursion/24 swap-nodes-in-pairs.py | 1,388 | 4.0625 | 4 | """
Given a linked list, swap every two adjacent nodes and return its head.
You may not modify the values in the list's nodes, only nodes itself may be changed.
Example:
Given 1->2->3->4, you should return the list as 2->1->4->3.
"""
class ListNode:
def __init__(self, x):
self.val = x
self.ne... |
a7c1c2fea1f7f8372d3ab33d8a00961c77d28ae8 | jerrylance/LeetCode | /58.Length of Last Word/58.Length of Last Word.py | 892 | 3.671875 | 4 | # LeetCode Solution
# Zeyu Liu
# 2019.1.30
# 58.Length of Last Word
from typing import List
# method 1 remove 和while 应用
class Solution:
def lengthOfLastWord(self, s: str) -> int:
if s:
last = s.split(" ")
while '' in last:#循环去除空值
last.remove('')
if last == []:
ret... |
89cf5519d27a376dbefd6a46c12c9298b3a8fdea | lavisha752/Python- | /Stock of a pharmacy.py | 1,145 | 4.375 | 4 | # creating a list with items
stock=['paracetamol','bandage','antiseptic wipes','cough syrup','antibiotics']
print("Current Stock")
# User input and to choose the option
option = input("1. Add an item to the stock pharmacy.\n\
2. Remove item from stock.\n\
3. Insert item at a specific location.\n\
Please enter an... |
1de6b4d19f48050128625ac2fdd0b4841c3ad477 | wmackowiak/Zadania | /Zajecia05/zad07.py | 1,030 | 3.78125 | 4 | # 8▹ Napisz program, który będzie sprawdzał, czy nasz samochód kwalifikuje się do zarejestrowania jako zabytek.
# Program zacznie ze stworzonym słownikiem o trzech kluczach:
# marka (str)
# model (str)
# rocznik (int)
# Wypisze ten słownik na ekran (bez żadnego formatowania)
... |
f3dea2bd28958d8b7ff9294b45da1bac22b166fb | Yadynesh-Nandane/YD-dcoder | /Symmetric_Swap.py | 345 | 3.796875 | 4 | """
Author:Yadynesh-Nandane
Program for Symmetric Swap
"""
#Accepting Input
N = int(input())
s = input()
d = s.split(' ')
#Swapping of numbers having symmetric positions
#i.e Swaping 1st position number from top and 1st position number from bottom of the list
for i in range(0,N//2):
d[i],d[N-(i+1)] = d[N-(i+1)],d[... |
d3ff306d26516b4e18348d054b09a305a924b972 | bibotai/LeetCodeExercise | /25_Longest_Substring_Without_Repeating_Characters/25_Longest_Substring_Without_Repeating_Characters.py | 1,230 | 3.859375 | 4 | # coding:utf-8
"""
问题链接:
https://leetcode.com/problems/longest-substring-without-repeating-characters/description/
问题描述:
找出一个字符串中,连续的,且不包含重复字符的,最长的字符串的长度
Given "abcabcbb", the answer is "abc", which the length is 3.
Given "bbbbb", the answer is "b", with the length of 1.
Given "pwwkew", the answer is "wke", with the... |
ce75d6fe7e900b47c78ea504241243928e5be28f | Canyon1997/PythonComputerShopping | /BuyComputer.py | 1,270 | 4 | 4 | available_parts = ["Computer",
"Monitor",
"Keyboard",
"Mouse",
"Mouse Mat",
"HDMI Cable",
"Graphics Card",
"CPU",
"Headset",
"Ram",
... |
51dc73efdfe3d01afaf43a0c1210e11282254f39 | zvarychdenys/MyProject | /sort/bublesort.py | 410 | 3.5625 | 4 | from random import random
data = []
def random_values(arr):
for elem in range(15):
arr.append(int(random()*100))
return arr
print(random_values(data))
def buble_sort(arr):
n = len(arr)
for i in range(n - 1):
for j in range(n - i - 1):
if arr[j] > arr[j + 1]:
... |
1b1047e4e8df945d7a4c3ba4f1382774502b87b0 | bmorale1/Program-Repository | /Python/Morales_I_Assignment#5.py | 1,565 | 4.25 | 4 | #author: Isaac Morales
#filename: Morales_I_assignment#5.py
#purpose: to create a visually appealing pattern using functions
# and user input values
#date: october, 18, 2015
import random
#Set user input function
def inputValidate():
user_number = input("Enter the side size of the ... |
b2918bf4f77c355b2dbb2d1296fb5d29eb25c2b3 | ajjumaxy/trump_tweet_analysis | /python_code/create_word_cloud_and_scatter_plot_by_topic.py | 4,923 | 3.96875 | 4 | import plotly.express as px
import seaborn as sns
import re
import csv
import matplotlib.pyplot as plt
import pandas as pd
from wordcloud import WordCloud, STOPWORDS
from nltk.corpus import stopwords
stop_words = set(stopwords.words('english'))
# a function to create a word cloud of Trump's tweets that contain the top... |
aa93f1d40e4a4b808d3e29ff92b7b35b2b97e1c0 | lizenghui1121/DS_algorithms | /算法思想/回溯/04.生成括号.py | 1,806 | 3.875 | 4 | """
已知N组括号,生成这N组括号的所有合法可能
@Author: Li Zenghui
@Date: 2020-04-06 15:10
"""
# 递归生成所有可能,包括合法不合法
def gen_test(n):
def generate(item, n, result):
if len(item) >= 2 * n:
result.append(item)
return
generate(item + '(', n, result)
generate(item + ')', n, result)
res =... |
eb3de63b345baac3a866da5d3ffaeeb807f71fa9 | rakzroamer/ExerciseCourse | /mod_ex.py | 751 | 4.15625 | 4 | score = input("Enter Score: ")
fscore = float(score)
if not fscore <= 0.0 or fscore >= 1.0:
if fscore >0.0 and fscore <0.6:
print ("F")
elif fscore >=0.6 and fscore <0.7:
print ("D")
elif fscore >=0.7 and fscore <0.8:
print ("C")
elif fscore >=0.8 and fscore <0.9:
print ... |
3c7aa3fc8a84d443c2484e73999c9b84ad9e3fec | theevilaunt/Projects | /wroxprojects/straight_line.py | 225 | 4.21875 | 4 | def straight_line(gradient, x, constant):
''' return y coordinate of straight line -> gradient * x + constant'''
return gradient*x + constant
print(straight_line(2,4,-3))
for x in range(10):
print(x,straight_line(2,x,-3)) |
fd4986f3f247eba7dabcf7d3f5d7d06c5eefa656 | chends888/CodingInterviews | /recursion/sum1.py | 1,286 | 3.625 | 4 | from tree import Tree
def sum_all(A, n):
if (n == -1):
return 0
else:
A[n]+=sum_all(A, n-1)
return A[n]
# A = [1, 2, 2,3,4,5]
# print(sum_all(A, len(A)-1))
def sum_digits(n):
def sum_digits_r(n, sum=0):
# print(n)
if (n > 0):
if (n%10 == 0):
... |
accf1bb4f35cae2d9a78b8aa1ac2996aee358df1 | juliannepeeling/class-work | /Chapter 5/5-5.py | 709 | 3.96875 | 4 | alien_color = 'green'
print(alien_color)
if alien_color == 'green':
print("You just earned 5 points for shooting the alien.")
elif alien_color == 'yellow':
print("You just earned 10 points!")
else:
print("You just earned 15 points!")
alien_color = 'yellow'
print(alien_color)
if alien_color == 'green':
print("You ju... |
89ff0a193e8bbb742a364afb47a261335de9c62f | padmaja125/Python-Assignment_Padmaja | /Task-2(Q-10).py | 653 | 3.921875 | 4 | x = 1
while x :
guess = input('Do you want to enter the game(Y/N) : ')
if guess == 'Y' or guess == 'y':
counter =1
while counter <= 5:
print("Type in the", counter, "number")
global number
number = int(input('Enter the number : '))
counter = counte... |
893ac6ab9d195519f357518de91e9e2aaac66ba5 | slott56/my-euler | /euler38.py | 2,852 | 4.34375 | 4 | #!/usr/bin/env python3
# Pandigital multiples
# =====================
# Problem 38
# Take the number 192 and multiply it by each of 1, 2, and 3:
#
# 192 × 1 = 192
#
# 192 × 2 = 384
#
# 192 × 3 = 576
#
# By concatenating each product we get the 1 to 9 pandigital, 192384576. We will
# call 192384576 the conca... |
acef67bf17194166f94aad2e23b4d3df70349bc1 | adrianmarino/algorithms | /guia/4.3.py | 1,213 | 3.53125 | 4 | #!/bin/python
def max_plateau(numbers):
"""
Order: O(n)
"""
max_num = None
max_count = count = i = 0
while i < len(numbers):
cur_num = numbers[i]
next_num = numbers[i + 1] if i + 1 < len(numbers) else None
count += 1
if next_num != cur_num:
if cou... |
02fb53eec5067a3d774a0e98ff479e4a05449ae5 | Santhoshharsha/python_practice | /bracevalidate.py | 654 | 4.03125 | 4 | #!/usr/local/bin/python
def braceValidate(s):
stk = []
for c in s:
if c == '{':
stk.append(1)
elif c == '(':
stk.append(2)
elif c == '[':
stk.append(3)
elif c == '}':
if stk.pop(-1) != 1:
return False
elif ... |
5afd1ffb669acca6c310d846a8e2fba240bbcc0f | Ayush456/MyJavascript | /Desktop/ayush/python/GlobLocVar.py | 161 | 3.71875 | 4 | total=30
def sum(arg1,arg2):
total=arg1+arg2
print("Inside the function : ",total)
return total
sum(10,12)
print("Outside The function : ",total)
|
4b3c432d7fafe217323bb6021cb9f58c086df442 | rathoresrikant/HacktoberFestContribute | /Algorithms/Array/zeroMover.py | 234 | 3.71875 | 4 | # Replace this with your own array.
arr = [1, 1, 0, 2, 3, 0, 1, 0]
zeroCounter = 0
newArr = []
for num in arr:
if num == 0:
zeroCounter+=1
else:
newArr.append(num)
for i in range(0, zeroCounter):
newArr.append(0)
print(newArr)
|
13809b285fcbc811323d9d0dab27f051bdebe8c0 | dqhcjlu06/python-algorithms | /test_linked.py | 1,100 | 4.125 | 4 | from ch03linked.positional_list import PositionalList
from ch03linked.favorites_list import FavoritesList
# 位置列表执行插入排序
def insertion_sort(L):
if (len(L) > 1):
maker = L.first()
while maker != L.last():
pivot = L.after(maker)
value = pivot.element()
if value > mak... |
13d608787bebef1f66a9dd9c9b313fbf072be824 | gabriellaec/desoft-analise-exercicios | /backup/user_084/ch59_2020_03_17_22_52_16_143390.py | 105 | 3.703125 | 4 | def asteriscos(n):
n=int(input('escolha um numero positivo: ')
y='*'
print (y*n)
return n |
290471713796baec34e9eff9291691dc4f545947 | BillionsRichard/pycharmWorkspace | /DataStructure/queue/ListQueue.py | 1,260 | 3.78125 | 4 | # encoding: utf-8
"""
用数组实现队列:
@version: v1.0
@author: Richard
@license: Apache Licence
@contact: billions.richard@qq.com
@site:
@software: PyCharm
@file: ListQueue.py
@time: 2018/8/26 15:47
"""
class ListQueue(object):
def __init__(self):
self.queue = []
def enqueue(self, data):
... |
2900bfb60ae162e6b410a1bf5be1e35c36be590e | liketheflower/CSCI13200 | /list/basic_list.py | 440 | 3.671875 | 4 | """
basic list operations
Sep 13, 2019
jimmy shen
"""
# sum of 1 to n by using list
def sum_1_to_n(n):
a = []
for i in range(1, n+1):
a.append(i)
print(a)
return sum(a)
n = 100
res = sum_1_to_n(n)
print(res)
a = [1, 2, 3, 4, 5]
b = [10, 13, -1, -1000]
print('a', a)
print(a[0])
print(a[-1])
pr... |
b987255f4ca617b4c00645bd56df00843251ebe7 | heddle317/coding-exercises | /min_max.py | 656 | 3.828125 | 4 | """
go-left Software Rotating Header Image
100 Little Programming Exercises
https://go-left.com/blog/programming/100-little-programming-exercises/
A.6 Min and Max
Write a program which accepts numbers as arguments and which determines the lowest and highest number.
$ min-max 1 10 99 5 19 -23 17
Read 7 numbers
Min va... |
be61ee63a72dc930bf1ec21548f3e9b632e6f784 | woodpeckeh/python | /Programa-4.py | 325 | 3.90625 | 4 | #-- 4. realiza una funcion que permita tener el maximo de 3 numeros --
def mayor(a,b,c):
may = ''
if a > b:
if a > c:
may=a
else:
if b > a:
if b > c:
may=b
else:
may=c
return may,a,b,c
mayo, x , y , z = mayor(4,10,3)
print "de los numeros: " , x , " , " , y , " , " , z , " el mayor es: " ,... |
cbb41c9109e792ae4b461a6cf05fd829173df663 | ramilabd/tasks_python | /hexlet/FizzBuzz.py | 423 | 3.6875 | 4 | def fizz_buzz(begin, end):
if begin > end:
return ''
result = ''
for i in range(begin, end + 1):
if i % 3 == 0 and i % 5 == 0:
result = result + 'FizzBuzz '
elif i % 3 == 0:
result = result + 'Fizz '
elif i % 5 == 0:
result = result + 'Buz... |
43c13e456a00ac8bb20b97b1d7f7c56ce189d2d4 | mananrg/Machine_Learning | /Machine Learning/2.Regression/2.Multiple_Linear_Regression/Multiple_Linear_Regression.py | 927 | 3.640625 | 4 | # Importing the libraries and dataset
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
df=pd.read_csv('50_Startups.csv')
X = df.iloc[:, :-1].values
y = df.iloc[:, -1].values
# Encoding the independent data (State)
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import On... |
c937d2fa924c7275b81db5895b41fceef05a2f32 | MarianoMartinez25/Python | /2 - operadores y expresiones/oplogico.py | 489 | 3.734375 | 4 | # Operador not
# print(not True)
# Operador and
# print(True and False)
# Operador or
# print (True or False)
c = "Phyton"
print(len(c) < 8 and c[0] == "P")
kil = int(input("A cuantos kilometros se encuentra de la escuela?: "))
her = int(input("Cuantos hermanos tiene en la escuela?: "))
ing = int(inpu... |
4bcf8527a0fc45f7dc487c91235f2c7b4cd1dcc1 | yzl232/code_training_leet_code | /Remove Invalid Parentheses.py | 1,805 | 3.984375 | 4 | '''
Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results.
Note: The input string may contain letters other than the parentheses ( and ).
Examples:
"()())()" -> ["()()()", "(())()"]
"(a)())()" -> ["(a)()()", "(a())()"]
")(" -> [""]
'''
'''
Remove t... |
027b72adb804597d6fba9090e452d4bc3be811e1 | Martsyalis/data-preprocessing | /index.py | 2,006 | 3.546875 | 4 | import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Import Dataset
dataset = pd.read_csv('./Data.csv')
x = dataset.iloc[:, :-1].values # grab values in all rows and all but the last columns
y = dataset.iloc[:, -1].values # grab values in all rows for the last column
# print(x)
# print(y)
# print... |
6a1c180a60338b97299a58fcee3839c865a21f9f | anki112279/Calculator | /Calculator.py | 1,011 | 3.625 | 4 | import re
def calculator(exp):
if check_float(exp):
return float(exp)
operators = ['+', '-', '*', '/']
for c in operators:
left, opt, right = exp.partition(c)
if opt == '+':
return calculator(left) + calculator(right)
elif opt == '-':
return calculator(left) - calculator(right)
elif o... |
8111a44e3256e57110cc9d7626717d91e2c49bb1 | Lunaire86/DummyCluster | /src/main.py | 2,046 | 3.828125 | 4 | ##
# Main program
# @author: marispau
from test import Test
def run_tests(test_unit, file_name):
"""
Runs various tests to make sure the program works as intended.
:param test_unit: str
:param file_name: str
"""
program = test_unit
if program == "Abel":
print("\nY... |
762cff88aa556d890ea3f234a508f74785da7bb4 | frclasso/revisao_Python_modulo1 | /cap12-dicionarios/11_get_method.py | 461 | 3.859375 | 4 | #!/usr/bin/env python3
"""obtém o conteúdo de uma chave. Não causa erro caso uma chave não exista, retorna valor;e
Se valor não for especificados nas chaves existentes, retorna None.
Sintaxe:dict.get(key, default=None)
"""
dict = {'Name':'Zara', 'Age':7}
print('Valor do campo: {}'.format(dict.get('Age')))
prin... |
4c4b8eec61bae0df4d61e95e22abb5854b6ebd5b | Lairin-pdj/coding_test_practice_programmers | /디스크 컨트롤러.py | 1,429 | 3.609375 | 4 | import heapq
def solution(jobs):
answer = 0
count = 1
jobs.sort() # 시간 순서대로 정렬
temp = []
for a, b in jobs: # 우선순위큐를 사용하기 위해 뒤집음
temp.append([b, a])
jobs = temp
queue = []
heapq.heapp... |
8a51dcc887d29344b68b8e0f145bb1152f90649b | vinayakentc/BridgeLabz | /AlgorithmProg/MonthlyPayment.py | 1,245 | 4.46875 | 4 | # Write a Util Static Function to calculate monthlyPayment that reads in three
# commandline arguments P, Y, and R and calculates the monthly payments you
# would have to make over Y years to pay off a P principal loan amount at R per cent
# interest compounded monthly.
# ----------------------------------------------... |
26f41c8b251b6dc77be5770614df8bf5791abffd | udoyen/pythonlearning | /1-35/ex24.py | 1,242 | 4.15625 | 4 | print "Let's practice everything."
print 'You\'d need to know \'bout excapes with \\ that do \n newlines and \t tabs.'
poem = """
\tThe lovely world
with logic so firmly planted
cannot deiscern \n the needs of love
nor comprehend passion from intuition
and required an explanation
\n\t\twhere there is none.
"""
print ... |
132099e7fc87f9b26ed6dcf55b4bd482d95be922 | praveendk/programs | /loops/whileLoop3.py | 254 | 4.1875 | 4 | # whileLoop practise
name = ""
while not name :
name = input("Please enter your name: \n")
numOfGuests = int(input("How many guests will you have? \n"))
if numOfGuests :
print("make sure you have enough rooms for accomodation.")
print("done") |
cc6bfa509b2b45f95c2bc014030a639592b7b581 | almoss1/CS-UY-1134 | /CODE/UnsortedArrayMap.py | 1,755 | 3.796875 | 4 | class UnsortedArrayMap:
class Item:
def __init__(self,key,value = None):
self.key = key
self.value = value
def __init__(self):
self.table = []
def __len__(self):
return len(self.table)
def is_empty(self):
return len(self) ==0
#... |
d17edefb098e75c69e5cd5b23d0f6d57949aa816 | damiati-a/CURSO-DE-PYTHON-2 | /ex113.py | 1,028 | 3.9375 | 4 | # reescrever o programa e corrigir os erros do mesmo
def leiaInt(msg):
while True:
try:
n = int(input(msg))
except (ValueError, TypeError):
print('\033[31mPor favor. Digite um número inteiro válido\033[m')
continue
except KeyboardInterrupt:
... |
3aabc3f69f33a9aa7e3dae27f96a0e353dc2196c | Vanya-Rusin/lavbs-5 | /Завдання 3.py | 375 | 3.859375 | 4 | import math
x = float(input("Введіть змінну х : "))
e = float(input("Введіть точність е: "))
S = 0
a = 1
while x ** (2 * a) / math.factorial(2 * a) > e:
S = -1**a * x ** (2 * a) / math.factorial(2 * a)
a += 1
print(S)
if math.cos(x) - S < e:
print("справедлива")
else:
print("несправедлива"... |
54525f49f024477518690f29c92798bbdddaf5c9 | arnoringi/forritun | /Skilaverkefni/fibo_abundant.py | 2,487 | 4.3125 | 4 | # Project 3: Fibo and abundant
type_sequence = input("Input f|a|b (fibonacci, abundant or both): ")
### Fibonacci Sequence
if type_sequence == 'f' or type_sequence == 'b':
length = int(input("Input the length of the sequence: "))
print("Fibonacci Sequence:")
print("-------------------")
# These... |
645f9c469988776ceb1e9a362125884a4efa8955 | zhuangsen/python-learn | /com/advanced/2-13.py | 2,787 | 3.78125 | 4 | # -*- coding: utf-8 -*-
# python中编写带参数decorator
#
# 考察上一节的 @log 装饰器:
#
# def log(f):
# def fn(x):
# print 'call ' + f.__name__ + '()...'
# return f(x)
# return fn
#
# 发现对于被装饰的函数,log打印的语句是不能变的(除了函数名)。
#
# 如果有的函数非常重要,希望打印出'[INFO] call xxx()...',有的函数不太重要,希望打印出'[DEBUG] call xxx()...',这时,log函数本身就需要传入... |
314652af704372aae4e03e637944d8964f592c6c | row-yanbing/code_knowledge | /chars_use.py | 993 | 3.6875 | 4 | # -*- codiyng: UTF-8 -*-
# Filename : chars_use
# author by : yanbing
# 测试实例一
print("测试实例一")
str1 = "runoob.com"
print(str1.isalnum()) # 判断所有字符都是数字或者字母
print(str1.isalpha()) # 判断所有字符都是字母
print(str1.isdigit()) # 判断所有字符都是数字
print(str1.islower()) # 判断所有字符都是小写
print(str1.isupper()) # 判断所有字符都是大写
print(str1.istitle()) # 判断所... |
9824df765c162659a46a44171f5bd7f281a3557b | ZimingGuo/MyNotes01 | /MyNotes_01/Step01/2-BASE02/day02_06/demo02.py | 1,602 | 4.46875 | 4 | # author: Ziming Guo
# time: 2020/2/8
'''
demo02
元组
基础操作
'''
# 1 创建元组(空)
tuple01 = ()
tuple01 = tuple()
# 因为一个元组里面也是一个个变量,所以也可以指向任何数据类型
# 所以元组里面也能放列表,字符串,数字
# 列表可以转换成元组:
tuple01 = tuple(["a", "b"])
print(tuple01)
# 元组也可以转换成列表:
list01 = list(tuple01)
print(list01)
# 这两种形式的相互转换其实是两个存储机制之间的转换
# ... |
83c0bfb753aab01e089ba02a8f65e0877f54ea5b | cochosca/curso_de_python | /Aprendizaje/python/POO/Herencia.py | 2,260 | 3.96875 | 4 | #------------------##
# HERENCIA
#------------------##
# Cuando hay una clase principal o padre que herede sus metosod y atributos a las subclases o clases hijo
class Principal:
def __init__(self,nombre,edad):
self.nombre = nombre
self.edad = edad
# la clase Principal tiene los atributos nombre y ed... |
f8d5dc821074a5478eb348bcf63a9d868bb2933e | BIAOXYZ/variousCodes | /_CodeTopics/LeetCode/401-600/000563/000563.py | 994 | 3.8125 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution(object):
def findTilt(self, root):
"""
:type root: TreeNode
:rtype: int
... |
1ceaa699ce47fd7b3fc58e400d50e750452dff71 | KVasileva/cd101 | /CW3/avage.py | 428 | 3.875 | 4 | def avg(ages):
return sum (ages) / len (ages)
if __name__== "__main__":
print(avg([12, 34, 21, 56]))
import math
def cos2(num):
for i in num:
return math.cos(i)/ 2
if __name__== "__main__":
print(cos2 ([12, 34, 21, 56]))
def sum3(a,b,c):
z = a+b+c
return z
... |
a2f760cfdf21be74ef5adf0bd4bc0ac9afbd0f00 | nylbert/PARSER | /lista.py | 2,106 | 3.6875 | 4 | import sys
class Node:
# Declaracao dos atributos desta Classe
tipo = None
nome = None
escopo = None
nextNode = None
# Fim declaracao
# Nesta secao encontram-se os metodos para acesso
# dos respectivos atributos
def __init__(self,nome, tipo, escopo):
self.tipo = tipo
self.nome ... |
576779722b7612720f91a73aab21fdc97b0bd699 | NZSGIT/Comp-110-Zybook-Labs | /Section 2/2.15.py | 1,050 | 4.125 | 4 | '''
2.15 LAB: Using math functions
Given three floating-point numbers x, y, and z, output x to the power of z, x to the power of (y to the power of z), the absolute value of (x minus y), and the square root of (x to the power of z).
Output each floating-point value with two digits after the decimal point, which can be... |
82c2eb3f20255c5859ad3da8b3e763bc4b59a164 | MaryanneNjeri/pythonModules | /.history/reverseString_20200605151541.py | 80 | 3.734375 | 4 | # looping through the array
def reverse(str):
reverse(["h","e","l","l","o"]) |
07d57ae131b32442893c61a01b92552abcde324e | faizkhan12/Basics-of-Python | /exercise9.6.py | 779 | 4 | 4 | class Restaurant(): #making a class
#defining methods
def __init__(self,name,cuisine):
self.name=name
self.cuisine=cuisine
def describe_restaurant(self):
print(self.name +" is name of the restaurant.")
print(self.name +" is famous for this "+self.cuisine+... |
384024473e97ab302b5d262cf5e9e5c61e48eaf0 | HassanElDesouky/Data-Structures-In-Python | /Dynamic Array.py | 1,401 | 3.875 | 4 | import ctypes
class DynamicArray(object):
# init method
def __init__(self):
self.n = 0
self.capacity = 1
self.original_array = self.make_array(self.capacity)
# Special methods
def __len__(self):
"""
:return: the length of the array.
"""
return ... |
ef944d5382a4c906958062b976f628ed8f141293 | liyi0206/leetcode-python | /92 reverse linked list II.py | 1,187 | 3.890625 | 4 | # Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def reverseBetween(self, head, m, n):
"""
:type head: ListNode
:type m: int
:type n: int
:rtype: ListNode
"""... |
5e270bb2098403d734a4fd918b64fbd055ba4be4 | AlexeyAMorozov/git-lesson | /NewYear.py | 265 | 3.90625 | 4 | from datetime import date
today = date.today()
print('Сегодня', today)
def NewYear():
delta = date(date.today().year + 1, 1, 1) - date.today()
return delta.days
print('До нового года осталось', NewYear(), 'дней')
|
9c7e8f010e82aa5b28d79757f6f0330a93c673dc | weilyu/hackerrank_python | /string/Capitalize.py | 334 | 4.15625 | 4 | # https://www.hackerrank.com/challenges/capitalize
line = input()
last_is_space = True
result = ''
for letter in line:
if last_is_space and letter.islower:
result += letter.upper()
else:
result += letter
if letter == ' ':
last_is_space = True
else:
last_is_space = False
... |
3a039ec788bf5dfd3d2a36199efec4680a44737a | RBaner/Project_Euler | /Python 3.8+/26-50/Problem 046/main.py | 553 | 4 | 4 | from sympy import isprime
from math import sqrt
import time
def main():
num = 3
while True:
if isprime(num):
num += 2
continue
else:
passed = False
for i in range(1,int(sqrt((num-3)/2))+1):
if isprime(num-2*(i**2)):
... |
77563ef42cd8d7c89249d99b2d31139364b7d806 | neuralfilter/hackerrank | /Coding_Bat/front_backer.py | 230 | 3.75 | 4 | def front_back(str):
if(str == ""):
return ""
temp = str[0]
if(len(str) == 1):
return str
store = list(str)
store[0] = str[len(str) - 1]
store[len(str) - 1] = temp
return "".join(store)
|
55c3182e191d1f525205c038196ea1b60d21d344 | qkleinfelter/AdventOfCode2020 | /Solutions/day5.py | 1,038 | 3.765625 | 4 | def day5():
data = open(r'Inputs\day5.in').readlines()
print('Part 1 result: ' + str(part1(data)))
print('Part 2 result: ' + str(part2(data)))
def part1(data):
# calculate the seatids for every seat in the data and return the maximum
return max(calc_seat_id(line) for line in data)
def part2(data):... |
ec116c05469a42e4d2b148c3dbd8063eaee5cb2c | kevinvkasundra/Naval-Mine-Rock-Classifier | /Sonar.py | 3,973 | 3.5 | 4 | import pandas as pd
from sklearn.model_selection import train_test_split
#file import
path = ""
df = pd.read_csv(path + "sonar_hw1.csv")
df.head()
##### Outlier Analysis #####
#Number of data points
n = df.shape[0]
#missing cases
missing = n - pd.DataFrame(df.count(), columns = ['Missing'])
#outliers ... |
19c20e9197198bf6a926d89050b9a6c720ca98e2 | kshirsagarsiddharth/Algorithms_and_Data_Structures | /Linked_Lists/single_linked_list.py | 6,199 | 4.03125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Apr 4 03:51:02 2020
@author: siddharth
"""
class Node:
#constructor
def __init__(self,data):
self.data = None
self.next = None
# method for setting the data field of the node
def set_data(self,data):
self.data ... |
7558d5363e6446ce8184e5689e135f75b5b47968 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2470/60618/312215.py | 780 | 3.65625 | 4 |
T=int(input())
for t in range(0,T):
length=int(input())
matrix=[[0]*length for _ in range(length)]
string=[int(k) for k in input().split()]
res=''
for i in range(0,length):
for j in range(0,length):
matrix[i][j]=string[i*length+j]
res+=' '
res+=str(matrix... |
23a182151b5e7a2cba472f45c7b0692a269ad4c9 | mitchellvitez/py2hs | /examples/example.py | 1,428 | 3.640625 | 4 | def lessThanOne(x):
if x < 1:
return True
return False
def fibonacci(n):
if n <= 1:
return n
return fibonacci(n - 1) + fibonacci(n - 2)
def fibonacci2(n):
if n <= 1:
return n
else:
return fibonacci2(n - 1) + fibonacci2(n - 2)
def allPairs(arrA, arrB):
retur... |
028758603d04d9610caad5ef23cdfe279077a0b4 | softborg/Python_HWZ_Start | /fitness_programm/fit_6.py | 734 | 3.765625 | 4 | # coding=utf8
# Fit 6
def checkio(number: int) -> int:
# Programmier - Aufgabe 6
# Input: Zahl
# Bedingung 1: Multiplizier alle einzlnen Stellen einer Zahl
# Bedingung 2: die 0 soll übersprungen werden
# Output: Zahl Multiplikation aller einzelnen Stellen (Zahlen)
str_number = str(number)
... |
c74427fecf307d22a7d796a24e59a87455cdb388 | Yema94/Python-Projects | /controlstatements/gradecalculator.py | 507 | 4.21875 | 4 | #Grade Calculation
"""Subjects: Maths, Physics, Chemistry
Pass Marks : 35
if Avg <=59 grade C
if Avg <=69 grade B
if Avg >69 grade A """
subjects = input("Enter the names of 3 subjects: ").split()
marks = [float(mark) for mark in input("Enter 3 subjects marks:").split(',')]
if marks[0]>=35 and marks[1]>=35 and marks[2... |
74535ed03e2a6286edf990dcd58ce14ee86f42d9 | Qeswer/info_second | /lab3/lab3.py | 1,742 | 3.734375 | 4 | import re
def first(text): #создаем функцию для первого задания
print("дан текст: ", text)
reg = re.compile('[^а-яА-Я ][^a-zA-Z ]')
text1 = reg.sub('', text)
#text.replace('.')
print(text1)
Broke=text1.split() #разбиваем текст на список слов
k=len(Broke) #длина списка
list_thr... |
1f952eb61529beca813f9e3bfcd3c16f929359b4 | roninski/perl2python | /demos/demo6.py | 962 | 3.671875 | 4 | #!/usr/bin/python2.7
import sys
sys.stdout.write (str("Please enter a number: "))
num = raw_input()
num = str(num)[:-1] if str(num)[-1] == '\n' else num
sys.stdout.write (str("\n"))
count = 0
for i in xrange(int(1), int(num)+1):
sys.stdout.write (str("count + i = "))
count = float(count) + float(i)
sys.stdout.write ... |
00700e20edb6d59eeef27eb25838f077ff19b683 | kwahome/python-escapade | /sort-algorithms/merge_sort.py | 3,714 | 3.921875 | 4 | # -*- coding: utf-8 -*-
#============================================================================================================================================
#
# Author: Kelvin Wahome
# Title: Merge Sort Algorithm
# Project: python-escapade
# Package: sorting-algorithms
#
# Merge sort is a sorting algorithm ba... |
8f67794f6339985c6e883b4dbf29ef3cf2f31d65 | stephen-hansen/Advent-of-Code-19 | /p1/p1-1.py | 240 | 3.6875 | 4 | #!/usr/bin/env python3
import math
with open("p1-input") as f:
inputs = f.read().splitlines()
numbers = [ int(x) for x in inputs ]
total = 0
for number in numbers:
fuel = math.floor(number/3) - 2
total += fuel
print(total)
|
f09e4c276f74aa1b12c44d1a877bd9dc66dc3340 | colombelli/biocomp | /list 4/part 2/submitted/e4-2/implementation1/genetic_means.py | 9,352 | 3.90625 | 4 | """
@Title: Genetic Means
@Author: Felipe Colombelli
@Description: A genetic algorithm using k-means as classification model
for selecting genes out of a dataset with two types of
leukemia: ALL and AML.
* Chromosome encoding:
An 1D array with zeros and ones representing what gene ... |
3d38791badbf61e176e03a97a3004c15c1f6d28f | KrishnaManaswiD/Tortoises | /code/test/old/FridayDemo2.py | 1,368 | 3.875 | 4 | from tortoise import Tortoise
from enums import Direction, SensorType
# In this version, they test the robot first and then fix the values and fill in the else. If format is good, but too much work, then prefill else.
# Change this to 1 when you've calibrated and have some values for not enough light, good light and t... |
fb9b40a38862f6d05595fa6032de47fe84de7e9f | t4d-classes/python_03222021_afternoon | /language_demos/fibonacci.py | 595 | 3.75 | 4 | import itertools
# 0 1 1 2 3 5 8 (num_1) 13 (num_2) 21 (next_num)
def fibonacci():
num_1 = 0
num_2 = 1
yield 0, num_1
while True:
next_num = num_1 + num_2
yield num_2, next_num
num_1 = num_2
num_2 = next_num
fib_gen = fibonacci()
print(fib_gen)
# print(next(fib... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.