blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
99dff7e2714dc096b6440f9dbf64ff56e90e5dcb | amymiao/connect-five | /connect_5.py | 5,136 | 3.734375 | 4 | '''
AI Project: Connect 5
Rules:
The game board will be a square board of length n where n is greater than or equal to 5
User will always start
'''
from alphaBeta import *
class Connect5():
game_board = []
game_board_size = 0
def __init__(self, game_board_size):
self.game_board_size = game_b... |
e863c8733f2791b9ebef94ac012e63dc1835fa32 | bhandarijyoti12/mspworkshop | /first.py | 440 | 3.59375 | 4 | cars = 100
space_in_a_car = 4.0
drivers = 30
passengers = 90
cars_nit_driven = cars-drivers
cars_driven = drivers
carpool_capacity = cars_driven * space_in_a_car
average_passenger_per_car = passengers / cars_driven
newstring="There are "+ str(cars) + "cars available"
print(newstring)
print("tHere are",cars,"cars avail... |
d8b5dbbbf996c1a2e2e8d7b140ccaaea629d11fc | yang953/PortTest | /ceses/list_7.py | 796 | 3.84375 | 4 | import re
def choice_email():
while 1:
email = input(r"请输入邮箱地址:")
if email=="Q" or email=="q":
# break
exit()
elif re.match(r"^(\w+)*@(\w+)+(\.com)$",email):
user_name = re.findall("(\w+)*@",email)[0]
company_name = re.findall("@(\w+).com$",em... |
62868a72b9a2fbbad9f859d4a6d470b6433289ab | yang953/PortTest | /ceses/list_8.py | 1,472 | 3.65625 | 4 | # nums = [1,2,7,8,12,14,9,9,10,3,9]
#
# b = [(index,value) for index,value in enumerate(nums)]
#
# print(b[0][1])
# list_num = []
# list_num.append(index)
# list_num.append(value)
# b = b+list_num
# print(list_num)
# print(b)
def towSum(nums,target):
index_list = []
for i in range(len(nu... |
3c0e80f8911b9a3ec8b1e9bbabe9bc08496bb69f | Zane-ThummBorst/Python-code | /Lab6.py | 2,276 | 4.0625 | 4 | #Zane ThummBorst
#I Pledge My Honor That I Have Abided By The Stevens Honor System.
def decimalToBinary(num):
'''converts from a decimal to binary'''
if num >= 1:
'''return creates list of the binary value, and recursivly calls the function'''
return [num%2]+decimalToBinary(num//2)
else:
... |
0260224543d1b2f8b51e3cbf22530d176fa1a684 | Zane-ThummBorst/Python-code | /Factorial code.py | 1,117 | 4.21875 | 4 | #
# Zane ThummBorst
#
#9/9/19
#
# demonstrate recursiuon through the factorial
# and list length
def myFactorial(x):
''' return the factorial of x assuming x is > 0'''
# if x == 0:
# return 1
# else:
# return x * myFactorial(x-1)
return 1 if x==0 else x*myFactorial(x-1)
#print(myFactorial(... |
6fd632f6903956d8217bd7215c6f3ddf0488ebff | jrottersman/comscore | /query.py | 2,555 | 3.609375 | 4 | #!/usr/bin/python
import json
import os
import argparse
from collections import defaultdict
from pprint import pprint
from operator import itemgetter
def get_args():
'''This functions parses and returns arguments passed in'''
parser = argparse.ArgumentParser(
description='A simple script for run... |
5112eeb9466b39995ead01021eb3f07198fa5231 | RafaelRampineli/DataQuest.IO | /Extra_Codes/Min_max_Method_Class.py | 4,071 | 4.21875 | 4 | """
Add two helper methods, SuperList._calc_min() and SuperList._calc_max(), which implement the logic from the functions in the code example above.
They should assign the minimum and maximum values to the attributes SuperList.min and SuperList.max respectively.
Add a SuperList._update() helper method which calls the t... |
fa9700d04ae2e9ad468953bceba94d50f2ae9c92 | SwatiShirke/Robotics- | /Finding Polygon Area/polygon_area.py | 1,145 | 3.5 | 4 | ####finding area of convex polygon###
import math
import curio
import Tri_area
poly_verts=[(5.1,-1.64),
(11.7,-0.22),
(13.82,2),
(12.52,3.56),
(10.12,5.22),
(7.48,4.64),
(4.14,3.48)]
c=len(poly_verts)
d=c-2
poly_area=0
k=1
for j i... |
d079ff04de3ddafd38fd6d4784e381e97b76a4e8 | ravi4all/Python_FebWE_19 | /02-WhileLoop.py | 199 | 3.78125 | 4 | a = 0
while a < 10:
print(a)
#a = a + 1
a += 1
'''
game = True
while game:
print("Game is running...")
'''
game = False
while not game:
print("Game is running...")
|
3fe977f0aecd1914f3378885d3e239659513f72f | ravi4all/Python_FebWE_19 | /01-LoopsIntro.py | 412 | 4 | 4 | '''
range(5) - start = 0, stop = 5, step = 1
range(5,25) - start = 5, stop = 25, step = 1
range(5,25,5) - start = 5, stop = 25, step = 5
'''
for i in range(2,11):
print(i,"->",i**2)
print("--------")
print("Loop Exit")
print("Where am I..??")
for i in range(2,21,2):
print(i)
#Reverse Loop
... |
a96dfcdbcde546e5d026ae9e9d80f105aab36c8c | seprab/PythonMiniGame | /Clases/Entidades.py | 2,301 | 3.6875 | 4 | import random
import math
from typing import List
from Clases.Ataque import Ataque
from Clases.TextStyle import *
class Entidad:
nombre: str
vida: float
defensa_fisica: float
defensa_magica: float
ataque_fisica: float
ataque_magica: float
ataques: List[Ataque]
def __init__(self, _nomb... |
6370d8386f0362ad5a46c5cf7cad87471fbad713 | vishalcv98/mini_project_sql-python | /main.py | 447 | 3.671875 | 4 | import sqlite3
import bcrypt
conn = sqlite3.connect('info.db')
c = conn.cursor()
#c.execute("""CREATE TABLE info (
#Name text, password text)""")
i = input("Name and Password separeated by comma ")
l = i.split(',')
l[1]=bytes(l[1], 'utf-8')
l[1]=bcrypt.hashpw(l[1],bcrypt.gensalt())
print(l)
t = tupl... |
58cdadc4d72f1a81b55e16f0a4067b44ae937f37 | rcolistete/Plots_MicroPython_Microbit | /plot_bars.py | 609 | 4.125 | 4 | # Show up to 5 vertical bars from left to right using the components of a vector (list or tuple)
# Each vertical bar starts from bottom of display
# Each component of the vector should be >= 0, pixelscale is the value of each pixel with 1 as default value.
# E. g., vector = (1,2,3,4,5) will show 5 verticals bars, with ... |
2f96c36c3d3a38325a8a693cb72604d240734510 | CrazyLine/TicTacToe | /TicTacToeState.py | 4,281 | 3.625 | 4 | #class that implements a state and the playing logic of the TicTacToe game.
import Square
from TicTacToeAction import TicTacToeAction
class TicTacToeState:
# Updates the utility value.
def updateUtility(self):
if ((self.field[0]==self.field[1] and self.field[1]==self.field[2] and self.field[0]... |
cce47b1d66710f8bff8367d12d86457534b07593 | Jlewis24/TOC_HW4 | /TocHw4.py | 2,385 | 3.6875 | 4 | #encoding: utf-8
#coding: utf-8
# Theory of Computation - Homework 4 -
# Name: 魏喬浩
# Student ID: F74007125
# Compilation: python2 TocHw4.py <URL>
# Description: This program takes a JSON file, scans it and prints the address (being it road, street, etc.) with more
# records and prints that street name, and its highe... |
0ce0d353379f73bbe2baebf5154de87ea21a73c7 | Marigold/math_in_python | /JendasWork/4_task/polygon.py | 1,753 | 3.65625 | 4 | #!/usr/bin/env python
import sys
sys.path.append("../3_task")
import numpy as np
from Turtle import Turtle
from math import pi
class Polygon():
def __init__(self, vertices):
self.n = len(vertices)
self.vert = [ np.array(vortex) for vortex in vertices]
self.edges = [ self.vert[(i... |
2f7d2c56083199fd50016c93be63bb8071ca756a | cxl99-start/tests | /基础/onetest.py | 76,635 | 3.8125 | 4 | # -*- coding: utf-8 -*-
# region 循环、循环练习
a=[1,'1233',0.2]#列表 list
b=(1,'1233',0.2)#元组 tupe
c={'name':'Tom','Age':'21'}#字典 dict
d={'happy','bed','age','Tom'}#集合
print(type(a))#type(变量)输出变量类型,在python中不用申明变量类型,系统会自动分配
print(type(b))
print(type(c))
print(type(d))
#斐波纳契数列
a,b=0,1#给变量赋值
i=0#控制循环次数
while i<20:
print(... |
961292fcb10463bdbdaf4eaf44ab3f41ee08d0ad | dcampos/exercism-solutions | /python/isogram/isogram.py | 161 | 3.84375 | 4 | def is_isogram(string):
return len(''.join(c for c in set(sorted(string.lower())) \
if c.isalpha())) == len(string.replace('-', '').replace(' ', '')) |
1590e035fbe29ba5edcbc0295fcd61d33b668bb5 | Shoter99/Projects | /PythonProjects/Fractals/fractals.py | 652 | 3.65625 | 4 | import turtle as t
import random as rand
t.hideturtle()
t.screensize(640, 480)
posx = 1
posy = 1
p1 = 0.3333
p2 = 0.6666
p3 = 1
for i in range(0, 100):
t.penup()
t.setpos(posx, posy)
t.pendown()
t.dot()
los = rand.random()
print(los)
if los < p1:
posx = ((posx*0.5)-0.5)*100
... |
3ac03378314f2165ae139bcfe7b55653ebdd8514 | rdednl/hackerrank | /Cracking the Coding Interview/Data Structures/Trees - Is This a Binary Search Tree?/solution.py | 463 | 3.71875 | 4 | """ Node is defined as
class node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
"""
def check(root, min, max):
if root is None:
return True
if root.data < max and root.data > min:
return (check(root.right, root.data, max) and check(ro... |
baff3b2c9413f52397149276285accf8f7cf5ec7 | rdednl/hackerrank | /Cracking the Coding Interview/Algorithms/Sorting - Bubble Sort/solution.py | 505 | 3.828125 | 4 | def bubble_sort(a):
totSwaps = 0
for i in range(len(a)):
tmpSwaps = 0
for j in range(len(a)-1):
if a[j] > a[j + 1]:
a[j + 1], a[j] = a[j], a[j + 1]
tmpSwaps+=1
if tmpSwaps == 0:
return a, totSwaps
totSwaps += tmpSwaps
n = i... |
babbcffce847202f6ec00d8769512babbcc8ef2e | miggoo/wk3_pyBank | /main.py | 1,780 | 3.921875 | 4 | #import os and csv tools
import os
import csv
#set data file path
tradeCSV = os.path.join('budget_data.csv')
#open data file in location below, read it, store data as csvfile
with open(tradeCSV, "r") as csvfile:
# make a list to store values
c1 = []
total = 0
months = 0
# Split the ... |
dc5a055097f7162f6204cbcbc66ec96eed827db4 | DangGumball/DangGumball | /Homework/BMI.py | 408 | 4.21875 | 4 | height_cm = int(input('Enter your height here (cm): '))
weight = int(input('Enter your weight here (kg): '))
height_m = height_cm / 100
BMI = weight / (height_m * height_m)
print(BMI)
if BMI < 16:
print('Severely underweight')
elif 16 <= BMI <= 18.5:
print('Underweight')
elif 18.5 <= BMI <= 25:
pr... |
be0ee7f5c59c864fbad5c7f7b2c00b7425ac38e3 | DangGumball/DangGumball | /Homework/turtle_2.py | 167 | 3.96875 | 4 | import turtle
turtle.fillcolor('yellow')
turtle.begin_fill()
for i in range(3):
turtle.forward(200)
turtle.left(120)
turtle.end_fill()
turtle.mainloop() |
7ced1bc2c5f4ee170bd34d0b4235d345f5435621 | DangGumball/DangGumball | /Homework/Sesson3/word.py | 523 | 3.59375 | 4 | from math import e
import random
champion = ['c','h','a','m','p','i','o','n']
random.shuffle(champion)
meticulous = ['m','e','t','i','c','u','l','o','u','s']
random.shuffle(meticulous)
hexagon = ['h','e','x','a','g','o','n']
random.shuffle(hexagon)
word = [champion, meticulous, hexagon]
print(random.choice(wor... |
d8301e71e2d210a4303273f2f875514bd4a6aff0 | mansi05041/Computer_system_architecture | /decimal_to_any_radix.py | 910 | 4.15625 | 4 | #function of converting 10 to any radix
def decimal_convert_radix(num,b):
temp=[]
while (num!=0):
rem=num%b
num=num//b
temp.append(rem)
result=temp[::-1]
return result
def main():
num=int(input("Enter the decimal number:"))
radix=int(input("enter the base to be... |
8bdff3cf295eb2de1fd258fdd249c345fb458464 | ruoshui-git/MIT6.0002 | /snippets/powerSet.py | 233 | 3.921875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Feb 24 08:20:43 2019
@author: ruosh
"""
from itertools import combinations, chain
def powerSet(items):
return chain.from_iterable(combinations(items, s) for s in range(len(items) + 1))
|
cbcb6dd90f7323c3c493b987e45e871377d6bf15 | thomas-li-sjtu/Sword_Point_Offer | /JZ48_Add without plus/solution.py | 494 | 3.90625 | 4 | # -*- coding:utf-8 -*-
class Solution:
def Add(self, num1, num2):
# write code here
result = 0
carry = 0
while True: # 无限循环...
result = (num1 ^ num2) & 0xffffffff # 相加
num2 = num2 & 0xffffffff
carry = (num1 & num2) << 1 # 进位
num1, nu... |
3a602031788791ffbc692fb3039842836005116c | thomas-li-sjtu/Sword_Point_Offer | /JZ27_Permutation/solution.py | 963 | 3.53125 | 4 | # -*- coding:utf-8 -*-
class Solution:
def Permutation(self, ss):
# write code here
def join(str, char):
arr = []
for i in range(len(str), -1, -1):
arr.append(str[:i] + char + str[i:])
return arr
if len(ss) < 2: # 特殊情况
return ... |
0e61680e85e8ca29045c5497e50e9a229e6dc880 | thomas-li-sjtu/Sword_Point_Offer | /JZ45_Is continuous/solution.py | 517 | 3.828125 | 4 | # -*- coding:utf-8 -*-
class Solution:
def IsContinuous(self, numbers: list):
# write code here
kings = numbers.count(0)
numbers = [i for i in sorted(numbers) if i != 0]
sub = [numbers[i + 1] - numbers[i] - 1 for i in range(len(numbers) - 1)]
if len(numbers) == 0: # special ... |
bc34a85811e1d000b642fbe84b71449fde4002a0 | Vutsuak16/LeetCode | /algorithm-solution/removeElement.py | 378 | 3.59375 | 4 | def removeElement(nums, val):
i=0
while 1>0:
if val not in nums:
break
if nums[i]==val:
del(nums[i])
continue
i+=1
return len(nums)
# use while loo... |
80b943fcbc48976109e6441524c23e58f3674cee | Vutsuak16/LeetCode | /algorithm-solution/even_odd_linked_list.py | 746 | 3.671875 | 4 | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def oddEvenList(self, head):
if head == None:
return head
odd=head
even=head.next
evenFirst=even... |
2f3d6651862dc0941316d99d777ed23f00757e4a | Vutsuak16/LeetCode | /algorithm-solution/two-sum.py | 511 | 3.8125 | 4 | '''
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice. '''
def twoSum(self, nums, target):
l=[]
for i in nums:
for j ... |
864a48b50b84b72e3517402937bcf15adf616a7f | Vutsuak16/LeetCode | /algorithm-solution/sqrtInt.py | 642 | 3.984375 | 4 |
#thing I learnt : INTEGERS HAVE BINARY SEARCH PROPERTY AS THEY ARE SORTED
def mySqrt(x):
if x==0: return 0
if x==1: return 1
start=1
end=x
ans=""
while(start<=end):
mid=(start+end) / 2
if m... |
c1cb6e28d9308d50606afee9df5792b16d05e449 | iriskarling/Extreme-Computing | /task8/mapperb.py | 328 | 3.515625 | 4 | #!/usr/bin/env python2
# mapperb.py
import sys
for line in sys.stdin:
year,rating= line.strip().split('\t')
if int(year)< 2010 and int(year) >= 1900:
t = (int(year)-1900)/10
t = 1900 + t*10 # preprocess the year into the format of decade
print(str(t)+'\t'+str(rating)) # decade /averag... |
1fd17cffac8fbea4c28e2a7013342c9260d9ae92 | vacuesta/Algorithmic-Implementations | /rollback_knapsack.py | 4,402 | 3.796875 | 4 |
"""
Created on Mon Nov 4 20:46:40 2019
@author: vincentacuesta
"""
'''
pseudocode:
my input will involve the same file and max weight. This wil be similar to the integer knapsack problem
that i wrote but instead of stopping there, the problem is going to lookback and change what it can to
maximize the ... |
a5a319c7250848e03168a7a13e62bc0edbfd738a | vacuesta/Algorithmic-Implementations | /frac_knapsack.py | 4,360 | 3.828125 | 4 |
"""
Created on Sun Nov 3 18:29:28 2019
@author: vincentacuesta
"""
'''
pseudocode:
the parameters entered will follow the file name that will be in the working directory along with the maximum
weight for the bag. The idea of this function is to optimize the objects that have the best worth into the
bag ... |
142be792253a6c02bf76999cf9095cdf3a64011f | Environmental-Informatics/python-learning-the-basics-msuherma | /Exercise_3.3_resub.py | 1,705 | 4.0625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Jan 21 11:39:57 2020
@author: msuherma@purdue.edu
"""
# Exercise 3.3
# PART 2 ~ Making 4x4 grid
plus_row = '+' + ' ' + 4 * ('-' + ' ') # to make + started row
vert_row = '|' + 9 * ' ' # to make | started row
def fcn_2x(f): # to define a function that... |
f919ddce92e76f06f3dabef6f3d0a54a54515ed9 | AntonisPav90/Python-projects | /multiassignment.py | 117 | 3.75 | 4 | x = 10
print ("x = " + str(10))
x = 20
print ("x = " + str(20))
x = 30
print ("x = " + str(30))
print ("x =",x) |
e253e1a3bd78e3a24e462286c6a4fe70418384b6 | chiaradiaz1991/Python | /Guide1/exercise_5.py | 232 | 4.03125 | 4 |
print("Please enter 2 numbers:")
number1 = int(input(" enter first number: "))
number2 = int(input("enter second number: "))
sum = number1 + number2
res = number1 - number2
div = number1 / number2
print(sum)
print(res)
print(div) |
2289be200aa60deacb93abfd87e812bc55befa3e | chiaradiaz1991/Python | /Guide2/exercise_1.py | 341 | 3.75 | 4 |
userVariable = ""
userMessage = input(f"insert text: {userVariable}")
userMessageLength = len(userMessage)
print(userMessageLength)
print(userMessage)
if userMessageLength > 100:
print(userMessage)
if userMessageLength > 50 and userMessageLength < 100:
print(userMessage[::-1])
else:
print("Su mensaje e... |
5b8878d21f4d609facf74ca55f6151eaa34d617e | mikaelfun/Leetcode | /18. 4Sum.py | 3,920 | 3.828125 | 4 | '''
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.
Note: The solution set must not contain duplicate quadruplets.
For example, given array S = [1, 0, -1, 0, -2, 2], and target = 0.
... |
ee59d0184e7bf0bb95ea2b01beca605ffe3b472d | mikaelfun/Leetcode | /DP_programming/The Coin Change Problem.py | 1,677 | 3.59375 | 4 | '''
ou are working at the cash counter at a fun-fair, and you have different types of coins available to you in infinite quantities.
The value of each coin is already given.
Can you determine the number of ways of making change for a particular number of units using the given types of coins?
For example, if you have 4... |
77d87a17ebfca2a0c95849a1d7172aa5bbcc54c6 | mikaelfun/Leetcode | /DP_programming/Coin on the Table.py | 2,626 | 4.09375 | 4 | '''
You have a rectangular board consisting of N rows, numbered from 1 to N, and M columns, numbered from 1 to M.
The top left is 1,1 and the bottom right is N,M. Initially - at time - there is a coin on the top-left cell of your board.
Each cell of your board contains one of these letters: URDL*
When the coin reaches... |
d3e7aa0f86ac729b44ad917455a17d0fe96609ce | mikaelfun/Leetcode | /DP_programming/The Longest Common Subsequence.py | 1,690 | 4.03125 | 4 | '''
Input Format
The first line contains two space separated integers and , the sizes of sequences and .
The next line contains space-separated integers .
The next line contains space-separated integers .
Constraints
Constraints
Output Format
Print the longest common subsequence as a series of space-sepa... |
6fe869efff8868028b8076d48f03dff41cc33e73 | Ewest19/MTH354_final_project | /prims_algorithm.py | 4,158 | 3.859375 | 4 | class MinimalSpanningTree:
def __init__(self, edge_list, vertex_count, initial_vertex):
self._edge_list = edge_list # Creating a variable for the initial set of edges
self._vertex_count = vertex_count # Creating a variable for the amount of vertices
self._initia... |
36c35f84ab388c512f527486adf0d2b919d12fff | zengwenhai/interface_test2019 | /utils/rundecorator.py | 1,225 | 3.59375 | 4 | from functools import wraps
# def deco(a):
# def decorator_name(f):
# @wraps(f)
# def inner(*args, **kwargs):
# if a == 'yes':
# f(*args, **kwargs)
# return inner
# return decorator_name
#
#
# @deco('yes')
# def a():
# print("123")
#
#
# a()
def run_test... |
2f178e328976d7df02a22b90d6b3f371e4405c5c | w0r1dhe110/PLR | /util.py | 769 | 3.578125 | 4 | END = '\n'
clean = lambda X: [x.decode().split(END)[0] for x in X]
def readP(path, encoding='iso-8859-1', n=0):
""" read txt passwords file (\n sep) """
with open(path, encoding=encoding) as f:
raw = [x.strip() for x in f if x]
if n:
raw = [x for x in raw if len(x) <= n]
return ... |
59278e737463c49f77ec9c94d2bd584b58ba77e1 | jayhebe/Exercises | /Github_Exercises/100+ Python challenging programming/Q38.py | 182 | 3.9375 | 4 | def printtuple(mytuple):
num = len(mytuple)
print(mytuple[:(num // 2)])
print(mytuple[(num // 2):])
t = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
printtuple(t) |
0fe42e240d6efe5b00f978dd9a8fe1272c7699b2 | jayhebe/Exercises | /Automate_Exercises/Chapter7/exercise7181.py | 371 | 3.828125 | 4 | import re
def pwd_detection(password):
if len(password) < 8:
return False
pwd_pattern = r"[A-Z]+[a-z]+[0-9]+"
result = re.search(pwd_pattern, password)
if result != None:
return True
else:
return False
password = "Start1234"
if pwd_detection(passwor... |
41cc27bf002e98ab71d14489bcebb29107f32209 | jayhebe/Exercises | /Automate_Exercises/Chapter9/backup_to_zip.py | 957 | 3.765625 | 4 | import zipfile, os
def backup_to_zip(folder):
folder = os.path.abspath(folder)
number = 1
while True:
zip_file_name = os.path.basename(folder) + "_" + str(number) + ".zip"
if not os.path.exists(zip_file_name):
break
number = number + 1
... |
b0609bfdda1727f6ba48b0a0d6568ac530b32d28 | jayhebe/Exercises | /Github_Exercises/100+ Python challenging programming/Q28L1.py | 201 | 4.03125 | 4 | def maxstr(str1, str2):
if len(str1) > len(str2):
print(str1)
elif len(str1) < len(str2):
print(str2)
else:
print(str1, str2)
maxstr("word", "shit") |
f35e846d8467e4be8995f204f3b62fa136dc3fd1 | tunstallzs/GIS540 | /MPHzip.py | 1,531 | 3.640625 | 4 | """
Zach Tunstall
zstunsta
MPHzip.py
"""
# input lists
dList = [0.04, 0.05, 0.91, 0.16, 18]
timeList = ['7m:13s', '11m:29s', '16m:48s', '3m:26s', '120m:0s']
# empty lists for seconds, velocity and hours
secList = [ ]
avgList = [ ]
hrList = [ ]
# split time fromat into seconds & print to empty list
for minu... |
b0d79fa56cab2372d046110fdc4f4d290fa56b66 | tunstallzs/GIS540 | /ski.py | 313 | 3.5 | 4 | """
Author: Zach Tunstall
University ID: zstunsta
"""
import sys
#get user age from argument
age = int(sys.argv[1])
x = age
if x <= 6:
print '$30'
elif x > 6 and x < 19:
print '$319'
elif x >= 19 and x < 30:
print '$429'
elif x >= 30:
print '$549'
else:
print 'Invalid Input' |
0ab529b2a31d67bd2867418aa9ce326ca3d900a0 | tunstallzs/GIS540 | /outline.py | 276 | 4.09375 | 4 | """
Zach Tunstall
zstunsta
outline.py
Using a nested for loop to print an arbitrary string and iterate through a list
"""
list = ['a', 'b', 'c']
for r in range(1, 5):
print str(r) + ') ' + 'hehe'
for thing in list:
print ' ' + thing + ') ' + 'hoho'
|
7f5967b7d04aab4e55fef2dceffafa9a332a0adc | klmansel/Code-Like-A-Pro-Junior-Edition | /Student_Files/Student Work/Blake/BlakeGamefortheCrazy.py | 1,008 | 4.03125 | 4 | import time
# welcome the User
name = input("What is your name?")
print("Welcome to your end if you fail " + name + "!")
#wait 1 second
time.sleep(1)
print("Start guessing...")
time.sleep(0.5)
# Set the secret word
word = "death"
# Create a variable with an empty value
guesses = ''
#turn
turns = 10
# Game loop... |
537bb9273cb89ddc6b50c9543178c42e45894d8f | jackersson/gst-filter | /gst_filter/cv_utils.py | 730 | 3.5625 | 4 | import cv2
def grayscale(img):
"""
Convert colored image to Grayscale
:param img: [height, width, channels >= 3]
:type img: np.ndarray
:rtype: np.ndarray
"""
return cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
def gaussian_blur(img, kernel_size=3, sigma=(1, 1)):
"""
... |
c82cbe4aa0027dcb6e841d3192fe96b3bd7dde5a | 1102jhc/pythonPractice | /fileIO.py | 1,991 | 3.5625 | 4 | # # score_file = open("score.txt", "w", encoding="utf8")
# # print("수학 : 0", file=score_file)
# # print("영어 : 50", file=score_file)
# # score_file.close()
# score_file = open("score.txt", "a", encoding="utf8")
# score_file.write("과학 : 80")
# score_file.write("\n코딩 : 100")
# score_file.close()
# score_file =... |
626bcc43bb3da3c4477a09a277351e628244f14c | 1102jhc/pythonPractice | /my_class.py | 11,939 | 3.546875 | 4 | # # 마린 : 공격 유닛, 군인, 총 사용
# name = "마린" # 유닛의 이름
# hp = 40 # 유닛의 체력
# damage = 5 #유닛의 공격력
# print("{0} 유닛이 생성되었습니다.".format(name))
# print("체력 {0}, 공격력 {1}\n".format(hp, damage))
# # 탱크 : 공격 유닛, 탱크, 포 사용, 일반모드 / 시즈모드
# tank_name = "탱크"
# tank_hp = 150
# tank_damage = 35
# print("{0} 유닛이 생성되었습니다.".for... |
0061d5a0d2ad7ac47a9c1d6043770307fe39f986 | kiko1004/Portfolio-Construction | /data/Functions.py | 6,304 | 3.546875 | 4 | import pandas as pd
def drawdown(return_series: pd.Series):
"""Takes a time series of asset returns.
returns a DataFrame with columns for
the wealth index,
the previous peaks, and
the percentage drawdown
"""
wealth_index = 1000*(1+return_series).cumprod()
previous_peaks = ... |
0a6ce06157bd0fb4e30e2c98a8327f5b98f14682 | zija1504/100daysofCode | /5.0 rock paper scissors/game.py | 2,843 | 4.3125 | 4 | #!/usr/bin/python3
# Text Game rock, paper, scissors to understand classes
import random
class Player:
"""name of player"""
def __init__(self, name):
self.name = name
self.pkts = 0
def player_battle(self, pkt):
self.pkts += pkt
class Roll:
"""rolls in game"""
def __ini... |
0fb2c856f79d547b94ac429386c730ecc9aa77b0 | Saurabh4626/dsa | /graph/get_path[using DFS].py | 1,182 | 3.53125 | 4 | class Graph:
def __init__(self,nVertices):
self.nVertices=nVertices
self.adjMatrix=[[0 for i in range(self.nVertices)]
for j in range(self.nVertices)]
def addEdge(self,v1,v2):
self.adjMatrix[v1][v2] = 1
self.adjMatrix[v2][v1] = 1
def __get_pa... |
42b51002591a076b78c615e02a148df95c565179 | Saurabh4626/dsa | /two_dimensional_list/word_search.py | 830 | 3.828125 | 4 | def search_helper(index,i,j,board,word):
if index==len(word):
return True
if i<len(board) and j<len(board[0]) and word[index]==board[i][j]:
curr=board[i][j]
board[i][j]=None
if search_helper(index+1,i+1,j,board,word)\
or search_helper(index+1,i-1,j,board,wo... |
5b9bd8fb194e94eb53f504af960ed05dfb2d63d1 | Saurabh4626/dsa | /graph/BFS[for all types of graph].py | 1,125 | 3.703125 | 4 | import queue
class Graph:
def __init__(self,nVertices):
self.nVertices=nVertices
self.adjMatrix=[[0 for i in range(self.nVertices)]
for j in range(self.nVertices)]
def addEdge(self,v1,v2):
self.adjMatrix[v1][v2] = 1
self.adjMatrix[v2][v1] = 1
... |
1c7a3a308cd94c2af9a6e06c06856997f1d89947 | Saurabh4626/dsa | /trees/inorder_traversal.py | 518 | 3.71875 | 4 | class BinaryTreeNode:
def __init__(self,data):
self.data=data
self.left=None
self.right=None
def InOrder(root):
if root is None:
return
InOrder(root.left)
print(root.data)
InOrder(root.right)
bt1=BinaryTreeNode(1)
bt2=BinaryTreeNode(2)
bt3=BinaryTreeNod... |
d2bec2178d2f8ca5e9a93547812477e72c680a9e | Saurabh4626/dsa | /linklist/mid_element_of_linklist.py | 1,081 | 3.6875 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
def printLL(head):
while head is not None:
print(str(head.data),end="--->")
head = head.next
print("None")
def takeInput():
inputList = [int(ele) for ele in input().split()]
head = None... |
66bc2558ffa0a9eee1a2293459a0f067bc09c199 | Saurabh4626/dsa | /linklist/merge_two_sorted_LL.py | 1,980 | 4 | 4 | ##time complexity of previous code was O(n*n)
##complexity of this code is O(n)
class Node:
def __init__(self, data):
self.data = data
self.next = None
def printLL(head):
while head is not None:
print(str(head.data),end="--->")
head = head.next
print("None")
def ta... |
b563c8137041b192e806fe263660d4b6cda72cd5 | Saurabh4626/dsa | /linklist/linklistinputoptimised.py | 669 | 3.765625 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
def printLL(head):
while head is not None:
print(str(head.data) + "-->", end="")
head = head.next
print("None")
def takeInput():
inputList = [int(ele) for ele in input().split()]
head... |
354abed7781c5806cf652eab97343f83cdd1aabb | Saurabh4626/dsa | /Classes_and_Object/class_variable.py | 420 | 3.796875 | 4 | class Student:
div="TE5"
def __init__(self,name,roll):
self.name=name
self.roll=roll
def print(self):
print(self.name)
print(self.roll)
s1=Student('saurabh',69)
print(s1.__dict__)
print(Student.div)
print(s1.div)
# {'name': 'saurabh', 'roll': 69}
# dict w... |
b65294555c557ac74d6c32f78a5739c40d4b6238 | hiteshkrypton/Python-Programs | /gsoc.py | 722 | 3.640625 | 4 | '''
Created By Shouvik Dutta.
This Question was asked in Google Summer Online Coding Challenge.
A number n is given to you and you have to divide the nuber in two numbers say x,y.
Such that:
x+y=n
and x,y does not contain digit 7.
You have to answer for T different test cases.
cnostraint:
1<=n<=10... |
f524472f1125b5d55bd1af74de6c5e0ba81c9f54 | hiteshkrypton/Python-Programs | /sakshi1.py | 310 | 4.25 | 4 |
def factorial(n):
if n == 1:
return n
else:
return n * factorial(n - 1)
n = int(input("Enter a Number: "))
if n < 0:
print("Factorial cannot be found for negative numbers")
elif n == 0:
print("Factorial of 0 is 1")
else:
print("Factorial of", n, "is: ", factorial(n))
|
6ead110f2934fb8234d3df1da0e06cae9a33640d | hiteshkrypton/Python-Programs | /sort.py | 576 | 4.03125 | 4 | #Subscribed by code house
# Python program to demonstrate sorting by user's
# choice
# function to return the second element of the
# two elements passed as the parameter
def sortSecond(val):
return val[1]
# list1 to demonstrate the use of sorting
# using using second key
list1 = [(1, 2), (3, ... |
837866bafec008c4e3ee90c5f0636eb292b39406 | hiteshkrypton/Python-Programs | /remove_duplicate_characters .py | 320 | 3.5625 | 4 | # https://www.facebook.com/zawed.akhtar.7923/posts/965501223932927
# Subscribed by MySirG.com
def fix(string):
s = set()
list = []
for ch in string:
if ch not in s:
s.add(ch)
list.append(ch)
return ''.join(list)
string=input("Enter string:")
print(fix(string))
|
c7cbcf16c864e660c8792219bd81800ff525fe41 | hiteshkrypton/Python-Programs | /string.py | 193 | 4.125 | 4 | # Python program to Print Characters in a String
str1 = input("Please Enter your Own String : ")
for i in range(len(str1)):
print("The Character at %d Index Position = %c" %(i, str1[i]))
|
21ed28249405b22bc2a8eed55b495f81efdeda88 | hiteshkrypton/Python-Programs | /Dice_rolling_simulator.py | 682 | 4.03125 | 4 | #https://www.facebook.com/100051921408118/posts/190716086002437/?app=fbl
#Subscribed by CodeHouse
import random
import time
print("----------Welcome to 'Roll the dice'-----------")
dice=input("Do you want to roll the dice?(y/n)\n")
if dice=="y":
while dice=="y":
num=random.randint(1,6)
print("Dice is rollin... |
afdd3e2934d150e7f45f432aa664d1a58c7ab456 | hiteshkrypton/Python-Programs | /return-series-sum.py | 513 | 4.03125 | 4 | #CODE 2
# Returns sum of n + nn + nnn + .... (m times)
def Series(n):
# Converting the number to string
str_n = str(n)
# Initializing result as number and string
sums = n
sum_str = str(n)
# Adding remaining terms
for i in range(1, n):
# Concatenating the string making n, nn, nnn... |
a906a6093594811a719d8113acd7c7ddcb1897fe | hiteshkrypton/Python-Programs | /dice_game.py | 1,665 | 4.1875 | 4 | #Dice game
#Made by satyam
import random
import time
import sys
while True :
def start():
sum = 0
counter = 0
verification = 'y'
while counter < 3 and verification == 'y' :
dice_number = random.randint(1, 6)
print('Computer is rolling a dice ',end ='')
... |
eb1418dc803a3bd7953758054c74ecdea53b8873 | hiteshkrypton/Python-Programs | /positivenumber.py | 137 | 4.09375 | 4 | num=int(input('enter number'))
if num >0:
print('positive no')
elif num ==0:
print('positive no')
else:
print('negative no')
|
2b7ed66f4971cc45d12a3e9685b700aae336f8ce | hiteshkrypton/Python-Programs | /Adventure_game.py | 1,546 | 3.9375 | 4 | #https://www.facebook.com/100051921408118/posts/190716086002437/?app=fbl
#Subscribed by CodeHouse
print("--------Welcome to this adventure game-------")
name = input("What is your name? ")
age = int(input("What is your age? \n"))
if age>=18:
print("You are old enough to play this game :)\n\n")
choice1=input("... |
a8208d7d0d616979a5b0e40ae918bca80e5ae460 | ZCKaufman/python_programming | /squareRoot.py | 559 | 4.28125 | 4 | import math
class SquareRoot():
def sqrt(self, num) -> float:
x0 = (1/2)*(num + 1.0)
i = 0
while(i <= 5):
x0 = (1/2)*(x0 + (num/x0))
i += 1
return x0
obj = SquareRoot()
obj.sqrt(4)
obj.sqrt(10)
obj.sqrt(8)
obj.sqrt(6)
if __name__ == '__main__':
obj = Squ... |
0bba954e9e69310f6a60a8fbda331084578f5bb9 | thwaiteso/MIT-6.0001 | /ps4/ps4c.py | 10,253 | 3.78125 | 4 |
from ps4a import get_permutations
### HELPER CODE ###
def load_words(file_name):
'''
file_name (string): the name of the file containing
the list of words to load
Returns: a list of valid words. Words are strings of lowercase letters.
Depending on the size of the word list, this fun... |
0c252b87765ea78cae8aa1bca121491ae3647e6d | fwzlyma/OpenCV-in-3h | /2_chapter.py | 1,141 | 3.921875 | 4 | # 项目 : Python学习
# 姓名 : 武浩东
# 开发时间 : 2021/7/11 20:03
import cv2
import numpy as np
img = np.zeros((512, 512, 3), np.uint8) #添加RGB
#print(img.shape)
# 1. line
cv2.line(img, (0, 0), (300, 300), (0, 255, 0), 3) #cv2.line(img, start_axis, end_axis, color, thickness)
cv2.line(img, (0, 0), (img.shape[1], img.sha... |
4dffcc0c82de72016c976ad4719e3187a72c3871 | Adnanize/SolvingProblems | /consecutive_zeros.py | 406 | 3.96875 | 4 | def consecutive_zeros(binary_string):
"""
This function takes a binary string as a parameter, and returns
the biggest number of consecutive zeros
"""
#returns the biggest number of consecutive zeros
return "The biggest number of consecutive zeros is ", max(map(len,binary_string.split('1')))
#... |
1aaf57525a83d51f7a27dcbe5afaddb1a695ab2f | 2485951710/ds | /python高级/pycharm/linklist合.py | 1,312 | 3.921875 | 4 | from typing import List
class Node:
def __init__(self,data):
self.data = data
self.next = None
def __repr__(self):
return f"Node({self.data})"
class LinkList:
def __init__(self):
self.head = None
self.tail = None
self.size = 0
def get(self,index):
... |
dfb693bb8093a5f86513a6cd0b565d5c1d0c2809 | sachinsaurabh04/pythonpract | /Function/function1.py | 544 | 4.15625 | 4 | #!/usr/bin/python3
# Function definition is here
def printme( str ):
#"This prints a passed string into this function"
print (str)
return
# Now you can call printme function
printme("This is first call to the user defined function!")
printme("Again second call to the same function")
printme("hello sachin, t... |
acd184397cb06ee98ca769b7f59e519f7c364682 | sachinsaurabh04/pythonpract | /List_Tuple_Dictionary_Str/tuple1.py | 139 | 3.5 | 4 | #!/usr/bin/python3
tup1=('sachin',432,'adc',55,'join')
print(tup1)
tup2=('ramu',44,'shyamu',33)
print(tup2)
tup3 = tup1 + tup2
print(tup3)
|
6449b99534151c641b5856b5bc31874d27eae50c | sachinsaurabh04/pythonpract | /Loop/forloop1.py | 576 | 4.15625 | 4 | #for letter in 'python':
# print("Letter in python is ", letter)
#print()
#fruits=['banana','apple','mango']
#for x in fruits:
# print('current fruit ', x)
#print("Good bye")
#!/usr/bin/python3
#fruits = ['banana','apple', 'mango']
#for x in range(len(fruits)):
# print("My favourite fruits are : ", fruits[x]... |
3d1454b0e36d30e41dcf2af89aa5bcce33ef4a19 | sachinsaurabh04/pythonpract | /List_Tuple_Dictionary_Str/dictionary.py | 205 | 4.09375 | 4 | #!/usr/bin/python3
dict={'Name':'Zara','Age':24,'city':'jabalpur'}
print("Name is :",dict['Name'])
print("Age is :", dict['Age'])
print("City is : ",dict['city'])
dict['School']='DPS'
print(dict['School']) |
187969d0bdfc7dc225a0fb631e17eaf8781c214c | sachinsaurabh04/pythonpract | /File/filetest.py | 487 | 3.96875 | 4 | #!/usr/bin/python3
# Open a file
fo = open("foo.txt", "r+")
fo.write( "Python is a great language.\nYeah its great!!\n")
#Open a file
str = fo.read() #It will let the str print full text file
#str = fo.read(10) #It will print only 10 letter of the file
print(str)
position = fo.tell()
print("Current file position : ",... |
b35cf97ec2fdb75d1821fdf1da7a8f54d07eb46c | sachinsaurabh04/pythonpract | /Function/function5.py | 454 | 3.984375 | 4 | #!/usr/bin/python3
#Function Argument
#. Required arguments
#. Keyword arguments
#. Default arguments
#. variable-length arguments
#Required Arguments
#To call the function printme(), you definitely need to pass one argument, otherwise it gives a syntax error
#function definition is here
def printme(st... |
70b59046590e09cf64be5d6c6d210893ab3d7bfc | sachinsaurabh04/pythonpract | /Function/funtion7.py | 1,115 | 4.3125 | 4 | #keyword Argument
#This allows you to skip arguments or place them out of order because the Python
#interpreter is able to use the keywords provided to match the values with parameters. You
#can also make keyword calls to the printme() function in the following ways-
#Order of the parameters does not matter
#!/usr/bin... |
8878272950ee348e753b3c5d79ccde9bb9640085 | JanillLema/pythonProjects | /aihw5/classifier_data/jl4817_classifier.py | 7,323 | 3.671875 | 4 | """
WITHOUT THE STOP WORD FILE
m=k=1
training set: 0.9917040358744394
test set: 0.9820466786355476
held-out: 0.9784560143626571
WITH THE STOP WORD FILE
m=k=1
training set: 0.9910313901345291
test set: 0.9820466786355476
held-out: 0.9748653500897666
PART 4:
m= 2
k= .4
training set: 0.9905829596412556
test set: 0.9802... |
f396bd8ccde8d79848b35dc7dd8eb04d9bdd6f72 | rychtaradam/library-kivy | /test.py | 736 | 3.78125 | 4 | from db import Database, Book, Author, Genre
db = Database(dbtype='sqlite', dbname='library.db')
first_author = Author()
first_author.id = 1
first_author.name = "Jeff Kinney"
db.create(first_author)
first_genre = Genre()
first_genre.name = "komedie"
first_book = Book()
first_book.id = 1
first_book.name = "Deník mal... |
6988714bc0bebcb8bc71eaf85fe6423b28194bc0 | RhetTbull/osxphotos | /osxphotos/datetime_utils.py | 6,211 | 3.625 | 4 | """ datetime.datetime helper functions for converting to/from UTC and other datetime manipulations"""
# source: https://github.com/RhetTbull/datetime-utils
__version__ = "2022.04.30"
import datetime
# TODO: probably shouldn't use replace here, see this:
# https://stackoverflow.com/questions/13994594/how-to-add-time... |
546faa55dd2debe093fcffeae33e812db3d6ef47 | amydshelton/Day4 | /Day4.py | 503 | 4.09375 | 4 | numbers = []
strings = []
names = ["John", "Eric", "Jessica"]
numbers.extend([1,2,3])
strings.append("hello")
strings.append("world")
# write your code here
second_name = names[1]
# this code should write out the filled arrays and the second name in the names list (Eric).
print(numbers)
print(strings)
print("The s... |
4756ee33038b45db04183209d8119214b86dc6d3 | Pradeep1321/LeetCode | /BinaryNumber-to-Integer.py | 132 | 3.515625 | 4 | def getDecimalValue(head):
stg = ''
while head:
stg += str(head.val)
head = head.next
return int(stg, 2) |
cb85f7ba3c770a909e107e1955e005c563a981bb | Pradeep1321/LeetCode | /Matrix-Diagonal-Sum.py | 696 | 3.8125 | 4 | import math
def diagonalSum(mat):
sum=0
for i in range(len(mat)):
sum+=mat[i][i]
j=0
for i in range(len(mat)-1, -1, -1):
if i == (len(mat) // 2) and (len(mat) % 2 != 0) :
j=j+1
continue
sum += mat[j][i]
j+=1
return sum
def sumoftwonumbers(lt,t... |
cd0dfcadabad228e5696374ad7441a9748984429 | Pradeep1321/LeetCode | /toLowerCase.py | 211 | 3.578125 | 4 | def toLowerCase(str):
st = ''
for i in str:
if 64 < ord(i) < 91:
st += (chr(ord(i) + 32))
else:
st += i
return st
str= '"al&phaBET"'
print(toLowerCase(str))
|
1ba9165278a6b4eb19f63cc50d77fd921281c5b9 | smurphy2230/csc-121-lesson12 | /student.py | 478 | 3.640625 | 4 | class Student:
def __init__(self, student_name):
self.name = student_name
self.project = 0.0
self.midterm = 0.0
self.final = 0.0
def inputScores(self):
self.project = float(input("Enter project score: "))
self.midterm = float(input("Enter midterm score: "))
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.