blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
b09a2d95a8b8ffe0d3989d527cf572f37cf8b531 | to-yuki/pythonLab-v3 | /ans/2/VariableSample.py | 192 | 3.609375 | 4 | greetings = ['Hello.', 'Hi!', 'Good-bye.', 'Ciao!']
print(greetings)
countryName = {
'001': 'Japan',
'002': 'United States of America',
'003': 'Italy',
}
print(countryName['001']) |
7eca02ae0bd62b82085d35368a661b327d0063df | to-yuki/pythonLab-v3 | /sample/4/Other_Function.py | 379 | 3.625 | 4 | # デフォルト引数
def funcDefArg(x=0,y=0):
print(x)
print(y)
funcDefArg()
# 任意引数
def funcMultiArg(*n):
print(n)
print(n[2])
funcMultiArg(10,20,30,40)
def funcKeyArg(id='null',name='null'):
print(id)
print(name)
# キーワード引数を使用した呼び出し
funcKeyArg(name='Yamada',id='001')
# ラムダ式
f = lambda x: x + 1
ans = f(5)
print(ans)
|
adc03defaa2493bdf9c1e47722a936d366ad2fa3 | olivia-salaben/astro98sp19 | /homework/mt0a/mt0a.py | 16,311 | 4.25 | 4 | """ASTRONOMY 98/198 SPRING 2019"""
"""MIDTERM PART 1: REVIEW"""
"""
Hey everyone, Alex here. This week's "homework" (midterm part 1) is going to be a review.
It's come to my attention that the lectures have not been fully in line with the homework,
so this week I'm going to try to write something that is hopefully a l... |
bb4cdc42eae716396d0f48e9f917a61c52a36313 | tayashigenori/algorithmic_puzzle | /011_A_Stack_of_Fake_Coins.py | 1,555 | 3.859375 | 4 | # -*- coding: utf-8 -*-
import sys
import random
from Coin import Coin, Coins
class Coin(Coin):
# fake coin is heavier than authentic ones
FAKE_COIN_WEIGHT = 11
AUTHENTIC_COIN_WEIGHT = 10
class FakeCoins:
def __init__(self, n = 10):
self._n = n
self._coinss = []
self._fake_i ... |
48bdb01067259fcb9a2c4fc76725c1abd321303e | tayashigenori/algorithmic_puzzle | /147_Hats_with_Numbers.py | 2,416 | 3.796875 | 4 | # -*- coding: utf-8 -*-
import random
import sys
class Hat:
def __init__(self, num):
self._num = num
return
def get(self,):
return self._num
class Hats:
def __init__(self, length): # length: 人数
self._length = length
# initialize hats
self._hats = {}
... |
966ded0fc93b1add143d0c9b63b087c5cf2da96f | HermanTeng19/pythonbootcamp | /d0_recurringInvestment_house/recurringHouseInvest.py | 26,268 | 3.96875 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Recurring Housing Investment Procedure
from d0_recurringInvestmentArt import logo
print(logo)
# ## Part 1 - Mortgage and Refinance Calculators
# ### 1. House appreciation calculator
# This function is aiming to calculate house price raising by user giving initial house pr... |
7f50c3ae74d94b3e8f276cbbab056d64265a8957 | invegat/lambdata | /lambdata_crawftv/ClassificationVisualization.py | 1,545 | 3.59375 | 4 | import sklearn
from sklearn import metrics
from sklearn.metrics import classification_report
from sklearn.metrics import confusion_matrix
from sklearn.utils.multiclass import unique_labels
import seaborn as sns
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
"""IMPORTANT must upgrade Seaborn to u... |
75002e26b132a696e99a7aa0f718267236564c4c | fiqhyb/Trajectory-Assignment | /traject.py | 924 | 3.671875 | 4 | import matplotlib.pyplot as plt
import random
if __name__ == '__main__':
#Coordinates and Equations
numx = list(range(0,26))#range is 26 for display purpose
numy = [((x**2)-(3*x)+4) for x in numx]
ranx = list(random.randint(0,25) for p in range(4000))
rany = list(random.randint(0,600) for ... |
9f9cfd78df80b82290c63d75700b5f0b34b65e6e | tongyijia/python_leetcode_and_Sword-means-offer | /LC104_Maximum_Depth_of_Binary_Tree.py | 553 | 3.703125 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def maxDepth(self, root: TreeNode) -> int:
if root == None: return 0
if not root.left and not root.right: return 1
... |
e4e4b8b75f654a4a10234085eecdf1df1dd0aeb7 | tongyijia/python_leetcode_and_Sword-means-offer | /LC35_Search_Insert_Position.py | 512 | 3.78125 | 4 | class Solution:
def searchInsert(self, nums: List[int], target: int) -> int:
if len(nums) == 0: return 0
if target in nums:
return nums.index(target)
elif nums[0] > target:
nums.insert(0,target)
return 0
else:
for i in range(1,len(num... |
fddca6017f8af463473d9874016ccd79775d101a | tongyijia/python_leetcode_and_Sword-means-offer | /LC146_LRU_Cache.py | 703 | 3.671875 | 4 | from collections import OrderedDict
class LRUCache:
def __init__(self, capacity: int):
self.capacity = capacity
self.table = OrderedDict()
def get(self, key: int) -> int:
if key not in self.table:
return -1
self.table.move_to_end(key)
return self.table[key]... |
d55d8052ff9f7e48094587fd0924bc0bc036d0ca | tongyijia/python_leetcode_and_Sword-means-offer | /LC322_Coin_Change.py | 653 | 3.71875 | 4 | class node:
def __init__(self, value, step = 0):
self.value = value
self.step = step
class Solution:
# BFS
def coinChange(self, coins: List[int], amount: int) -> int:
if amount == 0: return 0
queue = [node(amount)]
visited = set()
while queue:
t ... |
46172ddbe1d946c7ffe2cc54d74d554302a37eae | ellepsis/pythonLabs | /lab2/string1.py | 2,709 | 3.734375 | 4 | # 1.
# Входящие параметры: int <count> ,
# Результат: string в форме
# "Number of: <count>", где <count> число из вход.парам.
# Если число равно 10 или более, напечатать "many"
# вместо <count>
# Пример: (5) -> "Number of: 5"
# (23) -> 'Number of: many'
def num_of_items(count):
return "Number of: " + ("many" ... |
ce9a91de954a8d2aad2aeafb48db59bce3e2150f | fainle/code | /python/data_structure/chapter1/index2.py | 1,028 | 3.734375 | 4 | # -*- coding: utf-8 -*-
# 各种列表的操作时间负责度。
# 索引与分配 O(1)
# append O(1)
# + 这种链接符号 O(k)
from timeit import Timer
def test1():
l = []
for i in range(10000000000):
l = l + [i]
return l
def test2():
l = []
for i in range(1000):
l += [i]
def test3():
l = []
for i in ra... |
95a29801463084c4374fa418b437e2b79719c702 | Aparna9876/cptask | /task9.py | 201 | 4.28125 | 4 | odd = 0
even = 0
for i in (5,6,8,9,2,3,7,1):
if i % 2 == 0:
even = even+1
else:
odd = odd+1
print("Number of even numbers: ",even)
print("Number of odd numbers: ",odd)
|
1d857616cd7dc22cbc06f7866d1f818cecc36127 | BlessCoffee/Python_Exercises | /Python Exercises/bob.py | 330 | 3.84375 | 4 | s = 'boboboboboboboobbbbobobobbdfdfdfsdbob'
bobs = 0
for num in range(len(s)):
if(num+1 > len(s)):
break
if(num+2 > len(s)):
break
if(s[num] == 'b'):
if(s[num+1] == 'o'):
if(s[num+2] == 'b'):
bobs+=1
print("Number of times bob occurs is : " + st... |
104c7307417369749d7a0c449add2f5cc153150e | TzabarDolev/HackerRank_solutions | /python/Basic Data Types/Nested Lists.py | 1,736 | 3.8125 | 4 | def order_list(unordered_list, unordered_names):
ordered = True
for i in range(0, len(unordered_list)-1, 1):
if unordered_list[i] > unordered_list[i+1]:
temp = unordered_list[i]
unordered_list[i] = unordered_list[i+1]
unordered_list[i+1] = temp
temp = unor... |
c8344b7c6645167f8d30c539a41c4368e02dc68a | mohar14/Python | /Posterization.py | 5,819 | 3.90625 | 4 | # Python program to make horizontal, vertical collages and posterize pictures based on a order
# Author: Mohar Dey
class smartPicture(Picture):
# defining the constructor variable for smart picture class
def __init__(self, file, noOfDuplicates=1,noOfRows=1):
Picture.__init__(self, file)
self.noOfDuplicate... |
3b0716580705352aa1aae1b510744a2d16f599f8 | erchiragkhurana/Automation1 | /Python_Practice/Handling/ExceptionHandling.py | 881 | 3.875 | 4 | #in one number, give character string value instead of number integer to generate exception
try:
user_input1= input("Please enter your number")
user_input2= input("Please enter your 2nd number")
c = int(user_input1) + int(user_input2)
print(c)
except:
print("Your input is incorrect, please enter ... |
661875f584581198453a3ba706a8dd24f2c71430 | erchiragkhurana/Automation1 | /Python_Practice/Loops/WhileLoop.py | 362 | 4.15625 | 4 | #Initialization, condition then increment
#while loop with increment, while loop is also called indefinte loop
number = input("Write your number")
i=1
while(i<=10):
print(int(number)*i)
i = i + 1
#while loop with decrement
number = input ("your num")
i=10
while(i>=1):
print(int(number)*i)
i=i-2
#another... |
f44179332da32aef455122138638c81943e63d61 | erchiragkhurana/Automation1 | /Excel/Read_Excel_xlrd.py | 721 | 3.828125 | 4 | import xlrd
# 1.We need to create object of workbook
wb = xlrd.open_workbook("E://XLRD_File.xlsx")
#Found number of sheets
print(wb.nsheets)
# 2.Now we need to move to the sheet level
ws = wb.sheet_by_index(0) #0 means first sheet here and 1 means 2nd sheet in the workbook
print(ws.nrows)
print(ws.ncols)
#one more... |
61d72a38fbeda9f07c9e3847e50dd85737c94f53 | erchiragkhurana/Automation1 | /Python_Practice/Handling/Condition_Handling.py | 1,511 | 4.46875 | 4 | # take a number from user to check condition handling using if and else
x = input("Hey User type your number")
if(int(x)==100):
print("Number is Greater")
else:
print("Number is smaller")
if(int(x)>100):
print("Number is Greater")
else:
print("Number is smaller")
#check multiple condition handling ... |
4aba95f8d59bec6b7be786522f62bcc98b8ca04f | tranhd95/euler | /1.py | 367 | 4.28125 | 4 | """
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.
The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
"""
multiplies_of_three = set(range(0, 1000, 3))
multiplies_of_five = set(range(0, 1000, 5))
multiplies = multiplies_of_three.un... |
2f7d4560d265d77ea047b76283d030dc462aa6f2 | azhuravlev1/STAD68-Advanced-Machine-Learning-and-Data-Mining- | /Assignment 7/code_task.py | 989 | 3.75 | 4 | import numpy as np
import matplotlib.pyplot as plt
import math
def weighted_majority(d, T, n=100):
"""
d -- number of experts
T -- number of rounds
"""
nu = math.sqrt(2*math.log(T)/d)
w = np.ones(d)
for t in range(1,T+1):
v = []
for i in range (1, d+1):
cost_i = np.random.binomial(n, 1-(i/(2*d)), d)/n
... |
dcdad36a4f52a954fee37f93056f1f6384b995f5 | snirsh/intro2cs | /ex12/GUI examples/8-events.py | 207 | 3.78125 | 4 | import tkinter as tk
def print_hi(event):
print('hi')
root = tk.Tk()
canvas = tk.Canvas(root, width = 200, height=200, bg='white')
canvas.pack()
canvas.bind("<Button-1>", print_hi)
root.mainloop()
|
208df7f911980922a68ba4115d5f5ef49fc1b75d | snirsh/intro2cs | /ex11/checker.py | 384 | 4.0625 | 4 | def plot_func(x0, x1, num_of_segments):
"""
plot f between x0 and x1 using num_of_segments straight lines.
use the plot_line function in the graph object.
f will be plotted to the screen with color c.
"""
list_of_x = [x for x in range(x0, x1, num_of_segments)]
list_of_y = [x**2 for x in list... |
e4a0c67027e213cf03f165c2ccd6b1ccc6c05ba6 | snirsh/intro2cs | /ex2/largest_and_smallest.py | 1,261 | 4.4375 | 4 | ######################################################################
# FILE : largest_and_smallest.py #
# WRITER : Snir Sharristh , snirsh , 305500001 #
# EXERCISE : intro2cs ex2 2015-2016 #
# DESCRIPTION: The code below calcul... |
619919d67e2e05efb3793275a27d4895ebdeb994 | FaustoUc/python | /Ejercicio 9.py | 259 | 3.859375 | 4 | import math
a = float(input("ingrese un cateto\n"))
b = float(input("ingrese el otro cateto\n"))
def hipotenusa (x, y):
Hp = math.sqrt(( x*x + y*y))
print("La hipotenusa de triangulo rectangulo es :")
print(Hp)
hipotenusa(a, b)
input()
|
8ce3c610d9995795f185fb26fe2ca9e0eecd3627 | KiraUnderwood/ParallelProgPython | /Theory/21_thread_pool.py | 846 | 3.609375 | 4 | #!/usr/bin/env python3
""" Chopping vegetables with a ThreadPool """
import threading
from concurrent.futures import ThreadPoolExecutor
'''
interface for azync running tasks ratehr than working with individual threads directly
submit callable obj to threadpoolexec and it assigns them to existing threads to run asynchr... |
7dadff2c732ec4ef99e6a6cd207136af9783f7ff | fanLiUB/sortingAlg | /sorting.py | 2,682 | 3.734375 | 4 | import math
import random
# sorting by comparisons
# can't achieve better than O*log(O)
# insertion sort:
def insertion_sort(l):
l1 = l
for i in range(1, len(l1)):
j = i-1
while l1[i] < l1[j] and j >= 0:
current = l1[i]
l1[i] = l1[j]
l1[j] = current
... |
14fbb7d1c54c664ed55fe2df2f15caa3ed8d9781 | pranjalghimire/mathematical-computing | /hw9.py | 9,663 | 4.8125 | 5 | # hw9.py
# Chris Monico, 3/15/21
# A simple example to demonstrate basic usage of tkinter.
# To complete the assignment, you only need to
# modify the draw() method; you don't need to make any
# other changes anywhere else in the code.
import tkinter as tk
# Define a class for our application,
# which inherits from ... |
158b40f4f6d5e310558026e793774c0fdb2bef26 | BobPoChunHuang/Data-Structures-and-Algorithms-in-Python | /src/Sorting/QuickSort.py | 331 | 3.84375 | 4 | def qsort(alist):
print(alist)
if len(alist) <=1:
return alist
else:
pivot = alist[0]
return qsort([x for x in alist[1:] if x < pivot]) + \
[pivot] + \
qsort([x for x in alist[1:] if x>= pivot])
alist = [8,7,6,5,4,3,2,1]
print(qsort(a... |
372b0f9f851f79f8e67d4e8a26c6bd4f61abe192 | hacetin/BugLocalizationDNN | /MetadataFeatures.py | 2,649 | 3.578125 | 4 | from datetime import datetime
'''
Function to return a list of previously filed bug reports that share a file with the current bug report
@params given file name in a Bug Report, the BR's date, and the dictionary of all BRs
'''
def getPreviousReportByFilename(filename, brdate, dictionary):
return [br for br in dic... |
55fe1b5b72bd10c263dfbdf853d197163caf0e90 | danschae/Python-Tutorial | /lists_tuples/appending.py | 944 | 3.9375 | 4 | current_choice = "-"
computer_parts = []
available_parts = ["computer",
"monitor",
"keyboard",
"mouse",
"mousepad",
"HDMI cable"]
valid_choices = [str(i) for i in range(1, len(available_parts) + 1)]
print(valid_choices)
while ... |
4078dfbb0fa06a2375d323e747edf7bd4aae9d4a | danschae/Python-Tutorial | /introduction/basics.py | 757 | 4.1875 | 4 | """
This section is more just about very basic programming, i'm not putting too much effort into it. This type of information is universal to most programming languages.
"""
print("hello world") # simple console log
print (5 * 7)
print("hello" + " world") # can concatante strings just like in javascript
# greetings... |
b3299f6e5d300404892111647477ef82d30dfb1b | Rohit102497/Command_Line_Utility | /web_crawler/links_from_html.py | 1,657 | 4.15625 | 4 | '''
This script prompts a user to pass website url and the html code in string format
and output all the links present in the html in a set.
'''
import re
HREF_REGEX = r"""
href # Matches href command
\s* # Matches 0 or more white spaces
=
\s* # Matches 0 or more w... |
d0ee6dd7583582dd88b37ab9b5385f7fead045f8 | mitabunov/Py_step | /HotDog_2206/hotdogkiosk.py | 937 | 3.8125 | 4 | from typing import Union
from hotdog import HotDogger
from hotdog import HotDog
from client import Client
class HotDogFacade:
"""
Фасад собакофабрики
"""
def __init__(self):
self.cook = HotDogger()
def cook_hotdog(self, hotdog: str) -> HotDog:
"""
Возвращает готовый хот ... |
7585b7e33611d6f42b786b51c30351bdd3175b46 | mitabunov/Py_step | /Tabunov_homework_l20_1304.py | 6,305 | 4.21875 | 4 | """
Описать класс «домашняя библиотека». Предусмотреть возможность
поиска книги по какому-либо признаку, например, по автору или по
году издания (признаки придумать самому), добавление книг в библиотеку,
удаления книг из нее, сортировки книг по разным полям (придумать самому
по каким).
Подсказка: задачу просто ... |
4b44a37b5d556ce1f5d4e00969f0554858064091 | juann2563/curso_python | /main.py | 1,316 | 4.125 | 4 | # tipos de datos y condiciones anidadas
""" x =float(input("Ingrese dato: "))
#print(x)
y= float(input("Ingrese dato: "))
print(10%2)
a = True
b = False
print(a) """
""" a = 5
if a<4:
print("hola")
print("mundo")
elif a<5:
print("es menor que 5")
else:
print("No es menor") """
# condiciones multiples
""... |
491fefbcbebbbe83f59f94b792b123bd2d0a5e0a | Madhu13d/GITDemo | /PythonBasics1/List.py | 1,217 | 4.5 | 4 | values = [1, 2, "Sai", 4, 5]
print(values[0]) # prints 1
print(values[3]) # prints 4
print(values[-1]) # -1 refers to the last element in the list, prints 5
print(values[1:3])#[1:3] is used to get substring.it will fetch 2 values leaving the 3rd index, prints 2, Sai
values.insert(3, "Ramana") # will insert Ramana at 3r... |
5256fdcc22dd21779edc500dbc15215319e06924 | HansrajMathakar/Practice | /NodeDelete.py | 471 | 3.765625 | 4 | class Solution:
def deleteNode(self, node):
"""
:type node: ListNode
:rtype: void Do not return anything, modify node in-place instead.
"""
prev = None
while node is not None:
if node.next is not None:
prev = node
prev.next ... |
85e20bca8b48a2c841936fdb1e9f497841be0c4f | HansrajMathakar/Practice | /permutation.py | 429 | 3.984375 | 4 | # Determine whether or not one string is a permutation of another.
import sys
import operator
def isPermutation(s1, s2):
input1, input2 = [], []
for i in s1:
input1.append(i)
for j in s2:
input2.append(j)
input1.sort()
input2.sort()
if operator.eq(input1, input2):
r... |
d7a642aad3d89447c87cc38a79f50956349c5011 | 52nlp/nn-autoencoder-classification | /op.py | 1,585 | 3.765625 | 4 | class Neuron(object):
def __init__(self, input_neurons=[]):
self.input_neurons = input_neurons
self.output_neurons = []
self.value = None
for node in self.output_neurons: # this node is output for each input
node.output_nodes.append(self)
def forward(self):
... |
f7ef0b01bafea0e60ef9163bc11d059014e75412 | Nalmac/DerivateTools | /UserInterface.py | 3,855 | 3.515625 | 4 | from tkinter import *
from Derivator import Derivator
#La classe qui gère l'interface utilisateur
class Interface():
def __init__(self):
#Initialisation de la fenêtre
self.window = Tk()
self.window.title("DerivateTools")
self.window.geometry("1080x720")
#Ajout des composan... |
679e7c9a759ff28bfbbc795b54975f02541e2167 | eeelinn/Rosalind | /Python/python_str_lst.py | 287 | 3.59375 | 4 | # Strings and Lists problem
import sys
filename = sys.argv[1]
with open(filename,'r') as f:
string = f.readline()
num = f.readline().split()
a = int(num[0])
b = int(num[1])
c = int(num[2])
d = int(num[3])
word1 = string[a:b+1]
word2 = string[c:d+1]
print word1, " ", word2
|
53b5eae4e88feefd427cc0092a2d4415bfc6f377 | dlin8/myMatrix | /matrix.py | 6,541 | 3.5625 | 4 | #!/usr/bin/env python3
import line
width = 500
height = 500
#width = int(input("width of image: "))
#height = int(input("height of image: "))
colorDepth = 255
matrix = []
color = [0, 255, 0]
for i in range(width):
matrix.append([])
for j in range(height):
matrix[i].append([0, 0, 0])
def printMatrix(... |
1bdc93f3380c0678b115f7c7ee4d0a556a46e0e8 | dsplaymaxxis/4linux-teste | /aula2/aula2 ex1.py | 673 | 4.21875 | 4 | #!/usr/bin/python3
#alterar vogais por asterisco
#jeito 1
palavra = input('Digite Palavra: ')
vogais = 'aeiou'
troca = ''
for k in palavra:
if k in vogais:
troca += '*'
else:
troca += k
print(troca)
exit()
#jeito 2
vogais = 'aeiouAEIOUáéíóúÂÊÎÔÛ'
palavra = input('Digite Palavra: ')
for k in palavra:
if ... |
0eaf6e272daa36b1e29c7aab652f8b713368281b | Qing8/Assignments-for-Data-Structure | /1/Python template files/question1.py | 705 | 4.03125 | 4 | def anagram(string1, string2):
'''
##Comment out print functions if you submit on gradescope.
@string1: The first string
@string2: The second string
@return True if string1 is anagram of string2
False otherwise
'''
# To do
string1 = string1.lower()
string2 = string2.lowe... |
ad16ce431ebfcc6c261c9ec2875f88b9a14e82e3 | Qing8/Assignments-for-Data-Structure | /1/Python template files/question3.py | 571 | 3.96875 | 4 | def gcd(a, b):
'''
##Comment out print functions if you submit on gradescope.
@a: the first integer
@b: the second integer
@return the greatest common divisor of integer a and b.
'''
# To do
if a > b:
larger = a
smaller = b
elif a < b:
larger = b
smal... |
ccfcf9ee5e7f16392e5f8e1184277d8cc5cb4329 | Qing8/Assignments-for-Data-Structure | /8/Assignment 8 files/Assignment 8 files/BST.py | 10,560 | 3.578125 | 4 | from LinkedQueue import *
from LinkedBinaryTree import *
class BinarySearchTree(LinkedBinaryTree):
#------------------------------- nonpublic utilities -------------------------------
def _subtree_search(self, p, v):
"""Return Position of p's subtree having value v, or last node searched."""
i... |
d74996213c9c52b73edf52e5dd7a25bd57d8881e | yankuang608/Algorithm | /Graph/DFS&topological sort.py | 859 | 3.59375 | 4 | '''
DFS
'''
class vertex:
def __init__(self,name):
self.name=name
self.d=None
self.f=None
self.color='white'
self.ancestor=None
time=0
topological_sort=[]
def DFS(G):
global time
for vertex in G.keys():
if vertex.color=='white':
DFS_VISIT(G,vertex)... |
3a314e2b8b56ce5cceb1fea5f85d119649e57647 | Phu-Pwint/Python-Mini-Projects | /Bunny Mad Lib/Funny Bunny Mad Lib.py | 1,162 | 3.734375 | 4 | def madlib():
per_name = input("\n\nPerson's Name: ")
place = input("Place: ")
verb1 = input("Verb: ")
animal = input("Animal: ")
exer = input("An Exercise: ")
noun1 = input("Noun: ")
face = input("Part of Face: ")
adj1 = input("Adjective: ")
vege = input("Vegetable: ")
... |
bd96ff7509716ca01e05bf91a26e7566bb2d55d5 | vaibhavbrid/pythonpractice | /LinkedList.py | 1,919 | 3.984375 | 4 | from Node import Node
class LinkedList:
def __init__(self):
self.root = None
root = Node
head = Node
def insert(self, data):
newNode = Node(data)
if self.root is None:
self.root = newNode
self.head = self.root
else:
self.head.next_no... |
ae9486148465dc0210cd8bc1eaa1dee232a7bd0d | dhaneeshgk/share_food | /task/string ex.1.py | 69 | 3.625 | 4 | my_string ="Hello!"
print (len(my_string))
print (my_string.upper())
|
b9d630435d40498f9a09e806870c5b4f67715901 | mike006322/FrobeniusNumber | /NijenhuisAlgorithm/nijenhuis.py | 1,027 | 3.65625 | 4 | from NijenhuisAlgorithm.dijkstra import *
def nijenhuis(*generators):
"""
input integers
output Frobenius Number, i.e. the largest number not a linear combination of inputs
"""
# 1. Create the Nijenhuis graph.
def make_nijenhuis_graph(generators):
"""
output is in form {node1:... |
ba9f0f27f461eb5ea544bf87087b099aa76060fe | edipguvenccekic/hafta4_algoritmalar | /hafta4_algoritmalar/hafta4.1_algoritmalar.py | 511 | 3.859375 | 4 |
#1-kullanıcının girdiği 2 sayı arasındaki sayıların toplamını bulan Sorgu
#For ile
print("4. Hafta Ödevi: 1\n2 sayı arasındaki sayıların toplamını bulan program")
say1 = int(input("Birinci sayıyı giriniz: "))
say2 = int(input("İkinci sayıyı giriniz: "))
toplam = 0
if say1 < say2:
for i in range((say1+1),say2,1):
... |
52ba75e1ad2fa0d7aef005e5d50d41ff92cfdb4f | MyHealthyHair/Week6 | /booking.py | 174 | 3.953125 | 4 | message = input('how many tables you want to book?')
message = int(message)
if message > 8 :
print('\nsorry, we have no table.')
else:
print('we have your table.')
|
de5e142bcc76c3c06f340b8bb211e6567c27f932 | junthbasnet/Project-Euler | /ProjectEuler #4[Largest Palindrome Product].py | 381 | 3.671875 | 4 | #Author@Junth Basnet
#Algorithm and Data Structures[Binary Search Algorithm]
#Palindrome
#Time Complexity:O(n^2)
import bisect
array=[]
for i in range(999,100,-1):
for j in range(999,100,-1):
numbers=str(i*j)
if numbers==numbers[::-1]:
array.append(i*j)
array.sort()
for i in range(int(raw_input())):
numbe... |
c3cac9be92f972acc323ff5879e1721a7a8ecbeb | RumorsHackerSchool/PythonChallengesSolutions | /Guy/edX/MITx:6.00.1xIntroductionToComputerScienceAndProgrammingUsingPython/while exercise 2.py | 115 | 3.75 | 4 | None
varA = 10
while True:
print("Hello!")
while varA !=0:
print(varA)
varA -= 2
break |
f88a428b294348655fba37c81c51cce6976e75aa | RumorsHackerSchool/PythonChallengesSolutions | /Guy/hackerrank.com/Python_Division.py | 596 | 4.15625 | 4 | '''
Task
Read two integers and print two lines. The first line should contain integer division, // . The second line should contain float division, / .
You don't need to perform any rounding or formatting operations.
Input Format
The first line contains the first integer, . The second line contains the second integ... |
5385719904df3e26e73973223ea75afede88ee37 | ang3lls/Training | /python/Aulas 6 e 7/002.py | 258 | 3.6875 | 4 | coisa = (input('Escreva algo: '))
print('O tipo primitivo é', type(coisa))
print('Ele é um numero: ', coisa.isalnum())
print('Ele é uma palavra: ', coisa.isalpha())
print('Letras maiuscula: ', coisa.isupper())
print('letras minusculas ', coisa.islower())
|
14640a9af1f8f1deddf7a86c36fc51a0f2dc7c59 | rabestro/sololearn-challenges | /medium/pro-snap-crackle-and-pop/SnapCrackle.py | 187 | 3.671875 | 4 | def sound(n):
if n % 3 == 0: return 'Pop'
if n % 2 == 0: return 'Crackle'
else: return 'Snap'
sounds = ' '.join(map(sound, [int(input()) for i in range(6)]))
print(sounds)
|
dc4ee65bc71c8a932c951c341c1dd995987842f6 | rabestro/sololearn-challenges | /easy/pro-ballpark-orders/BallparkOrders.py | 297 | 4.09375 | 4 | menu = {'Nachos': 6, 'Pizza': 6, 'Cheeseburger': 10, 'Water': 4, 'Coke': 5}
tax = 1.07
items = input().split()
total_cost = 0
for item in items:
if item not in menu:
total_cost += menu['Coke']
else:
total_cost += menu[item]
total_cost *= tax
print('%.2f' % total_cost)
|
13c7cc5ec621a0e0cdd5aa98e926a3d7090f8a09 | rabestro/sololearn-challenges | /medium/pig-latin/PigLatin.py | 127 | 3.734375 | 4 | sentence = input().split()
pig_latin = ""
for word in sentence:
pig_latin += word[1:] + word[0] + "ay "
print(pig_latin)
|
b534d09482005784cbb40c846d085fa47dc6767c | rabestro/sololearn-challenges | /easy/popsicles/Popsicles.py | 140 | 3.5 | 4 | siblings = int(input())
popsicles = int(input())
if popsicles % siblings == 0:
print("give away")
else:
print("eat them yourself")
|
34e7898973c96a83106140f62c81de5078e3930b | rabestro/sololearn-challenges | /easy/cheer-creator/CheerCreator.py | 123 | 3.65625 | 4 | yards = int(input())
if yards > 10:
print("High Five")
elif yards < 1:
print("shh")
else:
print("Ra!" * yards) |
60db2691c7b5b970c00d7d9691dc3b06bd7e88fa | JustBeYou/ctfs | /ecsc19/crypto2.solve.py | 335 | 3.703125 | 4 | from string import ascii_lowercase
from string import ascii_uppercase
def decrypt(t, alph, k):
r = ""
for c in t:
if c in alph: r+=alph[(alph.index(c)+k)%len(alph)]
else: r+=c
return r
key1= 17
key2 = 24
s="YnuNmQPGhQWqCXGUxuXnFVqrUVCUMhQdaHuCIrbDIcUqnKxbPORYTzVCDBlmAqtKnEJcpED"
s1 = decr... |
c2f7d26b4ccf79ca90b57edcf5423401422773e9 | JustBeYou/ctfs | /pwn2win/gabi.py | 499 | 3.59375 | 4 | import numpy as np
def Pow(b,exp,mod):
ans=np.array([1,0,0,1]).reshape(2,2)
i=1
while(i<=exp):
if(i&exp):
ans=np.matmul(ans,b)
ans%=mod
b=np.matmul(b,b)
b%=mod
i*=2
return ans
def decrypt_char(char0,char1):
mod=242612
exp=pow(char0,2)-1
... |
999a0b840be12598fc69b093d0996631414dc5bd | JopValle/Jogoprojeto | /Jogo Python/Jogo_Python.py | 1,344 | 3.609375 | 4 | import Tutorial.Interfac
import andarone.comandos
import andartwo.comandos
from time import sleep
jogador = dict()
#criando a ficha do jogador (nome, nível, andar e vida)
while True:
resposta = str(input('Você deseja fazer o tutorial? ')).strip().upper()[0]
if resposta == 'S':
nome = Tutorial.Interfac... |
9eba80b679239027c2b81054e875280e5258a3ee | JopValle/Jogoprojeto | /Jogo Python/andarone/exsala.py | 7,471 | 4.03125 | 4 | def exsala(sala):
if sala == 'A2':
resultado = 0
print('-'*30)
print('Se o somatório das forças externas sobre um sistema de partículas de massa constante é zero, é CORRETO afirmar ser constante a: ')
print('-'*20)
print('1-energia potencial do sistema.')
print('2-ene... |
1e15a4196445c917bb33a048900cf35cd1d0da98 | radiant107/Merchant | /m.py | 801 | 3.921875 | 4 | merchant = []
while True:
name = input('請輸入商品名稱: ')
if name == 'q':
break
price = input('請輸入價格: ')
m =[] # 在大清單裡面設小清單
m.append(name)
m.append(price)
merchant.append(m)
print(merchant)
print(merchant[0][0], merchant[0][1], '元') # 取出大清單的第一個小清單,再取出小清單的第一個和第二個
print(merchant[1][1])
# 簡化小清單寫法
merchant = []
while... |
2e0533a762c609db240fc45634b6a93c17c7e265 | crictor320/Python-Class | /my_numbers.py | 811 | 3.859375 | 4 | #print("Hello Python")
# scalar data types: Integers, Floating point
# None, and Boolean
print("Binary notation", 0b0100)
print("Hex notation", 0x0100)
# use the int() constructor
print("477")
# option for base
print(int("1001", 2))
# Floating point: IEE-754 notation
# Scientific notation
print("scientific not... |
a062b457acbc3b7f0ae31f6fe2a590e998b5eda9 | sodrian/checkio | /ch02_home/hm99_most_wanted_letter.py | 919 | 3.6875 | 4 | import string
def checkio(text):
d = {}
for l in text.lower():
if l in string.ascii_lowercase:
d[l] = d.get(l, 0) + 1
mx = (None, 0)
for k, v in d.items():
if v > mx[1]:
mx = (k, v)
elif v == mx[1] and k < mx[0]:
mx = (k, v)
return mx[0... |
2af8778881808dee7e6751a5612f210f00b151e2 | mavroskardia/ilovemymudder | /mudder/src/story/cave.py | 1,019 | 3.84375 | 4 | name = 'Hole in the Ground'
description = '''
You descend the ladder into the hole in the ground.
As you set foot on the bottom rung of the ladder, the trapdoor above slams
shut, leaving you in total darkness.
'''
exits = {
}
def light(origin, what=None, *args):
if not what:
origin.write('''
Yeah, a light wou... |
6d41c911f53ae0971e046f34ce7f215d98d6c472 | chiragpatel390/exercise | /python/allergies/allergies.py | 680 | 3.78125 | 4 | class Allergies(object):
def __init__(self, score):
self.score=score
def is_allergic_to(self, item):
return (item in self.lst)
@property
def lst(self):
l=[]
temp = self.score%256
while temp>0:
if temp >=128:
l.append("cats")
temp -= 128
elif temp >=64:
l.append("pollen")
temp -= 6... |
014981b6d3638da4e75d5c1977332ac2ae8cbfb2 | chiragpatel390/exercise | /python/sublist/sublist.py | 635 | 3.96875 | 4 | SUBLIST = 0
SUPERLIST = 1
EQUAL = 2
UNEQUAL = 3
def check_lists(first_list, second_list):
if first_list == second_list:
return EQUAL
elif len(first_list) < len(second_list):
if len(first_list) == 0:
return SUBLIST
for i in range(len(second_list)):
if first_list[0] == second_list[i]:
if first_list ==... |
cb1d84e9dda5a19c823cc580f9e4cc99b19190c9 | chiragpatel390/exercise | /python/sum-of-multiples/sum_of_multiples.py | 149 | 3.609375 | 4 |
def sum_of_multiples(limit, multiples):
a=[]
for i in multiples:
for j in range(1,limit):
if i*j<limit:
a.append(i*j)
return sum(set(a)) |
262309ece345f0668b9ec79174d38e68e1c37658 | tahniyat-nisar/if_else | /to check input num lies in the which range of numbers.py | 465 | 4.09375 | 4 | number=int(input("enter a number above 100:"))
if number>=100 and number<=1000:
print('the number lies in between 100 to 1000')
elif number>=1001 and number<=10000:
print("the number lies in between 1000 to 10000")
elif number>=10001 and number<=50000:
print("the number lies in between 10001 to 50000")
elif... |
edcc1681efd32fb99d9c6e3ad28109cc9073e54e | tahniyat-nisar/if_else | /comparing ages.py | 606 | 4.125 | 4 | aryan=int(input("enter the age of aryan:"))
arjun=int(input("enter the age of arjun:"))
arav=int(input("enter the age of arav:"))
if (aryan<(arjun and arav)) and ((arjun and arav)>aryan) :
print("aryan is younger brother of arjun and arav\narjun and arav are elder brothers of aryan")
elif (arjun<aryan and arav) and... |
6b3ce9ad7bbb682b4be10a24084975d40bfbcd83 | tahniyat-nisar/if_else | /attendence percentage on classes conducted.py | 423 | 3.859375 | 4 | attendence=int(input('enter number of classes attended:'))
classes_held=int(input ('enter number of classed held:'))
if ((attendence/classes_held)*100)<75:
print(attendence/classes_held*100,'%')
print("student is not allowed to sit in exam")
elif (attendence/classes_held*100)>=75 and (attendence/classes_held*1... |
73accd36a09f8c18c4428475aa85845a06bf6e5d | tahniyat-nisar/if_else | /6 table in if else.py | 507 | 4.09375 | 4 | number=6
number=int(input("Do you want mutiplication table of 6\n then enter the number 6:"))
if number*1==6:
print("6*1=6")
if number*2==12:
print("6*2=12")
if number*3==18:
print("6*3=18")
if number*4==24:
print("6*4=24")
if number*5==30:
print("6*5=30")
if number*6==36:
print("6*6=36")
if num... |
88178fe718a377817fbc9100a5d790ba5ca2798a | tahniyat-nisar/if_else | /based on age and gender wages.py | 356 | 4.15625 | 4 | age=int(input("enter age upto 40 only:"))
gender=(input("enter as M for male and F for female:"))
if age>=18 and age<30:
if gender=="M":
print("wage/day=700")
elif gender=="F":
print("wage/day=750")
elif age>=30 and age<=40:
if gender=="M":
print("wage/day=800")
elif gender=="F... |
e3e535a5b3e44eca28d2d97cb831ea99f18193ae | oddood/Data_Mining | /HW08/HW08_Morris_Thomas.py | 10,466 | 3.890625 | 4 | """
Author: Thomas Morris | tcm1998@rit.edu
Date: 5 April 2020
=======================================
We model the line we seek as:
A * x + B * y + C = 0;
This is the cannonical form, used in linear algebra and many other places.
In our case we are going to use:
A * x + B * y - rho = 0;
We do this because, in a s... |
ccaa278424d123c2994582ee3a2d7d27898732ec | kralmachine/veribilimi | /Machine Learning A-Z/Part 4 - Clustering/Section 25 - Hierarchical Clustering/hc_myfile.py | 1,602 | 3.5 | 4 | # Hiyerarşik Clustering
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import os
# Set working directory
os.chdir("C:\\Users\\toshiba\\Desktop\\Machine Learning A-Z\\Part 4 - Clustering\\Section 25 - Hierarchical Clustering")
# Importing the dataset
dataset = pd.read_... |
f8fc43399cd4e605da487286fb36948c182eefb3 | Vanderhoekx/fantastic-dollop | /webpagesaver.py | 1,457 | 3.890625 | 4 | #saves html from webpages using requests
#written by Kelly Schmidt
#import modules
import re
import requests
import pyinputplus as pyip
import pyperclip as pclip
#compile out the DNS from the url for filename
filename_compile = re.compile(r'''(http://|https://)
(www.)?
... |
3b67d19042b74339430b6776280af5299b1a83b2 | s18009/programdekanojotukuru | /nekomimi/nekomimi.py | 306 | 3.921875 | 4 | n = input()
def count(word, s):
n = 0
for i in range(len(s) -2):
if s[i: i + 3] == "word
n += 1
return n
def count2(word, s):
return s.count(word)
def display(n):
print(n)
if __name__ == '__main__':
s = input()
result = count2('cat', s)
display(result)
|
20e786982082f482ab6812170100caf701583ab5 | ShartepStudy/MachineLearning | /Lecture_1/lecture-1_2.py | 1,220 | 3.546875 | 4 | import numpy as np
import pandas as pd
from sklearn.tree import DecisionTreeClassifier
data = pd.read_csv('titanic.csv', index_col='PassengerId')
# remove unused columns
data.drop(['Name', 'SibSp', 'Parch', 'Ticket', 'Cabin', 'Embarked'], inplace=True, axis=1)
# remove rows with NaN's values
data = data.dropna()
data... |
37705f8a1cafdb174a5ded0e0e89596641cc4529 | AGTGreg/Strategy_tester | /utils/gc_profiler.py | 456 | 3.71875 | 4 | import time
def time_function(f):
""" Times any function and prints the result. Use it as a decorator.
"""
def f_timer(*args, **kwargs):
start = time.time()
result = f(*args, **kwargs)
end = time.time()
print(
'==> Function [',
f.__name__,
... |
24133ae84a9b9e115a94e62f848ed1e37937e219 | AntonioGalvanPerez/RaberryPiVariables | /variableAssignment.py | 1,179 | 3.53125 | 4 | #Change the Shape arrays to display two shapes that will alternate back and forth
#By either using the colors provided or by creating custom collors from: https://www.rapidtables.com/web/color/RGB_Color.html
#At the end change the default text to a new message
from sense_hat import SenseHat
import time
sense = SenseH... |
e476be820696840de4b52ed563350e4e879950f3 | pol9111/dododo | /others/时区,时间字符串,时间计算.py | 787 | 3.671875 | 4 | import datetime
# from datetime import datetime
# 写一个进行时间计算,比如加减
now = datetime.datetime.now()
print(now)
new_now = now + datetime.timedelta(hours=7)
print(new_now)
new_now2 = now + datetime.timedelta(days=11)
print(new_now2)
new_now3 = now + datetime.timedelta(days=3, hours=10)
print(new_now3)
# 写一个时间转字符串,字符串转时间... |
c9dd404fca312d0ae01675a53d01874b401655c9 | COMHIS/article_2019_early_modern_canon | /code/commonlibs_py/data_importers.py | 534 | 3.578125 | 4 | import csv
import json
def read_csv_to_dict(file_path):
result_list = []
with open(file_path, 'r') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
result_list.append(row)
return result_list
def read_jsonfile(jsonfile):
with open(jsonfile) as json_datafile:... |
a32edbda2f7764996963c374c599d79d4744c082 | dana19-meet/meet2017y1lab4 | /caught_speeding.py | 552 | 4.09375 | 4 | speed=input('what was your speed?')
birthday= input('is it your birthday?')
if birthday=='no':
if int(speed)<31:
print('no ticket!')
elif int(speed)>30 and int(speed)<51:
print('small ticket!')
elif int(speed)>50:
print('big ticket')
else:
if int(speed)<36:
print('no ti... |
37160dbc5d2f72cd5a898e555d9db07f61f18b10 | MukundKulkarni/ArtificailIntelliegnceProblems | /TicTacToe1.py | 2,429 | 3.953125 | 4 |
# By default player goes first, and then computer moves.
# Player is denoted X, computer is denoted by 0 and blank is denoted by _
import random
wining_positions = [[0, 1, 2],[3, 4, 5], [6, 7, 8], # All winning Combinations
[0, 3, 6], [1, 4, 7], [2, 5, 8],
[0, 4, 8], [2, 4, 6]... |
5febfd5358c7e973aadf4a4212e48fd497d4c75c | hervster/HackHealth | /python.py | 3,938 | 3.90625 | 4 | import datetime
class BottleStorage:
def __init__(self):
self.map = {}
def addBaby(self, baby):
self.map[baby] = baby.bottles
def addBottle(self, bottle):
self.map[bottle.baby].insert(bottle)
def insertBottle(self, bottle, bottleList):
"""inserts bottle into sorted l... |
995a1bbf95d98be9fd0ad66d4ffdbef299e9b78d | sudharkj/ml_scripts | /regression/regression_template.py | 1,426 | 4.125 | 4 | # From the course: Machine Learning A-Z™: Hands-On Python & R In Data Science
# https://www.udemy.com/machinelearning/
# dataset: https://www.superdatascience.com/machine-learning/
# Import the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Import the dataset
dataset = pd.read_csv(... |
d73be7748c66e2a6d3a50c8d884b4e713dc1b92d | sudharkj/ml_scripts | /regression/simple_linear_regression.py | 1,252 | 4.34375 | 4 | # From the course: Machine Learning A-Z™: Hands-On Python & R In Data Science
# https://www.udemy.com/machinelearning/
# dataset: https://www.superdatascience.com/machine-learning/
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
dataset = pd.rea... |
caf3b53e3859c11920e587847eb8e9ac46108c20 | sudharkj/ml_scripts | /nn/ann.py | 2,119 | 3.9375 | 4 | # From the course: Machine Learning A-Z™: Hands-On Python & R In Data Science
# https://www.udemy.com/machinelearning/
# dataset: https://www.superdatascience.com/machine-learning/
# Import the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Import the dataset
dataset = pd.read_csv(... |
c44b5e9040559494d1a42c281f5bf16252393998 | sudharkj/ml_scripts | /data_preprocessing/data_preprocessing_template.py | 1,377 | 3.984375 | 4 | # From the course: Machine Learning A-Z™: Hands-On Python & R In Data Science
# https://www.udemy.com/machinelearning/
# dataset: https://www.superdatascience.com/machine-learning/
# Import the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Import the dataset
dataset = pd.read_csv(... |
40ae53e7e5520f6b4b2c729b148863416d1bd1f4 | singhchirag502/Email-Generator | /email.py | 682 | 3.578125 | 4 | import random
names=["Chirag Singh","Ambrish Singh","Richa Singh","Bruno Singh","Ragini Singh"]
index_email=0 # i have to make it increase
email=[]
for j in range(0,5):
for i in range(0,len(names)):
email_choose=random.randint(1,2)
email_rand_int2=random.randint(10,99)
email_rand_int4=r... |
d148edb75adbcb51103e08d5ec5e8be44fee8ff3 | xbum2008/python | /Lesson02/Lesson02_05.py | 573 | 3.6875 | 4 | inlist = [7, 5, 3, 3, 2]
print(f"Reyting - {inlist}")
digit = int(input("Vvedite chislo (-1 - vichod) "))
while digit != -1:
for el in range(len(inlist)):
if inlist[el] == digit:
inlist.insert(el + 1, digit)
break
elif inlist[0] < digit:
inlist.insert(0, ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.