blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
513fa97db59d58eda8bc09f1ee3531c833e4677c | DidiMilikina/DataCamp | /Machine Learning Scientist with Python/16. Introduction to Deep Learning with Keras/04. Advanced Model Architectures/02. Neural separation.py | 1,441 | 3.953125 | 4 | '''
Neural separation
Neurons learn by updating their weights to output values that help them distinguish between the input classes. So put on your gloves because you're going to perform brain surgery!
You will make use of the inp_to_out() function you just built to visualize the output of two neurons in the first lay... |
3a7fa5f2e12982b58c007f03f98a5f6cdd069ab2 | MagidElgady/PyDataScience | /4_SciPy/6_scipy_linear.py | 437 | 3.578125 | 4 | # Python Full Course - Learn Python in 12 Hours | Python Tutorial For Beginners | Edureka
# This lesson shows how to solve linear algebraic equations using the SciPy
# library as well as how fast SciPy can be.
import numpy as np
# Linalg allows us to perform linear
# algebraic functions
from scipy import linalg
a = n... |
a4dbd2c0c174b2168b0791c0160c949f5eca3f8f | hodazare/LeetCode | /Python/GroupAnagrams.py | 875 | 4.09375 | 4 | """
Given an array of strings, group anagrams together.
Example:
Input: ["eat", "tea", "tan", "ate", "nat", "bat"],
Output:
[
["ate","eat","tea"],
["nat","tan"],
["bat"]
]
Note:
All inputs will be in lowercase.
The order of your output does not matter.
"""
class Solution(object):
# sorting words
... |
5628f6a44badf82968dc10643d9778d24607b01c | rshafi2/The-Tech-Academy-Basic-Python-Projects | /add_fileNamePython:103.py | 1,100 | 4.15625 | 4 | import sqlite3
# the conn variable is going to hold our connection
# when we connect to a database
# with loop meaning while we have the connection
# do the following lines of code after with
# cur or cursor is what actually operating on the database
# when we want to invoke commands or do something we would c... |
c44908297f11dff395dda3651507d6dacaee283d | JoTaijiquan/Python | /Python101-New130519/2-5-4.py | 309 | 4.09375 | 4 | #Python 3.9.5
#Example 2-5-4
'หา factorial number ด้วย lambda function'
if __name__ == "__main__":
factorial4 = lambda n: 1 if n==0 else n*factorial4(n-1)
print ("3! =",factorial4(3))
print ("5! =",factorial4(5))
print ("1! =",factorial4(1))
print ("0! =",factorial4(0))
|
e168200d581e0488ab6dac7cc4c6ac4a3c5f1580 | ZainLiu/dailypractice | /单例模式.py | 827 | 3.703125 | 4 | class Single(object):
def __init__(self,name):
self.name = name
@classmethod
def instance(cls, *args, **kwargs):
if not hasattr(Single, "_instance"):
Single._instance = Single(*args, **kwargs)
return Single._instance
def __str__(self):
return self.name
class... |
94276ed924c296e993de246021dea0869fd8bdf4 | Pedrobertuola/curso-em-video-course | /Mundo_3/Ex79.py | 226 | 3.96875 | 4 | lista=[]
while True:
n=int(input('Digite um valor:'))
if n not in lista:
lista.append(n)
R=str(input('Deseja continuar?[S/N] ')).strip().upper()[0]
if R in'Nn':
break
lista.sort()
print(lista)
|
5cd87eccf54731d727aa5bf1614000baa1cb2aa5 | isabelycosta/IABusca | /teste_busca.py | 2,459 | 3.546875 | 4 | import os
from busca import BFS, DFS, DFSV, IDS, DLS, UCS, GBFS, AS, BS
from classes import Problema
from mundos import map_romania, HSLD
from mundos import vaccum_world as vaccum
NUMBER_OF_ITERATIONS = 20
INIT_MAP = "Oradea"
GOAL_MAP = "Bucharest"
INIT_VACCUM = "ESS"
GOAL_VACCUM = "DLL"
def menu(problema):
prin... |
e906f5922450e0bb1a25087e10ef001a70425784 | JiaShy94/Python-spider | /正则提取/变量名有效.py | 1,350 | 3.625 | 4 | # 判断变量名是否有效
import re
# file_name = input("请输入变量名:")
# # \w也包含中文,所以不能使用,要使用[0-9a-zA-Z_]*
# ret = re.match(r"^[a-zA-Z_]+[0-9a-zA-Z_]*$", file_name)
# try:
# if ret.group():
# print(file_name + "符合规范")
# else:
# print(file_name + "不符合规范")
# except:
# print(file_name + "不符合规范")
# 匹配五位以上的数字... |
9bd0cc7b078d3564231cb357740515d6e3520094 | MDU-PHL/parseGenbanksExtractCDSsByGeneName | /parseGenbanksExtractCDSsByGeneName.py | 3,159 | 3.5 | 4 | #!/usr/bin/env python
'''
20160623_2130
github schultzm
dr.mark.schultz@gmail.com
Extract CDS DNA sequences from gbk files using the CDS gene name.
Can be used to extract one or many CDS DNA sequences from one or
many genbank files.
Example usage (in series):
python parseGenbanksExtractCDSsByGeneName.py -g *.gb... |
6ec8c0b8e0f76149d4879d6bc895dbd6c43015b2 | arunsri7/code-wars | /8kyu/python/thinkful.py | 123 | 3.5 | 4 | def fillable(stock, merch, n):
if merch in stock:
if(stock[merch]>=n):
return True
return False |
b6b9d72b63405314a47c73a7a9edcb8e589de3a4 | gxsoft/SkillShare---Python-3--Programming-in-Py-for-Beginners | /Sample 16 -Add new Definition Search Existent Definition or Delete.py | 1,588 | 4.28125 | 4 | """
Sample 16 -Add new Definition Search Existent Definition or Delete.py
Dictionary
1- Add new Definition
2- Search Existent Definition or
3- Delete.py
"""
dictionary = {"1": "Uno", "2":"Dos", "3":"Tres"}
print("Dictionary:", dictionary)
print("")
print("------------- Dictionary TASK ---------------")
print("1: ... |
9fcf191452f2fd1373a7eae2f7ca0fc083887150 | KamozZze/Programming0 | /week1/2. If-Elif-Else-Simple-Problems/calculator.py | 391 | 4.09375 | 4 | # calculator.py
a = input("Enter a: ")
b = input("Enter b: ")
oper = input("Enter operation: ")
result = False
a = int(a)
b = int(b)
if oper == "+":
result = a+b
elif oper == "-":
result = a-b
elif oper == "/":
result = a/b
elif oper == "*":
result = a*b
if result == False:
print("We do not sup... |
e31c1510f06fccd1582a89a8883b923064cc0f84 | julienawilson/data-structures | /src/insertion_sort.py | 1,228 | 4.0625 | 4 | """Insertion sort."""
def insertion_sort(some_list):
"""It sorts."""
if not hasattr(some_list, "__iter__"):
raise(TypeError)
idx = 0
while idx < len(some_list) - 1:
if some_list[idx] > some_list[idx + 1]:
some_list[idx], some_list[idx + 1] = some_list[idx + 1], some_list[id... |
02eb7aa9612d6b0d192e311bd7c4bc12fde4c58f | myegorov/ip-filter | /data/obst.py | 6,607 | 3.765625 | 4 | '''
Compute optimal binary search tree with various weighting functions:
- equal weights (balanced tree)
- weights correlated with prefix count
- weights correlated with prefix IP address space share
Using Knuth's dynamic programming algorithm.
'''
import os
from sys import maxsize
from conf import *
cla... |
b7a50edb8fa5310e55da2d7c8424a1c19c0f1b06 | bowbahdoe/Carol | /Math/Coordinate.py | 962 | 4.4375 | 4 | from math import sqrt
class Coordinate:
"""class to contain a Coordinate"""
def __init__(self,x,y):
assert(type(x)==int)
assert(type(y)==int)
self.x = x
self.y = y
def setX(self,x):
"""Sets the x value of the coordinate"""
assert(type(x)==int)
self.x =... |
b725eb9ead877155aab7f9026b8db9613b2de55a | kunhuang/LeetCode | /023_Merge k Sorted Lists.py | 3,406 | 3.96875 | 4 | import pdb
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
def print_list(self):
cursor = self
while cursor.next:
print cursor.val, '->',
cursor = cursor.next
print cursor.val
clas... |
669445cc35c9e3845e2753f8d266d31570d9e591 | Zhivlova/-Zhivlova-GU_Python_728-28-08-2020- | /2 (5).py | 264 | 3.765625 | 4 | my_list = [7, 5, 3, 3, 2]
answer = input('Введите число: ')
for index, number in enumerate(my_list):
if int(answer) < int(number):
continue
my_list.insert(index, answer)
break
else:
my_list.append(answer)
print(my_list) |
95fd236c2d9e6abccd2939c41889d1b76fa40e28 | hanyuan-zhu/homework | /Numerial Analysis/4/HW4-bisection.py | 1,067 | 3.703125 | 4 | import numpy as np
import math
#iteration counter: to count how many steps to reach the threshold value
i=0
#Define the target funciton
def f(x):
return math.tan(x)-math.cos(x)
def randompostive(x):
return np.multiply(np.random.random(),x)
## NOTE: Inital generator, range:[0,1), half open interval, choosing ... |
ec1d3110035548342da7eb4df194417eadb1c23d | amit-kr-debug/CP | /codeForces/round 666 div 2/A. Juggling Letters.py | 1,409 | 4 | 4 | """
You are given n strings s1,s2,…,sn consisting of lowercase Latin letters.
In one operation you can remove a character from a string si and insert it to an arbitrary position in a string sj (j may be equal to i). You may perform this operation any number of times. Is it possible to make all n strings equal?
Input
... |
7491d939c6ce7dec066747aca55617acb3ee09d4 | jsolano28/Data_Scientist_with_Python_Career_Track | /C9_Merging_DataFrames_with_Pandas/Ch2_Ex04_Concatenating_pandas_DataFrames_along_column_axis.py | 1,334 | 4.28125 | 4 | # EXERCISE:
# Concatenating pandas DataFrames along column axis
# The function pd.concat() can concatenate DataFrames horizontally as well as vertically (vertical is the default). To
# make the DataFrames stack horizontally, you have to specify the keyword argument axis=1 or axis='columns'.
# In this exercise, you'l... |
74b46df643ae5f2a60c51622a6605e57a61f929c | xc21/Algorithms | /167_twoSum_Nov6_2018.py | 574 | 3.65625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Nov 6 23:19:51 2018
@author: Xun Cao
"""
class Solution(object):
def twoSum(self, numbers, target):
"""
:type numbers: List[int]
:type target: int
:rtype: List[int]
"""
right=len(numbers)-1
left=0
... |
2513d89955b7e26e930f897d31f09caf91252fe2 | davidoh0905/Algorithms | /linkedlist/generate_parenthesis.py | 2,617 | 3.921875 | 4 | class Solution(object):
## I am going to use recursion so that the next opening or closing parenthesis can be continuously be added based on rule
def generateParenthesis(self, n):
return self.generateParenthesisHelper(n, 0, "", [])
## State dictates decision : STATE STATE STATE STATE
## ... |
936c3fa9141df4103c5e43c98cbf9d4c5adfe545 | dcsheive/Python-Algorithms | /Arrays.py | 555 | 3.90625 | 4 | def pushFront(arr,num):
arr.append(0)
for i in range(len(arr)-1,-1,-1):
if i == 0:
arr[i] = num
else:
arr[i] = arr[i-1]
print( arr)
# pushFront([1,2,3,4], 0)
# arr.insert(0,val)
def popFront(arr):
for i in range(0,len(arr)-1):
arr[i] = arr[i+1]
arr.pop... |
3ba7fa0d59a6015e626f241254ddaff11e1050b6 | Nagendracse1/Competitive-Programming | /greedy/Ratndeep/n meeting room2.py | 576 | 3.578125 | 4 | def maximumMeetings(n,start,end):
'''
:param n: number of activities
:param start: start time of activities
:param end: corresponding end time of activities
:return: Integer, maximum number of activities
'''
# code here
meeting = []
for i in range(n):
meeting.append([start[i]... |
582b9042cc746d101e5554ed61e1ece6c0729be4 | Sarolus/AirBnB_clone | /tests/test_models/test_amenity.py | 410 | 3.5 | 4 | #!/usr/bin/python3
"""module test classes"""
from models import amenity
from models.base_model import BaseModel
import unittest
Amenity = amenity.Amenity
class TestAmenity(unittest.TestCase):
"""Amenity test class"""
def testName(self):
"""Test Amenity has attribute"""
amenity = Amenity()
... |
024ae10ceff388210ffbc05f3bc4f82b29c73931 | harasees-singh/Notes | /Python Basics/python_unacademy_6.py | 5,141 | 3.828125 | 4 | '''
modules and imports in python
file I/O
python interpreter
arrays
'''
# Python modules:
# a module can be made by a user and few are provided
# to us by python
#
# what to do if we need a module
import math
result = math.factorial(6)
print(result, math.log10(6556), math.log(2.37))
from math import * # this me... |
3d50f95b987f68eb188b134357c003114d3ca6dd | RoyLizhiyu/Leetocde | /5. Longest Palindromic Substring.py | 1,536 | 3.671875 | 4 | class Solution:
def longestPalindrome(self, s):
if len(s) < 1:
return s
def isPalindrome(left, right):
return s[left:right] == s[left:right][::-1]
left, right = 0, 1
for index in range(1, len(s)):
if index - right > 0 and isPalindrome(index - rig... |
c2bf8caae2b41d2c6b3018440058bf11e6231531 | GuardianBob/Python | /_python/python_fundamentals/practice.py | 4,381 | 3.859375 | 4 | # def a():
# print(1)
# x = b()
# print(x)
# return 10
# def b():
# print(3)
# return 5
# y = a()
# print(y)
# # Simple Swap:
# arr = [5, 4, 3, 2]
# arr[0], arr[1], arr[2], arr[3] = arr[3], arr[2], arr[1], arr[0]
# print(arr)
# def bubbleSwap(lst1):
# n = len(lst1)
# for i in range(n-1... |
d4d5bfb7b2f0cdaa8dafe670b68ad67eacdb0788 | chadmilburn/Financial_and_Election_Breakdown | /PyBank/main.py | 3,098 | 3.875 | 4 | # import modules
import os
import csv
# set path for file
csvpath = os.path.join("Resources", "budget_data.csv")
# open csv file
with open(csvpath) as csvfile:
# #csv reader with delimieter and variable to hold contents
csvreader = csv.reader(csvfile, delimiter=",")
#check that I am getting my... |
a101fb3262168629e13fb6870a5445d901226723 | kimsehwan96/studying_python | /DataStruct/__init__.py | 609 | 3.84375 | 4 | class Node:
def __init__(self, data, next = None):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
self.size = 0
def add(self, item):
self.head = Node(item, self.head)
self.size += 1
def remove(self):
if ... |
5518906ce1c08cab4a4b836a363e67aba4f8cd1c | guyman575/CodeConnectsJacob | /semester1/lesson9/otheroopstuff.py | 768 | 3.984375 | 4 | class Candy():
# class variable
taste = "sweet"
def __init__(self, name):
# Instance variable
self.name = name
twix = Candy("Twix")
sourpatch = Candy("Sour Patch")
# sourpatch.taste = "sour"
Candy.taste = "sour"
Candy.name = "test"
print(twix.taste)
print(sourpatch.taste)
print(twix.name... |
70a0f3c88dc36004dc2505f6348b36c738b23a7a | alexmojaki/scramble_to_unscramble | /game.py | 1,844 | 3.5625 | 4 | import json
import random
import itertools
from common import DATA_PATH
def get_path():
all_data = json.loads(DATA_PATH.read_text())
data = all_data["8"]
while True:
seen = set()
path = []
node = random.choice(list(data))
while True:
seen.add(node)
... |
25380d08451b35172b9a2d812478d7e27bfda626 | dtingg/Fall2018-PY210A | /students/ZachCooper/session06/mailroom4.py | 7,103 | 3.578125 | 4 | #!/usr/bin/env python3
import os
import math
from textwrap import dedent
# Name letters will be under in disk
OUT_PATH = "thank_you_letters"
# Creates path to open cwd for letters
def prepare_to_run():
if not os.path.isdir(OUT_PATH):
os.mkdir(OUT_PATH)
# Donor and donations zipped into a dict
def disn... |
c906dfd8bb4c53b19b513c37a5ba750b89b53ebb | gordy2015/django_day25 | /static/test.py | 752 | 3.984375 | 4 |
def collatz(number):
w = number % 2
# print(w)
if w == 0:
number = number // 2
# print(number)
return number
else:
number = 3 * number + 1
#print(number)
return number
def game(a):
print('start number--> %s' % a)
while True:
a = collatz(a)... |
f8380703565b3623f8245f319ae9bd24afdb8f5d | srikanthpragada/beyond_basics_of_python | /examples/morelib/functools_demo.py | 324 | 3.890625 | 4 | # functools.reduce(function, iterable[, initializer])
from functools import reduce
from operator import mul
def multiply(x, y):
print(x,y)
return x * y
values = [1, 5, 8, 10]
print(reduce(multiply, values))
print(reduce(multiply, values, 1))
print(reduce(lambda x,y : x * y, values))
print(reduce(mul, value... |
0890a9e4cafdcf6d550dccb40e36d7e12624d5ca | CodeHemP/CAREER-TRACK-Data-Scientist-with-Python | /10_python-data-science-toolbox-(part-1)/3_lambda-functions-and-error-handling/05_reduce()-and-lambda-functions.py | 1,561 | 4.6875 | 5 | '''
05 - Reduce() and lambda functions
You're getting very good at using lambda functions! Here's one more function
to add to your repertoire of skills. The reduce() function is useful for
performing some computation on a list and, unlike map() and filter(), returns
a single value as a result. To use reduce... |
ca2d1388780c1a907252899e308aaaad2d08fcaa | davishek7/PythonTest | /ArraywithWhile.py | 95 | 3.53125 | 4 | from array import *
val=array('i',[1,2,3,5,8])
i=0
while i<len(val):
print(val[i])
i+=1 |
2e4782a63ec696c5afb796a3fc17917ac2f8a905 | ss87021456/2018-UIUC-Machine-Learning | /assignment4/mp4/models/support_vector_machine.py | 2,670 | 3.8125 | 4 | """Implements support vector machine."""
from __future__ import print_function
from __future__ import absolute_import
import numpy as np
from models.linear_model import LinearModel
class SupportVectorMachine(LinearModel):
"""Implements a linear regression mode model"""
def backward(self, f, y):
"""... |
7116192d435fa4db91da3798a2f55a205bdd728e | sogawa-yk/coding_practice | /11章/unionfind.py | 1,148 | 3.75 | 4 |
from typing import Union
class UnionFInd():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
self.size = [1] * n
def root(self, x):
# 根をたどる
if self.parents[x] == -1: return x
else: return self.root(self.parents[x])
def issame... |
3a59e9dd9ffd6b876b9795c07122a24162e4856d | sunyumail93/Python3_StepByStep | /Day06_JoinAndFunction/Day06_JoinAndFunction.py | 683 | 3.546875 | 4 | #!/usr/bin/python3
#Day06_JoinAndFunction.py
#Aim: Convert bed format containing RNA sequences to a FASTA format, saving the bed information in the FASTA header
#Use Join and self-defined function
import sys
def ConvertBED2HeaderFasta():
fi = open(sys.argv[1],'r')
fo = open(sys.argv[2],'w')
for line in fi:
line=l... |
a5dbd369df092afce4c10d932bec066da78c9aad | Prathap16/Jenkins_build | /workout/arranging_alpa_num.py | 307 | 4.15625 | 4 | string1=input("enter string to sort:")
alpa_result=""
num_result=""
for ch in string1:
if ch.isalpha():
alpa_result=alpa_result+ch
else:
num_result=num_result+ch
result_list=sorted(alpa_result)+sorted(num_result)
output=""
for ch in result_list:
output=output+ch
print(output)
|
a60a933c68c6210b3c407f3bdfcae0352cd575c6 | MarkHershey/PythonWorkshop2020 | /Session_01/py101/10_classes.py | 418 | 3.984375 | 4 | class People:
def __init__(self, name, birthYear):
self.name = name
self.birthYear = birthYear
self.age = 2020 - birthYear
self.height = None
self.pillar = None
p1 = People("Maria", 1999)
print(p1.name)
print(p1.birthYear)
print(p1.age)
p1.pillar = "Architecture and Sustai... |
97d38767185d4c96f60784a7d564bd085fa51e3f | wwjholmes/leetcode | /739.daily-temperatures.py | 1,328 | 3.921875 | 4 | #
# @lc app=leetcode id=739 lang=python3
#
# [739] Daily Temperatures
#
# https://leetcode.com/problems/daily-temperatures/description/
#
# algorithms
# Medium (64.58%)
# Likes: 4010
# Dislikes: 122
# Total Accepted: 229.4K
# Total Submissions: 354.2K
# Testcase Example: '[73,74,75,71,69,72,76,73]'
#
#
# Given ... |
b83bf2769e04c91a58ced0c55bc85da7d25a8d4b | wxjlotus/Python | /python3.6/test.py | 576 | 3.75 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed May 31 17:23:25 2017
@author: wangxj
print ("Hello world!")
try:
print('try...')
r = 10 / int('2')
print('result:', r)
except ValueError as e:
print('ValueError:', e)
except ZeroDivisionError as e:
print('ZeroDivisionError:', e)
else:
print('no error... |
7d36649031e71b50efc232d0892f112719522bb9 | windelsalazar/sample | /hello.py | 313 | 4.1875 | 4 | from tkinter import *
root = Tk()
e = Entry(root, width= 50)
e.pack()
#e.insert(0, "Enter Your Name: ")
def myClick():
hello= "Hello " + e.get()
myLabel = Label(root, text= hello)
myLabel.pack()
#button name
myButton= Button (root, text="Enter", command= myClick)
myButton.pack()
root.mainloop() |
8b431ac15107888396a9ea085b95b9f47947dc0c | Iararibeiro/coding-challenges | /easy/arrays/RemoveDups.py | 679 | 3.859375 | 4 | from SingleLinkedList import SingleListNode
def solution(head):
node = head
while node is not None:
leaf = node.getNext()
if leaf is not None:
if node.getValue() == leaf.getValue():
node.setNext(leaf.getNext())
node = node.getNext()
def printList(head):
result = "["
node = head
while node:
result ... |
e9d575ad97fc13e3b1a09adceb0edcba728d7b4e | AndreySperansky/TUITION | /_STRUCTURES/LIST/Nested_list/iteration_list.py | 803 | 3.703125 | 4 |
"""" ОБХОД ВЛОЖЕННОГО СПИСКА """
def sumtree(L):
tot = 0
for x in L: # Обход элементов одного уровня
if not isinstance(x, list):
tot += x # Числа суммируются непосредственно
else:
tot += sumtree(x) # Списки обрабатываются рекурсивными вызовами
return tot
L = [1, [2... |
9bb804e3a791bd5505455c732a16ec9f33ed8f07 | exer047/homework_4 | /task_3.py | 275 | 4.0625 | 4 | numbers = [2, 4, 6, 8]
def f(numbers):
for element in range(len(numbers)):
if element == len(numbers) - 1:
numbers[element] = numbers[0]
else:
numbers[element] = numbers[element + 1]
return numbers
print(f(numbers)) |
23c60b35a1b171f3e93fb6b63cc57bbdc9ccf0ff | LoveDarkblue/PythonTest | /test3/test3_5.py | 131 | 3.734375 | 4 | # 筛选出一个序列中所有能整除2的数
def f1(i):
return i % 2 == 0
l = filter(f1, [1, 2, 3, 4, 5])
print(list(l))
|
7d8ffb173ce9ea8e74e731433a15e1dded9da9e1 | ZoranPandovski/al-go-rithms | /data_structures/trie/Python/trie.py | 2,605 | 4.1875 | 4 |
# Python program for insert and search
# operation in a Trie
class TrieNode:
# Trie node class
def __init__(self):
self.children = [None]*26
# isEndOfWord is True if node represent the end of the word
self.isEndOfWord = False
class Trie:
# Trie data str... |
3d9b71539f23a9314dea1efc9076a1c4e8ac54ae | GabrielSilva2y3d/Curso-em-video-python-exercicios | /Ex036.py | 949 | 4.09375 | 4 | #emprestimo
#Insira o valor da casa em reais:
valor_Casa = float(input('Qual o valor da casa? R$'))
#Insira o valor do seu salário em reais:
salario = float(input('Quanto é o seu salário? R$'))
#Informe em quantos anos o emprestimo sera dividido
anos_pagamento = int(input('Quantos anos de finaciamento? '))
#Valor da ... |
38e33b48076a570cab340c5481eb8ceb80ee7832 | Humbertzhang/LPTHW- | /ex12.py | 928 | 4.0625 | 4 | #-coding:utf-8--
age = raw_input("How old are you? ")
height = raw_input("How tall are you? ")
weight = raw_input("How much do you weight? ")
print "So, you are %r old, %r tall and %r heavy." %(age,height,weight)
#第一题
#输入 python -m pydoc raw_input 后输出:
#PS C:\LPTHW> python -m pydoc raw_input
#Help on ... |
68c66540466c167558cf0b1c33d22dc2b0eb4f67 | icjsb/Python_learning | /study1/test.py | 922 | 3.828125 | 4 | #coding=utf-8
len('ifdgsdg')
str(134)
a=[]
a.append(10)
print a
a.append(4)
print a
a.insert(2,3)
print a
a.index(4)
a.remove(3)
print a
a=[1,2,'ff']
a[2]
a='abcdef'
print a[:-1]
import random
print random.random()
[python]
<span style="font-size:18px">
from datetime import datetime... |
b282818bc358c32287d915a005fde96f76959f7b | sudhir192311/Top-Interview-Questions--Leetcode | /Top-Interview-Questions--Leetcode/Rotate Image/python.py | 427 | 3.71875 | 4 | video : https://www.youtube.com/watch?v=uSanzwcYEZg&list=PLlMTxcUZWpmBjE3Zm8pdgGfvG2iPOqk7m
class Solution:
def rotate(self, matrix: List[List[int]]) -> None:
for i in range(len(matrix)):
for j in range(i,len(matrix)):
matrix[i][j],matrix[j][i]=matrix[j][i],matri... |
5e50e8e10e1ebdf948b223806b22eb248948345e | syntaxmonkey/NNCourse | /FFT/diary.py | 474 | 3.84375 | 4 |
'''
How to plot using matplotlib:
Source: https://jakevdp.github.io/PythonDataScienceHandbook/04.12-three-dimensional-plotting.html
How to plot FFT:
https://docs.scipy.org/doc/numpy/reference/generated/numpy.fft.fftn.html#numpy.fft.fftn
plt.imshow(np.log(np.abs(np.fft.fftshift(FS))**2))
1. Can now plot the FFT in... |
28145475d50eab6f601005c8cbbaae94b817f087 | Raymond0620/Interview | /算法笔试/顺丰/2.py | 556 | 3.515625 | 4 | '''
@Descripttion:
@Author: daxiong
@Date: 2019-08-29 19:53:13
@LastEditors: daxiong
@LastEditTime: 2019-08-29 20:26:40
'''
size = int(input().strip())
nums = input().split()
nums = [int(x) for x in nums]
tail = [nums[0]]
for i in range(1, size):
left = 0
right = len(tail)
while left < right:
mid... |
5953eb85f63cbe615b1eff6f1936c338ad111abe | nullscc/pythoncode | /class03.py | 353 | 3.640625 | 4 | #!/usr/bin/python
# -*- coding:utf-8 -*-
class Animal(object):
def some_run(self, animal):
animal.run()
animal.run()
class Cat(Animal):
def run(self):
print('cat is runing')
class Dog(Animal):
def run(self):
print('dog is runing')
class Test(object):
def run(self):
print('test is runing')
ll = Animal... |
b93ec26ece258b23cc5296a255bf13e1fce58867 | jonathanFielder/slither_into_python_exercises | /ch16_question3.py | 440 | 3.90625 | 4 | def power_check(num):
print(num)
if (num % 2) != 0 and (num != 1):
return('Not a power of two!')
elif (num == 1):
return('Number is a power of two.')
else:
return(power_check(num/2))
def main():
#runtime testing
test = 4
while test < 200:
pri... |
952d4374acec8eb261fd04b8400a4de07fc89828 | haidragon/Python | /Python基础编程/Python-11/工厂方法模式.py | 1,345 | 4 | 4 | # 定义一个基本的4S店类
class Car(object):
#def setTypeName(self,TypeName):
# self.TypeName = TypeName
def __str__(self):
return "制造了一台"+self.typeName
def move(self):
print("----车在移动----")
def stop(self):
print("----停车----")
# 定义伊兰特车类
#class YilanteCar(object):
# 定义车的方法
# 定义索纳塔车类
#c... |
73bf7e304f36996e6ad482d58fa7ff5eee03088a | green-fox-academy/hoanjinan | /week-02/day-2/demo-w2d2/error-handling.py | 630 | 3.890625 | 4 | drinks = ["cola", "water"]
try:
index = int(input("Which item would you like to get?"))
print(drinks[index])
except IndexError:
print("Please provide a valid index.")
except ValueError:
print("Please use the index instead of the name.")
finally:
print("This will always run.")
print("Will it run?"... |
650cd9f5a4fd4b4d169146764ca7e7cd6e6669f6 | ocoetohe/Automation | /CCNA DevNet/lists2.py | 504 | 4.0625 | 4 | from __future__ import print_function
names = ["Ben", "Sally", "Amy", "George", "Randy", "Alice"]
print(names)
raw_newIndex = input('Please enter the index to replace: ')
newIndex = int(raw_newIndex)
newName = input('Please enter the name to put into index: ')
names[newIndex] = newName
print(names)
newName = input... |
3edf1b510d0afa4ac46dd00863da0e6f2017d587 | CesarJOtizM/learnPython | /curso-py/debugging.py | 613 | 3.984375 | 4 | def divisors(num):
divisors = []
for i in range(1, num + 1):
if num % i == 0:
divisors.append(i)
return divisors
def run():
while True:
try:
num = int(input('Enter a number: '))
if num < 0:
raise Exception('Negative number is not vali... |
d1ac4e675adc3e4abad82d9e0b96e31c2c9a2306 | blockchain99/pythonlecture | /ex122findduplicate.py | 2,843 | 4.1875 | 4 | '''
find_the_duplicate([1,2,1,4,3,12]) # 1
find_the_duplicate([6,1,9,5,3,4,9]) # 9
find_the_duplicate([2,1,3,4]) # None
'''
print("--------not intended ---------")
def find_the_duplicate(alist):
return list(x if alist.count(x) > 1 else None for x in alist) #not as intended!
print(find_the_duplicate([1,2,1,4,3,... |
afc0034826d2f6510e99fb94e0cb9ce4f51fce4a | 4nandes/CodeWars | /Python/findOutlier.py | 394 | 3.859375 | 4 | def find_outlier(integers):
odds = []
evens = []
for x in integers:
if (x%2 == 0):
evens.append(x)
else:
odds.append(x)
if len(evens) == 1:
return evens[0]
else:
return odds[0]
print(find_outlier([1, 2, 2]))
# print(find_outlier([2, 4, 0, 100,... |
b92550ae6322a52bd50a6a2123b5505fcfa342a5 | timlefkowitz/python | /Reading_and_Converting.py | 130 | 3.96875 | 4 | #Reading_and_Converting
name = input('Enter:')
print(name)
apple = input('Enter:')
# x = apple -10
x = int(apple) -10
print(x)
|
028518358c89a5fe1472c0e8bde1008d4a1c71d5 | pmarcol/Python-excercises | /Python - General/List/51-60/excercise60.py | 299 | 4.09375 | 4 | """
Write a Python program to find a tuple with the smallest second index value from a list of tuples.
"""
"""
SOLUTION:
"""
def myFunc(aList):
from operator import itemgetter
return sorted(aList, key = itemgetter(1))[0]
x = [(4, 1), (1, 2), (6, 0), (2, -2), (1, -1, 6)]
print(myFunc(x)) |
d695254cc2da69c501ea7c1623bddff9a90014b7 | teamhh-dev/aStar | /a_star_misplaced_tiles.py | 12,641 | 3.71875 | 4 | import math
from copy import deepcopy
class Puzzle:
def __init__(self,start_state:list,goal_state:list):
self.start_state=start_state
self.current_state=deepcopy(self.start_state)
self.goal_state=goal_state
self.blank_tile=self.findBlankTile()
self.length=len(self.s... |
2e73b847c6a4746de14579211da98148e44e464b | DavidC117/David_Castillo_1560 | /Precip.py | 1,113 | 3.546875 | 4 | import xlrd
from xlrd import open_workbook,cellname
from Array3D import Array3D
def main():
lluvias = Array3D(32,12,35)
a =0
b =0
c =0
for anio in range (1985,2020,1):
archivo=xlrd.open_workbook(filename="./Precipitacion/"+str(anio)+'Precip.xls')
hoja=archivo.shee... |
f180b9446f20b9f853b0fbb5bd202c89802ae295 | cesarandres8911/Python_exercises | /ExtractAudioFromVideo/ExtractAudio.py | 1,077 | 3.640625 | 4 | # Tutorial: https://github.com/antonioam82/ejercicios-python/blob/master/ventana_pesta%C3%B1as.py
# Graphic module to request saves and open files.
from tkinter.filedialog import askopenfilename, asksaveasfilename
# Python code to convert video to audio
import moviepy.editor as mp
import ffmpeg
# Manipulate path syste... |
95beb873fcbbcd0cea67ad6aeaf141f173cd024b | iapurba/datastructure-algorithms-python3 | /data-structures/array.py | 892 | 3.90625 | 4 | #!/usr/bin/env python3
class Array:
def __init__(self):
self.length = 0
self.data = {}
def append(self, value):
self.data[self.length] = value
self.length += 1
def get(self, index):
return self.data[index]
def pop(self):
lastItem = self.data[self.lengt... |
0272a22064c98adf22471e811d0155cc69743b25 | Takashiidobe/learnPythonTheHardWayZedShaw | /ex32.py | 1,457 | 4.4375 | 4 | """hairs = ['brown', 'blond', 'red']
eyes = ['brown', 'blue', 'green']
weights = [1,2,3,4]
this is list declaration
"""
the_count = [1,2,3,4,5]
fruits = ['apples', 'oranges', 'pears', 'apricots']
change = [1, 'pennies', 2, 'dimes', 3, 'quarters']
#this first kind of for-loop goes through a list
for number in the_coun... |
791015681da6cb072c2f19984dfbf792c83253c7 | JoseAntonioVelasco/2DAM_Workspaces | /Python/Actividad_pag58/operaciones/operacion/aritmeticasBasicas2/multiplicacionydivision.py | 202 | 3.59375 | 4 | #aritmeticasBasicas2
def multiplicacion(n1,n2):
resultado = n1*n2
print("La multiplicacion es ",resultado)
def division(n1,n2):
resultado = n1/n2
print("La division es ",resultado)
|
3faa78a868ce7542f2af9b0cb3cb40ac7d8cefe7 | MichelleLucero/assignments-12700 | /YT Learning/cl.py | 555 | 3.65625 | 4 | def strexp(s):
#if s = abc then retuen aababc
l = len(s)
i = 0
while i < l:
part = s[0:i+1]
result = result + 1
i = i + 1
return result
strexp("abcd")
def strexp_for(s):
#if s = abc then retuen aababc
l = len(s)
result = ""
for i in... |
1a326cc196976ed52be9cdbc6ac0bc74017b2b8f | vmaddukuri/vijayGitRepo | /code-snippets/numpy-notes/1-mem-space.py | 197 | 3.59375 | 4 | import numpy as np
import sys
# python numpy is that it occupies less memory as compared to list.
S = range(1000)
print(sys.getsizeof(5) * len(S))
D = np.arange(1000)
print(D.size * D.itemsize) |
fce3628df5b497b90f648d57b286230b65d236b3 | ByeongjunCho/Algorithm-TIL | /191004/3752_가능한시험점수.py | 325 | 3.5625 | 4 | s = set()
def all_vals(k, score):
if k == N:
s.add(score)
return
all_vals(k+1, score+vals[k])
all_vals(k+1, score)
T = int(input())
for tc in range(1, T+1):
N = int(input())
vals = list(map(int, input().split()))
all_vals(0, 0)
print('#{} {}'.format(tc, len(s)))
s = se... |
9cbc6c869fefd1704a70ffadbb63985b6ad94024 | hirurana/Past-Projects | /pythonFilesDAPS/projectWork/piCalc/piApprox.py | 1,122 | 3.953125 | 4 |
def estimate_pi(precision):
"""Due to the nature that this function depends on 9999999 random coordinates, the probability of getting the exact
value of pi is quite small and can only be achieved by either doing more computations (which would make the program
very slow) or by comparing the value estimated... |
0019be4961fd33183ad95cd11053269d7d9e8e44 | mijikm/algorithm-practice-leetcode | /python/013_Roman_to_Integer.py | 1,407 | 3.875 | 4 | '''
Roman numerals are usually written largest to smallest from left to right.
However, the numeral for four is not IIII. Instead, the number four is written as IV.
Because the one is before the five we subtract it making four.
The same principle applies to the number nine, which is written as IX.
There are six instanc... |
5f418e1d518e8a8c8083be47a3f089c2fe636567 | soobun/Python_Exercise | /CH_10/10_2.py | 428 | 3.8125 | 4 | # 10-2 C语言学习笔记:可使用方法replace() 将字符串中的特定单词都替换为另一个单词。
# 读取你刚创建的文件learning_python.txt中的每一行,
# 将其中的Python都替换为另一门语言的名称,如C。将修改后的各行都打印到屏幕上。
with open('learning_python.txt') as file_object:
for line in file_object:
print(line.replace('python', 'Java').rstrip())
|
2f95031ebc8ac99a1eda944dd91323e479fb4fe3 | ronan-bb/IOT | /gradient_color.py | 2,257 | 3.546875 | 4 | import pycom
import time
import machine
def hex_to_RGB(hex):
''' "#FFFFFF" -> [255,255,255] '''
# Pass 16 to the integer function for change of base
return [int(hex[i:i+2], 16) for i in range(1,6,2)]
def RGB_to_hex(RGB):
''' [255,255,255] -> "#FFFFFF" '''
# Components need to be integers for hex to... |
92705454ed4f625d8faf64ca8b291cc2234684a1 | JTS3/PythonABMs | /Yakovenko.py | 1,615 | 3.921875 | 4 | #This program implements something I saw Yakovenko of UMD show in a presentation about inequality.
#The random graph structure of the exchanges done during every tick produces a final histogram that is decidedly skewed.
# The skew is motivated by the zero lower bound on individual's balances.
# Set up the list of agen... |
f926348c09d83895963a11d7d183c5c16ac67fc7 | flacout/algorithm-bucket | /dijkstra.py | 1,585 | 3.75 | 4 | #Uses python3
import sys
import queue
def distance(adj, cost, s, t):
dist = [float('inf') for _ in range(len(adj))]
# keep prev if you want to reconstruct the path
#prev = [None for _ in range(len(adj))]
dist[s] = 0
pQueue = [float('inf') for _ in range(len(adj))]
pQueue[s] = 0
correctSpa... |
5e6a1e53444a77bd11cc97e70608e0d48ec203d1 | MarcinCosmosPL/Fair_Share | /Run Fair_Share.py | 6,824 | 3.703125 | 4 | import tkinter as tk
from functions import *
from Communicators import *
#necessary variables
cost = 0 #cost - to be stored in int - lowest currency units (gr = 0.01 pln) and displayed using MoneyFormat()
FandClist = [] #friends and contributions list - to be filled with tuples of names and abs amounts (in lowes... |
1f97ee268a54cbeb59a0fceeb2feb54527c58d9d | publicmays/LeetCode | /remove_nth_node_from_end.py | 1,039 | 3.609375 | 4 | class Solution(object):
def removeNthFromEnd(self, head, n):
if head is None: return None
head_copy = head
temp = None
counter = 0
while head is not None:
head = head.next
if counter == n:
temp = head_copy
if counter > n:
... |
a4f587f5c326ce9156b7bb89592ed48d6bed1664 | a-n-rose/games | /spell/spell.py | 1,312 | 4.03125 | 4 |
def spell(word):
'''little spelling game I made for my 3 year old.
Parameters
----------
word : str
The word to be spelled
Returns
-------
None
Examples
--------
>>> spell('happy')
Spell the word: happy
h
Great!
...
h____
...
... |
f5bd54a4cd1957ee79e222270a72a0fff35c4589 | HyoHee/Python_month01_all-code | /day17/exercise05.py | 1,224 | 3.578125 | 4 | """
定义函数,在员工列表中查找编号是1003的员工
定义函数,在员工列表中查找姓名是孙悟空的员工
"""
from common.iterable_tools import IterableHelper
class Employee:
def __init__(self, eid, did, name, money):
self.eid = eid # 员工编号
self.did = did # 部门编号
self.name = name
self.money = money
list_employees = [
Empl... |
62ce4666612fc7ceb23216a0d31fda8cac7668fb | wym693/python_learning | /chap5.py | 2,978 | 4.0625 | 4 | #!/usr/bin/en python
# -*- coding: utf-8 -*-
#dict 字典数据类型,
#1.和列表一样,可以存多个元素,但是无序(存入和输入元素可能不一样)
#2.通过索引访问元素,但是索引可以使用多种数据类型(可以同时在一个dict出现多种类型做索引=key),不仅是整数
#同一dict,value也可以多种
#3.字典是键值对,键就是索引,值就是value,key是不能重复。value是可以重复(存在多个key指向一个value)
#d={1: 'tom', 2: 'lisi', 3: 'wangwu', 4: 'wangwu'}
#d={'1': 'tom', '2': 'lisi', 3: ... |
9ec5c977a87b753553ab0a1bfb58f98244236e31 | tanglan2009/mit6.00 | /LecturePractice/L5P2.py | 402 | 4.09375 | 4 |
def iterPower(base, exp):
"""
base: int or float.
exp: int >= 0
return: int or float, base ^ exp
"""
result = 1
while exp > 0:
result *= base
exp -= 1
return result
def recurPower(base, exp):
if exp == 0:
return 1
if exp == 1:
return base
ret... |
21a5c1a421062a3a305314cca5f6591084b174a5 | gleydsonmazioli/pynet_ex | /class9/exercise5/mytest/world.py | 897 | 3.96875 | 4 | #!/usr/bin/env python
'''
Class 9 - Exercise 5
'''
#pylint: disable=invalid-name
def func1(param='World'):
'''
Print a parameter when a function is called
'''
print param
class MyClass(object):
'''
Main Class of the class exercise
'''
def __init__(self, x='param1', y='param2', z='para... |
b26465f9f5b5bb280969d958911b9d611e835029 | yangml6/LeetCode | /1-List/605_canPlaceFlowers.py | 1,015 | 3.703125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 18 09:54:59 2018
@author: yml
"""
#第一、最后可视为前后各加一个0
import re
class Solution(object):
def canPlaceFlowers(self, flowerbed, n):
"""
:type flowerbed: List[int]
:type n: int
:rtype: bool
"""
return su... |
17e21e0bb2d3a52f3055f7f8270d3131ee320d43 | themanoftalent/Python-3-Training | /07 Functions/functions-namedargs.py | 613 | 3.796875 | 4 |
def main():
testfunc(one = 1, two = 2, three = 3)
testfunc2(5, 6, 7, 4, 5, one = 1, two = 2, three = 3)
def testfunc(**kwargs):
print('This is a test function', kwargs['one'], kwargs['two'])
def testfunc2(this, that, other, *args, **kwargs):
print("This, that, other: ", this, that, other)
print("... |
1bc4d8936b491f0655697dda49127dd4cc0e4c42 | zalando/postgres-operator | /ui/operator_ui/backoff.py | 1,547 | 3.703125 | 4 | import random
def expo(n: int, base=2, factor=1, max_value=None):
"""Exponential decay.
Adapted from https://github.com/litl/backoff/blob/master/backoff.py (MIT License)
Args:
base: The mathematical base of the exponentiation operation
factor: Factor to multiply the exponentation by.
... |
3f8591418b0bb7f2552efc51f9b0e2e28867fd46 | sohn0356-git/TIL | /PyStudy/day02/test01.py | 230 | 3.875 | 4 | data = [1,2,3,4,5] # List
print(data)
sum=0
for d in data:
sum+= d
print(d, end = ' ')
print()
print(sum)
datas = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]
sum = 0
for dr in datas:
for dc in dr:
sum+=dc
print(sum) |
7c5a6f5f2c0089323f9c3846767a3ecbd8599e7f | Guzinanda/Interview-Training-Cracking-The-Coding-Interview | /01 Arrays & Strings/01-is-unique.py | 868 | 4.15625 | 4 | """
@ Is Unique | 1.1
@ Problem
Implement and algorithm to determine is a strigs has all unique characters.
What if you cannot use additional data structures?
@ Example
Input: str = Hi
Output: True
Input: str = Hello
Output: False
@ Template:
01. Create a dictio... |
5d70385586172cc7bea3940f23fdcd939c543f45 | zhiymatt/Leetcode | /Python/68.text-justification.132244884.ac.python3.py | 2,990 | 3.515625 | 4 | #
# [68] Text Justification
#
# https://leetcode.com/problems/text-justification/description/
#
# algorithms
# Hard (20.00%)
# Total Accepted: 69.6K
# Total Submissions: 348.2K
# Testcase Example: '["This", "is", "an", "example", "of", "text", "justification."]\n16'
#
# Given an array of words and a length L, forma... |
c17bd6e4d40e90c089fc9a77b7c7ee59f2059852 | gschen/where2go-python-test | /1906101031王卓越/以前的代码/列表.py | 429 | 3.625 | 4 | for b in range(4):
i = False
while i==False:
name=input("用户名:")
password=input("密码:")
while name == "王卓越" and password == "123":
print("登陆成功")
# print(i=True)
else:
print("登陆失败")
print("你还剩%d次机会" % (3-b))
break
else:
... |
94d1b6a23b2b5a754510a21ebe63c5e94734ed05 | sungwoncho94/SWexpert | /intermediate/day_09/지영_2048.py | 3,650 | 3.53125 | 4 | def notwall(new_x, new_y):
return 0 <= new_x < N and 0 <= new_y < N
def zeroleft(x, y):
global arr
if arr[x][y] == 0:
for i in range(y, N, 1):
for j in range(i, N, 1):
if notwall(x, j):
if arr[x][j] != 0 and arr[x][i] == 0:
ar... |
98ea2e661304a0827b3e20aaba8be840f782b956 | bitjefe/depaul-cs | /applied-algorithms/4thought.py | 517 | 3.78125 | 4 | # accepted by Kattis
m = int(input())
operations = ['+', '-', '*', '//']
possibleResult = {}
for op1 in operations:
for op2 in operations:
for op3 in operations:
equationStr = '4 ' + op1 + ' 4 ' + op2 + ' 4 ' + op3 + ' 4'
result = eval(equationStr)
possibleResult[resul... |
e42be224fb4513e0db9e5df708eabc884e50132d | DayGitH/Python-Challenges | /DailyProgrammer/DP20120615A.py | 1,640 | 4.21875 | 4 | """
Write a program that given a floating point number, gives the number of American dollar coins and bills needed to
represent that number (rounded to the nearest 1/100, i.e. the nearest penny). For instance, if the float is 12.33, the
result would be 1 ten-dollar bill, 2 one-dollar bills, 1 quarter, 1 nickel and 3 pe... |
ec760278910f9da4625f37cd5a8e193ad9d43d82 | Pnickolas1/Code-Reps | /AlgoExpert/Graphs/validate_BST.py | 619 | 4.09375 | 4 |
"""
validate a BST
time: O(n) # n is the number of nodes
space: O(d) # d is the depth of the tree, length of the longest branch
- this is because we are calling the function and putting it on the call stack
"""
def validateBSTHelper(tree, minValue, maxValue):
if tree is None:
return True
if tree.v... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.