blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
eb3d83b0bbece1e169567a4dcd64aaf6475713d6 | VincentiSean/Python-Practice | /multiplicationTable.py | 1,067 | 4.3125 | 4 | #! python3
# multiplicationTable.py - This program takes a number, N, from command line
# and creates an N x N multiplication table in an Excel sheet.
import openpyxl, sys
from openpyxl.styles import Font
wb = openpyxl.Workbook() # Create a new blank spreadsheet
sheet = wb['Sheet']
numIn = int(sys.arg... |
f2828f15c694ca5ae8bfe5cba9a5bd43ab256dc7 | aadimangla/Churn-Modelling-for-a-Bank | /Model/neural_network.py | 2,141 | 4.03125 | 4 | # Artificial Neural Networks
# Part 1 - Data Preprocessing
# Importing Libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
#Importing Dataset
dataset = pd.read_csv('Churn_Modelling.csv')
X = dataset.iloc[:, 3:13].values
y = dataset.iloc[:, 13].values
# Encoding categorical data
from skl... |
9ad4caea101d27a61c93de4c90ffca2a69fd2774 | Anish-RV/pied-piper | /tests/unit/algorithms/test_pied_piper.py | 388 | 3.578125 | 4 | """Tests for pied-piper/pied-piper.py."""
import unittest
class TestPiedPiper(unittest.TestCase):
def test_upper(self): # example of a unit test that tests for if the second argument is capitalized
self.assertEqual('foo'.upper(), 'FOO')
if __name__ == '__main__':
unittest.main()
"""//b... |
683ecd564cb7da8235ede27662d69870611e483f | dstamp1/stock-query-mongodb-v2021 | /stocks.py | 1,864 | 3.890625 | 4 | import pymongo
mongo_db_username = 'student'
mongo_db_password = 'PqyqrY2aEC22B5SB'
mongo_db_database = 'stock-prices'
## instantiate an instance of MongoClient
client = pymongo.MongoClient(f"mongodb+srv://{mongo_db_username}:{mongo_db_password}@cluster0-ya1yr.mongodb.net/{mongo_db_database}?retryWrites=true")
## co... |
4e783c391c9455c813790339864fc12e82c68d41 | ruchirbhai/Trees | /N-aryTreeLevelOrderTraversal_429.py | 2,719 | 3.90625 | 4 | # https://leetcode.com/problems/n-ary-tree-level-order-traversal/
# Given an n-ary tree, return the level order traversal of its nodes' values.
# Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples).
# Example 1:
# Input: ro... |
1729d46c2c2c7bf4ba429d046e1c25a2fe4eb7ca | Ford-z/LeetCode | /1217 玩筹码.py | 1,001 | 3.875 | 4 | #数轴上放置了一些筹码,每个筹码的位置存在数组 chips 当中。
#你可以对 任何筹码 执行下面两种操作之一(不限操作次数,0 次也可以):
#将第 i 个筹码向左或者右移动 2 个单位,代价为 0。
#将第 i 个筹码向左或者右移动 1 个单位,代价为 1。
#最开始的时候,同一位置上也可能放着两个或者更多的筹码。
#返回将所有筹码移动到同一位置(任意位置)上所需要的最小代价。
#来源:力扣(LeetCode)
#链接:https://leetcode-cn.com/problems/minimum-cost-to-move-chips-to-the-same-position
#著作权归领扣网络所有。商业转载请联系官方授权,非... |
77c0867c00771a80927f174eae3775e7ed5e889d | Theveenan/Kahoot-Python-Game-Project | /Early Versions/V4 (two player implemented).py | 12,831 | 3.921875 | 4 | #Modules are imported
import time
import random
#Functions are defined
def create_question():
try:
questionsCount=int(input("how many questions would you like to create?"))
for x in range(questionsCount):
print("")
print("now editing question",x,". all changes later on will... |
3871c0c930bb34de8731f55c632043e759fd11bc | Burlesco70/ManagerObjects | /ScaleZip.py | 2,473 | 3.515625 | 4 | '''
#####################################################################
TOPIC PYTHON OBJECT ORIENTED - ALL ACTION OBJECTS - MANAGERS - PART 3
#####################################################################
See how simple it is now to create a photo scaling class that takes advantage of the ZipProcessor fun... |
2fca0ce5cb3ab56e298c866b0d1fe161a823703f | dhanendraverma/PythonL1Assignment | /Ques9.py | 286 | 3.671875 | 4 | #!/usr/bin/python
import os
directory = str(input("Enter the directory path: "))
for (path,dir,files) in os.walk(directory):
for file in files:
filename = os.path.join(directory, file)
size = os.path.getsize(filename)
if(size==0):
print(file)
|
8355791fc0ec1e7eebfa4fdfecc9e90d5ca2f84c | ornichola/learning-new | /pythontutor-ru/08_functions/03_capitalize.py | 1,394 | 4.5625 | 5 | """
http://pythontutor.ru/lessons/functions/problems/capitalize/
Напишите функцию capitalize(), которая принимает слово из маленьких латинских букв и возвращает его же,
меняя первую букву на большую.
Например, print(capitalize('word')) должно печатать слово Word.
На вход подаётся строка, состоящая из слов, разделённых... |
fe3dbef91c1842b210ca033b532448374bb9171a | smile921/Ciss921 | /code_py/old_snippets/brute_force_d20.py | 616 | 3.59375 | 4 | # Brute Force D20 Roll Simulator
# Import random module
import random
# Create a variable with a TRUE value
rolling = True
# while rolling is true
while rolling:
# create x, a random number between 0 and 99
x = random.randint(0, 99)
# create y, a random number between 0 and 99
y = random.randint(0, 9... |
41550c2acf0c202925fbf8fb9b3523b5bce7fb2c | rue-glitch/PythonIntermediateWorkshopEmpty | /Person.py | 1,167 | 4.4375 | 4 | from datetime import date, datetime # for date
class Person:
"""
A person class
==== Attributes ====
firstname: str
lastname: str
birthdate: date YEAR, MONTH, DAY
address: str
"""
def __init__(self, firstname, lastname, birthdate, address):
"""
Initialize our cla... |
1c05fd98d8d447c4d43401bc991bb941c9e34623 | coolavy/nsf_2021 | /Homework_Week3/problem2.py | 567 | 4.3125 | 4 | month = int(input("Enter the month as a number: "))
day = int(input("Enter the date: "))
if (month == 3 and day >= 20) or month in (4, 5) or (month == 6 and day < 20):
print("It is spring.")
elif (month == 6 and day >= 20) or month in (7, 8) or (month == 9 and day < 22):
print("It is summer")
elif (month == 9 ... |
67080fdc5e82649ea9f48dd94fe5aa5b331ee504 | ahchin1996/Leecode | /21. Merge Two Sorted Lists.py | 1,065 | 4 | 4 | # Definition for singly-linked list.
class ListNode(object):
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution(object):
def mergeTwoLists(self, l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
:rtype: ListNode
"""
... |
dea906bb68de3a5a9b2e2ea9c553b3b2f60d2b7f | Leejeongbeom/basic | /4-8.py | 146 | 3.828125 | 4 | phrase = input("문자열을 입력하시오:")
acronym = ""
for word in phrase.upper().split():
acronym += word[0]
print(acronym) |
25fd0a90e1928817c6ef25c033fdfd3be79e7432 | krishnajaV/luminarPythonpgm- | /oops/inheritance/Constructor.py | 414 | 3.765625 | 4 | class Person:
def __init__(self ,name,age):
self.name = name
self.age = age
print("name=", self.name)
print("age=", self.age)
class Student(Person):
def __init__(self,mark,rollno,name,age):
super().__init__(name,age)
self.mark = mark
self.rollno =rollno
... |
540ca26c47e3fbe92ebf8bf2a395b6de1709fb90 | felipechatalov/7-Segment-Display | /7SegmentDisplay.py | 3,287 | 3.625 | 4 | import pygame
window_w, window_h = 800, 600
white = (255, 255, 255)
red = (255, 0, 0)
screen = pygame.display.set_mode((window_w, window_h))
pygame.display.set_caption("Led Display")
clock = pygame.time.Clock()
# Segments which need to be activated to display the number, in order oif segments(a, b, c, d, e, f, ... |
c5eb6a778353510cb34297e97dd33996904abb68 | cbucholtz19/Project-Euler-Solutions | /Project_Euler/problem_12.py | 550 | 3.6875 | 4 | import math
def triangle(n):
return int(((n*n)/2) + (n/2))
def numFactors(n):
factors = 0
for i in range(1,math.floor(math.sqrt(n))):
if ( (n/i).is_integer() ):
factors += 2
if ((n/n).is_integer()):
factors += 1
return factors
def firstTriangleWithNFactors(n):
test... |
f2fc5e5cb5e6476f777ae2a68179cb9c984fc84c | Mmerenz/mi_primer_proyecto | /test_imput.py | 329 | 3.921875 | 4 |
mi_numero = 10
numero_del_usuario = int(input("Adivina un numero: "))
if mi_numero == numero_del_usuario:
print("Ganaste")
else:
print("Perdiste")
mi_numero = 10
numero_del_usuario = int(input("Adivina un numero: "))
if mi_numero == numero_del_usuario:
print("Ganaste")
else:
print("Perdiste")
... |
f0d5cac9ad5eebeec6c230157ffbc17bb11be03c | zarana-nakrani/Softvan_Internship_Task | /Task2_Day7.py | 3,033 | 3.828125 | 4 | class Error(Exception):
pass
class LengthException(Error):
pass
class OneLowerCaseExceptiom(Error):
pass
class OneUpperCaseException(Error):
pass
class OneDigitException(Error):
pass
class OneSpecialCharError(Error):
pass
class LoginError(Error):
pass
class SignUp:
def __in... |
31fc32b285b135240490bebaa41083799fc95156 | zsbati/PycharmProjects | /Currency Converter2/Currency Converter/task/cconverter/cconverter.py | 990 | 3.703125 | 4 | # write your code here!
import json
import requests
user_currency = input().lower()
cache = dict() # to store the exchange rates
url = f'http://www.floatrates.com/daily/{user_currency}.json'
r = requests.get(url).json()
cache['usd'] = r.get('usd') # save the USD and EUR in the cache
cache['eur'] = r.get('eur')
whil... |
c6e636c09fbbd0d202465a930a9c7b63066e1f73 | samarthsaxena/Python3-Practices | /Practices/advanced python/ItertoolsDemo.py | 3,301 | 4.34375 | 4 | # Advanced iteration functions in the itertools module
import itertools as iter
# https://docs.python.org/3/library/itertools.html
def testFunction(x):
return x < 40
def customeLogicForAccumulate(x, y):
"""
Custm logic function for accumulate
:param x: Number
:param y: Number
:return: x +... |
824edea190c392247a3e243007039c4dddc25959 | mbaeumer/python-challenge | /block2-datatypes/date/test_age-calculator.py | 879 | 3.859375 | 4 | import unittest
import datetime
from age_calculator import calculate_age
class SumTestCase(unittest.TestCase):
def test_calculate_age_one_day_before(self):
birth_date = datetime.datetime.strptime("1981-07-23", "%Y-%m-%d")
today = datetime.datetime.strptime("2023-07-22", "%Y-%m-%d")
self.assertEqual(calcu... |
9d36f61604a99cdbf40d16476060f634d965058d | JuanPabllo/studynotes | /cursos/python/Estrutura-de-dados-em-python/numbers.py | 1,855 | 4.125 | 4 | import random
# Int
num1 = 300
num2 = -8
print(type(num1))
print(type(num2))
# Float
num3 = 300.5 # número positivo com uma casa decimal
num4 = -433.6750 # número negativo com quatro casas decimais
print(type(num3))
print(type(num4))
# Complex
num5 = 2 + 4j
num6 = 4j
num7 = -10j
print(type(num5))
print(type(num... |
1b768af3c627cce6f03b03932327e86abc371906 | Jakab90/challenges | /programming_101/unit_2/unit_2a_lesson.py | 559 | 3.78125 | 4 | # this is a basic solution using multiple inputs and variables
from typing import Sized
slithy_adj = input("Give an adjective")
gyre_noun = input("Give a noun")
gimble_noun = input("Give another noun")
mimzy_adj = input("Give another adjective")
borogoves_propernoun = input("Give a proper noun")
word_arr = [slithy_... |
929dab46999f32402183f8b3f3b6847a216c6f62 | Divisekara/Python-Codes-First-sem | /PA2/PA2 ANSWERS 2015/1/A1-1/2015 - PA2 - 19 - Weight of an object on a Planet.py | 2,082 | 3.828125 | 4 | #PA2 - 19 - Weight of an object on a Planet
def getText():
#To get text from input and check for any errors.
try:
fileOpen=open("FileIn.txt","r")
data=fileOpen.read().split()
fileOpen.close()
M=int(data.pop(0))
N=i... |
6722d77c6958167e516686b036602a6f213bdcd6 | avaiyang/Hadoop-HDFS-MapReduce | /mapper.py | 1,228 | 4.03125 | 4 |
import sys
import re
def read_input(file):
for line in file:
# here we need to remove all the special characters from the file
#for the purpose of which I am using a regular expression
line = re.sub('[^A-Za-z0-9]+', ' ', line)
# split the line into words
yield lin... |
40cb691913b6f646e004e3d88566959279dccb91 | bamshad-shrm/codingPractice | /py/class/a.py | 350 | 3.71875 | 4 | # Note: if we use import bamshadMath we will face with the error of: TypeError: 'module' object is not callable
from bamshadMath import bamshadMath
x = int(input("Enter an integer: "))
y = int(input("Enter another integer: "))
bamshadMathObj = bamshadMath()
print('The sum of ', x, ' and ', y, ' is ', bamshadMathOb... |
eec0dc7ce99ba1495f5304316a3e8e0624f3756a | Giocatory/PythonOOP | /decorator/first decorator.py | 730 | 3.6875 | 4 | def show_func(func):
def inner():
print('Start decorator')
func()
print('Stop decorator')
return inner
@show_func # say = show_func(say)
def say():
print('Hello World')
say()
# Start decorator
# Hello World
# Stop decorator
def show_func2(func):
def inner(*args, **kwargs)... |
09259aad7d1224c2ac7cb83e4c3ddb47cbd72cf9 | aulb/ToAsk | /Technical Questions/092 - Reverse Between LL.py | 487 | 3.6875 | 4 | def reverseBetween(head, m, n):
x, y = min(m, n), max(m, n)
d = y - x
i = 0
current = head
# Find starting point
for i in range(1, x):
prev = current
current = current.next
last = prev
i = 0
# From the starting point just reverse the .next to like the previous one
for i in range(d + 1... |
eb8818ff53904609d14825be9c5aa833bc789328 | madease/Ciao-World | /Week 4/AGENTORANGE.py | 1,237 | 3.703125 | 4 | from turtle import Turtle
import random
t = Turtle()
t.screen.bgcolor('black')
#t.color('orange')
t.fd(100)
def generateText(txt, font, color):
t.color(randomColor)
xpos = random.randint(-500,500)
ypos = random.randint(-500,400)
t.setpos(xpos, ypos)
t.write(txt,move=True,align="center",font=(font,30,"normal"))
... |
a3262289a989b0622b427e05cd27cd0aa5028f48 | minahabibm/Data-Structures-Algorithms | /Data Structures/Hash Tables/main.py | 4,913 | 3.90625 | 4 | '''Collision resolution techniques:
Separate chaining (open hashing)
Linear probing (open addressing or closed hashing)
*Quadratic Probing
Double hashing
'''
class HashTable:
def __init__(self, size):
self.size = size# int(input("Enter the Size of the hash table : "))
self.table = list(0 for i in range(self.s... |
6b1968cd00bec5b2a944c0f2e1a05bad3df6085c | suvrajitkarmaker/python | /data structure/stack.py | 949 | 3.875 | 4 | class Stack:
def __init__(self):
self.stack = []
self.top = 0
self.stackSize = 1000000
def push(self, value):
if(self.stackSize == self.top):
print("Stack is full")
else:
self.stack.append(value)
self.top = self.top + 1
de... |
ac67dc14fa60ec3fc7b82c3c58dc66a8630493fb | vegeta008/FundamentosP | /Ejercicio1.py | 552 | 4.03125 | 4 | #1.Calcular el valor a pagar de una compra realizada, cuyo monto neto es ingresado por el usuario. Considere que el valor del IVA
#(Impuesto al Valor Agregado- puede variar en cada país), y un descuento del 5% para todas las compras.
# -*- coding: utf-8 -*-
"""
@author: aorozco@dragonjar.org
"""
Valor_Compra... |
4aebef57aff30af6fae636882f5102c81d704a5f | fbokovikov/leetcode | /solutions/longset_palyndrom.py | 1,072 | 3.765625 | 4 | class Solution:
def longestPalindrome(self, s: str) -> str:
max_length, length = 0, len(s)
start_pos, end_pos = 0, 0
for cur_pos in range(length):
len1 = self.expandAroundCenter(s, cur_pos, cur_pos)
len2 = self.expandAroundCenter(s, cur_pos, cur_pos + 1)
c... |
d25a4324863b8da5d210b3e655fe9bae072a77a4 | guilhermeleobas/maratona | /leetcode/14.py | 425 | 3.546875 | 4 | class Solution:
def longestCommonPrefix(self, strs: List[str]) -> str:
sol = ""
j = 0
word = strs[0]
for i in range(0, len(word)):
for j in range(1, len(strs)):
other = strs[j]
if i >= len(other):
return sol
... |
a3ceed91cd041af6743133cd050e11229d7fbc26 | deasymaharani/Grok-Learning | /C7-ITERATION/while loop.py | 456 | 4.09375 | 4 | def mul_table(num,N):
n=0
while n<N:
result = (n+1)*num
print_result = str(n+1) + " * " + str(num)+ " = "+ str(result)
n = n+1
print(print_result)
num=input("Enter the number for 'num': ")
N=input("Enter the number for 'N': ")
if not num.isdigit() or not N.isdigit()... |
f0fa038818368170069ddc6f7d88753a4d422efb | Neeraj-kaushik/Geeksforgeeks | /Array/Find_Triplet_With_Zer_Sum.py | 322 | 3.65625 | 4 | def find_triplet(li, n):
count = 0
for i in range(len(li)-2):
for j in range(i+1, len(li)-1):
for k in range(j+1, len(li)):
if li[i]+li[j]+li[k] == 0:
count += 1
print(count)
n = int(input())
li = [int(x) for x in input().split()]
find_triplet(li, n... |
1ad46942d6c22cd688dc53237ecb559b814e3309 | edu-athensoft/stem1401python_student | /py200325_python1/py200529/stem1401_python_homework_quiz10_Kevin.py | 1,394 | 4.21875 | 4 | """
Quiz 10 and homework
"""
# Question 3. A class of student just look a midterm exam on French course.
# Please figure out the average of this class. And how many students got A.
# s is score, and s is student
s_s = [
("Marie", 85),
("Phoebe", 78),
("Sabrina", 96),
("Emma", 85),
("Amy", 73),
... |
8e31bd87be6a78e4a13eb30b53563e0f28d2b38d | jmfrank63/text-catalog | /model.py | 2,561 | 3.796875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
The database model
'''
from app import db
class Language(db.Model):
'''
This table stores the language name
'''
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String, unique=True, nullable=False)
def __init__(self, name):
... |
703e7ae67d44db0314ce45c4d7c4ad605870351c | clumsy-k/memorandom_python | /function_zip.py | 296 | 3.6875 | 4 | #! /usr/bin/env python
# encoding:utf-8
# 要素10のlistを2つ作成
List1 = []
List2 = []
for i in xrange(10):
List1.append(i)
List2.append(i)
List2.reverse()
Last_list = []
for (a, b) in zip(List1, List2):
print a, b
elm = a + b
Last_list.append(elm)
print Last_list
|
4a94782b19e24504297ea7aef2749f52cedcf721 | dxmahata/codinginterviews | /leetcode/3Sum.py | 1,533 | 3.671875 | 4 | """Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
Note: The solution set must not contain duplicate triplets.
For example, given array S = [-1, 0, 1, 2, -1, -4],
A solution set is:
[
[-1, 0, 1],
[-1, -1, ... |
7ad26bd897c8627fc8fb22e4f82144f947b97fa7 | anasssaghir/mundiapolis-math | /math/0x01-plotting/6-bars.py | 546 | 3.65625 | 4 | #!/usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(5)
fruit = np.random.randint(0, 20, (4, 3))
names = ['Farrah', 'Fred', 'Felicia']
fs = ['apples', 'bananas', 'oranges', 'peaches']
colors = ['red', 'yellow', '#ff8000', '#ffe5b4']
for i in range(len(fruit)):
plt.bar(names, f... |
f9d66fd14799109c00a92a392aa5c42ea8d341b5 | daniel-reich/turbo-robot | /tfbKAYwHq2ot2FK3i_21.py | 734 | 4.1875 | 4 | """
Let's define a non-repeating integer as one whose digits are all distinct.
97653 is non-repeating while 97252 is not (it has two 2's). Among the binary
numbers, there are only two positive non-repeating integers: 1 and 10. Ternary
(base 3) has ten: 1, 2, 10, 20, 12, 21, 102, 201, 120, 210.
Write a function that... |
22e896c8f47fd3edd568ac59d276b52493bad8e8 | payamgerami/algorithm-and-data-structure | /src/lists/Numeric Palindromes.py | 687 | 4.15625 | 4 | # A palindrome is a word or a phrase or a number, that when reversed, stays the same.
# For example, the following sequences are palindromes : "azobi4amma4iboza" or "anna".
# But this time, we are not interested in words but numbers. A "number palindrome" is a number, that taken backwards, remains the same.
# For examp... |
eaffa32155cd678cc74e4a2ce02d7b667908a50c | aseeth/first_repo | /palindrom.py | 274 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
n = int(input("enter any num:"))
m = n
rev = 0
while n>0:
dig = n%10
rev = rev *10+dig
n = n//10
if m == rev:
print("this is the palindrom")
else:
print("not a palindrom")
|
b7ccb2dc2eeebdd4219d89ab3a6832780add3dd0 | asharilabs/PelatihanKemenpora | /harikedua.py | 239 | 3.640625 | 4 | # bilangan = input('input bilangan: ')
# for i in range(int(bilangan) + 1):
# if i != 0:
# print('Hitung %d' %i)
# x = 3
# y = 3
# a = [1,2,3]
# b = [1,2,3]
# print( x is y)
# print(x is x)
# print([1,2,3] == [1,2,3])
# print ('123 ->' + (a is b))
lst = [1,2,3,4,5,['a','b','c','d']]
for x in lst:
... |
3a343b95f80f846efe74573fda6784b7400ccbcd | Environmental-Informatics/building-more-complex-programs-with-python-SteveTsui1361 | /xu1361_program_4.2.py | 1,006 | 4.375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 31 14:11:38 2020
This code is used to draw flowers as mentioned in the Exercise(Think Python)
@author: xu1361
"""
# import necessary modules
import turtle
import math
bob = turtle.Turtle()
# draw the circles
def arc(t, r, angle):
arc_length = 2... |
b5a991801e8e8828449e83be5c6b1af44aca457b | rodyns2001/crimtech-comp-f21 | /python/random_ints.py | 458 | 3.53125 | 4 | import random
def random_ints():
# Write your code here!
l = []
return l
def test():
N = 10000
total_length = 0
for i in range(N):
l = random_ints()
assert not 0 in l
assert not 11 in l
assert l[-1] == 7
total_length += len(l)
assert abs(total_length... |
1b9a85d530d1ea3abb650e8877a44870608256b7 | RenanRibeiroDaSilva/Meu-Aprendizado-Python | /Exercicios/Ex011.py | 699 | 4 | 4 | """Ex 011 - Faça um programa que leia a largura e a altura de uma parede em metros, calcule sua área
e a quantidade de tinta necessaria para pinta-la, sabendo que cada litro de tinta pinta uma área de
2m²."""
print('-' * 10, '>Ex 011,', '-' * 10)
#Criando variaveis e recebendo dados.
par_alt = float(input('Qual a alt... |
daf3a11b90138b689481a2ed9a9b7dc9219fe7d5 | rafaelperazzo/programacao-web | /moodledata/vpl_data/197/usersdata/274/78744/submittedfiles/atividade.py | 242 | 3.75 | 4 | # -*- coding: utf-8 -*-
import math
n = int(input("Digete n: "))
i = 1
while i<n:
x = float(input("Digite x: "))
y = float(input("digite y: "))
if x>0 and y>0 and (x*x+x*y) <=1 :
print("SIM")
else:
print("NAO") |
538693ff27cf980a4efa15e766ffae9ca1a89d4d | nikesh610/Guvi_Codes | /Beginner_Set2_3.py | 101 | 3.78125 | 4 | vow=['a','e','i','o','u']
x=input()
if(vow.count(x)==1):
print("Vowel")
else:
print("Consonant")
|
85a64f86e39d2b3608dec78588a7b8ea06d39b53 | vishruth-v/Social-Network- | /Graph.py | 6,867 | 3.765625 | 4 | class Graph:
def __init__(self, nodes, names):
self.adjlist = [[] for i in range(nodes)]
self.indexes = {i:j for i,j in zip(names, range(nodes))}
self.V = nodes #V is th number of nodes present in the graph
self.cycle = []
def disp_adjlist(self):
print(self.a... |
9ff630b1b3e042fc3cf17c7d24793bc0e4b35310 | alberto-re/aoc2020 | /day04.py | 1,612 | 3.59375 | 4 | #!/usr/bin/env python3
# --- Day 4: Passport Processing ---
import re
def extract_passports(lines):
passports = [{}]
for line in lines:
if line:
for field in line.split():
key, value = field.split(":")
passports[-1][key] = value
else:
p... |
66fdd352325fc33d2b03f6521d05c54e7a8da197 | Georgieboy68/ICTPRG-Python | /addingnonx.py | 305 | 4.21875 | 4 | #Write a program that keeps asking the user for a number, and adds it to a total.
# Ensure that pressing x stops entering numbers.
# Example:
firstnum=input("Enter Number: ")
sum=0
while firstnum != "x":
sum=sum+int(firstnum)
firstnum=input("Enter Number: ")
print("Total: ",sum)
|
99a8b7c9e169c55220549c3b0ff8be49ef8b0108 | b0sst0p/DinhTienHoang-Dataforeveryone-D12 | /Session3/menu.py | 1,401 | 3.609375 | 4 | name ='trung ran'
name1 = 'bap'
name2 = "bo"
name3 = 'mo'
name4 = 'mam tom'
name10= 'ca ran'
#list, array: dữ liệu kiểu danh sách, mảng. dữ liệu bthg kiểu int, string chỉ tạ ra lệnh print số hoặc chữ. nhg dữ liệu list có thể in được cả 2.
mon_an = ['trung ran','bap','mo','bo','mam tom'] #buoc khoi tao(i: initialize)
pr... |
9c85bedfa0dbd1d1e38cf4eaa2fbcac915040209 | zs930831/Practice | /招聘的在线编程/华为机试/质数分解.py | 327 | 3.53125 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
a = int(input())
def qiuzhishu(x):
iszhi = 1
for i in range(2, int(x ** 0.5 + 2)):
if x % i == 0:
iszhi = 0
print(str(i), end=" ")
qiuzhishu(x // i)
break
if iszhi == 1:
print(str(x), end=" ")
qiuzh... |
a3ec713d6e5d037ef39d92174566551d725cf48b | l-damyanov/Python-Advanced---January-2021 | /02-Tuples-and-Sets-Exercise/unique_usernames.py | 147 | 3.625 | 4 | n = int(input())
usernames = set()
for el in range(n):
user = input()
usernames.add(user)
for username in usernames:
print(username)
|
d5cb598d8ac769febd2232db224a9461787d5aac | wisdom2018/PythonLearning | /SodaDrinkBottleExchange/python/sodaDrinkBottleExchange.py | 1,214 | 3.625 | 4 | #! /usr/bin/env python
# -*- coding:utf-8 -*-
# @Time : 2020/11/30 5:07 PM
# @Author: zhangzhihui.wisdom
# @File:sodaDrinkBottleExchange.py
import sys
from selenium import webdriver
def sodaDrinkBottleExchange(bottlesNumber):
result = 0
if bottlesNumber == 0:
result = 0
while bottlesNumber != 0:
... |
a4edfa7c702d84ddb796edd46b3c1340a4a4fa79 | christinenyries/madlibs | /template/night_circus.py | 1,078 | 3.59375 | 4 | def madlib():
noun1 = input("Noun1: ")
verb1 = input("Verb1: ")
place1 = input("Place1: ")
place2 = input("Place2: ")
noun2 = input("Noun2: ")
adj = input("Adjective: ")
noun3 = input("Noun3: ")
noun4 = input("Noun4: ")
noun5 = input("Noun5: ")
color = input("Color: ")
madli... |
2559c10a8826a61b734796471b15eb0ee5984723 | vinodhkrishnaraju/python_coding | /algorithms/reverse_words.py | 487 | 3.921875 | 4 | def reverse_words_in_list(words_list):
reverse_words = []
words = []
for letters in words_list:
if letters == '':
reverse_words += [''.join(words)]
words = []
continue
words += letters
reverse_words += [''.join(words)]
reverse_words1 = []
... |
c41587d25fb56b28e3db967a43c151467eb35302 | monjurul003/algorithm-problems | /rat_in_a_maze.py | 1,342 | 4.09375 | 4 | # Rat in a maze problem. Given a Grid of size n*n, rat starts from (0,0) and has to reach (N-1, N-1). Find out if
# such a path exists and print that path. Note that there might be blockades in the maze (designated by 0).
def is_safe(maze, x, y, N):
if x >= 0 and x <= N-1 and y >= 0 and y <= N-1 and maze[x][y] ==... |
7f8a9128e6a927b0ca893ca1a5eb152e61a40fd1 | dashanhust/leetcode | /algorithm/108_convert_sorted_array_to_binary_search_tree.py | 2,862 | 3.96875 | 4 | """
题目:将一个按照升序排列的有序数组,转换为一棵高度平衡二叉搜索树。
本题中,一个高度平衡二叉树是指一个二叉树每个节点 的左右两个子树的高度差的绝对值不超过 1。
示例:
给定有序数组: [-10,-3,0,5,9],
一个可能的答案是:[0,-3,9,-10,null,5],它可以表示下面这个高度平衡二叉搜索树:
0
/ \
-3 9
/ /
-10 5
二叉搜索树(Binary Search Tree(BST))又称为二叉查找树或二叉排序树,它或者是一棵空树,或者是具有如下性质的二叉树:
1. 若它的左子树不空,则左子树上所有节点的值均小于它的根节点的值;
2. 若... |
676edbfe3cf6081ab18cd0a47fc269a350156950 | hackpsu-tech/hackPSUS2018-rfid | /test_programs/readConfig.py | 385 | 3.890625 | 4 | #!/usr/bin/python
"""
This application simply reads a config file created by the HackPSUconfig module and prints the output to the console
"""
import HackPSUconfig as config
configFile = input('Please enter the name of a configuration file: ')
dict = config.getProperties(configFile)
print('Dictionary:')
for key in d... |
4405ad549385390f53647c809d36cdfe5e066538 | kriskowal/planes | /python/text/indent/column.py | 1,883 | 3.515625 | 4 |
# 2004-08-07 by Kris Kowal
from tab_length import tab_length
from next_tab import next_tab
def column(line, column = 0, tab_length = tab_length):
"""
returns the |column| offset that the cursor would end on if this
|line| were printed out on a perfect terminal, starting at |column|,
... |
0261e7039beaa4f2c339a6f8175e87c11732bafe | sureshallaboyina1001/python | /Functions/primeFunction.py | 288 | 4.09375 | 4 | def prime(num):
if num>1:
for i in range(2,num):
if num%2==0:
print(num,"is not prime no")
break
else:
print(num,"is a prime no")
num= int(input("enter the number:"))
prime(num)
|
31a694a567a7145f37974b5c8b4b75b317b9d7f1 | SeanyDcode/codechallenges | /dailychallenge734.py | 1,128 | 3.921875 | 4 | # from dailycodingproblem.com
#
# Daily Challenge #734
# Write a map implementation with a get function that lets you retrieve the value of a key at a particular time.
#
# It should contain the following methods:
#
# set(key, value, time): sets key to value for t = time.
# get(key, time): gets the key at t = time.
# Th... |
8530157b0a414907aef3ea8c555c33a9de6e2000 | aambrioso1/NLP | /NLTK/word_vec_view.py | 1,995 | 3.53125 | 4 | # Found here: https://www.kaggle.com/alvations/word2vec-embedding-using-gensim-and-nltk
# Some basic operation with word2vec and gensim.
import gensim
from nltk.data import find
word2vec_sample = str(find('models/word2vec_sample/pruned.word2vec.txt'))
model = gensim.models.KeyedVectors.load_word2vec_format(word2vec_s... |
71654413eafa0d90df557b1099ecc097a694e306 | robertrebnor/DataScience_Visualization | /InitializeData.py | 2,589 | 4.1875 | 4 | #########################################################
### ###
### Initialize Data ###
### ###
#########################################################
"""Overvi... |
4ac3d560b3beda9744f7ddcb9e7c4a36fc0ae8d3 | vanrein/perpetuum | /compiler/pntools/petrinet.py | 13,422 | 3.578125 | 4 | #!/usr/bin/python3
# -*- coding_ utf-8 -*-
""" This program implements a parser and data structure for Petri net files.
This program implements an XML parser and a python data structure for
Petri nets/PNML created with VipTool or MoPeBs.
"""
import sys # argv for test file path
import xml.etree.ElementTree as ET # X... |
103942d6f4f22fbfe60b9f1ae03c38b4d41fcf55 | salma27/pygame | /salma 12.py | 1,799 | 3.78125 | 4 | game =['a','f','g','a','b','w','c','m','b','d','l','g','w','l','e','f','e','c','g','m']
no=['1','2','3','4','5','6','7','8','9','0','1','2','3','4','5','6','7','8','9','0']
s=no
j=0
i=0
k=0
print("welcome to the memory game\n")
print(no)
while(True):
if j%2==0:
print("player 1 : it's your turn\n")... |
5d102cc424620eea7d9d06f28945421eb55ae479 | haraldfw/pyprog | /scripts/oving02/functions.py | 252 | 3.859375 | 4 | def celsius_far(celsius):
return celsius * (9.0 / 5.0) + 32 # must have decimals to prevent int-calc flooring
valIn = input('Enter celsius value to be converted: ')
print str(valIn) + ' degrees celsius in fahrenheit: ' + str(celsius_far(valIn))
|
c3fbe0e9cc18c44f79296a74d07e2789ee57bd11 | Lavenda/myPythonCastle | /src/myLibs/myThread/threadqueue/myCommand.py | 1,976 | 3.734375 | 4 | #!/usr/bin/env python2.6
#-*- coding: utf-8 -*-
"""
Created on 2013-5-1
@author: lavenda
"""
class MyCommand(object):
"""
This class is uesd to package all kinds of method objects, likes a data transfer object.
"""
def __init__(self):
self.methodObject = None
self.lock = obje... |
edfb9cba3770b70e3cd8d998d0f49c9a61cd0cbb | Helper2020/LRU-Cache | /problem_1.py | 4,996 | 4.46875 | 4 | class Node:
'''
Node class is used to encapsulate a key and a value.
'''
def __init__(self, key, value):
self.key = key
self.value = value
self.next = None
self.prev = None
class Doubly_linked_list:
'''
This double linked list tracks the usage ord... |
f6c402fc8a7f5c3e8cc066d170986fb7e3e62ec3 | vbsilva/Algoritimos_2016.1 | /Exemplo_Python/ex.py | 250 | 3.53125 | 4 | class MyClass():
def __init__(self):
self._nome = ""
def setNome(self, nome):
self._nome = nome;
def getNome(self):
return self._nome
def main():
x = MyClass()
x.setNome("olar mundo!")
print(x.getNome())
if __name__ == "__main__":
main() |
172cf9b041c49df1d0230bd8b794b0179ece6386 | enriqueee99/learning_python | /ejercicio_15.2.py | 814 | 4.0625 | 4 | empleados = []
faltas = []
for x in range(3):
nombres = input('Nombre del empleado: ')
empleados.append(nombres)
dias = int(input('Cuantos dias faltó?: '))
faltas.append([])
for y in range(dias):
dia = int(input('Qué dias faltó?: '))
faltas[x].append(dia)
print('Empleados y los dia... |
370c04ddc8b29fcad7ff7eaf41c4bd916b9b61c3 | zbrtech/matplotlib_study | /random_walk.py | 1,778 | 4.46875 | 4 | from random import choice #this is file 11
class RandomWalk(): #one class to randomly and autoly create walk steps
#this class contain 2 funtions and 3 properties
def __init__(self,num_points=5000): #1 of 2 functions of this class. to send steps arguments to this class itself. ... |
e40d0ae8d7dd1c8799f4d36e81e27ee7497ebea1 | ssmore88/effective-meme | /GuessMyNumber.py | 550 | 3.984375 | 4 | import random
number = random.randint(1,40)
tries = input()
tries = int(tries)
print ("You have 5 guesses to find my number otherwise you lose")
while tries < 5:
answer = int(input("Please enter a number between 1 and 40:"))
if answer == number:
break
if answer > number:
print ("Choose a n... |
870282e27827d3a4662b293db1d40345fca520de | danagle/boggled | /src/boggled/boggle_words.py | 6,118 | 3.90625 | 4 | # boggle_words.py
"""
Library for building a word dictionary including prefixes for Boggle.
"""
from collections import UserDict
from re import sub
class NoneFieldDict(UserDict):
"""
This dict subclass returns a None type instead of raising a KeyError.
"""
def __missing__(self, key):
"Returns... |
63ae78075db5316ba31b75d1405af70b043f28fb | Tom-Petty98/PythonExercises | /Challenges/Code/DC3.py | 483 | 4.28125 | 4 | # Write a program that accepts a comma separated sequence of words as input and prints the words in a comma-separated
# sequence after sorting them alphabetically.
# (without,hello,bag,world) -> bag,hello,without,world
def sort_words(s1):
a = s1.split(',')
a.sort()
s2 = ""
for i in range(len(a)):
... |
56ef8d34f3b107ce9f52867d96dac289520b0621 | aguscoppe/ejercicios-python | /TP_9_Matrices/TP3_EJ4.py | 1,972 | 3.859375 | 4 | import random
def crearMatriz():
n = int(input("Ingrese la cantidad de fábricas: "))
filas = n
columnas = 6
matriz = [[0] * columnas for i in range(filas)]
return matriz
def rellenarMatriz(matriz):
filas = len(matriz)
columnas = len(matriz[0])
for f in range(filas):
... |
eb31f2d88a7420acec20ecb80a8be7e7e245441a | sandeep-singh-79/DSAlgo | /src/GFG/07-peakElement.py | 2,065 | 4.21875 | 4 | """ A peak element in an array is the one that is not smaller than its neighbours.
Given an array arr[] of size N, find the index of any one of its peak elements.
Note: The generated output will always be 1 if the index that you return is correct. Otherwise output will be 0.
Example 1:
Input:
N = 3
arr[] = {1,2,3}
... |
0fa31538db9bb28e6a4e7b518059509db9250dbe | iamwillcode/PumpBot | /trading/BasicInvestmentStrategy.py | 915 | 3.625 | 4 | """
An investment strategy in which the funds that are invested are based on
a predefined fraction.
"""
from trading.InvestmentStrategy import InvestmentStrategy
from wallet.Wallet import Wallet
class BasicInvestmentStrategy(InvestmentStrategy):
investmentFraction: float
def __init__(self, investmentFraction... |
b3fb958a829b855b9905f4317784cc44c1aab5f4 | s-hiiragi/atcoder-study | /arc001_3/main.py | 1,335 | 3.53125 | 4 | # https://atcoder.jp/contests/arc001/tasks/arc001_3
# 斜めもダメということを忘れていた
import io
s1 = '''\
........
........
.......Q
........
..Q.....
........
.Q......
........
'''
s2 = '''\
.....Q..
.Q......
........
........
........
Q.......
........
........
'''
s = s2
c = []
with io.StringIO... |
c413df07b9d92cc0abcfe9aef1aad0d68e21e418 | artsR/Automate-the-Boring-Stuff-with-Python | /Chapter 10/Chapter 10 - Debugger.py | 5,327 | 4.125 | 4 | ############ CHAPTER 10 #############
def boxPrint(symbol, width, height):
if len(symbol) != 1:
raise Exception('Symbol must be a single character string.')
if width <= 2:
raise Exception('Width must be greater than 2.')
if height <= 2:
raise Exception('Height must be greate... |
4a566fc5c894468882d255267ccefd94b8e15295 | dungtutb/algorithm_pttkgt | /insertion_sort.py | 265 | 3.953125 | 4 | def insertion_sort(ds):
for i in range(len(ds)):
cur_value = ds[i];
j = i-1;
while j>=0 and ds[j]>cur_value:
ds[j+1]=ds[j]
j=j-1
ds[j+1]=cur_value
ds = [9,4,8,1,5,7,3,6,2]
insertion_sort(ds)
print ds
|
126f0859ae16160a7e2316876fb02fc21938b0d1 | beOk91/code_up | /code_up1718.py | 202 | 3.671875 | 4 | text=input()
whereH=text.index("H")
if text[whereH-1]=="C":
c_val=1
else:
c_val=int(text[1:whereH])
if len(text)-1==whereH:
h_val=1
else:
h_val=int(text[whereH+1:])
print(c_val*12+h_val) |
1f48bfbad0a7b2bfe17eb07780a43177a492f798 | DanielPramatarov/Penetration-Testing-Tools | /Python/PythonNmap/PyMap.py | 3,223 | 3.8125 | 4 |
import nmap
while True:
print("""\nWhat do you want to do?\n
1 - Get detailed info about a device
2 - Scan IP for open ports with stealth scan
e - Exit the application""")
user_input = input("\nEnter your option: ")
print()
ip = input("\nPlease enter ... |
cf1e65f9972ed22345dcdb7362ea0af992b089d5 | text007/learngit | /5.字符串/字符串内建函数/35.title()方法.py | 258 | 3.75 | 4 |
# title()方法:返回"标题化"的字符串,就是说所有单词的首个字母转化为大写,其余字母均为小写
# 注意,非字母后的第一个字母将转换为大写字母
str45 = "this is hello b2b2b2 and 3g3g3g!!!"
print(str45.title())
|
46ece28d1f110e4aee7e64ec39a494e397f30cdd | AtilioA/Python-20191 | /lista7jordana/Ex055.py | 2,285 | 3.765625 | 4 | # Faça um programa que percorre uma lista com o seguinte formato:
# [['Brasil', 'Italia', [10, 9]], ['Brasil', 'Espanha', [5, 7]], ['Italia', 'Espanha', [7,8]]]
# e imprima na tela algumas# informações.
# Essa lista indica o número de faltas que cada time fez em cada jogo.
# Na lista acima, no jogo entre Brasil e Itáli... |
664b7ff2c325bb21b55b99e44dfbc441c0407586 | Daniyar-Yerbolat/university-projects | /year 2/semester 1/programming languages/labs/question H - Daniyar Nazarbayev [H00204990].py | 4,287 | 3.78125 | 4 | # Daniyar Nazarbayev, H00204990.
# exercise H #1
def mult1 (list_num):
x = 0
total = 1
while (x<len(list_num)):
total = total * list_num[x]
x = x + 1
return total
# exercise H #2
def mult2 (list_num):
if len(list_num)==0:
return 1
else:
return list_num.pop() *... |
e6868adf0854fae59f07515b2ac384fef30d945f | alenaks/OSTIA | /code/helper.py | 789 | 3.953125 | 4 | def prefix(w):
''' Returns a list os prefixes of a word. '''
return [w[:i] for i in range(len(w)+1)]
def lcp(*args):
''' Finds longest common prefix of unbounded number of strings strings. '''
w = list(set(i for i in args if i != "*"))
if not w: raise IndexError("At least one non-unknow... |
e7cb56a91eb062c0fd7d55e1cf5cf195434b9410 | SA253/python-assignment | /Python/functions/assigment.py | 1,964 | 3.96875 | 4 | """#using global
x=0
def demo():
global x
x+=1
print(x)
demo()
demo()
demo()
demo()
#lexical reference here is hello . This pattern name is "closures"
#using nonlocal scope
def outer():
i=0
def inner():
nonlocal i
i+=1
print(i)
return inner... |
898701415bb5ff3873e653a5bc871ac53a634fa7 | DoriRunyon/Dictionary-skills-assessment | /advanced.py | 3,858 | 4.3125 | 4 | """Advanced skills-dictionaries.
IMPORTANT: these problems are meant to be solved using dictionaries and sets.
"""
def top_characters(input_string):
"""Find most common character(s) in string.
Given an input string, return a list of character(s) which
appear(s) the most the input string.
If there... |
12e05e1d8eef3c7b6c6fb5d220301b05767a69ba | remd/aoc-2018 | /07/steps-1.py | 1,211 | 3.5 | 4 | from re import findall
class Step():
def __init__(self, label, ancestors=[]):
self.completed = False
self.label = label
self.ancestors = ancestors
def __str__(self):
return "{'%s':%s}" % (self.label, self.ancestors)
def available(steps):
available = []
for step in step... |
d28fab07bf7bee3251333650809ecb5d361ddfbf | owis1998/intersection-between-two-lines | /intersection_algorithm.py | 1,749 | 4 | 4 | class Line:
def __init__(self, p1, p2):
self.x1 = p1[0]
self.y1 = p1[1]
self.x2 = p2[0]
self.y2 = p2[1]
# linear equation: y = m.x + b, m = slope, b is level of y when x is 0, then b = y - m.x
self.m = (self.y2 - self.y1) / (self.x2 - self.x1)
self.b = self.y1 - (self.m * self.x1)
def equation(self, x... |
d79e0f3f38d6b3bb7bacf8d2d54338652f59d8fb | odira1/Comparative-Study-of-Programming-Languages | /guess_game/string_database.py | 644 | 3.625 | 4 | '''
created on may 21, 2019
@author Emmanuel Uhegbu
'''
class string_database:
"""
Encapsulates a method required to create list from text File.
"""
def _init_(self):
"""
constructs a new string_database object.
"""
def get_word(self, index):
"""
returns a... |
cca8298cf8f7ee52492d35c00d2fd2934487e65a | mojinming/low | /123.py | 208 | 3.765625 | 4 | c=1
while c==1:
a=int(input("请输入次数"))
for b in range(a):
if b % 7 ==0 or b%10==7:
continue
print(b)
c==input("继续请按“1”,结速请按“2”") |
3cb7735aac37595fe9988cc1ee865fc35a000b85 | seoul-ssafy-class-2-studyclub/GaYoung_SSAFY | /알고리즘/알고리즘문제/4866_괄호검사.py | 1,610 | 3.5625 | 4 | for t in range(int(input())):
data = input()
stack = []
result = 1
for i in range(len(data)):
if data[i] == '(':
stack.append(')')
elif data[i] == '{':
stack.append('}')
elif stack and data[i] == stack[-1]:
stack.pop()
elif data[i] == ... |
a42d74c207bf67680b7bae6dcb0d7058a8701efe | nuriengincatak/Python_practice | /practice_python/8th game rock scissors and papers.py | 1,347 | 3.9375 | 4 | #Make a two-player Rock-Paper-Scissors game. (Hint: Ask for player plays (using input), compare them,
# print out a message of congratulations to the winner, and ask if the players want to start a new game)
#r, s ,p
repeat='yes'
while repeat=='yes':
p1=input('Player1 please input your choice:')
p2=input('Playe... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.