blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
49e055bca5c2583e22d6cf48a570c5c32a830c71
aysin/Python-Projects
/repeat.py
271
4
4
#defines a 'repeat' function that takes 2 argument def repeat(s, exclaim): result = s * 3 if exclaim: result += '!!!' return result def main(): print repeat ('Yay', False) print repeat ('woo hoo', True) print repeat('Yay', False) print repeat('Woo Hoo', True)
d190cf17e29502fd451ff812f68414fef94eeec9
aysin/Python-Projects
/ex32.py
538
4.65625
5
#creating list while doing loops the_count = [1, 2, 3, 4, 5] fruits = ['apple', 'oranges', 'pears', 'apricots'] change = [1, 'pennies', 2, 'dimes', 3, 'quarters'] #this first kind of for loop goes through a list for n in the_count: print "This is count %d." % n #same as above for n in fruits: print "A fruit type ...
cd8dd7f643ff410882645f6492d301197eeee484
nyLee-max/python_study
/chap03/chap03_01.py
112
3.53125
4
# 값 비교 print(10 == 100) print(10 is 100) print(10 != 100) print(10 is not 100) x = 25; print(20 < x < 30)
9514e7d97fcfa6bc45e153ac464989b4868ab991
bmargerison/codewars
/Python/MakeUpperCase (8kyu).py
189
3.96875
4
""" Write a function which converts the input string to uppercase. """ # my solution def make_upper_case(s): return s.upper() # best solution def make_upper_case(s): return s.upper()
5ee3bde1ea205254430a61648a14d1909d0956ae
ankimoha/BookStore
/frontend.py
3,195
4.125
4
""" This is an application that store all the information of a book in a bookstore These are the things that a user can do in this application: search a book add a book update an entry delete close """ from tkinter import * import backend def get_selected_record(event): try: global selected_tuple i...
ef43ec961cbe83db63f0d53f56796ecf2cc12b37
AshTiwari/Python-Guide
/OOPS/OOPS_global_local_static_instance_variable.py
559
3.65625
4
#global, local, static, instance variable. #global variable are defined at the op of program or defined using keyword:global global global_var1 = 1 def local_variable: #local variable are defined inside of a function or a class. local_var1 = 2 class static_instance: #local variable are defined inside o...
0dd3b07d4250e643eab1ce11efbe11d05bfbf6cb
AshTiwari/Python-Guide
/staticmethod_Iheritance.py
584
3.859375
4
# static method in inheritance class Parent: class_var1 = 1 def __init__(self): self.param1 = 10 self.param2 = Parent.staticmethod1() self.param3 = self.staticmethod2() @staticmethod def staticmethod1(): return 20 @staticmethod def staticmethod2(): ret...
8d48eb05e3ba95ea9a2818f1b4ac5729c39aa3e8
AshTiwari/Python-Guide
/Basic Python/user_defined_functions.py
1,157
4.09375
4
#User Defined Functions in python # Functions #Syntax ''' def funct_name (parameters): statements return (expression) x = funct_name(parameter_value) #x takes the value returned by function. #If the function dosen't return any value the x will take value 'None'. ''' def ...
13a8aa65cf25ed0cf5b42a45f92c9fa5fc6b7e93
AshTiwari/Python-Guide
/Regex/Regular_Expression.py
4,578
3.9375
4
# regular expression. import re message = ('Call at +91-9280690895 or +91-9920699095') RegExpObj = re.compile(r'\+\d\d-\d\d\d\d\d\d\d\d\d\d') #raw string as an input argument. #findall() print('\n\nfindall()') print('Prints all regular expression and its group.') m_o = RegExpObj.findall(...
1689e0badd6bfc5c742c18bbce1df341cda6f723
AshTiwari/Python-Guide
/OOPS/OOPS_Class_Composition_vs_Aggregation.py
327
3.828125
4
# difference between class composition and aggregation. print('1.') print('-In composition, if the object of second class deletes then') print(' the object of first classs automatically deletes.') print('-But, in aggregation both the objects are intanstiated seperately,') print(' so they dont have an effect on each ot...
328e01359af583ee01b0d794f2cea72e30e382cd
AshTiwari/Python-Guide
/Files/file_os_delete_file.py
1,029
3.953125
4
#deleting files. import os os.path.isfile('D://f1.txt') os.path.isdir('D://f1') #for deleting files, access is denied. #PermissionError: [WinError 5] Access is denied: 'C://Users//MSI//Desktop//folder' #We can try to delete folder by changing user account control. #Alternatively, we can check that the programming i...
b8b2a1657751ce23a002789f4cc298aecaf43263
AshTiwari/Python-Guide
/OOPS/OOPS_Operator_Overloading.py
158
3.6875
4
# operator overloading print('Everything is object in python.') print('- ' + str(type(2))) print('- It is an object of class "int".') # yet to complete.
210541b96402d575201e7bce74d539bd89e8aa97
AshTiwari/Python-Guide
/Python Iter Tools/namedtuple_methods().py
318
3.921875
4
#named tuple functions. from collections import namedtuple student = namedtuple('student','name age') print('Functions in namedtuple.') print('\nPrint field of tuple.') print(student._fields) s1 = ('Ash',21) s2 = ('Ashu',22) print('\nPrinting tuple of namedtuple.') t = (s1, s2) print(t) print(type(t[1]))
49210e9015050c7aefcbb429b1815f01e6e6a44e
AshTiwari/Python-Guide
/OOPS/OOPS_encapsulation.py
1,474
3.890625
4
#encapsulation. class unencapsulated: def __init__(self,rNo): self.roll_no = rNo class encapsulated: def __init__(self,rNo): self.__roll_no = rNo def getRollNo(self) : return self.__roll_no def changeRollNo(self,no): self.__roll_no = no unsafe = unencapsul...
cde03d01900ffa7f01f5f80e4bfc869454ac8116
AshTiwari/Python-Guide
/OOPS/OOPS_Abstract_Class_and_Method.py
720
4.5625
5
#abstract classes # ABC- Abstract Base Class and abstractmethod from abc import ABC, abstractmethod print('abstract method is the method user must implement in the child class.') print('abstract method cannot be instantiated outside child class.') print('\n\n') class parent(ABC): def __init__(self): pass...
eb9dee9b3ae053c0fb598791d6cd7f40e2171a87
AshTiwari/Python-Guide
/Regex/Regular_Expression_search()andgroup().py
701
3.84375
4
#search(pattern) and group() import re message = ('Call at +91-9280690895 or +91-9920699095') RegExpObj = re.compile(r'\+\d\d-\d\d\d\d\d\d\d\d\d\d') #raw string as an input argument. #search() m_o = RegExpObj.search(message) #match_object searches the expresion in the message print('...
fb1a77d591507125bed703a7da342f8a20d1c21a
AshTiwari/Python-Guide
/Graphs/shortest_path_using_top_sort.py
975
3.734375
4
# shortest path on DAG # handles negative edges. from topological_sort import topologicalSort def shortestPath(adjacent, edge_weight): topological_sort = topologicalSort(adjacent) start = topological_sort[0] distance = [float("inf") for i in range(len(adjacent))] distance[start] = 0 parent = {star...
7e4ddd15e0f172c12d428ae551708b3c650abc08
ColinFendrick/python-udemy
/python-1000/s5/mylistdelta.py
154
3.625
4
zlist = ["Fred", "Ralph", "Zelda", "Zoe"] print(type(zlist)) for index in range(len(zlist)): zlist[index] = "Guest " + zlist[index] print(zlist)
11534692689f007ac35d5ceea6075fc24f86a318
JeremyPaulPalmer/Python-Projects
/Hangman/bad_guess.py
2,373
4
4
import hangman #Graphic representation of each stage of incorrect guesses. Final incorrect #guess results in play defeat, hanged man, and prompt to show word and start #new game def bad_guess(x, word, letters): if x == 6: print(' _____') print(' | |') print(' O |') print(' ...
16ce6311c48799bc0773f095191fe66c6541cf75
JeremyPaulPalmer/Python-Projects
/Yahtzee/yahtzee.py
2,524
3.6875
4
import global_var import dice_roll import os import sys import view_dice import upper_lower import card import choice import time print('Welcome to Yahtzee!') card.card() def play(): print('Roll', global_var.roll_counter + 1) time.sleep(2) full_upper = False full_lower = False #while upper...
e43016c2f00cf2b4c02a1b79666c0b8e6596fa5c
JeremyPaulPalmer/Python-Projects
/Yahtzee/upper_score.py
3,861
3.921875
4
import global_var import time import card def upper_score(): score = (input('Where would you like to score? (1-6) ')) while score != '1' and score != '2' and score != '3' and score != '4' and score != '5' and score != '6': score = (input('Where would you like to score? (1-6) ')) if score == '0' o...
8971130c5137892b0c1d8d4a522e99137320fe66
JamesLuoau/reinforcement_learning
/model_based_keras.py
5,914
3.578125
4
import numpy as np import matplotlib.pyplot as plt import gym env = gym.make("CartPole-v0") learning_rate = 1e-3 # Learning rate, applicable to both nn, policy and model gamma = 0.99 # Discount factor for rewards decay_rate = 0.99 # Decay factor for RMSProp leaky sum of grad**2 model_batch_size = 3 # Batch si...
e3e3d219ebe745654300590349f8ada101ff0181
billtomking/Python_Practice
/井字棋/井字棋胜率估计(非随机).py
12,185
3.640625
4
#随机下子 import copy import random from time import time from pprint import pprint import csv TheBoard = {'1':' ','2':' ','3':' ', '4':' ','5':' ','6':' ', '7':' ','8':' ','9':' '} jie = '' def printboard(board): print('-' * 20) print(j) print(jie) print(board['1'] + '|' + board['...
f78e136d2c84ef95c26714d1f0bee1e901334128
billtomking/Python_Practice
/文本加密解密/0.1/加密.py
5,995
3.578125
4
# 之后应该可以将字数转换部分集合到一个函数里 ming_wen = input('请输入明文(带空格)') ming_wen = ming_wen.upper() ming_wen = list(ming_wen.split()) mingl = len(ming_wen) mi_wen = [] n = 0 def chuang_yao(n): # 用于产生随机密钥,之后可以考虑修改让用户自行输入 import random if n=='': n = mingl i = 1 n = int(n) mi_yao = [] while i <= n: ...
f7d8a882ffb990d069f1cb3e1119881752ea6beb
murphyptx/murphytools
/pdf_imageonly/pdfcheck.py
884
3.65625
4
import pdfplumber # the power tool to rip through and analyze the PDFs import glob # filename pattern matching import os # for interacting with the file system import shutil # sile system operations; copying, etc. pdf_source_path = "" pdf_no_text_path = "" pdf_text_path = "" print('You are about to analyze PDFs for t...
47d9de81f2dca433304440c3eed83f236f1f78a0
kirane61/letsUpgrade
/Projects/Milestone project/TicTacToe/game.py
5,553
4.3125
4
#Write a function that can print on a board #set your board as a list #Where each index 1-9 corresponds with a number on a number pad #You get a 3 by 3 board representation # from IPython.display import clear_output def display_board(board): # clear_output() print('--------------------------') print(' ...
54acadc2fb5af27b386dd4ead0cbfcdd62492a53
kirane61/letsUpgrade
/Day3/ContactBook.py
526
3.796875
4
#Contact Book howManyContact = int(input("Enter the number of contacts you want to add: ")) contactDictionary = {} for i in range(0,howManyContact): name = input("Enter Name:") number1 = input("Enter number1:") number2 = input("Enter number2:") imageurl = input("Enter imageUrl:") email = input("Enter emai...
597e2b3918aa6a8bf0a63d2c6a8e88722c4d471f
hernaneche/gpiotest
/gpiotest.py
556
3.78125
4
#!/usr/bin/python #coding: latin-1 import RPi.GPIO as GPIO # Selecciona numeración de pines # BCM es nro de gpio # BOARD es nro de pin (indicado en placa) pinNumber = 12 GPIO.cleanup() GPIO.setmode(GPIO.BOARD) GPIO.setup(pinNumber, GPIO.OUT) #configura como salida #GPIO.output(pinNumber, False) #manejo individua...
4bc681eda2ae57a3d3b55dbba931d7130ecb6b67
jklusnick/fashion_app
/create_person.py
601
4.03125
4
class Person: """GBiT student""" def __init__(self, age, name, eye_color, fav_ice_cream): self.age = age self.name = name self.eye_color = eye_color self.fav_ice_cream = fav_ice_cream def print_person(self): print "This person's name is " + self.name + ", " + str(self.age) + " years old, has " + self.eye_...
9a5abf54834ca5034906b847c71539513ee9fa28
alastairparagas/functionalprogramming-workshop
/dataisimmutable.py
788
3.921875
4
# Bad Example def mutatesParams(mutableObjectParam): mutableObjectParam["newAddedProperty"] = "someValue" return mutableObjectParam someObject = { "key": "value" } returnValue1 = mutatesParams(someObject) print("newAddedProperty" in someObject.keys()) print("newAddedProperty" in someObject.keys()) print(someOb...
e8187f4393ff43fc5d05a2a836249ecab831a4e3
MariaKrepko/my_python
/my_max.py
86
3.640625
4
num1=input() num2=input() if num1 > num2: print(num1) else: print(num2)
c6032cb68386c2ddc8018f357f98624a9440fcf8
mhigu/AutonomousFlyingCar
/lessons/MovingInto3D/random_sampling.py
2,910
3.90625
4
import time import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from shapely.geometry import Polygon, Point """ In this notebook you'll work with the obstacle's polygon representation itself. Your tasks will be: Create polygons. Sample random 3D points. Remove points contained ...
b385be1d7263a98675cc78190b4ca1b74ae322a4
bbiiggppiigg/basicml
/hw1/code/vector.py
1,403
3.671875
4
#!/usr/bin/python class vector: def __init__(self,n): self.value = [0]*n def set_value_by_vector(self,v): if(v.length() != self.length() ): print "Error" return -1; for i in range(v.length()): self.value[i]=v.value[i] #print (self.value,self.length); def set_value_by_list(self,v): if(len(v)!=sel...
483e55d99cef39b301fd288a1574c6797841ee50
jinliangXX/LeetCode
/27. Remove Element(移除元素)/solution.py
828
3.59375
4
from typing import List class Solution: def removeElement(self, nums: List[int], val: int) -> int: if not nums: return 0 left, right = 0, len(nums) - 1 while left <= right: if nums[left] == val: is_true = False while right > left: ...
c01e19399cc294ef21fa48add227a9f976ae67ae
jinliangXX/LeetCode
/59. Spiral Matrix II(螺旋矩阵 II)/solution.py
851
3.5625
4
from typing import List class Solution: def generateMatrix(self, n: int) -> List[List[int]]: if n <= 0: return list() result = [[0 for _ in range(n)] for _ in range(n)] i, j = 0, 0 turns = ((0, 1), (1, 0), (0, -1), (-1, 0)) turn = 0 for k in range(1, n *...
63e8f13a4abdd89ce94e29b10ace4165d3ddd0ac
jinliangXX/LeetCode
/655. Print Binary Tree(输出二叉树)/solution.py
837
3.828125
4
# Definition for a binary tree node. from typing import List class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def printTree(self, root: TreeNode) -> List[List[str]]: def get_deep(node: TreeNode): if not node: ...
94555b4909e244e1e8e9e23bb97ad48b81308118
jinliangXX/LeetCode
/380. Insert Delete GetRandom O(1)/solution.py
1,462
4.1875
4
import random class RandomizedSet(object): def __init__(self): """ Initialize your data structure here. """ self.result = list() self.index = dict() def insert(self, val): """ Inserts a value to the set. Returns true if the set did not already contain ...
af9bee822dff5d0926796378cf9915b611fd1aa6
jinliangXX/LeetCode
/445. Add Two Numbers II/solution.py
1,084
3.734375
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def addTwoNumbers(self, l1, l2): """ :type l1: ListNode :type l2: ListNode :rtype: ListNode """ stack_l1 = list() st...
cb51a81e4c0632bb2b3a744a0d81dcdf22221aa1
jinliangXX/LeetCode
/508. Most Frequent Subtree Sum(出现次数最多的子树元素和)/solution.py
1,375
3.671875
4
# Definition for a binary tree node. from typing import List class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def findFrequentTreeSum(self, root: TreeNode) -> List[int]: if not root: return list() self....
2ff1f2032f65bb0a23a44c71cce2ae6149237466
jinliangXX/LeetCode
/654. Maximum Binary Tree(最大二叉树)/solution.py
706
3.890625
4
# Definition for a binary tree node. from typing import List class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def constructMaximumBinaryTree(self, nums: List[int]) -> TreeNode: if not nums: return None ...
ead2a7fd5b119248dde16b690afaafab388ecb49
jinliangXX/LeetCode
/166. Fraction to Recurring Decimal/solution.py
1,222
3.6875
4
class Solution(object): def fractionToDecimal(self, numerator, denominator): """ :type numerator: int :type denominator: int :rtype: str """ first = 1 if numerator < 0: numerator = -numerator first = -first if denominator < 0: ...
4546f14c41c87e28bb3bf7e8a5ec3036b3460b09
jinliangXX/LeetCode
/124. Binary Tree Maximum Path Sum(二叉树中的最大路径和)/solution.py
1,169
3.8125
4
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def maxPathSum(self, root: TreeNode) -> int: self.result = int(-100) def get_result(node: TreeNode) -> int: if not n...
663fc3868cc9a9a56f07b979a55fabd72892f88c
jinliangXX/LeetCode
/5. Longest Palindromic Substring/solution.py
607
3.5
4
class Solution: def longestPalindrome(self, s: str) -> str: result = '' method = [[0, 1], [1, 0], [1, 1]] for i, char in enumerate(s): for met in method: left, right = i - met[0], i + met[1] while left >= 0 and right < len(s) and s[ ...
6745bddaba6f219dd408eaf1bde0b31bc1382fea
jinliangXX/LeetCode
/409. Longest Palindrome(最长回文串)/solution.py
541
3.65625
4
import collections class Solution: def longestPalindrome(self, s: str) -> int: a_dict = collections.Counter(s) result = 0 is_odd_number = False for char in a_dict: if a_dict[char] % 2 == 0: result += a_dict[char] else: is_odd_...
49f34fc8099a75e31180597c8af51e29a05fce81
jinliangXX/LeetCode
/70. Climbing Stairs/solution.py
576
3.796875
4
class Solution: def climbStairs(self, n: int) -> int: last_two = 1 last_one = 2 if n < 3: return n for i in range(n + 1): if i < 3: continue num = last_two + last_one last_two = last_one last_one = num ...
8ba913b7250f65e2e11701f7216ba7704d3ba513
jinliangXX/LeetCode
/面试题 01.06. 字符串压缩/solution.py
439
3.671875
4
class Solution: def compressString(self, S: str) -> str: left, right = 0, 0 result = '' while right < len(S): while right < len(S) and S[right] == S[left]: right += 1 result += S[left] + str(right - left) left = right return result ...
7f1deca0b2a2fdfb6126895717e120bdfbb33d91
jinliangXX/LeetCode
/44. Wildcard Matching(通配符匹配)/solution.py
777
3.578125
4
class Solution: def isMatch(self, s: str, p: str) -> bool: m, n = len(s), len(p) result = [[False for _ in range(n + 1)] for _ in range(m + 1)] result[0][0] = True for i in range(1, n + 1): if p[i-1] == '*': result[0][i] = result[0][i - 1] else...
6387bd99d374b9dd5e10b02777622f15c810b8f4
jinliangXX/LeetCode
/103. Binary Tree Zigzag Level Order Traversal/solution.py
935
3.65625
4
# Definition for a binary tree node. from typing import List class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def zigzagLevelOrder(self, root: TreeNode) -> List[ List[int]]: self.result = list() result = se...
cc8fcc5f18b08502b4035a9ecc72711413c96614
jinliangXX/LeetCode
/530. Minimum Absolute Difference in BST(二叉搜索树的最小绝对差)/solution.py
874
3.671875
4
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def getMinimumDifference(self, root: TreeNode) -> int: self.result = None self.last = None if not root: return...
42db1c7acd7d615fdd39d56ab45f5f05f7f1f3bb
jinliangXX/LeetCode
/814. Binary Tree Pruning(二叉树剪枝)/solution.py
611
3.78125
4
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def pruneTree(self, root: TreeNode) -> TreeNode: if not root: return None left_result = self.pruneTree(root.left) ...
8bb1692cb6deaaea9046fe892f7014f7d48daf46
jinliangXX/LeetCode
/872. Leaf-Similar Trees(叶子相似的树)/solution.py
683
3.921875
4
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def leafSimilar(self, root1: TreeNode, root2: TreeNode) -> bool: def get_result(node: TreeNode, result): if not node: ...
4ebb0881083611f711b8ac1fe710f47ae6a070cf
jinliangXX/LeetCode
/297. Serialize and Deserialize Binary Tree(二叉树的序列化与反序列化)/solution.py
2,470
3.796875
4
# Definition for a binary tree node. import json from queue import Queue class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Codec: def serialize(self, root): """Encodes a tree to a single string. :type root: TreeNod...
55d1e60b44b18fdffc5ddce1516f5bf533be7e89
smruti-10/zelthy
/assignment_3/wifi_networks.py
482
3.6875
4
class Wifi(): def __init__(self): self.wifi_networks = [">[1] Wifi_network 1",">[2] Wifi_network 2",">[3] Wifi_network 3"] print("> Your available wifi networks are:") for i in self.wifi_networks: print(i) self.wifi_choice = input("Your choice?") if self.wifi_choi...
c33b8d86a0050189b9c31c284c75d1c4a08014e8
codymlewis/perceptron
/Perceptron.py
7,225
3.734375
4
#!/usr/bin/env python3 import argparse import numpy as np import pandas as pd ''' An implementation of a multi-layer perceptron. Author: Cody Lewis Date: 2019-09-21 ''' class Neuron: '''A neuron of the perceptron''' def __init__(self, input_layer=False): self.activation_strength = 0 self...
fe09cf57664dc6a49600db1481f9fb0024d9d88b
z1908144712/leetcode
/48/main.py
637
3.734375
4
from typing import List class Solution: def rotate(self, matrix: List[List[int]]) -> None: n = len(matrix) for i in range(0,n-1): for j in range(i+1,n): matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j] i, j = 0, n-1 while i < j: for k i...
5ea0cc442e77167a80c56151628227d91d4b0889
sathvik-85/Pong-game
/pong.py
2,065
3.53125
4
# Importing the library import pygame,random, time # Initializing Pygame pygame.init() #Window size WIDTH,HEIGHT = 700,800 # Initializing surface win = pygame.display.set_mode((WIDTH,HEIGHT)) pygame.display.set_caption("Pong") # Initialing RED RED = (255,0,0) BLUE_LIGHT = (52, 232, 235) WHITE = (255,255,255) ...
3e53d2ad752183297b106c314c893fcf9078c65e
macord1/LazorProject
/Lazor.py
25,648
3.546875
4
from itertools import permutations from itertools import combinations import copy import numpy as np ''' SOFTWARE CARPENTRY LAZOR PROJECT Molly Accord Sreelakshmi Sunil ''' ''' Computes solutions from bff file of lazor game. Solutions are saves as a text file - solution.txt Separate unit_tests.py file...
f7039a59a2634d081b488230a2824f55058989ef
rafaelgmenezes/Mapping_kml
/kml_to_df.py
2,745
3.640625
4
# -*- coding: utf-8 -*- """ Created on Thu May 28 16:49:08 2020 @author: Rafael G. de Menezes Oceanographer, Msc. Marine Biotechnology Clube do Cientista Biosustente Estudos Ambientais ltda. Developed with Python 3.7.6 README: Python function to transform google earth .kml files list into a pandas Da...
4078939ebf8447a2f72f802a1479bf82126175f0
ilyaperepelitsa/pydata
/databases.py
793
3.734375
4
import sqlite3 import pandas as pd from pandas import DataFrame query = """ CREATE TABLE test (a VARCHAR(20), b VARCHAR(20), c REAL, d INTEGER );""" con = sqlite3.connect(":memory:") con.execute(query) con.commit() data = [('Atlanta', 'Georgia', 1.25, 6), ('Tallahassee', 'Florida', 2.6, 3), ('Sacrame...
8316850c2d6ae5b3ba5ec731786c2c727ae10fc8
LiuMaoYang/SwordForOffer
/18/__init__.py
1,283
3.796875
4
# -*- coding:utf-8 -*- class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def createTree(self): global data x = data[0] del data[0] if x == '#': node = None else: node = TreeNode(x) ...
f26e4b7a391b46d38c6a5a84d73c8508dc34eb58
LiuMaoYang/SwordForOffer
/12/main.py
389
3.6875
4
# -*- coding:utf-8 -*- class Solution: def __init__(self): pass def Power(self, base, exponent): e=abs(exponent) y=1.0 while(e>0): y=y*base e=e-1 if(exponent<0): y=1/y return y so=Solution() base=float(raw_input()) exp=int(...
5155a530d3d3dee39d7f94f0d1ad1901c1cefbfe
Verycoder/Verycoder.github.io
/mywork/python/reptile/regular.py
560
3.609375
4
''' . : 匹配任意字符,换行符\n除外 * : 匹配前一个字符0次或无限次 ? : 匹配前一个字符0次或1次 .*: 贪心算法 .*?: 非贪心算法 () : 括号内的数据作为返回结果 ''' import re secret_code = 'hadkfalifexxIxxfasdjifja134xxlovexx23345sdfxxyouxx8dfse' # . 的使用 #a = 'xz123' #b = re.findall('x.', a) #print(b) # *的使用 #a = 'xyxy123' #b = re.findall('x*', a) #print(b) # ?的使用 #a = 'xy123' #...
0d6618e8d328877e5d121958a59e5caf6334457d
Verycoder/Verycoder.github.io
/mywork/python/returnoffunc.py
215
3.5625
4
#encoding ''' def test(): i = 7 return i print(test()) ''' def test2(i, j): '''this is a test function''' result = i * j return (i, j, result) #print(test2(2, 5)) ''' a = test2(4, 6) print(a[2]) ''' help(test2)
d38a5e6361641c908495f91e3a0c8890959f9335
Verycoder/Verycoder.github.io
/mywork/python/if.py
99
4.03125
4
a = 3 if (a == 8): print("a = 8") elif (a == 9): print("a = 9") else: print("a != 8 && a != 9")
f3929bb9278ceb71bca85fa1aeb8f31e52d8337a
ayushi-rathod/creative-engine
/imageutil.py
1,924
3.625
4
from PIL import Image from PIL import ImageDraw from PIL import ImageFont # author: Prateek Rokadiya # Example usage # img = resizeByWidth(img, w, p) # where, w = wanted width, p = padding (decreases more width) def resizeByWidth(img, toWidth, padding = 20): new_width = toWidth - padding new_height = new_wid...
0c127c312750a34e1161876e1f5cf3d9e1ba8b81
Aarti5424/Week2Assignment
/main.py
411
3.984375
4
from math import pi r = float(input ("Input the radius of the circle : ")) print ("The area of the circle with radius " + str(r) + " is: " + str(pi * r**2)) fname = input("Input your First Name : ") lname = input("Input your Last Name : ") print ("Hello " + lname + " " + fname) import datetime now = datetime.datetim...
e8c4f5dcc44e10a19ab4699eec662ea89b841261
boubli/Encrypt-messages
/__main__.py
2,769
3.59375
4
from tkinter import * from tkinter import ttk import sys, random from tkinter import messagebox LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def main(): myMessage = vv.get() myKey = 'HWERTUYIOPQSDFGAJKLZXCVBNM' myMode = v.get() if myMode == 'mode22': translated = encryptMessage(myKey, myMessage) ...
248b55c5db43544fc57eca7723e703f61f6a9285
Khoa100/RegularCode
/Point.py
752
3.53125
4
class Point: def __init__(self, row_init, col_init): self.row = row_init self.col = col_init def mid_left(self): return Point(self.row, self.col-1) def mid_right(self): return Point(self.row, self.col+1) def vert_left(self, vert_dir): return Point(s...
16971cbd6d666cd37b33803f08c0c4af22ac3730
thatDaiwikKashyap/Face-Recognition-With_Pic
/facereco.py
723
3.859375
4
#import CV2 https://pypi.org/project/opencv-python/ import cv2 #Train the code trained_face_data = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') # Choose an image to detectfaces in #img = cv2.imread('pic1.jpg') img = cv2.imread('pic2.jpg') # Must Convert to grey scale grayscaled_img = cv2.cvtColor(...
076a40fc02b0791eedaae92747394f46170a9678
prathyusak/pythonBasics
/errors.py
2,720
4.21875
4
#Syntax Errors and Exceptions #while True print('Hello world') => syntax error #ZeroDivisionError =>10 * (1/0) #NameError => 4 + spam*3 #TypeError => '2' + 2 ################# # Handling Exceptions import sys def this_fails(): x = 1/0 while True: try: x = int(input("Please enter a number: ")) t...
894e6ecd16cceb83d90cf431d37f913c20fb3b11
nikhilpradhan28/python_basic
/odd_even_list_for.py
258
4.03125
4
a=[] n=int(input("Enter number of elements:")) for i in range(1, n + 1): b = int(input("Enter element:")) a.append(b) print(a) even=[] odd=[] for j in a: if(j%2==0): even.append(j) else: odd.append(j) print(even) print(odd)
1017d52173ea39db94f0e419d4ba011357af3dc0
nikhilpradhan28/python_basic
/Python_DataType/string_operations.py
210
3.578125
4
#print("Hello I am Nikhil") #print('I am going to learn python') #print("Hello I am Nikhil\t"+"I am going to learn python") #print("Hello I am Nikhil\n"+"I am going to learn python") print("7"+"7") print("7"*7)
e0023cf7a93de5270f164ed012d01ccd2b4e6ecc
annargrs/ldt
/ldt/helpers/formatting.py
3,915
4.40625
4
# -*- coding: utf-8 -*- """Text formatting functions This section includes a few helper functions for formatting different spelling variants. """ def remove_text_inside_brackets(text, brackets="()[]"): ''' A helper function for :func:`get_relations`, code from `here <https://stackoverflow.com/questions...
50c4c4c68abf3a777b4195e41b970174ae0173a2
adonispujols/Adonis_ASC3
/Bouncing_Ball_app/Bouncing_Ball_app.pyde
980
4
4
#Makes a ball bounce off the walls at set angles but starting from a random direction from random import * #Setting varaibles for easy customization x_boundary = 400 y_boundary = 400 x_coordinate = 200 y_coordinate = 200 speed_x = randrange (1,5) #both changes in x and y are randomized to make ball move in rando...
72610155dc84c194919e0f4e4c8c68354f4d0e5c
ArshiaRa/Coffee-Machine
/Coffee Machine.py
3,537
3.765625
4
water = 400 milk = 540 beans = 120 cups = 9 money = 550 Ewater = 250 Ebeans = 16 Emilk = 0 Lwater = 350 Lbeans = 20 Lmilk = 75 Cwater = 200 Cbeans = 12 Cmilk = 100 def reduce(number,water11,beans11,milk11,money11,cups11): global water global beans global milk global money global cups if num...
9d80ad503bf762a8079389c4026f8ee5857d4f4e
LivNarc/exosphere
/user_generator.py
452
3.640625
4
import csv products ={} user_file = raw_input('which file would you like to open:\n\t') form = raw_input('which format would you like:n\t\'HTML'n\t\'Plain') if form is 'HTML': print 'HTML Report Here' elif 'Plain' is: print 'Plain Report Here' else: print 'invalid msg with open(user_file,'rb') as csvfile: repo...
0bb7b65666ac17d8207a34eea9141ea700d5aa46
N11K6/Digi_FX
/Distortion/Valve.py
1,552
3.5
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ This function applies distortion to a given audio signal by modelling the effects from a vacuum tube. Input parameters are the signal vector x, pre-gain G, "work point" Q, amount of distortion D, and pole positions r1 and r2 for the two filters used. @author: nk """ i...
d93ea23a75b58330903c8d2e5cf8ebdfe587d1cf
matiasbouin/Facultad
/programacion 1/networking.py
397
3.640625
4
# NETWORKING ''' URL and IMAGES from urllib SOCKET PROGRAMMING from socket SEND EMAILS from smtlib ''' # Acces url and downloading html import urllib.request try: url = urllib.request.urlopen('https://www.python.org/') content = url.read() url.close() except urllib.error.HTTPError: print("Page not f...
d02b55e743382cd1bf8bc9381066afff35fe23c9
caphael0925/CAPython
/src/MyAPPs/Get_primef.py
1,132
3.578125
4
''' Created on 2012-12-7 @author: Caphael ''' if __name__ == '__main__': pass import sys inum=input('Please input a number:') factor=0 factors=[] primelist=[2] i=1 prod=inum def get_factor(prod): global primlist if prod in primelist: return prod for p in primelist: ...
061fb47ae51971c35c9155d67e75d00e7a261ce3
lanbowcn/TFstudy
/TFAction/1-7-1.py
927
3.53125
4
import tensorflow as tf import numpy as np # 实现激励函数 sess = tf.Session() # 显式调用内建激励函数 # 1.整流线性单元(Rectifier linear unit,ReLU)神经网络常用非线性函数 # 函数为max(0,x)连续但不平滑。 print(sess.run(tf.nn.relu([-3., 3., 10.]))) #2.为限制ReLU的线性增长部分,会在min()函数中嵌入max(0,x),其在tf中的实现成为ReLU6,表示 # min(max(0,x),6),这个是hard-sigmoid函数的变种,计算运行速度快,解决梯度消失(无线趋于0...
426c6ee8f7b916d1a65112a928d60e93d6c9e347
gersonpas/LoteriaCEF
/main.py
1,622
3.515625
4
from random import randint, sample import time print('\033[0;33m{:=^44}'.format('\033[0;33m LOTERIAS ')) print(''' [1] = QUINA [2] = MEGA SENA [3] = DUPLA SENA [4] = LOTOFÁCIL [5] = lOTOMANIA [6] = DIA DE SORTE''') loto = int(input('Escolha sua loteria: ')) while loto > 6 or loto < 1: loto = int(input('\033[0;34mEnt...
22bccb77b938e7e796a695a86638491a7fb70a03
EdwardLijunyu/first-room
/数据结构/17二进制中1的个数.py
1,134
3.59375
4
''' 输入一个整数,输出该数的二进制表示中的1的个数,其中负数用补码表示 请实现一个函数,输入一个整数,输出该数二进制表示中 1 的个数。例如, 把 9 表示成二进制是 1001,有 2 位是 1。因此,如果输入 9,则该函数输出 2。 ''' class Solution: def hammingWeight(self, n: int) -> int: n = 0xFFFFFFFF & n # 将负数 print(bin(n)) #bin()是将数转化为二进制,负数转化为补码 int有32位 4个字节,一个字节8位 k = 0 for i in...
34367a4657eed0a6868f596eebbd0899ba6ebbc3
DevelopDevelopDevelop/Python-Practice
/deck_shuffler.py
585
3.625
4
# Build and shuffle a card deck # My attempt to solve the problem of redundant cards import random # Assign list holders card = [] suit = ["Clubs", "Spades", "Hearts", "Diamonds",] royals = ["Jack", "Queen", "King", "Ace"] deck = [] # Create list of numbered cards for i in range(2,11): card.append(str(i)) # Create...
6b7a130685cb240f3bda7a35efb4f31082d63f06
cafesao/Programas_Python
/Adicionar_Valores.py
808
3.984375
4
#Variaveis lista_valores = list() cont_vezes = num_Cinco = int(0) resposta = str() #Adição de valores while True: numero_user = int(input('Digite um valor inteiro: ')) cont_vezes += 1 if numero_user not in lista_valores: lista_valores.append(numero_user) resposta = str(input('Deseja ...
54ef9a990c29e514e8d23dee89d77162b6638c27
cafesao/Programas_Python
/NotasV2.0.py
2,869
3.5625
4
from tabulate import tabulate alunos = [] dados = [] alunosc = [] alunost = media = 0 print('Bem-Vindo ao programa Media_Notas V2.0\n') escola = str(input('Digite o nome da escola: ')).capitalize() serie = str(input('Digite a serie: ')) while True: a = str(input('\nDigite o nome do aluno: ')).capitaliz...
7014dfce8be85d3e0d993081faa228fb5693d68a
cafesao/Programas_Python
/Alistamento.py
834
4
4
#Codigo while True: nome_user = str(input('Qual seu nome?: ')).split()[0].capitalize() ano_nascimento = int(input('Qual o ano do seu nascimento?: ')) ano_nascimento = 2019 - ano_nascimento if ano_nascimento < 18: print(f'{nome_user}, você ainda não se alistou, faltam {18 - ano_nascimento} ...
f2f7e7c15682418d151df456a099d7fed777001d
cafesao/Programas_Python
/Contagem_Regressiva.py
418
3.734375
4
# Contagem regressiva para o estouro dos fogos! import time while True: n1 = int(input('Digite um valor: ')) for c in range(n1,0,-1): print(f'Vai estourar em: {c}') time.sleep(1) print('Os fogos estouraram!! \n') r = str(input('Deseja recomeçar? (Sim / Não): ')).split()[0].uppe...
bcbf7460cbac72daf800fa9cb4cb9944f2904270
dmallows/Crayon
/plots/typesys.py
13,462
3.625
4
"""Validating type system and simple types. It is worth noting that Type objects only contain information for validation, and a default value. The decision to use objects to represent types. Inspired by, though no patch on, Haskell's type system. Types are class objects, and are transformed using a (simple!) metaclass...
9e4ba8e7e9a227ed061602d291bd1b5e7851f933
zangell44/DS-Unit-3-Sprint-1-Software-Engineering
/acme.py
2,589
3.953125
4
#!/usr/bin/env python """ Classes representing products sold by Acme Corp """ import random class Product: """ Generic class for items sold by Acme Corp """ def __init__(self, name, price=10, weight=20, flammability=0.5): if not isinstance(name, str): raise AttributeError("'name' o...
57e443004e07c95bc99217d700e6b4f40f5c8a5f
yamaz420/PythonIntro-LOLcodeAndShit
/pythonLOL/vtp.py
2,378
4.125
4
from utils import Utils class VocabularyTrainingProgram: words = [ Word("hus", "house") Word("bil", "car") ] def show_menu(self): choice = None while choice !=5: print( ''' 1. Add a new word 2. Shuffle the words i...
4f55c17a043ee6a78b76220c8c25240a21b8195c
yamaz420/PythonIntro-LOLcodeAndShit
/pythonLOL/IfAndLoops.py
1,881
4.15625
4
#-----------!!!INDENTATION!!!----------- # age = int(input("What is your age?")) # if age >= 20: # print("You are grown up, you can go to Systemet!") # else: # print("you are to young for systemet...") # if age >= 20: # if age >= 30: # print("Allright, you can go to systemet for me, i hate sho...
f405ff7aa196a99aca98db4ad221cab524f36a28
yamaz420/PythonIntro-LOLcodeAndShit
/pythonLOL/car.py
836
3.703125
4
from wheel import Wheel import random class Car: nr_of_wheels = 4 def __init__(self, model, year): self.model = model self.year = year self.wheels = [] self.install_wheels() def install_wheels(self): for i in range(self.nr_of_wheels): co...
e2847e6e40c6a7db988624957597c2f45108b4ba
EsslWeiss/Algs-and-DataStructures
/DataStructures/graph/bfs_graph_traverse.py
773
3.875
4
import ipdb from collections import deque # adj list matrix representation GRAPH = { 0: {1, 2}, 1: {0, 3, 4}, 2: {0}, 3: {1, 5}, 4: {2, 3}, 5: {10, 2, 6}, 6: {10, 5, 7}, 7: {0, 1, 3}, 10: {0, 5, 6} } def bfs_traverse(graph, init_vertex): ipdb.set_trace() visited = [init_ve...
9794994149b10a7f30ab5bc6b053d0479f1f2a2b
Baepeu/coding_training
/q14_01.py
370
3.8125
4
# 입력 : 구매금액, 주 # 출력 : 중간합계, 세금, 총 합계 amount = input("What is the order amount? ") state = input("What is the state? ") # 형변환 amount = float(amount) tax = amount * 0.055 total = amount + tax if state == 'WI': print(f"The subtotal is ${amount:.2f}") print(f"The tax is ${tax:.2f}") print(f"The total is ${tota...
3574b3fd265469ee1d9222831d97d839554bd1fa
Baepeu/coding_training
/q04_01.py
319
4
4
# 문자열 보간 # % 문법 # str.format() 메서드 # python 3.6 부터 등장한 f string noun = input("Enter a noun: ") verb = input("Enter a verb: ") adjective = input("Enter an adjective: ") adverb = input("Enter an adverb: ") msg = f"Do you {verb} your {adjective} {noun} {adverb}? That's hilarious!" print(msg)
2dffe7f603412fad09fa52d71c9a9f533fe13e9f
Baepeu/coding_training
/q09_01.py
453
3.5625
4
from math import ceil # round : 반올림, ceil : 올림, floor : 버림 # 입력 : 천장의 길이와 폭 # 출력 : 몇 리터가 필요한가? # 입력 width = input("Width : ") height = input("Height : ") # 형변환 width = float(width) height = float(height) square_meters = width * height # 올림 liters = ceil(square_meters / 9) msg = f"You will need to purchase {liters} ...
f6279772c0e492defaafef12e38a23afcc313661
Baepeu/coding_training
/q08_01.py
735
4.0625
4
# 피자 파티 # 입력값 : 몇명, 몇판, 한판당 조각수 # 출력 : 한사람 당 몇조각씩 먹고 몇조각이 남느냐? # 연산자 : //(몫), %(나머지) # 데이터 입력 people = input("How many people? ") pizzas = input("How many pizzas do you have? ") print() pieces = input("How many pieces are in a pizza? ") # 형변환 people = int(people) pizzas = int(pizzas) pieces = int(pieces) # 계산 total_p...
c26b455b4b05b8be9d813d899dd9d461efba5af8
Fingolfin123/ben_gislason_cse_exercise
/ben_gislason_cse_exercise/utilities/db_write.py
1,076
3.515625
4
import pandas as pd import sqlite3 import os from shutil import copyfile from pathlib import Path def dbWrite(dbPath, dbTable, df, optional_path): ''' Writes dataframe to summary database file. Parameters: dbPath: Path of summary database this database is saved to local ...
3c4ae6d7d146e231e636b75130ec3186bdece503
nav272/100DaysofCode
/DAY3/pattern_16.py
400
3.875
4
print("------------Pattern 16---------") txt = "" i = 0 print(txt+"*") txt = "" j = 0 for i in range(3): txt = txt+"*" for k in range(i): txt = txt+" " txt = txt+"*" print(txt) j = 0 k = 0 txt = "" for i in range(4): txt = txt+"*" for k in range(3-i): txt = txt+" " ...
a81662a267b8d8315298490f266244ce204957b5
nav272/100DaysofCode
/DAY3/pattern_12.py
375
3.90625
4
print("------------Pattern 12---------") txt = "" i = 0 for j in range(5): txt = txt+"*" print(txt) i = 0 for i in range(3): j = 0 txt = "" for l in range(i): txt = txt+" " txt = txt+"*" for j in range(3-i): txt = txt+" " txt = txt+"*" print(txt) txt = "" j = 0 txt = ...