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
4289df499b54c520185c5d719956cc70cc9ef59c
jerinphilip/massive-multilingual-sentence-embeddings
/mmse/utils/logging.py
521
3.5625
4
from numbers import Number from collections import OrderedDict def _format(val): default = lambda x: x cases = OrderedDict([ (float, lambda x: '{:.3f}'.format(x)), (int, lambda x: '{}'.format(x)), ]) for key in cases: if isinstance(val, key): return cases[ke...
ef47c071219b5964290c6802f8006a639abf1955
amylearnscode/CISP300
/Lab 8-5.py
2,270
4.1875
4
#Amy Gonzales #March 21, 2019 #Lab 8-5 #This program uses while loops for input validation and calculates #cell phone minute usage def main(): endProgram = "no" minutesAllowed = 0 minutesUsed = 0 totalDue = 0 minutesOver = 0 while endProgram=="no": ...
a3a02e0cacafaa398e472821aa6a05292d14b43b
amylearnscode/CISP300
/lab 2-7.py
861
3.796875
4
#Amy Gonzales #Lab 2-7 February 7, 2019 #This program calculates state and county tax. def main(): monthlySales= inputSales() countyTax = calcCounty(monthlySales) stateTax = calcState(monthlySales) totalTax = calcTotal(countyTax, stateTax) printInfo(countyTax, stateTax, totalTax) def in...
e5333a6c49c6107e14d2e2a36848b6931bccc4cb
Luciana1012/Intech
/API/public API.py
782
3.921875
4
import requests # import the necessary library cookie = None # Save your username as cookie in your code! 1 # Ask user which options/operations they would like to do. Keep looping until the user decided to exit while True: mode = input("Please select an operation") if mode == "1": response = reques...
97b54f212f883ae8625888c5c3fedebdd761caa9
ShizhongLi/Data-Analysis
/investigate texts and calls/Task1.py
988
4.1875
4
""" 下面的文件将会从csv文件中读取读取短信与电话记录, 你将在以后的课程中了解更多有关读取文件的知识。 """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ 任务1: 短信和通话记录中一共有多少电话号码?每个号码只统计一次。 输出信息: "There are <count> different te...
82fc95d5d86f08c337f3823f0bd147c142f8c69e
floydnunez/Project_Euler
/problem_004.py
852
4.21875
4
""" A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. """ import math def check_palindrome(number): is_palindrome = True str_num = str(number) size...
5e24dee4392d9f9e6cc2f5cd6720834ecc8a6dab
heinervdm/MysticMine
/monorail/tiles.py
24,792
3.703125
4
"""Tiles, trails, etc. """ import math import struct import copy from random import randint import pygame from koon.geo import Vec3D, Vec2D from koon.res import resman class Direction: """A wind direction Don't use constructors, but use: Direction.NORTH Direction.EAST Direc...
481960e5f76464a710e1b11148005fd43d9ec1f5
swaroopsaikalagatla/Python
/python9.py
159
3.6875
4
def greatest(*nos): result = nos[0] for num in nos: if num > result: result = num return result print(greatest(10,50,30))
9b6ed13e70dcb0706ea37b9c4d36b8e838d7965a
swaroopsaikalagatla/Python
/python5.py
267
4.125
4
def maximum(a,b,c):#function list=[a,b,c]#statement 1 return max(list)#statement 2 x=int(input("Enter the first number : ")) y=int(input("Enter the second number :")) z=int(input("Enter the third number :")) print("biggest number is :",maximum(x,y,z))
a977ff1631c584a92ec24817828c5c7e67996653
NickBarraclough/CS325-AnalysisOfAlgorithms
/HW 3/knapsack.py
1,707
3.6875
4
######################################################################### # Nick Barraclough # CS325 Analysis of Algorithms # 2/7/2020 # Homework 3 Problem 3 - 0/1 Knapsack: Recursive vs Dynamic Programming ######################################################################### import random import time # RECURSIV...
acdda0fa4bceeaf72b4b94836f606591b7141a6c
joook1710-cmis/joook1710-cmis-cs2
/assignment1.py
2,319
4.3125
4
#Created a variable and defined my name. myName = "Joo Ok Kim" print myName #Created a variable and defined my age. myAge = 16.4 print myAge #Created a variable and defined my height. myHeight = 1.65 print myHeight #Created a variable and defined the length of a sqaure. lengthOfSquare = 4 print lengthOfSquare #Cre...
9ec775fc60d2b79769dee316e6905a9e31927a26
joook1710-cmis/joook1710-cmis-cs2
/newguess.py
255
3.671875
4
def game(): if guess > targetnumber: print "The number is too low." elif guess < targetnumber: print "The number is too high." elif guess == targetnumber: print "You guessed the right number!" def main(): main()
1362a39f7084df60f86894c00c920958a6bc5ad1
indykiss/DataStructures-Algos
/Leetcode/Python Easies/Replace_digits_w_chars.py
532
4.1875
4
# Replace All Digits with Characters # Input: s = "a1c1e1" # Output: "abcdef" # Explanation: The digits are replaced as follows: # - s[1] -> shift('a',1) = 'b' # - s[3] -> shift('c',1) = 'd' # - s[5] -> shift('e',1) = 'f' class Solution: def replaceDigits(self, s: str) -> str: res = '' f...
c019d27e0a66b79d8c4e2574a1f624690cfee96a
indykiss/DataStructures-Algos
/Leetcode/Python Easies/Valid_mt_arr.py
695
3.84375
4
# Valid Mountain Array # Given an array of integers arr, return true if and only if it is # a valid mountain array. # 1 peak and zero valleys # Strategy: # Iterate and count peaks/ valleys # Only one peak in the array of nums and 1 valley class Solution: def validMountainArray(self, arr: List[int]) -> bool:...
d188094ab7f49953d1ed4971cbf086f9aa90d1bb
indykiss/DataStructures-Algos
/Leetcode/Heaps - Top K/Heaps.py
870
3.71875
4
# Last Stone Weight # Input: stones = [2,7,4,1,8,1] # Output: 1 # Explanation: # We combine 7 and 8 to get 1 so the array converts to [2,4,1,1,1] then, # we combine 2 and 4 to get 2 so the array converts to [2,1,1,1] then, # we combine 2 and 1 to get 1 so the array converts to [1,1,1] then, # we combine 1 and 1 to...
95197ff6e7c18853981845ebb1fc486d94068bbe
indykiss/DataStructures-Algos
/Leetcode/Trees/Binary_tree_pruning.py
883
3.921875
4
# Binary Tree Pruning # Given the root of a binary tree, return the same tree where # every subtree (of the given tree) not containing a 1 has been removed. # A subtree of a node node is node plus every node that is a # descendant of node. # Definition for a binary tree node. # class TreeNode: # def __init__...
12025a813dc4b0c2115947a68caf586504b271ad
indykiss/DataStructures-Algos
/Leetcode/Company specific/G.py
5,389
4.21875
4
Counting Words With a Given Prefix You are given an array of strings words and a string pref. Return the number of strings in words that contain pref as a prefix. A prefix of a string s is any leading contiguous substring of s. Google Let's say the words in the dictionary are sorted Strategy: Better answer: Binar...
80e6af30145862b1fe6b0058b70f71115b69f174
indykiss/DataStructures-Algos
/Leetcode/Sliding window/Longest_repeating_char_replace.py
2,717
3.921875
4
Longest Repeating Character Replacement Given a string with lowercase letters only, if you are allowed to replace no more than ‘k’ letters with any letter, find the length of the longest substring having the same letters after replacement. "aabccbb", k=2 Output: 5 Explanation: Replace the two 'c' with 'b' to have ...
95e1b9576d1227e9bbe48ad5045c65f55605fb8e
indykiss/DataStructures-Algos
/Leetcode/Python Easies/Anagram_mappings.py
878
4.15625
4
# Find Anagram Mappings # You are given two integer arrays nums1 and nums2 where nums2 is # an anagram of nums1. Both arrays may contain duplicates. # Return an index mapping array mapping from nums1 to nums2 where # mapping[i] = j means the ith element in nums1 appears in nums2 at index j. # If there are multiple...
12af45a4bc48c4eb1ee19f93f824c0a45c8e5850
timmynth/GeoNewsClassify
/classification/orientaldaily_past_spider.py
4,590
3.625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from html.parser import HTMLParser from urllib.request import urlopen from urllib import parse from bs4 import BeautifulSoup # We are going to create a class called LinkParser that inherits some # methods from HTMLParser which is why it is passed into the definition class ...
d52cfe731bdb5da080e3c93850c6d0f7d0cb84e9
gailmccolgan/SciBridge.Temperature-Dependence-of-Solar-Cells
/learning-python/SciBridge/daily_efficiency_gui.py
14,137
3.78125
4
# need to get tkinter GUI from tkinter import * # need to get matplotlib import matplotlib matplotlib.use("TkAgg") from matplotlib.figure import Figure from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg # create the main window, object named root root = Tk() # giving title to the main window root.title("...
efaabae63cbd556d6e1a3d52a1bb39d61a163fab
Zahidsqldba07/codingbat-programming-problems-python
/Solutions/string-2/end_other.py
579
4.1875
4
# Given two strings, return True if either of the strings appears at # the very end of the other string, ignoring upper/lower case differences # (in other words, the computation should not be "case sensitive"). # Note: s.lower() returns the lowercase version of a string. # end_other('Hiabc', 'abc') → True # end_other(...
55abceb1ba77b7dd223b4f92a776fce334421991
HTaylor7486/projects
/projects/HT.py
1,327
3.546875
4
import mcpi.minecraft as minecraft,time#impots moduals mc = minecraft.Minecraft.create()#sets the minecraft modual to mc #x,y,z = mc.player.getPos() x = int(raw_input("please enter x"))#sets x to an interger that is gotten from the user y = int(raw_input("please enter y"))#sets y to an interger that is gotten from the ...
55ea429df48b2ae917a8239f40e1a12acad1179d
yasu094/learning-python
/10-calendars.py
1,139
4.15625
4
import calendar # print a text calendar (week start day is Sunday) c = calendar.TextCalendar(calendar.SUNDAY) str = c.formatmonth(2020, 1, 0, 0) print (str) # create an HTML formatted calendar hc = calendar.HTMLCalendar(calendar.SUNDAY) str = hc.formatmonth(2020, 1) print (str) # loop over the days of a month # zero...
14ae952a36f7f39aca963fafbee8516a50737f50
alfredoimc/curso_python
/pes.py
178
3.84375
4
class altura(object): m = 0 def __init__(self, m): self.m = m m = input('digite sua altura \n') pes = m*3.2808 print('sua altura em pes eh', pes, 'ft')
d3781248c9f12172fd6b0faac8ffb749ecb1be95
laurent-vigneron/FreeCodeCamp
/8-Data_Analysis_with_Python_Certification/5-Sea_Level_Predictor/sea_level_predictor.py
1,381
3.5625
4
import pandas as pd import matplotlib.pyplot as plt from scipy.stats import linregress def extrapolate(x, y, start, end): # first, determine the slope of the line (slope, intercept, rvalue, pvalue, stderr) = linregress(x, y) # then, build the x and y 'coordinates' based on the required range x_fut = [i...
fc74fe344919966935cef5b6eb206e92564af881
nseetim/Hackerrank_challenges
/String_Validators.py
2,562
4.34375
4
''' Python has built-in string validation methods for basic data. It can check if a string is composed of alphabetical characters, alphanumeric characters, digits, etc. str.isalnum() This method checks if all the characters of a string are alphanumeric (a-z, A-Z and 0-9). >>> print 'ab123'.isalnum() True >>> print ...
d211881f2dd07dcf9448dc10a04e4cca835ceff1
aounathyakrao/python
/add.py
110
3.734375
4
#printing the values a=30 b=60 print("value of a is:") print (a) print("value of b is:") print (b) print (a+b)
d6ccb37a5d3449701e5a2ff8a03174175706f615
chvnaveenkumar/Crypto-Markets
/Problem2/sort.py
400
3.6875
4
newinput = open("aftermapper.txt","r") # a new input file with mapper output is opened newoutput=open("sort_output.txt","w") # a new output of the sorted file is opened with write privilage data = newinput.readlines() #new lines from data file is fed to 'data' data.sort() # all the values in the data are sorted her...
389c06f6623f6339d9d0e4a066c6f804b4ac06cc
aldew5/Speaking-Tool
/markers.py
1,842
3.703125
4
import numpy as np import cv2 from cv2 import aruco from augment import * import time class Marker(object): """ An abstract class that defines some methods all markers in the program will use """ def __init__(self, id, eindex, image, frame, corners, frame_width, frame_height, console): sel...
e3fe3361f1e60e9f48f09d37c0de75e224df46d8
RiChrisMurphy/HackerRankAnswers
/TheMinionGame.py
522
3.625
4
__author__ = 'chrismurphy' def find_substring(str_ing): vowel = ["A", "E", "I", "O", "U"] Stuart = 0 Kevin = 0 for x in range(0,len(str_ing)): if str_ing[x] in vowel: Kevin += (len(str_ing)-x) else: Stuart += (len(str_ing)-x) if(Stuart>Kevin): prin...
819f06ff47d9843a78fb41d30b6960ab7c77c710
PapaGateau/Python_practicals
/089-Safe_list_get/safe_list_get.py
629
4.15625
4
def recuperer_item(liste, index): """function to get and element form a list using its index incorrect indexes are protected and will return an error string Args: liste ([list]): [list searched] index ([int]): [index of searched element] Returns: [str]: [list element or error s...
8aaf4ee554a9442eb492bdfe52cf592da07b7bdb
yanyudefensi/DataStructureAndAlgorithm
/pythonProject/数据结构/LinkList.py
11,954
3.921875
4
# 单项链表实现栈 class LinkedStack: # 轻量级节点类 class _Node: __slots__ = '_element', '_next' def __init__(self, element, next): # 初始化一个新节点 self._element = element self._next = next # 栈堆 def __init__(self): self._head = None self._size = 0 def __l...
69715247197c70bd80a216149c4b7a7ca5b9a173
praveenkumarcs/socialMediaAnalysis
/featureVector.py
1,192
3.515625
4
# import re module import re #importing stopwords from nltk from nltk.corpus import stopwords #This is the script manually coded import preprocessTweets stopWords = stopwords.words("english") def replaceRepeatingChars(word): prev,freq = word[0],0 for char in word[1:]: if char == prev: freq += 1 continu...
f0732f07bbdb369d092c7807cdd35240566efef0
chenweizhong-beep/phthon01
/objectdemo/game01.py
1,259
3.5625
4
class Games(): my_power: int = 200 enemy_power: int = 199 def __init__(self, my_hp, enemy_hp): self.my_hp = my_hp self.enemy_hp = enemy_hp def fight(self): while True: self.my_hp = self.my_hp - self.enemy_power print(self.my_hp) self.enemy_hp...
0352f384d8bf682d874ba47fa8e5dc88d1dfdbbd
Alexkvintin/PyBase08
/lesson03/hw_3_2.py
654
3.578125
4
import math def nok(x, y): print("НОК чисел a и b =", x * y // math.gcd(x, y)) c = input("что-бы посчитать НОК нажмите ENTER ") while c != None: try: print("введите целые положительные числа а и b") a = int(input("a: ")) b = int(input("b: ")) nok(a, b) c = int(input(...
05e9b270bf0c76dbf5adc46697ab603cf59ba990
linhndt/stock_predict_interface
/descriptive.py
14,790
3.90625
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt from mpl_finance import candlestick_ohlc import matplotlib from sklearn import preprocessing from data_gathering import gather_data def count(df): """ Count the number of rows in a data frame Return the data frame counting number of...
75ae0caa5ecf1dcd6e792bdb770f499d67e39760
BhagyashreeKarale/function
/predefinedf.py
1,179
3.859375
4
# Pre-defined Functions Questions # Ab aapko kuchh questions solve krna hai pre-define function ka use kr ke. # Q1 . Aapko max function ka use krke di hue list me se sbse bada value print krvani hai. # Input numbers = [3, 5, 7, 34, 2, 89, 2, 5] print(max(numbers)) # Output :- 89 # Q2. Aapko sum function ka use krk...
dcf82c1d994f980388094411e11da0c36af8b939
BhagyashreeKarale/function
/output2.py
1,629
4.28125
4
# def primeorNot(num): # if num > 1:#it will only take numbers more then 1,not even 1 # for i in range(2,num):#all the numbers from 2 to the given number.i.e in this case 406 # if (num % i) == 0: # print(num,"is not a prime number") # print(i,"times",num//i,"...
ab111b6810f7652e3f3b52e2eb1934971f8484c9
BhagyashreeKarale/function
/palindrome.py
622
4.375
4
# Write a Python function that checks whether a passed string is palindrome or not. def palindromecheck(string): rlist=(string[::-1]) if rlist == string: print("It is a palidrome") else: print("It isn't a palidrome") # another one for palidrome: def palidromecheck2(string): left_pos = 0 ...
fb8e839c9384d9a1b7f22230a89822ec453ffd58
BhagyashreeKarale/function
/2ques1.py
466
3.984375
4
# eligible_for_vote name ka function likho jo ki user ko bataye ki vo # (he/she) vote de sakta hai ya nahi. ( Consider minimum age of voting to be 18. ) # Example:- Agar user input me 18 se kam deta hai to “not eligible “ print kare # aur agar user 18 ya 18 se jyaada input kare to “you are eligible” print kare. def...
a9fa0889a3791ae0b2fd6bb0a80cc0cc80b72ffd
juanegido/PythonExs
/ex3.py
169
3.890625
4
a = [1, 1, 2, 3, 1, 8, 13, 21, 34, 55, 89] b = [] num = int(input("Give me a number: ")) for element in a: if element < num: b.append(element) print(b)
b19da2de09c9d5afa4e7c9c01b00d42a3f697780
Win-Htet-Aung/kattis-solutions
/datum1.py
197
3.59375
4
import calendar s = input() wd = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] d = int(s.split()[0]) m = int(s.split()[1]) print(wd[calendar.weekday(2009, m, d)])
fc58be5e9f980fb047220a57acca709e9001de6b
Win-Htet-Aung/kattis-solutions
/crackingRSA.py
397
3.65625
4
def is_prime(num): if num > 1: for i in range(2, int((num ** 0.5) + 1)): if num % i == 0: return i break # return True, 0 else: return False, 2 t = int(input()) for i in range(t): st = input() n = int(st.split()[0]) e = int(st.split()[1]) p = is_prime(n) # print(p, n) q = n // p pq = (p-1) * ...
7b9104c68936705b2373bde2069fb440c3ef2bb4
Win-Htet-Aung/kattis-solutions
/inversefacto.py
87
3.609375
4
facto = int(input()) n = 2 while facto // n != 1: facto = facto // n n += 1 print(n)
478d59a283a2dca53fad293389f61cedfcd04d2e
Win-Htet-Aung/kattis-solutions
/securedoors.py
380
3.671875
4
n = int(input()) log = [] for i in range(n): ent_exit, name = tuple(input().split()) if ent_exit == 'entry' and name in log: print(name, 'entered (ANOMALY)') elif ent_exit == 'entry' and name not in log: print(name, 'entered') log.append(name) elif ent_exit == 'exit' and name in log: print(name, 'exited') ...
6e03a148fa35fcd0d06b5189200d97b22afd3fb2
Win-Htet-Aung/kattis-solutions
/lastFacto.py
137
3.703125
4
t = int(input()) num = [1, 2, 4] for i in range(t): n = int(input()) if n >= 5: print(0) elif n in num: print(n) else: print(6)
0d8226309c9c529457d4de122a3ecff30a6a9db1
Win-Htet-Aung/kattis-solutions
/qaly.py
136
3.5
4
t = int(input()) tot = 0 for i in range(t): s = input() a = float(s.split()[0]) b = float(s.split()[1]) tot = tot + a * b print(tot)
fc1c6efa0ef6633c897d6aba044f30b78abe1d1a
Win-Htet-Aung/kattis-solutions
/baconeggspam.py
272
3.515625
4
n = int(input()) while n != 0: daily = {} for i in range(n): rec = input().split() name, food = rec[0], rec[1:] for f in food: daily.setdefault(f, []).append(name) for d in sorted(list(daily.keys())): print(d, ' '.join(sorted(daily[d]))) n = int(input())
6b87d13f3287506d9c9593de3c879877721c4a3a
Win-Htet-Aung/kattis-solutions
/alphabetSpam.py
393
3.765625
4
st = input() space = 0 upper = 0 lower = 0 symbol = 0 upperLis = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" lowerLis = "abcdefghijklmnopqrstuvwxyz" total = len(st) for i in st: if i == "_": space = space + 1 elif i in upperLis: upper = upper + 1 elif i in lowerLis: lower = lower + 1 else: symbol = symbol + 1 print(space...
2aa8b59021e6f63384bf9a09f1740152cfb5a340
Win-Htet-Aung/kattis-solutions
/babybites.py
200
3.578125
4
n = int(input()) s = input().split() i = 1 while i < n + 1: if str(i) != s[i - 1] and s[i - 1] != 'mumble': i = n + 2 i += 1 if i == n + 1: print('makes sense') else: print('something is fishy')
b2cd2de3f606d65607180279d62d86d2b3711a84
wougamer/zero-to-hero-pentesting
/2._week-2/python101.py
3,431
4.15625
4
#!/bin/python3 #Print string print("Strings and things:") print('Hello, world!') print("""Hello, this is a multi-line string!""") print("This is " + "a string") print('\n') #new line #Math print("Math time:") print(50 + 50) #add print(50 - 50) #subtract print(50 * 50) #multipy print(50 / 50) #divide print(50 + 50 ...
397b1ae59cdfed65341b1487d42eab007cf94cfe
momongss/Starcraft2AI
/#1. Works/최종/newNet_pysc2/newNet_pysc2/test.py
234
3.640625
4
import numpy as np from pysc2.lib.named_array import NamedNumpyArray a = NamedNumpyArray([1, 2, 3], ["x", "y", "z"]) b = NamedNumpyArray([4, 5, 6], ["x", "y", "z"]) print(a.shape) for i in range(len(a)): print(a[i]) print(a[-1])
1cf059ecebd42373c270e43e75fb0809a35e8857
Kaviprakash156/playerset1
/diffonlyonechar.py
151
4.125
4
string1 = input("Enter the first string:\n") string2 = input("Enter the Second string:\n") if string1 == string2: print ("NO") else: print ("YES")
c1acc52b003ee0326340a4ac2c9b2a395ed1643a
DanielFernandoYepezVelez/Fundamentos-Python
/18-EjerciciosComfenalco/05-CiclosQuintaClase/24.CompaniaAutomotriz.py
1,603
4.03125
4
numeroAutomoviles = input('Ingrese El Número De Automoviles Que Posee: ') acImpuestoCategoriaUno = 0 acImpuestoCategoriaDos = 0 acImpuestoCategoriaTres = 0 impuestoAutomovilUno = 0 impuestoAutomovilDos = 0 impuestoAutomovilTres = 0 i = 1 while i <= int(numeroAutomoviles): valorAutomovil = float(input(f'Ingrese El Va...
fa78625e9347e095937a81f272cfd909fc52a231
DanielFernandoYepezVelez/Fundamentos-Python
/18-EjerciciosComfenalco/04-DecisionesLogicasCuartaClase/07-NumeroMayor.py
528
4.25
4
numeroUno = float(input('Ingrese Un Numero Uno: ')) numeroDos = float(input('Ingrese Un Numero Dos: ')) numeroTres = float(input('Ingrese Un Numero Tres: ')) print('') if numeroUno > numeroDos and numeroUno > numeroTres: print(f'El Numero Mayor Es: {numeroUno}') elif numeroDos > numeroUno and numeroDos > numeroTre...
8adc894f3d9f759ba556e3f5038e058aff0b357e
DanielFernandoYepezVelez/Fundamentos-Python
/03-Operadores/07-FuncionesNumeros.py
988
4.15625
4
SEPARADOR = '-----------------------' def suma(a = 0, b = 0): print(a + b) print('\nSuma => ') suma(5.1, 4.9) suma(2.999, 33) suma(3) print(f'{SEPARADOR}\n') def resta(a = 0, b = 0): print(a - b) print('Resta => ') resta(12.2, .2) resta(5, 10) resta(5) print(f'{SEPARADOR}\n') def producto(a = 0, b = 0): ...
169c4e9aab46ef7a84a7b3ec7f8739dd0ca8dcba
DanielFernandoYepezVelez/Fundamentos-Python
/16-ManejoErrores/01-ExplicacionExcep.py
437
4
4
""" Capturar Excepciones Y Manejar Errores En Código Susceptible A Fallos/Errores """ try: nombre = input('¿Cual Es Tu Nombre?: ') if len(nombre) >= 1: nombre_usuario = 'El Nombre Es: ' + nombre print(nombre_usuario) except: print('El Nombre Del Usuario Es Obligatorio') else: print('El Co...
6a75951a51b194859009202dc2603615644ec38c
DanielFernandoYepezVelez/Fundamentos-Python
/18-EjerciciosComfenalco/05-CiclosQuintaClase/22-Vendedor.py
1,222
4.09375
4
ventasVendedor = int(input('Ingrese La Cantidad De Ventas Realizadas: ')) contadorVentasUno = 0 contadorVentasDos = 0 contadorVentasTres = 0 acVentaUno = 0 acVentaDos = 0 acVentasTres = 0 globalVentas = 0 iterador = 1 while iterador <= ventasVendedor: valorVenta = float(input(f'Ingese El Valor De la Venta #{itera...
3bb7b1ee0a9896295c779c40cb49bff953f639ef
DanielFernandoYepezVelez/Fundamentos-Python
/06-Ciclos/01-For.py
647
3.828125
4
contador = 0 resultado = 0 for contador in range(0, 10): print(f'Voy Por El Numero {contador}') resultado += contador print(f'El Resultado Acumulativo Es: {resultado}\n') print('##### TABLAS MULTIPLICAR ######') numberUser = int(input('Ingresar Un Numero: \n')) if(numberUser < 1): numberUser = 1 print(...
98e3cee68b685c3de14fc2cad18a8f20dd2b7dbc
DanielFernandoYepezVelez/Fundamentos-Python
/04-EntradaSalida/01-Input.py
183
3.609375
4
""" INPUT """ name = input('¿Cual Es Tu Nombre?\n') edad = input('¿Cual Es Tu Edad?\n') """ OUTPUT """ print(f'Me Alegro De Conocerte {name}, Tu Edad Es De {int(edad) + 2} Años')
94f8962a2ad2bfff65207d80ae5dc1d60870d888
DanielFernandoYepezVelez/Fundamentos-Python
/12-POO/04-Herencia/01-Restaurante.py
734
3.90625
4
class Restaurant: def __init__(self, nombre, categoria, precio): self.nombre = nombre self.__categoria = categoria #PRIVATE self._precio = precio # PROTECTED def mostrar_informacion(self): print(f'Nombre: {self.nombre}, Categoría: {self.__categoria}, Precio: {self._precio}') ...
d924bc7e14da2270ea730ebcef771abbe9cd065f
DanielFernandoYepezVelez/Fundamentos-Python
/11-Diccionarios/04-MasMetodos.py
944
4.15625
4
SEPARADOR = '--------------------' jugador = {} print(jugador) print(f'{SEPARADOR}\n') """ Para Agregar Un Nuevo Jugador Al Diccionario Vacio """ jugador['nombre'] = 'Danielito Fernandito' jugador['puntaje'] = 0 print(jugador) print(f'{SEPARADOR}\n') # Incrementando El Puntaje jugador['puntaje'] = 110 print(jugado...
0cb65dfc84e85288336179223983879a3b537493
DanielFernandoYepezVelez/Fundamentos-Python
/18-EjerciciosComfenalco/04-DecisionesLogicasCuartaClase/01-NoGemelos.py
366
3.96875
4
nombreUno = str(input('Ingrese El Nombre: ')) edadUno = int(input('Ingrese La Edad: ')) nombreDos = str(input('Ingrese El Nombre: ')) edadDos = int(input('Ingrese La Edad: ')) if edadUno > edadDos: print(f'Hermano Mayor es: {nombreUno}') elif edadDos > edadUno: print(f'Hermano Mayor es: {nombreDos}') else: ...
0894ec2c824ac79cfb8b762104812615ca8bd47c
mirror1982/Scripts
/p4i/computepay.py
354
3.78125
4
def computepay(h,r): if h > 40: p = ((h - 40) * 1.5 * r) + (r * 40) else: p = r * h return p try: inp = raw_input("Enter hours: ") hours = float(inp) inp = raw_input("Enter rate: ") rate = float(inp) except: print "error, enter a numeric symbol" quit() print "Sa...
b2aa27d1b8b02a74f90c4fd68c09debeb1c84a77
Preethi-Vannal/Preethi
/lab2_prog1_24thjan19(sinewave).py
281
3.546875
4
import numpy as np import matplotlib.pyplot as plot f1=input(" frequency for your signal") fs=input("enter your sampling frequency") x=np.arange(0,10,0.1) y=np.sin(2*np.pi*x*(float(f1)/float(fs))) plot.plot(x,y) plot.xlabel('sample') plot.ylabel('amplitude') plot.show( )
bd88bea647e67ba4246299ce6f01b9a1fba291c3
debkumar81/CPPI
/utility.py
6,388
3.5625
4
import pandas as pd import numpy as np import scipy.stats as st from scipy.optimize import minimize def price_return(price_series, window = 1, ret_type = "S"): """ Takes a time series of asset prices Based on "ret_type", calculates either simple return or log-return Default is simple return "window...
f248a68629b02b71bd7137eb956cb059a86673ad
AdrianKonca/TD_2020_44367
/LAB_10/hamming.py
3,818
3.53125
4
from utilities import make_ordinal def hamming_coding(bits): encoded_bits = [None] * 7 parity_bits = [None] * 3 parity_bits[0] = (bits[0] + bits[1] + bits[3]) % 2 parity_bits[1] = (bits[0] + bits[2] + bits[3]) % 2 parity_bits[2] = (bits[1] + bits[2] + bits[3]) % 2 encoded_bits[0] = bool(pari...
b9836cfb5a6b6b98394fbac4790f24fe1ca0c0a8
jshcs/cfe
/src/parsing/citationStringParser.py
3,616
3.578125
4
delimiter = [',','(',')'] def sepStrings(string,delimiter): res = [] temp = '' for s in string: if s in delimiter and temp!='': res.append(temp) temp = '' elif temp!='' or s!=' ': temp = temp...
806b2cc1abf640c6311ab9f24cd5e303cacad722
NathanCFoster/pythonBasics
/testing/functions_basic/basicClasses/classBank.py
1,097
3.59375
4
class User: def __init__(self, name, initDeposit): self.name = name self.balance = initDeposit def make_deposit(self, amount): self.balance += amount return self def make_withdrawl(self, amount): self.balance -= amount return self def display_user_balance(...
9122d94eea0b791c29a4482dd4d3910cd741aae1
ninaalli/Python-101
/BubbleSort.py
638
4.09375
4
def bubble_sort(data): idx = 0 end_idx = len(data)-1 while end_idx>0: idx=0 while idx<end_idx: if val > data[idx+1]: data[idx],data[idx+1] = data[idx+1], data [idx] idx + = 1 end_idx = 1 print bubble_sort use the name space Bubble sort is defined within global namespace def bubble_s...
8388e0dafd4bb15c75a519a43b4f1fa72ac590aa
Kagia001/Progress-bar
/progressbar.py
726
3.5625
4
class progressbar: """a progress bar""" def __init__(self, segmentNum, maxValue, minValue=0, startValue=0): self.maxValue = maxValue self.minValue = minValue self.Value = startValue self.segmentNum = segmentNum self.bar = '[' + '-'*self.segmentNum + ']' ...
90f0803347adc2ce934cd3aaa25fa3b0a2665536
xiangfuli/leetcode-py
/solutions/array/medium/Queries_on_a_Permutation_With_Key.py
3,435
3.75
4
# Given the array queries of positive integers between 1 and m, you have to proc # ess all queries[i] (from i=0 to i=queries.length-1) according to the following r # ules: # # # In the beginning, you have the permutation P=[1,2,3,...,m]. # For the current i, find the position of queries[i] in the permutation P (inde ...
0103df5fb0af34b664ae22cb943b8fbe3f5e8c45
xiangfuli/leetcode-py
/solutions/array/medium/Merge_Intervals.py
1,332
3.953125
4
# Given an array of intervals where intervals[i] = [starti, endi], merge # all overlapping intervals, and return an array of the non-overlapping # intervals that cover all the intervals in the input. # Example 1: # Input: intervals = [[1,3],[2,6],[8,10],[15,18]] # Output: [[1,6],[8,10],[15,18]] # Explanation: Since ...
9f37af2bc41ff3adcf822d185d0b3e55719a21b4
xiangfuli/leetcode-py
/solutions/array/hard/First_Missing_Positive.py
4,366
3.796875
4
# 41. First Missing Positive # Hard # 5445 # 965 # Add to List # Share # Given an unsorted integer array nums, find the smallest missing positive # integer. # Example 1: # Input: nums = [1,2,0] # Output: 3 # Example 2: # Input: nums = [3,4,-1,1] # Output: 2 # Example 3: # Input: nums = [7,8,9,11,12] # Output...
ec994acafbdba0a043d9c00f750f91dfca29c302
xiangfuli/leetcode-py
/solutions/array/medium/Spiral_Matrix.py
2,701
3.90625
4
# Given an m x n matrix, return all elements of the matrix in spiral order. # Example 1: # Input: matrix = [[1,2,3],[4,5,6],[7,8,9]] # Output: [1,2,3,6,9,8,7,4,5] # Example 2: # Input: matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]] # Output: [1,2,3,4,8,12,11,10,9,5,6,7] from typing import List import logging logger...
9bf7189e0e0208671771a94f9f9cf0ea6c73b3d5
jdh00127/movie_recommend
/movie_recommendation.py
6,882
3.53125
4
import re import os import math import pandas as pd #✨중요 pandas 다운로드 받아야함 ✨중요 def main(): data = pd.read_csv("tmdb_5000_movies.csv", encoding = "CP949") #data 갯수 4799개 print(data) data = data.sort_values(["popularity"], ascending=[False]) print(data) genres = data.pop("genres") #장르(여러...
c20872a10d18293c9e46a891fcce42bc1c7e1886
zsy1987/LeetCode
/有效的括号.py
364
3.71875
4
class Solution: def isValid(self, s: str) -> bool: l=[] d={ ")": "(", "]": "[", "}": "{", } for i in s: if i in d: if not l or l[-1]!=d[i]: return False l.pop() else: ...
2105c9110f01a09965b195db45c9367ccb5f80f6
florias/TNO-RU-Lane-detection-project
/ImageProcessing/Extrapolation.py
7,825
3.546875
4
import numpy as np import copy class Extrapolation: """Extrapolates dots to account for unknown data points behind the car. If there is no previous observation, the extrapolation output is the same as the observation. For all subsequent times the extrapolation is called, push down the previous observ...
bc84af13179f6464fcc9fcec7b504dfcb83a0ac2
georstef/Python_ObjectOrientedProgramming
/chapter4_raise.py
1,793
3.65625
4
import sys class EvenOnly(list): def append(self, integer): if not isinstance(integer, int): raise TypeError("Only integers") if integer % 2 != 0: # same same => if integer % 2: raise ValueError("Only evens") super().append(integer) def no_return(): print("I am a...
74fdb5fe19497626ce891e4cb53f635042291b85
rangerkevin/algorithms-sedgewick-wayne
/src/chapter_3/section_2/BST.py
5,116
3.9375
4
class Node: def __init__(self, key, value, n): self.key = key self.value = value self.N = n self.left = None self.right = None class BinarySearchTree: """The general APIs for binary search tree""" def __init__(self): self.root = None def size(self): ...
202c0a4c5098262630db6123ff9ab7fdbc3deb97
rangerkevin/algorithms-sedgewick-wayne
/src/chapter_4/section_1/Cycle.py
1,074
3.953125
4
from Graph import Graph import sys class Cycle: """ Determining if a graph has cycle """ def __init__(self, G): self.marked = {} self.hasCycle = False for v in G.vertices(): self.marked[v] = False for v in G.vertices(): if not self.marked[v]: ...
0df75e9cac9b0d910a6edbef9dc7adbf2c065934
rangerkevin/algorithms-sedgewick-wayne
/src/chapter_2/section_2/exercise_9.py
1,527
4.0625
4
import random import time class MergeSort: def __init__(self): print("Merge sorting: ") def merge(self, alist, lo, mid, hi, aux): i, j = lo, mid + 1 # We still need to assign the values to this aux array since the values here in alist are changing after each merge for...
9f4e2482fa561b0d0b3549c873a5c7105b4089ad
rangerkevin/algorithms-sedgewick-wayne
/src/chapter_1/section_3/exercise_11.py
1,188
3.75
4
from exercise_10 import * class EvaluatePostfix: """Exercise 1.3.11 of Algorithms Fourth Edition""" def __init__(self, postfixExpression): self.s = postfixExpression.split(' ') self.operands = [] def getResult(self): for c in self.s: if c.isdigit(): sel...
d31e8333d65a9c5368a0b9dc0d09fd9fe1c887f7
rangerkevin/algorithms-sedgewick-wayne
/src/chapter_2/section_3/exercise_17.py
3,199
3.9375
4
import random import time import sys import quickSort class Quick: def __init__(self): print("Quick sorting: ") def sortWithSentinels(self, alist): maxItem = alist[0] maxIndex = 0 for i in range(len(alist)): if alist[i] > maxItem: maxItem = alist[i]...
b1877560159c16d0969d2ef174b07dc2b8e1cad7
minsu8252/python_test
/root_ex2.py
211
3.765625
4
def print_root(a, b, c): r1 = (-b + (b**2 - 4*a*c)**0.5)/(2*a) r2 = (-b - (b**2 - 4*a*c)**0.5)/(2*a) print('해는 {}, 또는 {}입니다.'.format(r1, r2)) print_root(1, 2, -8) print_root(2, -6, -8)
3f7cfebc6fc2d11e0724de57383a55102308322f
minsu8252/python_test
/return.py
238
3.6875
4
def function_that_prints(): print("I printed") def function_that_returns(): return "I returned" f1 = function_that_prints() f2 = function_that_returns() print("Now let us see what the values of f1 and f2 are") print(f1) print(f2)
72871b67dd71410aedb185651c2764a1397aa5f0
DorotaNowak/machine-learning
/simple-linear-regression/simple_linear_regression.py
1,057
4.15625
4
# Simple linear regression import numpy as np import pandas as pd import matplotlib.pyplot as plt dataset = pd.read_csv('Salary_Data.csv') # print(dataset.head()) X = dataset.iloc[:,:-1].values y = dataset.iloc[:,1].values from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_t...
26b03ae0130d6101eec63fd7852ca68767a24049
aazambrano2/CS3-Labs
/Singly Linked List implementation/Zambrano_Aaron_Lab3.py
12,242
4.4375
4
""" Created on Mon Feb 17 4:34:47 2020 Course: CS 2302 Data Structures @author: Aaron Zambrano Assignment: Lab 3 - Singly Linked List Instructor: Dr. Olac Fuentes T.A: Oscar Galindo Last Modified on Mon Feb 28, 2020 Purpose of the program is to implement functions within the List class to create and observe the ...
6ba65baf088a2055fe89c76fea31cdbbd7052312
samuel-co/clustering-algorithms
/KMeans.py
3,793
3.625
4
''' Sam Congdon, Kendall Dilorenzo, Micheal Hewitt CSCI 447: MachineLearning Project 4: KMeans December 11, 2017 This python module is used to create a series of clusters using a k-means clustering. kmeans_clustering() is the primary function, find_clusters and move_centroids are helper functions. Parameters are the d...
fdfdd4ab700fb22b43940652f0e43777a0b1ddcc
bjanani/PyPI
/sqrt.py
119
3.96875
4
//A python program for square root// import math n=eval(imput("enter number")) print("square root is",math.sqrt(N)):
af7934755840efacec55136f1d602c12b9300401
bjanani/PyPI
/dict.py
146
4
4
//A python program for dictionary// dict['a':"support",'b':"confidence",'c':"ethic"] print(dict['b']) for i in dict: print(i)
f0b07c17bbcc8adc01d8d207cea8a8ec953d2308
clairewild/AlgorithmsStudying
/three_sum.py
875
3.90625
4
def three_sum(array, target): result = [] array = sorted(array) i = 0 while i < len(array) - 1: j = i + 1 while j < len(array): sum = array[i] + array[j] new_target = target - sum k = binary_search(array, new_target) if k > -1 and k != i an...
cf50d0c027a51fa5d510f993ee4b5ce65bcd40e8
nyoko708/python
/mondai/replace_spaces.py
274
4.03125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- def replace_spaces(str): rs = "" for num in range(len(str)): if str[num] == " ": rs += "%20" else: rs += str[num] return rs if __name__ == "__main__": str = "ab c d e " print replace_spaces(str)
3b0a2170d3675455f863e877587652622294de9c
pixman92/Learned
/Python/Dynamic_Variables.py
231
3.765625
4
obj = {} def makeDynamic(str, data): obj[str] = data print obj def addTo(str, data): obj[str] += data print obj def printMe(str): print obj[str] #makes a dynamic Dictionary #adds data #and then prints it
6a38705cd2b63a13942c95bcf2b0cd39a51c2ebb
trinhhoaichuong/gamedev
/flap/flap.py
11,692
3.65625
4
# Flap # KidsCanCode 2014 # Flappy bird in pygame # For educational purposes only # Art from http://lanica.co/flappy-clone/ # Music from opengameart.org (http://opengameart.org/content/cheerful-1-choro-bavario-happy-loop) # Copyright 2009 MSTR "Choro Bavario" <http://www.jamendo.com/en/artist/349242/mstr> # Copyrig...
4404071f5d46f4142dabb86b2bda624490de2868
trinhhoaichuong/gamedev
/pygame template.py
1,508
3.828125
4
# Pygame Template # Use this to start a new Pygame project # KidsCanCode 2015 import pygame import random # define some colors (R, G, B) WHITE = (255, 255, 255) GREEN = (0, 255, 0) BLUE = (0, 0, 255) BLACK = (0, 0, 0) FUCHSIA = (255, 0, 255) GRAY = (128, 128, 128) LIME = (0, 128, 0) MAROON = (128, 0, 0) NAVYBLU...
b10395a36be87b043ed18ad3973f2ae4eeb955ca
tdominic1186/ATBS
/Chapter 2/question13while.py
214
4.28125
4
""" 13. Write a short program that prints the numbers 1 to 10 using a for loop. Then write an equivalent program that prints the numbers 1 to 10 using a while loop. """ i = 1 while i < 11: print(i) i += 1
e168e246982a5e6861163b33e13510592705ae44
adivis/PythonProg
/prob_5.py
1,233
4.1875
4
""" Problem Statement:- You are given few sentences as a list (Python list of sentences). Take a query string as an input from the user. You have to pull out the sentences matching this query inputted by the user in decreasing order of relevance after converting every word in the query and the sentence to lowercase. Mo...
5fcd14c076c167c233a9e78bfd0b93c3648f1dec
numba/numba-examples
/legacy/binarytree.py
3,784
3.65625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ This is a more complicated jitclasses example. Here, we implement a binarytree and iterative preorder and inorder traversal function using a handwritten stack. """ from __future__ import print_function, absolute_import import random from collections import OrderedDict ...