blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
d76f4893f497f69740a308692ee9a0f9300e3a91 | HeeJi/p2_201611069 | /game.py | 5,523 | 3.6875 | 4 | import turtle
wn=turtle.Screen()
d1=turtle.Turtle()
wn.bgcolor("Lightblue")
oldheading=d1.heading()
t1=turtle.Turtle()
t1.shape("turtle")
t1.color("Blue")
def Start():
raw_input('input anything you want: ')
print 'GO!!!!'
def Triangle():
d1.penup()
d1.goto(-320,200)
d1.pendown()
for i in range(0... |
73762e06d7c40f6cd01b965835ea60a8ded1dd68 | Rinqt/stock | /machine_learning/utils/linear_regression_helper.py | 3,369 | 4.15625 | 4 | from sklearn.model_selection import train_test_split
from utils.data_util import get_stocks
def prepare_data(company_symbol, result_feature, features, forecast_out, test_size, random_state):
"""
Method will shift data values by given 'forecast_out' amount. Basically, we will be predicting 'n' values
in th... |
c5208d316d4930d978d4f1f84292daa48b3d7cb5 | MattFrankowski/algorithms | /pattern_search/naive_algorithm.py | 1,377 | 3.625 | 4 | class NaiveAlgorithm():
def __init__(self, pattern, text):
self.pattern = pattern
self.text = text
self.lenPattern = len(pattern)
self.lenText = len(text)
self.search()
def search(self):
results = []
if self.text == "":
return results
... |
3f85eb5cd4639dc3b711f67ea8b1cef19285b33d | eltnas/ExerciciosPythonBrasil | /03 - EstruturaDeRepeticao/36.py | 269 | 3.75 | 4 | mult = int(input('Multiplicador: '))
numInicio = int(input('iniciar em :'))
numFinal = int(input('Encerrar em :'))
cont = numInicio
for i in range(numInicio, numFinal + 1):
tab = mult * cont
print('{} X {}: {}'.format(mult,cont,tab))
cont += 1 |
c16782569c7ca14943a67e0dcc68a8ee356114ab | brfabri/ALGORITMOS-21.06.17- | /04-loja_tinta.py | 232 | 3.75 | 4 | area=float(input("Insira o tamanho em metros quadrados da área a ser pintada: "))
if area%54==0:
latas=area/54
else:
latas=(area/54)+1
total=latas*80
print("Quantidade de latas: %2.d. Total: R$%2.f"%(latas,total))
|
88d739d0e67d0fd830c3ba002c354ff5fcaaf8d7 | nazishhussain/max-programming | /while.py | 150 | 4.09375 | 4 | #write a program to write your name using while lop
i=1
while i<6:
name=input("what is your name: ")
print(name,i)
i=i+1
print("end the program") |
7c8443d98ec63fc5cf26a9330ba18a28ff885b2e | Ian-Dzindo01/HackerRank_Challenges | /Python/Sherlock_And_Squares_I_Solution.py | 589 | 3.515625 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
import math
def squares(a, b):
cnt = 0
for i in range(a, b+1):
if math.sqrt(i).is_integer():
cnt += 1
return cnt
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
q = int(input())
... |
63f0723c13a55b023518406be6a168f03a390318 | NicolaiFinstadLarsen/Mine-prosjekter | /text_adventure.py | 954 | 3.640625 | 4 | print("intro")
print("intro2")
print("lobby, to veier")
def rom_1(self, path):
while path != "1" and path != "2" and path != "3":
path = input("Hvilken vei vil du gå? rom1")
if path == "1":
print("Rom1_vei1")
path_rom1 = input("Hvilken vei? rom1_vei1 ") # rom 2 eller 3
i... |
e41f575983a03f790b48c29507796d677c58f8c5 | IbrarShakoor/Python-codes | /iterators.py | 728 | 3.734375 | 4 | num =[1,32,42]
for i in num:
print(i)
print("\t\tBy iterator built in function:")
it=iter(num)#ye ak built in fun ha jo values ko iterate krta ha
print(it.__next__())#next valu k liye
print(it.__next__())
print(next(it))#ye dono same han =print(it.__next__())
print()
class topten:
def ... |
0a20671ba76738397e4cd66cb8394a396147c26e | cathyxingchang/leetcode | /code/LinkList/142_M.py | 1,666 | 3.859375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# 142_M
# Created by xc 18/03/2017
"""
1 2 3 4 5 6 7 8 9 10->4
slow 1 2 3 4 5 6 7 8
fast 1 3 5 7 9 4 6 8
1 2 3 4 5 6 7 8 9 10->1
slow 1 2 3 4 5 6 7 8 9 10 1 ... |
ae189d8077ffef2ec16a29938b292f2d95e94f22 | rohansadale/Problem-Solving | /epi/binary_trees/9_1_height_balanced.py | 552 | 3.890625 | 4 | from binary_tree import *
class Height:
def __init__(self):
self.height = 0
def is_balanced(root, height):
if not root:
return True
l_height, r_height = Height(), Height()
l = is_balanced(root.left, l_height)
r = is_balanced(root.right, r_height)
height.height = 1 + m... |
a8f5bb71e2e724b7e794e4a2d071020757140fb8 | amanrajjeev1208/bankers-algorithm | /banker.py | 2,829 | 4.0625 | 4 | #***************************************************************************
#****************************THE MAIN FUNCTION******************************
#***************************************************************************
def main():
#Take the number of processes, number of different resources, maximum resour... |
2e9a31aeada60204b1962545a65630fa5e4245e6 | alexact/metodosnumericosbackend | /raicesPolinomios.py | 235 | 3.78125 | 4 | from math import *
from sympy import*
def poliRoots(f):
respuesta=[N(places)for places in solve(f)]
return respuesta
#"3*x**3+2*x+5"
str_ecuacion = str(input("Ingrese la ecuacion"))
print (poliRoots(sympify(str_ecuacion)))
|
0a4fbcbfc5a4d31b09a3a0a01f975f4c0b871f89 | Dmast00/Python_Exercises | /Exercise_1.py | 353 | 4.15625 | 4 | hours = str(input('How many hours did you work?'))
rate = float(input('Input the rate:'))
hrs = float(hours)
if hrs <= 40:
pay = (hrs) * (rate)
print(pay)
else:
half_hours = (rate / 2) + rate
hlf_hrs = float(half_hours)
extra_pay = (hrs - 40)
pay = (40 * rate) + (extra_pay * half_hours... |
64bff461331e2a43e7ac82bc3a9a5a58ee13e7e5 | HuiboZhou/Algorithm | /code/4/simplex.py | 2,777 | 4.03125 | 4 | #!/usr/bin/python3
# Simplex method
# Author: HongXin
# 2016.11.17
import numpy as np
class Simplex:
def __init__(self):
pass
def xlpsol(self, c, A, b):
"""
Solve linear programming problem with the follow format:
min c^Tx
s.t. Ax <= b
x >= 0
... |
7d13bbce5ed685d95cc86c14caf4eab23abff937 | youssrao/HMI | /Vision/Face-Recognition/identify.py | 2,242 | 3.8125 | 4 | import face_recognition
from PIL import Image, ImageDraw
import numpy as np
# Load a sample picture and learn how to recognize it.
obama_image = face_recognition.load_image_file("obama.jpg")
obama_face_encoding = face_recognition.face_encodings(obama_image)[0]
# Load a second sample picture and learn how to recogniz... |
1516e6419ea1fd379703b420537ae7a71e27bfe0 | Bilal094/forever-young | /tafelmanieren/klok.py | 96 | 3.6875 | 4 | for i in range(00,13,+1):
print(i,'AM')
for e in range(13,23+1):
print(e,'PM')
input('') |
01fcaaaf1e94180ecb52c98fc5425b88edfbb933 | suyashgupta01/RandomIpAndLocationGenerator | /generator.py | 772 | 3.796875 | 4 | # ip address is of the format: x.x.x.x; where x is from 0 to 255
import random
import requests as rq
import json
def random_ip_address():
return str(random.randint(0, 256)) + "." + str(random.randint(0, 256)) + "." + str(random.randrange(0, 256)) + "." + str(random.randint(0, 256))
def main():
while True:
... |
5ad6c4fc2cc6e10e6cfb214f5d2cf531334095b5 | Daroso-96/ejercicios-basicos-python | /ejercicio-03.py | 170 | 4.125 | 4 | #Escribir un programa que pregunte al usuario su nombre y lo dijite dicienodo "Hola <nombre>"digitado
nombre = input('Digite su nombre: ')
print("¡Hola " + nombre + "!") |
f4646fab8d6aede2823741e5671eb97b5127a78f | Nm99codex/Python-Project-S-W-G | /snake_water.py | 1,995 | 3.65625 | 4 | import random
# ***GAME FUCTION**
def swg_game(comp_turn, p, n, round_num, comp_win, player_win):
while(round_num<=n):
p= input("Player's Turn: ")
if(p!='s' and p!='w' and p!='g'):
print("Invalid entry")
continue
print(f"--Round {round_num}")
if (comp_turn == p):
print(f"Match tie in Round - {ro... |
707682005c6c2ac496228b1347f1324f40acbb63 | lexjox777/bubble-sort | /main.py | 2,314 | 3.8125 | 4 | # arr=(49,24,18,5,10,56,40,34,20,4,1)
# def bubble_sort(arr):
# sorted = False
# while not sorted:
# sorted = True
# for i in range(len(arr)-1):
# if arr[i] > arr[i+1]
# sorted = False
# arr[i], arr[i+1] = arr[i+1], arr[i]
# # 0 1 2 3 4 5 6 7 8 9 10
# x=[49,24,... |
e424086cde215be2c668bc4a94cd1f1027a75540 | cp-helsinge/2020-2 | /matias/Opgave2.py | 184 | 4.03125 | 4 | text = "hej"
print (text)
navn = input ("Hvad Hedder du? ")
if navn == "Matias":
print ("hej "+navn+" det er et grimt navn")
else:
print ("hej "+navn+" det er et pænt navn")
|
51e748fdfa052b3af07653bd17092869d2ddee19 | KARTIK16Sherwal/NANOBEING | /Rock paper scissor.py | 1,242 | 4.1875 | 4 | ask = input("What is your name: ")
print(f" Hello, {ask} nice to meet you!")
import random
while True:
user_action = input("Enter a choice (rock,paper,scissor):")
possible_actions = ['rock', 'paper', 'scissor']
computer_action = random.choice(possible_actions)
print(f"\nYou choose {u... |
f7359b3fe1a8acc5edc09f0adc7cf2be82d9b35e | sandeshgajare55/LiveTraining | /Assingment_5/Duplicate_list.py | 271 | 3.8125 | 4 | l1=[20,25,20,30,40,30]
print('Original List : ',l1)
l2=[]
l3=[]
c=0
for i in l1:
if i not in l2:
l2.append(i)
else:
l3.append(i)
c=c+1
print('List Without Duplication : ',l2)
print('Duplicate Elements : ',l3,', Duplicate No count ',c)
|
8ab16aca3b2ccccf47763969e93bab0a993689e8 | jh-lau/leetcode_in_python | /02-算法思想/贪心算法/738.单调递增数字(M).py | 1,529 | 3.5625 | 4 | """
@Author : liujianhan
@Date : 2020/12/15 13:58
@Project : leetcode_in_python
@FileName : 738.单调递增数字(M).py
@Description : 给定一个非负整数 N,找出小于或等于 N 的最大的整数,同时这个整数需要满足其各个位数上的数字是单调递增。
(当且仅当每个相邻位数上的数字 x 和 y 满足 x <= y 时,我们称这个整数是单调递增的。)
示例 1:
输入: N = 10
输出: 9
示例 2:
输入:... |
cf17e9007807c134aa71ce42d77ada0f88e45e2c | antdinodev/pythonfun01 | /pythonlearn10-files.py | 562 | 3.765625 | 4 | #open files
#file objects
#r will read the file
with open('python dev job desc.txt', 'r', encoding="utf8") as f:
f_contents = f.read()
print(f_contents)
#w will write or overwrite current file if it already exist
with open ('test2.txt', 'w') as f:
f.write('Test')
f.seek(0) #seek does something, A BI... |
937f359e45bd12e91290d8c4df6cc82e07c8c4f3 | hqsds/Python | /leet_code/283. Move_Zeroes.py | 1,486 | 3.890625 | 4 | # Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.
#
# For example, given nums = [0, 1, 0, 3, 12], after calling your function, nums should be [1, 3, 12, 0, 0].
#
# Note:
# You must do this in-place without making a copy of the array.
... |
70c863d5629a201ce628967d4ff74ead13f7e2a5 | ParulProgrammingHub/assignment-1-Harshpatel44 | /P1.py | 148 | 3.8125 | 4 |
len=input("Enter Length:")
bre=input("Enter Bredth:")
print("Area is %s and Perimeter is %s"%((float(len)*float(bre)),(2*(float(len)+float(bre))))) |
edc6eec4773a36e002d6f1b66e32bfefbb5392b3 | ataicher/learn_to_code | /careeCup/parenthesis.py | 559 | 3.65625 | 4 | #!/usr/bin/python -tt
import sys
import time
def r_paren(n,m,paren_lst):
if n == 0:
for i in range(m):
paren_lst.append(')')
print ''.join(paren_lst)
for i in range(m):
paren_lst.pop()
else:
paren_lst.append('(')
r_paren(n-1,m,paren_lst)
paren_lst.pop()
if m > n:
... |
0e5084f8c8292b441a5f5b010652d421511ac86e | purnesh42H/algorithms-in-python | /python_numbers/fibonacci_python.py | 669 | 4.21875 | 4 | def fibonacci_sequence_recursive(n):
if n < 2:
return n
else:
return fibonacci_sequence_recursive(n-2) + fibonacci_sequence_recursive(n-1)
def fibonacci_sequence_dp(n):
result = [0, 1]
if n > 2:
for i in range(2, n+1):
result.append(result[-1] + result[-2])
... |
96aa3fcc091e43c6da0247d9d00eb0a5c679aeb3 | Justinest/2017-Work | /Justin E Cipher/Cipher.py | 1,640 | 4.1875 | 4 | def encrpyt():
key = input("What key do you wish to input:")
key_input = int(key)
cipher = ' '
print ("Your Choosen key is:")
print (key_input)
ciphertext = input("Enter the Message you Wish to Cipher:")
alphabet = "abcdefghijklmnopqrstuvwxyz"
for c in ciphertext:
if c in alphabe... |
ec4630e3d2342becc9ac5f573c870210696f2094 | bzbislawski/ml-foundations | /logistic_regression/logistic_regression.py | 1,237 | 3.5 | 4 | import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from sklearn.linear_model import SGDClassifier
from sklearn.model_selection import train_test_split, cross_val_score
dataset = pd.read_csv("dataset.csv")
x = dataset[['x', 'y']].values
y = dataset['label'].values
means_values = {}
scores = np.zero... |
36792edeeabddd6686eddd8efdcb444a496604a6 | grillzwitu/alx-higher_level_programming | /0x01-python-if_else_loops_functions/8-uppercase.py | 227 | 4.0625 | 4 | #!/usr/bin/python3
def uppercase(str):
for c in range(len(str)):
char = ord(str[c])
if char >= ord('a') and char <= ord('z'):
char -= 32
print("{}".format(chr(char)), end='')
print()
|
f04c86ca0f65cdc65f6187d3df8107d7cb416490 | Zahidsqldba07/codesignal-53 | /Intro/differentSquares.py | 448 | 3.75 | 4 | def differentSquares(matrix):
total2x2 = []
for i in range(len(matrix)-1):
for j in range(len(matrix[0])-1):
temp = [matrix[i][j],matrix[i][j+1],matrix[i+1][j],matrix[i+1][j+1]]
if temp not in total2x2:
total2x2.append(temp)
return len(total2x2)
matrix = [... |
f6376621be82cb0ddcaec451a8ff8bb6c8c34e40 | VRossi18/Uri | /1398.py | 331 | 3.625 | 4 | while True:
try:
binario = input()
while ('#' not in binario):
cont = input()
binario = binario + cont
num = int(binario.replace('#',''),2)
if (num % 131071 == 0):
print('YES')
else:
print('NO')
except EOFError:
... |
c0cc1f11e982980c689a65b34d8b5a84be48bb03 | firmanrizaldi/vitraining | /no.2/BilanganPrima.py | 555 | 3.875 | 4 | # No. 2
# Buat script python untuk menentukan apakah suatu bilangan adalah Prima atau Bukan Prima
# Input: angka x
# Output:
# x adalah bilangan prima
# atau
# x bukan bilangan prima
x = int(input("Masukkan angka: "))
# bilangan prima harus lebih besar dari 1
if x > 1:
for i in rang... |
1a9272816b3b870b8eb4ece787257361a6c24e23 | n1e2h4a/AllBasicProgram | /BasicPython/Timexecution.py | 381 | 3.890625 | 4 | import time
try:
def sumofnumbers(n):
starttime = time.time()
sum=0
for i in range(1,n+1):
sum = sum+i
endtime = time.time()
return sum,endtime-starttime
N=int(input("Enter the number:---"))
print("\n time taken to sum 1 to ",N,"and time to calculate is:",... |
edd1592df02faaee5fa507cf31a5f4928a68271c | yousuf1318/hypervage | /DSA_step_7/check if the srt palindrome.py | 191 | 4.15625 | 4 | inp=input("Enter Your Word : ")
palindrome =""
for i in inp:
palindrome= i+palindrome
if inp==palindrome:
print("It's a palindrome")
else:
print("it's not a palindrome.") |
b497b1a3da48e72468378a6b4a20e625fe0ff788 | tendoou/PythonCrashCourse-Exercises | /Extras/Codewars/decode.py | 700 | 3.765625 | 4 | class Cipher(object):
def __init__(self, map1, map2):
self.map1 = list(map1)
self.map2 = list(map2)
def encode(self, s):
s1 = []
s = list(s)
for x in s:
temp = self.map1.index(x)
s1.append(self.map2[temp])
return ''.join(s1)
def decod... |
b102efe756c4f203a52474467aba05590dd594c0 | ivyana/PR | /lab2/utils.py | 3,672 | 3.703125 | 4 | import math
import random
import struct
'''Finds the file size with the help of seek function'''
def calc_file_size(file):
file.seek(0, 2) # Moves the file pointer to the EOF
file_size = file.tell() # Gets file size
file.seek(0, 0) # Moves the file pointer the the beginning of the file
return fil... |
fa0525ad1a9016888e2f3ba96e000c34250d52e8 | prasad01dalavi/eye_blink_detection | /main.py | 2,179 | 3.578125 | 4 | import cv2
import time
# Face detection Model
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
# Eye Detection Model
eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml')
eye_flag = True
show_count = True
blink_count = 0
# Capture the Video Stream
cap = cv2.VideoCapture(1)
while Tr... |
cf0eb547a6d998e124babc510e6ff41ed3d9286d | boliu613/ProgrammingPractice | /Python/Hammurabi.py | 9,016 | 4.25 | 4 | import random
def print_intro():
'''print introduction information'''
print """Congrats, you are the newest ruler of ancient Samaria, elected for a ten year term of office. Your duties are to distribute food, direct farming, and buy and sell lanas needed to support your people. Watch out for rat infesta... |
5b2e36ee99febc1ca8fbff55b3794d47d30acb9f | kelbymartin/kmart-python | /lists.py | 227 | 4.125 | 4 |
list_of_numbers = [1, 2, 3, 4, 5, 6, 7, 8]
list_of_names = ["a", "b", "c"]
#a = list_of_numbers[2:5]
list_of_numbers.append(10)
print(list_of_numbers)
list_of_numbers.pop(4)
list_of_numbers.reverse()
print(list_of_numbers) |
2dd6ff175d48c88940f23745fc6e26f27bc2ecc1 | 0xch25/Data-Structures | /3.Stacks/Balanced Brackets.py | 896 | 4.09375 | 4 | '''program to check the given string is balanced or not using staks'''
def isMatch(p1, p2):
if p1 == "(" and p2 == ")":
return True
elif p1 == "[" and p2 == "]":
return True
elif p1 == "{" and p2 == "}":
return True
else:
return False
def isBalanced(str):
stk = []
... |
4acbc84266835b348eba131b0fbc3201100dd62b | Robin-Bjornsdotter/Python_Labs | /lab9/lab9.py | 3,928 | 3.5625 | 4 | class Automat():
def __init__(self, board, alive, iterations):
self.board_width = board['w']
self.board_height = board['h']
self.alive_height = alive['w']
self.alive_width = alive['h']
self.iterations = iterations
active_cells = []
for x in range(self.alive... |
34d938781e46413d313d85625c604bd22753f9e7 | Minji0h/Introduce-at-CCO-with-python | /Semana3/exercicio6.py | 834 | 4.125 | 4 | # Receba 4 números na entrada, um de cada vez. Os dois primeiros devem corresponder, respectivamente, às coordenadas x e y de um ponto em um plano cartesiano. Os dois últimos devem corresponder, respectivamente, às coordenadas x e y de um outro ponto no mesmo plano.
# Calcule a distância entre os dois pontos. Se a dist... |
9aea5fe35e7d91df8d09e4802018a8369109a529 | fjsmhjj/pytest3.6.2 | /py3.6test.py | 367 | 3.65625 | 4 | # -*- coding:utf-8 -*-
import sys
import numpy as np
import pandas as pd
# df=pd.DataFrame(np.random.randn(10,4))
# print(df)
#
# b={x :y for x in [1,2,3] for y in [4,5,6]}
# print (b)
a=['1242061', '']
# ['739368', ''],
# ['1421161', ''],
# ['1242061', ''],
# ['1467263', ''],]]
print (a)
c=[y for x in a for y i... |
9d95aaec769ebd33b57349d716af5172c7eb034e | Saswati08/Data-Structures-and-Algorithms | /LinkedList/remove_duplicates_sorted_list.py | 597 | 3.828125 | 4 | class node:
def __init__(self, val):
self.data = val
self.next = None
def removeDuplicates(head):
#code here
if head.next == None:
return head
prev = head
curr = head.next
while(curr != None):
if curr.data != prev.data:
prev.next = ... |
2d25c96b27b520c7929537fbcfbc69770ea7b113 | iamaaditya/advent_of_code | /day12.py | 759 | 3.5 | 4 | import re
import json
input = open('./input_data/input12.txt').read()
nums_pattern = re.compile(r"[+-]?\d+(?:\.\d+)?") # generic pattern for numbers, positive, negative, decimal
numbers = re.findall(nums_pattern, input)
print "Part 1 sum : " , sum(map(int, numbers))
stack = json.load(open('./input_data/input12.txt'... |
944e23e4329f4cb1a291df94c4f8de3996543f8b | augustedupin123/python_practice | /p46_lower_andUpper.py | 947 | 4 | 4 | #Write a program to print a string in upper and lower cases
'''a = 'A'
print (ord(a))'''
'''for i in range(100,120):
print (chr(i))'''
'''for i in range(200,400):
print(chr(i))'''
'''m = 'swrjryeraeryy'
for i in range(len(m)):
print(ord(m[i]))'''
'''m = 'dngnsdigg'
for i in range(len(m)):'''
Str1=input... |
cf90b92792bd7bee76778e2f5a9ad7e5a855b97a | daniel-reich/turbo-robot | /w5eFnzhADpLZSuCM3_13.py | 871 | 4.3125 | 4 | """
Write a function that returns a list of elements `[number, multiplicity]`. The
`multiplicity` of a number refers to the number of times it occurs in the
list.
To illustrate:
[5, 5, 1, 1, 5, 5, 3]
[[5, 4], [1, 2], [3, 1]]
# Since 5 appears 4 times, 1 appears twice, and 3 appearance once.
The f... |
26423da94e1c83abb01ae4a008ad91ea4d7e80ad | NiamhOF/python-practicals | /practical-18/p18p3.py | 1,087 | 3.84375 | 4 | '''
Practical 18, Exercise 3
Define a function isLetter
checks that character is a lowercase letter
Define a function isCode
assign numcode the value 0
if the length of the string is less than 4 characters
return an error
else:
for all characters in the range 0 to the length of the str... |
0ec9a86cf12b5127bf70cd824e2a9c42400cefcc | ktomczuk/pythonbootcamp | /Zjazd_1/z10.txt | 157 | 3.5625 | 4 | import datetime
a = int(input(' Poadaj rok narodzin'))
b = datetime.datetime.today().year
if 2018 - a <= 18:
print('Gówaniarz jestes')
else:
print('mozesz chlac')
|
0d9a71aac859826774ffab13c00f912e8fd0bf6e | lucifer279/Bank-ATM-Program | /Bank ATM.py | 2,740 | 4.125 | 4 |
#Bank ATM
Balance = 1000
Chances = 3
Restart = ('Y')
print("Welcome to Pune Bank")
while Chances >= 0:
pin = input("Enter your 4 Digit Pin : ")
if pin == "1234":
print("You have entered a correct pin")
print("\n")
while Restart not in ('n','No','no','N'): # As restart va... |
0b40400ff45d6fcec5c199db5f3c7eaab99e132f | DhruviV/LeetCode | /1051.py | 273 | 3.8125 | 4 | heights=[1,1,4,2,1,3]
correct_order=[]
count=0
for number in heights:
correct_order.append(number)
correct_order.sort()
print(correct_order)
print(heights)
for i in range(0, len(heights)):
if heights[i]!=correct_order[i]:
count+=1
i+=1
print(count)
|
2fcb9cae94b937335db759abbb43db2951300ed6 | eelki/my-isc-work | /python/ex3.1.py | 153 | 3.6875 | 4 | x = [1, 2, 3, 4, 5]
print("second item is", x[1])
print("second to last item is", x[-2])
print("whole list is", x[:10000])
print("my slice is", x[1:4])
|
d53da64de509845f3f107be3d6adc9d4a10d9480 | muryliang/python_prac | /origtry/break.py | 174 | 3.609375 | 4 | #!/usr/bin/python2
#filename:break.py
while True:
s=raw_input('Enter something:')
if s=='quit':
break
print 'Length of th string is',len(s)
print 'Done'
|
01b1125295827166342974088de9b0fd4003a17c | davidhansonc/coding_exercises | /day1_q1-4.py | 1,095 | 3.984375 | 4 | # -*- coding: utf-8 -*-
# @Author: davidhansonc
# @Date: 2021-01-14 15:44:10
# @Last Modified by: davidhansonc
# @Last Modified time: 2021-01-15 12:46:05
'''
Question 1
'''
def find_nums(low_num, high_num):
num_list = []
for num in range(low_num, high_num+1):
if num % 7 == 0 and num % 5 != 0:
... |
a103bb5d50cc368fe41714c598f25e21ce710de3 | voraparth1337/System-Programming-and-Compiler-Construction-Solutions | /first_and_follow.py | 4,509 | 3.890625 | 4 | # Written by Parth V
# Disclaimer : I am no expert in python but just a learner. In no way is this code perfect or the most 'pythonic' implementaion
# It was written for practice and understanding the concepts. Feel free to extend or make it better. Cheers !!
# www.parthvora.tk
################################... |
bd595986e74f31a75855f6064a5631f57095ee00 | JunyoungJang/Python | /Introduction/02_Introduction_numpy/1 How to call and use libraries/2 Call the library math - import as.py | 513 | 3.65625 | 4 | # Python comes with many standard libraries
import math
print math.sqrt(2)
print math.hypot(2,3) # sqrt(x**2+y**2)
print math.e, math.pi # as accurate as possible
# Python also provides a help function
import math
help(math)
# And some nicer ways to import
from math import sqrt
print sqrt(3)
# same result
fro... |
0d8b3d91c157f562aca6af9b4bdd497a9c3d8092 | Yuan98Yu/solutions-to-leetcode-cn | /solutions/872.叶子相似的树.py | 779 | 3.828125 | 4 | #
# @lc app=leetcode.cn id=872 lang=python3
#
# [872] 叶子相似的树
#
# @lc code=start
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def leafSimilar(self, root1: TreeNode, root2: TreeNode) ... |
1e0a17a57def36cd342214398f3be50a9c83a275 | Abdelmuttalib/Python-Practice-Challenges | /Time Conversion Challenge/timeConversion.py | 2,070 | 4.4375 | 4 | ## CHALLENGE QUESTION
"""
Given a time in -hour AM/PM format, convert it to military (24-hour) time.
Note: - 12:00:00AM on a 12-hour clock is 00:00:00 on a 24-hour clock.
- 12:00:00PM on a 12-hour clock is 12:00:00 on a 24-hour clock.
Example
s = '12:01:00PM'
Return '12:01:00'.
--
s = '12:01:00AM'
Return '00:01:00... |
74473175ef42b048802386c267bc906ecf44da05 | ddoox/Practicepython.org | /25_guessing_game_two.py | 423 | 3.59375 | 4 | import random
user = 1
number = random.randint(0, 100)
maxn = 100
minn = 0
rounds = 1
while user:
print("Number " + number.__str__() + "?")
user = int(input("0 - correct, 1 - too low, 2 - too high: "))
if user == 1:
minn = number
elif user == 2:
maxn = number
elif user == 0:
... |
1c67848b1f88e8447916dfafd39c54d069aba4a3 | christinababaya/guessing-game | /game.py | 1,379 | 4.25 | 4 | """A number-guessing game."""
# Put your code here
#The computer will choose a random number between 1-100 and ask the user to guess the number
#Once the user guesses, the computer will tell the user if their guess was too high or too low
#The game is over once the user guesses the computer's number. When the game is o... |
c116bd8381065ac8d8868cb19780456fe2363a1d | xuegangliu/python | /sample/threadModule/threadModule.py | 539 | 3.59375 | 4 | #!/usr/bin/python
# coding=UTF-8
# author: xuegangliu
# description: 线程
import _thread
import time
sumCount=1
# 为线程定义一个函数
def print_time(threadName,delay):
count = 0
while count < 2:
time.sleep(delay)
count += 1
print("%s: %s" % ( threadName, time.ctime(time.time())))
# 创建两个线程
try:
_threa... |
e8b294018071094fdc742750aa35632c64fa7ffd | anthonybotello/Coding_Dojo | /Python/python/fundamentals/hello_world.py | 325 | 3.953125 | 4 | print("Hello World")
name = "Anthony"
print("Hello,",name)
print("Hello, " + name)
num = 12
print("Hello",num)
# print("Hello, " + num)
print("Hello " + str(num))
food_one = "ribs"
food_two = "brisket"
print("I love to eat {} and {}.".format(food_one,food_two))
print(f"I love to eat {food_one} and {food_tw... |
0f835488ff8ece8736d30b7cbff5e5307f42f429 | germandouce/AyP-1 | /Parciales/2020-C1-P2/2020_1C_P2.py | 7,931 | 3.65625 | 4 | #2020 1C P2
#07/07/20
#total ej num + 2 cortitos = 1 hr 5 min
# me quedan 55 min xa ABM (u 1hr 15 min si tengo suerte y dan mais tempo)
#ej 1 + 2 ) 17:00 - 17:25 -> 25 min
'''
#ej 1)
#21 digits
#1101001111011,10100101 (base 2) = 1A7B, A5 (base 16)
#ej 2)
#2019(base 10) = 133203 (base 4)
#2019(base 10) = 1111110001... |
32cb9f5942075abf63af59facb214ad84b5d8965 | tristan-ae-smith/gdpgroup3 | /recommender/datastore/vector.py | 983 | 3.765625 | 4 | from __future__ import division
import numpy
def string_to_vector(string):
""" Given a string representing a vector returned from the datastore,
returns a numpy array representation of the vector. The precision is capped
to 12 s.f for the purpose of restricting each vector element inthe database
to 14 characte... |
f7d3b0e0005e85fe33a24ddbf08784d65e0b172d | chyt123/cosmos | /coding_everyday/lc1-100/lc5/Longest Palindromic Substring.py | 897 | 3.53125 | 4 | import collections
from typing import List
class Solution:
def longestPalindrome(self, s: str) -> str:
ans = ''
maxx = 0
for i in range(len(s) * 2):
if i % 2 == 0:
l = r = i // 2
cnt = -1
else:
l, r = (i - 1) // 2, (i ... |
8bfe65372908044c2e2f37520937d7a0b2f06215 | NikitaVozisov/CommandLineArgumentParser | /ArgParse.py | 968 | 3.671875 | 4 | import argparse
import functools
@functools.lru_cache()
def fib(n):
a,b=0,1
for i in range(n):
a,b=b,a+b
return a
def Main():
parser=argparse.ArgumentParser()
group=parser.add_mutually_exclusive_group()
group.add_argument("-v","--verbose", action="store_true")
group.add... |
246fbbd4433b06d361d181fc3da421bac69f60a2 | SankeerthTella/Algorithms | /CSES/Introductory/Permutations.py | 348 | 3.875 | 4 | def helper(n):
if n==1:
print(1," ")
return
res=[]
if n<=3:
print("NO SOLUTION")
return
for i in range(1,n+1):
if i%2==0:
print(i,end=" ")
for i in range(1,n+1):
if i%2==1:
print(i,end=" ")
def main():
n=int(input())
... |
287427b2cc0da6301b9f701428f18ee8f4288909 | TechedLemur/TDT4171-Methods-in-AI | /Exercise-5.py | 9,764 | 4 | 4 | # Use Python 3.8 or newer (https://www.python.org/downloads/)
import unittest
# Remember to install numpy (https://numpy.org/install/)!
import numpy as np
import pickle
import os
class NeuralNetwork:
"""Implement/make changes to places in the code that contains #TODO."""
def __init__(self, input_dim: int, hi... |
e85cdee4a3397c0f794c1b9009158677dfa80e58 | pdhhiep/Computation_using_Python | /polpak/slice.py | 2,351 | 4.03125 | 4 | #!/usr/bin/env python
def slice ( dim_num, slice_num ):
#*****************************************************************************80
#
## SLICE: maximum number of pieces created by a given number of slices.
#
# Discussion:
#
# If we imagine slicing a pizza, each slice produce more pieces.
# The position ... |
3dba5e5a2d3c6690df38ed03a4301ac283bd2e1a | NoisNette/Codesignal-solutions | /powersOfTwo.py | 152 | 3.625 | 4 | def powersOfTwo(n):
res = []
base = 1
while n > 0:
if n % 2 == 1: res.append(base)
base *= 2
n //= 2
return res
|
c739980776e1ddaa451a2fa213858102438cd234 | MrHamdulay/csc3-capstone | /examples/data/Assignment_3/dkcgeo002/question4.py | 433 | 4.03125 | 4 | __author__ = 'George'
def isprime(number):
prime = True
for a in range(2,number):
if number%a == 0:
prime = False
break
return prime
start = eval(input("Enter the starting point N:\n"))
end = eval(input("Enter the ending point M:\n"))
print("The palindromic primes a... |
1b08b4f8622e7d695b5001b97b2f9abde8486b81 | jayyok/ensiie-P | /Python/seCroiseOuPas.py | 239 | 3.734375 | 4 | #!/usr/bin/python3
x1 = int(input("x1:\t"))
y1 = int(input("y1:\t"))
x2 = int(input("x2:\t"))
y2 = int(input("y2:\t"))
det = (x1 * y2) - (x2 * y1)
if(det==0):
print('Les segments ne se croisent pas !')
else:
print('elles se croisent') |
8c96b3dcfa5923ef2a80e5462823370e1fca092a | pytoinette/python-ta | /src/app.py | 386 | 3.875 | 4 | import sys
import os
def palindrome(s):
small_word = s.lower()
no_space_word = small_word.replace(' ' , '')
reverse = no_space_word[::-1]
return no_space_word == reverse
def solution(s):
return palindrome(s)
if __name__ == "__main__":
if len(sys.argv) <= 1:
sys.exit(os.... |
816731e703a95f7748fdf08800d0e21f7b71330b | ejm2095/practice | /prob4.py | 395 | 4.03125 | 4 | __author__ = 'ejm2095'
#Find the largest palindrome made from the product of two 3-digit numbers.
from utils import largest
def pal():
v = []
for x in range(999, 99, -1):
for y in range(999, x, -1):
v1 = x*y
v1_s = str(v1)
v2_s = v1_s[::-1]
if v1_s == v2_... |
9a879c5cdf583df0a9dfea57d3c9beb0002973fa | danpianji/python3.7 | /lgp/example100/exam50_随机数.py | 880 | 3.953125 | 4 | #!/user/bin/env python
#coding:utf-8
import random
print random.random() #输入0-1之间的随机数
print random.uniform(10,20) #输出10-20之间的随机数
print random.randint(10,20) #输出10-20之间的随机整数
print random.choice([x for x in range(1,100)]) #输出1-99间的随机数
class Num:
nNum = 1
def inc(self):
self.nNum += 1... |
d9d5e886048c162986eefd3c6e1aca8e3cdc6777 | tngo0508/practice_coding | /quicksort.py | 560 | 3.734375 | 4 | def quick_sort(arr, lo, hi):
if lo < hi:
p = partition(arr, lo, hi)
quick_sort(arr, lo, p - 1)
quick_sort(arr, p + 1, hi)
# lomuto partion
def partition(arr, lo, hi):
i = lo - 1
pivot = arr[hi]
for j in range(lo, hi):
if arr[j] < pivot:
i += 1
arr... |
4aa856d4ed4d60c1a4ab4d45bb464ca14658b2be | lncannon/cti110 | /M3T1_AreasOfRectangles_LisaCannon.py | 790 | 4.125 | 4 | # Lisa Cannon
# CTI-110
# M3T1: Areas of Recatangles
# 24SEP17
print ("This program will calculate the area of two rectangles.")
# Rectangle One
width1 = int(input("Enter the width of Rectangle One: "))
height1 = int(input("Enter the of Rectangle One: "))
area1 = width1 * height1
##print ("The area of R... |
da82b2f6046f1063005842905858aaf79536986b | haggaingosamwape/machine_learning | /maths/probability/0x01-discrete_probability/1-binomial_moments.py | 267 | 3.546875 | 4 | #!/usr/bin/python3
"""calculating moments of a a binomial distribution"""
from scipy.stats import binom
#distribution parameters
p = 0.3
k = 100
#calculate moments
mean, var, _, _ = binom.stats(k, p, moments='mvsk')
print("Mean=%.3f, Variance=%.3f" % (mean, var))
|
d4dd99de29ec472c7c9d60d51e30ed61ce9f5371 | yurii-fylonych/array_problems | /array_problem_6.py | 2,172 | 3.609375 | 4 | array = [10, 3, 16, 99, 22, 100, 44, 22, -12, 33, 21]
def mid_number(array):
C =int(input('Enter value C'))
k = 0
sum = 0
if array == 0:
return None, 'Enter new array. This one slightly short'
for item in array:
if item > C:
k = +1
sum += item
if k == ... |
5192814a5f84ae29aa0f6fbcce6e13ad8ba62858 | MaherBouidani/CrackTheCoding_InPython | /Chapter8/problem_9.py | 1,029 | 3.953125 | 4 |
# a d g
# b e h
# c f
import math
def print_f(string):
list_string = string.split(" ")
list_string = sorted(list_string)
N = len(list_string)
num = math.ceil(N/3)
table=[]
for row in range(num):
temp=[]
for col in range (row, N, 3):
temp.append(li... |
81fb2d8ddf679847b0d095f1277fea7eae2db178 | Dou8856/Hobby | /scripts/python/test.py | 2,666 | 3.921875 | 4 | from random import *
print random()
print randint(0, 100)
print uniform(1, 10)
#shuffle the list
i = 0
l = []
while i < 10:
l.append(randint(1,10))
i=i+1
print l
l.sort()
print l
shuffle(l)
print l
print sample(l, 2)
print type(sample(l, 2))
#Class
class Student(object):
#Private variables
__name = "... |
e77529e5ca581d581cd63adc3c646bf9b29c0beb | gabriellaec/desoft-analise-exercicios | /backup/user_124/ch41_2019_04_05_03_07_18_456621.py | 149 | 4 | 4 | senha = input("descubra a senha: ")
while senha != "desisto":
senha = input("descubra a senha: ")
else:
print("Você acertou a senha!")
|
759b101ede1544a69d70126ac4626b81816cd335 | DanJimm/pystudy | /login_check/getname.py | 901 | 3.625 | 4 | #coding=utf-8
#!/usr/bin/env python
import os
def getkey(str):
if '=' not in str:
print u'Error'
else:
L = str.split('=')
#print L
key = L[1].split()
#print key
return key
def getname(keyword):
with open(u'D:\python_project\login_check\passwd.txt' , 'r') as fil... |
6848514b760ff4ef3d6d720f4ee5df4ae5915e19 | Crabhammer/hello-world | /Shopping List 2.py | 4,735 | 3.671875 | 4 | from colorama import Fore,Back,Style
topCrafts = []
medCrafts = []
needed = {}
crafts = {}
inv = {}
bank = {}
def addTopCraft():
print("Add top-level crafts or 'done'")
print("Format:")
while True:
s = input("Quantity.Name\n")
if s.lower() == "done":
break
else:
... |
7f93be4aca3975889d8f0a4e6510fbba2ac7cf59 | ebarillot/Python2 | /Upmc_TP/trinome.py | 2,272 | 3.71875 | 4 | # coding: Utf8
def Trinome(a,b,c):
if a==0:
print 'Equation du premier degré'
if b!=0:
print "dont l'unique solution est ",'{:4f}'.format(float(c)/b)
elif c!=0:
print "qui n'a pas de solution"
else:
print 'dont tout nombre réel est solution'
... |
c92ea9c064f5a690da8fb131dac97e51a61e40ee | mjwolfe91/DS_7335_MWolfe | /Homework3/old/NumPy matrix math 1.py | 8,137 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Feb 16 11:18:35 2019
@author: Chris
"""
import numpy as np
# Decision making with Matrices
# This is a pretty simple assingment. You will do something you do everyday, but today it will be
# with matrix manipulations.
# The problem is: you and your work fi... |
e7fd017dedea6acf9e3140e7305199c538302123 | Yanlu109/lab2-py | /main.py | 734 | 3.671875 | 4 | # Author: Yanling Yan Lu yfl5541@psu.edu
# Collaborator: Gabrielle Brunner-King gsb5225@psu.edu
# Collaborator: Mason McGuirk (mtm5868@psu.edu)
# Section: 4
# Breakout: 13
def getLetterGrade(grade):
if grade >= 93.0:
lettergrade = 'A'
elif grade >= 90.0:
lettergrade = 'A-'
elif grade >= 87.0:
letterg... |
ab96b42b39e66c2d7fa085a83a1edbf1b527e8a4 | loveplay1983/python_study | /4_dic/demo.py | 5,746 | 4.375 | 4 | ## dictionary is key value pair in python, aka , associative array, mapping
#
#dic = {'a':1, 'b':2, 'c':3}
#print(dic['a'])
#
## add new entry
#dic['d'] = 100
#for i in dic:
# print(i)
#
#en_de = {"red" : "rot", "green" : "grün", "blue" : "blau", "yellow":"gelb"}
#print(en_de)
#print(en_de["red"])
#de_fr = {"rot" : ... |
663cbd24bf97137969a7575bfcd6598bb094674f | daniiarkg/codewars_solutions | /strip_comments.py | 428 | 3.515625 | 4 | # Kata URL https://www.codewars.com/kata/51c8e37cee245da6b40000bd
def solution(string,markers):
if len(markers) == 0:
return string
for i in markers:
string = string.replace(i,markers[0])
rs = [x.rstrip(' ') for x in string.split(markers[0])]
result = rs[0]
rs = rs[1:]
f... |
fef717e2f35131316bf6f6d9bfd2b4f69df91e53 | jesusdmartinez/python-labs | /03_more_datatypes/1_strings/03_04_most_characters.py | 445 | 4.40625 | 4 | '''
Write a script that takes three strings from the user and prints the one with the most characters.
'''
string1 = str(input("please input a string1"))
string2 = str(input("please input a string2"))
string3 = str(input("please input a string3"))
len1 = len(string1)
len2 = len(string2)
len3 = len(string3)
big = max... |
fc8161b380e88a7402577de8a033bcda6b06dd5c | devang191/algorithms_competitions | /google_code_jam/practice (Case Conflict)/next_number.py | 2,006 | 3.890625 | 4 | import os
import sys
"""
The basic code for reading a file, should return a string
"""
def parse_input(input_file):
f = open(input_file, "r")
test_cases = int(f.readline())
final_result = ""
for i in range(test_cases):
test = int(f.readline())
result = next_number(test)
final_re... |
4d44015b1186cdeefbacd181fe4acf9db95a1fb3 | prabakaran1477/PythonScripts | /Techgig_codes/graph_nodes.py | 3,542 | 3.9375 | 4 | graph = {'A': ['B', 'C'],
'B': ['C', 'D'],
'C': ['D'],
'D': ['C'],
'E': ['F'],
'F': ['C']
}
'''
def find_path(graph, start, end, path=[]):
print(' =:= ',graph[start])
path = path + [start]
if start == end:
return path
if start not in graph:... |
cd6fe909ec8871bfbf70b9a0a16cc9efb716ee54 | SushanPoojary/Print-3-lines-from-file | /Print 3 lines from a file.py | 721 | 3.6875 | 4 | from sys import argv
script, input_file = argv
def print_all(f):
print(">>>>> print_all:", f) #just to se entry
print(f.read()) #read
print("<<<<< print_all:", f, "\n") #check exit
def rewind(f):
print(f.seek(0)) #seek
def print_line(line_count, f):
print(line_count, f.readline()) #read single l... |
0b92d0e0c43d2aac97e9e149c536dce76e7d0aca | Introduction-to-Programming-OSOWSKI/2-8-hasl-NolanThrondset2022 | /main.py | 178 | 3.65625 | 4 | #WRITE YOUR CODE IN THIS FILE
def hasL(w):
for i in range(0,len(w)):
if w[i] == "l":
return True
return False
print (hasL("washington")) |
d942834c4b2c62a7b1aa11a67a69584ca38d677f | LYoung-Hub/Algorithm-Data-Structure | /copyRandomList.py | 978 | 3.5625 | 4 | """
# Definition for a Node.
"""
class Node(object):
def __init__(self, val, next, random):
self.val = val
self.next = next
self.random = random
class Solution(object):
def copyRandomList(self, head):
"""
:type head: Node
:rtype: Node
"""
if no... |
d0133093122f0fa288c1fcd1e7d094ca683fe7ec | ng29/SPOJ | /ANARC05B.py | 918 | 3.53125 | 4 | # SPOJ Problem Set (Classical)
# 4557. The Double HeLix
# Problem Code: ANARC05B
def intersection(list1, list2):
int_dict = []
list1_dict = {}
for e in list1:
list1_dict[e] = 1
for e in list2:
if list1_dict.has_key(e):
int_dict.append(e)
return int_dict
x = raw_input().split()
while x[0] != '0':
y = r... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.