blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
74b950480084c75a1dcf93fde1dde4f04b5219b1
ZSL-1024/Python-Crash-Course
/chapter_07_input_and_while/no_pastrami.py
802
3.90625
4
# 7-9 no_pastrami.py sandwich_orders = ['chicken', 'pastrami', 'steak', 'tuna', 'pastrami', 'shrimp', 'veggie', 'pastrami'] finished_sandwiches = [] # Add code near the beginning of your program to print a message # saying the deli has run out of pastrami print("Sorry, we have run out of pastrami today.") # ...
35141cad6f1bce0aa1df347c44a818afb7dc5375
ZSL-1024/Python-Crash-Course
/chapter_09_classes/number_served.py
1,401
3.890625
4
# EX 9-4 number_served.py class Restaurant(): """docstring for Restaurant""" def __init__(self, restaurant_name, cuisine_type): """Initialize the restaurant.""" self.restaurant_name = restaurant_name.title() self.cuisine_type = cuisine_type self.number_served = 0 def describe_restaurant(self): ...
96629a676dcff57f3d8813c6ef41ea7f6ee8159a
ZSL-1024/Python-Crash-Course
/chapter_08_functions/great_magicians.py
848
4.1875
4
# 8-10 great_magicians.py def show_magicians(names): """Rrint the name of each magician in the list.""" for name in names: print(name.title()) def make_great(names): """Add 'the Great!' to each magician's name.""" # Build a new list to hold the great magicians. great_magicians = [] # Make each magi...
6bda24fcfe9ede0092899adf8a81a297ae05a0c8
ZSL-1024/Python-Crash-Course
/chapter_02_variables & data types/favor_number.py
323
3.8125
4
# Store your favorite number in a variable. Then, using # that variable, create a message that reveals your favorite number. Print that # message. favor_number = 25 print("My favorite number is: " + str(favor_number)) favor_number = 25 message = str(favor_number) print("My favorite number is: " + messa...
94c8e9e16d63b91981abedf3a26a6ef4fc9ea250
sudhir-j-sapkal/python-basic-examples
/07Dictionaries/01Dictionaries.py
866
4.46875
4
#Create and print a dictionary: my_car_dict = { "brand": "Ford", "model": "Mustang", "year": 1964 } print(my_car_dict) #Accessing Items #You can access the items of a dictionary by referring to its key name, inside square brackets: car_model = my_car_dict["model"] print(car_model) #There is also a method calle...
a6e73e0c55105a3695536845ea14e4b305981a87
sudhir-j-sapkal/python-basic-examples
/12ObjectOrientedProgramming/01OOP_Basic.py
282
4.375
4
#Creat Class Example class MyClass: x = 05 #Member of MyClass y = 10 #Member of MyClass my_class_object = MyClass() print(my_class_object) #See what happens when you print object print(my_class_object.x) #This should print x value which is member of MyClass
41946b85a53e4f333dad9f48a81ee7a03bffe1b8
sudhir-j-sapkal/python-basic-examples
/12ObjectOrientedProgramming/08Polymorphism.py
779
4.25
4
class Parrot: def fly(self): print("Parrot can fly") def swim(self): print("Parrot can't swim") class Penguin: def fly(self): print("Penguin can't fly") def swim(self): print("Penguin can swim") # common interface def flying_test(bird): bird.fly() #inst...
6e6850e0dfae0e3c343ac10e459b94fbdcfb2103
trancker/Program_Hackerrank
/Debugging/string.py
141
3.765625
4
s1=("this string") s2=("that string") print(s1==s2) s1=("this string") s2=("thisstring") print(s1!=s2) s1=("This") s2=("This") print(s1>=s2)
d87611cd3eb499877a2a792a90111a62a7a26a00
tlhpaul/Python-Project
/Cities/cities_test.py
2,265
3.5
4
import unittest from cities import * road_map = [("Alabama", "Montgomery", 32.361538, -86.279118), ("Maine", "Augusta", 44.323535, -69.765261), ("West Virginia", "Charleston", 38.349497, -81.633294), ("South Dakota", "Pierre", 44.367966, -100.336378)] class ...
739f10fd76a4ad5080a91aadeacea9b56cd0bfc5
HolyPi/LeetCode2
/ValidPalindrome.py
445
3.890625
4
s = "A man, a plan, a canal: Panama" def isPalindrome(s): s = s.lower() left = 0 right = len(s) - 1 while left < right: while not s[left].isalpha(): left += 1 while not s[right].isalpha(): right -= 1 if s[left] != s[ri...
e7b2302e8b25031d4c38d8a9dc882c6c54833633
RyanPencak/TextAnalysis
/BasicStats.py
4,958
3.921875
4
#################################################################################################################################################################### # Name: Ryan Pencak # Class: Basics Stats # Summary: This class handles the statistics used to analyze the documents. It can calculate the frequency map of...
2c578222c7a33b0c0cd3e70baad518491e46a7bf
RyanPencak/TextAnalysis
/MatPlotPlotter.py
1,928
4.3125
4
#################################################################################################################################################################### # Name: Ryan Pencak # Class: MatPlot Plotter # Summary: The MatPlot Plotter class has two methods to plot different types of graphs. The method scatter plo...
a3486bfbda0c174c527853641e4d15f42120417f
daniyalnawaz-heek/url-shortner
/url_shortner.py
254
3.59375
4
#importing pyshortener module import pyshorteners #taking input link link=input("enter the link:\t") #shortening the url shortened=pyshorteners.Shortener() new_link=shortened.tinyurl.short(link) #printing the shortened url print(new_link)
0b2cb3f3c22bacb9d7b5fb1c2ba8a10a3d075b75
dompuiu/puzzles
/mafia-problem/src/gangster.py
1,578
3.59375
4
from src.linked_list import LinkedList from enum import Enum GangsterLocation = Enum('GangsterLocation', 'UNKNOWN') GangsterStatus = Enum('GangsterStatus', 'FREE INJAIL') class SameGangsterException(Exception): pass class Gangster: def __init__(self, name, age, location=None): if not isinstance(age...
447368e0b301efdafb7adbed7c8fe29343b96124
dompuiu/puzzles
/grid-navigation-paths-count/tests/test_string_permutations.py
840
3.5
4
from unittest import TestCase from grid_path.string_permutations import Permutations class TestPermutations(TestCase): def test_get_permutations_with_empty_string(self): self.assertEqual(Permutations('').get_permutations(), set([''])) def test_get_permutations_with_one_letter_word(self): self...
c32027494037cd86d6e1b949502c6ed35300cd5f
tengkuaizat/phyton
/PythonTask/pythonworks 2/DrawingWeek1.py
1,116
3.671875
4
from graphics import * from random import randint import random import time # Read in and print out the data in the data file datafile = open("data.txt",'r') # Do some simple drawing window = GraphWin("Visualisation", 400, 400) i = 0 for line in datafile: print(line) i += 5 num = int(float(l...
e52d4909c7c49483322249747a657c747c4dc696
gefeinic2010/MyPyStudy
/GuessNum/GuessNum.py
429
3.5625
4
#! /usr/bin/env python # _*_ coding:utf-8 _*_ import random Rnum = random.randint(1, 100 ) print(Rnum) Gnum = 0 try: while Gnum != Rnum: Gnum = int(raw_input('请你输入你猜测的数字:\n')) if Gnum > Rnum: print('猜的大了') elif Gnum < Rnum: print('猜的小了') else : p...
fffde4464ea5c49cf8aab32766ab7b7b5c44eaca
vineethMM/DataStructuresAndAlgorithms
/recursion/harmonic_number.py
329
4.15625
4
def nth_harmonic(n): ''' Find the nth harmonic number''' if n == 1: return 1 else: return (1 / n) + nth_harmonic(n - 1) if __name__ == "__main__": print("Test 1") print(f"3rd harmonic number is {nth_harmonic(3)}") print("\nTest 2") print(f"9th harmonic number is {nth_harmon...
aea80fcdace10420e620082075bee2c3a215beae
vineethMM/DataStructuresAndAlgorithms
/recursion/recursive_max_and_min.py
818
3.765625
4
def binary_op(numbers, comparator): def inner(numbers, begin, end): if begin == end: return numbers[begin] else: mid = (begin + end) // 2 return comparator( inner(numbers, begin, mid), inner(numbers, mid + 1, end) ) ...
5e189fea7591bb7b454b495ecce88a8bc2c4c188
awshepard/adventofcode
/2015/day2/day2.py
668
3.53125
4
import sys import os import itertools total_paper = 0 total_ribbon = 0 with open("input") as f: for line in f: dims = line.strip().split("x") if len(dims) == 3: volume = int(dims[0]) * int(dims[1]) * int(dims[2]) combo_it = itertools.combinations(dims,2) side_areas = [] side_perimete...
ca820cce13c3ac1721c02e829ec227a45f5b7dc3
Wojtas2001/Algorithm-and-Data-Structures
/sorting_algorithms/14-15zad3.py
1,224
3.65625
4
def binarySearch(array, x, index): left, right = (0, index-1) while left <= right: mid = (left+right)//2 if array[mid] == x: return mid elif array[mid] < x: left = mid+1 else: right = mid-1 return -1 def find(T): # funkcja ta tworzy po...
3c2a9e8785841d82c35de5a8a86b60d3f5932023
Wojtas2001/Algorithm-and-Data-Structures
/graph_algorithms/depthFirstSearch.py
714
3.546875
4
# Depth First Search algortihm for graph in matrix representation # Time complexity: O(V^2) # where V - number of vertex # It could be done in O(V*log(E)) in list representation def dfs(G): n = len(G) time = 0 visited = [False]*n entry = [0]*n parent = [-1]*n process = [0]*n def dfs_visi...
a4b29601f0f01851f336a4ae73fd2f733c8b1aad
jcdickman/draconem_py_lab
/checkio/missions/ed_solve_number_length.py
752
4.125
4
def number_length(a: int) -> int: # your code here # algorithm # 1) Will recive an argument called "a" of datatype "int" # 2) Convert the integer into a string # 3) Calculate the length of the string # 4) Return the Length of the string return len(str(a)) def number_length_two(a: int) -> in...
543b236667f24ee46b18368925ac09c47ae5b69f
Gyuniku/MailDestinationExtraction
/splitter.py
2,083
3.671875
4
# -*- coding: utf-8 -*- import re import difflib # 出力されるメールアドレス一覧の区切り文字(;) mailaddress_delimiter = ';' # 正規表現設定 r = re.compile(r"^[^\(]*") # 参加者メールリスト participants_mail_list = [] # 元データ入力 mailaddresses = input('半角セミコロンで分割されたメールリストを入力してください\n →') participants = input('半角セミコロンで分割された参加者を入力してください\n →') # 入力データを分割 mail_...
8a244899dca6bc541b0bb1b2aa14be8d793bbb3c
rpfarish/small_projects
/super.py
184
3.9375
4
while input("Guess the number between 0 and 30:\n") != "27":pass input(input("Enter your name:\n").title() + " is Super" + input("Enter your gender(Man or Woman):\n").lower() + "!")
0e5b214dd5ede45a71ce96547aca627d16317743
samrahsoarus/build-a-blog
/crypto/caesarCL.py
1,193
3.734375
4
def alphabet_position(letter): alphaz = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] upperLetter = letter.upper() return alphaz.index(upperLetter) def rotate_character(char, rot): alphaz = ['A','B','C','D','E','F','G','H','I','J','K','L','M',...
f18b5360c23044dfeaf7ce792955e8e6c49fc323
isaackliewer/ROICalculation
/validation.py
484
3.90625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Apr 25 18:47:05 2021 @author: isaackliewer """ class ValidationClass: def checkFloat(self, str_input): flag = True while flag: try: str_input = float(str_input) except ValueError: ...
e0ab41f72f5d6b12b12b00a2c701827f75133166
Jiao-Jia-Xiong/path-finding
/test_map.py
1,906
3.65625
4
"""Unit test for map module""" import unittest from map import Map class TestMap(unittest.TestCase): def test_init(self): self.map = Map((100, 100)) self.assertEqual(100, len(self.map.nodes)) self.assertEqual(100, len(self.map.nodes[0])) self.assertEqual((9, 9), self.map[9, 9].loc...
e40f2cfdc7b0a17dda5bd985d1568f3a2f12c978
gracemarod/codingChallenges
/iceCreamParlor.py
999
3.640625
4
''' Given the value of and the cost of each flavor for t trips to the Ice Cream Parlor, help Sunny and Johnny choose two distinct flavors such that they spend their entire pool of money during each visit. EXAMPLE: Input: m(target) = 4, a = 1 4 5 3 2 output: 1 4 Explanation ice cream #1 cost $1 and ice cream#2 cos...
20e49f4ce10e70e069216c010d669d959ed59944
gracemarod/codingChallenges
/Others/arrays/removeSpaces.py
221
3.921875
4
'''Remove unnecessary spaces from given string.''' def removeSpaces(s): count = 0 l = [] for i in s: if i.isalpha(): l.append(i) newStr = "".join(l) print newStr s = "g eeks for ge eks " removeSpaces(s)
c486ea338e701648dca4153b681566a7d28ea008
gracemarod/codingChallenges
/Others/recursion/recursiveColor.py
655
3.71875
4
image = [[0,0,0,1,1,1,1,1,1,3,3,8,7,4,7,6,7,1], [0,0,0,0,1,1,1,1,0,5,5,5,5,5,5,0,0,0], [1,1,1,1,0,5,5,5,5,5,5,5,5,5,5,4,7,6], [1,1,1,1,0,5,5,5,5,5,5,5,5,5,5,4,7,5]] oldColor = "5" def floodfill(image, x, y, oldColor, newColor): #print image[x][y] if image[x][y] != oldColor: ...
d94a7425ae6350992f24fc81094f6715e0447044
Marchel21/UG9_E_71210782
/4_E_71210782.py
256
3.578125
4
bil_awal = 1 bil_sebelas = 11 kelipatan = int(input("Deret dengn Kelipatan: ")) for i in range(bil_awal, bil_sebelas+1): akhir = bil_awal*(kelipatan**(i-1)) hasil = akhir print(akhir) print("\n", "Deret: ", kelipatan, "suku ke-11: ", hasil)
de01a8a3dbd21e0af1301f59eb007be8c9e02fc5
SelinaJing/python_proj
/hm_8/lp_1.py
1,353
3.671875
4
# -*- coding: utf-8 -*- """ Created on Tue Apr 15 07:30:07 2014 The example for linear programing using barrier method @author: admin """ import numpy as np import lp_solver import matplotlib.pyplot as plt """ input: A, b, c, and x_0 as start point output: x_opt, v_opt """ m =100 n = 500 plt.close('all') # #A = np.ra...
d3088e9b9f2d7a45dcdf391358e5b184037d37b0
cs-richardson/novel-tkinter-project-albs1010
/novelTkinter.py
4,985
3.703125
4
#Albert from tkinter import * import tkinter as tk from tkinter import messagebox from datetime import datetime, date import sqlite3 as sq con = sq.connect("novel.db") c = con.cursor() #Function gets author's data from the table def get_author(): res = c.execute("SELECT AuthorID, AuthorDOB, AuthorName from Aut...
49bff0060fc42f0ca2b7815b7772797579d73b60
edmarcavalcante/projectpython
/13.1_arquivos_excecoes_continuacao.py
1,647
3.796875
4
# continuação de arquivos e exceções with open("livros_lidos_2019.txt") as lv: l = lv.read()#método para ler o arquivo texto print(l) print('\n') #with open("livros_lidos_2019.txt") as lv: #l = lv.write("ler é enriquece a alma") - esse comando deve ser # utilizado com cuidado, pois ele sobrescreve o ...
b4fb0c815f0e2e61a95edecf8571116693c32384
matthewbyrne-school/LinearRegression
/Program.py
6,149
3.65625
4
''' A Level Computer Science Project 2019 ''' # Author: Matthew Byrne # Date: 11/10/19 # Imports import linear_regression_MB import tables_MB import math try: import matplotlib.pyplot as plt # This module is the only one that requires external installation, and so if not present you must be instructed t...
f60ad042853c4cb4f56b738ea55d1ccba2eb0b73
alphaomegos/pylesson4
/Task 05.py
717
4.1875
4
# Реализовать формирование списка, используя функцию range() и возможности генератора. # В список должны войти четные числа от 100 до 1000 (включая границы). # Необходимо получить результат вычисления произведения всех элементов списка. # Подсказка: использовать функцию reduce(). import functools Even_List = l...
e9cf9a27e30c6868412a6de3297c6210c1fb776d
kfiramar/Homework
/1.b.py
186
4
4
def sumall(): x = input("enter numbers with , ") reshima = x.split(',') sum2 = 0 for i in reshima: sum2 += int(i) print("the sum is:" + str(sum2)) sumall()
65c68fad248985727b66d0dc6fadfb1011b2bba0
jeevankumarr/problems
/leetcode/1389_find_difference_str.py
1,912
3.640625
4
""" Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more letter at a random position. Find the letter that was added in t. Example: Input: s = "abcd" t = "abcde" Output: e Explanation: 'e' is the letter that was added. """ class ...
e9bedc4434c7b5627cde15b77fe845f9fea7d144
taka1156/AtCoder
/ABC/ABC_A_Plural_Form.py
187
3.609375
4
import test_case _CASE = """\ box """ test_case.test_input(_CASE) ########### # code ########## s = input() if s[len(s) - 1] == "s": s = s + "es" else: s = s + "s" print(s)
b58972edd535ed22c2ddd56b409abe6d4596eb75
taka1156/AtCoder
/ABC/ABC_B_Quizzes.py
285
3.53125
4
import test_case _CASE = """\ 20 10 xxxxxxxxxxxxxxxxxxxx """ test_case.test_input(_CASE) ########### # code ########## n, x = map(int, input().split()) s = input() score = x for i in s: if i == "x": score = max(0, score - 1) else: score += 1 print(score)
5da0c3a112e7d327b92123b17cd03f45c27f4422
taka1156/AtCoder
/ABC/ABC_A_Not.py
156
3.546875
4
import test_case _CASE = """\ 0 """ test_case.test_input(_CASE) ########### # code ########## if int(input()) == 0: print("1") else: print("0")
a40bc547b035d9d2b4d7d7580e152aa8b00c6ba3
taka1156/AtCoder
/APG4b/APG4b_EX8.py
605
3.65625
4
# https://atcoder.jp/contests/apg4b/tasks/APG4b_co """ p = int(input()) # パターン # パターン1 if p == 1: price = int(input()) # 価格 n = int(input()) # 個数 print(price * n) # 値段 # パターン2 if p == 2: text = input() price = int(input()) # 価格 n = int(input()) # 個数 print(text + "!") # 説明 print(...
c744dcabaa9f37e065e5a6abe516cf4c5b7d6751
ProPurav/Project-100
/atm.py
946
3.8125
4
class Atm: def __init__(self,pin,cardnumber): self.cardnumber = cardnumber self.pin = pin def CashWithdrawal(self, amount): new_amount = 500-amount print ("WithDrawal Successful : " + str(new_amount) + "Remaining Balance is: " + str(new_amount)) def balance(self):...
f5445f9b84fc2ed0f137863b6dccfe3fd425daea
BrentChesny/project-euler
/problem205.py
930
3.515625
4
from itertools import product def calculate_pyramid_chances(): pyramid_chances = [0] * 37 total_throws = 0 for throw in product(range(1, 5), repeat=9): pyramid_chances[sum(throw)] += 1 total_throws += 1 return [p/float(total_throws) for p in pyramid_chances] def calculate_cube_chance...
72b307cf455e013e0cc5b1dbdf6e7350b7beb6ff
BrentChesny/project-euler
/problem083.py
957
3.515625
4
from common import Graph, dijkstra def solve(): matrix = [map(int, line.strip().split(',')) for line in open('resources/p083_matrix.txt')] g = Graph() g.add_node('source') g.add_node('target') for r in xrange(len(matrix)): for c in xrange(len(matrix[r])): g.add_node((r...
8ecb516477642cf75fdf81cac117cbf33396aba0
BrentChesny/project-euler
/problem160.py
757
3.625
4
N = 1000000000000 def factors(x, n): result = 0 y = x while x < n: result += n / x x *= y return result def f(n): return even(n) * odd(n) % 100000 def even(n): if n == 0: return 1 else: return f(n / 2) def odd(n): if n == 0: ...
a538afcbafa54bba86490edb8e019701d222ca0a
Arin-py07/Python-Hashing
/CountDistinctElements.py
570
3.515625
4
#Without using set: def cDistinctFinder(l): res = 1 for i in range(1,len(l)): if l[i] not in l[0:i]: res = res+1 return res l = [10,20,10,30,30,20] print(cDistinctFinder(l)) #using Set:---------------------------------------------------------------------------------------...
14b2623532bc30e84099a7e4e5ca0ce239a3d6aa
obDann/fundamentals
/sorts/heap_sort.py
692
3.96875
4
from min_heap import * def heap_sort(L): ''' ([List of comparable objs]) -> [List of comparable objs] O(nlog(n)) sorting algorithm Returns a list of sorted objects from the passed list ''' # create a heap pipe = MinHeap() # and create a returning list ret = [] # iterate throug...
bcf39c6fc3e1af2bdbb33c8e9ff9e9c90589665c
obDann/fundamentals
/sorts/merge_sort.py
2,713
4.4375
4
def merge_sort(L): ''' (List of comparable objs) -> List of comparable objs O(nlog(n)) sorting algorithm Returns a list of sorted objects from the passed list ''' # make a returning value ret = [] # base case: the passed list is empty if (L == []): # if it is, then we retu...
c29c2c02172cc8eda5c34121acac664f941b5505
salario/python_samples
/play.py
538
3.96875
4
def demo(name, age, gender, oppGender): print "Your name is %s." % name print "You are %s years old." % age print "You are %s." % gender print "You are not %s." % oppGender prompt = "> " print "What is your name?" yourName = raw_input(prompt) print "What is your age?" yourAge = raw_input(prompt) ...
760b2b3351ea234208dcc50fc3ba864c21d576af
qccr-twl2123/PythonANS
/sample/Chapter7.py
774
3.5
4
# -*- coding: utf-8 -*- #1、 x=[1,2 ,3] def permutation(x): x[0],x[-1]=x[-1],x[0] return(x) y=permutation(x) y is x #2、 def sum_lists(x,y): return([x[i]+y[i] for i in range(len(x))]) #3、 def sum2(*lists): if len(lists)==2: return(sum_lists(lists[0],lists[1])) else: return(sum_list...
fac546ef5c9066f001ac5e382c5d9fe4cb08bf5e
qccr-twl2123/PythonANS
/Test/test13.py
1,024
3.78125
4
# coding:utf-8 # 一元线性回归分析例子 from sklearn import linear_model import pandas as pd #Function to get data def get_data(file_name): data = pd.read_csv(file_name) X = [] Y = [] for time, city in zip(data['时间'], data['北京']): X.append([float(time)]) Y.append(float(city)) return X, Y #Fun...
fb19476c7fdb9386480ad5e65ca04cb6700ca96e
vicjohnson1213/Bones
/utils.py
815
3.6875
4
import re def snake_case(string): """Converts a string to snake case.""" return re.sub(r'[^_A-Za-z1-9]+', '_', string) def get_parents(command): """Recursively finds the name of each parent command.""" if not command.parent: return [] if not command.name else [command.name] parents = get_...
069ebc9198675d37f7f0cd17c257c365521c712d
kasaiee/Python-Exercise
/10. functions/recursive functions/3/I.py
170
3.875
4
def r_fact(num): assert num >= 0, 'Must not be negative!' if num == 1 or num == 0: return 1 else: return num * r_fact(num - 1) print(r_fact(4)) print(r_fact(-4))
72ad2addba2b50172f84914de01ceac60aa5fcc7
kasaiee/Python-Exercise
/01. variables/04/03.py
216
3.90625
4
try: c = float(input('celsius degree: ')) if c < -273.15: print('celsius degree must be greather than', 273.15) else: print(c / 5 * 9 + 32) except ValueError: print('Incorrect input!')
f66dadcbbccb48e2ee8f31ab965187f5e75cf2ec
kasaiee/Python-Exercise
/11. files/16/I.py
134
3.5
4
max_line = '' for line in open('../words.txt').readlines(): if len(line) > len(max_line): max_line = line print(max_line)
b351ed803ea920877dcbb23c60cb2281ed74a80d
matheusmendes58/Python-Fundamentos-2-
/jogo impar ou par.py
1,253
3.703125
4
import random from time import sleep print('vamos jogar PAR ou IMPAR') print('-=' * 30) v = 0 while True: computador = random.randint(0, 10) user = int(input('digite um valor:')) print('---' * 30) PI = str(input('Par ou Impar? [P/I]')).strip().upper()[0] if PI != 'P' and PI != 'I': ...
8eb006777dd26d0a5a13a6d50f961cb0b8036295
matheusmendes58/Python-Fundamentos-2-
/aprovando emprestimo.py
419
3.75
4
vc = float(input('Qual valor da casa: R$')) s = float(input('Qual o seu salario: R$')) f = int(input('quantos anos de financiamento: R$')) pre = vc / (f * 12) po = (s * 30) / 100 print('Para pagar uma casa de R${} em {} anos ' '\na prestação será de R$ {:.2f}'.format(vc, f, pre)) if pre <= po: print('...
607639ca77b9d8f72182dd9252e477ad6d6e107a
matheusmendes58/Python-Fundamentos-2-
/Tratando varios valores.py
292
3.75
4
c = 0 total = 0 numeros_digitados = 0 while c != 999: c = int(input('digite um numero [999 para parar]:')) numeros_digitados = numeros_digitados + 1 total = total + c print('voce digitou {} numeros e a soma entre eles foi {}'.format(numeros_digitados - 1, total - 999))
13b42d464e58693989a235e8d04d7f15933eee63
matheusmendes58/Python-Fundamentos-2-
/Simulador Caixa eletronico.py
675
3.6875
4
print('=' * 30) print('{:^30}'.format('BANCO CCC')) print('=' * 30) saque = int(input('Que Valor vcoçê quer sacar R$:')) total = saque cedula = 50 total_cedula = 0 while True: if total >= cedula: total -= cedula total_cedula = total_cedula + 1 else: if total_cedula > 0: ...
34e32aa027daabdb1d848c83c17c398b866e3c76
r-portas/cosc3000
/assignment2/parse.py
2,883
3.734375
4
""" Parses the input data and does the following operations - Loads the CSV dataset - Geocodes city names to latitude and longitude - Exports the data as JSON """ import argparse import csv import json import urllib.parse import urllib.request import os import time import tableprint GEOCODE_API_KEY = os.environ.get(...
b308814afff9dda0ff57ce489fe9219843609fe9
saikishore-py/python-assignment-7
/natural.py
108
4
4
#program to print natural numbers num = 10 i = 1 while i <= 10: print("i=", i) i= i+1
f6dc87d39c8284e9db36c5b13666cf362423ad37
kumaravinashm/Python-Question
/Random/dayofdate.py
215
3.640625
4
def dayofweek(d, m, y): t = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4] y -= m < 3 return ((y + int(y / 4) - int(y / 100) + int(y / 400) + t[m - 1] + d) % 7) # Driver Code day = dayofweek(1, 1, 1) print(day)
e822d481cb5f012b86ac2fa93873c042cfddd197
kumaravinashm/Python-Question
/Random/sort012.py
394
3.671875
4
def sort(a): lo = 0 hi = len(a)-1 mid = 0 while mid <= hi: if a[mid] == 0: a[lo], a[mid] = a[mid], a[lo] lo=lo+1 mid=mid+1 elif a[mid]==1: mid=mid+1 else: a[hi], a[mid] = a[mid], a[hi] hi = hi -1 arr = [1...
e9e75565f2f79ebe68bb8645bf579222d01317c5
Warrior-X/yaag-mme
/yaag_mme/utils.py
928
4.1875
4
import re def is_blank(string): """ This function returns if the string is blanks or not. Args: string(str): The string to check. Returns: bool: Whether the string is blank """ return re.match(r"^\s*$", string) def lower_equals(string, match): """ This function returns ...
4ce47364a5c332533aabdaaf40f708cac6bb0a08
pietroastolfi/Walking-bus-challenge
/src/dat_parser.py
1,280
3.515625
4
from pulp import Amply def get_data(file_path): """ Get the data contained in the Ampl input file :param file_path: the file_path of the input file :return: An object that contains the data contained in the input file """ # I put in file_content the content of the file with open(file_path...
ac0293c31810d235b9288806e6a1f9de1dfad7bc
kaushikd13/tasks
/programs/tablebook.py
450
3.90625
4
print(" MULTIPLICATION TABLE BOOK") counter = 1 table_number = 1 while table_number <= 20: for counter in range(1, 21): product1 = table_number * counter product2 = (table_number + 1) * counter print("%2d x %2d = %3d\t " %(table_number, counter, product1), end = ' '); print(...
5f979681cdcefddcad4a9baf9d0bcf12627d64b4
OscarHChung/Time-Calculator
/main.py
1,530
3.859375
4
def add_time(start_time, added_time, start_date = ""): days_passed = 0 start_temp = start_time.split()[0] start_hour = int(start_temp.split(":")[0]) start_min = int(start_temp.split(":")[1]) added_hour = int(added_time.split(":")[0]) added_min = int(added_time.split(":")[1]) final...
18bd13bcccca3d498667b2c35a8530f4588360bf
sku0x20/DefineBot
/src/main/Word.py
1,096
3.71875
4
from dataclasses import dataclass from typing import Dict, List @dataclass(frozen=True) class Word: word: str homographs: List["Homograph"] # just for sake; we are only checking weather two word strings match, # if they do, we return true, since a word should be unique in itself # it can have dif...
c87eec8cb9875de6f1f64f917bcadd2fcd50f1e8
crystalDf/Grokking-Algorithms-Chapter-04
/Max.py
143
3.765625
4
def find_max(arr): if len(arr) == 0: return 0 else: return max(arr[0], find_max(arr[1:])) print(find_max([2, 4, 6]))
81cd6c9dd7b14577287c3f57594691634a16c7f1
dxfl/ud120-projects
/svm/svm_author_id.py
1,721
3.578125
4
#!/usr/bin/python """ This is the code to accompany the Lesson 2 (SVM) mini-project. Use a SVM to identify emails from the Enron corpus by their authors: Sara has label 0 Chris has label 1 """ import sys from time import time sys.path.append("../tools/") from email_preprocess import preproce...
5d660e4a4a134a6773418e7292e23ce4a8542b36
mariya347/Maze-game
/Level2.py
8,135
3.8125
4
import turtle import math wn=turtle.Screen() wn.bgpic("Background.png") wn.title("A Maze Game") wn.setup(700,700) wn.tracer(0) #set score on a screen score=turtle.Turtle(visible=False) # For time output score.penup() score.setposition(300, 300) # In this position I want to output variable score.write("...
fb5dbcb0f6b2f975f81c1d22ab7370d9bff6732c
bilash-biswas/1040
/Python.py
505
3.640625
4
p,q,r,s = input().split() a = float(p) b = float(q) c = float(r) d = float(s) v = (a * 2 + b * 3 + c * 4 + d * 1) / 10 print("Media: {0:.1f}".format(v)) if v >= 7.0: print("Aluno aprovado.") elif(v >= 5.0): print("Aluno em exame.") e = float(input()) print("Nota do exame: {0:.1f}".format(e)) f = (v ...
700a3188b70be336452b11dc5dba2792e392e683
reybalgs/students-and-monobears
/ai_solver.py
15,055
3.71875
4
# ai_solver.py # # Python file containing the source code for the game's AI. import random, pdb from student import * from monobear import * class Node(): def print_node(self): """ Prints the node. """ print('<' + str(self.cannibals) + ',' + str(self.missionaries) + ',' + ...
988279824587bcd74579b67d526ddfb6b5a55ecd
chandresh189/REGex-ONLINE-Training-2020
/Rakhi Pareek/Python Task 5/ass5.py
822
3.75
4
# Question - 5 """ WhatsApp texting using webbrowser Lib. """ import webbrowser as wb import time import pyautogui as g send = False print(time.ctime()) number = int(input("Enter the number to send message: ")) message = input("Enter your message") YourTime = input("Enter time to send message(hh:mm:ss...
6935a21fcb3b8a1d413fc4334809d58f0708e0f6
chandresh189/REGex-ONLINE-Training-2020
/Shubhang Vats/Python-Task 6/question7.py
1,118
3.859375
4
# Question - 7 """ 7. #### MAIN TASK #### - To scrap data from worldometer example: INDIA Data and run it on live mode. - Print Additionally total number of Coronavirus Cases, Deaths, Recovered. """ import requests #handles the http requests from bs4 import BeautifulSoup # used to pa...
88ad99fdfdebb81c77deb5338fe129012bc37354
chandresh189/REGex-ONLINE-Training-2020
/Rakhi Pareek/Late Night Task-7(Final task of Python)/late_night.py
1,359
3.8125
4
''' Late Night Task You have to Make a WhatsApp Script -> Till now we have seen about sending message in WhatsApp through Python using Webbrowser. -> run a program and send a same message to 6 persons through a script. -> Script to send "Hi" 5 times to a friend ''' import webbrowser as w...
40a9d21d0f8178d7f8c6ef823ec7059371ff31e3
EWiliams0590/Spotify
/GetSongDataFromSearch.py
1,742
3.984375
4
### Get the song, track, and track id for songs from a spotify search ### for provided years and genres. Note that the amount of searching done per ### genre/year combination is 1000. import numpy as np import pandas as pd def get_track_id(spotify, years, genres, N): """ Parameters ---------- ...
5d133604d16aba2be2dde88c514a956f54a622e9
Rjt17/Python
/automate_the_boring_stuff-with_python/name_loop.py
173
3.921875
4
#!/usr/bin/env python print("please enter your name.") name = raw_input() while name != "your name": print("please enter your name.") name = raw_input() print("thank you")
02ddaf6fb341c30574d9d3e07606c54307be1060
Rjt17/Python
/rock_paper_scissor.py
1,503
3.953125
4
import random #1 = rock #2 = paper #3 = scissor computer = 0 human = 0 player = input("enter your name\n") while True: number = random.randint(1,4) print('\nchoose one number\n1.rock\n2.paper\n3.scissor\n4.see scorecard\npress enter to exit') user_input = input("") if user_input == "": break elif int(use...
b19df0edde9d763517c3a2b72ec57cace6f78600
Rjt17/Python
/automate_the_boring_stuff-with_python/script_example.py
3,068
4.5625
5
#!/usr/bin/env python # work with strings # Strings can be concatenated (glued together) with the + operator, and repeated with *: word = 'Help' + 'A' print word print '<' + word*5 + '>' # Two string literals next to each other are automatically concatenated; # the first line above could also have been written "...
e548659b80eea88145a08d5ede7c0c8eb5a4afb0
Rjt17/Python
/python scripting/my_tcp_server.py
394
3.5625
4
#!/usr/bin/env python import socket bind_ip = "127.0.0.1" bind_port = 12345 server = socket.socket() server.bind((bind_ip,bind_port)) print("socket is binded to %s" %(bind_port)) server.listen(100) print("[*] Listening on {}:{}".format(bind_ip,bind_port)) while True: client, addr = server.accept() print("got con...
9ccba41a3ba3ce1f5422092019aa278649f186c7
Rjt17/Python
/automate_the_boring_stuff-with_python/regex.py
376
4.40625
4
#!/usr/bin/env python import re phoneNumRegex = re.compile(r'(\d{3})-(\d{3})-(\d{4})') mo = input("enter a phone number:") searchResult = phoneNumRegex.search(mo) if searchResult != None: print(f"The entered phone number {searchResult.group(1)}-{searchResult.group(2)}-{searchResult.group(3)} is a phone number.") ...
8d66bde1b9a423bf98a39525766703f84219419f
Rjt17/Python
/automate_the_boring_stuff-with_python/test_program.py
875
4.03125
4
#!/usr/bin/env python s = input("enter the new string to encrypt") s_length = len(s) texts = s.split(" ") texts.reverse() encryptedString = "" lowercaseLessM = {'b':2, 'c':3, 'd':4, 'f':6, 'g':7, 'h':8, 'j':10, 'k':11, 'l':12} lowercaseMoreM = {'n':14, 'p':16, 'q':17, 'r':18, 's':19, 't':20, 'v':22, 'w':23, 'x':24, 'y...
6f9cdbf8af7137fab3258868afd267fe39240768
4g/reinforce
/classic_control/mountain-car.py
4,636
3.59375
4
# -*- coding: iso-8859-15 -*- """ --Learning to balance a pole-- learn a q-network, which learning the q function directly from (s,a,r,s') http://neuro.cs.ut.ee/demystifying-deep-reinforcement-learning/ As per https://arxiv.org/pdf/1312.5602.pdf """ import gym from keras.layers import Dense, Input, concatenate from...
aa391d5277752b73eb5bee00051e37b97acfcfdc
pykili/py-204-hw1-lilovyjgrib
/task_7/solution_7.py
325
3.8125
4
word = input() rev_word = '' len_count = 0 i_index = 0 a_index = 0 for letter in word: len_count += 1 for i in word: for a in word: if a_index == len_count - i_index - 1: rev_word += a a_index += 1 a_index = 0 i_index += 1 is_palindrom = rev_word == word print(is_palind...
14f4532f77a9e1349e7621099b6c962d7e2636b9
akshatsi/Python-Basic-Codes
/6th.py
210
3.765625
4
a = int(input("enter marks")) b = int(input("enter marks")) c = int(input("enter marks")) d = int(input("enter marks")) e = int(input("enter marks")) total = a + b + c + d + e avg = total / 5 print(total, avg)
56946e3ae97f4873c14b1e0e963145ae62a27df9
rafaan/stanford-algorithms-design-and-analysis
/sorting/quicksort.py
1,536
3.59375
4
import random import numpy as np def partition(array, l, r): p = array[l] i = l + 1 for j in range(l+1, r+1): if array[j] < p: new_i, new_j = array[j], array[i] array[i], array[j] = new_i, new_j i += 1 new_l, new_i_minus_one = array[i-1], array[l] array...
cbb5631051d22124f8d61837c17bdd3f78dbb043
bcnishi/pomodoro
/tasks.py
8,003
3.53125
4
import pandas as pd import numpy as np import os import time import matplotlib import matplotlib.pyplot as plt def create(): """Verify if the csv archive already exists, if so do nothing. If the archive doesn't exist, create the dataframe and write in a csv archive""" if os.path.exists("pomodoro.csv"): ...
bc7b70c2f302bc843b11c7b30650554b07331612
TheIncredibleK/SecurityLabs
/Lab1/CaeserLab1.py
486
3.734375
4
def caesar(s, k, decrypt=False): if decrypt: k = 26 - k r = "" for i in s: if (ord(i) >= 65 and ord(i) <= 90): r += chr((ord(i) - 65 + k) % 26 + 65) elif (ord(i) >= 97 and ord(i) <= 122): r += chr((ord(i) - 97 + k) % 26 + 97) else: r += i ...
328b1cb7b2ca61a5b9a3f4c1df109f39e206c3ff
JASONews/Coding-Day-by-Day
/Maximum Product Subarray 10.4/Maximum Product Subarray.py
675
4.09375
4
""" Find the contiguous subarray within an array (containing at least one number) which has the largest product. For example, given the array [2,3,-2,4], the contiguous subarray [2,3] has the largest product = 6. """ class Solution(object): def maxProduct(self, nums): """ :type nums: List[int] ...
baef17bfa3afe3f817a96363544ca5fab279fb3a
JASONews/Coding-Day-by-Day
/Word Break 10.2/Word Break.py
1,000
3.71875
4
"""Leetcode Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. For example, given s = "leetcode", dict = ["leet", "code"]. Return true because "leetcode" can be segmented as "leet code". Solution: DP arr[i] represents ...
d20a2e6bc9ed9048a3cb5181530d0acb0be5a124
JASONews/Coding-Day-by-Day
/Maximal Square 10.3/Maximal Square.py
1,044
3.71875
4
"""Leetcode Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area. For example, given the following matrix: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 Return 4. Solution: DP arr[i][j] represents the length of square end at matrix[i][j] """ class Solution(o...
dd19b7c6085be06d8570cc8a6bf6fe6558d62fbb
kratosowarlord/BigData2P1-Apriori
/Ques_1.py
653
3.5625
4
#%% import pandas as pd import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [10, 6] plt.xlabel("Items") plt.ylabel("Sales") data = pd.read_csv(r"BreadBasket_DMS.csv") #Now we will firstchange index to item to sort items into new datasets without 'NONE' type of Items. items = data.set_index(['Item']) New...
3183daf402c3a64f4fe057b6a7d8df771741e977
dichosito/Python-test
/calculo.py
490
4.0625
4
import sys def Fibonacci(n): if n<0: sys.exit("El numero ingresado no es positivo") else: a=1 b=1 if n==1: print('0') elif n==2: print('0','1') else: for i in range(n-3): tota...
2c8834feb169b3f367863d6df8b0ba71bee14cc7
ukrserhiy/Python_beetroot
/math_quiz_program.py
954
4.34375
4
##The math quiz program. ##Write a program that asks the answer for a mathematical expression, ##checks whether the user is right or wrong, and then responds with a message accordingly. import string import random digitals = string.digits math_opers = ('+','-','*','/') first_element = random.choice(digitals) second_el...
5840200119815d4f57eb92ddba690807fff10bc3
Duaard/ProgrammingProblems
/HackerRank/Easy/QuickSort4/solution.py
2,235
4.09375
4
#!/bin/python3 def insertion_sort(arr): # Record the number of shifts performed shifts = 0 # Loop through each element in arr starting from arr[1] for elem in range(1, len(arr)): # Save the current indexed val val = arr[elem] # Loop through the array starting from elem index to...
be42208338d7906454f4bdb4f306853e56d19009
Duaard/ProgrammingProblems
/HackerRank/Easy/Gemstones/solution.py
560
3.578125
4
#!/bin/python3 import os def gemstones(arr): # Create the set that will hold all intersection gemStones = None for a in arr: if gemStones == None: gemStones = set(a) else: gemStones = gemStones & set(a) return len(gemStones) if __name__ == '__main__': fpt...
ba843fbcee6db0846dedc9463c1bc5a540ac0b34
Duaard/ProgrammingProblems
/HackerRank/Easy/QuickSort1/solution.py
794
4.15625
4
#!/bin/python3 import math import os import random import re import sys def quickSort(arr): # Get the pivot number pivot = arr[0] # Save all the subsets for each array left, equal, right = [], [], [] # Loop through the array to get each subset for num in arr: if num < pivot: ...