blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
087e6cd3070ec412d576950f66881f1ee85ce62b | chalmerlowe/jarvis_II | /sample_puzzles/24_alpha_num_list/your_code_here_alpha_num_list.py | 896 | 3.78125 | 4 | # TITLE: alpha_num_list >> your_code_here_alpha_num_list.py
# AUTHOR: Chalmer Lowe
# DESCRIPTION:
# The file: alpha_num_list.txt contains a sequence of letters and numbers
# that may include duplicates.
# Deduplicate the sequence and identify the item at the 42nd position
# position, counting from zero. E... |
5a7d13487a5d16ddd4806dc3b3e799cbd758dbe8 | chalmerlowe/jarvis_II | /sample_puzzles/18_rising_numbers/aidan_empty_rising_numbers.py | 1,188 | 3.96875 | 4 | # TITLE: rising numbers >> empty_rising_numbers.py
# AUTHOR: Chalmer Lowe
# DESCRIPTION:
# Identify and sum all the numbers in the file that have a
# "rising numerical pattern": meaning for each digit in the
# number, the digit is either equal to OR greater than the
# preceding digit (in this order: 0, 1, 2... |
2176dad189a22439442754ac38fb3d20da5ad0db | chalmerlowe/jarvis_II | /sample_puzzles/03_war_of_the_worlds/your_code_goes_here.py | 1,272 | 3.71875 | 4 | # TITLE: 03_war_of_the_worlds >> your_code_goes_here_wotw.py
# AUTHOR: Chalmer Lowe
# DATE: 20181231
# DESCRIPTION:
# In this puzzle, you will be given a file (war_of_the_worlds.txt) that contains
# the text of H. G. Wells' "War of the Worlds" (via Project Gutenberg).
#
# Below are five hash hexdigests and five in... |
66136c87288375ffb1d119fdd2ec3d733eab32fd | byteshiva/CS-4660 | /2019/Kopek_Constraint_Satisfaction/yield_and_all_different/queens.py | 3,251 | 3.5625 | 4 | # queens.py
# From Classic Computer Science Problems in Python Chapter 3
# Copyright 2018 David Kopec
#
# Modified by Russ Abbott (July, 2019)
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the ... |
2a2503e1aa50a07d97f2012be1b28b9ca18d7a0b | mzaldiadithya/Python | /Tugas Pertemuan 4/menghitung_nilai.py | 1,899 | 3.9375 | 4 | title = "Program Menghitung Nilai Matakuliah Praktek"
print(title.center(100))
print("=========================================================".center(100))
# Define Variable
nama_matkul = input("\nMasukkan Nama Matakuliah : ")
max_pertemuan = int(input("Masukkan Max Pertemuan : "))
kehadiran = int(input("Masukkan Ju... |
1fd757fc69e6e8e9579686e75d1bcfb628489c8a | RussellLuo/the-python-challenge | /solutions/level-4/solution.py | 929 | 3.6875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Puzzle page:
http://www.pythonchallenge.com/pc/def/linkedlist.php
Solution page:
http://www.pythonchallenge.com/pcc/def/peak.html
"""
import re
from urllib2 import urlopen
BASE_URL = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing='
def reques... |
0ca4dd5afcb21a801f9ee52abe27c5a97a975228 | niyaziso/pharmacy_count | /src/counting.py | 599 | 3.65625 | 4 | def counting(input_file):
pharmcount1 ={}
with open(input_file, "rb") as inp:
for i, line in enumerate(inp):
if i >0 :
sepline = line.split(",")
#print sepline
if sepline[3] not in pharmcount1:
pharmcount1[sepline[3]] = [0, ... |
9fcfdf8875a31fe2371e26fddcdce54b8d0b5a1c | HenryMoore13/Gas-Pump | /gas_pump.py | 3,206 | 3.96875 | 4 | from datetime import datetime
def get_payment():
print('-----------------------------------------------------------')
payment = input(
'\n\t1 Prepay\n\t2 Pay After\n\tQ Quit\n>>> ').upper().strip()
while not (payment == '1' or payment == '2' or payment == 'Q'):
print('Invalid Choice... Ple... |
9468a316a31e4fa40ef40925884bdaee8e0e974f | volmaletc/Python-Core | /calculation of project payback.py | 12,064 | 3.59375 | 4 |
from tkinter import *
import tkinter.messagebox
import pprint
import matplotlib.pyplot as plt
win = Tk()
win.geometry('1200x800')
Investments = 0
Quantity_Of_Product = []
Cost_Per_Mounth = []
Price_Per_Mounth = []
Office_Rent = 0
Rent_Workshop = 0
SEO_Selary = 0
Accounter_salary = 0
Employee_salary= 0
Office_Rent_Li... |
7a7c0778660c800e1563f5ddae0bb86b007d66a4 | volmaletc/Python-Core | /CW/cw8/cw9-01.py | 801 | 4.1875 | 4 | # Напишіть скрипт, який обчислює площу прямокутника a*b,
# площу трикутника 0.5*h*a, площу кола pi*r**2.
# (для виконання завдання необхідно імпортувати модуль math,
# а з нього функцію pow() та значення змінної пі).
from math import pow, pi
def rectangle():
a_rectangle = 5
b_rectangle = 7
sq_rectang... |
6cdf10cb9c28c3c3a754bff4088602d0bcc4f0dd | volmaletc/Python-Core | /CW/cw3-1.py | 444 | 4 | 4 | #1. Роздрукувати всі парні числа менші 100
# (написати два варіанти коду: один використовуючи
# цикл while, а інший з використанням циклу for).
for i in range(2,100,2):
print (i)
else:
print("The end")
j = 2
while j < 100:
print(j)
j += 2
else:
print("The end")
for i in range(100):
if i % ... |
50461117852145bb0dbd957b4b6317804665a7b1 | arleyguerrero70/MachineLearningArlo | /PythonDesde0/comparadores.py | 218 | 3.734375 | 4 | print(5==5)
"""
Puedo comparar flotantes, strings, enteros...
!= y <> = En esta declaracion pregunto si es distinto
< = pregunto si es mayor
> = pregunto si es menor
<= = mayor o igual que
>= = menor o igual que
""" |
ae5e3b3650f4d51347b96631ba19cc9a04aaac76 | jc7553a/Hierarchical_Machine_Learning | /Miscellaneous_Functions.py | 1,007 | 3.515625 | 4 | def askQuestions(errors):
print("Do you want a visual graph? Type 0 for yes")
graph = int(input())
if graph == 0:
plt.plot(errors)
plt.show()
print("How many splits do you see?")
splits = input()
splits = int(splits)
splitsVals = []
for i in range(splits):
print("... |
c99d594f39fcd25a176a7f81ef2db87553a2e581 | MikeSmithLabTeam/labvision | /labvision/images/geometric.py | 2,668 | 3.625 | 4 | import numpy as np
import cv2
from .basics import *
from .colors import *
__all__ = ['resize', 'rotate', 'hstack', 'vstack']
def resize(img, percent=25.0):
"""
Resizes an image to a given percentage
Parameters
----------
img: numpy array containing an image
percent:
the new size of... |
bc4916c4eabbbbed5f0de31e85e46cfbf0557357 | MikeSmithLabTeam/labvision | /labvision/camera/quick_timer.py | 2,163 | 4.375 | 4 | from threading import Timer
import time
def time_in_s():
"""
Utility method that returns absolute time
"""
return time.time()
def datetimestr(format="%Y%m%d_%H%M%S"):
"""
Date and time string, formatted according to specifier.
:param format: keyword argument that specifies how
... |
5d3e517f7baffef8e135ca41f96deb4430e53337 | steven-rr/path-planning-autonomy | /hw2/p7_triag1.py | 10,815 | 3.546875 | 4 | # ////////////////////////////////////////////////////////////////////////////
# //|
# //| Author : Steven Rivadeneira
# //|
# //| File Name : p7_triag1.py
# //|
# //| Description : Solves a convex tangram puzzle using A*.
# //| Heuristic involves difference between centers of shapes.
# //|
# //| Notes : ... |
1b4bc3c85df37af5a6caa524d12e3ef5a5bbf951 | steven-rr/path-planning-autonomy | /hw2/lec11_example.py | 1,764 | 3.59375 | 4 | #define graph dictionary, key is node, values are nodes connected to key node and number is the associated cost.
#define heuristic cost, which is an estimated number on how close we are to the goal from the current node. higher number means we are farther away.
graph1 = {'S':[['A',2],['B',5]], 'A':[['D',4],['C',2]]... |
45308f30072b5d8d75a9af9b8162e724f5cc470a | anagorko/inf | /gcd/gcd.py | 327 | 3.71875 | 4 | """
Iterative and recursive computation of GCD (greatest common divisor), using Euclid's algorithm.
"""
def gcd_rec(a: int, b: int) -> int:
"""Compute greatest common divisor of a and b, recursive version."""
def gcd_iter(a: int, b: int) -> int:
"""Compute greatest common divisor of a and b, iterative versi... |
3b12fc2d54e016866e9219dcccfcbbeeeba95707 | anagorko/inf | /home/piotrn-j/anagram.py | 2,224 | 4.34375 | 4 | """Anagrams"""
def bucket_sort(given_word):
"""Bucket sort algorithm implementation"""
result = [0 for _ in range(127)]
result_final = []
for element in given_word:
result[ord(element)] += 1
index = 0
for element in result:
for _ in range(element):
... |
eb72a5701df0b699cda9a3b882406be320d0497a | anagorko/inf | /numeric/area.py | 544 | 3.875 | 4 | """
Zaimplementuj algorytm obliczania pola pod wykresem funkcji pisząc funkcję o sygnaturze
def area(f: Callable[[float], float], a: float, b: float, n: int) -> float:
gdzie f to dana funkcja, a i b to granice całkowania zaś n to liczba przedziałów w rozbiciu [a, b].
Proszę przetestować program i zmianę dokładności ... |
d74c76465d23e6f74ebdbb2aed0e1954effd345d | anagorko/inf | /home/piotrn-j/palindromes.py | 1,942 | 4.34375 | 4 | """Palindromes"""
import unittest
import random
def digits(num, divisor): # divisor is based on numeral system in which the given number is to be represented
"""Converts a number into a list of separate digits"""
bin_list = []
if num == 0:
return [0]
while num > 0:
... |
eb7dfdace3cda064fdc7b9eb47089ba9a6d8bd74 | anagorko/inf | /home/kmulinski/greedy_change.py | 676 | 3.984375 | 4 | import unittest
def greedy_change(income):
coins = [500, 200, 100, 50, 20, 10, 5, 2, 1]
change = []
for x in coins:
if x <= income:
change.append(income//x)
else:
change.append(0)
income = income % x
dictionary = {nominal: number for nominal, number in z... |
ddc1f6181bffa06e53b31d406142122bb2eb9c45 | anagorko/inf | /home/nagorko/greedy_change.py | 854 | 4.28125 | 4 | """
Finds a minimal number of notes/coins needed to make a change. A greedy algorithm is used.
"""
from typing import Dict
import unittest
COINS = [1, 2, 5, 10, 20, 50, 100, 200]
def change(amount: int) -> Dict[int, int]:
"""Find how many coins of each denomination we need to get given amount.
The total nu... |
f1e1a14b4f5ae7de324d7812eac738163c79b10d | WolvesWithSword/TATIA | /PreProcessing.py | 860 | 3.65625 | 4 | # nltk
from nltk import word_tokenize
from nltk.corpus import stopwords
from nltk.stem import WordNetLemmatizer
import string
PONCTUATION = set(string.punctuation)
STOP_WORDS = stopwords.words("english")
STOP_WORDS.extend(PONCTUATION)
def tokenize(text):
text = text.lower()
tokens = word_tokenize(text)
t... |
8298bc1bedc5685491f975cc8d52152d4da55819 | shuntucodes/pythonWorkshop | /conditional.py | 419 | 3.828125 | 4 | name = input ( 'What is your name ?')
if name=='Sandeep':
print('Welcome master')
else:
print('Identify yourself stranger')
secret=input("Solve this riddle, if you wanted to know a person's secret, who would it be :")
if secret=='victoria':
print('Nice bro, come on in')
e... |
ab153c6b1665b5d2903df59bc56991d926240907 | ChiaSang/Labs | /Python/Guess Number.py | 644 | 3.6875 | 4 | # _*_coding:utf-8_*_
import random
print("这个程序是一个猜数字的小游戏\n你有6次的机会\n")
secret = random.randint(0, 100)
print("请输入你要猜的数字\n")
score = 0
i = 0
while score != secret and i < 6:
score = int(input())
if score < secret:
print("你输入的数字小了")
elif score > secret:
print... |
14a2a65ad489ac0f8362a20e0d079f46afaaa5d4 | ChiaSang/Labs | /Python/isNumber.py | 223 | 4.125 | 4 | str1 = input("please type a str\n")
num = '0123456789'
flag = False
for c in str1:
if c in num:
flag = True
if flag:
print('this str included a num\n')
else:
print('this str excluded a num\n')
|
7c78a5c7e634415a5a911163ec8d703272fad40e | ChiaSang/Labs | /Python/studentManagment.py | 1,224 | 3.640625 | 4 | import sys
studentinfo = {}
studentName = []
print("学生管理系统 v0.1")
print("0退出系统")
print("1添加学生信息")
print("2删除学生信息")
print("3修改学生信息")
print("4查询学生信息")
print("-" * 20)
while True:
No = int(input("请选择功能\n"))
if No == 0:
print("退出")
sys.exit()
elif No == 1: # 做一个循环,依次输入信息。判断每次输入的字... |
cf4d888c35f911b4c516084260d83014e3022f26 | ChiaSang/Labs | /Python/is_palindrome.py | 321 | 3.71875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2017/7/21 13:57
# @Author : ChiaSang
# @Project : Python
# @File : is_palindrome
def is_palindrome(n):
if str(n) == str(n)[::-1]:
return n
else:
pass
output = filter(is_palindrome, range(1, 1000))
print(list(output))
... |
94470436bc85f760a9f6474c84acb8244169ee7f | rmncruz/Python_Tutorial | /HelloWorld/HelloWorld.py | 8,720 | 4.1875 | 4 | """Primeiro programa em python."""
# ---------------------------------------------------------------------
# The built-in function dir() is used to find out which names a module defines
#
# Usage: dir(HelloWorld)
# ---------------------------------------------------------------------
# print("Hello World")
import o... |
697caf10ab09eda9cc5b8f2cd2bc27a525bbf39f | Hituls07/SampleCodes | /BinomialDistribution.py | 1,186 | 4 | 4 | # import matplotlib.pyplot as plt
def factorial(num):
if num == 1 or num == 0:
return 1
else:
return num * factorial(num - 1)
def Combination(upper, lower):
result = (1 / factorial(lower))
for i in range(upper , upper-lower, -1):
result *= i
return result
def Binomia... |
49cfddf628e44a2d7a20ee58b629a5a9622fa4b6 | Don-George-Thayyil/algorithms | /array_adt.py | 1,435 | 3.59375 | 4 | import ctypes
class TheArray:
def __init__(self,size):
assert size > 0, "Array size must be greater than zero"
self._size = size
self._array_ = (ctypes.py_object * size)()
self.clear(None)
self._curindex = 0
def __len__(self):
return self._size
de... |
a214962296edbbd5c5019c4ad88a0c8e36a8b5e8 | Don-George-Thayyil/algorithms | /bubble_sort.py | 463 | 3.84375 | 4 | def bubble_sort(number_list):
comparable = 0
for i in range(len(number_list)):
for j in range(len(number_list)-1):
if number_list[j] > number_list[j+1]:
temp = number_list[j]
number_list[j] = number_list[j+1]
number_list[j+1] = temp
print... |
d4d373b1236f448376eef8f53575b74f0346f62b | jilias/Election_Analysis | /Python_practice.py | 3,193 | 4.34375 | 4 | print("Hello World")
counties = ["Arapahoe", "Denver", "Jefferson"]
if counties[1] == "Denver":
print(counties[1])
temperature = int(input("What is the temperature outside?"))
if temperature > 80:
print("Turn on the AC.")
else:
print("Open the windows.")
#Counties
counties = ["Arapahoe", "Denver", "Jeff... |
2a67ff0b6339f5eece51e30cbd22c70daad0a0d5 | A-Bougiouklis/trainApp | /trainApp/core/models/line.py | 1,098 | 4.09375 | 4 | '''
This class represent a train line with all the stations and the lines
that is connected with.
'''
class Line:
def __init__(self, line_name, initial_station, connected_lines):
self.name = line_name
self.stations = list(initial_station)
self.connected_lines = self._remove_self_... |
2e6e4c40b9d139e02021de3726339542ca0ad1a4 | Patrickyyh/CSCE110 | /lab5/q1.py | 1,203 | 3.859375 | 4 | # File: q1.py
# Author: Yuhao Ye
# Date: 07/03/2020
# Section: 529006730(UIN)
# E-mail: yeyuhao1234@tamu.edu
# Description:
# Take a text and prints the number of occurrences of eacht letter
line = input("Enter a Sentence: ").split()
print()
print("Sentence Statistics:")
letter_dict = dict()
count = 0
for word in lin... |
0cd54cf13c391cef910770cf0efd10d6cfa902cb | Patrickyyh/CSCE110 | /q5.py | 488 | 3.625 | 4 | # File: q5.py
# Author: Yuhao Ye
# Date: 06/13/2020
# Section: 529006730(UIN)
# E-mail: yeyuhao1234@tamu.edu
# Description:
# Take in the cost of the gas for the last five months and
#print out the average cost with two digits after the decimal point.
cost = input("Enter gas cost: ").split()
total = 0;
print()
for num... |
fbefaba647710c992843e075760d366b52cb9331 | Patrickyyh/CSCE110 | /plot/Barnsley.py | 1,366 | 4.15625 | 4 | import random
import matplotlib.pyplot as drawing
def fractal(iterations):
""" This function generates some points for the barnsley fractal """
x = 0
y = 0
x_axis = [x]
y_axis = [y]
for i in range(iterations):
# Generate a random number between 0 and 1 (Probability)
probability... |
4fa2793085b1f63a6847df65349fb0cf62510bfe | Patrickyyh/CSCE110 | /finalExam/10.py | 360 | 3.78125 | 4 | class Calculator:
def add(self,first_number,second_number):
return first_number +second_number
def subtract(self,first,second):
return first - second
def multiply(self,first,second):
return first * second
def divide(self,first,second):
return first * second
calculator = ... |
7643f321eefd315bf544097438d104db38b5c0fe | Patrickyyh/CSCE110 | /Lab6/q1.py | 1,892 | 4.09375 | 4 | # File: q1.py
# Author: yuhao ye
# Date: 07/10/2020
# Section: 529006730
# E-mail: yeyuhao1234@tamu.edu
# Description:
# check the validity of a password chosen by a user
#contain at least 1 letter between [A-Z],
#b) contain at least 1 letter between [a-z],
#c) contain at least 1 number between [0-9],
#d) contain at le... |
78824a91e9018e62a13af87542287b3c11230017 | Patrickyyh/CSCE110 | /quiz7/q6.py | 176 | 3.828125 | 4 | line = input('Enter a sentence: ').split()
with open('book.txt','w')as my_book:
for words in line[::-1]:
words = f'{words}\n'
my_book.write(words.upper())
|
426079ab894149c4881f07b4d9334405239ecd05 | Patrickyyh/CSCE110 | /numpy/test.py | 474 | 3.65625 | 4 | import numpy as numpy
import matplotlib.pyplot as plot
zero_array = numpy.zeros((1,5))
print(f'zero_array: ')
print(zero_array)
print()
one_array = numpy.ones((5,2))
print(f'one_array : ')
print(one_array)
print()
print(numpy.linspace(0,1, 20))
print()
list_x = numpy.linspace(0,numpy.sin(numpy.pi/4),20)
print(list)... |
18b0c4c4318b64d2d41cd8ea5235a5254f345fc0 | Patrickyyh/CSCE110 | /file/calculate_average.py | 619 | 3.625 | 4 | import os
print('Reading in the Data')
path = os.path.join('C:\\','Users','e3270','Desktop','CSCE110','file','mydata.txt')
## get current work directory
current_path = os.getcwd()
path_list = current_path.split(os.path.sep)
print(path_list)
## seperate the path into the tuple
current_path = os.getcwd()
print(os.path.... |
f5961d7e586ae681b14bc901e07a165d4417587d | Patrickyyh/CSCE110 | /algorithm/buble_sort.py | 560 | 4.21875 | 4 | def buble_sort(numbers):
"""This function sort a list using a bubble sort"""
n = len(numbers)
for i in range(n):
for j in range(n-i-1):
if numbers[j] > numbers[j+1]:
"""swap the number"""
print(f'checking the statue of bubles')
temp = numb... |
8a3853c9a8b81da469b6ea65472a4076c42b7f68 | Patrickyyh/CSCE110 | /List_test/list.py | 1,878 | 4.03125 | 4 | my_list = []
for num in range(10):
my_list.append(num)
my_seocndList = list(my_list)
for ele in my_seocndList:
print(ele,end = ' ' )
print()
if bool(my_seocndList) and bool(my_list):
print("Both of them have the elements")
else:
print("one of the them does nothave the value")
## List compehension
... |
a1386cda94e7e9ebe0226e76ecd70b285a1ac93b | Patrickyyh/CSCE110 | /q3.py | 489 | 3.890625 | 4 | # File: q3.py
# Author: Yuhao Ye
# Date: 06/13/2020
# Section: 529006730(UIN)
# E-mail: yeyuhao1234@tamu.edu
# Description:
#This probram take the loan interest rate
# and period. Then print out the total pay off
#amount
rate = float(input("Enter the interest rate (in percentage): "))
period = float(input("Enter the l... |
5714aec4fefc27f57a7a8bd55e54f03a06359296 | Rafaelmbc/Aulas | /questao14.py | 276 | 4 | 4 | loop = True
lista = []
while(loop):
numero = int(input("Digite numero a quantidade que quiser, ou zero para encerrar\n"))
if numero != 0:
lista.append(numero)
else:
loop = False
print ("A quantidade de valores inseridos é de", len(lista))
|
1a0df7f873899fc5a6f88126b877965ddcba083c | Manuel-Python/Python-Maths | /hexagon.py | 1,170 | 4.40625 | 4 | import turtle
# Number of Sides Polygon name Exterior Angle
# 5 Pentagon 72
# 6 Hexagon 60
# 7 Heptagon 51.42
# 8 Octagon 45
# 9 Nanogon 40
# 10 Decagon 36
screen = turtle.Screen()
mathTurtle = t... |
c2d88ad83a00c53c2a2eb61c258f748d5a183f7c | igrgurina/Python | /zadatak1.py | 1,102 | 3.609375 | 4 | def matInit(i):
Matrix = {}
with open('matrice.txt', encoding='utf8') as dat:
text = dat.read()
text = text.split('\n\n')
lines = text[i].split('\n')
size = lines[0].split()
Matrix['r'] = int(size[0])
Matrix['s'] = int(size[1])
for line in lines[1:]:
element = line.split()
Matrix[(int(element[0... |
1f9fc61c21421fa2b8d893a4447980ced78cc670 | Sharonxavier20/Xmas | /Radius of the circle.py | 139 | 4.3125 | 4 | r=float(input("nput the radius of the circle :"))
print("The area of the circle with radius" + str(r) + " is:" + str(3.14*r**2))
|
0934bb914c2774f7d53a563f502fc508230e28f5 | cu-swe4s-fall-2019/test-driven-development-rachelbowyer | /math_lib.py | 845 | 3.765625 | 4 | import numpy as np
def list_mean(L):
"""evaluates the mean of a list"""
if L is None:
return None
if len(L) == 0:
return None
s = 0
for l in L:
try:
s += l
except Exception:
raise ValueError('Unsupported value in list')
return s/len(L)... |
95e62a21649eb574f6b6c5ef5b1d5255a8976120 | gbasilio/challenges | /project_euler/P28_number_spiral_diagonals.py | 560 | 3.578125 | 4 | import time
start = time.time() * 1000.00
diagonal_numbers = [1]
last_diagonal_number = 1
diagonal_increment = 2
for i in range (3,1002,2):
for y in range(0,4):
curr_diagonal_number = last_diagonal_number + diagonal_increment
diagonal_numbers.append(curr_diagonal_number)
last_diagonal_numb... |
31659da0ab54b624509397f0b355020686473df9 | leemingee/CoolStuff | /torch_trial/Others/LC_temp.py | 1,507 | 3.5 | 4 | '''
Created by Ming Li at 2019-02-05
Feature:
Description:
Contact: ming.li2@columbia.edu
'''
# Definition for an interval.
class Interval:
def __init__(self, s=0, e=0):
self.start = s
self.end = e
class Solution:
def merge(self, intervals: 'List[Interval]') -> 'List[Interval]':
fr... |
57912fb5f21515abfc20aaf3c17ba2dd98a7c19d | leemingee/CoolStuff | /pythonds/priority_queue_based_BT.py | 2,803 | 3.84375 | 4 | '''
Created by Ming Li at 2019-02-03
Feature: priority queue implemented by the binary heap
Description:
A priority queue acts like a queue in that you dequeue an item by removing it from the front.
Contact: ming.li2@columbia.edu
'''
# implementation of binary heap (minheap here)
class binaryHeap:
def __i... |
d69d4d3f0c87299e4255466ae7d895971d2f3a41 | k01e/Code-Helper | /Python/Basics in Python.py | 1,110 | 4.1875 | 4 | ############
names = ["John", "Bob", "Mosh", "Sam", "Mary"]
print(names[0]) # John
print(names[-1]) # Mary
print(names[0:3]) # ['John', 'Bob', 'Mosh']
names.append("Josh")
print(names) # ['John', 'Bob', 'Mosh', 'Sam', 'Mary', 'Josh']
names.insert(3, "Katie")
print(names) # ['John', 'Bob', ... |
f7fa03ab10f26c0d1937068c652eecb29feaffdc | ryangohca/Escape-Room-Text-Game | /game_objects.py | 25,061 | 3.84375 | 4 | """Game objects related functions and classes."""
import command
from place import Place
class GameObject:
"""Represents an object in the game. Each object has some commands for the player to interact with.
Attributes:
name (str): Name of this object
collectable (bool): Determines whether ... |
768c29753131a76fcf1b8769ca3e84ee950159d2 | rcuevass/NLP-exploration | /text-summarization/src/utilities/text_extractor.py | 1,031 | 3.984375 | 4 | # importing libraries
import bs4 as BeautifulSoup
import urllib.request
def extract_text_from_wikipedia_link(url_wikipedia_link: str) -> str:
"""
Function that scrapes text associated with a wikipedia page based on its link to it
:param url_wikipedia_link: string capturing the url of a wikipedia page
... |
56bd489f49ed15618a6976aca9878c177ccc38ab | baricks/algorithmic-poetry | /archive-anthropocene/python-scripts/test_scripts.py | 614 | 3.71875 | 4 | ## A collection of random scripts to manipulate the text
import csv
import json
import pandas as pd
import random
import markovify
col_list = ['Datetime', 'Tweet Id', 'Text', 'Username']
df = pd.read_csv("data/climate-tweets.csv", usecols=col_list)
tweets = (df["Text"])
# Print a random tweet
print(random.choice(twe... |
ffb26f1817909b2d7eb8e8533155c3bb3334cc92 | GenguoWang/LearnGround | /leetcode/contest6/1.py | 594 | 3.59375 | 4 | class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution(object):
def sumOfLeftLeaves(self, root):
"""
:type root: TreeNode
:rtype: int
"""
self.s = 0
def calc(self, node, isLeft):
... |
92b638bc8bfc4db28877f2181a9ca82ef6cb9956 | GenguoWang/LearnGround | /leetcode/234.py | 1,280 | 3.8125 | 4 | # Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def revertList(self, head):
pre = head
now = head.next
pre.next = None
while now != None:
tmp = now.next
... |
da199da6c629ab9f786debcd0c97830c50e1acf8 | JangHun-00/AI_portfolio | /자작 파이썬 프로그램/가위바위보2(5월 13일 재제작).py | 869 | 4.0625 | 4 | import random
Win = '이겼습니다!'
Draw = '비겼습니다.'
Lose = '졌습니다...'
rock = '바위'
scissors = '가위'
paper = '보'
wintable = { scissors:paper, paper:rock, rock:scissors}
list1 = [rock, scissors, paper]
computer = random.choice(list1)
""""
number = random.randint(0, 2)
if number == 0:
computer = "가위"
elif number == 1:
... |
285d17b3f3a614558db3e0014c4949aedd5fa2f5 | DavidMena-Q/learning_python | /first_steps-py/recorrer.py | 546 | 3.96875 | 4 | # def run():
# # nombre = input('Dime tu nombre: ')
# # for pi in nombre:
# # print(pi)
# frase = input('Escriba frase: ')
# for c in frase:
# print(c.upper())
# if __name__ == ('__main__'):
# run()
def run():
cadena = input('Ingresa la cadena: ')
cadena2 = ''
cadena3... |
52f9a15c8056e6fcb52a18b38d9ea09897ba2afc | DavidMena-Q/learning_python | /second_steps-py/reto_raíz_cuadrada.py | 1,517 | 3.984375 | 4 | menu = int(input('''"Métodos para buscar la raíz cuadrada"
método de enumeración = 1
método de aproximación = 2
método de busqueda binaria = 3
Elija el método:'''))
objetivo = int(input('Ingrese un número entero: '))
respuesta = 0
epsilon = 0.001
def enumeracion_exaustiva(respuesta):
while respuesta**2 < ... |
388c368af2dfc8bba980586eb8c4a2f424806bc2 | tungatadube/Physics_plots | /understanding_figs_subplots.py | 656 | 3.96875 | 4 | import matplotlib.pyplot as plt
import numpy as np
def understand_figs(title):
plt.figure(1) # the first figure
plt.subplot(211) # the first subplot in the first figure
plt.plot([1, 2, 3])
plt.subplot(212) # the second subplot in the first figure
plt.plot([4, 5, 6])
plt.figure(2) # a sec... |
7574c486e86ca113004c2d15faa514c8ce389694 | parvesh128/Coursera_simulation | /Peer_review_simulation.py | 20,606 | 3.640625 | 4 |
"""Peer review Simulation
Classes used:-
SubmissionState - Different States for a Submission.
Submission - Represent attributes and functionalities for a submission.
SubmissionNode - Double linked list(DLL) representation to store submission.
SubmissionDLLAndMap - Encapsulates Double linked list of su... |
5b02f602b05cca1ea313437176de62116727b9a7 | wicaksa/flip_coin | /flipCoin.py | 577 | 4.28125 | 4 | # This is a virtual coin toss program. It will randomly tell the user "Heads" or "Tails".
# This program generates a random number, either 0 or 1. Then use that number to print out Heads or Tails.
import random
# Psuedocode
# Calculate a random number and save it into a variable (Round it).
# If the random number ... |
7118f926544ff9e1dcb4175206631199dac5937d | Gayathri547/SURPRISE_TESTS | /st_01-10-2021/1_freq.py | 416 | 4.21875 | 4 | text = input("give your input\n")
words = []
words = text.split(" ")
wfreq=[words.count(w) for w in words]
# to combine the words and its freqency - used zip
x = dict(zip(words,wfreq))
print("Given words with it's frequency are")
print(x)
a = [x[i] for i in x]
a.sort(reverse = True)
print("descending order of frequency... |
1c8d1d8f40467ee0328d55121886042d6b0d2b7c | rajveergandhi/Compiler-Design | /grading/3-semantics+codegen/valid/8-11-switchstmts-explist.py | 515 | 3.59375 | 4 | # import all necessary Python libraries
from __future__ import print_function
import copy
def main():
_GOLITE__a = 2
print(str(_GOLITE__a).lower() if type(_GOLITE__a) is bool else _GOLITE__a, sep=' ', end='\n')
if _GOLITE__a == 1 or _GOLITE__a == 2:
print(str(_GOLITE__a).lower() if type(_GOLITE__a... |
5198ef19d827d07057308a0c7993d2aa31d717a8 | Cu7ious/000-algorhitms-and-data-structures-stepic | /000-parentheses.py | 1,265 | 3.8125 | 4 | #! /usr/bin/env python3
import sys
class Stack:
def __init__(self):
self.stack = []
def print(self, s=""):
print(s, self.stack)
def push(self, key):
self.stack.append(key)
def top(self):
return self.stack[-1]
def pop(self):
return self.stack.pop()
d... |
ec754feddebe5a6ace44502fc09d7b324ddae298 | w-hat/codeartprize2017 | /count_letters.py | 2,089 | 3.921875 | 4 | # Print the sum of the letters in the English form of the integers from 1 to 1000.
# This code is based on code from
# https://github.com/w-hat/ctci-solutions/blob/master/ch-16-moderate/08-english-int.py
SINGLE_DIGIT = {0: 'zero', 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five',
6: 'six', 7: 'seve... |
a4d3483f2b058cc48512b5dd54ab8b29701caa4f | mjbock17/VirtualBroker | /sortserachGUI.py | 21,212 | 3.546875 | 4 | from graphics import *
from button import Button
class Data_Analysis:
def __init__(self):
#creates window for GUI
win = GraphWin("Data Analysis",700,500)
win.setCoords(0,0,10,10)
win.setBackground("slategray")
self.win = win
self.__createButtons()
... |
87088ed4859d596ba8bef8ef18b474442b01cab2 | mwitiderrick/transfer-learning-with-layer | /models/model/model.py | 4,537 | 3.796875 | 4 | """New Project Example
This file demonstrates how we can develop and train our model by using the
`features` we've developed earlier. Every ML model project
should have a definition file like this one.
"""
from typing import Any
from layer import Featureset, Train, Dataset
from PIL import Image
import io
import base6... |
82a5e3b804e3ed53e2298e765ab7d45d158833d4 | florentiino/monet_boys | /monet_boys/generator.py | 3,551 | 4 | 4 | """
generator.py -- Generator()
A generator is comprised of a downsample and an upsample method.
1. Downsampling
The downsample reduces the 2D dimensions, the width and height, of the image
by the stride within a 2D convolution layer
The stride is the length of the step the filter takes. Choosing a stride of 2 means ... |
6e3a90b50873b2c1147c2d6a2314e900bab8b31f | blancopedro/100daysOfcode | /day11.py | 759 | 4.1875 | 4 | """#write addition, subtraction, multiplication and division
print(5+3)
print(11-3)
print(4*2)
print(16/2)
#Pedro Blanco, 08/01/2019
fav_number = 3
text ="My favorite number is" + str(fav_number) + " !!!!"
print(text)
#guessList
list = ["pedro", "john","Charles"]
print(list[0] + ", welcome to our res... |
3c516d782e52d9a9f779268c253285c7e502554e | vino160898/Recursive | /GCD_rec.py | 124 | 3.703125 | 4 | #Greatest common divisor in recursive
def gcd(x,y):
if y==0:
return x
else:
return gcd(y,x%y)
print(gcd(60,48)) #12
|
8cc1ea6155eebd54cf9da2b7d0e14b8747be1c08 | git-athul/Python-HARDWAY | /ex19.py | 147 | 3.515625 | 4 | #ex19 Functions and Variables
def fruits_count(apple, orange):
print(f"We have {apple} apples and {orange} oranges")
fruits_count(2+3, 3**2)
|
d21b6d9d5fa588773fee6aca7c09adc3bfc32f4c | git-athul/Python-HARDWAY | /ex07.py | 177 | 3.640625 | 4 | #ex07 More printing
print('.' * 12)
print("You", end=' ')
print("should", end=' ')
print("see", end=' ')
print("!")
#"end= " changes the ending of printing
print('.' * 12)
|
fb845e68d6cecf9efb4985e0eb3c3ebc16eb100d | git-athul/Python-HARDWAY | /ex38.py | 363 | 3.921875 | 4 | #Ex38: Doing Things to Lists
ten_things = "apples oranges ladder rat mike bike cake food pizz fuel"
stuff = ten_things.split(" ")
more_stuff = ["python", "snake", "Girl", "boy"]
print(stuff)
print("appending",end="")
while len(stuff) != 14:
next_item = more_stuff.pop()
stuff.append(next_item)
print(".",e... |
24f363f54f8a8b253471312e186df62d50501bde | zxjzxjwin/Python_everyday_ex | /Python_everyday_ex/ex21.py | 1,154 | 4.28125 | 4 | #coding:utf-8
#用=和return将变量设成“一个函数的值”
#定义函数:求和
def add(a, b):#!!!!!!!冒号!!!!!!!!
print "ADDING %d + %d" % (a, b)
return a+b
#定义函数:求差
def subtract(a, b):
print "SUBTRACTING %d - %d" % (a, b)
return a-b
#定义函数:求积
def multiply(a, b):
print "MULTIPLY %d * %d" % (a, b)
return a*b
#定义函数:求商
def divide(a,... |
96a2197ea2d601e26e4beb95a17c045e885966ff | MengtaoZhang/project_9527 | /leetcodePractice/7-6-2020/LIS.py | 961 | 3.6875 | 4 | '''
词语接龙
longest increasing sequence
'''
def longestIncreasingSubsequence(self, nums):
if nums is None or not nums:
return 0
# state: dp[i] 表示从左到右跳到i的最长sequence 的长度
# initialize: dp[0...n - 1] = 1
dp = [1] * len(nums)
# prev[i] 代表 dp[i] 的最优值是从哪个 dp[j] 算过来的
pre... |
585128de10b3cb018934532c9d873a301136de95 | MengtaoZhang/project_9527 | /leetcodePractice/6:11:2020/sortColors.py | 270 | 3.6875 | 4 | def sortColors(A):
left, index, right = 0, 0, len(A) - 1
while index <= right:
if A[index] == 0:
A[left], A[index] = A[index], A[left]
left += 1
index += 1
elif A[index] == 2:
A[right], A[index] = A[index], A[right]
right -= 1
else:
index += 1
|
116e370b60ff51b3ac908ee8858757dc375b7ea7 | watinha/collector | /opencv-2.4.9/samples/python/convexhull.py | 1,814 | 3.890625 | 4 | #! /usr/bin/env python
print "OpenCV Python version of convexhull"
# import the necessary things for OpenCV
import cv2.cv as cv
# to generate random values
import random
# how many points we want at max
_MAX_POINTS = 100
if __name__ == '__main__':
# main object to get random values from
my_random = random... |
670f622a5a705f04f1b88e9bfdebcaa398a42bc5 | sirmammingtonham/efficientpicomputation | /test.py | 1,563 | 3.890625 | 4 | m1 = 1
# digits = int(input("How many digits of pi would you like to compute?"))
m2 = 10**3
print(m2)
# Mass of object initially at rest : m1
# Mass of object moving initially : m2
initvector = [0 ,1]
# [Velocity of m1, Velocity of m2)
currentvector = initvector[:]
def mulA(vec):
msum = (m1 + m2)
a11... |
f477fe4e12a8c5712bdc9646333d0e80a7c29ead | Heidi-/ExtractContactInfo | /mergefiles.py | 11,325 | 3.515625 | 4 | """
Now that all the files are csv, and the headers have been manually edited where they were lacking,
time to combine all the files. Cases to deal with:
- Header casing is inconsistent
- Sometimes the name is in one colum, sometimes in two
- Address isn't often present, but multiple address columns can ex... |
59b7016e715afb6f7f49622c48f6d8ff8dbf2544 | Lukazovic/Learning-Python | /CursoEmVideo/exercicio070 - nome preco varios produtos.py | 1,406 | 4.125 | 4 | '''
Crie um programa que leia o nome e o preço de vários produtos. O programa deverá
perguntar se o usuário deseja continuar. No final, mostre:
A) Qual é o total gasto na compra;
B) Quantos produtos custam mais de R$ 1000;
C) Qual é o nome do produto mais barato.
'''
count = totalGasto = countMil = 0
nomeProdutoBarato... |
3bd305cc7c5536571bfeffdbd82e568bf4e43749 | Lukazovic/Learning-Python | /CursoEmVideo/exercicio063 - Fibonacci.py | 377 | 4 | 4 | print('\n----- Sequência de Fibonacci -----\n')
nTermos = int(input('Informe quantos temros da sequência de Fibonacci deseja mostrar: '))
s1 = 0
s2 = 0
soma = 0
print('Sequência de Fibonacci: ',end='')
for i in range(0, nTermos):
soma = s1 + s2
print(soma, end='')
if i != nTermos-1:
print(' -> ', end='')
i... |
9ecae4b5af07e4f8ae909d945c2e249cc3f9536f | Lukazovic/Learning-Python | /CursoEmVideo/exercicio030 - par ou impar.py | 171 | 4.09375 | 4 | numero = int(input('Informe um número: '))
if numero % 2 == 0:
print('\nO número {} é par' .format(numero))
else:
print('\nO número {} é ímpar' .format(numero)) |
9faba77b58403e7556150223854c258348896086 | Lukazovic/Learning-Python | /CursoEmVideo/exercicio039 - alistamento.py | 921 | 4.21875 | 4 | '''
Faça um programa que leia o ano de nascimento de um jovem e informe, de acordo
com a sua idade:
-Se ele ainda vai se alistar ao serviço militar;
-Se é a hora dele se alistar;
-Se já passou do tempo do alistamento.
O programa também deverá mostrar o tempo que falta ou que passou do prazo.
'''
from datetime import d... |
d625f12bb5a47847d4d002887b9ef073af404110 | Lukazovic/Learning-Python | /CursoEmVideo/exercicio023.2 - Formato inteiro.py | 776 | 4.1875 | 4 | #Com formato inteiro
numero = int(input('Digite um número de 0 a 9999: '))
'''
#pegando a unidade do número
unidade = numero/10
unidade = unidade - int(unidade)
unidade = int(unidade*10)
print('\nUnidade: {}' .format(unidade))
#Dezena
dezena = int((numero/100 - int(numero/100))*10)
print('Dezena: {}' .format(dezena))
... |
51f692c02ead56e85992185d19f3eea5e66ce1fb | Lukazovic/Learning-Python | /CursoEmVideo/exercicio022 - lendo nome.py | 712 | 4.4375 | 4 | '''
Desafio 22: Crie um programa que leia o nome completo de uma pessoa e moste:
-O nome com todas as letras maiusculas
-O nome com todas as letras minusculas
-Quantas letras tem o nome todo (sem considerar espaços)
-Quantas letras tem o primeiro nome
'''
nome = str(input('Digite o seu nome: '))
print('\nO seu nome c... |
23c7b308696e15acaa0ed6d6a80f25d3119ad70f | Lukazovic/Learning-Python | /CursoEmVideo/exercicio019 - sortear alunos.py | 416 | 3.765625 | 4 | from random import choice
aluno1 = str(input('Informe o nome do primeiro aluno: '))
aluno2 = str(input('Informe o nome do segundo aluno: '))
aluno3 = str(input('Informe o nome do terceiro aluno: '))
aluno4 = str(input('Informe o nome do quarto aluno: '))
listaDeAlunos = [aluno1, aluno2, aluno3, aluno4]
alunoE... |
741de4e3cfaa19674a02694c0ae24db1489e8813 | Lukazovic/Learning-Python | /CursoEmVideo/exercicio075 - tupla 4 valores.py | 1,069 | 4.25 | 4 | '''
Desenvolva um programa que leia quatro valores pelo teclado e guarde-os em uma
tupla. No final, mostre:
(a) Quantas vezes apareceu o valor 9;
(b) Em que posição foi digitado o primeiro valor 3;
(c) Quais foram os números pares.
'''
print('')
numero1 = int(input('Informe um número: '))
numero2 = int(input('Informe ... |
4d76b831589523de945e1048f3b285c964ee033d | Lukazovic/Learning-Python | /CursoEmVideo/exercicio073 - colocados brasileirao.py | 1,087 | 4.03125 | 4 | '''
Crie uma tupla preenchida com os 20 times do Brasileirão, na ordem de colocação.
Depois mostre:
(a) Apenas os 5 primeiros colocados;
(b) Os 4 últimos colocados da tabela;
(c) Uma lista com os times em ordem alfabéfica;
(d) Em que posição está a Chapecoense.
'''
equipes = ('Flamengo', 'Palmeiras', 'Santos', 'São Pa... |
70ad42736cf622162dae4a4786ee1591ff0473b3 | Lukazovic/Learning-Python | /CursoEmVideo/exercicio076 - nome precos tuplas.py | 455 | 3.890625 | 4 | '''
Crie um programa que tenha uma tupla única com nome de produtos e seus respectivos
preços, na sequencia.
No final, mostre uma listagem de preços, organizando os dados em forma tabulas.
'''
produtosEprecos = ('Isoporzitos', 'Litrão', 'Open Bar', 'Dogão', 'Xerox',
3.5, 8, 35, 6, 0.15)
print('')
for i in range(0, in... |
6c5e0d34e967926586f756f37a993a423773ad36 | implementation-of-functional-maps/SHED_Python | /SimsMetaph/lang_convert_word_dict.py | 859 | 3.671875 | 4 | # -*- coding: utf-8 -*-
import time
import mojimoji
import sys
dic=sys.argv[1]
input_file=sys.argv[2]
f_in = open(input_file)
lines_in = f_in.readlines() # 1行毎にファイル終端まで全て読む(改行文字も含まれる)
f_in.close()
f_dic = open(dic)
lines_dic = f_dic.readlines() # 1行毎にファイル終端まで全て読む(改行文字も含まれる)
f_dic.close()
dict={}
for line in lines_d... |
6aad8edcf7a22d1dda4f1be6734b8e2b3b91cd3f | jtyurkovich/python-tutorial | /Lesson One: Basics/challenge1.py | 1,259 | 4.40625 | 4 | # jtyurkovich, 2014
# coding: utf-8
# In[1]:
# Write a script that takes this string as input and breaks the code to read the message contained within:
# espqtcdeapcdzyezdzwgpestdrpedespstrspdezqqtgpd
# This code was encrypted using a shift cipher of 11 (t = t + 11 = e, h = h + 11 = s). Hint: use a dict to define th... |
be074fbcf094549ef2cf3861bb0a2891cc5f7a98 | Aumaim1234/PANDAs-Excel- | /pandas 2.py | 1,402 | 3.921875 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[8]:
import numpy as np
import pandas as pd
# In[9]:
##Quiz 1##
#Read csv file
df = pd.read_csv('C:/Users/Acer/Desktop/HW/coding/Final/1-9/Salaries.csv')
# In[10]:
# first 10
df.head(10)
# In[11]:
# first 20
df.head(20)
# In[12]:
# first 50
df.head(50)
# I... |
a6a2f29ef0b48f774736670ff50cd050425952fc | adityakumarjaiswal/Assignment1 | /Divisibleby5and7.py | 231 | 3.953125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
#Assignment no 1:-
# Divisible by 5 and 7
for value in range(1500,2701):
#print(value)
if(value%5==0 and value%7==0):
print(value ,"is Divisible by 5 and 7")
else:
continue
|
2b2236c5f983675318d9845ec6a26ec3de70ddac | Mubarok-cup/HACKER-X | /Registration.py | 661 | 3.5625 | 4 | color_off="\033[0m" # Text Reset
# Regular Colors
black="\033[0;30m" # Black
red="\033[0;31m" # Red
green="\033[0;32m" # Green
yellow="\033[0;33m" # Yellow
blue="\033[0;34m" # Blue
purple="\033[0;35m" # Purple
cyan="\033[0;36m" # Cyan
white="\033[0;37m" #... |
64c44b89138137994311f0ddacf55ec00c7c12df | Mukesh-Choubey/Juniper | /string_practice.py | 918 | 3.90625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Jun 5 11:13:53 2020
@author: mchoubey
"""
x = 'hello world !'
print(x[0:5])
print(x[:])
print(len(x))
###Reverse the string
print(x[::-1])
###Count number of ls in string
print(x.count('l'))
####Iterate over string, two lines
for a in x:
# print(a)
print(a, end='\n \... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.