blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
542a463f11a9999c2d04abe685c35c05d0b9b50e | Al153/Programming | /Python/Cryptography/vignere cracker.py | 756 | 3.65625 | 4 |
def parallel_sort(labels,data):
'''parallel_sort(labels,data)'''
for
return (newlabels,newdata)
def gcd(a,b):
if a>b:
temp = a
a = b
b = temp
while 1:
if a == 0:
return b
break
elif b == 0:
return a
break
... |
dad0663f6e8455efe4dc36ab0fbebe7a68fdf8e2 | Aasthaengg/IBMdataset | /Python_codes/p03567/s367598178.py | 116 | 3.6875 | 4 | s = input()
p = False
for i in range(len(s)-1):
if s[i:i+2] == 'AC': p = True
if p: print('Yes')
else: print('No') |
1b93cab1781562939926ee88577a3fce1fdc437d | phattdoan/MIT6001 | /Week2.py | 2,178 | 3.953125 | 4 | # PS2
# -----------------------------------------------------------------------------
# check if the minimum payment will payoff of the credit card in the pre-determined length
def monthlyUnpaidBalance(b, p, i, m):
for l in range(0, m):
b = (b - p) + (i / 12) * (b -p)
return b <= 0
def minimumPayment(b... |
507f86eefb2f9670c7eca163e1691689bbb71925 | WrongAardvark/techdegree-project-1 | /random_num.py | 2,458 | 4.125 | 4 | import random
def start_game():
print("Welcome to the Rando-Numbo!")
print("In this game, I will pick a number between 1 and 10, and you will try to guess the number in the least amount of guesses possible.")
guess_amount = 0
play_game = True
high_score = []
player_guess = None
while p... |
280b91fc6719b612eef2a4d7ba197c1c89b1c167 | pranayreddy604/gitam-2019 | /basic.py | 568 | 3.953125 | 4 | #!/usr/bin/env python
# coding: utf-8
# print("hi")
print(""""hi""")
# In[10]:
print(""""hi""");
# In[6]:
print (1214)
# In[15]:
a=10
# In[16]:
b=15
# In[17]:
print(a+b)
# In[33]:
x=15
y=55
sub=x-y
add=x+y
mul=x*y
div=x/y
print (sub,add,mul,div)
# In[27]:
print ("substraction", sub)
... |
b85d9575d5ac99d07760d2ea42e533eded81d94e | damarkrisnandi/CP | /599/02.py | 408 | 3.53125 | 4 | def solve(a,b):
for i in range(len(a)):
for j in range(len(a)):
arra = list(a)
arrb = list(b)
arra[j], arrb[i] = arra[i], arrb[j]
c = ''.join(arra)
d = ''.join(arrb)
if c == d:
return "YES"
return "NO"
for _ i... |
48cf47725e9f103c2523142b6c9d348882b54dc6 | jeb482/Blotto | /blotto.py | 5,014 | 3.5625 | 4 | # blotto.py
#
# Basic data structures for the blotto game
#
import pdb
# Returns the tuple of (wins, draws, losses) for strategy_a.
def run_blotto_game(strategy_a, strategy_b):
num_battlefields = len(strategy_a)
wins = 0; draws = 0; losses = 0
for i in range(num_battlefields):
if (strategy_b == N... |
7cc15d97d6dc771c7b627f0f8f5c91272c077e78 | Carter7868/CTrade | /main.py | 1,633 | 3.75 | 4 | #Started 06/19/21
#Last Edited 06/19/21
#Do Not Copy, Use, Distribute, or Edit
from gui import initializeGUI
from gui import updateStrategiesGUI
from gui import refeshGUI
def initialize():
#Initialize Program
print("Initializing...")
#Load GUI
initializeGUI()
#Load Settings
#Collect Chart Data... |
2506cfbbe3daab1d6f475f4c77d5d9f110624c0e | Wfl13213141812/Everyday-Is-Freash | /Everyday-Is-Freash/pretictice.py | 255 | 3.625 | 4 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time : 2018/12/29 21:01
# @Author : 梁学才
# @Site :
# @File : pretictice.py
# @Software: PyCharm
list = ['a','b','c','d','e']
a = '#'.join(list)
print(a,'AAAAAAAAAAAAAAA')
print(a.split('#')) |
a0e2365701e888c48f7763e5b31f67e14ef37bc8 | Prithvirajbilla/AlgorithmCoding | /hackerearth/parse.py | 989 | 3.609375 | 4 | import json
#reading the input
inp = ""
while True:
try:
inp+=raw_input().strip()
except EOFError:
#do nothing
break
json_data = json.loads(inp)
# print json_data
def cal_exp(k):
if isinstance(k,unicode):
return int(k)
elif isinstance(k,str):
return int(k)
elif isinstance(k,dict):
if "expr" in [l.low... |
c53598c8aaddd6fbc35d3bdd7ecc563a90cf96a4 | swhsiang/algo-note | /python/binary_tree_zigzag_level_order.py | 1,304 | 3.671875 | 4 | """
https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/
"""
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def zigzagLevelOrder(self, root):
"""
:ty... |
1673152d8c75cce5d66fae76ef769c77a994e8c4 | btab2273/functions | /nodes_in_triangle.py | 840 | 3.90625 | 4 | # Write a function that identifies all nodes in a triangle relationship
# with a give node
import networkx as networkx
from itertools import combinations
def nodes_in_triangle(G, n):
"""
Returns the nodes in a graph 'G' that are involved in a triangle
relationship with the node 'n'
"""
triangle_nodes = set([n])
... |
0a43212d7133e380aaf1e4dc3e78823ae15af1de | ryanatgz/data_structure_and_algorithm | /jianzhi_offer/55_翻转单词顺序.py | 847 | 3.984375 | 4 | # encoding: utf-8
"""
@project:data_structure_and_algorithm
@author: Jiang Hui
@language:Python 3.7.2 [GCC 7.3.0] :: Anaconda, Inc. on linux
@time: 2019/8/8 15:05
@desc:
"""
class Solution(object):
def reverseWords(self, s):
"""
:type s: str
:rtype: str
"""
s = s[::-1]... |
62b8743535bba6d7a51df93bef08349e1a6c27df | ziqingW/python-exercise-flex-Mar08 | /dictionary_exercise/letter_summary.py | 205 | 3.703125 | 4 | def letter_histogram(word):
result = {}
for char in word:
result[char] = word.count(char)
print(result)
if __name__ == "__main__":
letter_histogram(input("Give a word to start. ")) |
39907b9c884da12557c2776b6ae01fc8049b4e5b | Radomiej/python-knn | /Code/distance.py | 770 | 3.796875 | 4 | import math
def distance_euclidean(a, b):
distance = 0.0
for columnNumber in range(len(a)):
diff = float(a[columnNumber]) - float(b[columnNumber])
distance = distance + diff * diff
distance = math.sqrt(distance)
return distance
def distance_manhattan(a, b):
distance = 0.0
fo... |
3655e6476840086af994dd02aba5fb26e9c00ee7 | marcinszymura/python_kurs | /day2/tuple.py | 405 | 3.703125 | 4 | # x = (1 , 2 , 100, '123str')
#
# print(len(x))
# print(x.count(100))
#
# print(x[0])
# print(x[:3])
# print(x[::2])
#
#zad
y = (1, 2, 3, 4, 5, 6, 7, 8, 9, 0)
# print co drugi element
print(y[::2])
# print przedostatni
print(y[-2])
# print od 3 do 7
print(y[2:7])
# print co trzeci element
print(y[::3])
# print co drug... |
f0882c1802d98d855c92d271f8b422598c15504a | Yuhanss/LearnPython | /circuference.py | 125 | 4.34375 | 4 | #!/usr/bin/python
pi = 3.14159
radius = 3
C = pi * (radius **2)
print "The circumference of circle of radius 3 is ",C,""
|
c31e91d7a7bc485439e47cf7274e0d98954f0d08 | eyelivermore/pythonlianxi | /ex/ex15.py | 655 | 3.78125 | 4 | from sys import argv
script,filename = argv
#把argv前面收到的两个参数传给两变量
txt = open(filename, encoding = 'utf-8')
#txt对象,打开filname收到的文件用,编码方式'UTF-8'
print(f"Here's you file {filename}!")
#打印这个变量
print(txt.read())
#用read()方法,读取txt这个对象
print("'Type the filename again:")
#打印
file_again = input(">")
#输入文件名
txt_again = open(file_a... |
6b52dc4c3c20576aee6e4c1611d467edb944a616 | felipe471/Python_Zero_ao_DS | /Aula_01.py | 2,001 | 4.03125 | 4 | # Carregue o conjunto de dados chamado kc_house_data.csv
# funcao - read_csv()
# biblioteca Pandas
import pandas as pd
data = pd.read_csv('datasets/kc_house_data.csv')
# Mostra na tela as 6 primeiras linhas do conjunto de dados
print(data.head())
# Mostre o número de colunas e o número de linhas do... |
708b5304244e1897bb26e2d1e94d1b2d903342f6 | Wellington475/GeoMath | /geomath/line.py | 4,283 | 3.71875 | 4 | #Line file for the GeoMath library
from math import sqrt, atan, degrees
from geomath import point as p
import re
class Line:
def __init__(self, *args, **kwargs):
#These are the initial line parameters
self.PointOne = 0
self.PointTwo = 0
self.Angulation = 0
self.Angular = 0
... |
91c5377ad81fe7eb82123b8c77bddadcd9654188 | sachinlohith/leetcode | /Arrays/reshape.py | 411 | 3.640625 | 4 | """
https://leetcode.com/problems/reshape-the-matrix/#/description
"""
class Solution(object):
def matrixReshape(self, nums, r, c):
"""
:type nums: List[List[int]]
:type r: int
:type c: int
:rtype: List[List[int]]
"""
newNums = [y for x in nums for y in x]
... |
c890226d60eb7d13dff9ff0f2d40031792eede4b | shaquilledavid/IEEE-754 | /gui.py | 1,597 | 3.578125 | 4 | import tkinter as tk
from tkinter import font
import ieee
def encode_button(number, result):
if number == "inf" or number == "-inf":
encoded_val=ieee.encode(number)
result['text'] = "IEEE-754 Representation: \n" + encoded_val
else:
try:
encoded_val=ieee.encode(float(number))... |
791f65607e23c3cfe8f1d9cd3a6f4a64624f559f | mecozma/100DaysOfCode-challenge | /day8/q25.py | 169 | 3.75 | 4 | class Animal:
name = "Harvey"
def __init__(self, name=None):
self.name = name
horse = Animal
print(horse.name)
dog = Animal("Peanut")
print(dog.name)
|
cb1441103909e53808046f49c196dbb02aeac17e | gu-zu/python_cursus | /opdrachten/opdr24.py | 126 | 4.03125 | 4 | str = input("Geef een woord ")
print(str, "achterstevoren is ", end="")
for v in reversed(str):
print(v, end="")
print()
|
aaf90f780585f0fa364050eba72ad6c6446b6cfb | rubengr16/BeginnersGuidePython3 | /7_loops/2_for.py | 1,166 | 4.8125 | 5 | # The for loop is used when we know how many times we need to iterate,
# we step a variable through a series of values until a given test is met,
# to do this, we will use the range function to generate a range of values to be used as the sequence in the loop
# it is also possible to loop over data structures,
# the f... |
73cfdb845161d346b6dae960863d8b0c4d200395 | Skharshavardhan/assignment-submition-day1 | /Day1.py | 144 | 3.984375 | 4 | val = [int(i) for i in input('Enter the numbers:').split()]
val.sort() #sorts the list
val.reverse() #reverse the sorted list
print(val)
|
026c70d30802e0283ca814f40f0cde1b2d159f9a | cyjangel/MystanCodeSC101Projects | /SC101_Projects/warm_up/blur.py | 1,793 | 3.96875 | 4 | """
File: blur.py
Name: Angel Chen
-------------------------------
This file shows the original image first,
smiley-face.png, and then compare to its
blurred image. The blur algorithm uses the
average RGB values of a pixel's nearest neighbors
"""
from simpleimage import SimpleImage
def blur(img):
"""
:param ... |
8b34d2527c4b5d486dd17cad04e2dbfacdcaa58f | N01329655/Python_practice | /Simple Pig Latin.py | 1,257 | 4.03125 | 4 | def pig_it(text):
list1 = list(text.split(" ")) # separating the text into an array of strings ['My','frined',....]
res_string = "" # string to store the result
list2 = ['[','@','_','!','#','$','%','^','&','*','()','<>','?','/','|','}','{','~',':',']','\\']
for word_ in list1:
# print(word_)
... |
cb47a1506bf417e1e44fc021169c8f9de6845ae6 | nazia-noor/DS601_ID-SI78373 | /Week10/file_processor.py | 2,083 | 3.53125 | 4 | import os
import zipfile
import requests
class FileProcessor:
def __init__(self, extract_path ='text_files', file_types=['.txt', '.docx']):
self.file_url = "https://github.com/msaricaumbc/DS601_Spring21/raw/main/Week10/homework/text_files.zip"
self.extract_path = extract_path
self.zip... |
ddb4c02f79ef420e79b81e578591cc9a61e5cd86 | EvgenySocialSpice/lesson2 | /for/task21.py | 89 | 3.640625 | 4 | nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
for num in nums:
num += 1
print(num)
|
59f95f70b7611dce91b0557710e4b258dabdc75a | Khun-Cho-Lwin/Python-Files-IPND | /Random_nouns.py | 175 | 3.71875 | 4 | from random import randint
def random_noun():
random_num = randint(0,1)
if random_num == 0:
return "sofa"
else:
return "llama"
print random_noun()
|
81f933288e4f6af4bc7a93e5d7fed7fe00cd76be | leomcp/HackerRank_Solutions | /Problem Solving/Data Structure/Stacks/largest_rectangle.py | 1,027 | 3.6875 | 4 | class Stack:
def __init__(self):
self._data = []
self._size = 0
def is_empty(self):
return self._size == 0
def __len__(self):
return self._size
def peek(self):
return self._data[-1]
def push(self, elem):
self._data.append(elem)
self._size = self._size + 1
def pop(self):
if self.is_empty():
... |
73dac4610d40a2a566d0e5a50ed74291b4a36f1f | KennethA2001/guess-a-number | /guess_a_number_ai.py | 4,351 | 4.125 | 4 | import random
import math
# helper functions
def show_start_screen():
print()
print()
print(" _____ _ _ _ _ ")
print(" / ____| /\ | \ | | | | /\ (_) ")
print(... |
7adc974fae93124994b1f953e63645ee514c2aa7 | spitzc32/Python-Basics | /basic_python/python_refresh5.py | 275 | 3.953125 | 4 | # Loops
# - running some chunk of code over and over again
# - for loop
# - while loop
#
# dognames = ["Mark", "Patras", "Lady", "Nimeria"]
# for dog in dognames:
# print(dog)
# for x in range(1, 10):
# print(x)
age = 0
while age < 18:
print(age)
age += 1 |
e28cbcc632d1b1f0572e1e2ec7f74fecc8ddb6a4 | hawahe/leran_frank | /function2.py | 235 | 4.125 | 4 | import math
a = int(input('please input the a:'))
b = int(input('please input the b:'))
def triangle(a,b):
c = math.sqrt(a*a + b*b)
return c
d = triangle(a,b)
print("The right triangle third side's length is {}".format(d))
|
be242ea1fe78afcc48aac455f8eb378996e302d3 | adrianmarino/algorithms | /examen/2017/7.1.py | 1,156 | 4.4375 | 4 | #!/bin/python
def more_frequently_element(elements):
"""
Returns more more frequently element along with its frequency.
Precondition: 'elements' is an ascending ordered numeric list.
Example:
elements = [1, 2, 4, 4]
-------------------
i Max curr, next
-------------------
0 ... |
123ab15fb1985c31140cdd1f84d7988d1ebd91c9 | qianjing2020/Computer-Architecture | /ls8/lecture/subroutines.py | 727 | 4.09375 | 4 | def foo():
print(1)
def bar():
print(2)
foo()
print(3)
bar()
foo()
print('Done')
"""
When we call:
1. Push the return address (the address diretly after CALL) on the stack
2. Set the PC to the address of the subroutine
When we return:
1. Pop the return address off the s... |
d05b2e50f72ecb7bd08f5ce1136625881d71194f | fongbb132/ACM_Practice | /increasing_subsequences.py | 414 | 4 | 4 | """
Given an integer array, your task is to find all the different possible increasing subsequences of the given array, and the length of an increasing subsequence should be at least 2 .
"""
def findSubsequences(nums):
subs = {()}
for n in nums:
subs |= { a + (n, ) for a in subs if not a or a[-1] <= ... |
fc5346de6040355b915ad2041d4f96ca89bd35da | ham4286/timer | /korean.py | 177 | 3.8125 | 4 | import time
timer = int(input("타이머를 입력해주세요(초 단위) : "))
for i in range(timer):
print(timer)
timer -= 1
time.sleep(1)
print("끝")
#한글 |
671d9b27bd6b65ffca779e614d67c50aee7c7a85 | srnovak13/Python-Projects | /Student_Tracking_Project/student_tracking.py | 1,298 | 3.5 | 4 | #
#
#Python Version: 3.9.1
#
#Author: Steven R. Novak
#
#Purpose: Demonstrating using Tkinter GUI module,
# Using Tkinter Parent and Child relationships
#
#Tested OS: This code was written and tested to work on Windows 10
from tkinter import *
import tkinter as tk
from tkinter import messagebox
#Importi... |
edac11f925209322c5398d7e0991475aa6b0762d | KrushikReddyNallamilli/python | /countdown.py | 129 | 3.8125 | 4 | import time
n=int(input("enter number to start countdown="))
while n>=0:
print(n)
time.sleep(1)
n=n-1
print("blast")
|
788f53c467539f35aaa50551b966b1c1b3545b5c | mhtehrani/Algorithm_LeetCode_Easy | /removeElement.py | 429 | 3.875 | 4 | """
Remove an Element from a List
=============================
@author: mhtehrani
October 28, 2021
https://github.com/mhtehrani
"""
def removeElement(nums, val):
left = 0
for j in range(len(nums)):
if nums[j] != val:
nums[left], nums[j] = nums[j], nums[left]
... |
37ba3649b9715c709361ce1bdf4e0f64b3189547 | ybsdegit/Weatherforecast | /query.py | 1,421 | 3.703125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019/3/16 22:47
# @Author : Paulson
# @File : query.py.py
# @Software: PyCharm
# @define : function
import json
import requests
from json import JSONDecodeError
FILENAME = 'city_code.txt'
def read_code(filename = FILENAME):
with open(filename,'r') ... |
76f0026086f6695cd09221ab8f08527c7d9ac3d7 | Rajahx366/Codewars_challenges | /6kyu_Constant_value.py | 1,094 | 4.03125 | 4 | """
Given a lowercase string that has alphabetic characters only and no spaces, return the highest value of consonant substrings. Consonants are any letters of the alphabet except "aeiou".
We shall assign the following values: a = 1, b = 2, c = 3, .... z = 26.
For example, for the word "zodiacs", let's cross out the ... |
e3e0693d1a22e935678b5345d4f235fa11f3ef8e | chonnomvv/practice | /q3.py | 107 | 3.59375 | 4 |
for i in range(1,10):
print()
for j in range(2,10):
print("%d*%d=%d"% (j,i,j*i),end="\t")
|
91cc5377a9886f8bfe59aa82f568fb191979aa74 | sathwik295/degree-python | /py.5.py | 1,209 | 3.953125 | 4 | ##n=int(input('enter a number'))
##for i in range(1,n+1):
## for j in range(1,n+1):
## print(n,end=' ')
## print()
##for i in range(1,6):
## for j in range(1,i+1):
## print('*',end=' ')
## print()
##for i in range(1,6):
## for j in range(1,i+1):
## prin... |
9bdcf6a7b9ddc69ea00ce82d188563451f8857e0 | jzhanay001/Python-Bootcamp | /week_one/even.py | 315 | 4.15625 | 4 | #the goal of this script is to print out the even numbers
# between 1 and N (inclusive), where N is a user input.
N=int(input("Enter an upper limit:"))
for number in range(1,N+1):
if(number%2==0):
print(number)
counter=1
while counter<=N:
if counter%2==0:
print(counter)
counter+=1
|
42fe7fee1e32a223e6277523f9b9abbf3f3b1811 | huangyingw/submissions | /398/398.random-pick-index.234342517.Accepted.leetcode.py | 207 | 3.75 | 4 | import random
class Solution:
def __init__(self, nums):
self.nums = nums
def pick(self, target):
return random.choice([i for i in range(len(self.nums)) if self.nums[i] == target])
|
dcfc8a521e6d2eb0141c387df6f3bdaee02ba834 | anfernee84/Learning | /python/calculator.py | 1,535 | 4.40625 | 4 | result = None
operand = None
operator = None
wait_for_number = True
while True:
result = input("Enter first digit: ")
try:
result = int(result)
except ValueError or TypeError:
print (f"{result} is not a digit")
else:
break
while True:
operator = str(input("Enter an operat... |
5455a9c21a79364e4007c789a4f393e532ca04e4 | rssgeorge/scientific-python-course | /src/logistic_regression_on_pension_dataset.py | 685 | 3.734375 | 4 | import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from sklearn.linear_model import LogisticRegression
age_to_getting_pension = pd.read_csv("https://github.com/Ceyron/machine-learning-and-simulation/files/7251110/age_to_getting_pension.csv")
classifier = LogisticRegression()
classifier.fit(age_to_... |
99c5ef16c7f12f43fed630b3de29ca91234f4b9d | dilaraism/-solutions | /codewars/python/is_prime.py | 632 | 4.0625 | 4 | from math import sqrt
def is_prime(n):
if n==1: return True
if n==2: return False
if n>2 and n%2 == 0 : return False
for i in range(3, int(sqrt(n+1)), 2):
if n%i==0:
return False
return True
print is_prime(42123424511122221)
# is_prime(4223131213131313131111111111)
# is_prime(42423564576467... |
5b482ccc3d79cd7e6963ee69aff74b01ce37d6ba | SnehalKaranje/python | /basics/prime.py | 400 | 4.0625 | 4 | def chkPrimeNumber(num):
if(int(num) <= 1):
print("Not a prime number")
return
for i in range(2, int(num)):
if(int(num) % i == 0):
print("It is not a prime number")
return
print("It is a prime number")
def main():
if(__name__ == "__main__"):
pr... |
e33395df6a75268e1d401ac8ab8009e68d70c7bb | panherz/MyPyCode | /UserInput.py | 2,333 | 4.5625 | 5 | __author__ = 'dark00ps'
# USER INPUT
# The simplest use of the input function assigns a string to a variable.
print('Please enter your first name::::\n', end='')
inputFirstName = input()
print('\nAnd your last name::::\n')
inputLastName = input()
print('\nMy full name is::::', inputFirstName, inputLastName, '\n')
# ... |
cdfca4b003717d8b03d90b319090175db128da06 | AdriBesson/ntds_2017 | /projects/reports/swiss_politics/clean_data.py | 3,423 | 3.796875 | 4 | import pandas as pd
import numpy as np
def get_voter_data():
"""
Loads the 2015 Smartvote data and cleans it to output a pandas Dataframe containing the answers to the questions and
the recommended party. Each party has an index coresponding to the second output variable, which is a list of party
name... |
d6c2574c4c1e5579bc144af8153fc46574e9bdab | InnaOrtman/homework | /урок 11/task_4.py | 800 | 3.765625 | 4 | # Task 4
# Custom exception
# Create your custom exception named `CustomException`,
# you can inherit from base Exception class,
# but extend its functionality to log every error message
# to a file named `logs.txt`.
# Tips: Use __init__ method to extend functionality for saving messages to file
class CustomException(... |
be45e59cf51f3ff74525f177f6dcbd078120db76 | pepeArenas/PythonGettingStarted | /ExcepcionesUseExamples.py | 944 | 4.21875 | 4 | person = {"name": "Jesus", "age": 34}
# This will raise an error KeyError
# names = person["names"]
# In order to handle the error we need to use try except, in this case we are just catching the key error
try:
names = person["names"]
except KeyError:
print("An key error has raisen")
print("Out of the excepti... |
e3821a0de8dd25b63fd1e02b0e7137777bb82c52 | Riya870/Rock-Paper-or-Scissors | /rps.py | 1,496 | 4.09375 | 4 | import random
# ROCK PAPER SCISSORS
def gameWin(computer,player):
# if both values are equal then it declare tie
if computer == player:
return None
#check for all possibilities when computer chose R(Rock)
elif computer == 'R':
if player == 'P':
print(player,"covers",comp... |
876f708c5b1a45e851f7b83cd4d4256a62165dc5 | jengfad/webscraping | /others/property24/utilities.py | 730 | 3.5 | 4 | import csv
from random import randint
import time
def append_to_csv(data, file_name, is_header):
# Add contents of list as last row in the csv file
with open(file_name, 'a+', newline='', encoding="utf-8") as write_obj:
item_row = []
for attr in dir(data):
if attr[:2] == '__':
... |
9bbd551d131cf18af0818c84fdbca6e499e37183 | sglim/inno-study | /leetcode/ino/prob_070/prob_070_climbing_stairs(1).py | 469 | 3.796875 | 4 | '''
let d[n] : number of ways to climbing n-stairs
then :
d[n] = d[n-1] + d[n-2]
'''
class Solution(object):
def climbStairs(self, n):
"""
:type n: int
:rtype: int
"""
if n < 0:
return 0
d = {0: 0, 1: 1, 2: 2}
if n <= 2:
return... |
66cf1ce688335896c1d0f438f5976ceba662758a | OstapKuch/Lab_01_alg | /main.py | 609 | 3.625 | 4 | import sort
import Student
import read_file
import time
student_list = read_file.read_class_file(input("Enter file nime:\n"))
start_time = time.time()
sort.buble_sort(student_list)
print("Time: ", time.time() - start_time, "\nResult:")
for i in student_list:
print(i, "\n")
print("----------------------------------... |
40ec7465936a689af399652add60a6c64c3eb713 | guilhermeagostinho22/exercicios-e-exemplos | /exercicio22.03/exercicio3.py | 607 | 3.625 | 4 | ageW = 0
numbW = 0
ageM = 0
numbM =0
for f in range(0,10):
sex=(input("Qual o seu sexo ? M para homem e W para mulher."))
if sex == "M":
numbM = numbM + 1
ageM = ageM + (int(input("Qual a sua idade ?")))
elif sex == "W":
numbW = numbW + 1
ageW = ageW + (int(input("Qual a sua i... |
c43af2acc58e816264a77dfe760afd13da19dba7 | aaguasvivas/CodeBreakersCode | /1.Fundamentals/linked_lists/LinkedList.py | 1,990 | 4.03125 | 4 | class Node:
def __init__(self, item, next=None):
self.item = item
self.next = next
class LinkedList:
def __init__(self):
self.head = Node("dummy")
self._size = 0
def __str__(self):
# O(n) runtime
# O(n) space
out = ""
cur = self.head.next
... |
b4ccc87a97ba8e213f08d52100cd4d0e927a2461 | EugeneAhramenko/python | /firstStepsInPython3.9/projects/physicsFunctions.py | 1,231 | 3.9375 | 4 | """
Getting Ready for Physics Class
"""
train_mass = 22680
train_acceleration = 10
train_distance = 100
bomb_mass = 1
# This is function that convert Fahrenheit to Celsius
def f_to_c(f_temp):
return (f_temp - 32) * 5 / 9
f100_in_celsius = f_to_c(100)
print(f100_in_celsius)
# This is function that convert Cels... |
eba12933715dfaec0591f6d72c64ed19d852da40 | Sujit-sahoo3571/python_programming | /sem_III_project/oops/advancePython/AdvancePython2/Filter.py | 263 | 3.578125 | 4 | # filter (function , list )
def greater_than_5(x):
if x > 5:
return True
else:
return False
g10 = lambda x : x >10
ls = [1, 2, 3, 5,8,10, 4, 44, 33, 24, 23, 53, 234]
print(list(filter(greater_than_5, ls)))
print(list(filter(g10, ls)))
|
802f40a79d7492db7395f1ae65563cbdc347271d | PrinceCuet77/Python | /Extra topic/extra_last_things.py | 522 | 3.703125 | 4 | # Doc string
def add(a, b) :
'''Taking 2 arguments and returning sum of two numbers'''
return a + b
print(add(1, 2))
print(add.__doc__) # Doc string calling
print(len.__doc__)
print(sum.__doc__)
print(max.__doc__)
print(min.__doc__)
print(sorted.__doc__)
print()... |
b365764e9e1594fff8bcb4e6a0c808ec36b07549 | Deliayayaya/alien_invasion | /ship.py | 1,971 | 3.6875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2019-10-11 17:18:23
# @Author : Your Name (you@example.org)
# @Link : http://example.org
# @Version : $Id$
import pygame
from pygame.sprite import Sprite
class Ship(Sprite):
def __init__(self,ai_setting,screen):
# ships = Sprite()
super... |
06294dcd9bc55821a27ac7fee94ec70b671f9438 | kopok2/CodeforcesSolutionsPython | /src/500A/cdf_500A.py | 935 | 3.640625 | 4 | class CodeforcesTask500ASolution:
def __init__(self):
self.result = ''
self.target = 0
self.connections = []
def read_input(self):
self.target = int(input().split(" ")[1])
self.connections = [int(x) for x in input().split(" ")]
def process_task(self):
target... |
1b2f827111e334c4f0d055555a85c9bc6e034b03 | qw20140729/lagou6 | /three/assignment_three.py | 433 | 3.59375 | 4 |
class Animal(object):
name = ''
color = ''
age = 1
sex = ''
def cry(self):
print(f'动物{self.name}会叫...')
def run(self):
print(f'动物{self.name}会跑...')
class Cat(Animal):
def __init__(self, hair):
super().__init__(self)
self.hair = hair
def clutch(self):
... |
bd5133e2b1e64498c1e80f64692c61c417c78c82 | sm-m-1/advent-of-code-2017 | /day1/solution.py | 1,107 | 3.59375 | 4 | from argparse import ArgumentParser
def _get_input():
with open('./day1/input_1.txt') as input_data:
data = input_data.read().strip()
return data
def solve_one():
data = _get_input()
vals = []
last_val = data[-1:]
for val in data:
if val == last_val:
vals.appen... |
375ab5a91d2ce524ddb7e1b923a7e71b386349bc | kiwiTR/Python-programming-from-entry-to-practice-1-11-answers | /9.6.py | 929 | 3.8125 | 4 | class Restaurant():
def __init__(self,restaurant_name,cuisine_type):
self.restaurant_name=restaurant_name
self.cuisine_type=cuisine_type
self.number_served=0
def describe_restaurant(self):
print(self.cuisine_type)
print(self.restaurant_name)
def open_resta... |
88c59325f27bb4502eebda8b7891a7e2e635e8e6 | snehilk1312/one-time-pad | /oneTimePad_concise.py | 695 | 4.15625 | 4 | #! /usr/bin/env python3
import os
import base64
def encrypt(plaintext, key):
r = ''
for i in range(len(key)):
c = ord(plaintext[i])^key[i]
r += chr(c)
return r
def decrypt(ciphertext, key):
# we will use the property of xor operation
return encrypt(ciphertext, key)
plaintext = input("Enter the text to ... |
06180a05129ae179773167b341b2bf36097fa25e | sandycamilo/SPD-2.3-Debugging-Techniques-Lab | /Refactoring-Other-Techniques/extract_class2.py | 2,073 | 3.59375 | 4 | # # by Kami Bigdely
# # Extract class
# class Email:
# def __init__(self, first_name, last_name, birthdate, email):
# self.first_name = first_name
# self.last_name = last_name
# self.birthdate = birthdate
# self.email = email
# def send_hiring_email(self):
# print("emai... |
f53c894a64e24ca70e3ea71fb78d5f03ba4356fc | tea-with-lemon/IU9 | /Python/del.py | 428 | 3.78125 | 4 | def Razl(n):
d=2
array=[]
stop=n//2
while (n!=1) and (d <= stop):
while n%d==0:
n=n/d
array.append(d)
else:
d+=1
return array
def Stroitel(n):
global array
for elem in array:
if n%elem==0:
print(n,"--",n//elem)
... |
8276e7d7c20e6db19152c89abd1b920bf157767b | Daedalus-B/Quadratics | /Factorising Calculator.py | 1,148 | 3.875 | 4 | ###Factorising for simple quadratics##
#Please Note your a value must always equal to 1
import math
import random
def factor(a, b, c):
t = False
while t == False:
n = random.randint(-1000,1000)
m = random.randint(-1000,1000)
if n*m == c:
if n+m == b:
t = True... |
35e68bc5685028d3217d8d7ce8a47254cfaa3aec | rid47/python_basic_book | /chapter6/review_exercise3.py | 92 | 3.84375 | 4 | def doubles(n):
print(n*2)
return n*2
j = 2
for i in range(3):
j = doubles(j)
|
1216b64ff64d1977a5abdd7055bb801f2f59391f | aishwaryasarath/Coursera | /Course2/week3/capturing-groups.py | 946 | 3.71875 | 4 | import re
result = re.search(r"^(\w*), (\w*)$", "Lovelace, Ada")
#print(result)
#
print(result.groups())
#print(result[0])
#print(result[1])
#print(result[2])
#
# print("{} {}".format(result[2], result[1]))
# def rearrange_name(name):
# #result = re.search(r"^(\w*), (\w*)$", name)
# result = re.search(r"^(\w*)... |
594179b2ff92cc1b4b9c12d465f0604b971eef23 | madsngh/python | /exe18.py | 445 | 3.875 | 4 | #_*_coding: utf=8_*_
'''NMAE VARIABLE CODE FUNCTION
IN THIS WE WILL LEARN TO DEFINE FUNCION FIRST THEN
WE WILL USE FUNCTION'''
def siddhu(*a):#the value or r and s is laatter stored in *a
c,d=a
print("the values you entered are %r %r"%(c,d))
def siddhu2(r,s):#with two argument
print("the values you entered are %r %... |
a7bf2ed4a130019350e28bdaa55a9aec5bdcb9cd | meyerjo/python-spielereien | /vokabel-3.py | 716 | 3.625 | 4 | import random
# Vokabeln definieren
vokabel = ["le chien", "le chat"]
bedeutung = ["der Hund", "die Katze"]
# Vokabeln / Bedeutung abfragen
entscheider = random.randint (0,1)
if entscheider == 0:
print ("Was heißt", vokabel[0], "?")
antwort = input ("Antwort >")
if antwort == bedeutung[... |
cd87437506e2a76672e81adb9baf8459b0c38905 | Dis-count/Python_practice | /GUI/Tkinter/grid.py | 565 | 3.734375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# author:
import tkinter as tk # 使用Tkinter前需要先导入
# 第1步,实例化object,建立窗口window
window = tk.Tk()
# 第2步,给窗口的可视化起名字
window.title('My Window')
# 第3步,设定窗口的大小(长 * 宽)
window.geometry('500x300') # 这里的乘是小x
# 第4步,grid 放置方法
for i in range(3):
for j in range(3):
tk.Labe... |
692384fbcd54fd4354c2ad8b585e514a24dec1dc | satoshun-example/algorithm-ari | /python/2-1-1_test.py | 1,885 | 3.953125 | 4 | #!/usr/local/bin/python3
## 階乗
def test_fact():
def fact(n) -> int:
if n == 1:
return 1
return n * fact(n - 1)
assert fact(10) == 3628800
## フィボナッチ数
def test_fib():
def fib(n):
if n <= 1:
return n
return fib(n - 1) + fib(n - 2)
assert fib(10) == ... |
e52151c17c60e63545715a9391a4ffa75f18f368 | sammanthp007/Weirdos | /CLRS/max_subarray_problem.py | 1,515 | 3.578125 | 4 | def find_max_crossing_subarray(A, low, mid, high):
max_sum = 0
highest_left = float('-inf')
temp_sum = 0
max_left = mid
for i in range(mid, low - 1, -1):
temp_sum += A[i]
if temp_sum > highest_left:
highest_left = temp_sum
max_left = i
max_right = mid + 1... |
37b6567881c04c16f5c68137bcceb57a07dddfcd | Chatchai222/SE-Kmitl-Intro-to-Comp-and-Prog | /Python LABS/Python Lab 7/q2.py | 704 | 3.6875 | 4 | # Question 2
class BankAccount:
def __init__(self, bank_name, owner_name, acc_num, balance):
self.bank_name = bank_name
self.owner_name = owner_name
self.acc_num = acc_num
self.balance = balance
def deposit_money(self, amount):
self.balance += amount
def ... |
586212038724930f16e87087d6aa2f665a9ebfec | ninabhatia/Math-449- | /HW 5 Code.py | 2,577 | 3.5625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Dec 13 09:22:10 2020
@author: ninabhatia
"""
import numpy as np
from utils import *
# %%
'''
Implemention of Newton-CG from scratch for the Rosenbrock function
'''
func = lambda x, y: 100*(y-x**2)**2 + (1-x)**2
plot_coutour(func, box = (-2,2), scale='... |
bad6041deabb6845490300420e600fecd1395481 | george-galli/python-usp | /FizzBuzz parcial2.py | 147 | 3.90625 | 4 | number = int(input("Digite em número inteiro: "))
a = number / 5
b = number % 5
if b == 0:
print("Buzz")
else:
print(number)
|
29a6b170d89f9a6ccad0f77cf10a9f58aefa89a8 | advil64/probabilistic-sensing | /src/gridworld.py | 2,042 | 3.796875 | 4 | from random import choices, randint, random
class Gridworld:
# NOTE: 1 -> blocked, 2 -> flat, 3 -> hilly, 4 -> forest
def __init__(self, dim, start=(0,0), target=(0,0), prob=0, empty=True):
# gridworld is an object attribute
self.gridworld = []
# start filling in grids by rows and co... |
93126380cbfc94d465ccfde2be0af5b0101ac81d | rsamhollyer/Digital-Crafts-Classes | /Programming-101/mediumexercises/exercise-4.py | 338 | 4.09375 | 4 | # Print Box
height = 0
width = 0
while True:
try:
height = int(input("Height? \n"))
width = int(input("Width? \n"))
break
except ValueError:
print("Please enter an integer only")
print("* " * width)
while height > 0:
print(f"* " + " " * (width) + " *")
height -= 1
pr... |
0df4f7495854d6ecc12f248735f13fb5d344e663 | KoeusIss/holbertonschool-machine_learning | /math/0x02-calculus/17-integrate.py | 850 | 4.03125 | 4 | #!/usr/bin/env python3
"""Integrate modulle"""
def poly_integral(poly, C=0):
"""Calculates the integral of a polynomial
Args:
poly (list): list of coefficients representing polynomial
C (int): representing the integration constant
Return:
(list|None): list of coefficients represen... |
8c46ef38774bd2dc4b49124e8cfc0774c605fbb6 | adityasingh108/python-Practice | /pratice/enumerate_fun.py | 408 | 3.578125 | 4 | def speciel_fun():
print("this is special function")
list = ["aadi","mith","manish"]
for index,item in enumerate(list):
if index%2 ==0:
print(item)
def normalfun():
print("this is normal function")
list1 = ["aad","mit","man"]
i = 1
for item in list1:
i... |
7f27d7b5c49e21a9b4f5cd1b09bfa12cd028bc1a | chanyoonzhu/leetcode-python | /959-Regions_Cut_By_Slashes.py | 1,629 | 3.59375 | 4 | """
- dfs
- O(n * 2), O(n * 2)
"""
class Solution:
def regionsBySlashes(self, grid: List[str]) -> int:
"""
- intuition: convert this into an "island" problem: slashes are "water", find how many isolated islands
- approach: pixelate the n * n grid to 3n * 3n grid (why not 2n * 2n? be... |
f26b7ec5a278de717f466ed251a1243fd0e2e747 | manofmountain/LeetCode | /392_IsSubsequence.py | 1,073 | 3.53125 | 4 | def isSubsequence(self, s, t):
t = iter(t)
return all(c in t for c in s)
from collections import defaultdict
from bisect import bisect_left
class Solution(object):
def createMap(self, s):
# create a map. key is char. value is index of apperance in acending order.
posMap = d... |
4ed0eec661814ab7f41ec777c025139a57479521 | mramnath94/DeepLearning | /sigmoid_plots.py | 857 | 3.65625 | 4 | import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits import mplot3d
import matplotlib.colors
def sigmoid_2d(x, w, b):
return 1/(1+ np.exp(-(w*x+b)))
w = 3
b = 3
X = np.linspace(-10, 10, 100)
Y = sigmoid_2d(X, w, b)
plt.plot(X, Y)
plt.show()
def sigmoid_3d(x1, x2, w1, w2, b):
return 1/(1+ np.exp(... |
2539f5a9c70072a294e7657fc9452d8df3b6b1d2 | Caoimhinv/-pands-problem-sheet | /squareRoot.py | 1,496 | 4.25 | 4 | # Problem Task 05 (27/02/21)
# This program takes a users inputted number and returns an approximation of its square root using the Newton method.
# Use of built-in functions was forbidden!
# Author: Caoimhin Vallely
# Newton's method involves a guess which I don't think was in the remit of this task
# so I'm going... |
5470c53cb3a13cc4c5fe0c3e43043e00fbaa047e | kaixuan0623/File-System-Visualizer | /treemap_genrator.py | 22,107 | 4.125 | 4 | """
=== Module Description ===
This module contains the basic tree interface required by the treemap
visualiser. You will both add to the abstract class, and complete a
concrete implementation of a subclass to represent files and folders on your
computer's file system.
"""
import os
from random import randint
import ma... |
07d4a480d54a4d8b118919238e721eecf224b80b | ChiUgb/CIS2348-15664 | /Homework 3/hw10.15.py | 1,294 | 4.125 | 4 | # Chiamaka Ugbaja
# 1772427
class Team: # Initializes the class that will execute the code
def __init__(self): # constructor/used as placeholder to store variable for use throughout the code
self.team_name = 'none'
self.team_wins = 0
self.team_losses = 0
def get_win_percenta... |
73319db1117f9200450a4c4e2b69b78571d7c616 | NoahDBos/IS51Test1 | /IS51Test1.py | 670 | 3.671875 | 4 |
"""
Create a program that will determine which option results in more money.
Option one is $100 a for ten days. Option 2 starts at $1 day but doubles
each day for ten days. One function will determine the amount of pay for
Option 1. The second function will determine the amount of pay for Option 2.
Function 1 will r... |
8d7e099b9df4cbc1e00a9efec8abf1036cbfa761 | ankitapalc/Clemson--Machine-Learning | /project4_1.py | 5,066 | 3.609375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 20 19:09:08 2019
@author: palan
"""
import os
def cleantext(text):
text = text.lower()
text = text.strip()
for letters in text:
if letters in """ []!.,"-!_@;':#$&%^*()+/? \|""":
text = text.replace(letters," ")
return text
def countwords(... |
f62ac0875906a0297ce87f37016e9d7c4e498fe1 | romulovieira777/Programacao_em_Python_Essencial | /Seção 07 - Coleções Python/Exercícios da Seção/Exercício_07.py | 392 | 4.3125 | 4 | """
7) Escreva um programa que leia 10 números inteiros e os armazene em um vetor.
Imprima o vetor, o maior elemento e a posição que ele se encontra.
"""
lista = []
for i in range(10):
lista.append(int(input("Enter the value: ")))
print(f"\nVetor: {lista}")
print(f"Largest element: {max(lista)}")
print(f"Positio... |
1111e0b443a6beb1fb211267c8e0fcb3d619298c | Jonathancui123/EdX-MIT-Python-Course | /MITPython/venv/Floats to binary.py | 280 | 4.1875 | 4 | x = float(input("Give me a decimal between 0 and 1"))
p = 0
while x*(2**p) %1 !=0:
p += 1
#print(x*(2**p))
#what to do to break infinite loop?
y = int(x*(2**p))
dec = ''
while y > 0:
dec = dec + str(y%2)
y = y//2
result = int(dec)/(10**p)
print(result)
|
5b383ea32f6f62d34fd95294ba43d5656d000d49 | iaslyk/towerofhanoi | /towerofhanoi.py | 610 | 3.90625 | 4 | import time
number = int(input('Enter number of disks: ')) # number of disks in tower
start = 'A' # start location
via = 'B' # helper
finish = 'C' # end location
def move(n, f, t):
print('Move disk {} for {} to {}!'.format(n, f,t)) # prints how we need to move disks to solve tower
time.sleep(0.3)
# recursion wher... |
faa6a746318aea726ad2e20590bd334a274f9f4f | govkartha/Python-programs | /lattice.py | 217 | 3.515625 | 4 | #Count the number of unique paths to travel from the top left to the bottom right of a lattice of size n*n.
import math
n=int(input())
result=(math.factorial(2*n))/(math.factorial(n)*math.factorial(n))
print(result)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.