blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
72025c7f7c19e3b3c6bc796e4709deef08b269cd | HouJingChen99/AbaqusScripts | /Materials.py | 3,415 | 3.515625 | 4 | """
Define materials for abaqus. To create a new material, define the class for it, and add an entry to the materials enum with the value
set to the name of the material class. The Elastic class provides a good template to follow. The youngs_modulus and poissons_ratio would need
to be changed for the variables of the n... |
8faaeae2b21400e454798e3f1d91a721efa5dd51 | jawbreakyr/LPTHW-exercises | /Documents/tutorials/python-docs/subbing/bullshit.py | 225 | 4.21875 | 4 | counter = 0
while counter < 15:
print counter,
# here we add one to the counter. on each iteration it will increment
# until it reaches 15 and then the condition in the while loop will be false.
#counter += 1 |
6485a7a7782617c67fa4b011f4ed18066c91a1df | jezzicrux/pumpkinpie | /helloworld.py | 678 | 4.125 | 4 | '''There is cake in the hallway
print ("Hello World")
There is cake in the hallway
print ("Goodnight Moon")
There is cake in the hallway
Hello="Hello"
World="World"
a=Hello
b=World
print (a+b)
a=2
b=3
print (a+b)
c="9"
d=2
print(float(c)+d)
test1=float(input("Please input the score for Test 1. "))
test2=int(input("P... |
baf385a1432c1383197b75ef57a1c741137f34f6 | fifa254144/PreFreshyChallengeSolution | /EZ/Palindrome/palindrome.py | 1,021 | 3.671875 | 4 | import random
import string
def randomString(stringLength):
"""Generate a random string of fixed length """
letters = string.ascii_letters
return ''.join(random.choice(letters) for i in range(stringLength))
def check(st):
temp = st[::-1]
if temp==st:
return True
return False
for r in ... |
ae77da29267cc3b91b97a40c2475734be89885c6 | VAICR7BHAV/Competitive_Programming | /BOY_OR_GIRL.py | 114 | 3.609375 | 4 | s=input()
ar=list(s)
se=set(ar)
if(len(se)%2==0):
print("CHAT WITH HER!")
else:
print("IGNORE HIM!") |
370e8bba0f1a1f1ed2c5c2cf0c2da041a948fdff | VAICR7BHAV/Competitive_Programming | /CHEFPRMS.py | 943 | 3.53125 | 4 | from sys import stdin,stdout
import bisect
def SieveOfEratosthenes(n):
prime = [True for i in range(n + 1)]
p = 2
while (p * p <= n):
if (prime[p] == True):
for i in range(p * 2, n + 1, p):
prime[i] = False
p+=1
prime[0]=False
prime[1]=False
... |
c80bc53659d91bdee8d5b6530c418ab07b96138f | VAICR7BHAV/Competitive_Programming | /FANCY.py | 309 | 3.65625 | 4 | t=int(input())
while(t>0):
s=[i for i in input().split()]
ind=0
for i in range(0,len(s)):
if(s[i]==("not")):
ind=1
break
else:
ind=-1
if(ind==-1):
print("regularly fancy")
else:
print("Real Fancy")
t=t-1 |
eb947bfcf66648c44a3d24cdf3fe47463c32c382 | VAICR7BHAV/Competitive_Programming | /INSOM_JUI.py | 385 | 3.6875 | 4 | import math
def lcm(x, y):
lcm = (x*y)//math.gcd(x,y)
return lcm
k=int(input())
l=int(input())
m=int(input())
n=int(input())
d=int(input())
'''
l1=lcm(k,l)
l2=lcm(k,m)
l3=lcm(k,n)
ans=d//k+d//l+d//m+d//n-d//l1-d//l2-d//l3
print(ans)
'''
arr=[]
for i in range(1,d+1):
if(i%k==0 or i%l==0 or i%m... |
9ecc64d48130d3b8792a0daad3e0877a2e5e28c2 | NanXiangPU/leetcode | /game-of-life/gameOfLife.py | 959 | 3.59375 | 4 | class Solution(object):
def gameOfLife(self, board):
"""
:type board: List[List[int]]
:rtype: void Do not return anything, modify board in-place instead.
"""
direction = [[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1]]
for i in range(len(board)):
fo... |
1af5fdbff881ff59bbbb0d97cbd02a1b901b6295 | mshahmalaki/DSPy | /s04/a410/a410.py | 168 | 3.984375 | 4 | import numpy as np
a = np.arange(1, 7)
b = a.reshape(3, 2)
print('3 * 2 numpy array :\n', b)
b[[0, 1]] = b[[1, 0]]
print('3 * 2 numpy array with swapped rows :\n', b)
|
7bb9710c9810c1da762a4bd04fb365fe2c2475f9 | jia0713/leetcode | /300-400/337-House Robber III.py | 731 | 3.734375 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution(object):
def rob(self, root):
"""
:type root: TreeNode
:rtype: int
""... |
afe1eeac5fec4e5373662d31d0036144704a0ede | jia0713/leetcode | /001-100/024-Swap Nodes in Pairs.py | 627 | 3.734375 | 4 | # Definition for singly-linked list.
class ListNode(object):
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution(object):
def swapPairs(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
if not head:
r... |
cc93b3a47176c44702988f5526908a44b06b879a | jia0713/leetcode | /001-100/047-Permutations II.py | 653 | 3.6875 | 4 | class Solution(object):
def permuteUnique(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
res = []
nums.sort()
self.dfs([], nums, res)
return res
def dfs(self, path, nums, res):
if not nums:
res.append(path)
... |
c15a65cde02460ac9da5e63692d8e7cb04fa0461 | jia0713/leetcode | /001-100/002-Add Two Numbers.py | 559 | 3.59375 | 4 | class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def addTwoSums(self, l1, l2):
l3 = ListNode(0)
temp = l3
carry = 0
while l1 is not None or l2 is not None or carry != 0:
sum = carry
if l1 is not None:
... |
435900941a02cea8af792d4b434964e60b3784a4 | jia0713/leetcode | /400-1000/993-Cousins in Binary Tree.py | 994 | 3.78125 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution(object):
def isCousins(self, root, x, y):
"""
:type root: TreeNode
:type x: i... |
995e94d49a31c76d016381532c7dab9d1452e08e | jia0713/leetcode | /400-1000/554-Brick Wall.py | 439 | 3.609375 | 4 | from collections import Counter
class Solution(object):
def leastBricks(self, wall):
"""
:type wall: List[List[int]]
:rtype: int
"""
counter = Counter()
for line in wall:
count = 0
for brick in line:
counter[count + brick] += 1
... |
c6462f5e067e3fc42f82c65ff5d145e51b77b176 | jia0713/leetcode | /400-1000/897-Increasing Order Search Tree.py | 905 | 3.765625 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution(object):
def increasingBST(self, root):
"""
:type root: TreeNode
:rtype: Tree... |
557f639cb9568af400aee9674967705e192b42a5 | jia0713/leetcode | /200-300/235-Lowest Common Ancestor of a Binary Search Tree.py | 645 | 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 lowestCommonAncestor(self, root, p, q):
"""
:type root: TreeNode
:type p: TreeNode
:... |
6ee39069263aac3dcc46a1c5a6cf8e7631ada1a7 | jia0713/leetcode | /300-400/309-Best Time to Buy and Sell Stock with Cooldown.py | 522 | 3.984375 | 4 | # 这道题的关键就是定义状态和状态之间的转移
# 状态是hold, sold, rest 三种
# 这三种状态是如何相互转移的
class Solution(object):
def maxProfit(self, prices):
"""
:type prices: List[int]
:rtype: int
"""
rest, sold, hold = 0, 0, -float("inf")
for price in prices:
pre_rest = rest
rest = ... |
1151be7c4bcfb168897525a70b9e3228334b61cb | shan-mathi/InterviewBit | /anti diagonals.py | 681 | 3.59375 | 4 | class Solution:
# @param A : list of list of integers
# @return a list of list of integers
def diagonal(self, A):
"""
1 2 3 5
4 5 6 7
7 8 9 8
9 1 2 3
[[0,0], sum = 0
[0,1],[1,0], sum = 1
[0,2],[1,1],[2,0], sum = 2
[1,2],[2,1], sum = ... |
20c9ebce3238540676519c3a234bc5304b9692a9 | shan-mathi/InterviewBit | /threading_queue.py | 1,066 | 4.0625 | 4 | from collections import deque
import time
import threading
class Queue():
def __init__(self):
self.Q = deque()
def dequeue(self):
return self.Q.pop()
def enqueue(self,val):
self.Q.appendleft(val)
def size(self):
return len(self.Q)
def peek(self):
return self.... |
700d4f5178163574c39219a6bfd002069e60ec14 | shan-mathi/InterviewBit | /partition_linked_lists.py | 904 | 3.84375 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
# @param A : head node of linked list
# @param B : integer
# @return the head node in the linked list
def partition(self, A, B):
if A.val>= B:
prev = ListNode(Non... |
2dace252b42aaee4bd3cd79a8337c8ff9da76b19 | shan-mathi/InterviewBit | /integer_to_roman.py | 437 | 3.53125 | 4 | import math
#brute force
def integer_to_roman(n):
ones=["","I","II","III","IV","V","VI","VII","VIII","IX"]
tens=["","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"]
hundreds = ["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"]
thousands =["","M","MM","MMM"]
ans = thousands[n//1000] + hundreds[(n%... |
34b83bd825c6cc61b2a4b20bb957664d239d8904 | shan-mathi/InterviewBit | /word_rank_without_rep.py | 515 | 3.828125 | 4 | import math
import string
def lex_rank(A):
"""
approach: interesting
:param A: a word
:return: the rank of the word when arranged lexically
"""
p = 0
alp = [i for i in A]
alp.sort()
print(alp)
ans = 0
l = len(A)
while p < l:
search = A[p]
p += 1
... |
2e2aca7d542218abb37bc0a3d73ba184a857e657 | shan-mathi/InterviewBit | /rotate_linked_list.py | 890 | 3.890625 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
# @param A : head node of linked list
# @param B : integer
# @return the head node in the linked list
def rotateRight(self, A, B):
itr = A
l... |
b175f7325ce8f5a66fd5807fb862975069902bd3 | shan-mathi/InterviewBit | /sorted_Array_to_BST.py | 695 | 3.734375 | 4 | # Definition for a binary tree node
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
# @param A : tuple of integers
# @return the root node in the tree
def sortedArrayToBST(self, A):
#2 pointer method... |
d7ad065ea92a1573a03f981010bddc4ccf2483af | samurato/deeplear-capstone | /Khoa Codes/kdd/logisticRegression2.py | 3,691 | 4.0625 | 4 | # Logistic Regression
import numpy as np
import tensorflow as tf
import timeit
import os
from tensorflow.examples.tutorials.mnist import input_data
class LogisticRegression(object):
"""Multi class Logistic Regression Class
The logistic regression if fully described by a weight matrix W
and bias vector b. Classifi... |
904017ac4e1ca413f54a532424638598d409f86a | san39320/lab | /3/dsa/lab3/postfix.py | 630 | 3.5625 | 4 | def postfix(exp):
s=[]
exp=exp.split()
l=len(exp)
i=0
while i<l :
if exp[i].isdigit():
s.append(int(exp[i]))
elif exp[i]=='+':
temp1=s.pop()
temp2=s.pop()
s.append(int(temp2)+int(temp1))
elif exp[i]=='-':
temp1=s.pop()
temp2=s.pop()
s.append(int(temp2)-int(temp1))
elif exp[i... |
c6d3b29620c02d5975e671ed9b80f8b9eb38220f | san39320/lab | /4/daa/lab5Greedy/scc.py | 1,391 | 3.546875 | 4 | class Graph:
def __init__(self,n):
self.n=n
self.g=[[]for i in range(self.n)]
self.grev=[[]for i in range(self.n)]
self.visited=[False for i in range(n)]
self.sccvisited=[False for i in range(n)]
self.soursestack=[]
def addEdge(self,a,b):
self.g[a].append(... |
38d4a4f9283c39a2390c0e66599f187c7e050220 | san39320/lab | /3/dsa/lab8/p1.py | 1,021 | 3.953125 | 4 | class graphmatrix:
def __init__(self,x):
self.x=x
self.adj=[[0 for i in range(int(self.x))]for j in range(int(self.x))]
self.adjlist = [[] for j in range(int(self.x))]
def insert(self,x,y):
self.adj[x][y]=1
self.adj[y][x]=1
self.adjlist[x].append(y)
self.a... |
6e3d635611b5cd4324f102425155601ab97ef118 | san39320/lab | /3/dsa/lab1/sort.py | 257 | 3.78125 | 4 | n=int(input("enter the number of elements"))
print("enter the elements to be sorted")
a=[]
for i in range(0,n):
b=int(input())
a.append(b)
for i in range(0,n):
for j in range(0,n-i-1):
if a[j]>a[j+1]:
temp=a[j]
a[j]=a[j+1]
a[j+1]=temp
print(a) |
f20c5ce833985bbd6c3f7be8bf57fbaf0b81da64 | bayufedra/encode-decode-python | /shift-vigenere-substitution-transposition/main.py | 4,801 | 3.890625 | 4 | #!/usr/bin/env python3
import argparse
def shift_encrypt(plaintext, key):
ciphertext = ''
for letter in plaintext:
if letter.isalpha():
shifted = (ord(letter) - 65 + key) % 26
ciphertext += chr(shifted + 65)
else:
ciphertext += letter
return ciphertext
... |
01b6dba03d3d2f23a0f002764312693f7795ae03 | anooprerna/How-to-Solve-it-By-Computer-Solutions-in-Python | /algo2_3_6.py | 321 | 4.125 | 4 | #Program to print first n terms of the series 1, 2, 4, 8, 16, 32.... Without using multiplication
def nseries(n):
first = 1
next = 1
while (n >= 1):
print(next)
next += first
first = next
n -= 1
number = int(input("Enter a number for which you want the series of numbers"))
nseries(number)
... |
05c6d8752179e8e02c92c0bdc0f57b9268d9e8d0 | anooprerna/How-to-Solve-it-By-Computer-Solutions-in-Python | /algo2_9.py | 310 | 3.75 | 4 | c = input("Alright, let's enter some number and we will convert it to decimal!")
size = len(c)
d = 0
i = 0
while i < size:
#print("Character",c[i])
a = ord(c[i])
#print("ASCII", a)
x = a - 48
#print("Decimal", x)
d = (d*10) + x
#print("Printing D", d)
i+=1
print(d) |
cba3ae3fa223eb0fc7365f755601103436c8cc0d | anooprerna/How-to-Solve-it-By-Computer-Solutions-in-Python | /algo2_4_1.py | 244 | 4.4375 | 4 | #Program to find out the factorial of a number
def Factorial(n):
fact = 1
for i in range(1, n+1):
fact *= i
print(1 / fact)
number = int(input("Enter the number for which you want the inverse of factorial"))
Factorial(number) |
e253f04a7f49eb0d898a2ab0d52221d7512dbe95 | anooprerna/How-to-Solve-it-By-Computer-Solutions-in-Python | /algo2_3_1.py | 214 | 4.1875 | 4 | print("Enter the numbers whose average is to be returned")
numbers = [int(x) for x in input().split()]
length = len(numbers)
sum = 0
for i in numbers:
sum += i
print("Average is ", sum/length)
|
449a5cb17094d10655fef86794d5102eac1ba466 | anooprerna/How-to-Solve-it-By-Computer-Solutions-in-Python | /algo3_1_3.py | 336 | 3.5625 | 4 | import random
n = int(input("Enter a number, I will do some magic!"))
e = 0.0000000001
r1 = random.randint(0, n)
print(r1)
# sub_c = 1
# add_c = 0.1
while (n - (r1**2)) < e:
if r1**2 > n:
r1 -= 1
else:
break
# sub_c /= 100
# add_c /= 100
print("The magical numbe... |
87c5bcc21e2147397483a6dd72b9cf05d8fb3a2f | Racs0XD/PythonBasicoC2021 | /HT2_201603028.py | 768 | 3.796875 | 4 | #Ejercicio 1
from colorama import Fore, init
init()
print(Fore.WHITE+"==================================================")
h = int(input(Fore.YELLOW+"Ingrese un valor entero positivo para la altura del triangulo: "+Fore.WHITE))
for i in range(h):
for j in range(i+1):
print(Fore.GREEN+"*", end="")
pri... |
186a4854ceb0d1b0a9a0290bfe061b3e3365c103 | W-yt/programme | /python/pythonProject1/main.py | 568 | 3.640625 | 4 | # test the file
# for i in range(10):
# print(i)
# pycharm Fast Typesetting —— ctrl+alt+l
# #input
# name = input("tel me your name: ")
# print("Hello, "+name+"!")
# #import the module
# import pizza
# pizza.make_pizza(16, 'mushrooms', 'green peppers', 'extra cheese')
# #import the functions from module
# from ... |
ca0919e6e2e8f82a3b485cb35a38e74628c3baf5 | DannyMSC/2020-hackathon-zero-python-retos-pool-15 | /src/kata2/rpg.py | 231 | 3.515625 | 4 | #!/usr/bin/python
import random
import string
def RandomPasswordGenerator(passLen=10):
pasw=""
for n in range(passLen):
pasw += "".join([random.choice(string.ascii_letters + string.digits) ])
return pasw |
297359594c1cf515a27a9544140dfbe70823f2dc | reepicheep/Python-Crash-Course-2-ed-by-Mathes-E. | /Chapter3/3.2_greetings.py | 437 | 4.03125 | 4 | # Start with the list you used in Exercise 3-1, but instead of just printing each person’s name, print a message to them.
# The text of each message should be the same, but each message should be personalized with the person’s name.
names = ["Georgi","Petko", "Reni", "Marietta"]
print(f"Happy Birthday, {names[0]}!")
... |
c720a8ca56affc2f021ad62e37614ee584b8953f | reepicheep/Python-Crash-Course-2-ed-by-Mathes-E. | /Chapter3/3.3_your_own_list.py | 544 | 4.15625 | 4 | # Your Own List: Think of your favorite mode of transportation, such as a motorcycle or a car, and make a list that stores several examples.
# Use your list to print a series of statements about these items, such as “I would like to own a Honda motorcycle.”
my_favorire_cars = ["Honda", "Mercedes", "Pegeout", "Ford"]
p... |
b53d77e0d983dc26e0f071eeda946b7ec3b8d248 | reepicheep/Python-Crash-Course-2-ed-by-Mathes-E. | /Chapter2/2.3_personal_message.py | 192 | 3.8125 | 4 | name = "Eric"
message = f"Hello {name}, would you like to learn some Python today?"
print(message)
message = "Hello {}, would you like to learn some Python today?".format(name)
print(message) |
0510284e66de628d5752d9ae0f8802d4d7944a0f | iychoi/biospectra | /tools/calc_size.py | 714 | 3.703125 | 4 | #! /usr/bin/env python
import os
import os.path
import sys
def _sumSize(path):
size = os.path.getsize(path)
print path, "=", size, "bytes"
return size
def sumSize(path):
sizeTotal = 0;
if os.path.isdir(path):
for p in os.listdir(path):
sizeTotal += sumSize(os.path.join(path, p... |
4612213e140b055814435d37310d0c8d8e7b555c | ai-asif/Leetcoding | /Array 101/Problem 2/my_solution.py | 546 | 3.625 | 4 | class Solution(object):
def findNumbers(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
evens = 0
for num in nums:
num_length = 0
while True:
num_length = num_length + 1
if num % 10 == n... |
79b935dae806f63981adc32075dddf761f485122 | tkazusa/CodingBat | /List-1.py | 2,899 | 4 | 4 |
# coding: utf-8
# In[1]:
## list-1.1 first_last6
'''
Given an array of ints, return True if 6 appears as either the first or last element in the array.
The array will be length 1 or more.
'''
def first_last6(nums):
return nums[0] == 6 or nums[-1] == 6
first_last6([13, 6, 1, 2, 3])
# In[2]:
## list-1.2 same... |
4212e16fca2b4923dea230b6afd5c06922c9a220 | DaFluffyOwl/Recent-Video-Youtube | /OpenRecentVideos(YoutubeAPI).py | 1,983 | 3.640625 | 4 | import json #Import dependencies
import requests
import os
api_key = '' #INSERT YOUR API KEY HERE!!!
def look_for_new_video():
base_video_url = 'https://youtube.com/watch?v=' #Used to look up video
base_search_url = 'https://www.googleapis.com/youtube/v3/search?' #Used to search the video on a channel with the ... |
1b0ea108bd6b664ea132c09881b4662cda0616bc | nduprincekc/python_snake_game | /main.py | 3,684 | 3.578125 | 4 | from turtle import *
import time
import random
score=0
execution_delay=0.1
root=Screen() #object of screen class
root.title('Snake Game')
root.setup(width=600,height=600)
root.bgcolor('black')
root.bgpic('border.gif')
root.tracer(False)
root.addshape('upmouth.gif')
root.addshape('food.gif')
root.addshape('downmouth.g... |
40c1d4c27696c5c52ce03d90cc35ffd4ca104d7a | Ashutos-h/Day6 | /1.py | 146 | 4.09375 | 4 | #Answer 1
def area(rad):
area_s=4*3.142*rad*rad
return area_s
radius=int(input("Enter radius of sphere:"))
print("Area of sphere:",area(radius)) |
62f706f31091da066722de95f8a3bc22348c51f4 | andres0970/Learning | /Hangman/Hangman.py | 1,243 | 3.8125 | 4 | import random
lives = 6
def get_word():
possibilities = ["para", "scrap", "divi", "trip"]
word = random.choice(possibilities)
return word
def debug(*args):
print(*args)
def turn_win(word, letters_guessed):
for letter in word:
if letter not in letters_guessed:
return False
... |
4feaecf885f65d23777a98d01d2dee301194795d | valentitomlinson/ZSS | /logic.py | 741 | 4.03125 | 4 | print('Ноль в качестве знака операции завершит работу программы')
while True:
s = input("Знак (&,|,^,~): ")
if s == '0': break
if s in ('&','|','^','~'):
x = int(input("Введите двоичное число x= "), 2)
y = int(input("Введите двоичное число y= "), 2)
if s == '&':
print(bin(... |
26dc8f8e7463768ea3bac7e785a014036af38cbe | jake-ilsoo-kim/APIDesign | /controller.py | 3,364 | 3.5 | 4 | from database import get_db
def insert_user(firstname, lastname, email, password):
db = get_db()
cursor = db.cursor()
statement = "INSERT INTO user(firstname, lastname, email, password) VALUES (?, ?, ?, ?)"
cursor.execute(statement, [firstname, lastname, email, password])
db.commit()
return Tr... |
f126931130536f60a6ff80e4380f1b2964552db3 | mingming741/RenneCode | /Python/CSCI 3320/第三次作业/ex2.py | 1,978 | 3.53125 | 4 | import os.path
import numpy as np
import matplotlib.pyplot as plt
from scipy import misc
from sklearn.decomposition import PCA
def load_data(digits = [0], num = 200):
totalsize = 0
for digit in digits:
totalsize += min([len(next(os.walk('train%d' % digit))[2]), num])
print('We will load %d images' ... |
f8a7e4ee7915bd8a853de04b0b0d22d477706c72 | mingming741/RenneCode | /Python/IERG 4190/miniproj1 張宇銘 1155076738.py | 3,784 | 3.71875 | 4 | #!/usr/bin/env python
""" About this project, I discussed with Hu Zixuan(1155043803),Yang Shihuan(1155076733).
It is the first time that I use python. I use spyder as the editer and test many
times. I discuss this with my classmate together and finally we get answer like this
"""
import scipy.io.wavfil... |
96bcdc70ea0ca94350789db2f45ae90d0950478b | RaviSankarRao/PythonBasics | /Student.py | 399 | 3.84375 | 4 | class Student:
# class initialize function
def __init__(self, name, major, gpa, is_on_probation):
self.name = name
self.major = major
self.gpa = gpa
self.is_on_probation = is_on_probation
def display_student(self):
return self.name + " : Major : " + self.major + " ... |
a7fb522c7c36c9ad087cbecd7b1ee3be92c7d1fb | RaviSankarRao/PythonBasics | /3_Working_with_numbers.py | 716 | 4.0625 | 4 |
print(2.345)
print(-2.5)
# arithematics
print(3 + 5.6)
print(3 * (4 + 5))
print(10 % 3)
print(10 / 3)
# convert number to string
my_number = 5
print(str(my_number) + " is converted to string and hence can be concatenated")
# convert strings to number
my_string = "3.4"
print(float(my_string))
my_string = "120"
print... |
6ac2ec81b99a93be96cf54244c8ec388ffaae278 | ramiBoss/GraphAlgos | /python/findCycle1.py | 826 | 3.65625 | 4 | import sys
def dfs(v, vertex, visited, graph):
visited[v] = 1
print v,"-> ",
for i in range(vertex):
if(visited[i] == 0 and graph[v][i] == 1):
dfs(i, vertex, visited, graph)
elif((visited[i] == 1 or visited[i] == 2) and graph[v][i] == 1):
print "Cycle Found Between ",... |
cf2e452633569fdf962752f0c97a206cf5160a4b | 19133/te-reo-quiz | /version1.py | 1,055 | 4 | 4 | import random
def yes_no(question):
valid=False
while not valid:
response = input (question) .lower()
if response == "yes" or response == "y":
response = "yes"
return response
elif response == "no" or response == "n":
response = "no"
return response
def... |
4bce97ac0c92c9c9c8681ea0e569b941fb6dbb09 | lauradoc/AdventOfCode | /day6.py | 830 | 3.515625 | 4 |
def count_yes_answers():
with open('day6.txt') as f:
lines = f.read().split('\n\n')
counter = 0
for line in lines:
counter += len(set(line.replace('\n', '')))
return counter
# print(count_yes_answers())
def count_yes_answers_2():
with open('day6.... |
f022d4c196b4c45454af923331572b6eecec2f1a | CyberWendy123/automation | /prettyCharacterCount.py | 474 | 3.828125 | 4 | # Aug 12, 2019 (Ch 5: Dictionaries)
# understanding pprint() and pformat() functions
import pprint
message = 'It was a bright cold day in April, and the clocks were striking thirteen.'
count = {}
for character in message:
count.setdefault(character, 0)
count[character] = count[character] + 1
pprint.pprint(coun... |
fb071851292cd966f23f709695b52d6cef90b89b | VishnuSandeep/first_evaluation | /step_4.py | 1,433 | 3.921875 | 4 | import time
import pandas as pd
import numpy as np
'''imports the module which is a written program and provides a lot of built-in function'''
def elements(sub_elements,all_elements):
'''Gives the return of length of verified elements'''
start = time.time()
verified_elements = []
for element in subset_... |
8fb338a991e15bde4a7250871eed53d6dcf339d9 | Massi1030/FIJ_Robotique | /00_algorithmique/01_python/variables.py | 424 | 3.703125 | 4 | #il existe 3 types de variables sous python
variable1 = 5#integer > int qui symbolis un nombre entier
variable2 = 3.2 # float qui symbolise un chiffre a virgule
variable3 = "Coucou" # string > str qui symbolise du texte
variable4 =True #boolean >bool symbolise une variable soit vrai
#soit faux
variable... |
a8289bf18554eeca38f41bf66a63db99b036f4e6 | LuisEnrique-OlazaranLaureano/AiLabSchool-Practicas-Python | /practica1.py | 755 | 4 | 4 | '''
Práctica 1.
Crear un programa que solicite el ingreso de números
enteros positivos, hasta que el usuario ingrese el 0.
Por cada número, informar cuántos dígitos pares y cuántos
impares tiene. Al finalizar, informar la cantidad de dígitos
pares y de dígitos impares leídos en total.
#Luis Enrique Olazarán L... |
9e2b24d086df8679d9fc711687f74e38d569babc | DonalChilde/utility_lib | /src/utility_lib/uuid_utilities/uuid_util.py | 1,188 | 3.609375 | 4 | """Utilities for dealing with UUID.
Version: 1.0
Last_Edit: 2019-09-07T18:10:57Z
"""
import uuid
from random import choices
from string import ascii_letters
from timeit import timeit
from typing import Union, Optional
import time
RANDOM_SALT = "".join(choices(ascii_letters, k=5))
def generate_uuid3(uuid_dns: uuid.... |
a39e88caa79d96b91422e6290df6b9454b4c0e76 | rtef23/algorithm-group-study | /lee-seongdong/week_01/1_1.py | 855 | 3.6875 | 4 | # Question1)
# 정수로된 배열이 주어지면, 각 원소가 자신을 뺀 나머지 원소들의 곱셈이 되게하라.
# 단, 나누기 사용 금지, O(n) 시간복잡도
# 예제)
# input: [1, 2, 3, 4, 5]
# left : [1, 1, 2, 6, 24]
# right: [120, 60, 20, 5, 1]
# output: [120, 60, 40, 30, 24]
def solution(input_list):
input_list_size = len(input_list)
left = list()
left.append(1)
for index in range... |
a47b84e926c2e36a72a91859b0ff2bca00afa8ef | smudger007/advent2020 | /day3/toboggan_trajectory.py | 946 | 3.59375 | 4 | import sys
import re
def loadInput():
with open("input.txt") as f:
content = f.read().splitlines()
f.close()
return content
def traversePiste(pisteIn, rightIn, downIn):
tobPointer = 0
treeCount = 0
pisteWidth = len(pisteIn[0])
for i in range(downIn, len(pisteIn), downIn):
... |
c9a84331c588580c2209ecc9389da36d6eec6eec | jm-sys/Multiple-Criteria-Decision-Aid | /codes/Chapter 3/PULP_example_2.py | 1,076 | 3.71875 | 4 | # Filename: PULP_example_1.py
# Description: An example of solving a binary
# linear programming problem with Pulp
# Authors: Papathanasiou, J. & Ploskas, N.
from pulp import *
import matplotlib.pyplot as plt
import numpy as np
# Create an object of a model
prob = LpProblem("Binary LP example with 6 decision "
"v... |
cd6cd5fee0da193e16827b8a1ba0ae0571e562b5 | KingsleyKelly/programmingpearls | /busywork.py | 435 | 3.765625 | 4 | from collections import defaultdict
import string
def main():
"""Prints all anagrams in the wordlist."""
f = open('/usr/share/dict/words')
anagrams = defaultdict(list)
for word in f.readlines():
word = word.translate(string.maketrans("",""), string.punctuation).strip().lower()
anagrams[''.join(sorted(w... |
5618d2210a7b742243aef736b6cb97156e24c466 | betaBison/vorkor | /tools/visMods.py | 1,235 | 3.671875 | 4 | import numpy as np
import matplotlib.pyplot as plt
import random
"""
Helper functions for visualization graphing
"""
def drawCircle(x0,y0,z0,radius):
# creates points for a circle of specified position and radius
N = 1000 # number of points for circle
pts = np.empty((N,3))
pts[0:int(N/2),0] = np.linsp... |
2773f455bb09f53e132b52628466cdc8e8244f11 | AthitXX/AthitXX-UW_FinTech_Challenge_1 | /loan_analyzer.py | 4,851 | 4.25 | 4 | # coding: utf-8
# Athit Padmasuta
"""Required Module Imports"""
# Module for csv file handling
import csv
# Module for handling files from OS paths
from pathlib import Path
"""Part 1: Automate the Calculations."""
# List of Loan Costs
loan_costs = [500, 600, 200, 1000, 450]
# Used the len function to calculate the to... |
3699d31efeda1e3400ff600d1c1e8ac35b3dc97f | JamesShoaf/AlgorithmPractice | /trie/wordSearchII/test.py | 875 | 3.546875 | 4 | import unittest
from word_search_II import Solution
class TestWordSearch(unittest.TestCase):
solver = Solution()
board = [
['o','a','a','n'],
['e','t','a','e'],
['i','h','k','r'],
['i','f','l','v'],
]
def test_search(self):
test_tuples = [
(['oath', ... |
76421dcf9bed406155b2c9f33ee1dbbab2891700 | JamesShoaf/AlgorithmPractice | /binaryTrees/binaryTree/sumRootToLeaf/sum_root_to_leaf.py | 1,003 | 3.71875 | 4 | from context import TreeNode
# In-order traversal
# initialize count and stack
class Solution:
def sum_root_to_leaf(self, root:TreeNode) -> int:
try:
count = 0
current = root
val = 0
stack = []
# push the node and its adjusted value to the stack
... |
bfd3bf9d6ae9d52a2286c45c87add5871f19b598 | JamesShoaf/AlgorithmPractice | /numericalMethods/hamming_distance/hamming_distance.py | 610 | 3.5625 | 4 | class Solution:
def hamming_distance(self, x: int, y: int) -> int:
if (not isinstance(x, int) or not isinstance(y, int)
or isinstance(x, bool) or isinstance(y, bool)) : return -1
xor = x ^ y
counter = 0
if xor > 0:
# this loop works in fewer steps for positive... |
76b72cad652c490ba57dbf9b45283f18b64f7dfb | lichhaosysu/algorithm | /Python/sort/QuickSort.py | 720 | 3.984375 | 4 | # -*- coding: utf-8 -*-
def quickSort(array, low , high):
i = low
j = high
tmp = 0
if low < high:
tmp = array[low]
while i != j:
while j > i and array[j] > tmp:
j = j - 1
array[i] = array[j]
while i < j and array[i] <= tmp:
... |
a32693e6713beaf459ac8878887c64f174987cb6 | PythEsc/Research_project2 | /Programming/python/importer/database/database_access.py | 4,920 | 3.890625 | 4 | from abc import ABC, abstractmethod
from importer.database.data_types import Post, Comment, Emotion, Sentence
class DataStorage(ABC):
"""
Abstract class / Interface that contains the method signatures needed for data access
"""
@abstractmethod
def update_post(self, post: Post):
"""
... |
3ecba5e53a0030b52cda723137f6b55a5e94134f | PythEsc/Research_project2 | /Programming/python/word2vec/word2vec_utitlity.py | 3,980 | 3.53125 | 4 | from gensim.parsing import PorterStemmer
import logging
import nltk
import re
import string as stringlib
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
logger = logging.getLogger("Word2VecUtility")
def clean_str(string):
"""
Cleans a given string using certain reg... |
2a00b1f9d660473b8e5cebbd593be5fd064e0529 | richeekawasthi/logistic-regression | /ex2/test.py | 433 | 3.75 | 4 | import math
import numpy as np
def sigmoid(m):
return 1.0/(1.0+math.exp(-m))
def hypothesis(features,theta):
return sigmoid(np.dot(features,np.transpose(theta)))
theta=np.load("result.npy")
x1=float(input("Enter x1: "))
x2=float(input("Enter x2: "))
features=np.ndarray(shape=(6),dtype=float)
features[0]=1.0
features... |
ea28f851765948e8709c8f9415a4149e1b8ce336 | Faracoeng/Python | /Aprimorando/baseMatPlotLib.py | 854 | 3.953125 | 4 | # Importando com apelido "plt" pyplot torna semelhante ao plot do Matlab
import matplotlib.pyplot as plt
#importando numpy
import numpy as np
x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
y = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# gerar relação x em função de y
plt.scatter(x,y)
#Plotar
plt.show()
# Array que começa em zero e ... |
07b0d67b322a198d076a44b580f300f209e017ea | Faracoeng/Python | /Exercicios estruturados/Condicionais/Lista II/Lista II exercicio 3.py | 190 | 3.5625 | 4 | peso = float(input('Peso: '))
if peso > 50:
excesso = peso - 50
multa = excesso * 4
else:
multa = excesso = 0
print ('Multa de R$ %.2f' %multa)
print ('Excesso: %.2f' %excesso)
|
5b19193704957d88a85997b2f0b55afda6fa244d | RongQiao/CodingPractice | /leetcode/ReverseStr344.py | 562 | 3.765625 | 4 | import unittest
class Solution(object):
def reverseString(self, s) -> None:
n = len(s)
start = 0
end = n-1
while start < end:
swap = s[start]
s[start] = s[end]
s[end] = swap
# change index
start += 1
end -= 1
... |
633e0b3b125f2f2098bbf8df4594721e7dfcd8b8 | mjm128/ClassicCiphers | /Row.py | 1,855 | 3.796875 | 4 | import math
class Row:
def __init__(self):
self.key = None
self.matrix = None
def setKey(self, key):
error = ""
if len(key) > 0:
l = []
for index, element in enumerate(key):
l.append((element, index))
if not element.isalpha():
error = "Key must be only alphabetical charact... |
d31ff2a6c5ddc03c68a6203af16e8e130fb521fd | TenederoGerard/Pandas | /cars.py | 232 | 3.828125 | 4 | import pandas as pd
#Corresponding .csv file into a data frame named cars using pandas
cars = pd.read_csv("cars.csv")
#Display the first five and last five rows of the resulting cars.
A = cars.head(5).append(cars.tail(5))
|
66c90ddfcdb89c74279fb4ed393feabe4fdee484 | gabrypol/algorithms-data-structure-AE | /selection_sort.py | 697 | 4.21875 | 4 | '''
Write a function that takes in an array of integers and returns a sorted version of that array. Use the Selection Sort algorithm to sort the array.
Sample Input
array = [8, 5, 2, 9, 5, 6, 3]
Sample Output
[2, 3, 5, 5, 6, 8, 9]
'''
def selection_sort(input_list):
for i, num_one in enumerate(input_list[:len(inp... |
35fa853535f504f06b1432c8ff311b56f808400c | gabrypol/algorithms-data-structure-AE | /suffix_trie_construction.py | 1,966 | 4.28125 | 4 | '''
Write a SuffixTrie class for a Suffix-Trie-like data structure. The class should have a root property set to be the root node of the trie and should support:
- Creating the trie from a string; this will be done by calling the populateSuffixTrieFrom method upon class instantiation, which should populate the root of... |
b2343b931d357ed51c092f30c6364f5c16ae7701 | gabrypol/algorithms-data-structure-AE | /bubble_sort.py | 859 | 4.34375 | 4 | '''
Write a function that takes in an array of integers and returns a sorted version of that array. Use the Bubble Sort algorithm to sort the array.
Sample Input
array = [8, 5, 2, 9, 5, 6, 3]
Sample Output
[2, 3, 5, 5, 6, 8, 9]
'''
def bubble_sort(input_list):
if len(input_list) == 0 or len(input_list) == 1:
... |
fa6f16a226c9fb75ef0ae3d0c0d9605b596bdb88 | gabrypol/algorithms-data-structure-AE | /breadth_first_search.py | 1,625 | 4.125 | 4 | '''
You're given a Node class that has a name and an array of optional children nodes. When put together, nodes form an acyclic tree-like structure.
Implement the breadthFirstSearch method on the Node class, which takes in an empty array, traverses the tree using the Breadth-first Search approach (specifically navigat... |
256f0b1451350097818cf653f0c1d319455f5c80 | gabrypol/algorithms-data-structure-AE | /move_element_to_the_end.py | 1,050 | 4.21875 | 4 | '''
You're given an array of integers and an integer. Write a function that moves all instances of that integer in the array to the end of the array and returns the array.
The function should perform this in place (i.e., it should mutate the input array) and doesn't need to maintain the order of the other integers.
S... |
f1adad8849912b0cc0d6f48d0988188ccf5ceb15 | gabrypol/algorithms-data-structure-AE | /levenshtein_distance.py | 1,012 | 4.03125 | 4 | '''
Write a function that takes in two strings and returns the minimum number of edit operations that need to be performed on the first string to obtain the second string.
There are three edit operations: insertion of a character, deletion of a character, and substitution of a character for another.
Sample Input
str1... |
44773d4ea6b487f628bc4d7699e13d2f923d1fd8 | WHKcoderox/microbit-template | /fireflies.py | 919 | 3.640625 | 4 | from microbit import *
import random
import radio
flash = [] # a list. do you remember the boats?
for x in range(9, -1, -1):
empty_img = Image()
fully_lit_img =
multiplied_brightness =
# add it into flash
flash.append(multiplied_brightness)
radio.on()
while True:
if button_a.was_presse... |
2715901e71d300e9545a86cdb3d1126231bd315b | kasper189/hackerrank | /algorithms/warmup/compare_triplets/compare_triplets.py | 585 | 3.515625 | 4 | #!/bin/python
import sys
def solve(a0, a1, a2, b0, b1, b2):
# Complete this function
a_counter = 0
b_counter = 0
a_list = [a0, a1, a2]
b_list = [b0, b1, b2]
for a, b in zip(a_list, b_list):
if a > b:
a_counter +=1
elif a < b:
b_counter += 1
return a... |
cf1883928e445f91eb4535007c6c06a2070f6936 | shabnam49/Geeks_For_Geeks | /Easy/Level-order-traversal-Line-by-Line.py | 2,346 | 3.90625 | 4 | '''
Given a Binary Tree, your task is to print its level order traversal such that each level is separated by $.
For the below tree the output will be 1 $ 2 3 $ 4 5 6 7 $ 8 $.
1
/ \
2 3
/ \ / \
4 5 6 7
\
8
Input:
The first line of input contains the num... |
ecdd15479dda996f899f38d86568e2fa2b23b0ef | chaithra-s/321810304038-Assignment-13 | /assignment 11.py | 1,453 | 4.1875 | 4 | #1:creation of tuples¶
In [1]:
t=(1,2,3,4)
print(t)
(1, 2, 3, 4)
#2:creation of tuple with different data types
In [2]:
t=(1,4.5,"chai")
print(t)
(1, 4.5, 'chai')
#3:tuple to a string
In [9]:
def con(tup):
str="".join(tup)
return str
tup=("micky","mouse","chota","bheem")
k=con(tup)
print(k)
mickymousechotabhe... |
f8abd009c0d438f8cd99f4e81e2c0713bf6b056b | Sterbic/CodeJam | /gcj_qualification_2013/tic_tac_toe_tomek/tic_tac_toe_tomek.py | 2,332 | 3.671875 | 4 | #!/usr/bin/env python3
"""
Google Code Jam 2013 - Qualification Round - 1. Problem
"""
__author__ = 'Luka Sterbic'
import sys
class GameResult(object):
X_WON = "X won"
O_WON = "O won"
DRAW = "Draw"
INCOMPLETE = "Game has not completed"
class Counter(object):
def __init__(self):
... |
67f91f3dd030bb085e96d3f69f86b4d50e9dc03c | bhavya-rshah/StaySafeTO | /staysafeto.py | 2,060 | 3.828125 | 4 | #Script and Text File Created By Bhavya Shah
# Data is based on 2018 crime statistics published by CP24 and reported by Narcity
# Intended to assist New Residents to Toronto when picking a neighbourhood to live in
import os
import sys
#Read the file line by line
filename = 'toneighbourhood.txt'
with open(filename) as ... |
9ce22a5d8498ed43170a7bada324430f5af4789c | tvhuong13/h1000 | /while.py | 274 | 3.5625 | 4 | def tinhgiaithua(n):
giaithua = 1
if ( n == 0 or n == 1 ):
return giaithua
else:
for i in range(2, n+1):
giaithua = giaithua * i
return giaithua
n = int(input('nhap vao so nguyen duong n: '))
print('giai thua cua',n, 'la') |
b12e6098df070e77e2778de195ef9d2d01b85e73 | joshua18charles/PythonLabs | /MadLibsGame.py | 1,327 | 3.9375 | 4 | #Mad Libs Game
#The purpose of this script is to have the user input the different data and have it append to a roster
#Roster must be entered in this order: Name, Postion, Height, Weight
roster = []
name = ''
postion = ''
height = 0.0
weight = 0
patrickMahomes = ['Patrick Mahomes', 'QB', 6.4, 225]
roster.append(pat... |
88736de25344e4738b7ee0dbaf1cce5162d70f71 | LuyiTian/LeetCode_luyi | /Count_Primes.py | 817 | 3.796875 | 4 | class Solution:
# @param {integer} n
# @return {integer}
def countPrimes(self, n):
if n <3:
return 0
def sieve(n):
"Return all primes <= n."
np1 = n + 1
s = list(range(np1)) # leave off `list()` in Python 2
s[1] = 0
sqrt... |
308c780307556bae4cdefb62ee532e1873660966 | LuyiTian/LeetCode_luyi | /Reverse_Linked_List_II.py | 1,344 | 3.78125 | 4 | # Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
# @param {ListNode} head
# @param {integer} m
# @param {integer} n
# @return {ListNode}
def reverseBetween(self, head, m, n):
if not head.next:
... |
bed2d1c8e15f54f4641768003571750a49492b57 | LuyiTian/LeetCode_luyi | /Validate_Binary_Search_Tree.py | 1,033 | 3.859375 | 4 | # Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
# @param {TreeNode} root
# @return {boolean}
def inorderTraversal(self, root):
output = []
def inorder(root, output):
... |
da9709fce744f57927173c4cf42ce5165730b221 | TangoMango223/Python-Practice-Code | /Hello-World/main.py | 364 | 3.859375 | 4 | #While Python has no main function, you can use it to help functions without bringing them to the top of your code
#Let's make a function that adds two numbers together
def add(x, y):
z = x + y
print(f"The sum of {x} and {y} is {z}")
#Now, let's make a main function to call it.
def main():
add(10,5)
#Ab... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.