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 |
|---|---|---|---|---|---|---|
ea1c40c22b4456285bf7215dcf0dc47229ede08f | ASDjonok/TRPZ_PK-91_20-21_Python | /lab4.py | 1,933 | 3.75 | 4 | # This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print(f'Hi, {name}') # Press ... |
fc85fdb2fe2cb3dbeb24a2d7531eea4fced508ee | zudevon/Automations | /forex_scrape.py | 1,298 | 3.625 | 4 | from selenium import webdriver
"""https://selenium-python.readthedocs.io"""
def investing_dot_com_scrape():
driver = webdriver.Chrome()
driver.get("https://www.investing.com/currencies/eur-usd-technical")
summary = driver.find_element_by_class_name("summary")
summary = summary.text
MA_summary = dr... |
562f98328126437944ea9c77161dbd6697011f51 | lucashss88/Estrutura-de-dados | /exe05.py | 506 | 3.640625 | 4 | class ContaCorrente:
def __init__(self,saldo,numero):
self._saldo= saldo
self._numero= numero
def debitar(self,valor):
self._saldo -= valor
def creditar(self,valor):
self._saldo += valor
def transferencia(self,valor,conta):
self.debitar(valor)
co... |
743e4790ef5fd1882fef7a8fb47edc12535fd50e | tolyapsh/SciPy | /addall.py | 212 | 3.578125 | 4 | import sys
s = 0
print 'The sum of',
for arg in sys.argv[1:]:
s += float(arg)
print arg,
print 'is', s
s = sum([float(x) for x in sys.argv[1:]])
print 'The sum of %s is %s' % (', '.join(sys.argv[1:]), s) |
2c500ec9a2e0025468466182c6a33bb7fce1bfd6 | Mrzhaohan/python-one | /dx.py | 100 | 3.890625 | 4 | import string
k=input('input')
if k.islower()==True:
k=k.upper()
else:
k=k.lower()
print(k)
|
2b50aa48d5637d2d68c35221c3bd41a52cc86cd2 | Mrzhaohan/python-one | /hanshu/suijimima.py | 493 | 3.578125 | 4 | import random
import string
def sm(n=6):
'''随机生成N位密码,默认为6位'''
mm=''
hc=string.ascii_letters
a=0
b=0
for i in range(n):
a=random.randint(1,3)
if a == 1:
b=random.randint(0,26)
mm+=hc[b]
if a == 2:
b=random.randint(26,52)
mm+=... |
f8c1e111c37343c59c378e5534f2521f4fae065a | Mrzhaohan/python-one | /hanshu/pingfen.py | 417 | 3.828125 | 4 | def pingfen(x):
a=''
x=int(x)
if x <= 100 and x >= 90:
a='A'
return a
elif x <= 89 and x >= 80:
a='B'
return a
elif x <= 79 and x >= 70:
a='C'
return a
elif x <= 79 and x >= 70:
a='D'
return a
elif x <= 59 and x >= 0:
a=... |
ec27fe33016192bac132bb7d97d32fad5f1ac040 | francheska-guzman/python-app | /routes.py | 925 | 3.84375 | 4 | # import the Flask class, and the function render_template
from flask import Flask, render_template
# create a new instance of the Flask class and save it into the variable app
app = Flask(__name__)
# map the url "/" to the function "index"
@app.route("/")
# defining function
def index():
# render the index.html fr... |
00a8a7d97bf652047b27efd913b5662f036d5db5 | rusben/python-exercices | /051-qualificacioSaxona.py | 714 | 3.9375 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
""" Algorisme qualificacioSaxona.py és
Donat un nom i una qualificació saxona, escriu el nom i la qualificació d'aquí"""
from os import system
# Esborrem pantalla
system("clear")
# Demanem Nom i qualificació saxona
nom=raw_input("Escriu el nom de l'alumne: " )
q=raw_inpu... |
f844ddf0949b44ee592e0fdac154728ed9fd0878 | rusben/python-exercices | /137-ppalParametres.py | 184 | 3.515625 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
if len(sys.argv)>1:
print "la cadena",sys.argv[1],"té %d caràcters"%(len(sys.argv[1]))
else :
print "Falten paràmetres !!!"
|
e1ce6804532e0b89f98db8c631b1742734205ecb | rusben/python-exercices | /110-Estadistic.py | 1,131 | 3.828125 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
from auxiliar import *
def menu():
op=raw_input("\n\ta) Introduir LLista\n\tb) Mitjana\n\tc) Moda\n\td) Desviació\n\te) Sortir\n\tTria una opció: ")
return op
def introduirElements():
l=[]
try:
demana=raw_input('Vols introduir més elements? [s/n]: ')
whil... |
e59be2e214a393f0eb32e5e6e33e9a215b562a36 | PhoebeDreamer/leetcode | /src/lc7.py | 391 | 3.53125 | 4 | class Solution(object):
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
if not x or abs(x)>=2**31:
return 0
flag = -1 if x<0 else 1
x = abs(x)
res = 0
while x:
res = res*10 + x%10
x//=10
... |
6787376c16c5e6647b332ea8df01baad47fa474e | PhoebeDreamer/leetcode | /src/lc332.py | 681 | 3.515625 | 4 | import collections as c
class Solution:
def findItinerary(self, tickets):
"""
:type tickets: List[List[str]]
:rtype: List[str]
"""
if not tickets:
return tickets
self.dic = c.defaultdict(list)
for frm, to in sorted(tickets)[::-1]
self.d... |
90e5889c40f93bb7f6a9d1a45359da6bc564adce | PhoebeDreamer/leetcode | /src/lc687.py | 797 | 3.859375 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def longestUnivaluePath(self, root):
"""
:type root: TreeNode
:rtype: int
"""
self.maxval... |
eb7f72d41dc867d7aa7b467d37cba84f3c3ed70b | PhoebeDreamer/leetcode | /src/lc55.py | 663 | 3.578125 | 4 | class Solution1(object):
def canJump(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
i = 0
target = len(nums)-1
dis = 0
while i <= dis and i <= target:
dis = max(dis, i+nums[i])
if dis>=target:
return Tru... |
daf90dbb6467010f960c20a5821970cd0ccce373 | PhoebeDreamer/leetcode | /src/lc725_rick.py | 950 | 3.6875 | 4 | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def splitListToParts(self, root, k):
"""
:type root: ListNode
:type k: int
:rtype: List[ListNode]
"""
... |
95ec10d849eefaabb368c84aa0238cd349b52725 | PhoebeDreamer/leetcode | /src/lc33.py | 1,552 | 3.640625 | 4 | class Solution1(object):
def search(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: int
"""
start = 0
end = len(nums)
while start<end:
mid = (start+end)//2
# nums[mid] and target on... |
3c4bca5787c2df3aaad3ef15bd931d95a0fb09ac | PhoebeDreamer/leetcode | /src/lt42.py | 1,334 | 3.984375 | 4 | # Description:
# Given an array of integers, find two non-overlapping subarrays which have the largest sum.
# The number in each subarray should be contiguous.
# Return the largest sum.
# Given an array of integers, find two non-overlapping subarrays which have the largest sum.
# The number in each subarray should be ... |
5eaab7918f40fc55c0da6cf2d7470bd06574dee5 | PhoebeDreamer/leetcode | /src/lc725.py | 1,098 | 3.75 | 4 | # Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def splitListToParts(self, root, k):
"""
:type root: ListNode
:type k: int
:rtype: List[ListNode]
"""
ans, length, cur = [], ... |
dc976267745961e645486627f64f3c49f54a195c | rajeshkannanb/PythonPrograms | /triangle.py | 596 | 3.953125 | 4 | from polygon import Polygon
from shape import Shape
#Inherit the class polygon, In class Triangle, the private members of polygon cannot be accessed.
#Multiple inheritance, inherit Shape class along with Polygon class.
class Triangle(Polygon, Shape):
def __init__(self):
#super().__init__() #This s... |
d04050727a1f83713666edd3e588b6d8003d7359 | rajeshkannanb/PythonPrograms | /salary_aggregation.py | 785 | 3.9375 | 4 | # Aggregation of classes - Combine two or more classes together.
# Aggregate classes have "has-a" relationship.
class Salary:
__pay = None
__bonus = None
def __init__(self, pay, bonus):
self.__pay = pay
self.__bonus = bonus
def get_salary(self):
return (self.__pay ... |
a3b273293d1cfb5404b3dfefd5df8eb62709c1be | ridhohafidz/DDP-Tugas2 | /buka_rekening/buka_rekening.py | 1,130 | 3.71875 | 4 | import random
import string
def buka_rekening(filename):
print()
print("* BUKA REKENING *")
name_rek = input(" Masukkan nama: ")
try:
saldo_rek = int(input(" Masukkan setoran awal: "))
while True:
pin_rek = int(input(" Masukkan nomor pin: "))
if (len... |
05564cfff12bdf3b73b32f3f4c8b484046ff3d91 | PatDaoust/6.0002 | /6.0002 ps1/ps1b adapt from teacher.py | 2,717 | 4.125 | 4 | ###########################
# 6.0002 Problem Set 1b: Space Change
# Name:
# Collaborators:
# Time:
# Author: charz, cdenise
#================================
# Part B: Golden Eggs
#================================
# Problem 1
def dp_make_weight(egg_weights, target_weight, memo = {}):
"""
Find number of eggs t... |
7a2da1bb3e3f3aa10c30b027b9eb57eab4834f98 | mukeshtiwari/covid_resource | /fetch_data.py | 798 | 3.625 | 4 |
#this function takes picode and
#returns the list of suppliers
def fetch_data_by_pincode(pincode):
#here we will connect to database
#and query it.
f = open("/Users/mukesht/Mukesh/Github/covid_resource/resource_item.text")
ret = []
for x in f:
t = x.split(',')
if ((t[2].strip()) == pincode.strip())... |
e748dfacaa09073963f25fd617f1fd89e9ccec18 | gracikk-ds/Yandex.Algorithms | /Week 1. Difficulty Testing/Lecture notes/Lesson1_DifficultyTesting.py | 3,832 | 3.78125 | 4 | """Task1"""
"""Here is a string (UTF-8 format). We should find the most repeatable symbol"""
"""If we have more than one symbol which has the same number of replays we can return any of them"""
"""Solution 0"""
s = input()
print(max(map(lambda x: (s.count(x), x), s))[1])
"""Solution 1 O(N**2) difficulty and... |
a814d56faeaded0501d7373a829890a967e7bbcf | iiraaa/repo2 | /week2/week2spyder.py | 3,733 | 3.796875 | 4 | # Lecture code for week2
# inspired by https://www.programiz.com/python-programming/tuple
my_string = 'baldan'
type(my_string)
mystr1 = 'Nice'
mystr2 = "day"
myFullStr = mystr1 +" " + mystr2 + " baina tiime?"
myFullStr
my_int = -15
type(my_int)
my_float = 15.234
type(my_float)
my_bool = False #True #0
type(my_bool... |
6c34492a6db3fd9cd5c1855b72237b5d6aee559d | tec1987/quic-version-detector | /quic_version_detector/cli.py | 710 | 3.515625 | 4 | import argparse
def parse_args(args):
"""Parses CLI arguments.
Args:
args (list): usually this will be sys.argv.
description (string): Text to display before the argument help.
Returns:
Namespace: with host and port fields.
"""
parser = argparse.ArgumentParser()
parse... |
fc13eb66c296177323d252a24d88631368bf57c6 | HenryBalthier/Python-Learning | /Leetcode_medium/array/59.py | 414 | 3.6875 | 4 | class Solution(object):
def generateMatrix(self, n):
"""
:type n: int
:rtype: List[List[int]]
"""
res = []
low = n*n+1
while low > 1:
high, low = low, low - len(res)
lst = [[i for i in range(low, high)]]
res = lst + list(ma... |
ed04657a0540fe83899e436e6b8c9d2947784c8b | HenryBalthier/Python-Learning | /Leetcode_medium/dynamicprogramming/62.py | 439 | 3.578125 | 4 | class Solution(object):
def uniquePaths(self, m, n):
"""
:type m: int
:type n: int
:rtype: int
"""
if m == 0 or n == 0:
return 0
paths = [[1]*n for _ in range(m)]
for i in range(1,m):
for j in range(1,n):
paths[i... |
70c5d6d671ead348a8dd858e4efaf87699a7efcc | HenryBalthier/Python-Learning | /Leetcode_easy/hash/242.py | 325 | 3.5625 | 4 | class Solution(object):
def isAnagram(self, s, t):
"""
:type s: str
:type t: str
:rtype: bool
"""
l1 = sorted(s)
l2 = sorted(t)
return l1 == l2
if __name__ == '__main__':
s = Solution()
s2 = "anagram"
t = "nagaram"
print(s.isAnagram(s2... |
2547702fb4c68b93d6a15fec622779a3a0eb897a | HenryBalthier/Python-Learning | /Leetcode_easy/array/26.py | 303 | 3.6875 | 4 | class Solution(object):
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
nums[:] = sorted(list(set(nums)))
return len(nums)
if __name__ == '__main__':
s = Solution
n = [1,2,2,2,2]
print(s.removeDuplicates(s,n)) |
2b0132c1c44be7117b0eee303cc486786667a125 | HenryBalthier/Python-Learning | /Leetcode_easy/array/283.py | 455 | 3.65625 | 4 | class Solution(object):
def moveZeroes(self, nums):
"""
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
"""
n = nums.count(0)
l = len(nums)
for i in range(l-1, -1, -1):
if nums[i] == 0:
nums.... |
0dbf8f5f8cb758f7320136497e1c3f4f150165cb | HenryBalthier/Python-Learning | /Leetcode_medium/linkedlist/24.py | 847 | 3.75 | 4 | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def swapPairs(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
if not head:
return None... |
e7dc4314a04c5ee2254df41b404312bc7a3181f7 | HenryBalthier/Python-Learning | /Leetcode_easy/array/414.py | 309 | 3.921875 | 4 | class Solution(object):
def thirdMax(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
s = sorted(list(set(nums)))
return s[-1] if len(s) < 3 else s[-3]
if __name__ == '__main__':
s = Solution
nums = [3, 2, 1]
print(s.thirdMax(s, nums))
|
43a3200b9cd7f713e77c0af64aec832e42f5cb50 | HenryBalthier/Python-Learning | /Leetcode_easy/string/557.py | 404 | 3.6875 | 4 | class Solution(object):
def reverseWords(self, s):
"""
:type s: str
:rtype: str
"""
ss = s.split(' ')
res = ''
for i, v in enumerate(ss):
ss[i] = ss[i][::-1]
res = res + ss[i] + ' '
return res[:-1]
if __name__ == '__main__':
... |
7b57b7375d120b995f104c8cb23a8eab685ababf | HenryBalthier/Python-Learning | /Leetcode_easy/math/258.py | 372 | 3.859375 | 4 | class Solution(object):
def addDigits(self, num):
"""
:type num: int
:rtype: int
"""
res = 0
while num>9:
res += num % 10
num = num // 10
res += num
return res if res < 10 else self.addDigits(res)
if __name__ == '__main__':
... |
acbd3ae0be90456c5ba87d0cdd58fb1fc0c62855 | HenryBalthier/Python-Learning | /Leetcode_medium/heap/373.py | 455 | 3.625 | 4 | class Solution(object):
def kSmallestPairs(self, nums1, nums2, k):
"""
:type nums1: List[int]
:type nums2: List[int]
:type k: int
:rtype: List[List[int]]
"""
l = [(x, y) for x in nums1 for y in nums2]
l.sort(key=sum)
return l[:k]
if __name... |
1bdc1af5eea9a402c7deb8b259c95a3443a90c78 | HenryBalthier/Python-Learning | /Leetcode_easy/tree/637.py | 563 | 3.71875 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def averageOfLevels(self, root):
"""
:type root: TreeNode
:rtype: List[float]
"""
from ... |
cea0ad21c21987e097a17c538ff4e930b46fb3e1 | HenryBalthier/Python-Learning | /Leetcode_easy/dynamicprogramming/70.py | 315 | 3.671875 | 4 | class Solution(object):
def climbStairs(self, n):
"""
:type n: int
:rtype: int
"""
a = b = 1
for _ in range(n):
a, b = b, a+b
print(a)
return a
if __name__ == '__main__':
s = Solution()
n = 2
print(s.climbStairs(n)) |
a2bc3dd188b80a85fb55ef9bfd16576c48629e44 | HenryBalthier/Python-Learning | /Leetcode_easy/math/326.py | 357 | 3.96875 | 4 | class Solution(object):
def isPowerOfThree(self, n):
"""
:type n: int
:rtype: bool
"""
if n == 0 or n == 2:
return False
while n % 3 == 0:
n = n // 3
print(n)
return n == 1
if __name__ == '__main__':
s = Solution()
... |
310bf43181ab7db84b6cacf91e0e3e47184d5a91 | HenryBalthier/Python-Learning | /Leetcode_easy/hash/409.py | 567 | 3.625 | 4 | class Solution(object):
def longestPalindrome(self, s):
"""
:type s: str
:rtype: int
"""
d = {}
c = 0
n = 0
for item in s:
d[item] = 1 + d.get(item, 0)
print(d)
for key, item in d.items():
print(item)
... |
4086a957db5c3b0bd54d5230533d11c9e94e01e6 | HenryBalthier/Python-Learning | /Leetcode_easy/tree/CreateTree.py | 3,792 | 3.9375 | 4 | class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
# 广度优先/深度优先遍历二叉树
class preBinaryTree:
def __init__(self):
self._root = None
def make_tree(self, node):
self._root = node
def insert(self, node):
# 这里是建立一个完全二... |
c3724eef89a9f0ea275c1785658e28934e28150e | HenryBalthier/Python-Learning | /Leetcode_medium/string/49.py | 459 | 3.5625 | 4 | class Solution(object):
def groupAnagrams(self, s):
"""
:type strs: List[str]
:rtype: List[List[str]]
"""
ss = [''.join(sorted(x)) for x in s]
d = {}
for i in range(len(s)):
d[ss[i]] = d.get(ss[i], []) + [s[i]]
res = []
for i in d:... |
0e3cd8abea3f4324a56517dfecbc8e17b0250caa | HenryBalthier/Python-Learning | /Leetcode_easy/array/581.py | 674 | 3.59375 | 4 | class Solution(object):
def findUnsortedSubarray(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
l = len(nums)
a = 0
z = l-1
for i in range(l):
if a == i-1 and nums[a] <= nums[i]:
a = i
while a >= 0 and nu... |
9ace7048371d8e403ed7b32dca7248a4c32415c9 | mgmk2/atcoder-python | /ABC/159/b.py | 285 | 3.984375 | 4 | def is_palindrome(s):
n = len(s)
for i in range(n // 2):
if s[i] != s[-(i + 1)]:
return False
return True
s = input()
n = len(s)
if is_palindrome(s) and is_palindrome(s[:n // 2]) and is_palindrome(s[-(n // 2):]):
print('Yes')
else:
print('No')
|
b3359da145aacff386c63486554266fee4208ec5 | mgmk2/atcoder-python | /ABC/161/f.py | 377 | 3.5 | 4 | def divisors(n):
x = set()
m = 1
while m * m <= n:
if n % m == 0:
x.add(m)
x.add(n // m)
m += 1
return x
n = int(input())
d = divisors(n)
ans = 0
for k in d:
if k == 1:
continue
nn = n
while nn % k == 0:
nn = nn // k
ans += nn % k ... |
e24250f4704dfd5aea487075f32b00e2a854df9f | mgmk2/atcoder-python | /ABC/111/A.py | 76 | 3.546875 | 4 | a = input()
a=a.replace('1','a').replace('9','1').replace('a','9')
print(a)
|
65910e977aeb69662a4cd02a879baf682a008ac2 | mgmk2/atcoder-python | /utils/prime.py | 437 | 3.609375 | 4 | def prime(x):
y = list(range(1, x + 1))
y[0] = 0
x_sqrt = x ** 0.5
for i in y:
if i > x_sqrt:
break
elif i == 0:
continue
for not_prime in range(2 * i, x + 1, i):
y[not_prime - 1] = 0
return [i for i in y if i > 0]
def is_prime(x):
for... |
9b7dae76feab6a0b38fe8bbe9cc17d11e6fc17f5 | dsc-lendi/Hacktober-fest | /python/vowel_or_consonant.py | 136 | 4 | 4 | v_list = ["a","e","i","o","u"]
ch = input("Enter the character to check:")
if ch in v_list:
print("vowel")
else:
print("consonant")
|
cfb266c99eb144843c3d9935a0d5ee2f020937eb | allinCode12/pygame | /Functions.py | 555 | 3.828125 | 4 | import turtle
my_turtle = turtle.Turtle()
def square(length , angle):
my_turtle.forward(length)
my_turtle.right(angle)
my_turtle.forward(length)
my_turtle.right(angle)
my_turtle.forward(length)
my_turtle.right(angle)
my_turtle.forward(length)
my_turtle.right(angle)
my_turtle.forward(length)
my_tur... |
48928842e45284a0275f4924b01d148de13324b4 | IrisShen/lintcode | /longestPalindrome.py | 637 | 3.890625 | 4 | class Solution:
"""
@param s: a string which consists of lowercase or uppercase letters
@return: the length of the longest palindromes that can be built
"""
def longestPalindrome(self, s):
# write your code here
len_pal = 0
counts = dict()
# count the occurence of ea... |
183c26bb205c0f3df933be4838b8513617db9908 | imajaydwivedi/Python-BootCamp | /practice/descriptor.py | 617 | 3.578125 | 4 | class Identity:
def __init__(self, val):
self.num = val
def __get__(self, obj, type=None):
return self.num
def __set__(self, obj, value):
if(value > 0):
self.num = value
else:
raise ValueError("negative value")
class Product:
id = Identity(12)
it... |
caf9f4760d098aa57fbd6ece8132cb82c23f2755 | matrix231993/cursopython2021 | /Unidad3/estructura.py | 751 | 4.03125 | 4 | # Python
#Sentencia If (true) : bool()
if True:
print("Se cumple la condicion")
print("A")
variable_1 = 12
#Varios If simples
a = 2
b = 50
if a==2:
print("Es par")
if b==2:
print("Es par")
# Ifs Anidados
if b!=5:
print("No es multiplo es 5")
if a>2:
print("Es par")
... |
38680acbf1ed3cf9480f38204373950d001f3537 | matrix231993/cursopython2021 | /Unidad4/funciones_valor_referencia.py | 418 | 3.8125 | 4 | #Paso por referencis : Se aplican directamente a las estructura como listas, tuplas, diccionario
def duplicar_numeros(numeros):
if isinstance(numeros,tuple):
temp_lista = list(numeros)
for i,n in enumerate(temp_lista)
temp_lista[i] *=2
numeros = tuple(temp_lista)
print(n... |
188c7e74ae3c05206ec4cdebd9b18fac6bc4aa1a | matrix231993/cursopython2021 | /TAREA_PYTHON/TAREA_PYTHON_1/ejercicio13.py | 269 | 4.125 | 4 | #EJERCICIO 13.- Pedir un número por teclado y mostrar la tabla de multiplicar
multi = int(input("ingrese un numero para la tabla de multiplicacion"))
m = 1
while m <= 12:
print(multi,"x", m, "=", multi*m)
m+=1
print("aqui esta la tabla de multiplicar",multi) |
350dc18eb4123270227f538c191dbe10a631a619 | matrix231993/cursopython2021 | /Unidad2/listas.py | 2,440 | 4.5 | 4 | # Lista en python
lista_enteros = [1,2,3,4,5] # Lista de Enteros
lista_float = [1.0,2.0,3.5,4.5,5.5] # Lista de floats
lista_cadenas = ["A","B",'C','SE',"HO"] # Lista de string
lista_general = [1, 3.5, "Cadena1", True] #Lista de tipo multiples
# 0 1 2 3
# Acceder a los elemento... |
1870e8edebccc486ebd204fac43b3859b60f7ab1 | matrix231993/cursopython2021 | /Unidad1/resumen_variable.py | 459 | 3.609375 | 4 |
#Resumen de variable
#Datos Primitivos
#Numerico = Number
numero_1 = 100 # Numerco de tipo Integer
numero_2 = 200.5 # Numerco de tipo Flot
# Variables de Tipo String
cadena_1 = "Esta es mi primera cadena"
cadena_2 = "Esta es mi segunda string"
cadena_3 = "Esta cadena es de tipo string"
# Variables de Tipo... |
f1bf9518a9bf9d02511bb2fb4b7fba6025eab364 | je7ov/Python | /Hanoi/recursive.py | 334 | 3.875 | 4 | def tower(n, fromT, toT, extraT):
if n==1:
print('Move piece ', n, ' from ', fromT, ' to ', toT, sep='')
return
tower(n-1, fromT, extraT, toT)
print('Move piece ', n, ' from ', fromT, ' to ', toT, sep='')
tower(n-1, extraT, toT, fromT)
n = int(input('Enter how many rings: '))
tower(n, '... |
d2564470622334c45db366cebcb5755038e27b7a | pshastri/EclipseWorkspace | /MyTestProgram/src/Regex.py | 185 | 3.609375 | 4 | '''
Created on Oct 13, 2016
@author: PShastri
'''
import re
n=raw_input("")
find_n=bool(re.search(r".",n))
find_nn=bool((re.match(r"+-",n)))
# or bool(re.match(r"-+",n))
print find_nn |
4760a64450d07142a1bcb07374074734072772d6 | Ajshannon/backend-baby-names-assessment | /babynames.py | 3,236 | 3.96875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# BabyNames python coding exercise.
# Copyright 2010 Google Inc.
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0
# Google's Python Class
# http://code.google.com/edu/languages/google-python-class/
import sys
import re
import... |
d4a379b13462248aee7436290097027b7b28201d | Lucas-Urbano/Python-for-Everybody | /Functions_Computerpay.py | 240 | 3.90625 | 4 | def computepay(h, r):
if h > 40:
p = ((h - 40) * (r * 1.5)) + (40 * r)
if h <= 40:
p = (h * r)
print('Pay',p)
return p
h = float(input("Enter Hours:"))
r = float(input("Enter rate/hour:"))
computepay(h, r) |
fb79529c283581cb63efacaacbb71932458420a6 | Lucas-Urbano/Python-for-Everybody | /Dictionarie6.py | 758 | 4.375 | 4 | Movie1 = {'Título':'Star Wars', 'ano': '1977', 'diretor': 'George Lucas'}
Movie2 = {'Título':'Indiana Jones e os salteadores da arca perdida', 'ano': '1981', 'diretor': 'Steven Spielberg'}
Movie3 = {'Título':'Matrix', 'ano': '1999', 'diretor': 'Irmãos Wachowski'}
Movie1['País'] = 'EUA' #add keys e value in a dictionary... |
653711677b6283276b40f3b4c9f0513d2484f36e | Lucas-Urbano/Python-for-Everybody | /Try_except_basic.py | 134 | 3.828125 | 4 | hours = input("Enter a hours:")
try:
h = float(hours)
pay = (h*9)
print(pay)
except:
print("Please enter a number:")
|
0f45330ad4255a565681181f3f2b24d2e5eacc8f | patchen/bacon | /bacon.py | 4,801 | 3.734375 | 4 | import urllib
import media
def invert_actor_dict (actor_dict):
'''Return a dictionary that is the inverse of the dictionary actor_dict.
The returned dictionary maps movies (string) to lists of actors (string)
appearing in the movie.'''
movie_dict = {}
for actor in actor_dict:
... |
ccb0f7dcd797252f3e7f4a00ee1725234aff1fe4 | kuritake/pynote | /setterANDgetter/setget.py | 1,132 | 4.0625 | 4 | class human:
def __init__(self, name,):
# With one underbar(_),this val is considered private.
# There is no binding effect if they use "instanceName_val".
self.name = name
self.age = None
#Setter and getter are hardly used in python coding.
#Cause python can't keep me... |
355303f2d63dd26e712530f165b3b9e2f682c66f | VadokDev/AyudantiasPrograUTFSM | /Certamen 1/Certamenes Anteriores/2017-1/P2-Comentada.py | 3,605 | 4.03125 | 4 |
#encoding: utf-8
#coding: utf-8
# Ignorar lo de arriba, es sólo para poder escribir con tildes
def pregunta1(): # Definimos la función que resolverá nuestro problema
# Declaramos las variables con las que trabajaremos
s1 = 0 # Precio total del sector 1
s2 = 0 # Precio total del sector 2
s3 = 0 # Precio ... |
0887fdcc44011622c16016a87e4b89a83e27aca8 | thinkAmi-sandbox/syakyo-deep-learning-from-scratch | /ch3/multi_dimensional_array.py | 2,531 | 3.90625 | 4 | import numpy as np
import traceback
import sys
def print_dimensional_array(x):
print(x)
print(f'NumPy配列の次元数(np.ndim()) -> {np.ndim(x)}')
# 多次元配列で統一した表記とするため、x.shapeはタプルが返ってくる
print(f'NumPy配列の要素数(x.shape) -> {x.shape}')
print(x.shape[0])
def print_dot(a, b):
print(f'x.shape -> {a.shape}')
... |
06c7fecc60739956a889769a9570563360a7d5e9 | cglw/leetcode | /15_3Sum.py | 913 | 3.71875 | 4 | # Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique
# triplets in the array which gives the sum of zero.
#
# Note:
#
# The solution set must not contain duplicate triplets.
#
# Example:
# Given array nums = [-1, 0, 1, 2, -1, -4],
#
# A solution set is:
# [
# ... |
aeba9589a9a1445194a82f074822186a04d9416e | amit2555/machine_learning | /matplotlib_ex1.py | 305 | 3.59375 | 4 | #!/usr/bin/python
from matplotlib import pyplot as plt
years = [1950,1960,1970,1980,1990,2000,2010]
gdp = [300.2,543.3,1075.9,2862.2,5979.6,10289.7,14958]
plt.plot(years,gdp,marker='o',color='green',linestyle='solid')
plt.xlabel('Year')
plt.ylabel('Billions in $')
plt.title('Nominal GDP')
plt.show()
|
198d0faeb4f69104c4dad2e643f1228a4e10c0c9 | rootid23/fft-py | /trees/serialize-and-deserialize-bst.py | 1,895 | 3.734375 | 4 |
#Recursion
# Deserialize = Preorder + Inorder
# Serialize = Preorder
#Serialization: generate space separated pre-order traversal string
#Deserialization: get in-order traversal string by sorting & generate the tree based on in-order and pre-order sequences
class Codec:
def serialize(self, root):
def pre... |
6df61f24bfe1e9943ac01de9eec80caad342c8a9 | rootid23/fft-py | /arrays/move-zeroes.py | 851 | 4.125 | 4 | #Move Zeroes
#Given an array nums, write a function to move all 0's to the end of it while
#maintaining the relative order of the non-zero elements.
#For example, given nums = [0, 1, 0, 3, 12], after calling your function, nums
#should be [1, 3, 12, 0, 0].
#Note:
#You must do this in-place without making a copy of the ... |
9245a904b74e7f4bea87f4ae3ddffcdad7a618fb | rootid23/fft-py | /linked_list/copy-list-with-random-pointer.py | 942 | 3.765625 | 4 | #Copy List with Random Pointer
#A linked list is given such that each node contains an additional random pointer which could point
#to any node in the
#list or null.
#Return a deep copy of the list.
class Solution(object):
def copyRandomList(self, head):
"""
:type head: RandomListNode
:rtyp... |
c06824c11bd1e942c94aef3d9a2754cc7b6896ee | rootid23/fft-py | /graph/find-eventual-safe-states.py | 2,194 | 4.0625 | 4 | #In a directed graph, we start at some node and every turn, walk along a directed edge of the graph.
#If we reach a node that is terminal (that is, it has no outgoing directed edges), we stop.
#Now, say our starting node is eventually safe if and only if we must eventually walk to a terminal
#node. More specifically, t... |
ecff63ff1c6a23548900edfd208002eddf65d7d2 | rootid23/fft-py | /stack/score-of-parentheses.py | 1,117 | 3.78125 | 4 | #Given a balanced parentheses string S, compute the score of the string based on the following rule:
# () has score 1
# AB has score A + B, where A and B are balanced parentheses strings.
# (A) has score 2 * A, where A is a balanced parentheses string.
#
#Example 1:
#Input: "()"
#Output: 1
#Example 2:
#Input: ... |
b77c86f0f92dd2d08e75d682859d7472f5f6947b | rootid23/fft-py | /strings/reverse-string.py | 827 | 3.890625 | 4 |
#Recursion
class Solution(object):
def reverseString(self, s):
l = len(s)
if l < 2:
return s
return self.reverseString(s[l/2:]) + self.reverseString(s[:l/2])
#swap w/ left and right
#python negative indexing
class SolutionClassicPythonic(object):
def reverseString(self, s):... |
3605db9b0b1fcb36e834f01a5a9706f97b61f968 | rootid23/fft-py | /trees/binary-tree-inorder-traversal.py | 1,379 | 4.09375 | 4 | #!/usr/bin/env python
#Given a binary tree, return the inorder traversal of its nodes' values.
#Example:
#Input: [1,null,2,3]
# 1
# \
# 2
# /
# 3
#Output: [1,3,2]
#Follow up: Recursive solution is trivial, could you do it iteratively?
from TreeNode import TreeNode
import unittest
#Iterative traversal
c... |
0a3890c4705561ada8077e9bdefc3fef0a2b60ca | rootid23/fft-py | /ckbk/plndrm_chk.py | 681 | 3.734375 | 4 | #!/usr/bin/env python
# Determine string is palindorme or not
import unittest
class Solution(object):
def is_palindrome(self, s):
sz = len(s)
if sz == 0 or sz == 1:
return True
return self.is_palindrome(s[1:-1]) and s[0] == s[-1]
class Test(unittest.TestCase):
def test_str_pal(self):
s... |
6d434c1355278f585f4ce2d5e8ac0e4fa5638f45 | rootid23/fft-py | /strings/longest-palindrome-substring.py | 1,930 | 4.09375 | 4 | #Longest Palindromic Substring
#Given a string s, find the longest palindromic substring in s. You may assume
#that the maximum length of s is 1000.
#Example:
#Input: "babad"
#Output: "bab"
#Note: "aba" is also a valid answer.
#Example:
#Input: "cbbd"
#Output: "bb"
#eg. aba (expand with i,i from b) , baab (expand wit... |
44d435cf99e3da04e37e7f01f42be2f840d95d70 | rootid23/fft-py | /trees/construct-binary-tree-from-preorder-and-inorder-traversal.py | 693 | 3.96875 | 4 |
#Given preorder and inorder traversal of a tree, construct the binary tree.
#Note:
#You may assume that duplicates do not exist in the tree.
#For example, given
#preorder = [3,9,20,15,7]
#inorder = [9,3,15,20,7]
#Return the following binary tree:
# 3
# / \
# 9 20
# / \
# 15 7
class Solution(object):
... |
ff376067c17137e6a8917b4a337e647c1055fcba | rootid23/fft-py | /bcktrk/generate-parentheses.py | 1,705 | 3.828125 | 4 | #Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
#For example, given n = 3, a solution set is:
#[
# "((()))",
# "(()())",
# "(())()",
# "()(())",
# "()()()"
#]
#Backtracking
#T(n) = 2T(n-1)
#Catlan # analysis
#1/(n+1) (2n C n) = 4^n/n(n)^1/2
class Solution(... |
b5d49a1a5d7cbdb7cb6a265a93496274bba7161d | rootid23/fft-py | /hash-table/contains-duplicate.py | 701 | 3.875 | 4 |
#cnstrnt : what it has O(n log N)?
#Ida
# 1. Sort
# 2. Auxillary set, check if it contains element
#W/ auxillary set
class Solution(object):
def containsDuplicate(self, nums):
mp = set()
for _,v in enumerate(nums) :
if(v in mp) : return True
mp.add(v)
return Fals... |
aa5dd84f15b43ce70c8e2c308487943c293ff293 | rootid23/fft-py | /trees/diameter-of-binary-tree.py | 2,472 | 3.84375 | 4 |
class Solution(object):
def diameterOfBinaryTree(self, root):
"""
:type root: TreeNode
:rtype: int
"""
self.ans = 0
def depth(p):
if not p: return 0
left, right = depth(p.left), depth(p.right)
self.ans = max(self.ans, left+right)
... |
18bc5ffcce3a5a90d50873f3e0a56e7ace8ec136 | rootid23/fft-py | /bcktrk/combination-sum-ii.py | 1,897 | 3.5625 | 4 | #Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.
#Each number in candidates may only be used once in the combination.
#Note:
# All numbers (including target) will be positive integers.
# The s... |
1fbba200958d0dca1b6e9d7af023ef1e046f9edc | rootid23/fft-py | /trees/serialize-and-deserialize-binary-tree.py | 4,462 | 3.734375 | 4 |
#Preorder save
#Use of iter and next
#recursion
#[1,2,3,null,null,4,5]
#1 2 # # 3 4 # # 5 # #
class Codec:
def serialize(self, root):
def doit(node):
if node:
vals.append(str(node.val))
doit(node.left)
doit(node.right)
else:
... |
f67f192f0fcaac18f9124f919626d24f3a1d2670 | rootid23/fft-py | /hash-table/shortest-word-distance-ii.py | 1,804 | 3.921875 | 4 |
class WordDistance(object):
def __init__(self, words):
"""
:type words: List[str]
"""
self.mp = {}
for idx, word in enumerate(words) :
if(word not in self.mp) :
self.mp[word] = []
self.mp[word] += [idx]
def shortest(self, word1,... |
54feaa9d09ff553ff873071f7dc9dce0c53c34f2 | rootid23/fft-py | /tricks/remove-duplicates.py | 587 | 3.984375 | 4 |
# For example, given nums = [0, 1, 1, 0, 3, 3, 0, 3, 4, 5, 0, 5, 5, 12], after calling your
#function, nums should be [1, 3, 4, 5, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0].
#Move idx in forward direction
def removeDuplicates(nums) :
if(not nums) : return nums
idx = 0
prev = 0
n = len(nums)
for i in range(n) :
if... |
ed4a4d7a485d0b38aa768fb4470e3c8e858bf9e4 | rootid23/fft-py | /dfs/word-search-ii.py | 3,076 | 3.828125 | 4 |
#Trie in python way
class Solution:
# @param {character[][]} board
# @param {string[]} words
# @return {string[]}
def findWords(self, board, words):
#make trie please refer
trie={}
for w in words:
t=trie
for c in w:
if c not in t:
... |
77625ff51fbe09f11de1d6cf37fe5e2be37a7d40 | rootid23/fft-py | /two-pointers/implement-strstr.py | 580 | 4.0625 | 4 | #substring
#"hello" "ll" = (5,2)
#0.
#Case analysis
#1. w-f needle at mid "hello" "ll" 2. at start "hello" "he" 3. at end "hello" "lo"
#Ida
#1. get the needle and scan over all haystack
m, n = map(len, [haystack, needle])
if(haystack == needle) : return 0
t_len = m - n + 1 # 1 is added due to python range is < not <=
... |
918cf46ced09c9ba9f951075a41d77b4fd40e07d | rootid23/fft-py | /first-position-of-target.py | 1,174 | 4.0625 | 4 | #First position of Target
#For a given sorted array (ascending order) and a target number, find the first index of this number in O(log n) time complexity.
#If the target number does not exist in the array, return -1.
#Have you met this question in a real interview?
#Example
#If the array is [1, 2, 3, 3, 4, 5, 10], for... |
e4e9783fec629e0bba8368c25f4b69a1a589a35d | rootid23/fft-py | /dfs/word-search.py | 2,929 | 3.515625 | 4 |
#DFS
#Whether its BFS / DFS in order to avoid backedge store the parent
#eg. memo.add( (x,y) ) and then explore the childern
class Solution(object):
def exist(self, board, word):
if(not board) : return False
m, n = map(len, [board, board[0]])
idx_dict = {}
for i in range(m) :
... |
00b09a7cee13d9efee34bb204b858b18ba3a0d28 | rootid23/fft-py | /dp/edit-distance.py | 2,862 | 3.921875 | 4 | #Edit Distance
#Given two words word1 and word2, find the minimum number of steps required to
#convert word1 to word2. (each operation is counted as 1 step.)
#You have the following 3 operations permitted on a word:
#a) Insert a character
#b) Delete a character
#c) Replace a character
# It works with suffix of both st... |
69165378556fe9e30c78de3fc668a5fccab49ea8 | rootid23/fft-py | /trie/build-trie.py | 341 | 3.59375 | 4 | #Build trie with only dict
#Init, progress, end
def buildTrie (words) :
trie = {}
for w in words:
t = trie
for c in w:
if c not in t:
t[c] = {} #init
t = t[c] #progress
t['#'] = '#' #end
print(trie)
print(trie.keys())
words = ['sea', 'she... |
dc65b47dc77f1d86e15ad157091db615e44ad5ee | GeorgyFirsov/Course-work | /DataGeneration/tables_generation.py | 5,061 | 3.546875 | 4 | from random import (randint,
randrange,
choice,
)
import pandas as pd
import numpy as np
from DataGeneration.fake_generation import make_generator
# All following functions are used for generation of random date
# and put it into pandas.DataFrame object. I... |
574f2fa0a57b335db183ee690bfe2da896c957c6 | hmlmodi/Python-Playground | /New folder/final ready game.py | 894 | 4.1875 | 4 | import random
choice = int(input('enter your choice:'))
user_choice = choice
comp_choice = random.randint(1, 3)
print(user_choice)
print(comp_choice)
logic = "TWLLTWWLT"
print(logic[(((user_choice) * 3) + (comp_choice)) ]);
# if (user_choice == 1 and comp_choice == 2) or (comp_choice == 1 and user_choice == 2):
... |
81e49d6968e508c5cda0f121954067e916be5cdd | Ambanib/Codes1 | /fibonacci.py | 126 | 3.765625 | 4 | no= int(input("Enter a Number"))
n=0
m=1
counter=0
while counter<no:
print(n)
f=n+m
n=m
m=f
counter +=1
|
496962da212cea72ab89fd7124534fba9cda89d6 | Raafm/dijkstradutor | /data_treatment/adj_to_matrix.py | 1,464 | 3.671875 | 4 | """
Program for generating the adjacency matrix of the database from the created
adjacency list (adjacency.py). This is done for showing that popular graph
sites, such as, https://graphonline.ru/en/ , are not capable of handling our
input and solving the problem we solve.
"""
from pathlib import Path
# adj is the adj... |
a97889609745846cb90c6270ff513a471d512e8c | felsen/felsen-test | /mro.py | 783 | 3.796875 | 4 |
class BaseClass:
num_base_calls = 0
def call_me(self):
print("BaseClass method call_me")
self.num_base_calls += 1
class LeftSubClass(BaseClass):
num_left_sub_calls = 0
def call_me(self):
print("LeftSubClass method call_me")
BaseClass.call_me(self)
self.num_l... |
5bf4fa7d0dcdca386a00932c361335a11ae75d55 | lboaventura25/Lucas-Python | /Códigos em Python/dictionary.py | 2,482 | 3.5625 | 4 | # Não edite a lista de usuários
USUARIOS = [
{
'nome': 'Ada Lovelace',
'emails': ['ada@gmail.co.uk', 'algo-ada@hotmail.com'],
'nascimento': (1815, 12, 10),
'senha': 'algoritmo',
},
{
'nome': 'Alan Turing',
'emails': ['turing@gmail.co.uk'],
'nascimento'... |
dcc5deb93731fc4f1815d60f2fd3d2cf92f067b6 | lboaventura25/Lucas-Python | /Códigos em Python/d.py | 120 | 3.734375 | 4 | def f(x):
return 2 * x
lst = [1, 2, 3, 4, 5]
m = map(f, lst)
for x in m:
if x == 6:
print(x)
|
f0660ade936e8b2e8e51a8277fbcfaeb859202cc | Nithya-Ganesh-Bhat/Assignment5 | /session5.py | 6,419 | 3.578125 | 4 |
import math
from timeit import default_timer as timer
def time_it(fn, *args, repetitons= 1, **kwargs):
if(fn not in (temp_converter, polygon_area, squared_power_list, print, speed_converter)):
raise ValueError("First positional argument must be function name - polygon_area/temp_converter/speed_conve... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.