blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
91531684a5b13d128361c167493957b55218ed4b | Ignacio-Gonzalez-C/sort-1 | /sort.py | 513 | 3.828125 | 4 | def get_pivot(array, i, j):
pivot = array[j]
item = i - 1
for k in range(i, j):
if array[k] <= pivot:
item = item + 1
(array[item], array[k]) = (array[k], array[item])
array[item + 1], array[j] = array[j], array[item + 1]
return item + 1
def quick_sort(array, i=None, j=None):
if i == None:
... |
9485759ef1b43b19642b35039ec0e5a0e5408f36 | raylyrainetwstd/MyRepo | /M07_Code_Fixed.py | 2,458 | 4.1875 | 4 | #this function takes an input from a user in response to a question
#if the user input is not a number, is_num doesn't accept the user input
def is_num(question):
while True:
try:
x = int(input(question))
break
except ValueError:
print("That is not a number")
... |
37dccd46a8aab0502d243a8d8d812a5f3d3d219a | akmeraki/Udacity-Facial-Keypoint-Detection | /Code/Face_detection_using_Haar_cascades(group).py | 1,563 | 3.515625 | 4 | #libraries required for this section
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import math
import cv2 # OpenCV library for computer vision
from PIL import Image
import time
# Loading the color image for face detection
image = cv2.imread('images/test_image_1.jpg')
# Conve... |
f113a7f877673af38220fa1fd08890b9b2ffdb90 | JaeSeo/basic | /12.recursion/7.reverse_list.py | 2,958 | 3.9375 | 4 | # 리스트 뒤집기
# 파라미터로 리스트 some_list를 받고, 뒤집힌 리스트를 리턴해주는 재귀 함수 flip을 쓰세요.
# 반복문은 쓰면 안됩니다!
# # 파라미터 some_list를 거꾸로 뒤집는 함수
# def flip(some_list):
# # 코드를 입력하세요.
# # 테스트
# some_list = [1, 2, 3, 4, 5, 6, 7, 8, 9]
# some_list = flip(some_list)
# print(some_list)
# [9, 8, 7, 6, 5, 4, 3, 2, 1]
# 파라미터 some_list를 거꾸로 뒤집는 함수
... |
33ae1012ddaf18c9514eea4f21bb9594c4e9cc96 | daicorrea/my-project | /book_me_up/src/hotel.py | 580 | 3.75 | 4 | from src import property
class Hotel(property.Property):
"""This Class provides a way to store hotel informations based on a property."""
# Creating Constructor
def __init__(self, property_name, property_type, local, star_rating, week_price, weekend_price,
loyalty_week_price, loyalty_wee... |
deb57f9886060032723de48d3d7ab6a514db6e62 | rcbop/hacker-rank-challenges | /python/introduction/python_if_else.py | 441 | 4.21875 | 4 | #!/bin/python3
import sys
N = int(input().strip())
if N % 2 != 0:
print("Weird")
else:
if N >= 2 and N <=5:
print("Not Weird")
elif N >= 6 and N <= 20:
print("Weird")
else:
print("Not Weird")
#If is odd, print Weird
#If is even and in the inclusive range of 2 to 5, print Not... |
5dace00ff2c7802cb29cbd4427cd99a2b225918b | delacruz-cbt/pit-n | /CHECK POINT I - RM82236.py | 1,752 | 4.125 | 4 | emailList = ['jaqueline@fiap.com.br', 'pedro@fiap.com.br', 'clara@fiap.com.br', 'alice@fiap.com.br', 'joao@fiap.com.br', 'miguel@fiap.com.br', 'enzo@fiap.com.br', 'gabriel@fiap.com.br', 'arthur@fiap.com.br', 'heitor@fiap.com.br', 'ana@fiap.com.br', 'helena@fiap.com.br', 'beisola@fiap.com.br', 'luiza@fiap.com.br', 'adal... |
abb3fa4473fcb2826b5519ecb36d969fe44256fb | keiti93/Programming0 | /week5/1-On-Budget/budget.py | 456 | 3.6875 | 4 | def on_budget(books, budget):
books = sorted(books)
price = 0
new_books = {"books_on_budget": 0, "loan": 0}
for book in books:
if book < budget:
budget = budget - book
price += book
new_books["books_on_budget"] += 1
if budget <0:
... |
2a08253b3b3b6fda68771a90fd62218da02c07da | hamidrezamousavi/weather | /get.py | 2,671 | 3.515625 | 4 | import requests, json, time
API_KEY = 'f9f5bd14bbc6b24dc1620b7c1d58b826'
def get_city_ID(city_name):
"""
this function take city name and find it's ID from
city.list.jason file
"""
with open('city.list.json','r') as city_file:
city_data = json.load(city_file)
city_ID = [city... |
ea00905895ae8e311aab2ea301eb87967342698c | unsortedtosorted/elgoog | /Easy/trees/isSymmetric.py | 2,043 | 3.953125 | 4 | """
101. Symmetric Tree
1. Do BFS
2. add child nodes to respective levels
3. check each level for mirror reflection
NOTE : check recursive solution on leetcode
"""
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# ... |
1f1ae1d46d13b00749f5ce6f1ae74537efaea4ee | dnav6987/TicTacToe | /src/GameState.py | 2,466 | 3.78125 | 4 | from Constants import EMPTY, X, O, SIZE, WINNING_BOARDS
class Game:
def __init__(self):
# the game board. all positions initially empty
self.board = [[EMPTY for i in range(SIZE)] for j in range(SIZE)]
self.num_moves = 0
def get_position(self, x, y):
return self.board[x][y]
... |
0f2672c2259fe74fd6549d7eb71bb76be2a9f54d | DoeDeer/python-project-lvl1 | /brain_games/games/even.py | 584 | 3.828125 | 4 | # -*- coding: utf-8 -*-
"""Even game module."""
import random
DESCRIPTION = 'Answer "yes" if number even otherwise answer "no".'
def is_even(number):
"""Predicate function, check given number even.
Args:
number: number to check
Returns:
even of the number
"""
return not numbe... |
873d3b56441924fcfda25f9cc6fbc34b1b4bdbc8 | datacenter/nexus9000 | /nexusdash/utils/qaes.py | 1,516 | 3.578125 | 4 | '''
http://www.tylerlesmann.com/2008/dec/19/encrypting-database-data-django/
'''
#!/usr/bin/env python
import string
from random import choice
from Crypto.Cipher import AES
EOD = '`%EofD%`' # This should be something that will not occur in strings
def genstring(length=16, chars=string.printable):
return ''.join(... |
7fde0c021f8e15453655d63574cbfb3a0f6b9ad9 | Suren76/Python | /python procedural programing/homework6/test.v2.py | 666 | 3.90625 | 4 | # Call function: simple_numbers(0)
# Function return: ()
# Call function: simple_numbers(8)
# Output: (2, 3, 5, 7)
# Call function: simple_numbers(97)
# Function return: (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97)
def simple_numbers(input_num):
all_num... |
ca14ba526126d0c48e8330facca5abeaf0f1ee63 | U-1337/demo | /scalc/scalc.py | 4,630 | 3.65625 | 4 | """Интерпретатор языка Calculator
Интерпретатор языка calculator, использующий синтаксис Scheme.
Выражения оператора должны быть символами. Выражения операндов разделяются
пробелами.
Примеры:
> (* 1 2 3)
6
> (+)
0
> (+ 2 (/ 4 8))
2.5
> (+ 2 2) (* 3 3)
4
9
> (+ 1
(- 23... |
81954bb5a60a3bedae2efb95c977ce1d0f88fec3 | Leorfk/Exercicios-Python | /Cev_exercicios/ex0012.py | 133 | 3.609375 | 4 | p = float(input('Digite o preço do produto: '))
desc = p*0.95
print('O valor do produto com desconto é: R${:.2f}'.format(desc))
|
65d364eb11afeb42b6fc942583ed5fba2a78c8d8 | shihanwen012/PythonByjocker | /day01.py | 3,802 | 3.71875 | 4 | # cmatrix 数据雨
# s1 火车
# cowsay hello 牛说你好
# chr()将整形转换成该编码对应的字符串(一个字符)
# ord()将字符串(一个字符)转换成对应的编码(整数)
# format可以任何类型
# id(x)查看内存地址
# is与== is快 每个字符对应一个内存地址
# in时判断在容器中(可迭代对象)有没有这个东西
# 能被for循环的叫可迭代对象
# +=自加
#切片是一个前闭后开的区间
#[satrt:end:step]
#[开始:结束:间隔]
#命名变量要见名思意
#一到一百相加的和:
# def sum():
# sum = 0... |
97215b92c68e195789593b5ded0c6b1d9a8d6d23 | shedrinav88/python-homeworks | /less02_2.py | 562 | 4 | 4 | number_of_elem = int(input("Enter the number of list's elements: "))
i = 0
my_list = []
while i < number_of_elem:
my_element = input(f'Enter your element № {i + 1} (it will be str class): ')
my_list.append(my_element)
i += 1
print(f'Initial view of the list {my_list}')
for elem in range(len(my_list)):
i... |
4a7233d16b76c0e0915d978ab908f0e3858700e0 | CptAnthony/crypto | /initials.py | 303 | 3.84375 | 4 | def get_initials(fullname):
fullname_upper = fullname.upper()
answer = ("")
for i in (fullname_upper.split()):
answer = answer + i[0]
return answer
def main():
username = input("What is your full name?")
get_initials(username)
if __name__ == '__main__':
main()
|
6c2ddd09741bb4ee0d5fe7c920e037656a021ab0 | kelasterbuka/Python3.x_Dasar_Programming | /Versi Lama 09 - while loop/while2.py | 326 | 3.71875 | 4 | # else, break, continue, pass
angka = 0
while angka < 10:
if angka is 5:
# print('checkpoint 1')
break
continue
pass
# print('checkpoint 2')
print( 'nilai angka adalah:', angka)
angka += 1
else:
print('nilai angka diakhir while adalah',angka)
print('di luar w... |
405a0fabb73e61491acb962882dc38db4a1f5faa | rsr2425/PyTrade | /test_strats.py | 1,563 | 4.0625 | 4 | from trading import *
import numpy as np
class ContraStrat(Strategy):
"""
Implementation of the contrarian trading strategy where buy/sell decisions are made
based on how far price has moved from a certain anchor point. If the target security
falls enough you buy, while if it goes sufficently high y... |
a609f50abe97c626810a2eb56e895e13258b29d8 | suhongsheng/PythonStudy | /Python005/src/test/test006.py | 2,056 | 3.609375 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
import Tkinter; # 导入 Tkinter 库
import tkMessageBox;
root = Tkinter.Tk(); # 创建窗口对象的背景色
display = Tkinter.StringVar()
buttonResult = Tkinter.Entry(root, textvariable=display, background='#909090');
buttonResult.grid(row=0, column=0, columnspan=6, rowspan=2, sticky=Tkinter.W ... |
101a0d3fcf297668a00f41e261fd20933829f6f4 | Trequetrum/leetcode_practice | /Python3/FizzBuzz/basic.py | 259 | 3.59375 | 4 | def fizzbuzz(n):
if n % (3 * 5) == 0: return "FizzBuzz"
if n % 3 == 0: return "Fizz"
if n % 5 == 0: return "Buzz"
return str(n)
def travel(nums, comp, effect):
for n in nums:
effect(comp(n))
travel(range(1,21,1), fizzbuzz, print) |
5ddcca66efeec5b38dc71e5767e4fd66d0df7414 | JulietaCaro/Programacion-I | /Trabajo Practico 2/Ejercicio 15.py | 593 | 4.03125 | 4 | #15. Generar una lista con números al azar entre 1 y 100 y crear una nueva lista con
#los elementos de la primera que sean impares. El proceso deberá realizarse utilizando
#listas por comprensión. Imprimir las dos listas por pantalla.
from random import randint
#FUNCIONES
def listaAzar():
lista = []
fo... |
609a71754581ae3d591bd392056be62d0cc54fd4 | lcgly123/leetcode | /179. Largest Number.py | 611 | 4 | 4 | 179. Largest Number
Given a list of non negative integers, arrange them such that they form the largest number.
Example 1:
Input: [10,2]
Output: "210"
Example 2:
Input: [3,30,34,5,9]
Output: "9534330"
class Solution:
def largestNumber(self, nums: List[int]) -> str:
def mycmp(x,y):
... |
1325fd3c4c1026bab1d2d6e410929b894e1562e0 | andrewkigara/CS171Game | /project.py | 3,278 | 3.578125 | 4 | # Andrew M Kigara
# ID : 14381581
# Email : amk526@drexel.edu
# CS 171 Game Project
# Name of the Game is : AFRICA AT 60!
# This is the main program that initiates the game
# I have 5 more programs that support the running of the program
# Comments have been incorporated on random positions of the program
# to enha... |
a967714aa1dc0e38d356faa7c81d9ce97dbe1821 | hashfx/DSApython | /DataStructures/tuple.py | 1,253 | 4.59375 | 5 | ''' TUPLE
A tuple is a collection which is ordered and unchangeable(immutable).
'''
''' Adding Elements '''
print("**********Adding Elements**********", end="\n\n")
tuple = (1, 2, 3, 'Alphabet')
print(f"Tuple is {tuple}", end="\n\n")
''' Accessing Elements '''
print("**********Accessing Elements**********", ... |
b0507d80b0f6c79c918bbed185acfb5bb14e79ff | aiazm496/PythonCompetitive | /gfgKthsmallestElement.py | 505 | 3.734375 | 4 | def kthSmallest(arr, l, r, k):
'''
arr : given array
l : starting index of the array i.e 0
r : ending index of the array i.e size-1
k : find kth smallest element and return using this function
'''
arr.sort()
result = arr[k-1]
return result
test = int(input())
while(test):
siz... |
b86ccfb41c57b17f539a24a1560fb4859d5ea922 | pedropenna1/Exercicios-Python | /exercicio 20.py | 348 | 3.6875 | 4 | import random
nome1 = str(input('Digite o nome do primeiro aluno: '))
nome2 = str(input('Digite o nome do segundo aluno: '))
nome3 = str(input('Digite o nome do terceiro aluno: '))
nome4 = str(input('Digite o nome do quarto aluno: '))
lista = [nome1,nome2,nome3,nome4]
random.shuffle(lista)
print('A ordem de apresentaç... |
3072e93cb6f72fd7668b8779d602471e6609e60f | Jishasudheer/phytoncourse | /Exception_handling/division.py | 139 | 3.59375 | 4 | n1=int(input("Enter no1"))
n2=int(input("Enter no2"))
try:
div=n1/n2
print (div)
except:
print("Divion by Zero..Error occured") |
7a4d0d25148ff612f808bd53c14da4048bb6c252 | ccrownhill/NewtonMethod | /newton_method.py | 2,345 | 3.78125 | 4 | #!/usr/bin/python3
import argparse
def newton_root(xn, f, f_prime, margin, verbose=False):
i = 0
while f(xn) > margin or f(xn) < -margin:
i += 1
try:
xn = xn - f(xn)/f_prime(xn)
except ZeroDivisionError:
print(f"Bad x-value: Derivative will become 0. You can't d... |
a74eb009b58abdd5c7f8a4b0d74bcb5576f433ee | minhd2/time2code | /company_logo/compny_logo.py | 831 | 3.8125 | 4 | # Problem: https://www.hackerrank.com/challenges/most-commons/problem
# Copy and paste bottom will work into that problem.
# Thought Process:
# 1) Use dictionary to store char/occurences at kv pair
# 2) Sort in reverse by key first then normal by value
# 3) Print only first three items and their occurence count
# I str... |
fd13de490516a83c6252074457e71f915af9e733 | brook-hc/py-study | /001-基本语法/012-列表.py | 2,091 | 3.5625 | 4 |
for i in 'hello':
print(i,end=' ')
print()
a=['a','b','c','d','e','f','g'] # 列表也有和上面字符串一样的骚操作
print(type(a))
for i in a:
print(i,end=' ')
print()
b= 'o' in a # 查看o是否在列表里,返回的是true或false
print(b)
w=['惠普','华为','苹果','三星','小米','神舟','联想']
long=len(w)
# for i in range(long):
# if w[i] in '华为':
# ... |
da45f54092ce1c3f5675eb47ce4401a67e2a1ac7 | mekdeshub123/Travel_project | /search.py | 479 | 3.671875 | 4 | """
1. get city
2. make 3 api calls.
3. display results
"""
import rest, weather, news
import db
def search():
city = ui.get_city()
restaurants = rest.get_restaurants(city)
news_articles = news.get_articles(city)
weather_forecast = weather.get_forecast(city)
ui.display(restaurants, news_articles... |
75a68e8822c3f2ce452f93dff0220000c67b2784 | Hanqing1996/blog | /python学习/变量作用域/global.py | 835 | 3.921875 | 4 | """
# 例1
def foo():
a = 200 # 定义了一个局部变量a,值为200
print(a) # 这里访问的a是值为200的局部变量
if __name__ == '__main__':
a = 100 # 定义了一个全局变量a,值为100
foo()
print(a) # 这里访问的a是值为100的全局变量
"""
"""
# 例2
def foo():
print(a) # 这里访问的a是值为100的全局变量
if __name__ == '__main__':
a = 100 # 定义了一个全局变量a,值为100
foo()
... |
f5baac7bde2ad782f6b59c6563c8168cc2e60ebf | Damdesb/python_fundamental | /03_more_datatypes/3_tuples/03_13_tuple_to_list.py | 191 | 3.5625 | 4 | '''
Write a script that takes a tuple and turns it into a list.
'''
users_input = tuple((input)("insert a script : "))
tuple_list = list(users_input)
print(users_input)
print(tuple_list)
|
48d01bb511cfcc2862ad968cf6c17c7ae4fa228c | winstonjay/dissertation-and-research-methods | /lib/textutils.py | 523 | 3.703125 | 4 | import collections
import re
from nltk.stem.snowball import SnowballStemmer
def clean_text(text, stopwords):
'''converts the text to lowercase remove all non words,
stopwords, non ascii characters and links. stem the remaining
words and concatinate the result into a new string.'''
return cat(stemmer.... |
63c60fc41b2ff79cf7ef4967115016084552b595 | mariekoorneef/advent-of-code-2020 | /day2.py | 1,519 | 3.859375 | 4 | """ Advent of Code day 2 """
from aocd import get_data
from dotenv import load_dotenv
import re
from helper import data
def parse_password_policy(line: str) -> tuple:
"""Given '1-3 a: abcde' return (1, 3, a, abcde)"""
a, b, letter, password = re.findall(r'[^-:\s]+', line)
return int(a), int(b), letter, ... |
3f4d5c33ab4baed47532e2579a2447ad4b7d371d | IlTorre/CodeEval | /palindromicRange.py | 389 | 3.578125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Marco Torreggiani'
import sys
if __name__=='__main__':
fil = open(sys.argv[1], 'r')
for row in fil.readlines():
L,R=row.split(' ')
L=int(L)
R=int(R)
pal=[]
int=[]
for i in xrange(L,R+1):
... |
b1ee6933460c385c592d4b7a5adbbd4dbebf99ae | whitphx/stlite | /packages/sharing-editor/public/samples/011_component_gallery/pages/widget.download_button.py | 917 | 3.65625 | 4 | import numpy as np
import pandas as pd
import streamlit as st
@st.cache_data
def load_data():
data = pd.DataFrame(np.random.randn(1000, 2), columns=["a", "b"])
return data
@st.cache_data
def convert_df(df):
# IMPORTANT: Cache the conversion to prevent computation on every rerun
return df.to_csv().e... |
314f4ec56692a0279db1d95acda5453668d8a0a3 | devinshields/Project-Euler | /old/python_legacy/Euler45/main.py | 743 | 3.53125 | 4 | #!/usr/bin/python
"""
Triangle, pentagonal, and hexagonal numbers are generated by the following formulae:
Triangle Tn=n(n+1)/2 1, 3, 6, 10, 15, ...
Pentagonal Pn=n(3n1)/2 1, 5, 12, 22, 35, ...
Hexagonal Hn=n(2n1) 1, 6, 15, 28, 45, ...
It can be verified that T285 = P165 = H143 = 40755.
Find the next tri... |
c8cee1c1a1dbca610c895040aefc84f748077ee9 | niranjan-1/Python_-_SQL_for_data-science | /python/challenge (4).py | 185 | 3.578125 | 4 | with open("sample.txt",'w') as tables:
for i in range(2,13):
for j in range(1,13):
print("{1:>2} times {0} is {1} ".format(i,j,i*j),file=tables)
print("_"*20, file=tables) |
13dcccb38f06c173d2eb3ed5f98505a935731416 | Silvan-M/Game-TARS | /NNN.py | 3,776 | 3.984375 | 4 | import numpy as np # helps with the math
import matplotlib.pyplot as plt # to plot error during training
import NN_Visualiazation_matplotlib as vis
global x,y
x = 0
y = 0
# input data
inputs = np.array([[1, 1, 0],
[0, 1, 1],
[1, 0, 1],
[0, 1, 0],
... |
3039631b38ee0519054b5bcf22750cd90638cce9 | januwarby/CalculatorCLI | /00play.py | 1,128 | 3.953125 | 4 | # Bermain Dengan Python (Membuat Kalkulator Sederhana)
# Penjumlahan Dua Buah Angka
def tambah(x, y):
return x + y
# Pengurangan Dua Buah Angka
def kurang(x, y):
return x - y
# Perkalian Dua Buah Angka
def kali(x, y):
return x * y
# Pembagian Dua Buah Angka
def bagi(x, y):
return x / y
print("Pili... |
242d3d84dfdcfcac290c20b7f5850be5c252d54a | MakrisHuang/LeetCode | /python/2034_stock_price_fluctuation.py | 1,459 | 3.96875 | 4 | import heapq
class StockPrice:
"""
Use two heap to track the previous largest and smallest elements
"""
def __init__(self):
self.timestampToPrice = {}
self.minHeap = []
self.maxHeap = []
self.curr_timestamp = None
def update(self, timestamp: int, price: int) -> None... |
2e472e83595c74f0a3ed518a876bf00d3efbf1cc | sergiotrautmann/Faculdade | /Bubble sort.py | 316 | 3.5625 | 4 | lista = [7, 2, 12, 4, 8]
ct = 0
while True:
for x in range(4):
ct = ct + 1
if lista[x] > lista[x+1]:
temp = lista[x]
lista[x] = lista[x+1]
lista[x+1] = temp
print(lista)
print("Foram feitos", ct, "testes.") |
f4891dd125a438c0c3d7a93f8550ffe331e3ec39 | huihanlhh/mobility-thesis | /Code/Algorithms.py | 987 | 3.90625 | 4 | def mergeBorder(lst1, lst2):
""" we compare each coordinate of lst1 with lst2 and create new list out of the two
the end point of repitition in lst1 would be the new start of the new list
"""
#because last coordinate equals first coordinate
l1 = lst1[:-1]
l2 = lst2[:-1]
result = []
repeat = False
s1 = n1 = ... |
f3367c47a418ce200d474729af1da4beba1479c7 | lucasmeirelesta/cpdoc-text-align | /old_script/fakedata.py | 2,798 | 3.578125 | 4 | """
This python file was used to generate texts with noise, so we could test our model in early stages.
Nowadays, I don't use it anymore but maybe in the future i could use it.
"""
import random
import numpy as np
from nltk.corpus import machado
import nwalgorithm
def fakedata(phrase, seed=42):
"""
Receives... |
e8b6512ec83b6e02dd075223184f1c57c2ea1c30 | mnishiguchi/python_notebook | /MIT6001x/week3/gcdIter.py | 529 | 3.75 | 4 | # -*- coding: utf-8 -*-
def gcdIter(a, b):
'''
a, b: positive integers
returns: a positive integer, the greatest common divisor of a & b.
'''
# Your code here
test = min(a, b)
while test > 1 :
# if found, answer it
if a % test == 0 and b % test == 0:
... |
cfa7c3dfe5a660b1c7c83a64458e15111247b094 | triptii01/project-2020 | /tst1.py | 452 | 3.53125 | 4 | def find(s):
y = s.find('au',3)
return y
print(find("wertyuijhgfdsacvbauetyukj"))
def code(x):
return x[1:]
print(code('dsfsgfgthyju'))
def add(a,b):
a = a + b
return a
print(add('wert','ewrty'))
print(add(3,6))
def square(x):
y = x ** 2
return y
print(square(5))
def sum3(a,b,c):
... |
f2005c69cf9d2d492f416db9b5482910524d9c34 | brunacorreia/100-days-of-python | /Day 8/exercise1-functions-with-inputs.py | 427 | 4.03125 | 4 | # write a function using PARAMETERS and ARGUMENTS
def greet(name, location):
print(f"Welcome, {name}.")
weather = input(f"How's the weather at {location} atm?\n")
print(f"{weather}? It seems a good time for a cup of coffee..")
# calling the function with KEYWORDS ARGUMENTS
greet(location = "Florianópolis", name... |
76a9ee79fa1425396e54205a7451c05b32c9e16f | txmayush22/reverse-function- | /reverse of number.py | 146 | 3.59375 | 4 | #homework
a="1","2","3","4","5","6","7","8","9","10"
rev=''
for i in range (len(a)-1,-1,-1):
print(a[i])
rev=rev+a[i]
print(rev)
|
bd6510510459c40f48b2c2241a5af655a84860b6 | YUNKWANGYOU/SWE | /Midterm_Preparation/Python/Syntax/variable.py | 1,140 | 3.671875 | 4 | x = 5
y = "yunkwang"
z = 3.0
X = 4
# x != X
print(x,type(x))
print(y,type(y))
print(z,type(z))
print(X,type(X))
# camel case
sweStuent = 'yunkwang'
# pascal case
SweStudent = 'yunkwang'
# snake case
swe_student = 'yunkwang'
# multi value assignment
a,b,c = 'chocolate',4,'study'
d=e=f='WeAreSame'
print(a,type(a))
pri... |
f085b3608ba7aa4880f52d7caaafdf8490abc0bd | IliaValkov/PythonExercises | /beggining_python/chapter_02_Lists_and_Tuples/listing2.py | 90 | 3.703125 | 4 | url = input("Please enter an URL: ")
domain = url[11:-4]
print("Domain name: " + domain) |
9838c0024ad36da5e3e1d27f50880bcf94596fd6 | Anjali-225/PythonCrashCourse | /Chapter_9/Pg_250_TIY_9_15.py | 3,124 | 3.796875 | 4 | #9-15
#THIS IS THE VERSION WHICH COUNTS THE LOOP THING
#HOWEVER BOTH VERSIONS DO WORK and for the first version I did take help from the internet
#-------------------------------------------------------------------------------
from random import choice
#MAKE A FUNCTION TO GET A TICKET THAT IS THE WINNING TICK... |
c645f97984fb01319bc4d9be3e68d85d4a4ba981 | chaitanyakrishnateja/pythonProject | /practice/Fpattern.py | 141 | 3.6875 | 4 | number = [5, 2, 5, 2, 5]
for x_count in number:
output = " "
for y_count in range(x_count):
output += 'X'
print(output) |
b874f350eccbc81ce7ada599d7116a0246c37b30 | DehNutCase/Othello | /Othello_with_comments.py | 15,227 | 4 | 4 | """
Rules:
Gameboard is 8x8, with the center 4 tiles being taken up by 4 disks, 2 of each color, and same
colored disks being in diagonal with each other.
Players take alternating turns, black goes first, if a player has no legal moves, his turn is skipped.
If neither player has legal moves, the game ends, otherwise ... |
93252a718deaa268ac4c4770fd7518207894085b | ArchAiA/DataScience | /Class01/chipotle.py | 11,583 | 3.53125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Mar 18 23:11:22 2015
@author: david
"""
import csv
print '\n'
"""PART 01: Read in the data, parse it, and store it in a list of lists called 'data'"""
with open('chipotle_orders.tsv') as data:
#data = csv.reader(tsv, delimiter = '\t')
data = [row for row in csv.... |
deb57ac5317a095477c0e84606484d58d590847e | smallfishxz/Practice_Algorithm | /LinkedList/Basic.py | 1,661 | 3.890625 | 4 | # http://interactivepython.org/runestone/static/pythonds/BasicDS/ImplementinganUnorderedListLinkedLists.html
class Node:
def __init__(self,initdata):
self.data = initdata
self.next = None
class linkedlist():
def __init__(self):
self.head = None
def isEmpty(self):
return self.head ==... |
c1402208921b4f5ac60a8a761181b3e25b863115 | emanoelmlsilva/ExePythonBR | /Exe.Lista/EL.07.py | 260 | 3.78125 | 4 | lista = list(range(5))
v = []
soma = 0
mult = 1
for i in range(len(lista)):
num = int(input('Digite um valor: '))
v.append(num)
soma += num
mult *= num
print('números {}'.format(v))
print('soma: {}'.format(soma))
print('Multiplicação: {}'.format(mult))
|
3332dae4c07153ceb97d1858e3c091096365249c | areezvisram/AI-Sketches-a-Photo | /sketches.py | 3,011 | 3.625 | 4 | import cv2 as cv
import numpy as np
import random
from outline import Outline
from background_noise import BackgroundNoise
from PIL import Image, ImageOps
# This program generates a light pencil sketch of a photo (drawing.png), and a more accentuated, thick penciled detailed sketch of a photo (final.png)
# The outline... |
fe17534c9082de6d1ae7b012228080f300a2cfd1 | d-zucho/milestone_1 | /main.py | 2,192 | 4.375 | 4 | # milestone one - movie filing system
""""
- must allow to add new movies to collection
- must allow users to view all the movies in the collection
- allow user to find movie by any attribute
[] - tell user options: 'a' - add, 's' - show, 'f' - find, 'q' - quit program
[x] - what format is a movie ~~~~~list of dict... |
19ce38fa3ba6474cf06e542d3a06a267c11641ea | lajapathy/python-practice | /dataStructures/singly_linked_list.py | 2,157 | 4.09375 | 4 | #implement singly linked list with the following methods
# Insert: inserts a new node into the list
# Size: returns size of list
# Search: searches list for a node containing the requested data and returns that node if found, otherwise raises an error
# Delete: searches list for a node containing the requested data and... |
064506e9437c156f07aad02e3204029abcce0c8c | upasek/python-learning | /conditional_statements_and_loops/csl_char_Z.py | 346 | 4.21875 | 4 | #Write a Python program to print alphabet pattern 'Z'.
string = ''
print("Expected output : ")
num = 5
for r in range(7):
for c in range(7):
if r == 0 or r == 6 :
string += '*'
elif c == num:
num -= 1
string += '*'
else:
string += ' '
stri... |
913c4a4057a8caca9a3fb61224cd09f66a5957eb | AthosFB/Exercicios-Python | /ExercícioDoCurso/017.py | 184 | 3.78125 | 4 | import math
n = float(input('Coloque um cateto: '))
n2 = float(input('Coloque o outro cateto: '))
hipo = math.hypot(n, n2)
print('A ipotenusa de {} e {} é {:.2f}'.format(n, n2, hipo)) |
74a599b5629d3ae370e03b87d252970aa9f30a44 | owis1998/project-euler | /problem 7/problem.py | 207 | 3.671875 | 4 | import math
def is_prime(n):
for i in range(2, int(math.sqrt(n)) + 1):
if n % i == 0:
return False
return True
n = 1
index = 1
while index != 10001:
n += 2
if is_prime(n):
index += 1
print(n)
|
f3d088e0092c72ce8393e40269280cfb07386fab | wgsantos97/Crime-Analysis | /append.py | 518 | 3.6875 | 4 | import csv
import pandas as pd
def main():
filename = "crime_data.csv"
endfile = "crime_data_update.csv"
print("Converting " + filename + " to pandas dataframe")
df = pd.read_csv(filename, dtype={'Longitude':str,'Location':str})
print("Converting Date columns to datetime")
df['Date'] = pd.to_datetime(df['Dat... |
285903c57ff4064a9c01daa551fd25b567c9502f | drekuru/CSUS-CPE-CSC-EEE-Materials | /PHYS 162/Homework/05plotting/hw5p3.py | 6,216 | 4.40625 | 4 | # -------------------------------------------------------------------------------
# HW05 - Plotting
# -------------------------------------------------------------------------------
# Imports
import numpy as np
import matplotlib
import math
from math import cos
from math import sin
from math import tan
from math impor... |
db7700ad38299b628b8edbf78eb4234382e5c189 | swatimahajan/python_programs | /self_powers.py | 266 | 3.546875 | 4 | #inp = input()
def power(inp):
sum_result =0
for i in range(1,inp+1):
result = pow(i,i)
sum_result += result
a = str(sum_result)
last_ten_ele = a[-10:]
if last_ten_ele[0] == '0':
print last_ten_ele[-9:]
else:
print last_ten_ele
inp= input()
power(inp)
|
b13fc9c8f741f9c73d2db3f0604576345ef52f9e | robgoyal/CodingChallenges | /CodeFights/Arcade/Intro/rainsOfReason/alphabeticShift.py | 324 | 3.765625 | 4 | # Name: alphabeticShift.py
# Author: Robin Goyal
# Last-Modified: July 13, 2017
# Purpose: Return new string with each character of input string
# shifted by 1
def alphabeticShift(inputString):
# Use moduolo to wrap around for character z
return "".join([chr((ord(i) - 97 + 1) % 26 + 97) for i in inpu... |
553f469205264cb581c61ab17d2cb30232b199d8 | janam111/datastructures | /Tree/Nodes at K distance.py | 402 | 3.71875 | 4 | from Node import Node
def node_at_k(root, k):
if not root:
return
if k == 0:
print(root.val)
node_at_k(root.left, k - 1)
node_at_k(root.right, k - 1)
root = Node(1)
root.left = Node(2)
root.left.left = Node(3)
root.left.right = Node(4)
root.right = Node(5)
root.right.left = Node(6)... |
87850a28b7100a44bd2c7f0ba36913900aab92e6 | rajacheers/mltrain | /akshaya1/list.py | 833 | 4 | 4 | print "Size of the list:"
n=int(input())
user=raw_input("Enter list1 of numbers : ")
a=[int(n) for n in user.split(' ')]
print "Enter list2 of strings : "
b=[]
for x in range(5):
x=input("")
b.append(x)
print "Enter list3 of numbers and strings : "
c=[]
for x in range(5):
x=input("")
try:
c.appe... |
5bd7b03d0df390af22a13e6264910e49e73abb7f | gmayock/blog_msco_ch02_naive_models_for_predicting_stationary_time_series_data | /MSCO_Chapter_2_Instruction_part_1.py | 1,661 | 3.609375 | 4 | import matplotlib.pyplot as plt
import pandas as pd
df = pd.read_excel('filepath/chapter_2_instruction.xlsx', sheet_name='2.3.1_table_2.1', header=None, index_col=0).T
df.reset_index(drop=True, inplace=True)
print(df)
# # This is the simple scatter plot
plt.ylabel('Widget Demand (000s)');
plt.ylim(0,15);
pl... |
088a38597e0eb5af93b6527fafac4de153b98def | swcho84/ROS101 | /hello_world_ros/include/tmtc/pymavlink/quaternion.py | 18,840 | 3.734375 | 4 | #!/usr/bin/env python
"""
Quaternion implementation for use in pymavlink
"""
from __future__ import absolute_import, division, print_function
from builtins import object
import numpy as np
from .rotmat import Vector3, Matrix3
__author__ = "Thomas Gubler"
__copyright__ = "Copyright (C) 2014 Thomas Gubler"
__license... |
0a372c7e84d1997a4b6f3f02c9126794bee7c5e4 | shadowstep666/phamminhhoang-fundamental-c4e25 | /section1/homework/day1/square.py | 175 | 3.65625 | 4 | from turtle import *
color("yellow")
fillcolor("yellow")
begin_fill
shape("arrow")
speed(100)
for i in range(4) :
forward(200)
left(90)
end_fill
mainloop() |
f50cb76043a7390c5ea71c77181ca3f7aebed9e0 | infinitevoid/algorithms | /py/algo/dynamic/subsequence/longest_increasing.py | 1,274 | 3.890625 | 4 | from typing import List, Any
def binary_search(array: List[Any], key: Any, left: int, right: int):
while right-left > 1:
m = (right+left) // 2
if array[m] > key:
right = m
else:
left = m
return right
def longest_increasing_subsequence(array: List[... |
7958915e4f361775d52289a35698112cdfb251e6 | ritendubhattacharyya/Python | /ResturantManagement.py | 15,809 | 3.609375 | 4 | from tkinter import *
from tkinter import messagebox
import random
# start coding
# global variables
calculator_entry=""
sum = 0
# Commands
def getNumber(number):
global calculator_entry
calculator_entry = calculator_entry + number
calc_entry.delete(0, END)
calc_entry.insert(0, calculator_entry)
... |
b13ffd68cfeb058ed88781394de714186e88cc87 | wb9/Python | /Mars/baner.py | 628 | 3.515625 | 4 | def baner():
dlugosc_banera = float (input ("Podaj długośc banera w metrach: "))
wysokosc_banera = float (input ("Podaj wysokość banera w metrach: "))
calkowity_wymiar_banera = wysokosc_banera*dlugosc_banera
cena = 0
if calkowity_wymiar_banera <= 5:
cena = calkowity_wymiar_banera*50
el... |
a9b79cb30fab07cf05ae76c2561809ce305e0e42 | Collins-Kibet/Email-Spam-Classification | /knn.py | 8,382 | 4.3125 | 4 | '''knn.py
K-Nearest Neighbors algorithm for classification
Collins Kibet
CS 251 Data Analysis Visualization, Spring 2021
'''
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
from palettable import cartocolors
from scipy.stats import mode
class KNN:
'''K-Nearest Neighb... |
4e2d73c214cc9ff94a363733c249b478ad8b19c9 | riyag283/Leetcode-July-20-Challenge | /quest15.py | 246 | 3.625 | 4 | def func(s):
revs = ''
word = ''
s += ' '
for l in s:
if l != ' ':
word += l
else:
revs = word + ' ' + revs
word = ''
return revs.strip()
print(func('Hello Miki, Me Mini'))
|
d6df71149e7bb07531890d2e328eea6dde6e7147 | gschen/sctu-ds-2020 | /1906101036-贾婧媛/day0225/test02.py | 2,253 | 3.71875 | 4 | list1 = [1,2,3,2,6,10,1]#求出最大的数
a = list1[0]
for i in list1:
if i > a:
a=i
print(a)
list2 = [1,2,3,4,'a',1]#求数组中所有数字之和
sum=0
for i in list2:
if isinstance(i,int):
sum = sum + i
print(sum)
x=5#判断5是否为素数
for i in range(2,x):#如果for循环中没有出错和遇到break
if x % i == 0: #就会执行else
print("不是素数... |
cb18b15767bc4913626fc49cb0b6514d70a60857 | hjq133/leetcode | /常用经典算法/continuous_sub_sequence.py | 414 | 3.5625 | 4 | # 最大子区间和
# 动态规划
# res[i]表示以i结尾的子序列的最大和
class Solution:
@staticmethod
def maxSubArray(nums):
res = [nums[0]] # 初始化以nums[0]结尾的数组的最大子序和
for i in range(1, len(nums)):
res.append(max(res[i - 1] + nums[i], nums[i]))
return max(res)
lst = [0, 1, -2, -4, 9, 1, 0]
print(Solution.... |
4717336ad1bbff7447fd05b805fc3697e9af21b4 | jabhij/UTAx-CSE1309x-PYTHON | /QUIZ-2/Part4.py | 208 | 4.21875 | 4 | # Type your code here
val = input('Enter:')
n = int(val)
if (n%2 == 0) and (n%3==0):
print ("BOTH")
elif (n%2 == 0) or (n%3 == 0):
print ("ONE")
elif (n%2 != 0) and (n%3 != 0):
print ("NEITHER")
|
91aa35759a0545ce6190087e1ff83fc4ea15c64b | gonghaozhang/163hw4 | /document.py | 2,950 | 4.21875 | 4 | """
Name: Anastasia Stevens
NetID: asteves
Section: CSE 163 AC
document.py defines a class to find the term frequency of each unique word in a
document.
"""
import re
class Document:
"""
The Document class represents a document and contains methods related to
the term frequency of unique words in this do... |
1741d8f80880af27ca41590bbab6f4e5540ddd5d | C-CCM-TC1028-111-2113/homework-3-CitlaliRodsan | /assignments/08TarjeteriaEspanola/src/exercise.py | 541 | 3.875 | 4 | import math
def tarjetas(pliegos, plumones):
pliego=pliegos*12
plumon=plumones*35
if pliego<plumon:
tarjetas=math.floor(pliego)
else:
tarjetas=math.floor(plumon)
return tarjetas
def main():
#escribe tu código abajo de esta línea
pliegos=int(input("Dame la cantidad de pliego... |
da1e2363377a9b6305fecc943ad716865c5cb218 | MManopoli/TamingBigDataWithSparkAndPython | /18_sorting_results_in_Spark/word-count-better-sorted.py | 1,124 | 3.546875 | 4 | import re
from pyspark import SparkConf, SparkContext
conf = SparkConf().setMaster("local").setAppName("WordCount")
sc = SparkContext(conf=conf)
input = sc.textFile("/home/mmanopoli/Udemy/TamingBigDataWithSparkAndPython/data/Book.txt")
def normalizeWords(text):
return re.compile(r"\W+", re.UNICODE).split(text.lo... |
dfbd2918e37b1fb6e179605300ce2db7e7f73a26 | ThalesAzevedo/studies-python | /ex006_dobro_triplo_e_a_raiz_quadrada.py | 342 | 3.796875 | 4 | exer="EXERCÍCIO 006"
tema='Dobro, Triplo e a Raiz Quadrada'
print('{:=^100}'.format(exer))
print('{:=^100}\n'.format(tema))
n=float(input('Digite um número qualquer:\n'))
dn=n*2
tn=n*3
rn=n**(1/2)
print('O dobro de {} é {}'.format(n, dn))
print('O triplo de {} é {}'.format(n, tn))
print('A raiz quadrada de {} é {:.5... |
d45642fea9e916d72b0ed6af646ba352cac77765 | deeqkko/pk-js-spa | /python/calcFromFile.py | 966 | 4.3125 | 4 | """Make a program which reads a text file, which can have any number of floating point numbers, which are all in their own lines.
The program will calculate and display the sum and average (mean) of all these numbers. Make your program fool proof.
It should handle all common errors and ignore those lines of the input t... |
60283dff101d04fd1b1ae9cf1ea75dc399bce5ac | 3NCRY9T3R/H4ck3rr4nk | /Python/Python_If-Else.py | 193 | 4.03125 | 4 | a=int(input())
if(a%2!=0 or a==1):
print("Weird")
if((a%2==0) and 2<a<5):
print("Not Weird")
if((a%2==0) and 6<a<=20):
print("Weird")
if((a%2==0) and a>=21):
print("Not Weird")
|
60e62008379fec4e59dba2d6efd4a6896a964c45 | 524860249/Algorithmic-learning-notes | /03-分治法/合并排序/MergeSort.py | 746 | 3.90625 | 4 |
def merge(left,right):
temp = [];
i = j = 0;
while i < len(left) and j < len(right):
if left[i] < right[j]:
temp.append(left[i])
i += 1
else:
temp.append(right[j])
j += 1
if j == len(left):
for item in left[i:]:
temp.ap... |
b0912e17a5530a2b881124832b941f72467a07a1 | binlu1981/python | /leetcode/1_Two_Sum.py | 1,367 | 3.890625 | 4 | """
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1].
UPDATE (2016/2/13):
The return format h... |
9c6156a5972588264ae01fd68e61e2a4ec7d9680 | ltzp/LeetCode | /剑指offer/最长不含重复字符的子字符串.py | 1,095 | 3.578125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2021/01/12
# @Author : yuetao
# @Site :
# @File : 最长不含重复字符的子字符串.py
# @Desc :
"""
输入: "abcabcbb"
输出: 3
解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。
"""
class Solution(object):
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:... |
807bff654d49c11cc76cfd13b55bbb21102428fd | xavierloos/python3-course | /Basic/Strings/Methods/join.py | 1,205 | 4.375 | 4 | # 1.You’ve been provided with a list of words from the first line of Jean Toomer’s poem Reapers.
# Use .join() to combine these words into a sentence and save that sentence as the string reapers_line_one.
reapers_line_one_words = ["Black", "reapers", "with",
"the", "sound", "of", "steel", "on... |
c08b6cf72e541db92d28966740983891339116fa | sandipthapa99/365-Days-of-Coding | /142-Tkinter canvas.py | 472 | 4.15625 | 4 | from tkinter import *
# create a tkinter window
root = Tk()
# window title
root.title(" My Program")
# Label for Text Area
Label(root, text='First Name').grid(row=0)
Label(root, text='Last Name').grid(row=1)
# Initializing Entry bject for Text Boxes
textBox1 = Entry(root)
textBox2 = Entry(root)
# Placing Text Boxes... |
9f5d1c6ded25ba07e4f0491876aa25d1c8c3e161 | cerver1/Python-Sprint | /valueComputed.py | 155 | 3.5625 | 4 |
sample = input("Please enter an integer: ")
a = int(sample)
b = int(sample + sample)
c = int(sample + sample + sample)
result = a + b + c
print(result) |
bb2f01149245c0c61bd6c89b01f107d69f907352 | MikeRollin/mars-rover-challenge | /test.py | 3,505 | 3.765625 | 4 |
import grid
#5 5
#
#1 2 N
#
#LMLMLMLMM
#
#3 3 E
#
#MMRMMRMRRM
theGrid = grid.Grid(5,5);
validMoveOrientations = ['R','L','M','V'];
def handleInput(stringInput = ''):
instructions = stringInput.split(' ');
global theGrid;
#potential setup of new grid
if len(instructions) =... |
3555803b131b2a2ff08977e1e1668dd2ac2de1ee | jcallin/eSeMeS | /dictionary.py | 816 | 4.09375 | 4 | from PyDictionary import PyDictionary
def dictionary(command):
dictionary = PyDictionary()
words = command.split()
choice = words[0]
word = str(words[-1])
print(choice)
print(word)
try:
if choice == "define":
definition = str(dictionary.meaning(word))
retur... |
eae889362dee2cf57324b12c08adfa705cd9cacd | Prithamprince/Python-programming | /string11.py | 90 | 3.625 | 4 | e=input()
l=[]
for i in e:
if(i.isnumeric()):
l.append(i)
print(*l,sep="")
|
f73c8869b52e4d58588df49734eb75be1d43cf17 | PaulMcMillan/django | /django/utils/checksums.py | 729 | 3.515625 | 4 | """
Common checksum routines.
"""
__all__ = ['luhn',]
from django.utils import six
LUHN_ODD_LOOKUP = (0, 2, 4, 6, 8, 1, 3, 5, 7, 9) # sum_of_digits(index * 2)
def luhn(candidate):
"""
Checks a candidate number for validity according to the Luhn
algorithm (used in validation of, for example, credit cards... |
27a180994a6508b08a7e2fa18f7b7d412465632e | valleyceo/code_journal | /1. Problems/b. Strings & Hash/a. Palindrome - Manacher - Palindrome Substrings.py | 1,889 | 3.8125 | 4 | # LC 647. Palindromic Substrings
'''
Given a string s, return the number of palindromic substrings in it.
A string is a palindrome when it reads the same backward as forward.
A substring is a contiguous sequence of characters within the string.
Example 1:
Input: s = "abc"
Output: 3
Explanation: Three palindromic s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.