blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
ffd9314fb9ba657039e5e06d964bbb2574afc97f | huazhige/EART119_Lab | /hw1/submissions/deanwilliam/deanwilliam_38830_1239734_hw1p3-1.py | 429 | 4.09375 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 8 17:17:00 2019
@author: williamdean
Problem 3 while loop
"""
import math
r = 12.6 #radius of circle in mm
A_circle = math.pi*r**2
a = 1.5 #length of side a in mm
b = A_circle/a
A_rectangle = a*b
# find greatest value of b so that A_circle is just ... |
cb1520f6a7a95093aa4664924f07d9450a62fcec | huazhige/EART119_Lab | /hw4/submissions/johannessonsofia/johannessonsofia_37907_1300164_finding_roots.py | 4,071 | 3.625 | 4 | # -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
#===============================================
# functions
#===============================================
c = 1.1
t_0 = 2.5
A = float(5)
def f(t):
f = c*(t-t_0)**2
return f
def g(t):
g = A*t+t_0... |
8930f1e29689a6166c72f7dea33543779a74b0c7 | huazhige/EART119_Lab | /hw1/late/sweeneyconnor_23244_1251088_HW_1_1.py | 606 | 3.890625 | 4 | # -*- coding: utf-8 -*-
"""
EART 119 HW 1
-Functions and Vectors-
"""
"""
1. Write a program that computes the area of a rectangle (A=bc) and the area of a triangle
(A = 0.5*hbb). The input of your function will be b and c for the rectangle and hb and b
for the triangle
"""
# Rectangle w... |
d8199d5f97cf34f2ffedfd08b6356b39d9235c1f | huazhige/EART119_Lab | /hw1/submissions/martinezverenise/martinezverenise_22776_1250546_Problem#2_Polygon_Area.py | 758 | 3.75 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 14 16:43:29 2019
@author: lopez
"""
#################################### Problem No.2##############################
"""
Problem#2
Computing the area of a polygon
"""
corners = [(1,1), (3,1), (4,2), (3.5,5), (2,4)] # x and y Cartesian Coordinates
def Po... |
ac6480fd640d20ad3a371b8d18eca5679d37b9ef | huazhige/EART119_Lab | /hw4/submissions/chapmanbrendan/chapmanbrendan_late_26691_1305638_HW4.4.py | 3,390 | 3.59375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun May 5 22:15:34 2019
@author: Hobo
"""
#========================================================================================================================
" Question 4"
""" Find the roots of four functions"""
#===================================================... |
f6f15b52a1b344d9d11d67d88c6909db8dae76a7 | huazhige/EART119_Lab | /hw1/submissions/lobmeyerbrady/lobmeyerbrady_33398_1250315_Homework#1.py | 757 | 3.984375 | 4 | # -*- coding: utf-8 -*-
"""
Brady Lobmeyer 4/13/2019
Find the area of a rectangle and triangle
Area of rectangle A=bc
Area of triangle A=.5hb
"""
#area of rectangle m^2
def A(t): #defining a function for Area of rectangle
b0 = 5
c0 = 7
return (b0*t)*(c0*t) #('base times height')
time = 1 ... |
5adb9de09afb67e790fadc28e481b8d8689a9fc3 | huazhige/EART119_Lab | /mid-term/martinezverenise/martinezverenise_22776_1312455_PartC-1.py | 786 | 3.59375 | 4 | # -*- coding: utf-8 -*-
"""
- We wi;; ne taking the first and second derivative for the given data set
- we will the plot each derivative
"""
import matplotlib.pyplot as plt
import numpy as np
########################## Load data ########################################
file_eq = "midterm_dydx.txt"
mData = ... |
79922260f68405bca69221d634d3513ec623c63a | xiangzho72/repo | /python/chessBoard/piece.py | 1,185 | 3.578125 | 4 | import chessBoard
class Piece():
def __init__(self,row,col,chess,*moves):
if isinstance(row, int) and isinstance(col,int) and len(moves)>0 and isinstance(chess, chessBoard.ChessBoard):
if row <0 or col <0 or row >= len(chess) or col >= len(chess):
raise ValueError
... |
f1d199495325cdde517b5dd9578ca96da8e96773 | AbeLudlam/542Poker | /542-Poker/poker.py | 6,504 | 3.671875 | 4 | #Originally project from here https://github.com/fogleman/Poker
#New authors: Abraham Ludlam and Hezekiah Pilli
#This code evaluates poker hands for 5 and 7 card poker. We added the functionality of 3 player 7 card poker and providing a UI for the user to interact with to run the evaluation functions as much as they ... |
e8d52647b08f6fd560620df17e0333fc865de3bd | samposn/algorithm004-02 | /Week 08/id_522/LeetCode_746_522.py | 1,534 | 3.5625 | 4 |
'''
#国际站, 看了
class Solution:
def minCostClimbingStairs(self, cost: List[int]) -> int:
size = len(cost)
for i in range(2,size):
cost[i]+= min (cost[i-1],cost[i-2])
return min(cost[i-1],cost[i])
'''
'''
#the first time
class Solution:
def minCostClimbingStairs(self, cost: List[int]) -> int:... |
176370a6c3d2bba0ab959c365a92edba1f657f18 | samposn/algorithm004-02 | /Week 08/id_387/ LeetCode_438_387.py | 634 | 3.9375 | 4 | # https://leetcode.com/problems/find-all-anagrams-in-a-string/
# 438. Find All Anagrams in a String
class Solution:
def findAnagrams(self, s: str, p: str) -> List[int]:
sLen, pLen = len(s), len(p)
if sLen < pLen: return []
result = []
sHash, pHash = [0] * 26, [0] * 26
for i in range(pLen):
... |
7c42c2d052933f247ec9a99b0b8cd2c7e5cfc359 | ThreeGoldStone/pythonDemo | /com/djl/py/l45/l_while_for.py | 4,200 | 4.03125 | 4 | # 非0 非空为true
# flag = 10
# while flag:
# print(flag)
# flag -= 1
# 10
# 9
# 8
# 7
# 6
# 5
# 4
# 3
# 2
# 1
# for element in iterable:
# block
# print("for 的例子 1")
# for i in range(10):
# print(i)
# print("for 的例子 2")
# for i in range(10, 5, -1):
# print(i)
# help(range)
# class range(object)
# ... |
846b8b69ada86b808e612e66a961499c9c005f04 | JamieDawson/code_for_fun_graph_lesson | /graph.py | 782 | 3.859375 | 4 | import turtle
t = turtle.Turtle()
t.speed(20)
t.down()
t.goto(0,0) #middle
t.write ("0", font=("Arial", 0, "normal"))
t.goto(0, 100) #left
t.write("Y 100", font=("Arial", 12, "normal"))
t.goto(0,0)
t.goto(-100, 0)#right
t.write("X -100", font=("Arial", 12, "normal"))
t.goto(0,0)
t.goto(100,0)#right
t.write("100", ... |
f12c134363ff16bfef91f8b22a6420fe5e00fc3f | ada-zhang-00/CS115-Intro-to-Computer-Science | /Lab 3 Math and Reduce Part 2/lab3.py | 756 | 4.21875 | 4 | from functools import reduce
# Task 1: Use reduce to add up all elements in a list
"""
Input: A list of numbers
Output A number representing the sum
Example: add_all([1, 2, 3]) = 6
"""
def add_all(lst):
return sum(list(map(int, lst)))
# Task 2: Use map to evaluate a given polynomial at a specific x-value... |
62a361f54432ee624eb1e7caf7b73028387d1896 | GabeOchieng/ebola-4 | /python_code/correlation_stuff_v1.py | 1,283 | 4.03125 | 4 | #!/usr/bin/python
# analytics challenge ebola correlation first python program
# Library imports
import numpy as np # np will be alias for numpy when calling numpy functions
#these are data points. for us its number of diseases in a city per year over 4 years
P = [100, 87, 76, 95]
#get standard deviation
stdP = n... |
e9e0a8d94032edf4f5c44d7e02dfa2228366351a | pshort05/droveBank | /unittests-droveBank.py | 3,535 | 3.875 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
# ----------------------------------------------------------------------------------------------------------------------
# Unit Testing framework using the built-in unittest in Python
# unittests-droveBank.py by Paul Short
# ... |
477cb421aa2eb6ab6cd6705bcd46ac33f56f4175 | hao-top/test_python | /enjoy_python_test/multiplication.py | 125 | 3.5625 | 4 | # Author:Mr浩
for i in range(1,10):
for m in range(1,i+1):
print("%s*%s=%s \t" %(m,i,i*m),end='')
print('')
|
5dd1be66ea75d4320cdc2d81707cf822a8f1487e | syanyong/binarytree_demo | /binarytree.py | 3,127 | 4 | 4 | #!/usr/bin/python
# Title: binarytree.py
# Description: Modified binary tree algorithm.
# Author: Sarucha Yanyong
# Version: 0.1
# Modified: 2015-12-04
# Python version: 2.7.9
# Revision History:
#
import sys
class BinaryTree():
def __init__(self,rootid):
... |
4ddd57cb4da4c8099d07ab3e1fee9e6765eb6f6b | grzesiu/bioinformatics-algorithms | /8_how_did_yeast_become_a_wine-maker/squared_error_distortion.py | 982 | 3.59375 | 4 | import numpy as np
SEP = '--------'
def distortion(centers, data):
def distances(point):
def distance(center):
return np.linalg.norm(center - point) ** 2
return np.min(np.apply_along_axis(distance, -1, centers))
return np.sum(np.apply_along_axis(distances, -1, data)) / data.shap... |
0fc8cb68e970f5941c261f344dd56896f61e94c9 | grzesiu/bioinformatics-algorithms | /9_how_do_we_locate_disease_causing_mutations/burrows_wheeler_transform_construction.py | 423 | 3.90625 | 4 | def transform(text):
cyclic_rotations = [text[i:] + text[:i] for i in range(len(text))]
bwt = [cyclic_rotation[-1] for cyclic_rotation in sorted(cyclic_rotations)]
return ''.join(bwt)
def main(text):
print(transform(text))
if __name__ == "__main__":
main("GCGTGCCTGGTCA$")
'''
Construct the Burr... |
23d1cb6df712a171056f4f550e0821f8326f2cdb | uathena1991/Leetcode | /Hard/k empty slots.py | 1,751 | 4.03125 | 4 | """
Problem:
There is a garden with N slots. In each slot, there is a flower. The N flowers will bloom one by one in N days. In each day, there will be exactly one flower blooming and it will be in the status of blooming since then.
Given an array flowers consists of number from 1 to N. Each number in the array repre... |
28a3289dea3b45c2ccd38678603a7f41cb98544b | uathena1991/Leetcode | /Interview coding problems/google/Count Univalue Subtrees.py | 935 | 3.890625 | 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 recursion(self, node):
if not node:
return False, None
if not node.left and not node.right:
s... |
a44449a4d082b8c61ff0e3713545dc05da334c44 | uathena1991/Leetcode | /Medium/Search Insert Position.py | 1,223 | 3.71875 | 4 | """
test case:
[1,3,5] 2
[1] 0,1,2
[1,4,5,6],5.5,4.5
"""
class Solution(object):
def searchInsert(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: int
"""
if not nums:
return 0
l_idx = 0
h_idx = len(nums)-1
whil... |
264fcd8b7a39332d7343124c30e12d479e478910 | uathena1991/Leetcode | /Medium/Find Leaves of Binary Tree.py | 1,363 | 3.890625 | 4 | """
DFS
"""
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def findLeaves(self, root: TreeNode) -> List[List[int]]:
def dfs(node):
if not node:
retu... |
062b29779e39d1eaa444cb784588ceeb36a78214 | uathena1991/Leetcode | /Easy/Max Stack.py | 1,129 | 3.828125 | 4 | class MaxStack:
def __init__(self):
"""
initialize your data structure here.
"""
self.stack = []
def push(self, x: int) -> None:
if not self.stack:
self.stack.append((x,x))
else:
max_ele = max(self.stack[-1][1],x)
self.stack.... |
119c3cacdcf2415464cbd0a0ac1a37a3f5b3df37 | uathena1991/Leetcode | /Medium/Path sum II.py | 1,869 | 3.921875 | 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 pathSum(self, root, sum):
"""
:type root: TreeNode
:type sum: int
:rtype: List[List... |
f085d22abed7e6a61d00db0bf3d226012097b0bb | uathena1991/Leetcode | /Easy/add binary.py | 1,392 | 3.5 | 4 | """ Notes:
A little tricky here... just know a few built-in function: int(a,2), bin(a)[2,:]
If time permitted, try the real transformation...http://lifexplorer.me/leetcode-add-binary/
"""
class Solution(object):
def addBinary(self, a, b):
"""
:type a: str
:type b: str
... |
0f6248063103411d0ee57693b38a08895762bee1 | uathena1991/Leetcode | /Hard/Longest consecutive sequence.py | 922 | 3.96875 | 4 | """
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.
Your algorithm should run in O(n) complexity.
Example
Given [100, 4, 200, 1, 3, 2],
The longest consecutive elements sequence is [1, 2, 3, 4]. Return its length: 4.
"""
class Solution(object):
def longestConse... |
7cead3e5bc00f416fb64d8c00ed778afd411e033 | uathena1991/Leetcode | /Medium/swam nodes in pairs.py | 661 | 3.71875 | 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
... |
0871edd57e96bcdd8cff90da39cfe20bd3a6cabe | uathena1991/Leetcode | /Easy/backspace string compare.py | 571 | 3.71875 | 4 | class Solution:
def backspaceCompare(self, S, T):
"""
:type S: str
:type T: str
:rtype: bool
"""
def helper(ss, sign = "#"):
# two pointers and scan from end
skip = 0
ns = ''
for i in range(len(ss)-1, -1, -1):
... |
47e76047857c86fe5759b4b3a20e34593380244b | uathena1991/Leetcode | /Medium/palindrome partitioning.py | 443 | 3.734375 | 4 | class Solution:
"""
backtracking
"""
def helper(self, s, curr_path, res):
if len(s) == 0:
res.append(curr_path)
return
for i in range(1, len(s) + 1):
if self.is_pal(s[:i]):
# curr_path.append(s[:i])
self.helper(s[i:], curr_path + [s[:i]], res)
def is_pal(self, s):
return s == s[::-1]
def... |
e4075f413eb70a6a5e00e189e97f18de212f5651 | uathena1991/Leetcode | /Easy/Palindrome Number.py | 967 | 3.84375 | 4 | class Solution(object):
def isPalindrome(self, x):
"""
:type x: int
:rtype: bool
"""
if x < 0 or (x!=0 and x%10 == 0):
return False
reverse = 0
while x>reverse:
reverse = reverse*10 + x%10
x /= 10
if x == reverse or ... |
1c88e8bd27c17a13c65af271d0a258891d7e5f72 | uathena1991/Leetcode | /Hard/N-queens.py | 3,388 | 3.65625 | 4 | """
use set to record: cols, diags, antidiags
"""
class Solution:
def solveNQueens(self, n: int) -> List[List[str]]:
col, diag, antidiag = set(), set(), set()
self.res = []
def dfs(path, row):
if row == n:
self.res.append(['.'*x + 'Q'+'.'*(n-x-1) for x in path])
... |
556bdaae8aa351538073ccfd61854cdcc12cc44b | uathena1991/Leetcode | /Easy/sentence similarity.py | 270 | 3.5 | 4 | class Solution(object):
def sent_similar(self, word1, word2, pairs):
if len(word1) != len(word2):
return False
for i in range(len(word1)):
if [word1[i], word2[i]] in pairs or [word2[i], word1[i]] in pairs:
continue
else:
return False
return True
|
25f7a6a2191b84872b884d3418c892ee93069cea | uathena1991/Leetcode | /Hard/word search II.py | 1,534 | 3.671875 | 4 | from collections import defaultdict
class TrieNode(object):
def __init__(self):
self.child = defaultdict(TrieNode)
self.isword = False
def buildTrie(words):
root = TrieNode()
for w in words:
curr = root
for c in w:
if c not in curr.child:
curr.chi... |
bee02801ed08a94f363be3f36ab16d4fe64dac8b | uathena1991/Leetcode | /Easy/Binary Tree Level Order Traversal_II.py | 968 | 3.765625 | 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 levelOrderBottom(self, root):
"""
:type root: TreeNode
:rtype: List[List[int]]
... |
e8a21a268adaff3156a5ddeb445e0275d095c5d1 | ChrisLeeSlacker/FibonacciSeq | /Math - Fibonacci - Slow Method.py | 468 | 3.609375 | 4 | """
Fibonacci Sequence: recursively
F(n) = F(n-1) + F(n-2)
F(0) = 0 and F(1) = 1
"""
import timing
"""
this exact representation of the mathematical definition is incredibly inefficient for
numbers much greater than 30, because each number being calculated must also
calculate for every number below it.
"""
... |
52b7457663cdfe9790e2348d8cbf25704da16199 | sanmiguella/coding_and_ctf | /Python/cli_test/main.py | 1,903 | 3.609375 | 4 | import sys
class Text_Manipulator:
@classmethod
def get_options_and_args(cls):
# If it starts with '-' , then it will be an option, else it will be an argument.
opts = [opt.lower() for opt in sys.argv[1:] if opt.startswith("-")]
args = [arg for arg in sys.argv[1:] if not arg.startswith(... |
14940d0574b4dff100b6303286559c82f8b90c50 | ilmfan/algorithms | /insertion_sort.py | 307 | 4.09375 | 4 | def insertion_sort(given_array):
for j in range(1, len(given_array)):
key = given_array[j]
i = j - 1
while i > 0 and given_array[i] > key:
given_array[i + 1] = given_array[i]
i -= 1
given_array[i + 1] = key
return given_array
|
7252f6eb3c52bf4c11f1a3dced1dacd3ef870354 | macinnis82/bicycle_industry | /bicycles.py | 2,526 | 4.15625 | 4 | class BikeShop(object):
""" Bike Shops have a name, an inventory and are profitable """
def __init__(self, shop_name, margin, shop_inventory):
self.shop_name = shop_name
self.shop_inventory = {}
self.margin = margin
self.profit = 0
for bike in shop_inventory:
bike.markup = int((bike.c... |
bbe2f5e78f90a3a178c2d34a3444acb92478da06 | XinyuYun/cs1026-labs | /lesson2/task6/task.py | 543 | 4.40625 | 4 | # Try the Python below and answer the questions.
# Wwe assign some variables and check an expression.
# Note how we checked the expression with format
x = -1
y = 0
print("Is it true that x <= y?")
print("It's {}!".format((x<=y)))
a = 2.52
b = 5
# Notice how these two print statements give different results. Why is th... |
63589794486560d84f7aa7937671008651b1d75c | XinyuYun/cs1026-labs | /lesson4/task3/task.py | 119 | 4.09375 | 4 | # Replace the placeholders to complete the Python program.
Outer for loop:
for x in range(1,11):
print(x)
|
d25f15f44d428badce922791493d762ad40cdff5 | XinyuYun/cs1026-labs | /lesson10/task1/task.py | 377 | 3.78125 | 4 | # Replace the placeholders with code and run the Python program
class Banana:
bananaID =0
def __init__(self):
Banana.bananaID += 1
self._ID = Banana.bananaID
def __str__(self):
return "This banana has an id of "+ str(self._ID)
# Create two banana objects
Create the first banana obj... |
c105ca15316d5d68496f06d32c8add3bba871599 | XinyuYun/cs1026-labs | /lesson8/task3/task.py | 245 | 4.03125 | 4 | # Replace the placeholders with code to raise an exception and run the Python program
values =[1,2,3,4,5,"hello",6,7,8,9,"10"]
for cur in values:
Insert the given print statement
if type(values[cur]) == str:
Raise an exception
|
7d378941a5eacf5ddea184e4ea04c999719742b5 | jradcliffe5/Useful_scripts_for_radio | /m2pc.py | 468 | 3.515625 | 4 | #!/usr/bin/python
# Program to transform meters into parsecs
# "m2pc.py 1 2 3" transforms all three numbers from
# m to pc
import sys
import string
lines = sys.argv
del lines[0]
if len(lines)==0:
print"\n m2pc.py written by Enno Middelberg 2001"
print"\n Program to transform meters into parsecs"
print"... |
7b153108fa675f4c0376cf16c54a004cbfaa24e8 | jradcliffe5/Useful_scripts_for_radio | /spix.py | 528 | 3.546875 | 4 | #!/usr/bin/env python
# This is a program to calculate spectral indices
import sys, math
if len(sys.argv)<5:
print "\n Program to calculate spectral indices. Usage:"
print "\n spix.py S(low) S(high) nu(low) nu(high)\n"
sys.exit()
S1 =float(sys.argv[1])
S2 =float(sys.argv[2])
nu1=float(sys.argv[3])
nu2=f... |
42c56e8adc3620277e4908ca7b69327da974b1f5 | jradcliffe5/Useful_scripts_for_radio | /deg2rad.py | 780 | 4.40625 | 4 | #!/usr/bin/env python
# deg2rad.py, task to convert an angle in degrees
# into radians
import sys, math, string
if len(sys.argv)==1:
print "\n deg2rad.py written by Enno Middelberg 2002"
print "\n Task to convert an angle in degrees"
print " into radians. Type deg2rad.py followed by"
print " a blank-... |
c1d4dbce37f88f3f5abff36cac990d069dd24a74 | brennopost/unb | /icc/lista5.py | 1,707 | 3.5625 | 4 | # %% QUESTA0 A
message = input()
crack = message.split()
for i in crack:
print(i[2], end="")
# %% QUESTA0 B
message = input()
def p_translator(text):
for i in text:
if i.lower() in ['a','á','e','é','ê','i','í','o','ó','ô','ú','u',' ']:
print(i, end="")
else:
print("p",... |
f84a2954f7f9d507c255e625219b1137364d2311 | Sanjeets41/Python_Assignment_1 | /Python_Session1_Assignment_3.py | 126 | 3.9375 | 4 |
# coding: utf-8
# In[1]:
x= input("Enter your first name:")
y= input("Enter your last name:")
print(x[::-1]+" "+y[::-1])
|
77a5fd2b3b89cfd8df10a34e388234b2baca1034 | alyssadicarlo/exercism | /python/pangram/pangram.py | 860 | 3.90625 | 4 | def is_pangram(sentence):
alphabet = {
"a": False,
"b": False,
"c": False,
"d": False,
"e": False,
"f": False,
"g": False,
"h": False,
"i": False,
"j": False,
"k": False,
"l": False,
"m": False,
"n": Fals... |
a734780940b6f24974b40623a325a0a2860eda36 | AdventurousDream/Top-100-Liked-Questions-by-python | /45 Jump Game II.py | 879 | 3.5 | 4 | from typing import List
class Solution:
def jump(self, nums: List[int]) -> int:
arr_len = len(nums)
if arr_len == 1:
return 0
ans = 0
curIdx = 0
maxPos = -1
nextIdx = -1
while True:
if curIdx + nums[curIdx] >= arr... |
1780035a92ca37e2e2748253e6d35e48a31a30dc | justalearner1/bmi-calculator | /bmi calculator.py | 452 | 4.21875 | 4 | full_name('John', 'Doe')
# bmi input data
height_m = (170/100)
weight_kg = 70
# calculate bmi
bmi = weight_kg / (height_m ** 2)
# print calculated bmi value
print(f'bmi: ' "{0:.2f}".format(bmi))
# bmi logic code
if bmi < 18.5:
print("You are underweight")
elif bmi >= 18.5 and bmi <= 24.9:
print(" You are ne... |
5a8a31508155302b11f7bd02d68732a7525b2a91 | nriya25/riya | /PythonCodes/iter2.py | 564 | 3.828125 | 4 | class PowNum(object):
def __init__(self,n=2,p=0):
self.n=n
self.p=p
def __iter__(self):
self.c=0
return self
def __next__(self):
if c <= p:
self.c +=1
r = n**c
return r
else:
raise StopIteration
p=PowNum(int(in... |
fe0bfa6e0723812643fdc9e7f990bb865add0486 | nriya25/riya | /PythonCodes/matrixx.py | 808 | 3.78125 | 4 | n,m=map(int,input("Enter matrix dimensions").lower().split( ))
def show(X):
for var in X:
print("\t",*var)
def trans(X):
r=[]
r=[[X[j][i] for j in range(n)] for i in range(m)]
print("\n")
for var in r:
print(var)
def add(X,Y):
k=[]
for row in range(n):
p=[]
f... |
be8fa4d959528393da7b7a536469bcb401cdf843 | nriya25/riya | /PythonCodes/pattern6.py | 342 | 3.96875 | 4 | n=int(input("enter no of rows"))
for row in range(1,n+1) :
c=65
for col in range(1,row+1) :
print(chr(c),end='')
c=c+1
print()
print("\n\n")
row=1
while row <= n :
col = 1
c=65
while col <= row :
print(chr(c),end='')
c += 1
col += 1
print()
row ... |
7d38875abbf886c5280ffb6e31d404311d8406eb | nriya25/riya | /PythonCodes/factorial.py | 108 | 4.09375 | 4 | x=int(input("enter a number for factorial"))
i=1
fact=1
while i<= x :
fact = fact * i
i=i+1
print(fact)
|
6a654a0de4ac2c08dc922b80d173a6c94c57d8d5 | nriya25/riya | /PythonCodes/fibbonacci.py | 148 | 3.609375 | 4 | a,b=0,1
n=int(input("enter number of times"))
print("{}\t{}".format(a,b),end='\t')
n = n-2
while n :
a,b=b,a+b
print(b,end='\t')
n -= 1
|
551175fbb54890dd744ed628888f7194e71fb74c | hydure/CS141-Computational-Problem-Solving | /Proj3.py | 8,917 | 4.03125 | 4 | # Proj3.py
#
# Colin Fox Lightfoot
# CFLightfoot@email.wm.edu
# (540)-538-2538
#
# This program allows you to choose one of five games labeled a through e. This
# program reads through a dictionary.txt file for the respective games.
# Game a finds all the words of a particular length containging just a single
# vowel t... |
522f016f1eebb935144734ee5c3ec5c837f3a8f7 | DZ521111/CodeChef-Python-and-Cpp | /June Long D2/evenm.py | 833 | 3.5625 | 4 | '''
Author : Dhruv B Kakadiya
'''
def spiralFill(m, n, a):
val = 1
k, l = 0, 0
while (k < m and l < n):
for i in range(l, n):
a[k][i] = val
val += 1
k += 1
for i in range(k, m):
a[i][n - 1] = val
val += 1
n -= 1
... |
344f51172b4a9d7e2f5cf793004c393e13b7e6b1 | LChanger/LeetCode | /LeetCode/baidu.py | 823 | 3.640625 | 4 | def change(num,n):
isneg=num<0
ans=""
num=abs(num)
while num!=0:
tail=num%n
if tail>9:
tail=chr(64+tail-9)
ans=str(tail)+' '+ans
num//=n
return ans if not isneg else '-'+ans
# print(change(-10,20))
class TreeNode:
def __init__(self,val):
sel... |
89954a5ba7e75a1f36a8bb9cad51d76b47b4b263 | LChanger/LeetCode | /LeetCode/LeetCode24.py | 923 | 3.765625 | 4 | # Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
l1 = ListNode(5)
l2 = ListNode(7)
l1.next = l2
l3 = ListNode(1)
l4 = ListNode(8)
l3.next = l4
l2.next = l3
# 思路,纸面上画一下每步的步骤
class Solution:
def swapPairs(self, head: ListNode) -> ListNode:... |
8b89dfc6136e7e8026f6b4d8337d66a84e6e46c6 | LChanger/LeetCode | /alibaba/xiaoqiang.py | 222 | 3.65625 | 4 | t=int(input())
for i in range(t):
nmab=input().split()
n,m,a,b=int(nmab[0]),int(nmab[1]),int(nmab[2]),int(nmab[3])
print(m)
pq=PriorityQueue()
def getNum(n,m,a,b):
for num in nums:
pq.put((num,num)) |
c82b4e2b6ecbde66d52c33c869fc8227f22e98d5 | LChanger/LeetCode | /LeetCode/LeetCode295_heap.py | 3,294 | 3.890625 | 4 | class MedianFinder:
#思路,维护一个最大堆和一个最小堆,保证两者数量最大差1
def __init__(self):
"""
initialize your data structure here.
"""
self.max_heap=[]
self.min_heap=[]
def max_heap_sit_up(self,num):
self.max_heap.append(num)
index=len(self.max_heap)-1
while index... |
f6d57a76549e76d9276e92ff9a96eb30ec98b0e1 | LChanger/LeetCode | /test1.py | 35,717 | 3.609375 | 4 | # print ("Hello world")
import time,os
words = input('请输入对祖国的祝福:')
# #例子:words = "Dear lili, Happy Valentine's Day! Lyon Will Always Love You Till The End! ♥ Forever! ♥"
# for item in words.split():
# t = os.system('cls')
# #要想实现打印出字符间的空格效果,此处添加:item = item+' '
# item=item
# letterlist = []#letterlist是... |
8f36869bedbce92380a1ed482869cde1124a78b7 | LChanger/LeetCode | /LeetCode/LeetCode116Populating Next Right Pointers in Each Node.py | 1,437 | 4.125 | 4 | # You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition:
# struct Node {
# int val;
# Node *left;
# Node *right;
# Node *next;
# }
# Populate each next pointer to point to its next right node. If there is no n... |
93d3f910f1486b2c13c27ed19816f859da3a990a | LChanger/LeetCode | /nowcoder/zhizixingtree.py | 1,016 | 3.578125 | 4 | # -*- coding:utf-8 -*-
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def Print(self, pRoot):
# write code here
if not pRoot:return []
from collections import deque
que=deque()
que.append(pRoo... |
c8f11df18e2993fd5cc4857ee3044da4fa5558e4 | LChanger/LeetCode | /LeetCode/LeetCode216 Combination Sum III.py | 486 | 3.671875 | 4 | class Solution:
def combinationSum3(self, k: int, n: int):
res=[]
def curCal(answer,target,start):#answer当前生成的组合序列,target目标数字,start 起始位置
if len(answer)==k and target==0:
res.append(answer)
return
for i in range(start,min(target+1,10)):
... |
7d2d4b9a3c5e0186eb740f865bf20d5a04328c8e | LChanger/LeetCode | /LeetCode/LeetCode85 Maximal Rectangle.py | 1,570 | 3.734375 | 4 | # 思路二:应用84题中的技巧,按行扫描,计算目前的最大面积,若有0该列被截断
# 计算目前最大面积的算法:定义一个栈,栈内存储所有的比栈顶元素值都小的值的 位置, 为递增序列
# 当 扫描的元素小于栈顶元素时,将栈顶元素取出,开始计算栈顶元素为水平线的 区域面积
# 此处边界处理非常巧妙
#----------------------O(n²) time limited--------------------
class Solution:
def maximalRectangle(self, matrix) -> int:
m=len(matrix)
if m==0:return 0
... |
5675882ba35c4ee92f1cacda8c24e6eb5cdf2cd4 | LChanger/LeetCode | /LeetCode/LeetCode501.py | 2,066 | 3.765625 | 4 | #题目描述:Given a binary search tree (BST) with duplicates, find all the mode(s) (the most frequently occurred element) in the given BST.
# 思路:由题意可知,相同的值只可能存在于父子节点之间,所以对树进行中序遍历
# 记录最大数量
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self... |
a5122c6fc731678f052740e0f0ee27b23e96d32d | LChanger/LeetCode | /LeetCode/LeetCode56.py | 364 | 3.78125 | 4 | #思路:分组异或
class Solution:
def singleNumbers(self, nums):
sum=0
for n in nums:
sum^=n
div=1
while sum&div==0:
div=div<<1
a,b=0,0
for n in nums:
if n&div==div:a=a^n
else:b=b^n
return [a,b]
s=Solution()
nums=[1,2,5,2... |
e1be035f2be798346a43fac32b0c9e6e05d4960e | Gibbo81/LearningPython | /LearningPython/06TheDynamicTypingInterlude.py | 909 | 3.765625 | 4 | def ListAdd(lista):
lista.append(3)
return
def IntSum(intero):
return intero+3;
def TwoEqualityCheck():
print('two different type of comparisation')
a=[1,2,3]
b=a
print(b==a) #check if the value is the same
print(b is a) #check if the referred object is the same (link to ... |
f23584c7210eb8655613e22706787e02d9cf5e64 | Gibbo81/LearningPython | /LearningPython/33ExceptionBasics.py | 1,790 | 3.71875 | 4 |
def fetch(x, number):
return x[number]
class MyException(Exception):
def __init__(self, text):
self.text = text
def __str__(self):
return ("I'm really a bad exception, %s" % self.text)
class Student():
def __init__(self,x):
self.x = x
print('-------------------------------... |
fe15830c832e043898b56e77bb71c76e90c99a3a | Gibbo81/LearningPython | /LearningPython/32AdvancedClassTopic.py | 7,001 | 3.890625 | 4 | class SearchingTest:
def __init__(self, value):
self.Data=value
def __add__(self, other):
return SearchingTest(self.Data + other)
class Base: attr = 1
class A(Base): pass
class B(Base): attr = 2
class C(A,B): pass
class Base1: pass
class A1(Base): pass
class B1: pass
class C1(A1,B1): pass... |
9db9f895994e174817db630ef3ab96ee1766809c | Gibbo81/LearningPython | /LearningPython/36DesigningwithExceptions.py | 794 | 3.5625 | 4 | import sys
print('---------------------------------------------------------------------')
print("if no exception has been handele sys.exc_info() return three none")
obj = sys.exc_info()
count = 0
for x in obj:
print("sys.exc_info()[%s]: %s" % (count, x))
count+=1
print('----------------------------------------... |
bd77dd5702caaf991c92b94c9454ad36edb81e0d | OpenTaal/emphasis | /2-process.py | 2,431 | 3.65625 | 4 | #!/usr/bin/env python3
from logging import error
from pprint import pprint
from re import compile, IGNORECASE
vowels = 'aeiouáéíóúàèìòùäëïöüâêîôûå'
emphasized = 'áéíóú'
filter_single = compile('[^{0}]*[{0}][^{0}]*'.format(emphasized), IGNORECASE)#FIXME
filter_double = compile('[{0}]{{2}}[^{0}]*'.format(emphasized), I... |
aefef8838485cfef2c44bc8cbc96f20a4b296ffb | kevinpatell/Reinforcement-Exercises | /Python Exercises/Python_programming_fundamentals1/exercise1.1.py | 540 | 4 | 4 | documentary = 'Man on wire'
comedy = 'Hangover'
dramedy = 'La La Land'
drama = 'Lincoln'
print('Choose your options\n 1. Documentaries\n 2. Dramas and/or\n 3. Comeedies?')
print('Answer')
interest = input().lower()
if interest == '1':
print('We recommend you watch "{}".'.format(documentary))
elif interest == '2 and... |
42e619475d604f54e15b3236d15cd64923cdbc46 | SivasubramanianA/Solved_programs | /product_even_or_odd.py | 100 | 3.890625 | 4 | n,m=raw_input().split()
n=int(n)
m=int(m)
op=n*m
if op%2==0:
print "even"
else:
print "odd"
|
d330dca5794d2ced6d980a5f386c82ecdd23c61e | SivasubramanianA/Solved_programs | /remove_vowels_and_rverse_string.py | 105 | 3.640625 | 4 | len=int(input())
string=raw_input()
for i in 'aeiou':
string=string.replace(i,"")
print string[::-1]
|
1574daf531703e83febfe1938caa877b0b110858 | stevefolta/word-puzzle-utils | /frequency-cutoffs | 1,484 | 3.5625 | 4 | #!/usr/bin/env python3
import sys
max_letters = 9999
class WordList:
def __init__(self, path, frequency_field = 1):
self.path = path
self.frequency_field = frequency_field
self.words = {} # word => frequency
self.total_frequency = 0.0
self.has_freqencies = True
self.read()
def read(self):
print(f"R... |
5be2d2ee9ce41b6b8dd44df8b5c698fb091c89ee | tso7/Python-Practice | /passwordStrength.py | 837 | 4.375 | 4 | #! /usr/bin/python3
# passwordStrength.py - Practice file to check password strength based on provided requirements
import re
print("Enter a password: ")
password = input()
while True:
if re.search('\w{8,}', password) != None:
if re.search('[a-z]+', password) != None:
if re.search('[A-Z]+', pa... |
f10e6e1bce18b6b2f8c7314d67f4e9580ef3d114 | tso7/Python-Practice | /selectiveCopy.py | 730 | 3.96875 | 4 | #! /usr/bin/python3
# selectiveCopy.py - Walks through a folder and copies files based on
# specified extension
import os, shutil
# TODO: read from input arguments
sourceDir = '/home/tso/Downloads/automate_online-materials'
targetDir = '/home/tso/Documents/Python Files/selectiveCopy'
extension = 'txt'
# Walk throug... |
8a3f0f1fcdcdbfc42f8d9b7cd0c84f9faaaf6518 | RLNetworkSecurity/Python_learning | /paycalculator.py | 194 | 3.984375 | 4 | hours = input("enter hours: ")
hourly_rate = input("enter hourly rate: ")
pay = float(hourly_rate) * float(hours)
tax = (pay / 100) * 20
output = pay - tax
print(f"Gross pay is £{output:.2f}")
|
b9dc08ab3bd0edb2675a814eb15d3531365bc744 | RLNetworkSecurity/Python_learning | /function_example.py | 797 | 4.125 | 4 | #CONSTANTS
DEGC = "\u2103"
DEGF = "\u2109"
# define functions
def c_to_f(num):
"""
this is what we call a doc string
this function changes degrees C to degrees F
"""
return (num * 9/5) + 32
#reverse function
def f_to_c(num):
"""
this is what we call a doc string
this function changes d... |
9d89b6717385277463f8394f119971d8bf55a224 | mensaochun/Notes | /tensorflow/code/basic/NeuralNetwork_regression.py | 1,913 | 3.5 | 4 | """
This python script is for constructing neural_network_regression
Google's deep learning frame tensorflow is used here
Author:Mensaochun
Date:2017.01.15
"""
# import relative packages
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
# Define parameters
learning_rate = 0.01
n_iterations = 5... |
99746a100f26d8ea33af782e98aa62a1595c2925 | sharduln/fsdse-python-assignment-1 | /square_of_numbers.py | 182 | 3.625 | 4 | def squareOfNumbers(n):
if n<0 or n>100:
return
squareDict = {}
for i in range(n+1):
squareDict[i]= i*i
return squareDict
print squareOfNumbers(5)
|
ad6c3a96b02eae840ddb47932febf6f00f33d232 | Mukund14400/8thjune_ml | /as1.py | 1,622 | 3.578125 | 4 | ##1 done
##2
>>> 5**9
1953125
>>> 3//2
1
>>> 7//3
2
>>> 7/3
2.3333333333333335
>>> 6==6
True
>>> a=20;a+=30;a%=3;print(a)
2
>>> True*False
0
>>> True&False
False
>>> True and False
False
>>> ((6>3) and (7<4)or (18==3))and(9>3)
False
>>> True is False
False
##3
>>> s1= "NIce to have it"
>>>... |
a35170ba86f14ac866948a51283457aa3219c20b | twyb/Data-Structure-and-Algorithm-Python | /SetsMaps/ListImp/map.py | 1,951 | 3.84375 | 4 | class Map:
# Instantiate the Map
def __init__(self):
self.map = list()
# Return the length of the map
def __len__(self):
return len(self.map)
# Check if key is in length
def __contain__(self, key):
if self.getKey(key):
return True
return False
... |
2e4684271b2b82e3548b3b034c57a5c11fd7fd6f | 123-rahul-anandraj/Py-DataVisualization_Day1_Assignment | /DataVisualize_LU_Day1_Assgn1.py | 280 | 3.890625 | 4 | #Assignment No:1
import numpy as np
import pandas as pd
import matplotlib as mplt
import matplotlib.pyplot as plt
x=np.arange(0,10)
y=x*x
plt.title('Simple Line Plot')
plt.xlabel('x-axis')
plt.ylabel('y-axis')
plt.plot(x,y,linewidth=2,linestyle='dashed')
plt.show()
|
0c844b9ca3373e090a5be313abc8d86051ecff12 | shreehari-a/PiCCE | /Validator/files_list.py | 420 | 3.640625 | 4 | import os
class ListFiles(object):
def __init__(self, foldername):
self.foldername = foldername
def recursive(self):
file_list = []
for root, dirs, files in os.walk(self.foldername, topdown=False):
for name in files:
item = os.path.join(root, name)
file_list.append(item)
return file_list... |
ceb7fb4b71e28cc54be14c888bce7b8eedcd9fef | skynyrd/machine-learning-fundementals | /data-preprocessing/data-preprocessing_template.py | 825 | 3.578125 | 4 | # Data Preprocessing
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# Importing the dataset
dataset = pd.read_csv('Data.csv')
X = dataset.iloc[:, :-1].values # All rows(observations) & all columns(variables) except the last one.
y = dataset.iloc[:, 3].values # All rows(observations) & only... |
0ed6a8b4e4f58b490a0ff787ad1c6cfab57c6d39 | StillsSma/list_comprehensions | /main1.py | 2,131 | 3.625 | 4 |
from datetime import datetime
def remove_vowls():
sentence = list("List Comprehensions are the Greatest!")
vowls = ["a", "e", "i", "o", "u"]
no_vowl = [letter for letter in sentence if letter not in vowls]
# print("".join(no_vowl))
remove_vowls()
# id,Wave Height,Wave Period,Avg Waves Per Second,Wate... |
3a2ed1a53ba23f300b7a433067c1bff854493b43 | RyanLeeBot/NetworkingTutorial | /Week5/excercise4.py | 1,838 | 3.71875 | 4 | '''
Copy your solution from exercise3 to exercise4. Add an 'import pdb' and pdb.set_trace() statement outside of your function (i.e. where you have your function calls).
Inside of pdb, experiment with:
Listing your code.
Using 'next' and 'step' to walk through your code. Make sure you understand the differenc... |
cafd276a9d8003170a0bf5236a8ef403ab73c1f1 | RyanLeeBot/NetworkingTutorial | /Week4/excercise2.py | 2,142 | 3.734375 | 4 | '''
Create three separate lists of IP addresses. The first list should be the IP addresses of the Houston data center routers, and it should have over ten RFC1918 IP addresses in it (including some duplicate IP addresses).
The second list should be the IP addresses of the Atlanta data center routers, and it should ha... |
f51b9b8410ecb5e7602d586dbc4a3669bd1534f8 | ImagineEyes/AllShapes | /Trapezium.py | 559 | 4.03125 | 4 | print("Welcome to 'Tapezium.py'")
def Trapezium():
Base = float(input("Base(One of the parellel side) = "))
Opp_Base = float(input("Side opposite to the Base = "))
Height = float(input("Height = "))
Side1 = float(input("One of the side = "))
Side2 = float(input("Another side = "))
Area = ... |
3213234fa0e08f277a81a229e7bbdd4394f5ccb0 | ImagineEyes/AllShapes | /Hexagon.py | 318 | 3.96875 | 4 | print("Welcome to Hexagon.py")
def Regular_Hexagon():
Side = float(input("Side = "))
Area = ((3*(3**(1/2)))/2)*Side
Perimeter = 6*Side
print("Area = ", Area, "sq units");print("Perimeter = ", Perimeter, "units")
while True:
Regular_Hexagon()
if input() == "quit()":
break |
911761781367f490afef7d8c1b6b59009d15820a | Zebreu/mist | /tools.py | 1,818 | 3.515625 | 4 | '''
A library of tools useful throughout the process of analyzing spatial relationships.
Created on 2012-02-21
@authors:
Sebastien Ouellet sebouel@gmail.com
'''
import math
def calculate_absolute_distance_center(shape1, shape2):
""" Outputs the distance, as a vector, between the center of two shapes """
vect... |
44a875f174e8bfde20db195058bafb638b505838 | EjHelo/IA_Proyecto_2 | /connect4_console.py | 2,739 | 3.859375 | 4 | import numpy as np
''' Constant variables '''
ROW_COUNT = 6
COLUMN_COUNT = 7
def create_board():
''' inicialize the matrix with zeros '''
board = np.zeros((6,7))
return board
def drop_piece(board, row, column, piece):
''' insert a piece on the board '''
board[row][column] = piece
def is_valid_l... |
a57291adef6043212654fb8bbde15ae3fa48c331 | javierdiezde/EjerciciosPython | /Bisección.py | 939 | 3.859375 | 4 | # Resuelve la ecuación x·sen(x)= ln(x) en el intervalo [2,3]
import math
print(' Resuelve la ecuación x·sen(x)= ln(x) en el intervalo [2,3]')
decimal = int (input('Hasta qué decimal quieres que aproxime? '))
tolerancia = 10**((-1)*decimal)
print (tolerancia)
a=2.0
b=3.0
distancia = b-a
print(distancia)
c=(a+b... |
94ca6818620c0fd1c6e2d885cf0023590aa30077 | javierdiezde/EjerciciosPython | /primo.py | 482 | 3.90625 | 4 | #Averigua si un número es primo
while True:
a = input('Introduce un número entero')
try:
a = int(a)
break
except ValueError:
print ("debes introducir un número entero")
mitad = int(a/2) +1
for divisor in range(2,mitad):
if a%divisor==0:
print(' no es primo, es divisible por: ')
... |
0d9612f8b89fe9321705cc1a0c1c3ed2eb111a0e | sss3600123/shangdanRichang | /myPython/python_project/test336.py | 313 | 4 | 4 | #!/usr/bin/env python
#coding:utf-8
#尽量不用+连接字符串。
print('hello %s, happy %s' % ('xiaolong','new year!'))
#交换赋值
a = 1
b = 2
print(a,b)
a,b = b,a
print(a,b)
_as = input('请输入关键词')
if _as == 'a':
print('欢迎你,%s' % (_as))
else:
print('翻滚吧,%s' % (_as))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.