blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
efc585c7a65c638ad40e2b2999a08b5514a67daf | ramostitoyostin-unprg/t6_ramos_tito_yostin | /ramos/condicionales_multiples/ejercicio5.py | 982 | 3.890625 | 4 | import os
# INPUT
velocidad_01=int(os.sys.argv[1])
velocidad_02=int(os.sys.argv[2])
distancia=int(os.sys.argv[3])
# PROCESSING
Tiempo_de_encuentro=(distancia)/(velocidad_01+velocidad_02)
# VERIFICADOR
validar_tiempo_encuentro=(Tiempo_de_encuentro==20)
# OUTPUT
print("##################################")
print(("# BO... |
b62d7087b6c3d7f4b1a02b16262078bf988c869f | VundaRoy/NumpySamples | /collection/integerArray.py | 158 | 3.53125 | 4 | import numpy as np
a=np.array([[1,2],[3,4],[5,6]])
print(a[[2,1,0],[0,1,1]])
print(np.array([a[0,0],a[1,1],a[2,0]]))
print(a[[0,0],[1,0]])
print(a[[0,0]]) |
840cd2c3ba164285f7db9f867a44f7eb08cb3bd2 | RishabhK88/PythonPrograms | /2. PrimitiveTypes/Numbers.py | 570 | 4 | 4 | x = 1
y = 1.1
z = 1 + 2j
# x is integer, y is float, z is complex numbers where j reperesens iota(i) in math
print(10 + 3)
print(10 - 3)
print(10 / 3)
print(10 * 3)
print(10 ** 3)
# ** is used for exponent i.e. first number raised to the power second number
print(10 // 3)
# // is used to get an integer part ... |
0bf0853ed0581af801a76606bcac407e4c45feb9 | testcg/python | /code_all/day03/demo02.py | 637 | 3.953125 | 4 | """
字面值:各种写法
数据类型
int float str
10 1.2 "随便"
"""
# 1. int 字面值
# 十进制DEC:每位用十种状态计数,逢十进一,写法是0~9。
number01 = 10
# 二进制BIN:每位用二种状态计数,逢二进一,写法是0~1。
number02 = 0b10
# 八进制OCT:每位用八种状态计数,逢八进一,写法是0~7。
number03 = 0o10
# 十六进制HEX:每位用十六种状态计数,逢十六进一,写法是0~9 a(10)~f(15)。
number04 = 0x10
# 2. ... |
9cbdab3c56407211104dbdc7d92524e64451bf5c | lschanne/DailyCodingProblems | /year_2019/month_02/2019_02_17__missing_positive_integer.py | 1,769 | 3.953125 | 4 | '''
February 17, 2019
Given an array of integers, find the first missing positive integer in
linear time and constant space. In other words, find the lowest positive
integer that does not exist in the array. The array can contain duplicates and
negative numbers as well.
For example, the input [3, 4, -1, 1] should giv... |
89fe8b5760c7527c4964670791da12bbb030cb7b | acmachado14/ListasCCF110 | /Lista07/16.py | 421 | 3.65625 | 4 | #16. Dado um conjunto de 100 valores numéricos disponíveis num meio de entrada qualquer,
#fazer um algoritmo para armazená-los em um vetor B, e calcular e escrever o valor do somatório dado a seguir:
# S = (b1 - b100)³ + (b2 - b99)³ + ... + (b50 - b51)³
A = []
for i in range(6):
A.append(int(input(f"Informe o nume... |
1e3cb8b971d8b8cc8b387bbdcb4b32f63d4aa02a | kaseyriver11/leetcode | /euler/01.py | 101 | 3.65625 | 4 |
total = 0
for i in range(1000):
if (i % 5 == 0) | (i % 3 == 0):
total += i
print(total)
|
e838e5f1798f8dabd5cdae9f5883d317c75d652a | NatnareeChong/WeAreJack | /main.py | 2,912 | 4.15625 | 4 | """
Advanture into the JACK land!
You might have heard of the story Jack and the magic beans. Jack accidentally
get a hold of the bean yesterday and planted them in his back garden.
He watered them day after day not knowing its magical property.
As time passes the tiny beans grow into a giant bean sprout.
Now the ... |
78e5ea5684f2209252792d6b317b246c68f20039 | Jungeol/algorithm | /leetcode/medium/34_find_first_and_last_position_of_element_in_sorted_array/hsh2438.py | 1,555 | 3.640625 | 4 | """
https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/
Runtime: 100 ms, faster than 50.70% of Python3 online submissions for Find First and Last Position of Element in Sorted Array.
Memory Usage: 14 MB, less than 8.93% of Python3 online submissions for Find First and Last Position of... |
e88849862d53dccc578c51b8aae03cc0d34116e1 | narrasubbarao/practise | /FileHandling/Database/Demo7.py | 176 | 3.578125 | 4 |
import sqlite3 as sql
conn = sql.connect("sathya.db")
curs = conn.cursor()
curs.execute("select * from student")
res = curs.fetchall()
for x in res:
print(x[0],x[1],x[2]) |
56fd0da6efe1562c9808d7698dcf627f4453bea3 | anthonyjatoba/codewars | /7 kyu/Sum of the first nth term of Series/Sum of the first nth term of Series.py | 93 | 3.515625 | 4 | def series_sum(n):
res = sum(1/(1+3*d) for d in range(n))
return '{:.2f}'.format(res) |
a1d2f1ccf92e37fd25fd07460403a69af641cb13 | andrewgrow/pyRobomix | /robomix/entries/Day.py | 508 | 3.59375 | 4 | import json
class Day(object):
def __init__(self, day_name: str, schedule: list):
self.schedule = schedule
self.day_name = day_name
def __str__(self):
return '{'+'"name":' + '"' + self.day_name + '"' + ', "schedule":' + json.dumps(self.schedule)+'}'
def get_json(self):
re... |
fe3a3e0d8c18ce36f2aa7220569a6bd15e8edb23 | arisend/epam_python_autumn_2020 | /lecture_04_test/hw/task_2_mock_input.py | 847 | 3.875 | 4 | """
Write a function that accepts an URL as input
and count how many letters `i` are present in the HTML by this URL.
Write a test that check that your function works.
Test should use Mock instead of real network interactions.
You can use urlopen* or any other network libraries.
In case of any network error raise Val... |
de8d7594b65e4fc3ffa5f6d482e58e0c74331d5e | aidangomez/pysched | /multi_jobs_example.py | 1,754 | 4 | 4 | #!/usr/bin/python
"""
Author: Mengye Ren (mren@cs.toronto.edu)
Example of using job scheduler of multiple jobs. This is useful for a
hyper-parameter search with limited resources, and each job maybe of different
length, so scheduling is crucial to keep the maximum utility of the resources.
Callbacks can be used to int... |
f65b59f9b5814c50da6f0fd15f59ef4b7e9dec29 | luiziulky/Controlstructures | /Exercise 13.py | 254 | 4.09375 | 4 | l = ['Sunday','Monday','tuesday','Wednesday','Thursday','Friday','Saturday']
print('DAYS OF THE WEEK')
while True:
num = int(input('Enter a number: '))
if 0 < num < 8:
print(l[num-1])
break
else:
print('Invalid value') |
0e16f3403d0fff57d4dee8126dd2ab9e7adfc594 | austinv211/Artificial-Intelligence-Assignment-1 | /search/problem2.py | 2,570 | 3.78125 | 4 | from typing import Dict, Generator, List, Tuple
from itertools import islice
from queue import PriorityQueue
graph = {
'S': (set(['A', 'B', 'D'])),
'A': (set(['C'])),
'B': (set(['D'])),
'C': (set(['D', 'G'])),
'D': (set(['G'])),
'G': (set())
}
weights = {
('S','A'):2,
('S','B'):3,
... |
5dccac4e948c556065ffe020fa7eff1361723d71 | remani/SRA221-PSU-Hozza | /LBD Hash Cracking/SimpleCracker.py | 1,508 | 3.890625 | 4 | # Simple script to crack lowercase MD5 password hashes
# Brant Goings
# Library needed to hash dictionary file
import hashlib
# Files to import
hashlist = "hashes.txt"
dictlist = "dictionary.txt"
# Method to run
def crack():
# Opens dictionary file as read-only referred to as dictreader
with open(dictlist, "... |
94941a6411f982dcdeeda8926e5b870dd222c26f | 1nF0rmed/network-manager | /security/secure.py | 1,755 | 3.546875 | 4 | import base64
import hashlib
from Crypto import Random
from Crypto.Cipher import AES
class AESCipher:
def __init__(self, key):
self.block_size = AES.block_size # The block size for the padding data
self.key = hashlib.sha256(key.encode()).digest() # Generate a hash for the key
# Lam... |
3b9b89f9e95200e9e4be1d74dd8a5c44f004ca9c | skafev/Python_fundamentals | /03.Third_week/05Numbers_filter.py | 685 | 3.8125 | 4 | num = int(input())
my_list = []
for n in range(1, num + 1):
new_num = int(input())
my_list.append(new_num)
command = input()
new_string = []
if command == "even":
for m in range(len(my_list)):
if my_list[m] % 2 == 0:
new_string.append(my_list[m])
if command == "odd":
for m in range(... |
471869c5fdd3249cf6297dd0ccd412d1637e216f | tainenko/Leetcode2019 | /python/34.find-first-and-last-position-of-element-in-sorted-array.py | 1,737 | 3.8125 | 4 | #
# @lc app=leetcode id=34 lang=python
#
# [34] Find First and Last Position of Element in Sorted Array
#
# https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/description/
#
# algorithms
# Medium (33.91%)
# Total Accepted: 331.2K
# Total Submissions: 974.2K
# Testcase Example: '[5... |
3311f3cedfa5e8c379d4203e50c7544ef32ca354 | PrasanthChettri/competitivecode | /cp/string.py | 189 | 3.71875 | 4 | #STRING , MASK --> _TRING
for _ in range(int(input())):
string = input()
mask = input()
for i in string:
if not i in mask :
print(i , end = '')
print()
|
04e6a5a7fd3f860d62c5ec073d3cc3e51bd6bb4f | yaphet17/Kattis-Problem-Solutions | /Apaxiaaaaaaaaaaaans!.py | 243 | 3.765625 | 4 | string=[i for i in input()]
output=[]
for i in range(len(string)):
if(i==len(string)-1):
output.append(string[i])
break
if(string[i]!=string[i+1]):
output.append(string[i])
for i in output:
print(i,end="")
|
aaf9dd76495d3bd6cf6a3ee32cc036c35641738a | TomAbrahams/Small_Tutorial_For_WordPress | /The_tutorial.py | 2,551 | 4.78125 | 5 | #Putting the # in front of an item is comments.
#This doesn't do anything to code.
#Why put comments? To let others know what you are making of course!
#This program will take an input and multiply it by 2.
#print prints a message. The \n is a return character.
#It puts stuff on the next line.
print("This prints the m... |
8448017d71527315842e6f1cf6cd1ae3a0ec5ddf | OneScreenfulOfPython/screenfuls | /GeneratePassword/generate_password_v1.py | 1,077 | 4.375 | 4 | import os, sys
import random
import string
try:
# Make Python2 work like Python3
input = raw_input
except NameError:
# On Python3; already using input
pass
letters = string.ascii_letters
numbers = string.digits
punctuation = string.punctuation
def generate(password_length):
"""Generate a password... |
91a54401b39a73e7849f74f9e70123baaa196489 | shangpf1/python_study | /2017-11/2017-11-04.py | 802 | 4.1875 | 4 | '''
我的练习作业02 创建类,将类进行实例化
'''
# 创建一个动物类,它可以能吃能喝能睡
class animal:
def __init__(self):
print("创建函数时要调用构造函数")
def eat(self):
print("eat")
def drink(self):
print("drink")
def sleep(self):
print("sleep")
elephant = animal()
elephant.eat()
elephant.drink()
elephant.sleep()
... |
c4532795baf369c70ceadf9555bfc103306f3636 | ardentras/minesweepyr | /src/tiles.py | 2,843 | 3.53125 | 4 | ###########################################################
# Filename: tiles.py
# Author: Shaun Rasmusen <shaunrasmusen@gmail.com>
# Last Modified: 12/31/2020
#
# tile classes for numbers and mines
#
import pygame
import colors
pygame.font.init()
MINE = 9
class Tile(pygame.sprite.Sprite):
def __init__(self, va... |
5722076ade91a65ee7551e69e4e9fba1d4a58424 | jonasht/cursoIntesivoDePython | /exercisesDosCapitulos/09-classes/9.3-usuarios/usuarios.py | 719 | 3.515625 | 4 |
class User():
def __init__(self, first_name, last_name, email, username, password):
self.first_name = first_name
self.last_name = last_name
self.email = email
self.username = username
self.password = password
def describe_user(self):
print... |
6103fa116c6431b19d70a6daa3376eec35f75102 | chenxu0602/LeetCode | /99.recover-binary-search-tree.py | 1,690 | 3.71875 | 4 | #
# @lc app=leetcode id=99 lang=python3
#
# [99] Recover Binary Search Tree
#
# https://leetcode.com/problems/recover-binary-search-tree/description/
#
# algorithms
# Hard (37.35%)
# Likes: 1177
# Dislikes: 65
# Total Accepted: 144.6K
# Total Submissions: 386.8K
# Testcase Example: '[1,3,null,null,2]'
#
# Two el... |
39bde1f0ae4c9962818198d278bf4d757cfcecfa | MultiRRomero/manhattan-map | /la-data/manhattan_dist.py | 1,100 | 3.703125 | 4 | import math
from subway_data import subway_data
"""
Returns: (distance in meters, subway stop data)
Subway stop data has: lat, lng, stop (name), lines
Lines is: string of all lines, i.e, '456'
"""
def get_distance_to_nearest_subway_stop(lat, lng, subway_lines = ['6','R','L']):
structs = get_all_subway_structs_... |
3136556b86cc21e5a8d007b4b368d70693dca208 | saurabhchris1/Algorithm-Pratice-Questions-LeetCode | /Minimum_Window_Substring.py | 1,741 | 3.8125 | 4 | # Given two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in t (including duplicates) is included in the window. If there is no such substring, return the empty string "".
#
# The testcases will be generated such that the answer is unique.
#
# A subs... |
054543e852cdd6c77cd64766ca6dc56212619c60 | grigor-stoyanov/PythonOOP | /decorators/even_numbers.py | 226 | 3.53125 | 4 | def even_numbers(function):
def wrapper(nums):
return list(filter(lambda x: x % 2 == 0, nums))
return wrapper
@even_numbers
def get_numbers(numbers):
return numbers
print(get_numbers([1, 2, 3, 4, 5]))
|
e844f091c5357c5bbdbd34acc5a888dd88da08c2 | TIU11/Pi-Smart-Home-PSU | /relay.py | 390 | 3.59375 | 4 | import gpiozero
# change this value based on which GPIO port the relay is connected to
RELAY_PIN = 18
# create a relay object.
# Triggered by the output pin going low: active_high=False.
# Initially off: initial_value=False
relay = gpiozero.OutputDevice(RELAY_PIN, active_high=False, initial_value=False)
def toggle_r... |
5c788c50f97557364bbb436dfc9688f2a730488b | Czartor/Big-Date | /Exercise4.py | 248 | 3.578125 | 4 | print('Wprowadź liczbę:')
print('n = ')
n = int(input())
if (n==0):
print(1)
exit()
else:
wprowadzona_liczba = 1
for i in range(1, n+1):
wprowadzona_liczba *= i
print("silnia z", n, "wynosi", wprowadzona_liczba)
|
fd7d3593594c6bdd867926fff268aee926ebaee8 | chomimi101/system-design | /mini-twitter/mini-twitter.py | 2,213 | 3.875 | 4 | '''
Definition of Tweet:
class Tweet:
@classmethod
def create(cls, user_id, tweet_text):
# This will create a new tweet object,
# and auto fill id
'''
class MiniTwitter:
def __init__(self):
# initialize your data structure here.
self.follows = dict()
self.tweets ... |
3571b8bab993818c9c768be22e877c3193f93452 | RITESH-Kapse/Python-Openpyxl-Codes | /6.2_Copying_formatting.py | 1,674 | 3.578125 | 4 | #!/usr/bin/env python3
"""
Copying cell formatting
"""
from openpyxl import Workbook
from copy import copy
from openpyxl.styles import colors, Font
def set_values(ws):
ws.delete_cols(1,100)
counter = 1
for row in ws.iter_rows(min_row=1, max_col=10, max_row=10):
for cell in row:
... |
170734fa058609e5d528dacf2446749068940e9c | matteiluca/info1 | /task1/module.py | 3,784 | 3.640625 | 4 | # REMARK: directory name HAD TO be changed in order to be importable
# without using the __import__ function (no space; 'task1' instead of 'task 1')
# because the filename is used as the identifier for imported modules and the 'import' statement doesn't support spaces!
from Exercise6.task1.moduleElement import * # RE... |
9d86708abd920c125b3857bcf74f90aa755ba1fb | LuisaMariaO/PhytonBasico2021 | /Hojadetrabajo3.py | 729 | 4.0625 | 4 | #Comparacion de contraseñas
print("___________________EJERCICIO 1__________________")
password=input("Ingrese una contraseña: ")
confirmacion=input("Confirme la contraseña: ")
if password.lower()==confirmacion.lower():
print("Confirmacion exitosa")
else:
print("Las contraseñas no coinciden")
#Grupos d... |
1998a5ad5655cf03c947359b9b454e67e35a4923 | omrakn/randomalgorithms | /convexhull/convexhull.py | 8,396 | 3.859375 | 4 | """
Convex Hull with Graham Scan Algorithm
@ Author: Res. Assist. Ömer Akın
@ Institution: Istanbul Technical University Geomatics Engineering Departmant
@ e-mail: akinom@itu.edu.tr
"""
import os, sys, math, random
import matplotlib.pyplot as plt
def getInput():
"""
Generate points randomly or from the in... |
bc60f94fec9de1e835406fb49946c66ef18ff804 | AyuJ01/forsk | /day17 multiple regression/Ayushi_Jain_53.py | 1,317 | 3.59375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Jun 1 12:35:14 2018
@author: Ayushi
"""
import numpy as np
#read csv
import pandas as pd
df = pd.read_csv("stats_females.csv")
features = df.iloc[:,1:].values
labels = df.iloc[:,0].values
#splitting the dataset
from sklearn.model_selection import train_test_split
featur... |
bd5a71e48a60e911a816856279a2213f3fe5811d | gauravcse/Codes | /Python/Complex/ComplexNum.py | 2,522 | 3.640625 | 4 | class ComplexNum(object) :
def __init__(self,a,b,c,d):
self.x1=a;
self.y1=b
self.x2=c
self.y2=d
def add (self):
self.sum=self.x1+self.x2
self.ima=self.y1+self.y2
if(self.sum==0.0) :
print "%0.2fi"%(self.ima)
else :
if ... |
19fdb88657e447c508b8f77134eef39cca8dd21f | asperaa/programming_problems | /dp/paint_house_linear_space.py | 681 | 3.578125 | 4 | """Paint house.Time - O(n). Space - O(n)"""
def paint_house(costs):
if not costs:
return 0
length = len(costs)
dp = [[0 for _ in range(3)] for _ in range(length)]
dp[0][0] = costs[0][0]
dp[0][1] = costs[0][1]
dp[0][2] = costs[0][2]
for i in range(1, length):
dp[i][0] +... |
1ba73f2c1d1097603d9e9881b8b3d1aa071930b8 | daveswork/pythonforeverybody | /chapter-08/excercise-06.py | 1,055 | 4.3125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Exercise 6: Rewrite the program that prompts the user for a list of numbers
and prints out the maximum and minimum of the numbers at the end when the user
enters "done". Write the program to store the numbers the user enters in a list
and use the max() and min() func... |
4ecc42de5bd9627996eb321e0e082993315661fe | kutakieu/AI-class | /Assignment-1-Search-master-63318a771170bfa64d905052bc0e733cfd3b576e/code/a_star_search.py | 2,552 | 3.59375 | 4 |
"""
Enter your details below:
Name:Taku Ueki
Student Code:u5934839
email:u5934839@anu.edu.au
"""
import util
from actions import Directions, Actions
from search_strategies import SearchNode
from frontiers import Queue, Stack, PriorityQueue
import heuristics
def solve(problem, heuristic) :
""" ***... |
d59839e5e25072211e7a4ee85baddc6c0cfea643 | Nishi216/PYTHON-CODES | /NUMPY/numpy7.py | 506 | 4.0625 | 4 | ''' Linear algebra in numpy '''
import numpy as np
array = np.array([[6,1,1],[4,-2,5],[2,8,7]])
print("Rank of array : ",np.linalg.matrix_rank(array))
print('Trace of the matrix : ',np.trace(array))
print('Determinant of matrix : ',np.linalg.det(array))
print('Inverse of matrix : ',np.linalg.inv(array))
prin... |
a862e69f1a765276f9b96e4b4e86757263dffb0d | itzketan/3rd-day | /3rd day.py | 2,945 | 4.46875 | 4 | #simple GUI registration form.
#importing tkinter module for GUI application
from tkinter import *
#Creating object 'root' of Tk()
root = Tk()
#Providing Geometry to the form
root.geometry("800x700")
#Providing title to the form
root.title('Registration form')
#this creates 'Label' widget for Registra... |
22b87fcbb97571a6d0c2d922ddacb4a0a6bdaf98 | WangXiaoTang333/python_30mintues | /lec01/currency_converter_v5.0.py | 1,024 | 3.875 | 4 | """
作者:王糖糖
功能:汇率兑换currency_converter_v5.0.py
版本:5.0
日期:27/12/2018
新增功能:(1)程序更加模块化
(2)lambda函数的使用
"""
#
# def converter_com(im,er):
# out_m = im * er
# return out_m
def main():
# 汇率
USD_VS_RMB = 6.77
currency_str_value = input("请输入带单位的货币输入金额(USD or CNY,退出... |
f1cc0c7668c97331be34f84f2c1d551af942d743 | haakoneh/TDT4110 | /Oving_2/Oving2_5.py | 829 | 3.703125 | 4 | def timelonn():
timelonn = float(input('Skriv inn timelonnen: '))
timer = float(input('Skriv antall timer: '))
lonn = timelonn*timer
print('Lonnen blir: ', lonn)
def provisjon():
grunnlonn = float(input('Skriv inn grunnlonnen: '))
enhetlonn = float(input('Skriv inn enhetslonnen: '))
antall = float(input('Skriv... |
66c666c2936792d9251384842ed993eaacca99c7 | HelloYeew/helloyeew-computer-programming-i | /OOP_Inclass_2/inclass_demo_exercise_code/Point2D_Rectangle.py | 1,330 | 4.21875 | 4 | class Point2D:
"""Point class represents and operate on x, y coordinates
"""
def __init__(self, x=0, y=0):
self.x = x
self.y = y
def distance_from_origin(self):
return (self.x*self.x + self.y*self.y)**0.5
def halfway(self, other):
halfway_x = (other.x + self.x) / 2
... |
da7e74fe1311970da818b2792ea60feef4bcde8b | nidawi/2DV515-A4 | /models/CrossValidation.py | 4,607 | 3.546875 | 4 | from models.NaiveBayes import NaiveBayes
from lib.utils import accuracy_score, confusion_matrix, present_matrix
from random import randrange
from typing import List
def crossval_predict(X: List[List[float]], y: List[int], folds: int) -> List[int]:
"""
Runs n-fold cross-validation on the provided dataset, X, with t... |
406753ae761c595afa2832ec080e83c0284315b6 | ISE2012/ch3 | /dino_v1.py | 970 | 3.828125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Sep 22 15:47:38 2020
@author: xyz
"""
def main():
print("Welcome to the DinoCheck 1.0")
print("Please answer 'True' or 'False' for each question")
isSharp = input("Does the dinosaur have sharp teeth? ")
isWalled = input("Is the dinosaur behind a la... |
24d8138f733cdb2d2bde10087c6600f23a9a0405 | rafarikrdo/QueroPizza | /1171 Frequência de números.py | 376 | 3.71875 | 4 | #def achaNumeros(lista):
# for i in range(0, len(lista)):
# return i
vezes=int(input())
a=0
list=[]
for i in range(0,vezes):
num=int(input())
list.append(num)
list.sort()
for i in range(0, vezes):
a = list.count(list[i])
if list[i] != list[i-1]:
print("{} aparece {} vez(... |
3b27cc2f8e6ecbcab795b5837df5ccad3eaa9517 | jbmasemza/katas_programming | /hello.py | 95 | 3.765625 | 4 | def main():
name = str(input("enter your name :"))
print("hello " + name + "!")
main()
|
31f36e9107d2fb41c529abcd77a23eb51c8efbdb | DarioSardi/AI | /Perceptron/perceptron.py | 774 | 3.5625 | 4 | import numpy as np
def act(x):
if (x > 0):
return 1
else:
return -1
import numpy as np
class Perceptron:
def __init__(self,size):
#prende input e inizializza in base alla sua dimensione pesi randomici
self.weights = np.random.rand(size,1)
self.lr = 0.01
def ... |
e6b226a375e276722e80f8a36e58a3b804c2bfe4 | miguelbatista21/python | /elif/test1-elif-else-if.py | 1,038 | 4 | 4 | num = int(input("Coloque um numero: "))
if num < 200:
preco = 0.20
elif num <= 400:
preco = 0.18
elif num <= 800:
preco = 0.15
else:
preco = 0.08
print("Resultado:", (num * preco))
print(preco)
#if soma > 0:
# print "Maior que Zero."
#elif soma = 0:
# print "Igual a Zero."
#else:
# print "... |
64fdc4823f6a31b01f85bbb79e814d9e16ff3f17 | kainpets/Zelle-introduction-to-CS | /code/chapter13/c13ex08.py | 2,013 | 4.03125 | 4 | # c13ex08.py
#Turtle and Koch snowflake
from graphics import *
from math import cos,sin,pi
class Turtle:
def __init__(self,window,location = Point(0,0),heading = 0.0):
# default position is (0,0) and direction is 0.0 (east)
self.position = location
self.direction = heading
self.win = wi... |
64a316993436ab7cfef39757c733cfdd5352a453 | ayusha72/PPL_ASSIGNMENT | /Assignment_1/puzzle.py | 668 | 3.78125 | 4 | list_a = ['goat','tiger', 'grass']
list_b = []
import random
def safe_check(list_c) :
if 'tiger' in list_c and 'goat' in list_c:
return False
elif 'grass' in list_c and 'goat' in list_c:
return False
else :
return True
while len(list_a) != 0 :
result = list_a.pop()
if safe_check(list_a) == False :
list_a.i... |
86c8ca8d3f5cbb170d6b14bebf69107533f758ef | Evaldo-comp/Python_Teoria-e-Pratica | /Livros_Cursos/Nilo_3ed/cap05/teste.py | 672 | 3.921875 | 4 | """
Escreva um programa que leia um número e verifique se é ou não um número primo.
Para fazer essa verificação, calcule o resto da divisão do número por 2 e depois
por todos os números impares até o número lido. Se o resto de uma dessas divisões
for igual a zero, o número não é primo. Observe que 0 e 1 não são primos ... |
a4b37a740ae68afb6e74ac5a4e4c2042daf97b49 | smohapatra1/scripting | /python/practice/start_again/2021/01172021/credit_card_validation_with_algorithm.py | 1,423 | 4.21875 | 4 | #Validate credit card using modulous-10 algorithm
#https://www.codeproject.com/Tips/515367/Validate-credit-card-number-with-Mod-10-algorithm
#Card Length
#Typically, credit card numbers are all numeric and the length of the credit card number is between 12 digits to 19 digits.
#14, 15, 16 digits – Diners Club
#15 d... |
1b547f344e13618b977166f9c59e3f58a7b422e9 | longngo2002/C4TB | /session9/part1/create.py | 109 | 3.671875 | 4 | a = ['blue','red','yellow']
print(*a,sep=", ")
b = input("Enter a new color:")
a.append(b)
print(*a,sep=", ") |
2bb5c97808cddf506f0c16eaabd18413527cfb43 | ronak148/Guessing-Number-1 | /Youcan.py | 798 | 4.0625 | 4 | #
import random
print("Let's Play Guessing Number Game")
a=int(raw_input("Select your range's Start Number:"))
b=int(raw_input("Select your range's Last Number:"))
#p#rint(a)
#print(b)
x = random.randint(a,b)
#print(x)
#y=range(a,b)
#print(y)
atp=3
while atp>0:
y=int(raw_input("Guess and Enter any Number in your... |
f658f082f40ca461f36a62f714ebcf58eab08075 | Sorochtej/Python---lerning- | /Chapter 3/Ex.1.py | 645 | 4.0625 | 4 | # Divination drawing program.
import random
print("\tMaybe it's not taste as good as real one but still it have somthing...")
print("\nYour divination for next year: ...")
fairy_tail = random.randint(1,5)
if fairy_tail == 1:
print("You will fall in love this year !")
elif fairy_tail == 2:
print("You wi... |
d863c6ccac2370669071527837380acb260fe9ea | phlalx/algorithms | /leetcode/604.design-compressed-string-iterator.python3.py | 1,277 | 3.53125 | 4 | # TAGS datatype, lexer
class StringIterator:
def __init__(self, compressedString):
"""
:type compressedString: str
"""
self.compressedString = compressedString
self.i = 0
self.cur_char = None
self.n = len(compressedString)
self.cur_count = 0
def... |
3dc5febdd20184c7948c52e5bd210aa0f1ebb82a | gmeneze/ase16hxx | /project/Code/Route.py | 964 | 3.703125 | 4 | #!/usr/bin/python
"""
Problem.py (c) 2016 gmeneze@ncsu.edu, dnair@ncsu.edu, smurali8@ncsu.edu. MIT licence
USAGE:
python Problem.py
OUTPUT:
Produces an output in the format of :-
"""
from __future__ import division,print_function
import sys,re,traceback,random, operator, string, time
sys.dont_write_bytecode=... |
a479b4b135e5ac57886549a8bca8cdfa1c8c8ede | stevenchendan/Grokking-Algorithms-Practice | /PythonSolution/04_quicksort/04_recursive_sum.py | 189 | 3.84375 | 4 | def recursive_sum(list):
if list == []:
return 0
return list[0] + recursive_sum(list[1:])
if __name__ == "__main__":
test_array = [1, 2, 3, 4]
print(recursive_sum(test_array))
|
c5027668aeaa431baef0bbe81b8d0b9701cb67a8 | Yuki-hosso/self-taught-python | /sample_str_conect.py | 114 | 3.625 | 4 | s1 = input("what :")
s2 = input("who :")
r = "私は昨日{}を書いて,{}に送った".format(s1,s2)
print(r) |
1b4f7ae4ea90057cd087d8e8ceffb450e9c1d768 | amir-mersad/ICS3U-Unit3-02-Python | /students.py | 486 | 4.0625 | 4 | #!/usr/bin/env python3
# Created by Amir Mersad
# Created on September 2019
# This program checks if there are more there 30 students
import constants
def main():
# This function checks if there are more than 30 student
# Input
number_of_students = int(input("Enter the number of students: "))
print... |
3f9efdd438c678fd1a92e8d157e69178549e99c6 | Roger-ELIAS/IDD | /CSV2SQL.py | 2,192 | 3.671875 | 4 | #lecture d'un fichier CSV -> dataframe -> table SQL
import pandas as pd
import pandasql as ps
import re
import sqlite3
#sqlRequest = "SELECT * FROM tournagesdefilmsparis2011 WHERE titre = 'COUP DE FOUDRE A JAIPUR';"
class CSV2SQL():
def translateRequest(self, sqlRequest):
result = re.search("FROM ([A-Z... |
2481a97f228584347704394cdf10b06ae06fea85 | jeansyo/Python | /producto_De_matrices_ala_antigua.py | 1,104 | 3.625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu May 7 23:00:47 2020
@author: DELL.E5430.SSD
"""
p = int(input('Digite el nuemro de filas de A: '))
q = int(input('Digite el numeros de columnas de A,(filas de B): '))
r = int(input('Digite el numeros de columnas de B: '))
matriz_a = []
matriz_b = []
for i in range(p):
... |
b142058868beea5bd1469c8eae2f04f616944bd7 | PabloYepes27/holbertonschool-higher_level_programming | /0x0B-python-input_output/100-append_after.py | 776 | 4.1875 | 4 | #!/usr/bin/python3
""" Write a function that inserts a line of text to a file, after
each line containing a specific string (see example): """
def append_after(filename="", search_string="", new_string=""):
"""inserts a line of text to a file,
Args:
filename (str, optional): [description]. Defaults ... |
66dbbeb6454327582324c03c276c41ba455ca623 | PabloLanza/curso-python3 | /exercicios-python/curso-python/ex032.py | 574 | 4.0625 | 4 | import math
print('Olá! Bem Vindo ao sistema de conversão numérica.')
num = int(input('Digite o número que você deseja fazer a conversão: '))
op = int(input('Você quer converter o número {} para:\n 1 - Binário\n 2 - Octal\n 3 - Hexadecimal\n'.format(num)))
if op == 1:
print('O número {} em Binário é: {}'.format(num... |
6acb8dcc0e5c2ad1354e71dc40c2f0f7e5cdfd9d | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_203/401.py | 1,731 | 3.671875 | 4 | """ Fill cake with grid initials"""
from sys import stdin
def find_first_non_quest(row, cols):
for i in range(cols):
if row[i] != '?':
return i
return -1
def solve_cakes(rows, cols, grid):
# First fill row wise.
new_grid = []
for row in grid:
# find first character not... |
c2cc95527d55137b6200da6fbf562c1d809b4bd8 | harishb2k/topic | /tenserflow/custom_layer_how.py | 2,046 | 3.75 | 4 | import tensorflow as tf
from tensorflow import keras
class Linear(keras.layers.Layer):
def __init__(self, units=32, input_dim=32):
super(Linear, self).__init__()
# We should have weights as random - for this case using simple var to debug
r = tf.constant([[1.0, 1.0, 1.0], [2.0, 2.0, 2.0]]... |
82bf25c4cfc2f37e551abd1582ee757e15999de7 | g00364787/52167assessments | /gmit--exercise01--fibonacci--20180123.py | 1,390 | 4.375 | 4 | # AUTHOR = PAUL KEARNEY
# DATE = 2018-01-23
# STUDENT ID = G00364787
# EXERCISE 01
#
# filename= gmit--exercise01--FIBINACCI--20180123.py
#
# FINONACCI NUBMERS
# Ian McLoughlin
# A program that displays Fibonacci numbers.
def fib(n):
"""This function returns the nth Fibonacci number."""
i = 0
... |
b8ece585b18abf2f49e4a981bf2c8c8a4811ce5a | Roshni-jha/ifelse | /equal or not equal .py | 111 | 3.703125 | 4 | # num =int(input("enter the number"))
# if num==1000:
# print("equal hai")
# else:
# print("not equal") |
33c83a5df2b2f47dc794dd66386a7ed0524c9486 | mitpokerbots/playground | /server/pokerbots_parser/bot.py | 2,987 | 3.6875 | 4 | '''
This file contains the base class that you should implement for your pokerbot.
'''
class Bot(object):
def handle_new_game(self, new_game):
'''
Called when a new game starts. Called exactly once.
Arguments:
new_game: the pokerbots.Game object.
Returns:
Nothing.
... |
2339fdcab9d3cfedd4887d71b31b5ba094b9844d | Hallym-OpenSourceSW/HL_Contributhon | /04_Algorithm/moveZeros.py | 722 | 3.6875 | 4 | """
배열을 입력 받아서 배열내에 있는 "0" 들을 모두 뒷부분으로 옮기는 알고리즘을 만들어 보세요!
단, 배열내에 "0"이 아닌 요소들의 순서는 지켜져야 합니다.
moveZeros(["false", 1, 0, 1, 2, 0, 1, 3, "a"])
returns => ["false", 1, 1, 2, 1, 3, "a", 0, 0]
"""
def moveZeros(array):
result = []
zeros = 0
for num in array:
if str(num).isdigit():
i... |
d608654928ecc802b8eec01a2556c2852fafd2ca | IBRAHIMDANS/TeachMePythonLikeIm5 | /loops/for-loops.py | 1,460 | 4.6875 | 5 | # ------------------------------------------------------------------------------------
# Tutorial: For-loops in Python
# ------------------------------------------------------------------------------------
# We use for loops when we have to access elements in a DS or while working within a range of numbers.
# One of t... |
4d596c67482d841a01d1c3cb947dd9d1b8cf2c4a | xxcocoymlxx/Study-Notes | /CSC108/labs/lab5_handouts/lab5.py | 91 | 3.78125 | 4 | def every_third(lst):
for i in range(len(lst)-1):
i += 3
return lst[i]
|
17046cd3ca794f9cabee660af1d45bb58f7f157e | Noya-santiago/Python-crash-course | /1- Variables and data type/Variables and Data type.py | 994 | 4.34375 | 4 | print("There once was a man named John")
print("he was 35 years old.")
print("He really liked the name John, ")
print("but didnt like being 35")
""" Basically there are several types of variables in python. Booleans, Strings, Floats, etc.
We can call any variables as the name we want to. Just by typping Variable... |
9a56ffd0963cd4be42f3c4111ae87c43d0c3a135 | TiffanyNicole919/python_week_one | /for_loop_basic1.py | 1,172 | 4.03125 | 4 | # Basic - Print all integers from 0 to 150.
# for a in range(0,151) :
# print(a)
# Print all the multiples of 5 from 5 to 1,000
# for number in range(5,1001) :
#if number % 5 == 0 :
#print (number)
#Print integers 1 to 100. If divisible by 5, print "Coding" instead. If divisible by 10, print "Coding Dojo".
#for x in... |
10af638db6cea5cf97b28463a81b3d1266b71f52 | nameera0408/Practical-introduction-to-python_Brainheinold | /ch6_3sol.py | 440 | 3.75 | 4 | def check(obj,lst):
d={'(':')','{':'}','[':']'}
for item in lst:
if( item == '(' or item == '{' or item == '[' ):
Stk.push(item)
elif( item == ')' or item == '}' or item == ']' ):
value = Stk.pop()
if d[value] != item :
return 'Not Balanced'
... |
9a41aa7bb0756d09211df19618e286426e456931 | bsivavenu/Machine-Learning | /pythonprograms/compare_arrays.py | 536 | 3.890625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Feb 27 12:03:57 2018
@author: HP
"""
def compare(a1,a2):
if len(a1)==len(a2):
if set(a1)==set(a2):
return print("they are same")
else:
return print("arrays are not same")
a1 = [1,2,3]
a2 = [3,1,2,4]
compare(a1,a2)
def compare(a1,a2):
... |
927c594a8e63c578a56156b6a9c16c84e23bbf82 | Triple-Z/Python-Crash-Course | /C11/11.1.py | 729 | 3.5625 | 4 | # 11-1
# import unittest
# from C11.city_functions import city_country
#
#
# class CityTestCase(unittest.TestCase):
#
# def test_city_country(self):
# output = city_country('santiago', 'chile')
# self.assertEqual(output, 'Santiago, Chile')
#
# unittest.main()
# 11-2
import unittest
from C11.city_f... |
be2c78ad36ad09cc30f922c96a155ef219fef232 | joelambert1/package_delivery | /distance.py | 676 | 3.59375 | 4 |
class Distance:
def __init__(self, location=None, address=None, distances=None, zipcode=None):
self.location = location
self.address = address
self.distances = distances
self.zipcode = zipcode
def add_location(self, location):
location = location.lstrip().rstrip()
... |
3dc8971af1ece90efd940995797e8bf6b3157bcc | AnthonyH93/CarScraper | /scripts/car_scraping.py | 10,570 | 3.828125 | 4 | # Function: Scrape Wikipedia for information about a specific car
# Author: Anthony Hopkins
# Year: 2021
import requests
from bs4 import BeautifulSoup
from .models.car import Car
from random import randrange
import time
import re
headers = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': ... |
442c91a2690794ed11eef3aec20738a0b002e305 | Tedford/Exercism | /python/black-jack/black_jack.py | 2,596 | 4.59375 | 5 | """Functions to help play and score a game of blackjack.
How to play blackjack: https://bicyclecards.com/how-to-play/blackjack/
"Standard" playing cards: https://en.wikipedia.org/wiki/Standard_52-card_deck
"""
CARD_VALUES = {
"1": 1,
"2": 2,
"3": 3,
"4": 4,
"5": 5,
"6": 6,
"7": 7,
"... |
6b33165a30d50d68a7ac087a9388ea6c334436be | simplymanas/python-learning | /PrimeNumber.py | 360 | 4.25 | 4 |
# 7th july 2020
# Manas Dash
# else with for loop
# the below else: belongs to the for loop
# for loop’s else clause runs when no break occurs
# Prime number test
for n in range(2, 8):
for x in range(2, n):
if n % x == 0:
print (n, ' = ', x, '*', n // x, ', hence', n, 'is not prime')
break
else:
# no fact... |
facf974ae105fe8b8b8cfe7de3d735d6a2aed5c3 | aravs16/DSA | /Heaps/PriorityQueue.py | 1,345 | 3.734375 | 4 | def max_heapify(A,node_idx,heap_max_idx):
left = 2*node_idx+1
right = 2*node_idx+2
largest = node_idx
if left <= heap_max_idx and A[left] > A[node_idx]:
largest = left
if right <= heap_max_idx and A[right] > A[largest]:
largest = right
if largest != node_idx:
A[node_idx],A[largest]= A[largest],A[node_... |
0e6944c219b2a2169ae2da42a71a75fa36da1be0 | AlexDuo/Pyreview | /components/listgeneator.py | 457 | 3.578125 | 4 | # print([i*2 for i in range(10)])
# #下面的就是生成器
# b= (i+1 for i in range(10000000))
#
#
# for i in b:
# print(i)
def fib(max):
n,a,b=0,0,1
while n<max:
yield b
a,b=b,a+b
n+=1
userinput = int(input('please input the lenght you want to generate'))
f = fib(userinput)
while True:
... |
5737e828b22ff155fec40db55eb0204996656eef | marcegeek/frro-soporte-2018-06 | /practico_02/ejercicio_03.py | 1,409 | 3.703125 | 4 | # Implementar la clase Persona que cumpla las siguientes condiciones:
# Atributos:
# - nombre.
# - edad.
# - sexo (H hombre, M mujer).
# - peso.
# - altura.
# Métodos:
# - es_mayor_edad(): indica si es mayor de edad, devuelve un booleano.
# - print_data(): imprime por pantalla toda la información del objeto.
# - genera... |
655c1bb56303c8ac6444e4757f108fa5c4b6955a | davidkowalk/UkGov-Company-Harvest | /src/csvhandler.py | 871 | 3.578125 | 4 | import csv
def combine_lists(names, creds):
combined_list = [["Search Name", "Region", "Found Name", "Website"]]
empty_list = [["Search Name", "Region"]]
print(names)
print(creds)
for i in range(len(names)):
cred_list = creds[i]
if len(cred_list) == 0:
name = names[i][... |
fb546d39df90cb86dcf4f16c9f7cda2ffe2fd2e6 | acch2016/pythonCanopy | /p4.py | 985 | 3.671875 | 4 | # -*- coding: utf-8 -*-
"""
Éditeur de Spyder
Ceci est un script temporaire.
"""
from scipy import * #módulos de optimización, algebra lineal, integración,
#interpolación
from numpy import * #manejo de arreglos y operaciones entre ellos
from sympy import * #es para variables simbólicas
from math imp... |
253742af62a5483f6ecfdd9cc06455058c9ee545 | codeartisanacademy/wednesday-python | /numbers.py | 452 | 3.90625 | 4 | x = 20 # integer, whole number
y = 10
z = 2.50 # float
print(type(z))
print(type(x))
print(x + y)
result = x - y
print(result)
division = x/y
print(type(division))
print(x * y)
print(x % y)
print(19 % 4) # module does divide the number and give you the remainder in return
print(20 / (5 * 2))
a = "2"
b = "3"... |
6a5bb8973e356a93ca891b137e49ae83cf26e262 | 1339475125/algorithms | /get_index_of_num_list.py | 221 | 3.6875 | 4 | """
数字序列中的某一位数字
"""
def get_index_num(str, n):
if n < 0:
return -1
for k, s in enumerate(str):
if k == n:
return s
print(get_index_num("1231414141414", 3)) |
a1888350a61a9316678f2d05c3289042563595cb | hanggun/leetcode | /20200521_countSquares.py | 1,697 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu May 21 17:43:18 2020
@author: Administrator
"""
import numpy as np
class Solution(object):
def countSquares(self, matrix):
"""
Using dynamic programming. First pad 0s to the original matrix.
Second, compare the current value to top, left and top... |
4ec5d8f6beb9c608aa61d1fa37f2923a9890b848 | gpreviatti/exercicios-python | /MUNDO_01/Aula_07/Ex08.py | 256 | 4.09375 | 4 | #Escreva um programa que leia um valor em metros e o exiba convertido em centimetros e milimetros
metros = float(input('Digite um valor em metros: '))
print('O valor em metros {} tem {} centimetros e {} milimetros'.format(metros, metros*100, metros*1000))
|
d082820aef2861c4f1ca9130447f27239b2796a8 | sBsdu/MAI1103_repo | /day 2/my_file_total_water_need_zoo.py | 274 | 3.5 | 4 | # my file
water = 0
my_file = open("zoo2.CSV",'rt')
for i in my_file:
y = i.split(',')
if y[0]=='elephant':
water = water+ int(y[2])
if y[0]=='elephant':
water = water+ int(y[2])
print"total water need for elephant is =",water
|
9a0311b2be09b89844a79754f2dc9f84eb47fdce | serykhelena/sand_box | /py_algorithms/insertion_sort.py | 734 | 4.15625 | 4 | import random
import time
'''
Algorithm complexity is O(n^2)
https://tproger.ru/translations/sorting-algorithms-in-python/
'''
def insertion_sort(data):
# assume that first element is already sorted
for d in range(1, len(data)):
item_to_insert = data[d]
# index of previous element
j = d - 1
while j >=... |
98cb1e03df7cf8675840570ba4ca17f7b2ff5f8d | walkuper/walkup | /srp.py | 3,782 | 3.71875 | 4 | import random
print("歡迎來訓練拍國古拳法:猜拳!")
human_name = str(input("請輸入名號:"))
print("拍國古拳法 Beta Come 大師對上 " + human_name + " 選手!")
human_score = computer_score = 0
round_x = wb = 0
human_boxing = computer_boxing = ["scissors","paper","rock"]
def round_fight(r):
global wb
if human_score < 3 and computer_score < 3:
... |
d8110188d8451df4bf041d9923ac7f03b9bc1ac6 | kasra-najafi/Tiny-Python-Projects | /Some Exercises/6.py | 222 | 3.84375 | 4 | def f(le, he):
print((he-1)*' ' + le*'*')
for i in range(2, he):
print((he-i)*' ' + '*' + (le-2)*' ' + '*')
print(le*'*')
le = int(input('Enter length: '))
he = int(input('Enter heigth: '))
f(le, he) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.