blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
441a34fbc020396140ba93ca743e0efd7355fe78 | efrigo88/Python-Course-Udemy | /01. HelloWorld/sequence_operators.py | 405 | 3.546875 | 4 | string1 = 'He\'s '
string2 = 'probably '
string3 = 'pining '
string4 = 'for the '
string5 = 'fjords'
print(string1 + string2 + string3 + string4 + string5)
print()
print('Hello ' * 5)
print('Hello ' * (5 + 4))
print('hello ' * 5 + '4')
print()
today = 'friday'
print('fri' in today) # True
print('day' in today) ... |
11a4aad1e6eeebaa62e4e54d3a32b26eec9119ee | joekreatera/math-integration | /RiemannTest.py | 987 | 3.890625 | 4 | #riemann rest for integration
def linear(x):
return x
def quadratic(x):
return x*x
def riemannIntegration(fn,a,b,n):
integrationTotal = 0
base = (b-a)/n
halfBase = base/2
for i in range(0,n):
integrationTotal = integrationTotal + fn(i*base+halfBase)
return (integrationTotal*base... |
b541bcbff56bcc0ed07b5d5f4d4940c4b3e35e86 | jinyoungch0i/Flask-Development | /flaskblog17.py | 9,219 | 3.703125 | 4 | def line_break(x):
print(str(x) + '---------' + str(x) + '---------' +
str(x) + '---------' + str(x) + '---------')
lb = line_break
'''
~appendix
* this is the seventeenth note on building a python flask application *
~lb(0): note on flask debug tool
~lb(1): custom validator for already taken username ... |
cfb1b1562e75fe76678c81b6413110e3a79e4ee9 | ballib/Forritun1 | /Æfingaverkefni1/dæmi2.py | 138 | 4 | 4 | x = int(input("Enter a integer: "))
y = int(input("Enter another integer: "))
f = int(input("Enter another ineger: "))
z = x+y+f
print(z) |
0fad4a31f8b05b8ade59552813354372774783c4 | DominiDeliya/pythonExamples | /find_duplicates_2.py | 163 | 3.640625 | 4 |
seq = [2,3,2,-1,5,3,-1,3]
seq.sort()
counter = 0
seen = ''
for elm in seq:
if elm == seen:
counter += 1
else:
seen = elm
print(counter)
|
8aef2bd6df0bac803fee802b35a34abde016eef4 | veikkoEF/TkInterWithPython | /3_Button2.py | 544 | 3.96875 | 4 | from tkinter import *
from tkinter import messagebox
# Event-Definition
def button_action():
messagebox.showinfo(message="Eine Meldung", title = "Infos")
# Ein Fenster erstellen
window = Tk()
# Den Fenstertitle erstellen
window.title("Hello World")
# Definition von GUI-Elementen
button = Button(window, tex... |
84eba9e631285d50764e75a060a4167fe6a1e184 | henriquelorenzini/EstruturasDeDecisao | /Exercicio05.py | 819 | 4.28125 | 4 | #Faça um programa para a leitura de duas notas parciais de um aluno. O programa deve calcular a média alcançada por aluno e apresentar:
#A mensagem "Aprovado", se a média alcançada for maior ou igual a sete;
#A mensagem "Reprovado", se a média for menor do que sete;
#A mensagem "Aprovado com Distinção", se a média for ... |
5a56e6b393b6431fda9770256116edcec097be31 | JAYESH-ALAGH/Study_Assist_App | /speech__recognition.py | 1,248 | 3.5625 | 4 | def speech_to_text():
from subprocess import call
import speech_recognition as sr
import os, time
r= sr.Recognizer()
text = {}
text1 = {}
def listen1():
with sr.Microphone(device_index = 2) as source:
r.adjust_for_ambient_noise(source)
... |
1bcaf7963ecc9cf352d74d3c901be84690cc69c2 | dstruiksma/advent_of_code | /2020/py/day3.py | 895 | 3.921875 | 4 | def main():
f = open("/home/detmer/programming/aoc/2020/aoc_input/input_day3.txt", "r")
snowslope = []
for line in f:
snowslope.append(line)
print("Product of amount of trees of all slopes:", traverse(1,1,snowslope) * traverse(3,1,snowslope) * traverse(5,1,snowslope) * traverse(7,1,snowslope) * traverse(1,2,sn... |
2c7f5d37f6858a4540abd8d4ab5ba26f569a7670 | deep2612/Simple-Linear-Regression | /SimpleLRGradientDescent.py | 2,722 | 3.5625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 5 17:33:13 2020
@author: deep
"""
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
def gradientDescent(alpha, X, Y, ep = 0.0001, max_iter = 5000):
print('Gradient Descent Model Begins : ')
converged = False
iter =... |
11f36bef818b389ba90496742f0ed601dff502a3 | loopDelicious/csinterviews | /pramp/merging.py | 1,185 | 3.71875 | 4 | """
Merging 2 Packages
Given a package with a weight limit and an array arr of item weights,
how can you most efficiently find two items with sum of weights that equals the weight limit?
Your function should return 2 such indices of item weights or -1 if such pair doesn't exist.
What is the runtime and space complexi... |
480ba8c83ed6ad387e4a50142dd14da48200bd81 | moinox80/cm2110-2021-coursework-arctic-flunkies | /run_window_old.py | 2,476 | 3.59375 | 4 | import window as w
import Weather_api as wa
import window_mechanism as wm
import curtain as c
import os
import csv
window = w.Window()
api = wa.WeatherApi()
window_mechanism = wm.WindowMechanism()
curtain = c.Curtain()
with open('user_data.txt', mode='r') as csv_file:
csv_reader = csv.DictReader(csv_file)
li... |
3e3b39f2a8e78dfd142a60dc496da8026dae2504 | Krebbet/work2vec_workshop | /xxxx_code.py | 10,260 | 3.703125 | 4 |
def build_dataset(words, n_words):
"""Process raw inputs into a dataset.
This function will
1) count the number of occurances of each word
2) collect the n_words most common words
3) give each word a unique number id
"""
'''
words -> the corpus of words...
... |
9c5e5c2470e4a8f3552d242e1c870ed065f8f170 | makutene/python | /projectEuler_32.py | 807 | 3.828125 | 4 | #We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital.
#The product 7254 is unusual, as the identity, 39 × 186 = 7254, containing multiplicand, multiplier, and product is 1 through 9 pandigital.
#Find t... |
929cd6e9da8fea824ec872d7a2e59a2bc95b0d75 | Kiranshankarbhat007/Python-basic- | /print_N_no.py | 123 | 3.984375 | 4 | n = int(input("enter a number up to which u want to print:"))
def n_no(n):
for i in range (n):
print i
n_no(n) |
da1c289f46adeebe25290cacbd974ab4423e558a | renatolaq/Python-Design-Paterns | /testa_conta.py | 14,632 | 4.09375 | 4 | import abc
from datetime import datetime
from abc import ABC, abstractmethod
class Cliente(ABC.abc):
def __init__(self):
pass
@abc.abstractmethod
def teste_abstract(self):
pass
class Transacao:
def gera_transacao(self, dt, operacao, valor):
a = 0
return {'data': dt,... |
a9167b55354e4c0d30089e443114125d413662a4 | Brian-Ckwu/discrete-mathematics | /1_mathematical_thinking_in_computer_science/n_queens.py | 1,593 | 3.796875 | 4 | """
Finding the solutions to the N Queens problem (place n queens on a n*n chess board):
1. Brute-force search
2. Backtracking
"""
import itertools
# 1. Brute-force search
# Time complexity: O(n^2) (n == length of perm)
def is_solution(perm: tuple) -> bool:
for i1, i2 in itertools.combinations... |
b2cb44e2cd287d580eefd56466a95326ca7e8923 | calick/pythonSample | /基礎/問題/case_0003/case_0003.py | 113 | 3.71875 | 4 | # coding: UTF-8
num=25
if(num>=10):
print("Bye")
else:
print("Hi")
if(num>=25):
print("Konnichiha")
|
6cc547ac909ca081aaac7232451c21dfd9cada3e | Asunqingwen/LeetCode | /简单/有效的山脉数组.py | 1,031 | 3.8125 | 4 | '''
给定一个整数数组 A,如果它是有效的山脉数组就返回 true,否则返回 false。
让我们回顾一下,如果 A 满足下述条件,那么它是一个山脉数组:
A.length >= 3
在 0 < i < A.length - 1 条件下,存在 i 使得:
A[0] < A[1] < ... A[i-1] < A[i]
A[i] > A[i+1] > ... > A[A.length - 1]
示例 1:
输入:[2,1]
输出:false
示例 2:
输入:[3,5,5]
输出:false
示例 3:
输入:[0,3,2,1]
输出:true
提示:
0 <= A.length <= 10000
... |
07cae87fa7fe78e70b04f3195e92838379e012f1 | neilbaruwati/Python | /python_basic_programs/class3_1.py | 3,473 | 4.03125 | 4 | x = True
print ("The initial state of x: ", x)
print("The type of x:", type(x))
x = not x
print("after not operation and assignment, the state x is",x)
x = 3
y = 4
print ("x=",x,"y=",y)
print("x==y returns", x==y)
print("x!=y returns",x!=y)
print("x>y returns", x>y)
print("x<y returns", x<y)
print ("x>=y returns",x>=... |
9b762b7494e73b596d6f991f56d04624b3e43a93 | rodrigueslopesantosdev/FirstRestApiPython | /Data control/Funcoes.py | 812 | 4.03125 | 4 | #funcoes.py
#Usando funções como parametro de tupla
#no exemplo abaixo o parâmetro valores é uma tupla
# #
def nomeFuncao (*valores):
return valores
#FUNÇÃO map(funcao_definida, lista_elementos)
#
##
def exponencial(base, expo):
return base**expo
elementos = [1,2,3]
'''
lista = map(exponencial, elementos)
... |
2499ef1e100a94c09acaec67dcff658d908a362b | forgetbear/B_PYTHON_GIS | /PythonForArcGIS/SF_PFA2/ch12/script/argPrint.py | 222 | 3.921875 | 4 | # argPrint.py
# Purpose: Print args with built-in 'enumerate' function.
# Usage: Any arguments.
# Example input: 500 miles
import sys
for index, arg in enumerate(sys.argv):
print 'Argument {0}: {1}'.format(index, arg)
|
9befa5ae7272957fdbdc3f0e7b8d4e5927e767d4 | kapokjyz/python | /06_if_else.py | 720 | 4.03125 | 4 | # 条件判断,是自动化必不可少的部分,根据不同的情况做出不同的选择
age = 20
if age >= 18:
print('adult')
elif age >= 6:
print('teenager')
else:
print('kid')
# if 判断条件可以简写
# if x:
# print('True')
# 只要x是非零数值,非空字符串,非空list等,就判断为True,否则为False
# input()函数返回的是str类型
age = input('please enter you age: ')
# 下面这样直接判断就会报错,因为str类型不能直接和整数比较,需要把str... |
4c84817608b7845b2cb7f5f358ad4a0654011d2e | JaleelAhmed/Python-Advanced | /oops/Override.py | 395 | 3.875 | 4 | class User:
name = ""
def __init__(self, name):
self.name = name
def printName(self):
print "Name = " + self.name
class Programmer(User):
def __init__(self, name):
self.name = name
def printName(self):
print "NameProgrammer = " + self.name
brian = User("Sriniva... |
a08e7accbd7bc36c25830996418bb6c447b24147 | KennethJHan/Bioinformatics_101 | /P045.py | 605 | 3.59375 | 4 | import sys
def Mer(n, arr1, arr2):
if n == 1:
return arr2
else:
arr_tmp = []
for i in arr1:
for j in arr2:
arr_tmp.append(i+j)
arr2 = arr_tmp
n -= 1
return Mer(n, arr1, arr2)
def isPalindrome(s):
l = 0
h = len(s)-1
while(... |
0163f956a3e9df34577abe09b7a713c36be053bd | usako1124/teach-yourself-python | /chap10/ex_10_1.py | 417 | 3.515625 | 4 | class Pet:
def __init__(self, kind, name): # __new__ じゃなくて __init__
self.kind = kind
self.name = name
def show(self): # self が必要?
print(f'わたしのペットは{self.kind}の{self.name}ちゃんです!')
if __name__ == '__main__': # app じゃなくて main
p = Pet('ハムスター', 'のどか') # new いらない
p.show() # -> じゃ... |
5e1ecdc93e4be6302458de50017e7b40e5244a2b | MrHamdulay/csc3-capstone | /examples/data/Assignment_5/sttjos003/mymath.py | 316 | 4.125 | 4 | def get_integer (x):
y=input("Enter " + x + ":\n")
while not y.isdigit():
y=input("Enter " + x + ":\n")
x=eval(y)
return (x)
def calc_factorial (x):
i=1
y=x
while i<y:
x=x*i
i=i+1
return (x) |
fd98b583d33e9e9dbdd9698a937d716a30d1d219 | Aadil101/mini-solar-system | /body.py | 1,315 | 3.640625 | 4 | #body.py
#Aadil Islam
#February 8, 2018
from cs1lib import *
class Body:
# body constructor
def __init__(self, mass, x, y, vx, vy, pixel_radius, r, g, b):
self.mass = mass
# for body movement
self.x = x
self.y = y
self.vx = vx
self.vy = vy
# for draw... |
63b3c5c2aebc94321bcd96af57763feb25645de6 | davide-butera/data-analysis-with-python | /part02/part02-e04_word_frequencies/src/word_frequencies.py | 548 | 3.859375 | 4 | #!/usr/bin/env python3
def word_frequencies(filename="src/alice.txt"):
with open(filename, 'r') as content_file:
dictionary = {}
for line in content_file:
content = line.split()
for word in content:
word = word.strip("""!"#$%&'()*,-./:;?@[]_""")
... |
8a36a3bf707af30c3a2cf22f89bf0379bb784c18 | Ozcry/PythonCEV | /ex/ex029.py | 567 | 3.765625 | 4 | '''Escreva um programa que leia a velocidade de um carro.
Se ele ultrapassar 80Km/h, mostre uma mensagem dizendo que ele foi multado.
A multa vai custar R$7,00 por cada Km acima do limite.'''
v = float(input('\033[34mDigite a velocidade do carro:\033[m '))
m = (v - 80) * 7
if v > 80:
print('\033[31mVocê foi multado... |
042189e68f8787bce947e049b4ff5da70d63fccf | jacobgillette/CS362_HW7 | /leapyear.py | 400 | 3.6875 | 4 | import unittest
def fun(user_in):
if user_in < 1:
return "Invalid Input"
if user_in % 4 == 0:
if user_in % 100 == 0:
if user_in % 400 == 0:
return "Input is a leap year"
else:
return "Input is not a leap year"
else:
re... |
bfd6e98f6142eb53b9adae85fd34469c2c3b2cb4 | AKDavis96/Data22python | /dictionary/forloop.py | 190 | 3.84375 | 4 | list_data = [1, 2, 3, 4, 5]
for num in list_data:
print(num*2)
embedded_list = [[1,2,3], [4,5,6]]
for data in embedded_list:
print(data*2)
for num in data:
print(num*2) |
96f4bee0dc6e28a3f90221fa85f1db73a7999424 | rono2845/Chat-App | /server.py | 972 | 3.59375 | 4 | import socket
from tkinter import *
## USING TKINTER TO GIVE IT A LOOK
def send(listbox, entry):
message = entry.get()
listbox.insert('end', "Server: "+message)
entry.delete(0,END)
client.send(bytes(message, "utf-8"))
receive(listbox)
def receive(listbox):
message_from_client = client.recv(50)... |
35a47b06b86cfcbcdf5426e52042eb202c04bd45 | chicocheco/automate_the_boring_stuff | /time_calc_prod.py | 455 | 3.515625 | 4 | import time
# Another way to profile your code is to use the cProfile.run() function.
def calc_prod():
# Calculate the product (nasobek in Czech) of the first 100,000 numbers.
product = 1
for i in range(1, 100000):
product *= i
return product
start_time = time.time()
prod = calc_prod()
end_... |
221ca899e96994d05da974715ea57d8cacebb371 | terrifyzhao/leetcode | /other/subarray_product.py | 574 | 3.515625 | 4 | class Solution(object):
def maxProduct(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
max_num, min_num, res = nums[0], nums[0], nums[0]
for num in nums[1:]:
tmp_max = max_num
tmp_min = min_num
max_num = max(num, tmp_max * n... |
d31c75fbfd3067ee7a99c683c8352c5d31946aed | vincenttuan/yzu_python | /lesson09/sql2/CreateTable.py | 445 | 3.671875 | 4 | import sqlite3
sql = '''
CREATE TABLE Employee(
ID INT PRIMARY KEY NOT NULL,
NAME VARCHAR(20) NOT NULL,
AGE INT NOT NULL,
ADDRESS VARCHAR(50),
SALARY REAL
);
'''
conn = sqlite3.connect... |
0c24677ed0689390fe53294bb9729f6767fc2d63 | tinynahran/Practical-Python-with-Applications-in-Finance | /Chapter2/2_1_5_main.py | 1,271 | 3.703125 | 4 | '''
This module validates methods created as part of exercise 2.1.5.
'''
from classFiles.loan import Loan
from classFiles.car import Lexus
def main():
# This is for validation of the static methods monthlyRate and annualRate.
print('Annual rate converted to monthly rate for simple interest: '
+ str... |
e3bbf6741cc76c295ba4b20540d48c3819e44ce3 | Aasthaengg/IBMdataset | /Python_codes/p03624/s543789215.py | 143 | 3.640625 | 4 | alpha="abcdefghijklmnopqrstuvwxyz"
S=input()
for i in range(len(alpha)) :
if alpha[i] not in S :
print(alpha[i])
exit()
print("None") |
99f4b3bc990764982731c8626a46bd0b67a742ce | huiyi1993/store | /day03/作业5+-调换.py | 162 | 3.75 | 4 | A = input("请输入A:")
A = int(A)
B = input("请输入B:")
B = int(B)
print("A=",A)
print("B=",B)
C = A+B
A =C-A
B =C-B
print("A=",A)
print("B=",B)
|
e5a264fa3f1c4ec634ed156bf1ba39a802915441 | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_209/605.py | 1,218 | 3.671875 | 4 | import os # NOQA
import sys # NOQA
import re # NOQA
import math # NOQA
from collections import Counter, deque, namedtuple # NOQA
from itertools import count, product, permutations, combinations, combinations_with_replacement # NOQA
# Itertools Functions:
# product('ABCD', repeat=2) AA AB AC AD ... |
2f47a781020c9955a395154d4c36f6df7eb51b4b | mychristopher/test | /pyfirstweek/tkinter学习/Entry控件.py | 585 | 3.78125 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import tkinter
#创建窗口
win = tkinter.Tk()
#设置标题
win.title("caicai")
#设置大小和位置
win.geometry("400x400+200+20")
#绑定变量
e = tkinter.Variable()
#用于显示简单的文本内容
#show 密文显示show="*"
def showInfo():
print(entry.get())
entry = tkinter.Entry(win,textvariable=e)
entry.pack()
button = tk... |
35d8d0628cc5b27d3d5bada8a400a1cd426f42fe | ahammer3/UCSD-AlgorithmicToolbox | /code/fibonacci_last_digit.py | 369 | 3.921875 | 4 | # Uses python3
import sys
def fibonacci_last_digit(n):
nums = [None] * (n+2)
nums[0] = 0
nums[1] = 1
for i in range(2, n+1):
nums[i] = (nums[i-1] + nums[i-2]) % 10
return nums[n]
if __name__ == '__main__':
# for stdin, end input with newline and CRTL + D
input = sys.stdin.read()... |
a88f8251ad55e7cdcfacfaa4a02dac87f951f9cd | kinetic-cipher/algorithms | /sorting/merge_sort.py | 2,103 | 4.28125 | 4 | # MergeSort
#
# Recursively splits into (left, right) sublists (down to length 1) and then
# recursively merges back up to a single list, with the sorting occurring
# during the merge.
#
import math
# merge two sublists
def merge(left_list, right_list):
result = list()
# merge sublists
# left and righr ... |
01b01a7b660b3afa7391bf61a3c3e990b8051c5e | kazhiryu187/myProgramming | /c2f.py | 178 | 4.1875 | 4 | # Celsius to Fahrenheit converter
cel = float(input('Temperature in Celsius: '))
#cel = int(cel)
fah = (cel * 9/5) + 32
print("{} Celsius = {} Fahrenheit ".format(cel, fah))
|
61d64bae1126bb6a134a9ef4e11cc4acf4db79ab | anmig13/Testing_GithubAPI_example | /Testing_GithubAPI/main.py | 696 | 3.734375 | 4 | from person import Person
from hello_world import Hello_World
def main():
# tworzymy dwa obiekty klasy Osoba
Jan = Person("Jan", "Nowak", 48)
Adam = Person("Adam", "Mickiewicz", 220)
# wywołujemy metodę przedstaw_sie() na każdym z nich
Jan.przedstaw_sie()
Adam.przedstaw_sie()
... |
302d7ef0e55442003fafe1367048f9d89a55622f | igauravsehrawat/HackerRank | /week-18/ghosts.py | 748 | 3.515625 | 4 | #!/bin/python
def gcd(number1, number2) :
looper = 1
gcd_number = 1
while ((looper <= number1) or (looper <= number2)) :
if ((number1 % looper == 0) and (number2 % looper ==0)) :
gcd_number = looper
looper += 1
return gcd_number
def main() :
A,B,C,D = raw_input().strip().split(' ')
A,B,C,D = [int(A),int(... |
83e67e9267fd5557aaf3755441032ec364ac15f5 | seunghyon/algorithm | /leetcode/11. Container With Most Water.py | 346 | 3.640625 | 4 | def maxArea(heights):
start,end = 0, len(heights)-1
result = 0
while start < end:
result = max(result,min(heights[start],heights[end]) * (end-start))
if heights[start] < heights[end]:
start += 1
else:
end -= 1
return result
heights = [1,8,6,2,5,4,8,3,7... |
77e38b2b407bebd1256bdb2fd4e60ac62316cfb5 | woshiskc/LearnPython | /Day7/ex8.py | 803 | 4.0625 | 4 | # -*- coding: utf-8 -*-
# define formatter . assign a format string to formatter
formatter = "%r %r %r %r"
test = "%r %r" # "%s %s"
print formatter % (1,2,3,4) # the variables of formatter are numbers
print formatter % ("one", "two", "three", "four") # the variables of formatter are strings
print formatter ... |
67e51b7a2e0796da6c72ccf9f11478260d0be0fc | BhargavReddy461/Coding | /LinkedList/insert_delete_traverse_reverse_DLL.py | 2,991 | 3.515625 | 4 | import gc
class Node:
def __init__(self, data):
self.data = data
self.prev = None
self.next = None
class DoublyLinkedList:
def __init__(self):
self.head = None
def push(self, new_data):
new_node = Node(new_data)
new_node.next = self.he... |
d01774c10aabb4f889404cd4cb9ac9502c0aa7d2 | PyPyPythonDude/Automate_the_Boring_Stuff_with_Python | /Projects/collatz_sequence.py | 623 | 4.53125 | 5 | # This program performs different calculations based on whether a given
# number is even or odd.
def collatz(number):
# Check if a number is divisible by 2 with 0 remainder.
if number % 2 == 0:
# Floor division means the // will always take the floor or lower number.
result = number // 2
# I... |
04ad9dfd0acd0f9dde158b04e80963c4a33a4ada | SFoskitt/python_extra | /ex_01_max_fun.py | 254 | 3.5 | 4 | from sys import argv
# script, first, second = argv
def max(first, second):
if first > second:
print "first is greater", first
return first
else:
print "second is greater", second
return second
# print "the answer is ", max(first, second) |
48e7db0f718d96314960b4ba7ac7eacdfa1bc49e | wbsjl/ftp-server | /Data/data2.py | 1,064 | 3.796875 | 4 | class StackError(Exception):
pass
class Sstack:
def __init__(self):
# 约定列表最后一个元素为栈顶元素
self.elems = []
def top(self):
if not self.elems:
raise StackError("no stack")
return self.elems[-1]
def is_empty(self):
return self.elems == []
def push(sel... |
379e86d508328c9718c8fe397c9c470473346532 | AtIasz/ccOW1 | /WeekNo1/pighutch.py | 269 | 3.96875 | 4 | width=8 #int(input("Give me the width of the hutch: "))
height=4 #int(input("Give me the height of the hutch: "))
for i in range(height):
if i==0 or i==(height-1):
print("*"*width)
else:
print("*"+" "*(width-2)+"*")
|
93f522d46ebaf76d7d615ba750ea43d06c4675e6 | RajiBala/Data-Structures-ADT | /TurtleLinkedList.py | 6,381 | 4.1875 | 4 | from node1 import *
import turtle
class linked_list:
def __init__(self):
self.head=None
self.tail=None
self.size=0
def size(self):
self.size=size
print (self.size)
def insertfirst(self,elem):
new=node(elem)
new.next=self.head
... |
38562e9aaea1b41c2e4b85cc909df95320520890 | daniel-reich/ubiquitous-fiesta | /e8TFAMbTTaEr7JSgd_24.py | 132 | 3.515625 | 4 |
def left_digit(num):
num=list(num)
for x in num:
try:
x=int(x)
return x
except ValueError:
continue
|
71a5ebc316ee4b71eb32f4ff467a1be87c0d962b | 4gn3s/adventOfCode2016 | /advent_of_code_1.py | 4,297 | 3.609375 | 4 | def parse_input(input_list):
steps = []
for entry in input_list:
if len(entry) < 2:
raise Error("Input incorrect")
steps.append({"dir": entry[0], "steps": int(entry[1:])})
return steps
def rotate(current, next_dir):
if next_dir != 'L' and next_dir != 'R':
raise E... |
5ae258472df7f4cb08740f14a1a9e0b845ad5bc4 | tg270798/30dayscodeHackerrank | /Day3: Intro to Conditional Statements | 461 | 3.859375 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
def check(num):
if((num<1)or(num>100)):
print("value out of range")
def main(num):
check(num)
if(num%2!= 0):
print("Weird")
elif(num%2 == 0):
if((num>=2) and (num<=5)):
print("Not Weird")
... |
50e6ec68f79afe15bb9629b503c1fa178560c180 | ucsb-cs8-f18/cs8-f18-lecture-code | /lec13/while_guess.py | 201 | 3.890625 | 4 | import random
def guess():
answer = random.randint(1, 10)
guess = raw_input("Guess a number between 1 and 10: ")
while int(guess) != answer:
guess = raw_input("Sorry, guess again: ")
|
1c5fb158579a98d1d8cca224b40cfab54f0ff732 | benzoa/pythonStudy | /basics/ex15_lambda.py | 1,705 | 3.984375 | 4 | # lambda expression(anonymous function)
plus_ten = lambda x : x + 10
'''
def plus_ten(x):
return x + 10
'''
print("plus_ten(1): {}".format(plus_ten(1)))
call_self = (lambda x : x + 9)(1)
print("self1: {}".format(call_self))
y = 3
print("self2: {}".format((lambda : y)()))
plus_three = lambda x : x + y
print("plus... |
eb49101739824ff5a803e72a62e8a0e81a336d5e | Keshavpp/Assignment-Codes-Python | /regexp_1.py | 550 | 3.640625 | 4 | #Course- Using Python to access web data
#Week 2 ; Assignment
#Use http://py4e-data.dr-chuck.net/regex_sum_42.txt \\ or \\ http://py4e-data.dr-chuck.net/regex_sum_582926.txt
import re
fname = input("Enter file name: ")
try:
fh = open(fname)
except:
print('File cannot be opened:',fname)
quit()
numlist = list()
f... |
db07f959f37a9e66806cb15f01a642b1a6c816ab | serxoz/auxilia | /lib/Song.py | 1,349 | 3.546875 | 4 | class Song:
# explicit refers to this song being purposefully added by a user,
# as opposed to by algorithm
def __init__(self, name, track_id, artist, album_uri, album_name, duration, added_by=None, explicit=False, valence=None, energy=None):
self.name = name
self.track_id = track_id
... |
1218c34d5ba70b14a16224faeb6a53d718c21c69 | ejimenezsoto/cs-module-project-recursive-sorting | /src/sorting/sorting.py | 1,282 | 4.125 | 4 | # TO-DO: complete the helper function below to merge 2 sorted arrays
import math
def merge(arrA, arrB):
elements = len(arrA) + len(arrB)
merged_arr = []
apos = 0
bpos = 0
while 1 < 2:
if bpos >= len(arrB):
return merged_arr + arrA[apos:]
if apos >= len(arrA):
... |
e1c27de70f3fb17d45003a39b64436d70714bb51 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2206/60590/236824.py | 838 | 3.625 | 4 | tests = int(input())
lists = []
for i in range(tests):
temp = int(input())
lists.append(temp)
#print(lists)
def func(num):
result = 0
ele = ((1+num)*num)/2
ele = int(ele)
lists = []
for i in range(ele):
lists.append(i+1)
#print(lists)
arr = []
for i in range(1,num+1):
... |
b28dc4e7f0a2ca3d0ee22daf9faf04e00f075a65 | gsudarshan1990/PythonSampleProjects | /Advanced_Python_Objects_And_DataStructures/exercise.py | 1,506 | 4.21875 | 4 | """
Convert 1024 to binary and hexadecimal representation
"""
print(hex(1024))
print(bin(1024))
"""
Round 5.23222 to two decimal places
"""
print(round(5.23222,2))
"""
Check if every letter in the string s is lower case
s = 'hello how are you Mary, are you feeling okay?'
"""
import string
s = 'hello how are you ... |
41c23b14496f660d5b9f784f5d3fd2cd6c735832 | jbobo/leetcode | /longest_palindromic_subsequence_dp.py | 1,156 | 3.828125 | 4 | #!/usr/bin/env python3
def longestPalindromeSubseq(input_string):
"""
"""
palindrome_length_at = [[1]*len(input_string)
for i in range(len(input_string))]
for length in range(2, len(input_string) + 1):
for left in range(len(input_string) - length + 1):
... |
295d9d7cb3868438050edc61352d5a285bb7d58a | AlexeyAG44/python_coursera | /week_5/22_less_positive.py | 551 | 3.78125 | 4 | # Выведите значение наименьшего из всех положительных элементов в списке.
# Известно, что в списке есть хотя бы один положительный элемент,
# а значения всех элементов списка по модулю не превосходят 1000.
numList = list(map(int, input().split()))
resNumList = []
current = numList[0]
for current in numList:
if cur... |
1a99ed951c0c7bb3240b2f41e6ae111f360587c7 | hahaliu/LeetCode-Python3 | /111.minimum-depth-of-binary-tree.py | 568 | 3.84375 | 4 | # ex2tron's blog:
# http://ex2tron.wang
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def minDepth(self, root):
"""
:type root: TreeNode
:rtype: int
"""
... |
a71e5112ccc7f8f30d238a81c30f158f4931b5b3 | mauricio071/pythonExercicios | /ex032.py | 273 | 3.953125 | 4 | from datetime import date
ano = int(input('Digite um ano: (coloque o 0 para analisar o ano atual)'))
if ano == 0:
ano = date.today().year
if ano % 4 == 0 and ano % 100 != 0 or ano % 400 == 0:
print('Esse ano é/foi bisexto')
else:
print('Não é/foi bisexto') |
a1fdc7b94d171d91a28b6c7d3354df04de0882f4 | brkunver/Python-Practice | /QuadraticEquationSolver.py | 877 | 4.15625 | 4 | # Written by Burakhan Unver 23.12.2020
def continue_check():
while True:
inp = input("Do you want to continue? y for yes, n for no\n")
if inp == "y":
return True
elif inp == "n":
return False
else:
print("Error, please enter 'y' or 'n'")
cont = True
while cont:
print("Please enter coefficients of... |
b4088545e8491b3c69dcb54863b96c2b52976908 | DalengaMRX/Python | /Exercicios/exe10.py | 281 | 3.9375 | 4 | # Crie um programa que leia quanto dinheiro uma pessoa tem na
# carteira e mostre quantos dolares ela pode comprar.
n = float(input('Insira o valor disponível para a troca cambial: '))
dolar = n / 5.11
print('Seu dinheiro convertido em Dólar vale: {} Dólares'.format(dolar)) |
708f816233ed4f52a455323439fb9ed2a63f956a | PavlySz/Code-snippets | /Python/parsers/Caesar_encryption_parsers.py | 1,503 | 3.84375 | 4 | from collections import deque
from string import ascii_lowercase, ascii_uppercase
import argparse
def caesar_cipher_encryption(plaintext, key):
upper = deque(ascii_uppercase)
upper.rotate(key)
upper_str = ''.join(list(upper))
lower = deque(ascii_lowercase)
lower.rotate(key)
lower_st... |
739563c7d1811bf05672b7cc1b6413187b444c29 | Carlodinhoo/Compiladores | /Proyectos/proyecto_1/proyecto/out/fz_error_identacion.plx.py | 190 | 3.734375 | 4 | a = 20
cont = 1
while(cont < a):
if cont%3 == 0 and cont%5 == 0:
print "FizzBuzz!"
elif cont%5 == 0:
print "Buzz"
elif cont%3 == 0:
print "Fizz"
else:
print cont
cont = cont+1 |
8b74db727e9d6f0c6232f8b7e76eabbbe0ec4fa9 | sohaibali01/programming_AI | /test_neural.py | 2,897 | 3.59375 | 4 | # https://towardsdatascience.com/neural-net-from-scratch-using-numpy-71a31f6e3675
# A simple neural network solver using numpy
from sklearn import datasets
from matplotlib import pyplot as plt
import numpy as np
def load_extra_datasets():
N = 200
gaussian_quantiles = datasets.make_gaussian_quantile... |
f86f104188d305236c466f7f38c4d3a95014a5d4 | gil-log/GilPyBrain | /baekjoon/steptwo/LeapYear.py | 147 | 3.703125 | 4 | # https://www.acmicpc.net/problem/2753
year = int(input())
if (year%4 == 0 and year%100 !=0) or (year%400 == 0):
print(1)
else :
print(0)
|
5ac0a4883b65a8e61bfe8d6ea10e49551c1cbe19 | Beowulfdgo/HackerRank | /Maximum Draws.py | 67 | 3.59375 | 4 | n=int(input())
for i in range(n):
x=int(input())
print(x+1) |
8ba117a2d0376eb7b67a3ab81df5ea3039fed3ba | eitan12345om/Euler-Projects | /Euler6.py | 549 | 3.71875 | 4 | """
The sum of the squares of the first ten natural numbers is,
12 + 22 + ... + 102 = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)2 = 552 = 3025
Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640.
Fin... |
4465af6e2ff8183f6ca0e4109e3f9ef83ebd768c | Wolverinepb007/Python_Assignments | /Conv_Sum/conversion.py | 369 | 3.828125 | 4 | #designing the conversion function
def DecimalToBinary(decimalNum): #Converting decimal numbery to binary
bit=[]
count=0
while count!=8:
R=decimalNum%2
bit.append(R)
decimalNum=decimalNum//2
... |
483ccd3bc201928a9c876c107b878de010b5e587 | sunyiwei24601/Intern_exercise | /Leetcode/79. Word Search.py | 2,523 | 3.65625 | 4 | class Solution:
def exist(self, board, word):
rows = len(board)
if rows:
cols = len(board[0])
memo = [[1]*cols for i in range(rows)]
def exist_word(matrix, memo, word, row, col):
if len(word) == 0:
return 1
if row >= rows or row <... |
ee8a3744ba58ffe8b1fd870102ca876d46a00e9c | Vadym95/Studing | /lesson8.py | 501 | 4.03125 | 4 | cities = ["New York", "Moscov", "new dehli", "singapure", "Kiev"]
print(cities)
print(len(cities))
print(cities[0])
print(cities[2].title())
print(cities[3].upper())
cities[4] = "Tula"
print(cities[4])
cities.append("Kursk")
print(cities)
cities.insert(1, "lviv")
print(cities)
del cities[3]
print(cities)... |
cfe7747d5a43fb78881aa4e0b3e6334691e1e9b3 | iliucaisi/ProgrammingInPython | /modules/fasteners/demo_1.py | 729 | 3.5625 | 4 | #!/usr/bin/python
import random
import threading
import time
import fasteners
def read_something(ident, rw_lock):
with rw_lock.read_lock():
print("Thread %s is reading something" % ident)
time.sleep(1)
def write_something(ident, rw_lock):
with rw_lock.write_lock():
print("Thread %s is writing something" % ide... |
f6bffb853f7226470f27be72d2eddd56ae1737a7 | JesusSePe/Python | /recursivity/search.py | 229 | 3.84375 | 4 | def search(list1, list2):
for i in list2:
if i == list1[0]:
return True
if len(list1) == 1:
return False
else:
return search(list1[1:], list2)
print(search([1, 2, 4], [5, 3, 5]))
|
b3f11f5ebe248e4d212289aaeacd84ae6524b04a | BrenoSDev/PythonStart | /Introdução a Programação com Python/EX04,9.py | 553 | 3.9375 | 4 | #Aprovação de empréstimo bancário para compra de uma casa
casa = float(input('Digite o valor da casa: R$'))
salário = float(input('Digite o valor do seu salário: R$'))
anos = int(input('Digite o total de anos a pagar: '))
prestação = casa / (anos*12)
if prestação > salário*0.3:
print('O empréstimo não poderá ser co... |
5217291ba8e5b1f07d73a80559ec756630524621 | Yasirkhana/RockPaperScissor_Python | /RockPaperScissor.py | 656 | 3.984375 | 4 |
# 2 players
from random import randint
def game(p1,PC):
if((p1==1 and PC==2) or (p1==2 and PC ==3) or (p1==1 and PC ==3)):
result = print("PLAYER 1 WON !")
return result
elif((p1==1 and PC==1) or (p1==2 and PC==2) or (p1==3 and PC==3)):
result = print("DRAW !")
... |
d9a5670bd23051f13e17872275b82b54545b7cf8 | akshatfulfagar12345/EDUYEAR-PYTHON-20 | /day 3(count occurence of character).py | 176 | 3.984375 | 4 | string=input("Enter any string:")
c=input("Enter character to check frequency:")
count=0
for i in string:
if i==c:
count+=1
print(c,"occurs",count,"time(s)",) |
50c2ea3d27424c84156e254b2d66e2b1887f9f23 | mattshakespeare/OU_python | /above_30.py | 311 | 4.21875 | 4 | #list of temperatures
temperatures = [32,45,44.2]
#empty list for values above 30
above_30 = []
#iterate through temperature list
for temp in temperatures:
#if value in temperatures is above 30
if temp > 30:
#append to above_30 list
above_30.append(temp)
#output all values above 30
print(above_30)
|
cef15b42c88083455f48894c91672a9fda0d5f35 | eyad-py/Hacker-Rank | /Arithmetic Operators.py | 166 | 3.703125 | 4 | if __name__ == '__main__':
a = int(input())
b = int(input())
if 1<= a <=10**10 and 1<=b<=10**10:
print(a+b)
print(a-b)
print(a*b)
|
84d3ee365ef273d116ad84ebdca44e6943ec70d4 | aknouche/hangman | /Hangman/hangman.py | 2,883 | 4 | 4 | import random
words = open("words.txt").read().splitlines()
randomword = random.choice(words)
# Build a hangman image to print on screen
hangman_img = ['''
+---+
| |
|
|
|
|
=========''', '''
+---+
| |
O |
... |
764cba41d12ad46d261a3a0633f9244111675b13 | furas/python-examples | /__scraping__/nwrfc.noaa.gov - requests/main.py | 673 | 3.5 | 4 | # author: Bartlomiej "furas" Burek (https://blog.furas.pl)
# date: 2022.02.26
# [python - Reading a CSV file into Pandas - Stack Overflow](https://stackoverflow.com/questions/71273200/reading-a-csv-file-into-pandas/71273335?noredirect=1#comment125983964_71273335)
import pandas as pd
import requests
import io
url = "h... |
37f19d629fe817b4cc6776e59bbc973d4741fe85 | sumanblack666/datacamp-python-data-science-track | /Manipulating DataFrames with pandas/Chapter 3 - Rearranging and reshaping data.py | 3,906 | 4.125 | 4 | #Chapter 3 Rearranging and reshaping data
#Pivoting a single variable
# Pivot the users DataFrame: visitors_pivot
visitors_pivot = users.pivot(index='weekday',columns='city',values ='visitors')
# Print the pivoted DataFrame
print(visitors_pivot)
# # # # # # # #
#Pivoting all... |
51479e64014ab9b380ac795574e3449715722735 | StevenLOL/kaggleScape | /data/script198.py | 10,151 | 3.53125 | 4 |
# coding: utf-8
# # About the dataset
# This dataset is about the show about "nothing". Yeah, you guessed it right. I am talking about Seinfeld, one of the greatest sitcoms of all time. This dataset provides episodic analysis of the series including the entire script and significant amount of information about each e... |
d4aeef3871a8c6528a7f439044b2b48ab30f72b4 | robertvari/pycore-210109-2 | /09_anonim_functions.py | 199 | 3.6875 | 4 | my_lambda = lambda a, b: a+b
# print(my_lambda(3, 3))
name_list = ["Vári Róbert", "Kiss Elemér", "Nagy Adrienn", "Tóth Barna"]
# print(sorted(name_list))
print(sorted(name_list, key=lambda name: name.split(" ")[-1])) |
ccac3371bd6b259b0de4e6d07c78ad2349eed1ca | comwork2016/algorithm | /recursion/splitnumber/sliptnumber.py | 935 | 4.15625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created on 2016/03/08
"""
[自然数拆分]任何一个大于1 的自然数n , 总可以拆分成若干个小于n
的自然数之和, 试求n的所有拆分(用不完全归纳法)。
"""
def split(n):
if n == 2:
list = [[1, 1]]
return list
else:
list = [];
for index in range(1, int(n / 2) + 1):
list.append([inde... |
25e64c831cf7f2023870084b8139ef34c484a640 | ahmadreza-smdi/DesktopAppointmentSys | /main.py | 2,358 | 3.625 | 4 | from config import *
global id_number = 0
class patient:
def __init__(self,fname,lname,id_number,national_id
,phone_number,address,plate_number
,post_code,special_disease,blood_type):
self.fname = fname
self.lname = lname
... |
5a36bbf48b47f66761c22704325fbb3782817558 | shayne-fletcher/zen | /ppf/ppf/math/root_finding.py | 3,545 | 3.734375 | 4 | import math
from special_functions import sign, max_flt
def bisect(f, min, max, tol, max_its):
"""Bisection method
The quadratic y(x) = x^2 + 2x -1 has roots
-1 - sqrt(2) = -2.4142135623730950488016887242097
and -1 + sqrt(2) = 0.4142135623730950488016887242097.
>>> bisect(lambda x: x*x + 2*x - 1, -3, -2, l... |
b35febe7efaee182ac64370d483d77e1aa549c5e | IvanLpJc/python-course | /funciones_avanzadas/funciones_generadoras.py | 507 | 4.09375 | 4 | # Son funciones que generan valores "sobre la marcha"
range(0,11) # Genera valores desde 0 a 10, es lo mismo que decir range(11)
for numero in range(0,11):
print(numero)
print("*************************************")
def pares(maximo):
for numero in range(maximo):
if(numero % 2 == 0):
y... |
98fd3091349b02bc33cfa1210060b4c02cdf1866 | SatishMonad/test_practice | /PythonP/LGVariable.py | 102 | 3.609375 | 4 | x = "patidar"
def myfunc():
x = "satish"
print("This is " + x)
myfunc()
print("This is " + x)
|
72d4ee48186ea4eecea8124dc5bc0e249069b0e1 | bhoffco/lc101 | /crypto/caesar.py | 475 | 4.25 | 4 | from helpers import alphabet_position, rotate_character
def encrypt(letters, rot):
encrypted = ""
for i in letters:
if i.isalpha():
encrypted = encrypted + rotate_character(i, rot)
else:
encrypted = encrypted + i
return encrypted
def main():
letters = input("... |
c8812ed95984048b2964fdcc399f7093c8cd5859 | markomamic22/PSU_LV | /LV1/Drugi.py | 368 | 3.90625 | 4 | ocjena = -1.0
while ((ocjena < 0.0) or (ocjena > 1.0)):
ocjena = float(input("Unesite broj između 0 i 1: "))
def cases(ocjena):
if(ocjena >= 0.9):
print('A')
elif(ocjena >= 0.8):
print('B')
elif(ocjena >= 0.7):
print('C')
elif(ocjena >= 0.6):
print('D')
elif(ocj... |
af7cd7f4e11d845d65e6b2080e59350ed28253db | kaushik853/lpthw_python_3 | /zed-python/got.py | 4,740 | 3.9375 | 4 | from sys import exit
from textwrap import dedent
class Scene(object):
print("Nothing is written yet")
def enter(self):
print("I need to write it")
exit(1)
class Start(Scene):
def enter(self):
print(dedent(
"""
You are starting the Game Of Thrones.
... |
543605bb3786ffbe4eba77f5d7426a1a31ce1c41 | IamTheVine/CS-2 | /Celcius_to_Fahrenheit.py | 143 | 4 | 4 | # Converts Celcius to Fahrenheit
# By Albert Molina 23-Mar-2018
C = float(input('Enter Celcius: '))
F = (9/5) * C + 32
print(str(F) + ' Fahrenheit') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.