blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
28f61625f6cc35e07557140465f6b2dcc3974d77 | delgadoL7489/cti110 | /P4LAB1_LeoDelgado.py | 549 | 4.21875 | 4 | #I have to draw a square and a triangle
#09/24/13
#CTI-110 P4T1a-Shapes
#Leonardo Delgado
#
#import the turtle
import turtle
#Specify the shape
square = turtle.Turtle()
#Draws the shape
for draw in range(4):
square.forward(100)
square.right(90)
#Specify the shape
triangle = turtle.Turtle()... |
714c9c402b65cf3102425a3467c1561eaa20f2dd | delgadoL7489/cti110 | /P3HW2_Shipping_LeoDelgado.py | 532 | 4.15625 | 4 | #CTI-110
#P3HW2-Shipping Charges
#Leonardo Delgado
#09/18/18
#
#Asks user to input weight of package
weight = int(input('Enter the weight of the package: '))
if weight <= 2:
print('It is $1.50 per pound')
if 2 < weight <=6:
print('It is $3.00 per pound')
if 6 < weight <=10:
print('It is $4.0... |
05be92d0a985f8b51e2478d52d0d476539b1f96c | delgadoL7489/cti110 | /P5T1_KilometersConverter_LeoDelgado.py | 659 | 4.59375 | 5 | #Prompts user to enter distance in kilmoters and outputs it in miles
#09/30/18
#CTI-110 P5T1_KilometerConverter
#Leonardo Delgado
#
#Get the number to multiply by
Conversion_Factor = 0.6214
#Start the main funtion
def main():
#Get the distance in kilometers
kilometers = float(input('Enter a distan... |
691901fba2190d657e8bfe6848c6858136a9a256 | AP-Skill-Development-Corporation/KITS-Python-14-06-2021-to-26-06-2021- | /iterators&generators.py | 1,266 | 3.78125 | 4 | ''' li=['h','i',' ','h','e','y']
print(''.join(li)) '''
st=input().split()
#print(''.join(st))
for word in st:
print(''.join(word))
st='fruit'
for ch in st:
print(st)
my_iter=iter(st)
print(next(my_iter))
print(next(my_iter))
''' print(next(my_iter))
print(next(my_iter))
pr... |
1b82280a718a8676938e9ef016cf10bb9a65609c | olbo98/Chatbot-Alpha | /src/stream.py | 2,351 | 3.78125 | 4 | from util import *
class Stream():
"""
General purpose (minimal) stream implementation.
Mostly imitating java.util.stream.Stream.
"""
def __init__(self, iterable):
self.base = iter(iterable)
def map(self, f):
return Stream(map(f, self.base))
def flat_map(self, f):
... |
b97e8694dd80c4207d2aef3db11326bef494c1d5 | aju22/Assignments-2021 | /Week1/run.py | 602 | 4.15625 | 4 | ## This is the most simplest assignment where in you are asked to solve
## the folowing problems, you may use the internet
'''
Problem - 0
Print the odd values in the given array
'''
arr = [5,99,36,54,88]
## Code Here
print(list(i for i in arr if not i % 2 ==0))
'''
Problem - 1
Print all the prime numbers from 0-100
... |
8105b9b973a61aaedab90b9844a11b9f427f761e | usb-reader/LineCounter | /count_lines.py | 1,339 | 3.71875 | 4 | import os
def main():
directory=str(raw_input("Directory: "))
recursive_traversal=str(raw_input("Recursive Traversal? (y or n): "))
file_exts=str(raw_input("File extensions (separate by comma): "))
file_exts=handle_file_exts(file_exts)
count= count_lines(directory, file_exts, recursive_traversal.lower())
print... |
458a227888540d810bf9d96191fa1436478a3b34 | aladinoster/class-toolkit | /tire.py | 289 | 3.859375 | 4 | from circle import Circle
class Tire(Circle):
""" Tires are circles with a corrected perimeter"""
def perimeter(self):
""" Circumference corrected for rubber"""
return Circle.__perimeter(self) * 1.25 # a problem if exposing radius
__perimeter = perimeter
|
1b99131e4ca2fc65db6ba7805df6a638cd727852 | orest95/Python_Labs | /Labs1/task3.py | 570 | 3.875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
a = int(input("Введiть a:"))
x = int(input("Введiть x:"))
esp = float(input("Введiть esp:"))
#while math.fabs(d) > eps:
# k += 1;
# fk *= k;
# fk2 *= fk;
# d = math.sin(a**k + x**k)/fk2;
# s += d;
k = 1
fn = stax=st3=1
d = math.sin(1)/2
s = ... |
c487f10008953853ffce904974c01f60be0e9874 | justus-migosi/desktop | /database/queries.py | 1,179 | 4.40625 | 4 | import sqlite3
from sqlite3 import Error
# Create a connection
def create_connection(file_path):
"""
Creates a database connection to the SQLite database specified by the 'path'.
Parameters:
- path - Provide path to a database file. A new database is created where non exists.
Return:
- Retu... |
6ed349e75986410c940889a87078ea621226e514 | mnikn/code-base | /python/permutations.py | 319 | 3.609375 | 4 | def permutations(seq):
if seq == []:
return [[]]
solutions = []
for i in range(len(seq)):
sub_solutions = permutations(seq[0:i] + seq[i+1:])
for sub_solution in sub_solutions:
solutions.append([seq[i]] + sub_solution)
return solutions
print (permutations([1,2,3]))
|
ed8ee7b2a281be50aff0342bda9170523b76f38d | smallfat17/FluentPython | /day03/test1.py | 1,121 | 3.5 | 4 | #切片, list的+、*、+=、*= ,list.sort、sorted
import random
if __name__ == '__main__':
#切片
l = list(range(10))
l[2:5] = (100, 200) #一定是可迭代类型
print(l) #[0, 1, 100, 200, 5, 6, 7, 8, 9]
l[2:5] = {55: '1', 66: '2'} #
print(l) #[0, 1, 55, 66, 6, 7, 8, 9]
del l[2:5]
print(l) #[0, 1, 7, 8, 9]
#... |
a61e5fa326991af056a692ef815b6062f0f86b5a | smallfat17/FluentPython | /day04/deque.py | 950 | 3.78125 | 4 | from collections import deque
import heapq
if __name__ == '__main__':
#deque
dq = deque(range(10), maxlen=5) #maxlen属性限制队列长度
print(dq) #deque([5, 6, 7, 8, 9], maxlen=5)
dq.rotate(2) #类似传送带,正数向右滚动,负数向左边滚动
print(dq) #deque([8, 9, 5, 6, 7], maxlen=5)
dq.rotate(-2)
print(dq) #deque([5, 6,... |
506db8ea638d7433472a2698f8fb19b7e9c6d1f0 | smallfat17/FluentPython | /day08/Operator_Test.py | 541 | 3.625 | 4 | from functools import reduce
#n的阶乘
def fact(n):
return reduce(lambda a, b: a*b, range(1, n+1))
print(fact(5))
#使用operator
import operator
def fact_operator(n):
return reduce(operator.mul, range(1, n+1))
print(fact_operator(5))
#itemgetter
a = [0, 1, 2]
getter1 = operator.itemgetter(1)
print(getter1(a)) #1
... |
decb0822cdf1c6203b5770b541d3af98dd600d16 | AngelEmil/2da-Practica--Operadores- | /Ejercicio 5.py | 173 | 4 | 4 | # 5 -- Pedir un número en Celsius y convertir a Fahrenheit: F = 1.8*C + 32.
C = int(input("digite el grado Celsius "))
F = 1.8*C + 32.
print("Su fahrenheit es", F) |
052b9fe5c715c32042336d83a198138a12ab97c1 | ianmlunaq/edhesive-python | /6.xx_Ian_Luna.py | 582 | 3.9375 | 4 | # 6.xx_Ian_Luna.py | ian luna | 2020.05.06 | 2-D List
def printBackward(List2D):
length1 = len(List2D)
for i in range(len(List2D)):
length1 -= 1
length2 = len(List2D[i])
for y in range(len(List2D[i])):
length2 -= 1
print(List2D[length1][length2], end='')
... |
0acadc79127f5cc53cb616bac3e31c2ef120822f | shahzadhaider7/python-basics | /17 ranges.py | 926 | 4.71875 | 5 | # Ranges - range()
range1 = range(10) # a range from 0 to 10, but not including 10
type(range1) # type = range
range1 # this will only print starting and last element of range
print(range1) # this will also print same, starting and last element
list(range1) # this will list the whole range from... |
446ebcd36776de90a6199e95e12bafef287829b8 | youssefibrahim/Programming-Questions | /Find all duplicates in list.py | 886 | 4.0625 | 4 | # Given a list of integers, return a list of all duplicates
def find_dups(int_array):
# Checks base case of empty list
if not int_array:
return None
# Sort the array to group all duplicates
int_array.sort()
# Create an array of size two to shift
# integers into
dups = [0]*2
# Create array to store duplic... |
69f33f4919562b4dd54d868fbc63c81ecf4567ca | youssefibrahim/Programming-Questions | /Is Anagram.py | 725 | 4.15625 | 4 | #Write a method to decide if two strings are anagrams or not
from collections import defaultdict
def is_anagram(word_one, word_two):
size_one = len(word_one)
size_two = len(word_two)
# First check if both strings hold same size
if size_one != size_two:
return False
dict_chars = defaultdict(int)
# Use di... |
a485518e1d88f8b6edd9d522a4644ba7530e063e | Therealchainman/LeetCode | /problems/unique_paths_iii/solution.py | 1,622 | 3.640625 | 4 | class Solution:
def uniquePathsIII(self, A):
R, C = len(A), len(A[0])
count = 0
# First objective is to count the number of empty cells that we must travel to in the grid.
for r, c in product(range(R), range(C)):
if A[r][c] == 0:
count += 1
eli... |
46892d5e2ed394785b9d7e4a483ef39e20d80f48 | Therealchainman/LeetCode | /problems/binary_tree_maximum_path_sum/solution.py | 840 | 3.6875 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def maxPathSum(self, root: TreeNode) -> int:
max_path = float('-inf')
def maxSoFar(root: Tre... |
107e4db7d5e8fe097c417af27adfcdc040a48f10 | Therealchainman/LeetCode | /problems/number_of_good_leaf_nodes_pairs/solution.py | 2,638 | 3.546875 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def countPairs(self, root, threshold) -> int:
self.ans = 0
def dfs(node, d=0):
i... |
ce27e17b4a362fb3c6c5287b45add36008b6ab3a | Therealchainman/LeetCode | /problems/find_a_value_of_a_mysterious_function_closest_to_target/solution.py | 440 | 3.578125 | 4 | class Solution:
def closestToTarget(self, arr, target):
s = set()
mind = float('inf')
for v in arr:
ns = set()
ns.add(v)
for u in s:
ns.add(u & v)
for u in ns:
mind = min(mind, abs(u - target))
if... |
9aea5739fb41af7127ddccc9bbd236ee45766cf6 | Therealchainman/LeetCode | /problems/stream_of_characters/solution.py | 1,362 | 3.90625 | 4 | class TrieNode:
def __init__(self):
self.edges={}
def get_edge(self,edge):
return self.edges[edge]
def add_edge(self,edge):
self.edges.setdefault(edge,TrieNode())
def has_edge(self,edge):
return edge in self.edges
def isWord(self):
... |
e2b80687eb476f9a72534927e57d34793e7cc72c | Therealchainman/LeetCode | /problems/ugly_number_ii/solution.py | 817 | 3.71875 | 4 | class Solution:
def nthUglyNumber(self, n: int) -> int:
factors = [2, 3, 5]
pointers = [0, 0, 0]
numbers = [1]
for _ in range(1, n):
candidates = [factors[i] * numbers[pointers[i]] for i in range(len(factors))]
newCandidate = min(candidates)
number... |
a4dbec17f74827979bc1ee98d36ba394bdcf0750 | Therealchainman/LeetCode | /problems/power_of_two/solution.py | 395 | 3.5625 | 4 | class Solution:
def isPowerOfTwo(self, n: int) -> bool:
if n <= 0:
return False
return n & -n == n
"""
Start time: 3:43PM
Approach1: Bit manipulation, O(1), O(1)
&: logical operator --> check if bit is on or not.
16 -> 0001 0000
&
16 - 1 -> 0000 1111
0
1 -> 0000 00... |
49a1b0bd0daed9c2fd4cbaf1fee92e10dde43da3 | Therealchainman/LeetCode | /problems/palindrome_number/solution.py | 368 | 3.515625 | 4 | class Solution:
def isPalindrome(self, x):
if x<0:
return False
multiple=1
while x>=multiple*10:
multiple*=10
while x>9 and multiple>1:
right=x%10
left=(x//multiple)%10
if left!=right: return False
multi... |
b44b3ec38221aa2ecea175dce8526807cac5e134 | VictoriaKwamboka/Sample-Repo | /Ex_1/python-numeric-operations/numeric_1.py | 285 | 4.09375 | 4 | first_num= input('First Number: ')
second_num= input('Second Number: ')
if first_num.isnumeric()==False or second_num.isnumeric() ==False:
print('Please enter numbers only.')
exit()
first_num= int(first_num)
second_num= int(second_num)
sum = first_num + second_num
print(sum)
|
2bda644eaa1351f8c7c3fc223a855366a4d3c9af | helenwang2014/python-practice | /Exercise5/poundstokg.py | 161 | 4 | 4 | #Convert pounds to kilograms
pounds = float(raw_input("Please enter the weight in pounds: "))
kg = pounds * 0.454
print pounds, "pounds equals %.2f kg. " % kg
|
4ff69b33c9d647ebc2de8069950951ab46b38bb5 | LiuYueyao/phylotree_mutation | /BinaryTree.py | 1,381 | 3.671875 | 4 | class BinaryTree(object):
def __init__(self, name_value):
self.name = name_value # name
self.seq = [] # alignment sequence, list
self.leftchild = None
self.rightchild = None
def set_name(self, name_value):
self.name = name_value
def set_seq(self, seq_value):
... |
4d50ce24bed3f2d96d1ae5d68bf0a47adb6e98ec | nsa32752/Python-tutoring | /튜터링_2018_2/tutor6.py | 491 | 3.875 | 4 | class Point:
def __int__(self, x=0, y=0):
self.x = x
self.y = y
def distance_from_origin(self):
return ((self.x**2) + (self.y**2)) ** 0.5
def __str__(self):
return "({0}, {1})".format(self.x, self.y)
def __del__(self):
print("Instance is removed")... |
d3199b14e08e23a9b195967ecc33fa2f67fa269a | nsa32752/Python-tutoring | /튜터링_2018_2/tutor 5-2.py | 783 | 3.5625 | 4 | file = open("text.txt", "r")
file2 = open("result.txt", "w")
words = []
dic = {}
line = file.readlines()
print(line)
for word in line:
words += word.split()
print(words)
for x in words:
x = x.lower()
#print(x)
if x.isalpha():
if x in dic:
dic[x] += 1
el... |
c841256925cf1f818abd9902f300c7a724d3846a | AbdulrahmanSamir/password-checker-1 | /password checker.py | 505 | 3.796875 | 4 | #Check password (Strong or Medium or week or very week)
#Upper case, lower case, digit and special chracters is a strong password!
pas = input("Please enter password: ")
L=0
U=0
D=0
S=0
for x in pas:
if x.islower():
L1=1
elif x.isupper():
U=1
elif x.isdigit():
D=1
... |
ab3422d963bcdc3a7d62f51196480c0e59b0373d | Anush-007/Leetcode | /2. Add Two Numbers/Solution.py | 501 | 3.640625 | 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 addTwoNumbers(self, l1, l2):
final = l1
carry = 0
while l1.next and l2.next:
l1.val += l2.val + carry
carry = l1.val / 10
l1.val %= 10
... |
65778e41f5d2fae0c62993edd0c98ca8c603783d | EXCurryBar/108-2_Python-class | /GuessNumber.py | 374 | 4.125 | 4 | import random
number = random.randint(0,100)
print(number)
print("Guess a magic number between 0 to 100")
guess = -1
while guess != number :
guess = eval(input("Enter your guess: "))
if guess == number :
print("Yes, the number is ",number)
elif guess > number :
print("Your guess is too high... |
3ae0eac4123ba95f7f92de9a80886bee3d06aa05 | Jacobhutter/JacobHutter_public | /cs440/mp1/part2/astar.py | 1,603 | 3.828125 | 4 | import sys
class successor:
def __init__(self, loc):
self.f = 0
self.g = 0
self.h = 0
self.location = loc
self.parent = -1
self.distance = -1
def manhattan_distance(loc1, loc2):
return abs(loc2[0] - loc1[0]) + abs(loc2[1] - loc1[1])
def a_star(start, end, maze):
#SEARCH CODE
start_successor = succ... |
7199d6bc8679d652b2c9f62c891e6225697a9d8b | NitroLearn/NitroLearn-Tic-Tac-Toe | /TicTacToe FirstTake.py | 12,910 | 3.84375 | 4 | import time
import sys
def delay_print(s):
for c in s:
sys.stdout.write(c)
sys.stdout.flush()
time.sleep(0.125)
def play_tic_tac_toe():
bp1 = '_|_|_'
bp2 = '_|_|_'
bp3 = ' | |'
bp1p1 = '_|'
bp1p2 = '_|'
bp1p3 = '_'
bp2p1 = '_|'
bp2p2 =... |
9f49395cf5ba8b2d9405ba9603c31f1f8768f2a5 | barness/Exam_Scheduler | /python_version/exam_scheduling_ver1.py | 6,139 | 3.6875 | 4 | # Khanh Nghiem
# Jun 04, 2018
# A command line program that prompts the user to choose excel files
# Extract class names and student data
# Use the Welsh-Powell algorithm to find blocks of courses that should be
# scheduled together
# Graphics Modules
from tkinter import Tk
from tkinter import filedialog
# Modules to ... |
bac18cdc3470e5afdcf0acd74c3d84c58c1af4f8 | IONIQ6000/Python_Cryptography | /Q3.py | 2,067 | 3.828125 | 4 | # This code covers question 3 on assignment 1
Xstream = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1] # The X,Y,Z streams provided from the assignment
Ystream = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]
Zstream = [1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]... |
400dcfdf334dd1ee951555a1720a90e2facc02d3 | bruhbruh445/ByteJam2020 | /PatrioticArcade/PatrioticArcade.py | 14,333 | 3.5625 | 4 | import pygame
# Global constants
# Colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)
BLUE = (0, 0, 255)
bg = pygame.image.load("bg.png")
left = False
right = False
walk_count = 0
# Screen dimensions
SCREEN_WIDTH = 1920
SCREEN_HEIGHT = 1080
class Player... |
39995e9d4ee9ec9cf35586f08f00aa7a22fa7ed6 | yuichi110/www.yuichi.com-python | /html/0550_code/sample1.py | 126 | 3.53125 | 4 | text = 'hello world'
d = {}
for c in text:
if c in d:
count = d[c]
d[c] = count + 1
else:
d[c] = 1
print(d)
|
9202b9f4c4cd48cbad78d1135435b8d333b750e4 | yuichi110/www.yuichi.com-python | /html/0075_code/image1.py | 229 | 3.828125 | 4 | a = 10
b = 10
def function():
a = 20
global b
b = 20
print('before: a = ' + str(a)) # 10
print('before: b = ' + str(b)) # 10
function()
print('after: a = ' + str(a)) # 10
print('after: b = ' + str(b)) # 20
|
7e59496928aff9f24fcb3e41318f26ebcb8eb2f6 | rishusolanki/Basic-python-program | /square_star.py | 99 | 3.875 | 4 | num = eval(input("enter numeric no beetween 4 to 8 : "))
for i in range(1,num):
print("* "*num) |
a586d65be1a182562c35932b5e4bf14824c99d30 | CHOIsunhyeon/bioinfo-lecture-2021-07 | /src/004.py | 108 | 3.6875 | 4 | #!usr/bin/python
num1 =3
if num1 % 2 == 0:
print(num1,"홀수")
else:
print(num1,"홀수아님")
|
2f7b527bc7d5370f0b6249616f3e2d8cde8e4694 | brandenk514/hal | /location.py | 8,066 | 3.5 | 4 | import googlemaps
import os
import formatter as f
import requests
import json
# A class that using the Google API python wrapper to get json request from Google APIs
class Location:
def __init__(self):
"""
Constructs a location object with a google API key and an ip
"""
self.locat... |
056a63254c3cf5dbaea60cc058b691a8e7d93e5c | d-vignesh/data-structures | /linkedlist/DoublyLinkedListImpl.py | 2,749 | 3.84375 | 4 |
class Node :
def __init__(self , data , prev=None , next=None ) :
self.data = data
self.prev = prev
self.next = next
class DoublyLinkedListImpl :
def __init__( self , head= None) :
self.head = head
def add_to_end(self , data) :
node = Node(data)
if not self.head :
self.head = node
return s... |
f4bc032612a04e8a5b7d979a5e91bc12797b6a3d | d-vignesh/data-structures | /graph/DijkstraOwn.py | 5,252 | 3.953125 | 4 |
'''
PYTHON MODULE TO IMPLEMENT A GRAPH DS AND DIJKSTRA ALGORITHM
'''
import logging
import collections
logging.basicConfig(level=logging.DEBUG, format = '%(asctime)s - %(levelname)s - %(message)s')
# CLASS TO REPRESENT A VERTEX
class Vertex(object):
def __init__(self, data):
'''
I/P : DATA OF THE VERTEX
... |
19a4778cdfc80fb6326ef680485fdc3e0ffa5ae7 | d-vignesh/data-structures | /dp/LCSRecMemo.py | 1,146 | 3.8125 | 4 |
'''
python class to find longest common subsequence of two string using recursion and memoziation.
'''
class LCSReMemo (object):
def compute_lcs(self, str1, str2):
memo = [[None for col in range(len(str2))] for row in range(len(str2))]
print(self._compute_lcs(str1, str2, 0, 0, memo))
def _compute_lcs(self, ... |
9e1f918e0fc420ce9ff330b45fb1027d2294914f | Nehawavre/Assignment1 | /Assignment_1.py | 3,320 | 3.90625 | 4 | import random
class Message:
msg = """
Welcome to Snake and Ladder Game.
Rules:
1. Initially both the players are at starting position 0.
2. You have to choose how many players.
3.You can choose 2 or 3 or 4.
4.Then play your game when it's your turn just enter player n... |
b61a5f6e60ed28b6e520ab1dc90b993f09e47500 | zerotsukaima/spisok | /test.py | 209 | 3.78125 | 4 | A = [ [4, 7, 3], [9, 5, 6] ]
for i in range(len(A)):
for j in range(len(A[i])):
print(A[i][j], end = ' ')
print()
for row in A:
for elem in row:
print(elem, end = ' ')
print() |
3f100f352581a0912c11357f4c79a28a4ed0d396 | sagarnildass/flask_rest_api_tutorial | /section_3_first_rest_api/app.py | 3,721 | 3.859375 | 4 | #jsonify converts dictionary to string(json) which is easy to send across web
from flask import Flask, jsonify, request, render_template
#creating object of Flask
app = Flask(__name__)
#set the root path
#@app.route('/') #https://www.google.com/ <--- This slash is the homepage
#This has to return a response to our br... |
3913cd582c45f08f794b58ef8b70fea56374aadc | Vincent74230/Racer | /racer.py | 4,114 | 4.0625 | 4 | """Little programm of an imaginary race between 5 imaginary cars
in an imaginary track made of 20 imaginary trackparts:
it's neverland"""
from random import random, randint
TERRAINS = ["asphalt", "sand", "mud", "rocky"]
COMPLEXITIES = ["normal", "rapid", "subtle"]
PILOT = ["A", "B", "C", "D", "E"]
class TrackPart:#py... |
ff4d6367f6ada7bf9333528553e669779e0b9271 | bailijiang/Python_exercise | /favorite_language.py | 1,654 | 3.78125 | 4 | __author__ = 'Bryan'
#coding=utf-8
from collections import OrderedDict
favorite_languages = OrderedDict()
favorite_languages['Bryan'] = 'C/C++'
favorite_languages['Heero'] = 'Python'
favorite_languages['Blues'] = 'Java'
favorite_languages['Bai'] = 'Golang'
for name, language in favorite_languages.items():
print... |
63b200afc8ee8164323901e1e459459594a066e1 | bailijiang/Python_exercise | /replace_test.py | 238 | 3.609375 | 4 | __author__ = 'Bryan'
#coding= utf-8
file_name = 'note.txt'
with open(file_name) as file_obj:
lines = file_obj.readlines()
replace_text = ''
for line in lines:
replace_text += line.replace('Python', 'C/C++')
print(replace_text) |
24c61c19c87c1dfe990ace7a4640a17328add3b0 | PaulSweeney89/CTA-Quiz | /factorial.py | 322 | 4.15625 | 4 | # Recursive Algorithms - Lecture 06
# Computing a factorial
# Iterative Implementation
def factorial(n):
answer = 1
while n > 1:
answer *= n
n -= 1
return answer
print(factorial(5))
# Recursive Implementation
def factorial_rec(n):
if n <= 1:
return 1
else:
return n*factorial_rec(n-1)
print(factorial(5... |
9a4487efbce48fe82a87b433d845b6be2738506f | ncedenog/ind_assignment_16_nov | /ex2_assignment_16_11.py | 1,255 | 3.828125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 19 15:57:46 2018
@author: nataliecedeno
"""
#%%
#Exercise 2
product_list = {
"Guitar": 1000,
"Pick box": 5,
"Guitar string": 10,
"Insurance": 5,
"Priority mail": 10
}
shopping_cart = ["... |
2b6658756ad37d95f8bbfe75ae24255d1c69843d | rg4592/text-representation | /text_representation.py | 1,093 | 3.609375 | 4 | # Prepare Text Data for Machine Learning with scikit-learn
# Word Counts with CountVectorizer
# from sklearn.feature_extraction.text import CountVectorizer
# text = ["The quick brown fox jumped over the lazy dog."]
# vectorizer = CountVectorizer()
# vectorizer.fit(text)
# print(vectorizer.vocabulary_)
# vector =... |
e7fb7d7469ce66c93a585e9cb3c2e848fca93e39 | hack-at-uchicago/python-workshop | /examples/twitter/get_tweet_lengths.py | 395 | 3.859375 | 4 | #!/usr/bin/python
#
# hack@uchicago Introduction to Python Workshop
# Borja Sotomayor, 2013-2014
"""
Prints out the lengths of the tweets in the dataset.
"""
import workshop
import sys
tfile = sys.argv[1]
n = int(sys.argv[2])
tweets = workshop.get_tweets_text(tfile, n)
for tweet in tweets:
print len(tweet)
#
... |
5add52b3eede353d2a1b589a83f87bd49511be3f | rodrigorafaeldamaceno/curso-rede-neural | /exercicios/0301c.py | 1,887 | 3.59375 | 4 | #!/usr/bin/env python3
import numpy as np
#import math
# exercício: implementar MLP xor em um único tensor
class Xor:
def __init__(self):
self.ds = np.array([
[0, 0],
[0, 1],
[1, 0],
[1, 1]
])
w1 = np.array([[1., 1.], [1., 1.]]) # pesos da primeira camada
b1 = np.array([-0.5... |
14e69b9c0629e0184bd491115068f3748f84d156 | SugarFreeManatee/ActividadThreading | /Actividad threading/AC04-Threading/solucion/imprimidores.py | 1,897 | 3.53125 | 4 | from threading import Thread, Lock
from random import randint, uniform
from utils import reloj
class Imprimidor(Thread):
impresion_lock = Lock()
def __init__(self, nombre, berlin, bolsa_dinero):
super().__init__()
self.nombre = nombre
self.daemon = True
self.berlin = berlin
... |
25f5b5b1822d9ab10962279eaafb0c063031d517 | nishantsahoo/ACM_Cryptography_SimpleCryp | /cryp_file.py | 911 | 3.65625 | 4 | import sys
from cryptography.fernet import Fernet
sys.stdout = open('Decrypt_file.txt', 'w')
# Put this somewhere safe!
a = {'A': '1',
'B': '2',
'C': '3',
'D': '3',
'E': '5', }
b = {} # Empty dictionary
key = Fernet.generate_key() # Generation of a fernet key
fer = Fernet(key) # fernet object
... |
2961fa9238b184a755f9174cb5479ea4913bb242 | nikuyoshi/Python-Hack-a-thon-2010.7--- | /balance.py | 2,059 | 3.6875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import fileinput
import codecs
from datetime import date
argvs = sys.argv[1:]
argc = len(argvs)
gdbm.firstkey=0
if (argc == 0) :
print 'Error: wrong number of arguments: 1 and over'
else:
for i in range(len(argvs)):
argvs[i] = unicode(argvs[i]... |
1769fffe754f8182c49efffe49bd708168264577 | seungjaeryanlee/clarity | /clarity/Move.py | 4,057 | 4.25 | 4 | #!/usr/bin/env python3
"""
This file defines the Board class.
"""
import numpy as np
from .MoveType import MoveType
from .Sq import Sq
class Move:
"""
This class represents a chess move.
"""
def __init__(self, init, dest, move_type):
"""
Run when a Board object is created.
Pa... |
23546cfa525208b09bc509b27f1bbfbef5c73f46 | TakeruNishimi/Kadai-A | /beautiful_kuku.py | 462 | 3.84375 | 4 | def main():
row = input("行数を入力してください。 > ")
col = input("列数を入力してください。 > ")
for i in range(1, int(row) + 1):
for j in range(1, int(col) + 1):
print_formula(i, j)
print()
def print_formula(a, b):
print(f'{a} × {b} = ', end=" ")
if (len(str(a * b)) == 1):
print(' ',... |
112da84fe029bfec6674f8fdf8cea87da361a96f | tminhduc2811/DSnA | /DataStructures/doubly-linked-list.py | 2,053 | 4.3125 | 4 | """
* Singly linked list is more suitable when we have limited memory and searching for elements is not our priority
* When the limitation of memory is not our issue, and insertion, deletion task doesn't happend frequently
"""
class Node():
def __init__(self, data):
self.data = data
self.nex... |
2d0e92702fd53f816265742c6f025e2b8b39e181 | tminhduc2811/DSnA | /Algorithms/binary_search.py | 703 | 4.3125 | 4 | import merge_sort
def binary_search(arr, start, end, x): # T(n/2) => O(lg(n))
if start <= end:
middle = (start + end)//2
if arr[middle] == x:
return middle
if arr[middle] > x:
return binary_search(arr, start, middle - 1, x)
if arr[middle] < x:
ret... |
bf3bf0b5546410fa191c261b24ec632e761ff151 | nayana09/python | /file1.py | 2,555 | 4.125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
print("Hello, Welcome to python Introduction")
# In[2]:
#Python Variables
x = 5
y = "Nayana"
print(x)
print(y)
# In[7]:
x = 4
x = "Grapes"
print(x)
# In[4]:
#casting
x = str(3)
y = int(3)
z = float(3)
print(x)
print(y)
print(z)
# In[6]:
#get data type
x... |
8b9cd55270f32d1e3a54f06d4a496d138801ec38 | xzfd1010/python-YushuBook | /app/libs/my_http.py | 827 | 3.90625 | 4 | """
HTTP的一般类
"""
import requests
class HTTP:
# 用于处理一切请求的类,方法应该都是静态方法,不涉及业务,是基础类
@staticmethod # staticmethod 没有用到类变量和对象变量
def get(url, return_json=True): # restful API 返回 json格式的数据
r = requests.get(url)
# 根据状态码处理不同情况
if r.status_code != 200:
return {} if return_json ... |
480527a80b956fdd5460fd91f81fe6132e90e98b | usamalatif/Assignment---RA-ITU | /Zip.py | 534 | 3.984375 | 4 | def Zip(Array1,Array2):
List = []
if (len(Array1)>0 and len(Array2)>0):
a=0
if(len(Array2)>len(Array1) or len(Array2)==len(Array1)):
while(a<len(Array1)):
List.append((Array1[a], Array2[a]))
a = a+1
elif (len(Array2)<l... |
f884af6224b29569f64f33575d76997a41b876a3 | 1000monkeys/probable-invention | /8/8-10.py | 392 | 3.625 | 4 | def show_magicians(magician_names):
for magician_name in magician_names:
print(magician_name)
def make_great(magician_names):
i = 0
while i < len(magician_names):
magician_names[i] += " the Great!"
i += 1
magician_names = ['Zabrecky, Rob', 'The Zancigs', 'Reveen, Peter', 'Ogawa, ... |
d9b4c46d0f658f3230b86b5b2a938507e6beba89 | 1000monkeys/probable-invention | /3/3-8.py | 416 | 3.515625 | 4 | if __name__ == "__main__":
locations = ['moon', 'mars', 'heaven', 'afterlife', 'new life']
print(locations)
print(sorted(locations))
print(locations)
print(sorted(locations, reverse=True))
print(locations)
locations.reverse()
print(locations)
locations.reverse()
print(locations)
... |
46db163621769216d4cb8260bab9296907ae61d9 | 1000monkeys/probable-invention | /6/6-5.py | 297 | 3.953125 | 4 | if __name__ == "__main__":
rivers = {
'nile': 'egypt',
'limpopo': 'mozambique',
'okavango': 'angola',
'gambia': 'gambia'
}
for name in sorted(set(rivers.keys())):
print(name)
for value in sorted(set(rivers.values())):
print(value)
|
92d029026320aba4299481e10843d74a65aa5627 | 1000monkeys/probable-invention | /5/5-6.py | 351 | 4 | 4 | if __name__ == "__main__":
age = 13
if age < 2:
print("You little baby!")
elif 2 < age < 4:
print("You toddler!")
elif 4 <= age < 13:
print("You child!")
elif 13 <= age < 20:
print("You teenager!")
elif 20 <= age < 65:
print("You adult!")
elif age <= ... |
e995f84edb108682d791a610298734717eeddd45 | 1000monkeys/probable-invention | /6/6-1.py | 276 | 3.640625 | 4 | if __name__ == "__main__":
kjell_info = {
'name': 'Kjell',
'middle-name': 'Roderick',
'last-name': 'Vos',
'age': 26,
'city': 'Groningen'
}
for key, value in kjell_info.items():
print(str(key) + " is " + str(value))
|
0e4068013a954c3a42f31d3875296b00ecbd4685 | 1000monkeys/probable-invention | /4/4-11.py | 370 | 3.921875 | 4 | from random import randint
if __name__ == "__main__":
pizzas = ["Salami", "Vier Kazen", "Pepperoni"]
friend_pizzas = pizzas[:]
pizzas.append("Hawai")
friend_pizzas.append("Ham and bacon")
for pizza in pizzas:
print("My favorite pizzas are: " + pizza)
for pizza in friend_pizzas:
... |
5a2b5101fbb0f75350788fb075ba788e15e5478e | MSDPhoenix/selection_sort_msd | /selection_sort.py | 1,321 | 4.03125 | 4 | # WITH EACH STEP PRINTED
x=[5,1,4,2,8,9,8,7,6,4,5,3,2,1]
y=[5,1,4,2,8]
def selectionSort(arr):
print("starting ",arr)
for j in range(len(arr)):
min=arr[j]
for i in range(1+j,len(arr)):
print("comparing index",j,"with index",i,arr)
if min>arr[i]:
min=... |
209ea7bed2bfaa08c6d4a427fafa6bb2172f7bad | iris04/Homework | /PycharmProjects/SWD/start.py | 163 | 3.515625 | 4 | # !/usr/bin/env python
# -*- coding: cp852 -*-
variable1 = 1
variable2 = int(raw_input("Gebe eine Zahl ein, bitte."))
summe = variable1 + variable2
print ""
|
f14a04ad4c8352985df955f747b5b6efa1f94edd | whygreedy/hi | /hobby.py | 136 | 3.859375 | 4 | name = input('what is your name ? ')
hobby = input('what is your hobby')
print('Hello world, my name is', name, ',and I love to', hobby) |
d4afb49cfd2a1fdb8fe99eb0231b2f8655798c81 | micro164/AdvGame | /Healing/Healing.py | 874 | 3.546875 | 4 | from Classes.Classes import Player
from Utilities.HelperUtilities import print_slow
def healer():
"""Gives the player a choice to heal in exchange for gold"""
print_slow("Welcome to the healer.\nWould you like to heal?")
choice = input("Y/N\n")
if Player.hp != Player.MaxHP and choice == 'Y' or choice... |
67fe5148d428da1ceb1c8cffaddaefd4a2e81783 | jessiicacmoore/python-reinforcement-exercises | /python-reinforcement-may13/exercise.py | 691 | 3.640625 | 4 | class Person:
def __init__(self, emotions):
self.mood = emotions
def __str__(self):
return f"Emotions: {self.mood}"
def get_mood(self):
results = []
for emotion, level in self.mood.items():
if level == 1:
results.append(f"I am feeling a low amount of {emotion}")
elif level ==... |
4e60800182b8bb8fccbb924b21ebc40cdfb497b5 | jessiicacmoore/python-reinforcement-exercises | /python_fundamentals1/exercise5.py | 319 | 4.125 | 4 | distance_traveled = 0
while distance_traveled >= 0:
print("Do you want to walk or run?")
travel_mode = input()
if travel_mode.lower() == "walk":
distance_traveled += 1
elif travel_mode.lower() == "run":
distance_traveled += 5
print("Distance from home is {}km.".format(distance_traveled))
|
1301993ebfd0261034f98e1c4879c951c9b9cde1 | jessiicacmoore/python-reinforcement-exercises | /python-reinforcement-may29/exercise.py | 1,258 | 4.09375 | 4 | seating_plan = [
[None, "Pumpkin", None, None],
["Socks", None, "Mimi", None],
["Gismo", "Shadow", None, None],
["Smokey", "Toast", "Pacha", "Mau"],
]
def display_available_seats(list):
done = False
for row in range(0, len(seating_plan)):
for seat in range(0, len(seating_plan[row])):
... |
6760a6c8331365ef174c58d2b742b3ffd407807c | jessiicacmoore/python-reinforcement-exercises | /python_fundamentals2/exercise6.py | 218 | 4.25 | 4 | def temperature_converter(f):
c = (f-32)*5/9
print(f"{f} degrees fahrenheit is {c} degrees celsius!")
print("Enter a temperature to convert from fahrenheit to celsius:")
f = int(input())
temperature_converter(f) |
7c931c1909d7acab6c66c0442564868ce7a16220 | vaisharma16/Election-results-analysis | /election.py | 2,656 | 3.84375 | 4 | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import collections
#===== Merging two excel files====
df = pd.DataFrame()
for f in ['2009maharashtraresults.xlsx', '2014maharashtraresults.xlsx']:
data = pd.read_excel(f, 'Sheet1') #this loop merges the two excel sheets into one.
... |
7718621d78568e45518df6f316631a0813785553 | sarojsh21/git_practice | /Pokemon/Pokemon.py | 4,065 | 3.734375 | 4 | class Pokemon:
def __init__(self, name, types, level):
self.name = name
self.level = level
self.health = level * 5
self.max_health = level * 5
self.types = types
self.is_knocked_out = False
def __repr__(self):
return f"Pokemon info: {self.name}, Type: {self.types}, Current Health: {se... |
6a7a1ce0caffe75b660464f58db654ae9e4077d9 | alvinsunyixiao/ece551-fa20 | /hw1/code/HW1.py | 4,899 | 3.734375 | 4 | from numba import njit
import numpy as np
############################################################################
############################################################################
########################## Window Implementations ##########################
##############################################... |
a95f593fa920783f712fb6d050aea7a8b00d40bf | gordiig/Un_Compilers | /4_Lab/main.py | 765 | 3.859375 | 4 | from analyzer import analyze_string
if __name__ == '__main__':
input_str = '1 < 2'
ans = analyze_string(input_str)
print(f'Ans is {ans}, should be: 12<')
input_str = '3 <> 4'
ans = analyze_string(input_str)
print(f'Ans is {ans}, should be: 34<>')
input_str = '1 + 2 < 3 - 4'
ans = an... |
8cde3fb2638487186eb6e10ae02eae10fefc62c5 | wolf43/Matasano-Crypto-Challenges | /set1/hamming_distance.py | 1,898 | 3.609375 | 4 | """This module contains functions dealing with hamming distance for Challange 6."""
from collections import namedtuple
def find_possible_key_size(ciphertext, max_key_len):
"""Find possible key sizes based on hamming distance calulation on ciphertext."""
list_of_possible_keylengths = []
possible_keylen = n... |
dc8f0d0382024352943f4505bfc748126ad4066b | jsonsnow/assoicate | /insert_word_to_db.py | 3,899 | 3.53125 | 4 | # _*_coding:utf-8_*_
import sqlite3
import parse_city
import os
class db_manager(object):
def __init__(self, db_path="input_word.db"):
super().__init__()
self.db_path = db_path
def connect(self):
self.conn = sqlite3.connect(self.db_path)
self.cursor = self.conn.cursor()
... |
6c9aff9343e11d543a778500881cca98e9a715b7 | chantigit/pythonbatch1_june2021data | /Python_9to10_June21Apps/project1/stringapps/ex11.py | 141 | 3.609375 | 4 | s='One apple cost is 60 rupees'
vc=0
for i in s:
if i=='a' or i=='e' or i=='i' or i=='o' or i=='u':
vc=vc+1
print('Vowels=',vc)
|
697d96b51c977df25cba906498bbf4b323df01e3 | chantigit/pythonbatch1_june2021data | /Python_9to10_June21Apps/project1/listapps/ex2.py | 287 | 4.0625 | 4 | #append(),insert() and extend()
myList1=list()
myList1.append(10)
myList1.append(9)
myList1.append(10)
myList1.append(15)
myList1.append(12)
print(myList1)
# [10 9 10 15 12]
# 0 1 2 3 4
myList1.insert(1,100)
print(myList1)
myList2=[11,22,33]
myList1.extend(myList2)
print(myList1) |
1061478953bb2c66a6a8492fdac4b0032f71ec4a | chantigit/pythonbatch1_june2021data | /Python_9to10_June21Apps/project1/functionapps/ex12.py | 601 | 3.578125 | 4 | #Arbitary argument / Variable length arguments
def totalItems(*a):
s=0
for i in a:
s=s+i
print('Total bill is:',s)
totalItems(10)
totalItems(10, 20)
totalItems(10, 20, 30, 40)
totalItems(10, 20, 30, 40, 50, 60, 70, 80, 90)
#can we pass in a different type some are int and some of then double or flo... |
4bc6ee264c0f70ebf585fb222c21d44169f03209 | chantigit/pythonbatch1_june2021data | /Python_9to10_June21Apps/project1/stringapps/ex10.py | 194 | 3.546875 | 4 | s='Python'
s=s+' is'
s=s+' simple'
print(s)
s='Good'
print(s*5)
s='Google'
print(s[0]) #G
print(s[0:2])#Go
print(s[0:4])#Goog
print(s[2:6])#ogle
print(s[1:4])#oog
print(s[4]) #l
print(s[-4]) #o |
04974fc269896c9c0682428962ba14c1b542c530 | chantigit/pythonbatch1_june2021data | /Python_9to10_June21Apps/project1/threadapps/ex1.py | 517 | 3.765625 | 4 | #Single thread in Python
from time import sleep
class Job1:
def task1(self):
for i in range(1,6):
print('Job1.task1() prints i=',(i/0))
sleep(1)
class Job2:
def task2(self):
for i in range(6,11):
print('Job2.task2() prints i=',i)
sleep(1)
class Job... |
32c4cc3778f9713a09d237cdb6024a7ec4fca5f2 | chantigit/pythonbatch1_june2021data | /Python_9to10_June21Apps/project1/dictapps/ex1.py | 534 | 4.25 | 4 | #1.Creating empty dict
a={}
b=dict()
#2.Creating dict with key,value
c={'id':21,'name':'Ajay','height':5.6,'age':21,'name':'Arun'}
print(type(a),type(b),type(c))
print(c)
#3.Accessing dict values based on keys
print(c['id'])
print(c['name'])
print(c['age'])
print(c['height'])
#4.Updating the dict
c['height']=6.9
c['age... |
67b18462ebb6fcdd2c9b1d8aa9148d2c978088d9 | chantigit/pythonbatch1_june2021data | /Python_9to10_June21Apps/project1/setapps/ex2.py | 312 | 3.578125 | 4 | a={}
b={1,}
c=set()
print(type(a))
print(type(b))
print(type(c))
d={100,57,999,88,4.4,56,1,2,3,77,1000,55,3.9}
print(d)
#print(d[0])
#TypeError: 'set' object is not subscriptable
#d[0]=1000
#TypeError: 'set' object does not support item assignment
#del d[5]
#TypeError: 'set' object doesn't support item deletion |
6c7313f1f5f9bd73fb7a2dd984435f0aa0ba02b8 | chantigit/pythonbatch1_june2021data | /Python_9to10_June21Apps/project1/functionapps/ex8.py | 213 | 3.671875 | 4 | #10.Aliasing the function
def one():
print('Hi')
#Calling Function
one()
#Printing Function Name: Return id/address of function(<function one at 0x000001B6773BE040>)
print(one)
two=one
print(two)
two()
one()
|
bcc2045e953975bbdf2d78dc2888346072a0af24 | chantigit/pythonbatch1_june2021data | /Python_9to10_June21Apps/project1/listapps/ex5.py | 407 | 4.3125 | 4 | #II.Reading list elements from console
list1=list()
size=int(input('Enter size of list:'))
for i in range(size):
list1.append(int(input('Enter an element:')))
print('List elements are:',list1)
print('Iterating elements using for loop (index based accessing)')
for i in range(size):
print(list1[i])
print('Iterat... |
e39c8da3f364e13b10b92b8cd6c05a65e2111281 | chantigit/pythonbatch1_june2021data | /Python_9to10_June21Apps/project1/controlstatements/ex2.py | 129 | 4.15625 | 4 | n=int(input('Enter a number:'))
if n>0 :
print('You entered positive number')
else :
print('You entered negative number') |
408c56fda4318417beacfd2fb1f90d383915222f | anhbkpro/common-sense-dsa | /dynamic-programming/add_until_100.py | 275 | 3.71875 | 4 | def add_until_100(array):
if len(array) == 0:
return 0
remaining_sum = add_until_100(array[1:])
if array[0] + remaining_sum > 100:
return remaining_sum
else:
return array[0] + remaining_sum
print(add_until_100([30, 20, 60, 10, 50]))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.