blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
14b2dc30e84b1e23c9d4f70f4be50c093d8a4a03 | dizidoro/pep8-conformant-util | /remove_bad_spaces.py | 1,461 | 3.890625 | 4 | #!/usr/bin/env python
"""A script to remove spaces before new lines in files as pep8 warns"""
import sys
import os
import re
__author__ = "Diego Izidoro"
def usage(argv):
"""Checks if script call usage was correct"""
assert argv.__class__ == list
if len(argv) < 2:
sys.exit('Usage: %s text_file_na... |
e614c9e46531ec79bfcdb39eaf925db54f5a203b | cartido/conversion_web | /conversion/util.py | 1,097 | 3.71875 | 4 |
class SourceIterator(object):
"""Iterator to facilitate reading the definition files.
Accepts any sequence (like a list of lines, a file or another SourceIterator)
The iterator yields the line number and line (skipping comments and empty lines)
and stripping white spaces.
for lineno, line in So... |
cd3fd69ab3637a005b7121e9d6aa879b31af8feb | itsdivik/Money-Manager | /moneymanager.py | 4,695 | 3.859375 | 4 | class MoneyManager():
def __init__(self):
'''Constructor to set username to '', pin_number to an empty string,
balance to 0.0, and transaction_list to an empty list.'''
self.u_num = ''
self.pin_number = ''
self.balance = ''
self.i_rate = ''
self.tr... |
2c783cdc9fe10a12c9ef7f3a5a84241bdf2e2ce9 | aa2841916/python-study | /first/8.1-15.py | 2,232 | 3.84375 | 4 | # class apple:
# def __init__(self,w,c,h,l):
# self.weight = w
# self.color = c
# self.high = h
# self.long = l
# print('cread')
#
# app1 = apple(10,'red','12cm','5cm')
# print(app1)
# import math
#
# class circle:
# def __init__(self,r):
# self.radius = r
#
# ... |
a8b5b68e372d29d174e0175dfebce29e1b957c51 | andregutierrez3/calc | /calc.py | 375 | 3.546875 | 4 | class Calc:
def __init__(self, a=0, b=0):
self.X = a
self.Y = b
return
def soma(self):
r = self.X + self.Y
return r
def sub(self):
r = self.X - self.Y
return r
def multiplicacao(self):
r = self.X * self.Y
return r
def divis... |
e98da80b811178884c8eeb46d415c33ff6d1e7af | Aasthaengg/IBMdataset | /Python_codes/p02993/s800339520.py | 443 | 3.734375 | 4 | a = input()
if a.count("00") > 0:
print("Bad")
elif a.count("11") > 0:
print("Bad")
elif a.count("22") > 0:
print("Bad")
elif a.count("33") > 0:
print("Bad")
elif a.count("44") > 0:
print("Bad")
elif a.count("55") > 0:
print("Bad")
elif a.count("66") > 0:
print("Bad")
elif a.count("77") > 0:... |
cd3240400abd6d783a7377121c5cd74b178a0ead | Amory0709/Python | /Data-Structure-and-Algorithm/NarcissisticNumber.py | 569 | 3.625 | 4 | class Solution:
"""
@param n: The number of digits
@return: All narcissistic numbers with n digits
"""
def getNarcissisticNumbers(self, n):
if n == 1:
return [0,1,2,3,4,5,6,7,8,9]
ans = []
for i in range(10**(n-1), 10**n):
sum, num = 0, i
... |
6618b22c20067475aee2f65aa213cdd94e068d47 | divyashree-dal/PythonExercises | /Exercise3.py | 97 | 3.953125 | 4 | n = int(input("Enter a number"))
dict1 = {}
for i in range(1,n+1):
dict1[i] = i*i
print dict1 |
8c2003d8aee3d3cb24a29f1e223f1a1ac746388f | borntoshine1/py_course_nechaeva_olga | /homework/hw7/task_1.py | 168 | 4.34375 | 4 | string = input("Enter your string: ")
symbol = input("Enter symbol: ")
new_string = ""
for i in string:
new_string = string.replace(symbol, "")
print(new_string)
|
5bebcea5617b73bb2eb5eef1246d159889177eec | mylgood/myl_good_demo | /code/chapter04/07_变量作用域.py | 1,004 | 3.703125 | 4 | # 全局变量
# 内置模块
"""
import builtins
print("内置模块:",dir(builtins))
b = 100
# 函数的嵌套定义
def fun_a(x,y):
# 形式参数x,y 也是属于本地变量
# 本地变量
a = 100
print("fun_a中访问:",sum)
def fun_b():
# a对于函数b来说是非本地变量
c = 100
print("访问本地变量:", b)
fun_b()
fun_a()
#fun_b()
访问规则: ① 现在本地作用域 > ② 全局作用域(glo... |
bb660408e43f5a9cf7b3d9955d886c808bd529df | Steven79203/sorting_collection- | /selection | 413 | 3.703125 | 4 | #!/usr/bin/env python
# Selection Sort
from random import sample
def selection(lst):
n = len(lst)
for i in range(0, n - 1):
tmp = lst[i]
for j in range(i + 1, n):
if lst[j] < tmp:
idx = j
tmp = lst[j]
lst[idx] = lst[i]
lst[i] = ... |
c79ca1a85831596f7d108b41b73f0d01ea078a7f | arayush841/medical-insurance | /prediction.py | 1,720 | 3.53125 | 4 | from os import write
from matplotlib.pyplot import step
import streamlit as st
import numpy as np
import sklearn
import pickle
st.set_page_config(page_title='Medical Insurance Cost Prediction', page_icon="🏥")
@st.cache
def load_model(file):
model = pickle.load(open(file, "rb"))
return model
... |
cb5cb58d3b32af55a7a5f8121dffdff1307bfe71 | swain-s/lc | /-排序-0冒泡排序.py | 352 | 3.796875 | 4 | import random
a = [random.randint(0, 10) for i in range(10)]
print(a)
def bubble_sort(a):
for j in range(0, len(a)):
last = (len(a)-1) - j
for i in range(0, last):
if a[i] > a[i+1]:
temp = a[i]
a[i] = a[i+1]
a[i+1] = temp
print("1-bubb... |
11930043424f9bd57657bbaa308adbef173fac51 | xhwupup/xhw_project | /3_Longest Substring Without Repeating Characters.py | 841 | 3.625 | 4 | # 时间:20190427
# Example:
#Example 1:
#Input: "abcabcbb"
#Output: 3
#Explanation: The answer is "abc", with the length of 3.
#Example 2:
#Input: "bbbbb"
#Output: 1
#Explanation: The answer is "b", with the length of 1.
# 难度:Medium(0.5)
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
if s=... |
1832d66327024e4d3f48730476edc27e8f9ed781 | kausthu/kausthub | /add.py | 343 | 4.1875 | 4 | #write a program to take 2 numbers from the user,
#then take option to add/subtract/mutiple/divide
#and perform that operation
a=int(input("value of a:"))
b=int(input("value of b:"))
c=a+b
print("addition of a and b:",c)
d=a-b
print("substaction of a and b:",d)
e=a*b
print("multiplication of a and b:",e)
f=a/b
print("d... |
2c65cc63493e4b366643c6f78becdea40d63ecb4 | comingback2life/LearningPython | /FirstPythonProject/ex3.py | 483 | 4.4375 | 4 | #The code is an extract from Learn Python the Hard way Ex3.
print "I will now count my chickens"
print "Hens",25+30/6
print "Rosters",100-25*3%4
print "Now I will count the eggs"
print 3+2+1-5+4%2-1/4+6
print "Is it true that 3+2<5-7"
print 3+2<5-7
print "What is 3+2",3+2
print "What is 5-7", 5-7
print "Oh this is ... |
81a6d267d59336eac6993de2660dd1c3703d0328 | bensalmontree/03_Quiz | /03_rounds_mechanics_v1.py | 1,845 | 4.09375 | 4 | # Quiz component 3 - Rounds Mechanic
# Functions go here
# Check if response to question is valid
def choice_checker(question, valid_list, error):
valid = False
while not valid:
# Ask user for choice (and put choice in lowercase)
response = input(question).lower()
# iterates throug... |
ff01593e573df82365da1b1a95a279a3469eb6bc | tejrajendran/Playground | /Inheritance/inheritance.py | 760 | 4.09375 | 4 | class Parent():
def __init__(self, last_name, eye_color):
self.last_name = last_name
self.eye_color = eye_color
def show_info(self):
print("last name: " + self.last_name)
print("eye color: " + self.eye_color)
class Child(Parent) :
def __init__(self,last_name,eye_color,num_t... |
c0f43e8c66d80174c39a9b8fca8c5d2e3e8e16aa | hunnurjirao/Simple-Linear-Regression-Application | /run.py | 732 | 3.734375 | 4 | import numpy as np
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
w = int(input("Enter weight in Kgs: "))
p = int(input("Enter price for the given weight: "))
weights = []
price = []
w = w * 10 ** 10
while w > 0:
w = w // 1.1
wp = (p * w)
weights.appen... |
0ed6433e057a7da3e08ad897e0a52f354eb5b612 | Shaonianlan/Python_exercise | /login.py | 1,545 | 3.78125 | 4 | user_data={}
def old_user():
prompt='请输入用户名:'
panduan=True
while panduan:
name=input(prompt)
if name not in user_data:
if name=='esc' or name=='ESC':
break
else:
prompt='用户名不存在,请重新输入:'
continue
else:
panduan=False
else:
password=input('请输入密码:')
pwd=user_data.get(name)
if passwor... |
5ecad1aef5e6380c372fdca69217df2fc4d1579b | YutingPang/leetcode | /293_filp_game.py | 227 | 3.546875 | 4 | class Solution(object):
def generatePossibleNextMoves(self, s):
return [s[:i] + '--' + s[i+2:] for i in range(len(s) - 1) if s[i:i+2] == '++']
test = Solution()
s = '+++++'
print(test.generatePossibleNextMoves(s)) |
4cdf5c348221ce85f8c861ea3094fd706ccaf271 | binnev/project-euler | /python/puzzles/euler22.py | 968 | 3.875 | 4 | # -*- coding: utf-8 -*-
"""
Names scores
Problem 22
Using names.txt (right click and 'Save Link/Target As...'), a 46K text file
containing over five-thousand first names, begin by sorting it into
alphabetical order. Then working out the alphabetical value for each name,
multiply this value by its alphabetical position... |
70b0a41da2cdaaf0b21ea4592f4c8eec6b0103d8 | sumanth-lingappa/prayathna | /linkedlist/testnode.py | 337 | 3.578125 | 4 | '''
6->3->4->2->1
'''
import node
nodeA = node.Node(6) #head
nodeB = node.Node(3)
nodeC = node.Node(4)
nodeD = node.Node(2)
nodeE = node.Node(1)
nodeA.next = nodeB
nodeB.next = nodeC
nodeC.next = nodeD
nodeD.next = nodeE
numberOfNodes = node.countNodes(nodeA)
print "Number of nodes is {}".form... |
616d598d870548d49ad6dd77aa50e9739e4e2115 | rghf/Twoc_Problem | /Day 6/8.py | 753 | 3.65625 | 4 | def spiral(nform, r, c):
rowStartIndex, colStartIndex = 0,0
while (rowStartIndex<r) and (colStartIndex<c):
for i in range(rowStartIndex,c):
print(nform[rowStartIndex][i],end=" ")
rowStartIndex+=1
for i in range(rowStartIndex,r):
print(nform[i][c-1],end="... |
7bf5a6e56e39d4da88ba10fc4503f40064e731fa | EricL0wry/algorithm-practice | /python-arcade/first-reverse-try.py | 633 | 4.46875 | 4 | # Reversing an array can be a tough task, especially for a novice programmer. Mary just started coding, so she would like to start with something basic at first. Instead of reversing the array entirely, she wants to swap just its first and last elements.
# Given an array arr, swap its first and last elements and retur... |
ece3e9e6e0f945ab13829d8170752b7f5f97d1b2 | moaazelsayed1/CS50x-psets | /week_7/pset7/houses/roster.py | 878 | 4.15625 | 4 | from cs50 import SQL
from sys import argv
import sys
# terminates the programs if the args not equals 2
if len(argv) != 2:
sys.exit("Error")
db = SQL("sqlite:///students.db")
# reading the required data from the students table ordered by last name and the first name
# db.execute retruns a lists of dictionari... |
b480150d33fae3cac8b3d56fa1550e1480a0fcbe | Evertcolombia/holbertonschool-higher_level_programming | /0x01-python-if_else_loops_functions/2-print_alphabet.py | 89 | 3.6875 | 4 | #!/usr/bin/python3
i = 97
for i in range(i, 123):
print("{}".format(chr(i)), end='')
|
a5ca6d9264f75943b97f5a4c60a831c8fbac4685 | mesomagik/python_tetris_game | /map.py | 3,434 | 3.609375 | 4 | class Map(object):
def __init__(self, height, width, squareSize):
self.squareSize = squareSize
self.height = height
self.width = width
self.mapMatrix = [[0 for i in range(width)] for j in range(height)]
self.connectedBricks = [[0 for i in range(width)] for j in range(height)]... |
63194d857612064f640f42654d90983c6447b423 | JuniorCardoso-py/PythonCourse | /Aula6/Aula6.0/Aula6.1.py | 1,223 | 4 | 4 | #Aula 6 - p2 - 13-11-2019
#Estruturas de repetição - FOR
#--- for simples usando range com incremento padrão de 1
# for i in range(0,10):
# print(f'{i} -Padawans HBSIS')
# for i in range(0,10,2):
# print(f'{i} -Padawans HBSIS')
# #--- for simples usando range com incremento padrão de 2
# for i in range(0,100,... |
a1105af7b0f972649bd7620771bec05b7397e88e | zlxl00917/LIKE_LION- | /input.py | 700 | 3.875 | 4 | # 파이썬에서 입력을 받는 함수가 있습니다~~ 구글링해서 찾아보세요!
print('문제 1. 전화번호 받기')
print('조건 1. 저장할 때는 공백 문자 없이')
print('조건 2. -, ., , 등이 들어올 때 전부 제외 하고 숫자만 저장!')
phone_number=input('전화번호를 입력하세요: ')
print('문제 2. 영어 이름 받기')
print('choi juwon 을 입력 받으면,')
print('first name : Choi, last name: Juwon 이 출력되게 만들기')
first_name, last_name=input(... |
910e7bbf5d50ec20460e0b87cbe12800446b5bb5 | christabella/code-busters | /store_credit_sort.py | 719 | 3.71875 | 4 | #!/usr/bin/env python3
def get_items_to_buy(items, credit):
indices, items = zip(*sorted(enumerate(items), key=lambda x: x[1]))
i = 0
j = len(items) - 1
current_sum = items[i] + items[j]
while current_sum != credit:
if current_sum < credit:
i += 1
elif current_sum > cr... |
498d646039a18008e69b4f7020c5b61c487f6112 | maoyalu/leetcode | /Python/1-99/5_Longest_Palindromic_Substring.py | 1,432 | 3.59375 | 4 | import unittest
def solution(s):
# ********** Attempt 2 - 2019/10/08 **********
'''Dynamic Programming'''
if len(s) < 2:
return s
size = len(s)
dp = [[False for _ in range(size)] for _ in range(size)]
max_length = 0
result = ''
for i in range(size):
max_length = 1... |
6451ffdf05cde5516d7f885a0daad77e25f208a7 | hverlin/algo | /hello_world/hello_world.py | 672 | 4.0625 | 4 | # coding: utf-8
import sys
# coding: utf-8
def hello_world(n):
"""Prints 'Hello World!' n times to stdout.
To run doctests:
python3 -m doctest -v solution.py
>>> hello_world(3)
Hello World!
Hello World!
Hello World!
Parameters
----------
n : integer
number of... |
835ee3a673d0639df597312dc4c746e9f2cbf0d3 | bgorsi/PFB_problemsets | /python_problem2.8.py | 493 | 4.25 | 4 | #!/usr/bin/env python3
import sys
number = int(sys.argv[1])
if number > 0:
print ("positive")
if number < 50:
print ("smaller than 50")
if number %2 ==0:
print ("it is an even number that is smaller than 50")
elif number > 50:
print("greater than 50")
if number... |
13a3fd4f993b399dc66107989b62a14bacada343 | jan25/code_sorted | /leetcode/weekly181/2_4_divisors.py | 666 | 3.5 | 4 | '''
https://leetcode.com/contest/weekly-contest-181/problems/four-divisors/
'''
class Solution:
def sumFourDivisors(self, nums: List[int]) -> int:
def numDivs(a):
d, s = 0, 0
for i in range(1, max(nums)):
if i*i > a: break
if a % i ==... |
033ffa55bb1fbc0a0df3e2ca6145e65a93522d99 | faizalmuzakki/Risop | /least_cost.py | 2,828 | 3.828125 | 4 | def create_table(row, column):
array2d = []
for i in range(row):
array = []
for j in range(column):
val = int(input("value: "))
array.append(val)
array2d.append(array)
for i in range(row):
val = int(input("supply: "))
array2d[i].append(val)
... |
c2fae5e17427fc6fb8e5064437d35013c3323222 | SauravShoaeib/College | /CS_127/Python/countin_stars.py | 197 | 4.0625 | 4 | #Saurav Hossain
#09/04/18
#A program that prints an opening statement and then asks the user for a number and prints that many stars, one per line
for i in range(int(input("Input was \n"))):
print("*") |
44ea283b16276460d75d47a25a02305f98c2342e | Ilnur92/skillfactory-module5 | /script.py | 1,479 | 3.75 | 4 | field = [[" ", "0", "1", "2"],
["0", "-", "-", "-"],
["1", "-", "-", "-"],
["2", "-", "-", "-"]]
def show_field():
for x in field:
print(x[0], x[1], x[2], x[3])
def ask_field():
i = input("Введите строку: ")
i = int(i)
j = input("Введите столбец: ")
... |
0479f1472d7399bcb4668d790dc5477a4ddbdb7e | Randyedu/python | /知识点/04-LiaoXueFeng-master/32-MetaClass.py | 7,559 | 4.625 | 5 | '''
type()
动态语言和静态语言最大的不同,就是函数和类的定义,不是编译时定义的,而是运行时动态创建的。
'''
class Hello(object):
def hello(self, name = 'world'):
print('Hello, %s' % name)
h = Hello()
h.hello()
print(type(Hello))
print(type(h))
print('--------------------------')
'''
我们说class的定义是运行时动态创建的,而创建class的方法就是使用type()函数。
type()函数既可以返回一个对象的类型,又可以创建出... |
5ab15fae83e1322eb46e0c0d2b1306554437794e | lightionight/LearnPython | /SourceCode/BuildInModules/datetime.py | 361 | 3.796875 | 4 | # datatime is python deal with time and date standard lib
# important datatime modules
# first datetime is modules name, second datetime is class name
from datetime import datetime
# get current time from system
now = datetime.now()
print(now)
# using order time to create datetime object
dt = datetime(2020, 11, 13... |
ef8cc271c0fa8304666d97ec0c962a9597546e36 | viviannevilar/pyhton-tasks | /functionsQ2.py | 306 | 4.3125 | 4 |
number = []
new_number_string = input("Type a number to add: ")
while len(new_number_string) > 0:
new_number = int(new_number_string)
number.append(new_number)
new_number_string = input("Type a number to add: ")
mean = sum(number)/len(number)
print("The average of the numbers is {mean}")
|
5f93df695fb0118e939018c8b7109b58e2ed5af6 | MahmoudHassan/hacker-rank | /30DaysOfCode/Day11.py | 1,341 | 4 | 4 | """
Context
Given a 6*6 2D Array, A:
1 1 1 0 0 0
0 1 0 0 0 0
1 1 1 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
We define an hourglass in A to be a subset of values with indices falling in this pattern in A's graphical representation:
a b c
d
e f g
There are 16 hourglasses in A, and an hourglass sum is the sum of an h... |
050c5774e4dc36741ed87008ee252aab5b3bd711 | ashutoshkrris/Data-Structures-and-Algorithms-in-Python | /Recursion/flatten.py | 457 | 4.0625 | 4 | # Write a recursive function called flatten which accepts an array and returns new array with all values flattened
def flatten(arr):
result = []
for item in arr:
if type(item) is list:
result.extend(flatten(item))
else:
result.append(item)
return result
print(flatt... |
8694362beeb11f7451b7232b226888c28b54dc7b | germandouce/AyP-1 | /Clases_y_ejercicios/Ejs_RPL/4_Decisiones.py | 2,432 | 3.84375 | 4 | #UNIDAD 4: Decisiones
#ej 4.1
# a) - Es par
'''Escribir una función indique si un determinado número entero es par o no'''
'''
n=4
def es_par(n):
"""
dice si es par o no
"""
# if n%2 == 0:
# return (n%2 + 1)
# else:
# return (n%2 - 1)
return (n%2 == 0)
print(es_par(n))
'''
... |
1bed4e2666c699ebf25b0a1035b23491dec84666 | woobaik/python200 | /qestion.py | 398 | 3.796875 | 4 | def delete_from_dict(a, *b):
if not isinstance(a, dict):
print(f"You need to send a dictionary. You sent: {type(a)}")
return
if len(b) != 1:
print("You need to specify a word to delete.")
else:
if b[0] in a:
del a[b[0]]
print(f"{b[0]} has been delete... |
252e89a41bc1023e2806f58c5eea6c81cc6b4c7c | purusoth-lw/my-work | /6.Bitwise operator.py | 422 | 3.953125 | 4 | a=int(input("Enter value 1 : "))
b=int(input("Enter value 2 : "))
c=a&b
print("a&b : ",c)
c=a|b
print("a|b : ",c)
c=a^b
print("a^b : ",c)
c=~a
print("~a : ",c)
c=a<<1
print("a<<1 : ",c)
c=a<<2
print("a<<2 : ",c)
c=a>>1
print("a>>1 : ",c)
c=a>>2
print("a>>2 : ",c)
c=b<<1
print("b... |
ac27deacfacab6a8e85e0141a42c61ee07aa29f6 | mcvholloway/reinforcement_tic_tac_toe | /draw_board.py | 1,130 | 3.75 | 4 | import matplotlib.pyplot as plt
import numpy as np
def setup_grid():
fig = plt.figure()
plt.xlim(0,3)
plt.ylim(0,3)
for x in [1,2]:
plt.vlines(x = x, ymin = 0, ymax = 3)
for y in [1,2]:
plt.hlines(y = y, xmin = 0, xmax = 3)
plt.axis('off')
def add_elements(board... |
fa405f4b4f479c4c2d9896e8ce632893a7048a50 | curtislb/ProjectEuler | /py/problem_009.py | 1,392 | 4.53125 | 5 | #!/usr/bin/env python3
"""problem_009.py
Problem 9: Special Pythagorean triplet
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a^2 + b^2 = c^2
For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2.
There exists exactly one Pythagorean triplet for which a + b + c = S.
Find the product a*b... |
dd9bfdff870560655783b59ed35c51f620045ff6 | gslandtreter/pyNeuralClassifier | /gradient_tester.py | 1,919 | 3.78125 | 4 | import neural_classifier
from neuralnetwork.activation_function import ActivationFunction
from neuralnetwork.neural_network import NeuralNetwork
if __name__ == '__main__':
activation_function = ActivationFunction(neural_classifier.sigmoid, neural_classifier.derivative_sigmoid)
#Topologia simples, 1 neuronio ... |
3932dd0a0cb7d95fac248801590ad028896de2ef | masterfung/LPTHW | /ex31.py | 1,248 | 4.3125 | 4 | print 'You are at crossroad and you have to choose from three paths. What do you choose (left, middle, or right)?'
userChoice = raw_input('Please enter your choice: ')
if userChoice.lower() == 'left':
print 'The giant zebra grabbed you and ate you like an eggplant. But all hope is not lost. You have two possible act... |
9fd2aea905257e82dd5c8fe9eba12b89dbfb6114 | enisnazif/battleships | /bots/Notorious_B_O_T.py | 4,933 | 3.734375 | 4 | import random
from typing import List, Dict, Union, Tuple
from config import BOARD_SIZE
from game_types import Bot, Board, Point, Ship, ShipType, Orientation
class Notorious_B_O_T(Bot):
""" Hello! I am a dumb sample bot who places its ships randomly and shoots randomly! """
def __init__(self):
super... |
41474e9e57bfc3ad78f908f587b448a6c7fded13 | euni-brownie/python-workbook | /average.py | 454 | 3.765625 | 4 | from Student import Student
continued = ""
student_list = []
student_info = 0
while(student_info != "1") :
student_info = input("학생정보입력(그만두기:1) >")
if(student_info == "1") : break
student_list.append(Student(student_info[0],student_info[1],student_info[2],student_info[3]))
print("이름 총점 평균 석차")... |
fb96da73cb49f829f9d4038cb8dddcd2330e9a9e | alexoah/PythonPlayground | /W3School-PyExercises/PY-IfElse/pyIfElseE8.py | 310 | 3.578125 | 4 | """
from PYTHON If...Else: Exercise 8 ( https://www.w3schools.com/python/exercise.asp?filename=exercise_ifelse8 )
question:
Use the correct short hand syntax to put the following statement on one line:
if 5 > 2:
print("Five is greater than two!")
"""
if 5 > 2: print("Five is greater than two!") |
2d1e6490abb63d6d47de12d5972fcf7c52a24e21 | SafonovMikhail/python_000577 | /001132StepikITclassPy/Stepik001132ITclassPyсh05p03st03TASK02_20210216_quadrant.py | 1,448 | 4.5625 | 5 | '''
В теории к уроку есть задача про определение четверти по введенным координатам x и y. Тебе необходимо исправить и дополнить программу, так, чтобы она не только определяла четверти, но и писала бы другие ответы: Положительная абсцисса, Отрицательная ордината, Начало координат и т.д.
Sample Input 1:
0
0
Sample Outp... |
2bfebb797ff74ce393f29cada7ae4b76a5436c9e | noserider/school_files | /Python-Next-steps/Python Next steps/L2 Loops/guessGame.py | 356 | 4.28125 | 4 | answer = "8"
guess = input("Guess a number: ")
# while() loop code goes here
# while() loop code ends
print("\nWell done, that's right!")
input("\nPress ENTER to exit program")
# EXTENSION ACTIVITY
# 1. Let the user put in the answer first (so it's not always 8)
# 2. Use a counter to count how many gues... |
02bbd4a0586531b083c7f17effb451eb69af936a | utsadev/ProgEngIIHW | /Week4_py/if-elif-example.py | 931 | 3.90625 | 4 |
print "Welcome to Hotel ABC"
print "How many rooms do you want to reserve?"
roomNo=int(raw_input())
print "How many nights do you want to stay?"
nightNo=int(raw_input())
print "We have King Room ($100/night), and Queen Room ($80/night)"
print "Press 1 to select King Room, and 2 to select Queen Room"
roomType=int(raw_i... |
c5ec33c64182ef2ccc89813e29753caffc8898ba | liuyonggg/youngcoders | /week1.py | 180 | 3.5625 | 4 | print ("Hello", "World!")
print ("Hello " + "World")
print ("Hello %s" % "World")
print ("2 + 3 =", 2+3)
print ("I'd much rather you 'not'.")
print ('I "said" do not touch this.')
|
faabb8972230daae0d2348a84a0a7050b8862ba6 | galayko/euler-python | /problem14.py | 945 | 4.125 | 4 | #!/usr/bin/env python
# The following iterative sequence is defined for the set of positive
# integers:
# n = n/2 (n is even)
# n = 3n + 1 (n is odd)
# Using the rule above and starting with 13, we generate the
# following sequence:
# 13 40 20 10 5 16 8 4 2 1
# It can be seen that this sequence (starting at 13... |
d8c0929193adf3aee997b4252a895237c2f97b3c | LarisaOvchinnikova/Python | /1 - Python-2/19 - datetime/HW19/3a - Get weekdays.py | 227 | 4.25 | 4 | # Print a full weekday's name of the first day of every month
from datetime import date
month = 1
first_weekday = [date(2020, month, 1) for month in range(1,13)]
for day in first_weekday:
print(day.strftime("%B %d: %A"))
|
fe6e5ba36bc8b2339d7a27f351d65cebd18a0c6d | stephanieeechang/PythonGameProg | /PyCharmProj/CupcakeMachine.py | 1,897 | 3.984375 | 4 | '''
The program runs a cupcake machine
'''
import time
from threading import Thread
import signal
chocolate = 50
vanilla = 30
redVelvet = 45
cherryP = 5
frostingP = 10
cTime = 10
vTime = 6
rTime = 8
cherry = False
frosting = False
productTime = 0
productPrice = 0
start = False
TIMEOUT = 10
def menu():
#flavor
... |
2db9f4c84c86fe945dad05166a20d021abb73e03 | adrianadames/GraphsRedo | /GraphsRedo/projects/graph/src/draw1.py | 15,010 | 3.546875 | 4 | # In draw.py, implement the BokehGraph class. The constructor should accept a
# Graph object (as you implemented in part 1), and optionally other parameters
# configuring e.g. graphical settings. The show method should use Bokeh to
# generate and display HTML that draws the graph - the included Pipfile will
# in... |
ead984afdc6d3600f684e4f87796df11646eadd8 | angel-becerra/trabajo10-Becerra_Chancafe | /app2.py | 885 | 3.5625 | 4 | import libreria
#aplicacion para guardar
def agregar_curso():
curso=libreria.pedir_nombre("ingrese curso:")
nota=libreria.pedir_numero("ingrese nota:",1,100)
contenido=curso + "-" + str(nota)+ "\n"
libreria.guardar_datos("notas.txt", contenido,"a")
print("datos guardados con exito")
def dar_informa... |
b107bbcb4242f3239ba8a3bdf07241208edc56e4 | ATJUstudent/DataManagePlatForm | /server/importdatafile.py | 11,673 | 3.53125 | 4 | """
Interface for import data into database by excel file <.xlsx> and csv file <.csv>
Please look forward to more features
"""
# Author: Wang Chuhan(wchwzhsgdx@gmail.com)
# Time: 2021.03.14
# for Data Manage Platform(TJU CS2018-3)
from openpyxl import load_workbook
from sqlcreator import SqlCreator
import ... |
b564685c9f5f899cd3562a8cdbe89415b006244c | Rimesh/Python-LPTHW | /ex13.py | 390 | 3.703125 | 4 | # Title: Exercise 13 - Parameters, Unpacking, Variables
# from Learn Python the hard way
# Date: 1st March 2017
# by Rimesh Jotaniya
# Description: taking command line arguments
from sys import argv
script, first, second, third = argv
print "The script is called: ", script
print "Your first variable is: ", first
pri... |
9d0c2dc40b8d6b7c61825bcf62f9ddcedbd771e5 | adstr123/ds-a-in-python-goodrich | /chapter-1/c22_dot_product.py | 632 | 4.3125 | 4 | def dot_product(list_a, list_b):
"""Performs dot product on two lists
:param list list_a: dot product left-hand side
:param list list_b: dot product right-hand side
:return int: dot product of input lists
"""
return sum([i * j for (i, j) in zip(list_a, list_b)])
print(dot_product([1, 2, 3], [1, 3, 3]))
... |
38c12b3bd8c3b175ce68dd2e06eea42ea4fa7e4b | kobrv/projekt | /minigames.py | 13,316 | 3.703125 | 4 | import random
class Quest:
def __init__(self, mainloop):
self.mainloop = mainloop
self.completed = False
def run(self):
self.completed = self.mainloop()
def guess_number():
print("Twoim zadaniem będzie zgadnięcie, jaką liczbę mam na myśli.\nJest to liczba z zakresu od 1 do 100.... |
04170aa4019650ddd2c1ed83a81c6de94b874e90 | keepsoftware/words2num | /tests/__init__.py | 1,069 | 3.671875 | 4 | import unittest
import words2num
class TestITN(unittest.TestCase):
"""Test inverse text normalization for numbers.
"""
def test_lang(self):
"""Test multi-lang handling of words2num.
"""
try:
words2num.w2n(None, lang='123')
assert False, "exception not raise... |
2e2a77e3902d91960f578fbc5711ca57b39bc897 | mieva/DATASCIENCE | /APPLICATIONS/TUBULAR/AlgoSolution_EngCodingTest_trains.py | 2,327 | 4.125 | 4 | ####### A possible algorithm to solve the coding test about train stations
####### PSEUDO CODE!
# Main function that read inputs and call the recursive function to find the required time
def FindPath():
import sys
data = sys.stdin.readlines()
# Parsing the first table that contains the travel time between connect... |
eb00e6d2dc615f1022097b924c89cc144aab61b5 | OneOneFour/NeuralSnake | /neuralnetwork.py | 9,133 | 3.609375 | 4 | import numpy as np
import names
import time
import snake
from tensorflow.examples.tutorials.mnist import input_data
import matplotlib.pyplot as plt
class NeuralNetwork:
def __init__(self, layer_setup, name, family, bias=None, weights=None):
'''
Create neural network with blank parameters for snake
... |
12f14d96f18b14f62b29217362257d0ae7530d8e | jpsalviano/uri-online-judge | /2147.py | 78 | 3.5 | 4 | for _ in range(int(input())):
print('{:.2f}'.format(len(input()) * 0.01))
|
c5e262d0df628a6a2badbd9a68b2550edcf1c88b | AhmadMWaddah/AMW_Functions | /AMW SLR Package.py | 4,342 | 3.640625 | 4 | class MeanSquaredError:
def __init__(self, actual_data, predicted_data):
self.
# Mean Squared Error.
def mean_square_error(self):
"""
Function Takes 2 Parameters lists of data, making counter and add to it and zipping lists.
:param actual_data:
:param predicted_data:
:return: Mean Square... |
5a5f041391049d4e7fa05338ae258462dcbf3e12 | iulidev/dictionary_search | /search_dictionary.py | 2,798 | 4.21875 | 4 | """
Implementarea unui dictionar roman englez si a functionalitatii de cautare in
acesta, pe baza unui cuvant
In cazul in care nu este gasit cuvantul in dictionar se va ridica o eroare
definita de utilizator WordNotFoundError
"""
class Error(Exception):
"""Clasa de baza pentru exceptii definite de utilizator"""
... |
8af974cf30f71656110ff8ea3510219cad025632 | jacquerie/leetcode | /leetcode/1374_generate_a_string_with_characters_that_have_odd_counts.py | 380 | 3.671875 | 4 | # -*- coding: utf-8 -*-
class Solution:
def generateTheString(self, n: int) -> str:
if n % 2:
return "a" * n
return "a" * (n - 1) + "b"
if __name__ == "__main__":
solution = Solution()
assert "aaab" == solution.generateTheString(4)
assert "ab" == solution.generateTheStri... |
caf0761b7ad526e99b283a1759adfab82ef03ddd | guydav/minerva | /stuff/peculiar_balance.py | 1,280 | 4.15625 | 4 | def answer(x):
'''
x: the weight on the left side to be balanced
return: a list of where to place each weight - "L" / "-" / "R"
'''
# create a list of all weights to be used:
if x <= 0:
return
current_weight = 1
weights = [current_weight]
while sum(weights) < x:
cur... |
9ccd3916c23a263cdd909fe8b273698c706d4daa | taeyoung02/Algorithm | /최대힙.py | 1,807 | 3.609375 | 4 | import sys
class heap:
def __init__(self):
self.n = int(input())
self.arr = [0]*(self.n+2)
self.count=0
self.start()
def heapmax(self):
if self.count==0:
print(0)
else:
print(self.arr[1])
self.arr[1]=self.arr[self.cou... |
d4d3857ea80ae8f790e55834cd171d4332d6d832 | eulestadt/MIS-304 | /Final Project/cupcakes.py | 3,356 | 4.4375 | 4 | # Name: Phoenix Wang
# Assignment Number: Final Project
# Date: 12/5/19
# Section: 9:30-11
# Description: The cupcake class for the cupcake object
# that is sold at the cupcake shop. Allows the user to access
# the price, flavor, inventory, and topping attributes of the
# cupcake, while also checking each part.
#cupca... |
a809edf288895b01433542db8ac8e623d264ca51 | HarshKhaiwal/Python-Assignment | /duplicate.py | 380 | 3.984375 | 4 | list1 = []
list2 = []
n = int(input('Enter no. of elements you want to enter in a list : '))
for i in range(0, n):
x = int(input())
list1.append(x)
print('Original list {}'.format(list1))
list1.sort()
for i in range(len(list1) - 1):
if list1[i] == list1[i + 1]:
list2.append(list1[i])
prin... |
1bad39d26c85c4368c5a8964bf242bc0340040b2 | smilezjw/LeetCode | /P142_Linked List Cycle II/Linked List Cycle II.py | 1,887 | 3.5625 | 4 | # coding=utf8
__author__ = 'smilezjw'
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def detectCycle(self, head):
if head is None or head.next is None:
return None
fast = slow = head
while fast and fast.next:
... |
4ec3cae997290213c5a5d074a2446bf5c677defb | TheRea1AB/Python | /Conditional.py | 1,129 | 4.34375 | 4 | #Conditional Statements
#if statement
grade = 95
if grade > 90:
print("You got an A!")
#if-else statement
grade = 75
if grade > 90:
print('You got an A')
else:
print('You did not get an A')
#if-elif statement
grade = 85
if grade > 90:
print("A")
elif grade > 80:
print("B")
else:
print("Youg d... |
7b1d132e85f8c478ae3c778ce465f10672bcc08b | mdeng1110/Computing_Talent_Initiative | /12_P2_Add_Node_to_BST.py | 1,410 | 4 | 4 | class Node:
def __init__(self,data):
self.data = data
self.left = None
self.right = None
class Tree:
def __init__(self):
self.root = None
def print_bfs(self):
if not self.root:
return
queue = [self.root]
while len(queue) > 0:
current_node = queue.pop(0)
print(cur... |
8c034bc5367ed40c4bae0b818a943384936b391e | iamNargiz/Py_concepts_RegEx | /RegEx.py | 775 | 4.125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[11]:
#search() function
import re
text = "The match in Azerbaijan"
x = re.search('^The.*Azerbaijan$',text)
print(x)
# In[12]:
if x:
print("Yes! We have a match!")
else:
print("No match")
# In[13]:
#findall() function
txt = "The rain in Azerbaijan"
x = re.fin... |
6f4fe239759e2bb1f8ca01b7a61a102cd2c82ed5 | guptaarchit/movie-recommendation-system | /Movie-Recommendation-Algorithm-master/runMe.py | 3,137 | 3.515625 | 4 | import networkx as nx
import matplotlib.pyplot as plt
def neighborList(G, node, props):
neigh = G.neighbors(node)
neigh.remove('Weight')
for prop in props:
neigh.remove(prop)
return neigh
#print "\n "
props = ['Actor','Director','Producer','Genre']
G = nx.Graph()
#Constructing a graph from the JSON file
fin =... |
19b0ea7d89396b790baee3f1265cd2f700105a21 | NCavaliere1991/space-invaders | /turret.py | 1,057 | 3.5625 | 4 | from turtle import Turtle
class Turret(Turtle):
def __init__(self):
super().__init__()
self.shape("sprites/ship.gif")
self.penup()
self.goto(0, -225)
self.bullet = None
self.bullet_list = []
def move_right(self):
if self.xcor() < 270:
self.fo... |
7f09b95f67b37362db89cf2b26951499901f930e | wongahee/python3 | /ex15.py | 1,006 | 3.75 | 4 | # 혈액 보관 시스템
A = []
B = []
AB = []
O = []
num = 0
for i in range(10):
blood = input('헌혈해 주셔서 감사합니다. 혈액형을 선택하세요 \n'
'A, B, AB, O : ')
if blood == 'A' or blood == 'a' : A.append(blood)
elif blood == 'B' or blood == 'b' : B.append(blood)
elif blood == 'AB' or blood == 'ab' : AB.append(b... |
5beb8e7970a2e8b1bb5cbf73f0c9717d6da7d2b6 | black40/helper_code | /balance_brackets.py | 1,084 | 3.6875 | 4 | ''' Balance of opening and closing brackets '''
def find_balance(data, left='[{(', right=']})'):
res = []
for i in data:
if i in left:
res.append(i)
elif i in right:
if len(res) == 0:
return False
elif right.index(i) == left.index(res[-1]):
... |
630836444b51ed83dcc7707b0df0cc086c29e767 | think-differentt/Final-Python-Project | /main.py | 2,640 | 4.53125 | 5 | # <Author> Think-differentt
# <Date> 11OCT20
# Program - This is a program that is used to get weather information from openweathermap
# and display it to the user.
#
# Some printing information taken from https://www.youtube.com/watch?v=PWZKTWJ9bJE REQ 1 - Asks the user for their
# zip code or city. REQ 2 - Use ... |
0480316d6fbf3dc3841ac9970687e470839c5816 | masoom-A/Python-codes-for-Beginners | /list_index.py | 178 | 3.796875 | 4 | def list(nums):
count=0
for num in nums:
if num==4:
count=count+1
return count
print(list([1,4,3,5,4]))
print(list([4,5,4,6,4,3]))
|
df3dc4f30b3d81c5c0ad4ac5114cbefb5d060ff1 | rodrigobmedeiros/Coursera-Introdution-To-Scientific-Computing-With-Python | /Exercises/soma_elementos.py | 444 | 3.9375 | 4 | #Introduction to Computer Science
#Function: soma_elementos
#Date: 18/02/2020
#Developed by: Rodrigo Bernardo Medeiros
#================================================================
#The program will receive a list with integer numbers and will
#sum all elements.
#===================================================... |
8b73cec23cf79ff10b91e7259e54d8b8f84bc949 | theref/Computing-For-Mathematics | /Lab Sheet 2/#3.py | 148 | 4.1875 | 4 | mylist = []
for i in range(1301):
if i % 3 == 0: #computes all the numbers in range divisible by 3
mylist.append(i)
print mylist
print mylist[-1] |
4ef22b0642da92e7839a0f71f2a7dae4482b7466 | jspahn/Python-Code | /Project-Euler/Finished Problems 1-25/04-PalindromeProject.py | 1,831 | 4.03125 | 4 | # Project Euler
# Problem 4: Largest Palindrome Product
# Problem Details:
# A Palindromic number reads the same both ways. The largest
# palindrome made from the product of two 2-digit numbers is
# 9009 = 91 * 99
# Find the largest palindrome made from the product of two
# 3-d... |
80502b084e3959c1a551e29d09ffa2432c9d81de | kristiangyene/IN1000 | /oblig4/regnelokke.py | 817 | 3.859375 | 4 | """
Programmet skal la brukeren skrive inn tall helt til brukeren skriver "0" og
legger det i en liste. Alle elemter blir skrevet ut hver for seg. Summen av
tallene, det største tallet, og det minste blir også skrevet ut ved hjelp av
for-løkker.
"""
liste = []
tall = 1
while tall != 0:
tall = int(input("Skriv inn... |
d5efc06c6703a1691cb8e48011fc78d69c28b16d | cassianasb/python_studies | /fiap-on/6-7 - Login.py | 219 | 3.5625 | 4 | import getpass
user = input("Digite o usuário: ").upper()
password = getpass.getpass("Digite a senha: ")
if user == "USERADM" and password == "OutTime":
print("Usuário logado")
else:
print("Login Negado") |
f454abf3c65d5508df03bbc74e0e5a8c6fd650d0 | emas89/Project-5_OpenFoodFacts_Advisor | /Scripts/5_substitute_finder.py | 4,943 | 3.9375 | 4 | #! /usr/bin/env python3
# -*- coding: utf8 -*-
"""
Open Food Facts Advisor.
Program which finds a healthier food alternative than the one chosen by
the user. The comparison is based on the nutition score: a better dish will
have a higher score than a worse one.
Furthermore, the program indicates where to buy... |
d9ae7392ce1848620afbea4b57c6aed0bccafc20 | Hiromitsu4676/algorithm | /connected_component.py | 1,637 | 3.859375 | 4 | class Queue():
'''
キュー(先入れ先出し)
'''
def __init__(self,size=100):
self.queue =[]
self.size=size
def enqueue(self,x):
self.queue.append(x)
return self.queue
def dequeue(self):
rslt=self.queue[0]
del self.queue[0]
return rslt
def is_empty(... |
972f5f57d97ffed00089beac68d409e691615f05 | marmara-technology/SIKAR-HA | /SIKAR-HA Control Panel/Programlar/konumgonder.py | 2,524 | 3.578125 | 4 | import tkinter.font
from tkinter import *
from tkinter import messagebox
from tkinter import Menu
import RPi.GPIO as GPIO
import os
wait=None
rec=None
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD) #Numbers GPIOs by physical location
def SetAngle(angle): # Angle paramater will be got from user
print('go')
def S... |
7940f16bbb51967bcccd2e40f54eb32178263453 | raghav581/DSA-Solutions | /Recursion/Day1/problem1/main.py | 218 | 4.125 | 4 | def fibonacci(n):
if n == 1:
return 0
elif n == 2:
return 1
return fibonacci(n - 1) + fibonacci(n - 2)
if __name__ == "__main__":
n = int(input())
res = fibonacci(n)
print(res) |
f4a4ed772b1fbce140eee1bc6d391472ca05de26 | mahsa-ashna/python-project | /project_phase2_mahsa ashna/login.py | 1,893 | 3.734375 | 4 | import pandas as pd
import hashlib
import csv
class User:
def __init__(self, username, password,varity):
self.username = username
self.password = password
self.kind = varity
@staticmethod
def register():
file_path = "account.csv"
df_account = pd.read_... |
43eb11b51339147fd49d99ea39b1e6d2d03ff0ea | alanniu99/codebyte | /letterChanages.py | 433 | 4.1875 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
def LetterChanges(str):
newStr = ""
for char in str:
if char.isalpha():
if char.lower() == 'z':
char = 'a'
else:
char = chr( ord(char) + 1 )
if char in "aeiou":
char = char.upper()
... |
83ff9347d8b13168ab53aceada5da6a7d491d857 | knuu/competitive-programming | /aoj/24/aoj2441.py | 1,029 | 3.65625 | 4 | def count_div(start, end, div):
# [start, end)
return (end - 1) // div - (start - 1) // div
def calc_start(mid):
cnt, i = 0, 1
while 10 ** i < mid:
d, p = 10 ** i, 10 ** (i - 1)
fif, three, five = count_div(p, d, 15), count_div(p, d, 3), count_div(p, d, 5)
cnt += i * (d - p) + ... |
7694c5fb666041e14760f5a0200bb09225f8be84 | alex99q/python3-lab-exercises | /Lab2/Exercise4.py | 366 | 3.9375 | 4 | leap_years = []
current_year = 2018
while len(leap_years) < 20:
current_year += 1
if current_year % 4 != 0:
continue
elif current_year % 100 != 0:
leap_years.append(current_year)
elif current_year % 400 != 0:
continue
else:
leap_years.append(current_yea... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.