blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
fcd9c8da693c1581079327bbb6beb6c2efa35422 | sfmajors373/MIT-600-Opened-Course-and-Book | /Week2/ProblemSet2.3.py | 1,778 | 4.09375 | 4 | #Using Bisection Search to calculate the lowest monthly payment that will pay off a $5,000 balance on a credit card with an 18% annual interest rate
#Basics
LowerBound = 5000/12 #lowest possible, balance divided by 12 months
UpperBound = 5000 #the balance with lots of interest divided by the 12 months
def midpoint... |
55b2ba2fc42ae86025fc1eff6338ff37f5efcca6 | jaythaceo/Jaythaceo | /newVS.py | 466 | 3.53125 | 4 | # Lets do something
# Lets's factor some numbers
"""
import time
from functools import reduce
def factors(n):
return set(reduce(list.__add__,([i, n//i] for i in range
(1, int(n**0.5) + 1) if n % i == 0)))
start = time.time()
tester = factors(222)
print(tester)
end = time.time()
print(end - start)
"""
# Lets pl... |
874dff17ef326b6c7fa72f887c424645652f546b | aarontravass/Nptel-DSA-Python-programs | /week2.py | 1,522 | 3.640625 | 4 | import math
def isprime(n):
flag = 0
for i in range(3, math.ceil(math.sqrt(n)) + 1, 2):
if (n % i == 0):
flag += 1
return False
if (flag == 0):
return True
def primepartition(n):
if (n > 0):
if (n % 2 == 0):
return (True)
else:
... |
c0f816905b94318cf383ec07b36faaa8c238824c | PeterSharp-dot/dot-files | /python-projects/modulo-generator/mog-gen.py | 142 | 3.75 | 4 | #!/usr/bin/env python
x = 0
while x <= 10:
for i in range(1,11):
print(f"{x} % {i} = {x % i}")
print("---------")
x += 1
|
8df34e4567226621f6542d517f152a446bea42e4 | AMao7/Python-Basic | /Python Exercises/101_exercises.py | 517 | 4.03125 | 4 | # Create alittle program that ask the user for the following details?
print('Hello there!, What is your name?')
your_name = input()
print("Hi there!", your_name.capitalize())
print(' What is your height?')
your_height = input()
print("No way you're", your_height)
print(' What is your favourite color')
favourite_color ... |
871320f56c96bfeb535688ca29256777f12f8a6b | laharily/python | /Pirate Language.py | 1,896 | 4.21875 | 4 | def translate():
'''translate() -> None
Prompts user to enter dictionary files and input and output files
Changes words in input file according to the dictionary file
Write translation in output file'''
# input for file names
dictFileName = input('Enter name of dictionary: ')
textFileNa... |
7f799e525e370ee220fe43bc2dbd8eddf6518909 | m-evtimov96/softUni-python-fundamentals | /10 - Exams/ExamPrepF-8.py | 429 | 3.953125 | 4 | import re
pattern = r"(.+)>(?P<Pass>[\d]{3}\|[a-z]{3}\|[A-Z]{3}\|[^<>]{3})<\1"
inputs_num = int(input())
for _ in range(inputs_num):
password = input()
match = re.match(pattern, password)
if match is None:
print("Try another password!")
else:
encrypted_password = match["Pass"]
... |
d1be0e284403e40efd3dfb33197685bf5b822aee | logicalpermission7/projects | /Elvis.py | 492 | 3.734375 | 4 | class Elvis:
def __init__(self, height, weight, birth_year, birth_place, favorite_food, pet, is_married):
self.height = height
self.weight = weight
self.birth_year = birth_year
self.birth_place = birth_place
self.favorite_food = favorite_food
self.pet = pet
... |
8b851500e53ad61c6aae2a3fdf8651edad00b2a8 | Jilroge7/holbertonschool-web_back_end | /0x00-python_variable_annotations/0-add.py | 203 | 3.515625 | 4 | #!/usr/bin/env python3
"""
type-annotated function.
"""
def add(a: float, b: float) -> float:
"""
add function that takes a and b arguments and returns sum as float.
"""
return (a + b)
|
fc47bf4ef317b04707df96ae8f0917bd6d83deae | Tom-Szendrey/Highschool-basic-notes | /Notes/Basic Arrays.py | 263 | 3.890625 | 4 | suitcase = []
suitcase.append("sunglasses")
suitcase.append("bathing suit")#adds to the array
suitcase.append("shirt")
suitcase.insert(0, "towel")
list_length = len(suitcase)
print "There are %s items in the suitcase." % (list_length)
print suitcase
|
26369e945a32520e149bbbd9d1b826a508ff7d3a | 981377660LMT/algorithm-study | /前端笔记/thirtysecondsofcode/python/python的typings/1_类型别名.py | 985 | 3.765625 | 4 | # Python 运行时不强制执行函数和变量类型注解,但这些注解可用于类型检查器、IDE、静态检查器等第三方工具。
# 类型别名(type alias)
from typing import Dict, List, Tuple
from collections.abc import Sequence
Vector = List[float]
def scale(scalar: float, vector: Vector) -> Vector:
return [scalar * num for num in vector]
# typechecks; a list of floats ... |
0a4cdef553d5732f415d57097cdc2ede8099036c | marioa/2014-12-03-edinburgh-students | /python/code/rev.py | 245 | 4.375 | 4 | #
# This defines a function that returns the reverse of a string,
# using a loop
#
#
#
def rev(string):
reverse_string = ''
for c in range(len(string)-1, -1, -1):
reverse_string += string[c]
return reverse_string
|
a53d90a00cc022ce2514f6e51e087ae5fd741c1d | NiamhOF/python-practicals | /practical-19/p19p3.py | 2,448 | 4.3125 | 4 | '''
Practical 19, Exercise 3
Import os to check if files exist
Define function stringCount that takes two parameters lines and string
assign count the value 0
for all lines in lines:
add the number of occurrences of that string to count
return the value of count
ask user to input a filename
check if file exists
... |
b61c2db9ad0c6181cd130b51c53b004f4cd9c78d | VolodymyrBodnar/pyBoost_FEB2021 | /pyBoost_FEB2021/zettelkasten/main.py | 747 | 3.765625 | 4 | all_notes = []
def crate_note(title, body, tags):
note = {"title": title, "body": body, "tags": tags}
return note
def find_note(tag):
result = [note for note in all_notes if tag in note["tags"]]
return result
while True:
title = input("введите назщвание заметки либо 0 чтобь перейти к поиску:")... |
fe165c1ee6a1c73d959f30c47843be82fac78c72 | anhpt1993/va_cham | /demo_vacham_rec.py | 1,748 | 3.78125 | 4 | import turtle as tt
import time
screen = tt.Screen()
screen.tracer(0)
t = tt.Turtle()
t.hideturtle()
def draw_rectangle(pen, x, y, width, height):
pen.penup()
pen.goto(x, y)
pen.pendown()
pen.pensize(3)
pen.pencolor("orange")
for i in range(2):
pen.forward(width)
pen.right(90)
... |
ff9c55ebc62eabe671dd73e1908305491ca9f92d | alpha1bah/Python-bootCamp | /Week2/Day3/dictionary.py | 535 | 4.4375 | 4 | # Dictionary
# Example of a dictionary
my_personal_info = {
"name" : "Alpha",
"DOB" : "01/01/2020",
"School" : "Hostos CC",
"GPA" : 0.5
}
# Dictionaries are known for their "key-value" pair system
# Checking if a key exists in a dictionary
if "name" in my_personal_info:
print(my_personal_info... |
d79b40858c6a3172547f5504702ae385a0c936c1 | davebremer/atbs | /Ch 04 Lists/messing with lists.py | 338 | 3.890625 | 4 | # catNames = []
# name="start"
# while name != "":
# name = input("enter a cat name: ")
# catNames = catNames + [name]
# print("the names of the cats are:")
# for name in catNames:
# print(name, end=' ')
# print()
spam = ['Zophie', 'Pooka', 'Fat-tail', 'Skiny','Pooka','Alpha','Beta','gamma']
print(spam[2... |
ba1f5e8f06ec2609adbf9a5a40edcb2227a0e3d1 | HozanaSurda/Analise-Projeto-Algoritmos | /quick-sort.py | 1,570 | 3.703125 | 4 | ##############################################
#ALUNA: HOZANA RAQUEL GOMES DE LIMA #
#MAT: 11414870 #
#DISCIPLINA: ANLISE E PROJETOS DE ALGORITMOS#
# EXERCICIO DE ORDENACAO #
##############################################
import so... |
dc78d0c3e05ed7ef266b72e56aa01f76b4a4836c | tanvisenjaliya/PES-Python-Assignment-SET-2 | /A28.py | 589 | 3.640625 | 4 | s=input("Enter a string: ")
s=s.lower()
l=list(s)
print(s)
cnt=0
cnta=0
cnte=0
cnti=0
cnto=0
cntu=0
for i in l:
if i=='a':
cnt+=1
cnta+=1
elif i=='e':
cnt+=1
cnte+=1
elif i=='i':
cnt+=1
cnti+=1
elif i=='o':
cnt+=1
cnto... |
8eb32ac753934c1c224623771c3f05670581ae3d | Bower312/Tasks | /task3/task3-2.py | 220 | 3.8125 | 4 | bazar=int(input("Введите количество яблок "))
chel=int(input("Количество человек "))
a=bazar//chel
b=bazar-(a*chel)
print("каждый получит по", a,"остаток", b) |
7a5730492eaa3451c5e7cb705ba50f46fe7a45cb | kjh950711/Coding-Test | /venv/Coding-Test/Practice/programmers/Sorting/ex2_biggestN.py | 466 | 3.65625 | 4 | # https://programmers.co.kr/learn/courses/30/lessons/42746
def solution(numbers):
answer = ''
check = {}
i = 0
for num in numbers.copy():
numbers[i] = str(num)
i += 1
numbers.sort(key=lambda x:x*3, reverse=True)
for i in numbers:
answer += i
answer = str(int(answer))... |
17d3d2cdb2b8f2d21bd1244011222c75a416fd9e | NarenneraN/Python_Beginner_Works | /Snake_Game/scoreboard.py | 1,300 | 3.890625 | 4 | from turtle import Turtle
class Score(Turtle):
def __init__(self):
super().__init__()
self.score = 0
with open("score.txt") as score_file:
self.high_score=int(score_file.read())
self.color("white")
self.hideturtle()
self.penup()
self.update_score()
... |
22293a82382ecc8125364f9cf7d1eb728427afbc | cravo123/LeetCode | /Algorithms/0448 Find All Numbers Disappeared in an Array.py | 403 | 3.5625 | 4 | # Solution 1, simulation
# it is common trick to use negative numbers to mark if we visit this position before
class Solution:
def findDisappearedNumbers(self, nums: List[int]) -> List[int]:
for i in range(len(nums)):
v = abs(nums[i])
nums[v - 1] = - abs(nums[v - 1])
... |
a0b94baff8ec56f076449d9bfcaf5563443fb370 | abriggs914/Coding_Practice | /Python/Pandas/pandas_merging_review.py | 1,756 | 4.5 | 4 | #import codecademylib
import pandas as pd
#WORKING WITH MULTIPLE DATAFRAMES
# Review
# This lesson introduced some methods for combining multiple DataFrames:
# Creating a DataFrame made by matching the common columns of two DataFrames is called a merge
# We can specify which columns should be matches by using the keyw... |
60ad04ea2110807becef454f2140b82eb74b94ad | rbiswas4/utils | /plotutils.py | 7,392 | 3.828125 | 4 | #!/usr/bin/env python
"""
module to help in plotting.
Functions:
inputExplorer: slider functionality to help in exploring functions
drawxband : drawing shaded regions of specific width around a value,
helpful in ratio/residual plots
settwopanel : returns a figure and axes for two subplots to show the
fun... |
5a9507f1c70a9a52c59837cf0044a90ea39d8443 | tferguson14/Time-Series-Modeling-Class-Assignments | /Lab # 3 - Taisha Ferguson.py | 4,900 | 3.59375 | 4 | # Import Packages
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from statsmodels.tsa.stattools import adfuller
# 3 - Create white noise with zero mean and standard deviation of 1 and 10000 samples
X = 1*np.random.randn(10000) + 0
# 4 - Write Python Code to estimate Autocorrelation Function
de... |
d98228ac3be04cde8a5b145afcddfb74e8df2dd4 | boa50/disaster-response | /app/charts.py | 3,123 | 3.546875 | 4 | import re
import pandas as pd
from plotly.graph_objs import Bar, Pie
def request_offers_comparison(df):
"""Create a pie chart comparing the number of requests and the number
of offers.
Arguments:
- df (Dataframe): The dataframe to extract data from
Returns:
- dict: A dictionary with the ... |
05b40c2791d3d14d8fdf15660c67f9ba9e1711a6 | fanmo04/Pacman | /PacMan_project/Search1.py | 2,317 | 3.828125 | 4 | class PacmanProblem1:
# grid is a 2D array
# pacman & ghost are tuples (r,a)
def __init__(self, grid, pacman, ghost):
self.grid = grid
self.rows = len(grid)
self.columns = len(grid[0])
self.pacman = pacman
self.ghost = ghost
# Since this problem require... |
3b9e0e60f1181e097b38eaf930c4a8faf1c12e1c | Aasthaengg/IBMdataset | /Python_codes/p03556/s456912043.py | 140 | 3.640625 | 4 | def actual(N):
for i in range(1, 10 ** 9 + 1):
if i ** 2 > N:
return (i - 1) ** 2
N = int(input())
print(actual(N)) |
0c944fc996fb1170bbcce10e26ec6fd9dcf15c80 | Dhivya-Ra/star | /sev.py | 59 | 3.671875 | 4 |
x = int(input(" "))
for a in range (0,x):
print("hello")
|
a91eee9484e956f8b269238d1225b79083db7943 | kazuo-mu/at_coder_answers | /ABC134/e_sequence_decomposing.py | 452 | 3.578125 | 4 | import bisect
from collections import deque
N = int(input())
tops = deque()
for i in range(N):
a = int(input())
p = bisect.bisect_left(tops, a)
if p == 0:
# bisect.insort_left(tops, a)
# Atcoder上だとエラーになる??
# appendleftしてもソート順は崩れないので、こっちの方が良い
tops.appendleft(a... |
16894423d526f2c3ffde4f4883c62431b5119205 | nitinmundhe/python_practice | /bin/day3/scopes_ex.py | 1,056 | 4.0625 | 4 | # Global namespace and each function will have its own namespace
x = 10 # Global Scope
def f1():
x = 20 # Enclosed Scope
def f2():
# global x
# nonlocal x
x = 30 # Local Scope
global y
y = 200
print('f2 x =', x)
f2()
print('f1 x =', x)
f1()
print(... |
e5b44ffa67e2dffe79384ee1d61bfa678ba1d18d | bjornsone/darwin | /environment.py | 6,686 | 3.5 | 4 | import logging
import matplotlib.pyplot as plt
import numpy as np
import plant
class Environment(object):
"""
Tracks each location in a 2D environment and defines the parameters of the environment.
"""
given_energy_per_cycle = 40
taken_energy_per_cycle = 20
energy_per_cell = 8
energy_per_... |
491f6be0dc08176d711ee420863a5a80412e03ca | lbh2001/cs61a-1 | /Quiz, Midterms, Finals/cs61a-summer-2020-midterm/q6/q6.py | 2,584 | 4.3125 | 4 | email = 'aunghtetpaing@berkeley.edu'
def elevator(speech, coffee):
"""
Write a function `elevator` that takes in two lists.
`speech` is a list of strings
`coffee` is a list of integers
It returns a new list where every element from `speech` is copied the
number of times as the correspo... |
c73d8124ba9f20888224a9570d0421a5c77f51a6 | basakmugdha/Python-Workout | /1. Numeric Types/Excercise 2 (Summing Numbers)/Ex2b_average.py | 292 | 3.8125 | 4 | #using the splat * operator here
def myavg(*numbers):
result = count = 0
for num in numbers:
result += num
count += 1
return result//count
print(myavg(12,89,0,6))
#prefacing the argument list with a * splits it into separate arguments
print(myavg(*[12,89,0,6]))
|
9c8541b7fdfbe2e7bdc04d4a994255cf622da5b2 | IamAmeySalvi109/consultaddassignment | /Assignment_2/Assignment_2_Part_2.py | 332 | 4.125 | 4 | x = range(1,21)
even = []
odd = []
for n in x:
if n%2==0:
even.append(n)
else:
odd.append(n)
print("The pair of numbers whose sum is equal to even number are:")
for i in even:
for j in even:
print(("({},{})".format(i, j)), end=", ")
for i in odd:
for j in odd:
print(("({},{})".format(i, j... |
91a712961cbd6bfd8c8ec3de6629d178d6e0b62e | Slackd/python_learning | /First/if_else.py | 616 | 4.34375 | 4 | is_male = False
is_tall = True
if is_male and is_tall:
print("You are a tall male")
elif is_male and not (is_tall):
print("you are a short male")
elif not (is_male) and is_tall:
print("you are not a male, but are tall")
else:
print("you are neither male not tall or both")
num1 = input("Enter 1st N... |
ddb9ebd1a7beb20c4a89eb0d28a0a7972925cef3 | steveayers124/PythonStandardLibraryEssentialTraining | /Ex_Files_Python_Standard_Library_EssT/Exercise Files/Chapter 4/04_06/stats_finished.py | 1,528 | 4.09375 | 4 | # using Python statistics functions
import statistics
import csv
import array
# simple statistics operations
sample_data1 = [1, 3, 5, 7]
sample_data2 = [2, 3, 5, 4, 3, 5, 3, 2, 5, 6, 4, 3]
# Use the mean function - calculates an average value
print(statistics.mean(sample_data1))
# Use the different median functions... |
3b47182a1808233ba8bf725a150f77c7c07776b7 | jaelyndomingo/STEMNight_MazeTutorial | /game_play.py | 1,188 | 3.859375 | 4 | from pygame.locals import *
import pygame
import maze_setup
def main():
# Here is where you will insert your character and block art images
player = "Images/Santa-1.png.png"
block = "Images/Box-1.png.png"
prize = "Images/Cookies-1.png.png"
# This is how to initialize our Maze Game
Maze = maz... |
35dc63ba8f37dfa2408e2b14fba3c951735051ec | SitaramRyali/SDCND_Particle_Filters | /Particle_Filters_in_python/move_robot_nonoise.py | 625 | 3.515625 | 4 | from robot_class import robot,eval
from math import *
import random
myrobot = robot()
##set a position of the robot
#myrobot.set(10.0,10.0,0.0)
#starts at coordinates 30, 50 heading north (pi/2).
myrobot.set(30.0,50.0,pi/2)
print(myrobot)
print(myrobot.sense())
##move the robot 10m forward
#myrobot = m... |
779d9ff3c16a7f37f8ac010657fccaec4a857077 | zjcszzl/PythonAndMachineLearning | /DirectedGraph.py | 3,695 | 3.921875 | 4 | import collections
class Node:
def __init__(self, v):
self.val = v
self.next = None
class Graph:
def __init__(self):
self.nodes = dict()
self.edges = dict()
# add Node()
def addNode(self, val):
node = Node(val)
self.nodes[val] = node
self.edge... |
54c2803047dfcbe447df445947a98e6251255bc9 | ongsuwannoo/PSIT | /Taxi.py | 798 | 3.78125 | 4 | ''' Taxi '''
def main(miter, result, time, ans):
"""Find Baht Miter"""
while miter != 'F':
miter = miter.split()
if miter[0] == 'K':
result += int(miter[1])
else:
result += int(miter[2])
time += int(miter[1])*1.5
miter = input()
... |
018dfb11c4b8ffe1f2d52dfcb98acda94cac3615 | CarpioVargas/InteligenciaArtificial | /Python/burbuja.py | 677 | 3.625 | 4 | from time import time
lista = [40, 19, 10, 1, 2]
#inicia tiempo de ejecucion
tiempo_inicial = time()
def ordenamientoBurbuja(lista):
""" Ordenar una lista utilizando el metodo de Burbuja """
for i in range (1, len(lista)):
# Scanea la lista, quitando los valores ya ordenados
for j in range (len(lista) - i):
... |
7854fac2668f4fb5cb1e8ff450a7dfa8e8e0d4fc | JosevanyAmaral/Exercicios-de-Python-Resolvidos | /Exercícios/ex070.py | 985 | 3.71875 | 4 | total_Gasto = maisde_1000 = mais_Barato = 0
nome_Maisbarato = ''
print('-' * 40)
print(f'{"CANTINA DO MAMADÚ":^40}')
print('-' * 40)
while True:
nome_Produto = str(input('Nome do Produto: ')).strip().title()
preco = float(input('Preço: R$'))
total_Gasto += preco
if preco > 1000:
maisde_1000 += 1... |
ee040035d4974301aa8d1ec757925163891bd826 | swayamshreemohanty/Python | /Find_Average_of_10_Numbers(Using_For-Loop).py | 464 | 4.15625 | 4 | #Take 10 numbers from the user and find average value of the entered number using WHILE LOOP
sum=0
limit=10
number=1
#This FOR-LOOP statement helps the loop to run 10 times
for i in range(limit):
#Here user will input the numbers for 10 times
userinput=int(input("Enter no %d: "%number))
#Algorithm lines (12,13,1... |
ba1349cef06828f41ad755d0d79f2caeb1a3439d | xieziwei99/py100days | /day01_15/multi/multiprocessDemo2.py | 529 | 3.515625 | 4 | """
Created on 2019/6/18
父进程在创建子进程时复制了进程及其数据结构
@author: xieziwei99
"""
from multiprocessing import Queue, Process
from time import sleep
def sub_task(name, q):
while not q.empty():
num = q.get()
print('%d: %s' % (num, name))
sleep(0.001)
def main():
q = Queue(10)
for num in range(1, 11):
q.put(num)
# 两个... |
0e33b50ead53bbd75c7d4b93251f22d1412a3d31 | stradtkt/Tkinter-messagebox | /message_box.py | 590 | 3.5625 | 4 | from tkinter import *
from PIL import ImageTk, Image
from tkinter import messagebox
root = Tk()
root.title("Learn to code at gowebkit.com")
root.iconbitmap("c:/gui/gowebkit.ico")
root.geometry("200x200")
# showerror, showwarning, askquestion, askyesno
def popup():
response = messagebox.askquestion("This is my p... |
58e10bb963fc90b2651b2b8faf36e5d7bbe874c8 | namani-karthik/Python | /Arth_op.py | 367 | 4.03125 | 4 | a=int(input('Enter first number:'))
b=int(input('Enter second nnumber:'))
print('Addition of two numbers:', a+b)
print('Substraction of two numbers:', a-b)
print('Multiplication of two numbers:', a*b)
print('Division of two numbers:', a/b)
print('Power of %d to %d is:%d'%(a,b,a**b))
print('Floor Division of two numbers... |
3ac636832132f1c4e386e522ee16850251ec7525 | chrislimqc/NTU_CompSci | /CZ1003/cz1003_tutorial/cz1003_tut10-2.py | 856 | 3.65625 | 4 | import re
myfile = open('cz1003_tut10-2.txt', 'r')
count_symbol = 0
count_number = 0
count_upper = 0
count_lower = 0
count_word = 0
count_space = 0
for i in myfile:
i = i.replace('\r', '')
i = i.replace('\n', '')
count_word += len(i.split())
print(i)
for character in i:
if character.isdig... |
3d35650bf404cde8e61cbe8fb5b113ae56d410e6 | aaronbushell1984/Python | /Day 4/q3.py | 285 | 4.0625 | 4 | def countWords(stringOfWords):
stringOfWords = stringOfWords.lower()
words = stringOfWords.split()
wordsEndROrS = 0
for word in words:
if word.endswith("r") or word.endswith("s"):
wordsEndROrS = wordsEndROrS + 1
return wordsEndROrS |
b3a3a75146e913034750b5bfeb1d06ca830ab7a5 | taisei-kito/hello-world | /hello.py | 55 | 3.5625 | 4 | str = "Hello" + " " + "World"
print(str)
print("seeU")
|
a2f2152fed09dc64d1a5b89885e7e3bd1ea1f183 | lianghp2018/PycharmDemo | /文件操作/07_文件操作.py | 632 | 4.0625 | 4 | """
1. 导入模块 os
2. 使用模块内功能
"""
import os
# rename(): 重命名
# os.rename('2.txt', '1.txt')
# os.rename('aa', 'aaaa')
# remove():删除文件
# os.remove('1_copy.txt')
# mkdir():创建文件夹
# os.mkdir('aa')
# rmdir():删除文件夹
# os.rmdir('aa')
# getcwd()获取当前文件夹
# print(os.getcwd())
# chdir():改变目录路径
# 在当前目录下创建文件夹
# os.mkdir('aa')
# os.mk... |
4de67580671b4df639471ff34d5bfe8fdf433743 | iccowan/CSC_117 | /Lab27 (BigLab08)/coins.py | 2,300 | 3.828125 | 4 | # Ian Cowan
# Lab Partner: Jake Pfaller
# CSC 117b BigLab08 Coins
# 19 Apr 2019
# Main File
# Import Dependencies
from graphics import *
from Coin import Coin
# Define initWindow()
# Inputs:
# NONE
# Outputs:
# Window win
def initWindow():
# Create the window and set the coordinates
win = GraphWin("100 Co... |
8f1303cb135098ab44238ea84f0cad9e7f179080 | NicoleGruber/AulasPython | /Aula05/Aula5.2.py | 982 | 4.15625 | 4 | # 2 -
# Mercado Tech ----
# Solicitar nome do funcionario
# Solicitar idade
# Informar se o funcionario pode adquirir produtos alcoolicos
# 3 -
# Cadrastro Produtos Mercado Tech
# Solicitar o nome do produto
# Solicitar a categoria do produto (Alcoolicos e Não Alcoolicos)
# Exibir o produto cadastrado
nome = input('D... |
50e383e87982215ca12a2140636c983614c3e6b5 | NoubotElbot/PalindromoIndex | /palindromo.py | 697 | 3.890625 | 4 | """
Retorna el indice de un caracter de la cadena que al removerse convertiría la cadena en un palindromo
Ej:
I: aaaad
O: 4
En el caso que ya sea un palindromo o no tenga solución retorna -1
"""
def palindromenindex(cadena):
inversa = cadena[::-1]
indice = 0
aux = cadena
while(indice < len(cadena)):... |
3519a553321acdc2434ac590948a914a6079cac1 | kevinarmdiaz/ProblemSolvingwithAlgorithmsandDataStructures | /anagram.py | 1,054 | 3.796875 | 4 |
def anagram_solution1(s1,s2):
a_list = list(s2)
pos1 = 0
still_ok = True
while pos1 < len(s1) and still_ok:
pos2 = 0
found = False
print(a_list)
while pos2 < len(a_list) and not found:
if s1[pos1] == a_list[pos2]:
found = True
... |
03b52cddd014e99ec6579fedea0ae845532a3014 | JohnSarancik/Wolfram_CA | /wolfram_ca.py | 2,590 | 3.640625 | 4 | # install Pygame Zero with: pip install pgzero
# docs: https://pygame-zero.readthedocs.io/
import pgzrun
import math
WIDTH = 800 # window dimensions
HEIGHT = 600
def decimal_to_binary(num):
return [int(d) for d in bin(num)[2:]] # list comprehension for binary number
decimal_val = int(input("Enter a number:... |
04c954d43031d66f2b0e201a143870baf7e60657 | aeogunmuyiwa/csc-361 | /smtpclient (1).py | 2,148 | 3.703125 | 4 | from socket import *
msg = "\r\n I love computer networks!"
endmsg = "\r\n.\r\n"
# Choose a mail server (e.g. Google mail server) and call it mailserver
mailserver =("smtp.uvic.ca",25)
# Create socket called clientSocket and establish a TCP connection with mailserver
clientSocket=socket(AF_INET,SOCK_STREAM)
host=ma... |
4111a4b628816267b0b525ae0d64d1d849236251 | bala4rtraining/python_programming | /python-programming-workshop/functions/5.default_args_in_functions.py | 254 | 3.96875 | 4 |
#Python program that uses default arguments
def computesize(width=10, height=2):
return width * height
print(computesize()) # 10, 2: defaults used.
print(computesize(5)) # 5, 2: default height.
print(computesize(height=3)) # 10, 3: default width.
|
982760fc8bd582586e6990b37fb60c3442456020 | ManuelLG92/Python | /funcions/globales.py | 328 | 3.6875 | 4 | animal = "Leon" #globales, fuera de las funciones
def m_animal():
#animal = "Cat" en py dentro de una funcion si se declara una variable local sera diferente a la hlobal asi sean iguales
global animal #asi podremos modificar la variable global
animal='Cat' # y aqui asignamos su valor
print(animal)
m_... |
f0c05467a5006b285d44107cec93f60fe3f779ed | Kcpf/MITx-6.00.1x | /Week 4-Good Programming Practices/simple_divide.py | 1,181 | 3.796875 | 4 | # =============================================================================
# Exercise: simple divide
#
# Suppose we rewrite the FancyDivide function to use a helper function.
#
# def fancy_divide(list_of_numbers, index):
# denom = list_of_numbers[index]
# return [simple_divide(item, denom) for item in list... |
c3bdc035ee96a35854d33be9f4667de39fcd0a4d | xu-robert/Leetcode | /4sum II.py | 2,489 | 3.5 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Dec 17 09:55:25 2020
Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero.
To make problem a bit easier, all A, B, C, D have same length of N where 0 ≤ N ≤ 500. All integers are in the range ... |
16f2935c4b30d4baac78019eb6df9c4c910148d6 | vt0311/python | /ex/ex1418.py | 262 | 3.71875 | 4 | '''
Created on 2017. 10. 30.
@author: acorn
'''
import re
mystr = 'abcd 1234 abAB'
regex = '[a-d]+'
pattern = re.compile(regex)
# findall
mylist = pattern.findall(mystr)
print(mylist)
myiter = pattern.finditer(mystr)
for abcd in myiter :
print( abcd) |
063cf07716b2fc23bd5e06327b71500ff9d310d3 | dicryptor/FirstRepo | /VMP_FIFO_v2.py | 521 | 3.578125 | 4 | import random
rand_list = random.sample(range(10), 6) # Random numbers to test VMP
mem_slot = 4
alist = [] # FIFO store simulate 4 pages
# Programmatically create empty memory slots
for i in range(mem_slot):
alist.append(-1)
print('List of items: ', rand_list)
print('Memory slots: ', alist)
def fifo():
i = ... |
a044a52f3aeffac16310d7cc7defbe5a7457a7f5 | dhruv-rajput/Basic_Inventory-Management-System | /Input.py | 3,683 | 4.21875 | 4 | from Products import *
def add_a_product():
id = int(input("Enter id of product "))
name = input("Enter name of product ")
value = int(input("Enter value of product "))
packaging_quantity = int(input("Enter packaging quantity od product "))
pro = Product(id, name, value,packaging_quantity)
... |
d41e95738dd7de617677e0c58b6bcb7d9f57222b | digdeeperisay/programming_data_analysis_udacity | /Weather Trends/Explore Weather Trends.py | 3,890 | 3.53125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Dec 5 19:55:43 2019
@author: Prajamohan
Purpose: Plotting Weather trends as part of the Data Analyst course on Udacity
High level steps:
Download the CSV files for the entire world and interested cities
Compare and understand range of years in each etc.
Pl... |
36836c4b9ca09dc168916f8c56439f1743437813 | neuxxm/leetcode | /problems/263/test.py | 345 | 3.671875 | 4 | #20:38-20:40
def f(x):
if x%2 == 0:
return f(x/2)
if x%3 == 0:
return f(x/3)
if x%5 == 0:
return f(x/5)
return x == 1
class Solution(object):
def isUgly(self, num):
"""
:type num: int
:rtype: bool
"""
if num <= 0:
return Fal... |
782ec46231b32d0517729b8f57e26372bd851140 | SBrman/BLU_stuff | /CHAPTER 2/Exercise/find_all_path_fromNode_toNode - best.py | 1,988 | 3.75 | 4 | #! python 3
"""Chapter 2 -- exercise 14"""
from math import inf
class Network:
def __init__(self, N, A):
self.N = {i: node for i, node in enumerate(N)}
self.A = {tuple((i, j)) for i, j in A}
self.h = set()
def forward_star(self, node_index):
"""Returns the ... |
cb9b4372f475e3c9e802d15c8e4b748e1673b7fa | supercavitation/Compsci | /recent sorting stuff/nearlySortedList.py | 520 | 3.53125 | 4 | import numpy.random as nprnd
from time import clock
def r_step_generator(lo, hi):
num = lo
while True:
num += nprnd.randint(0, 100)
if num < hi:
yield num
else:
raise StopIteration
N = 10 ** 3
t1 = clock()
u = range(0, (N // 100) * 99)
x = nprnd.randin... |
3e95804c97239f8ddb289c24a4ecaf323a63bfa0 | jashasweejena/scripts | /mac_convert.py | 252 | 3.5 | 4 | import pyperclip
import sys
mac = sys.argv[1]
converted = " "
length = len(mac)
x = 0
for i in range(0, length, 2):
converted = converted + ":" + (mac[x:i])
x = i
final = converted[3 : len(converted)]
print(final)
pyperclip.copy(final)
|
d7a64f1495c952f9c176513169104d302c095fd4 | jed1-sketch/Pythontrends | /keylogintest.py | 2,187 | 4.03125 | 4 | def loGtest():
user_key = {'kelvin@gmail.com': 5, 'blue': 1, 'red': 2, 'yellow': 3}
passKey = {5: 'rt'}
pkey=0
# this gives the set of keys and values that can be displayed for the administrator to see about login details
d = user_key.keys()
f = user_key.values()
pr... |
e5585a7907884e4fc26f55245f3d317d96cc364f | cnovoab/coding-interview | /udemy-11/7.minesweeper_expand.py | 643 | 3.734375 | 4 | #!/bin/python
def click(board, rows, cols, click_x, click_y):
board = [[0 for col in range(cols)] for row in range(rows)]
for bomb in bombs:
(x, y) = bomb
print "({}, {})".format(x, y)
board[x][y] = -1
for i in range(x -1, x + 2):
for j in range(y - 1, y + 2):
... |
7873abfc56116d5a6aea78ef96899e34e91abbb3 | leinefran/project-euler | /3-find_prime_factor.py | 274 | 3.84375 | 4 | #!/usr/bin/python2
"""
A function to find the largest Prime Factor of the number n.
"""
def find_max_prime_factor():
n = 600851475143
i = 2
while i * i < n:
while n%i == 0:
n = n / i
i = i + 1
print (n)
find_max_prime_factor()
|
183e0029b027ddbf5ee73fda88e696a786fd9ec3 | gautamsbaghel/ml_prediction_projects | /coronaprediction/myTraining.py | 857 | 3.546875 | 4 | import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
import pickle
if __name__=="__main__":
#read data
df=pd.read_csv('corona_dataset.csv')
#split dataframe
X = df.iloc[:,:5].values #values is used to convert ... |
2406087dc39754005a7f5106e747d877a6990eb4 | lokeshraogujja/practice | /marks_totext.py | 241 | 3.671875 | 4 | # accept marks from user and return them to file named marks
f = open("marks.txt", "wt")
while True:
n = (input("Enter Marks (Enter -1 to Stop) : "))
if n == "-1":
break
else:
f.write(n + "\n")
f.close()
|
752fa90affe6826068d33edafec7984cba0fbe75 | Jason9789/Python_Study | /week5/while_loop.py | 1,220 | 3.78125 | 4 | import time
sum = 0
print('1부터 10까지의 합')
i = 1
while i <= 10:
sum += i
if i < 10 :
print(i, '+ ', end='')
else:
print(i, '= ', end='')
i += 1
print(sum)
number = 0
# 5초 동안 반복합니다.
# target_tick = time.time() + 5
# while time.time() < target_tick:
# number += 1
# print("5초 동안 {... |
0ef7c971fe7810463d55b2342c06a8347151d5e1 | Lucces/leetcode | /385-Mini-Parser/solution.py | 2,971 | 4.125 | 4 | # """
# This is the interface that allows for creating nested lists.
# You should not implement it, or speculate about its implementation
# """
#class NestedInteger(object):
# def __init__(self, value=None):
# """
# If value is not specified, initializes an empty list.
# Otherwise initializes a ... |
4bfe33a0cbe44424c237331d96fc17c372c422be | Daniela-Villanueva/1684742-MatComp | /Fibonacci (Memoria).py | 443 | 3.53125 | 4 | Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> D={}
>>> cnt=0
>>> def fibonacci(n):
global D, cnt
cnt+=1
if n==0 or n==1:
return(1)
if n in D:
return D[n]
else:
val=fibonacci(n-2)+fibon... |
33105419cbada6eb8b54a848f81125e149dbce73 | SA253/python-assignment | /Python/modules/regular expression/first.py | 1,295 | 4.09375 | 4 | import re
pattern="zomato"
#text="does this text match the pattern?" #ans:none ,not found
text="zomatonn" # ans: <re.Match object; span=(0, 6), match='zomato'> , found match
print(re.search(pattern,text))
if re.search(pattern,text):
print("found match")
else:
print("not found")
... |
292808920c7c7fb6d230811efb0766dace003dae | Leonardo220389/Deber | /Deber1/Codigo2/Ciclo.py | 621 | 4.09375 | 4 | class Ciclo:
def __init__(self, numero=5):
self.numero=numero
self.numero2=0
def usowhile(self):
#ciclo repetitivo que se ejecuta mientras la condicion se cumple(verdader)
#es decir sale por falso
car=input("Ingrese vocal:")
car= car.lower()#transforma a minuscula... |
e405b04078b9980bd66b79617707bf12e98a0a2d | mbcaira/POS-system | /POS.py | 4,332 | 3.609375 | 4 | import Item
import Membership
import Receipt
# Initialize inventory
Inventory = []
inventoryFile = open("Inventory.txt", "r")
for i in inventoryFile:
Inventory.append(i)
# Remove inventory text headers from inventory array
Inventory.pop(0)
# Generate an array of Item objects for convenience during t... |
b37352fe13b699c8c8e9d9f92adcd9731de42044 | mehranaman/Intro-to-computing-data-structures-and-algos- | /Assignments/DNA.py | 1,716 | 3.78125 | 4 | #File: DNA.py
#Description: Computing the largest pair of similarity in a pair of DNA seqeunce.
#Name: Naman Mehra
#UTEID: nm26465
#Course name: CS303E
#Unique number: 51850
#Date created: March 28th, 2017
#Date last modified: Feb 24th, 2017
def main():
in_file = open("/Users/NamanMehra/Documents/CS303E/HW/Assign... |
5d8ec547cefd464fb662bf21a0b40a70f9c7a039 | taibon38/python_sample | /src/c3/sort-animal-dict.py | 327 | 3.609375 | 4 | # 辞書型で動物:最高時速を表したもの
animal_dict = {
"ライオン": 58,
"チーター": 110,
"シマウマ": 60,
"トナカイ": 80
}
# 時速で並び替えて表示
li = sorted(
animal_dict.items(),
key=lambda x: x[1],
reverse=True)
for name,speed in li:
print(name, speed)
|
eb3d18f69655d2433196b63caab09e664faa8b2d | Huxhh/LeetCodePy | /common_methods/py_quicksort.py | 2,395 | 3.703125 | 4 | # coding=utf-8
"""
快速排序的几种实现方法
"""
# 第一种,一行实现
quick_sort = lambda array: array if len(array) <= 1 else quick_sort([item for item in array[1:] if item <= array[0]]) + [array[0]] + quick_sort([item for item in array[1:] if item > array[0]])
# 第二种,常见实现,两次循环
def quick_sort_double_loop(array, begin, end):
if begin ... |
afe8de2f9cce4cb041447238e258204c2a3d5253 | gexiaojing/tongji2 | /zy4.1.py | 5,241 | 3.84375 | 4 | 1.
class Rectangle(object):
def __init__(self,width=1,height=2):
self.width=width
self.height=height
def getArea(self):
return self.width*self.height
def getPerimeter(self):
return (self.width+self.height)*2
def mai... |
f6184bb18b698d5b308c293b7cc5d8e64e57cd6c | wesleyhodge/vsa-programing | /wes.py | 3,226 | 4.0625 | 4 | import random
name=raw_input("what is your name?")
name=name.lower()
print "hello " + name + ", pleased to meet you."
hayd=raw_input("how are you? (good, bad, ok, awesome, horrible)")
hayd=hayd.lower()
if hayd=="good":
print "I am glad you are having a good day"
elif hayd=="bad" or hayd=="horrible":
print "that... |
f3e85847ec3fcb582a06758f21d5ca53560fef16 | Ravin-Karthika-C-R/Python | /CO1/over_5.py | 192 | 3.84375 | 4 | a=[]
n=int(input("enter the number of terms in list:"))
for i in range(n):
x=int(input("enter the numbers:"))
if x>100:
a.append("over")
else:
a.append(x)
print(a)
|
cdb17307c5b621e6f3a8130f195a3a195aeec7f7 | cristinast/100LanguageProcessing | /Section_Two.py | 6,514 | 3.765625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#第2章: UNIXコマンドの基礎
#count 10 行数のカウント
#just use to count small file
'''
count = len(open('hightemp.txt','rU').readlines())
'''
# for big file,use circulation to count numbers of line
'''
count = -1
for count,line in enumerate(open(r'hightemp.txt','rU')):
pass
cou... |
7e1e6aec096ade854e835d71b5c38d8ba3685d96 | himavardhank/PYTHON-PRACTICE-PROGRAMS | /programs-part@2/thread6.py | 308 | 3.65625 | 4 | import threading
import time
class X(threading.Thread):
def run(self):
for p in range(1,101):
#time.sleep(2)
print(p)
class Y(threading.Thread):
def run(self):
time.sleep(3)
for q in range(101,201):
print(q)
x=X()
x.start()
y=Y()
y.start()
|
52fe910981bfbf2a1e2d696441a62fc4acc16790 | Ardent-Mechanic/Tasks | /hard1.py | 1,504 | 4 | 4 | """Текстовый файл содержит строки различной длины. Строки содержат такие символы как: <=>.
Определите максимальное количество подстрок такого вида: ==>.
Пример. Исходный файл:
1. ===>==<==>==><>===<= Здесь 2 таких подстроки
2. <><>==>==<<<<==> Здесь 2 таких подстроки
3. <==<==<==> Здесь 1 таких подстроки
4. ==>==>===... |
b0d7a1a8d48e1216e52f8903b7f015d5b9aefeb8 | saisurajpydi/FINAL_SHEET_450 | /Final_450/Arrays/minMaxInArr.py | 516 | 4.03125 | 4 | """
arr = []
n = int(input("enter the size of the array : "))
for i in range(n):
arr.append(int(input()))
arr.sort()
print(arr)
#size = len(arr)
print("max elemnt is ", arr[len(arr)-1])
print("min elemnt is ", arr[0])
"""
arr = []
n = int(input("enter the size of the array : "))
for i in range(n):
arr.append(in... |
220b48442665acfc5645051ffad11963561a0d77 | L200180200/prak_algostruk | /L200180200_Modul1_G/Modul1(lanjutan1).py | 1,695 | 3.78125 | 4 | #No.6
lower = 2
upper = 1000
print("Bilangan prima dari",lower,"sampai",upper,":")
for num in range(lower,upper + 1):
if num > 1:
for i in range(2,num):
if (num % i) == 0:
break
else:
print(num)
#No.7
def faktorPrima(x):
a = []
b = ... |
2f50d4c1055ead029472c36a0b210f1e4c6f1388 | Dmitry1973/algorythms | /Less_4_temp/trial_div.py | 1,066 | 3.953125 | 4 | def trial_division(n: int) -> list:
a = []
while n % 2 == 0:
a.append(2)
n /= 2
f = 3
while f * f <= n:
if n % f == 0:
a.append(f)
n /= f
else:
f += 2
if n != 1:
a.append(n)
# Only odd number is possible
... |
fc2fd8a6459a258c1680e1753ff22363fccfcb28 | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/bob/b4cd143f3d4846f8a505e2bafc836933.py | 280 | 3.578125 | 4 | #
# Skeleton file for the Python "Bob" exercise.
#
def hey(what):
what_stripped = what.strip()
if what_stripped == '':
return 'Fine. Be that way!'
if what_stripped.isupper():
return 'Whoa, chill out!'
if what_stripped.endswith('?'):
return 'Sure.'
return 'Whatever.'
|
2be390ad872afaa1f05aa581b0dff60ad5455427 | MartinRomero2007/Python_Quantum | /Practica1/Hello.py | 171 | 3.953125 | 4 | def hello(nombre):
if nombre == str(name):
print(f'Hola {nombre}!')
else
print(f'Hola mundo')
name = str(input('Ingrese su nombre: '))
hello(name) |
dc8cb2a2782e489bac6a0ccfc1e75f534edca245 | AKSHAY-KR99/luminarpython | /test/test.py | 228 | 3.765625 | 4 | num1=int(input("Enter 1"))
num2=int(input("Enter 2 "))
c=0
for num in range(num1, num2+1):
for i in range(2, (num//2)+1):
if (num % i == 0):
c+=1
break
if(c==0):
print(num) |
6253ec7f874f1f3702d4b56303264a3031ea4cc2 | siddhanthaldar/deep_learning_codes | /tensorflow/MNIST_multilayered.py | 2,720 | 4.375 | 4 | #This is an implementation of digit recognition in the MNIST data set using tensorflow library. This
#code achieves this with the use of a neural network having three hidden layers.
import tensorflow as tf
import numpy as np
sess = tf.InteractiveSession()
from tensorflow.examples.tutorials.mnist import input_data
mn... |
d6a8e6041c54b4f402c619039234523d66e0d058 | soojihan/RPDNN | /src/context_features/propagation_features.py | 1,399 | 3.5625 | 4 | from collections import abc
from src.data_loader import load_structure_json
def looping_nested_dict(structure, depth=0):
"""
compute the depth of each tweet in a thread
:param structure: json which contains the structure of a thread
:param depth: the depth of each reply (source tweet's depth = 0)
... |
8dfb0ae388088764658dfa8e7cd9f5e0f6577499 | liu-allan/TimeTracker | /scratch_1.py | 434 | 3.921875 | 4 | import time
from threading import Thread
def timer():
count = 0
while True:
time.sleep(1)
count += 1
print("This program has now been running for " + str(count) + " minutes.")
background_thread = Thread(target=timer, args=())
background_thread.start()
while True:
print("Hello! We... |
1153e9c3418dca171b5598773807d6b82b6ed0dc | bingh0616/hackerrank | /contests/pythonist/classes_dealing_with_complex_numbers.py | 1,863 | 3.6875 | 4 | from math import sqrt
from sys import stdin
class Complex:
def __init__(self, real, imag):
self.real = real
self.imag = imag
def __add__(self, other):
real = self.real + other.real
imag = self.imag + other.imag
return Complex(real, imag)
def __sub__(self, other)... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.