blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
b8bd7096aa800ba40dfd70bdcb94e63c47b78043
niranjan2822/Interview1
/program to print odd numbers in a List.py
1,328
4.53125
5
# program to print odd numbers in a List ''' Example: Input: list1 = [2, 7, 5, 64, 14] Output: [7, 5] Input: list2 = [12, 14, 95, 3, 73] Output: [95, 3, 73] ''' # Using for loop : Iterate each element in the list using for loop and check if num % 2 != 0. # If the condition satisfies, then only print the number. # ...
8a0fcc9d999434e6952ca9bb6c5d2d2f2ca36e6c
niranjan2822/Interview1
/Uncommon elements in Lists of List.py
2,104
4.5
4
# Uncommon elements in Lists of List ''' Input: The original list 1 : [[1, 2], [3, 4], [5, 6]] output : [[3, 4], [5, 7], [1, 2]] # The uncommon of two lists is : [[5, 6], [5, 7]] ''' # Method 1 : Naive Method # This is the simplest method to achieve this task and uses the brute force approach of executing a loop a...
c94beb6e76b22a160c56d890e898ca1c8d3664dc
acheun1/02.Functions_Basic_I
/Functions Basic I.py
2,232
4
4
#Functions Basic I #2018 09 14 #Cheung Anthony #Predict the output of the codes below without running the codes directly. #Write down your predictions for all challenges below and once done, please compare your predictions with the results from the shell. def a(): return 5 print(a()) #OUTPUT=5 def ...
9f8122868428f91785b782958d2a2d26f410c760
jbakerr/Pong
/ball.py
1,773
3.875
4
import pygame from pygame.sprite import Sprite import math from random import choice class Ball(Sprite): """A class to manage the main ball""" def __init__(self, ai_settings, screen): """Create a ball object that starts in the center""" super().__init__() self.ai_settings = ai_setting...
aed946af31844dd04feee025ba58d6d878fb42f7
endytc/praktikum
/pbo/interface.py
467
3.828125
4
from abc import ABCMeta, abstractmethod, ABC class Transaksi(ABC): @abstractmethod def tagihan(self): pass @abstractmethod def pembayaran(self): pass class Penjualan(Transaksi): def tagihan(self): print("tagihan penjualan") def pembayaran(self): print("pembayran penjualan") class Pembelian(Transa...
d45f0a3161f06e50abc3b88f001b116821612dfc
endytc/praktikum
/struktur-data/linked-list.py
1,147
4.09375
4
class Node: def __init__(self,data): self.dataval = data self.next = None head = None # menambahkan node di depan def addFirst(node): global head node.next = head head = node # menambahkan node di ujung def addLast(node): global head ujung = head while ujung.next: ujung = ujung.next uju...
6fc03e029814d1e7f48e0c65921d19a276c15b06
CHilke1/Tasks-11-3-2015
/Fibonacci2.py
586
4.125
4
class Fibonacci(object): def __init__(self, start, max): self.start = start self.max = max def fibonacci(self, max): if max == 0 or max == 1: return max else: return self.fibonacci(max - 1) + self.fibonacci(max - 2) def printfib(self, start, max): for i in range(start, max): print("Fibonac...
0e5e9dee42bb6f223dbb3df01896e0673065df4a
bvo773/PythonFun
/mathpy/calculator.py
469
3.90625
4
print ("Calcultor initializing...Hello World, I am a CalculatorBin") def factor_of(x): try: if (x.is_integer()): for factor in range(1, x + 1): if(x % factor is 0): print(factor) except TypeError: print("Not an integer value") def add(x, y): ...
e0ec66c76e6f734caf5262867aac6245414ba8e9
bvo773/PythonFun
/tutorialspy/basic/listPy.py
557
4.40625
4
# (Datatype) List - A container that stores ordered sequence of objects(values). Can be modified. # listName = [object1, object2, object3] def printFruits(fruits): for fruit in fruits: print(fruit) print("\n") fruits = ["Apple", "Orange", "Strawberry"] fruits[0] #Accessing a list fruits[1] = "Mango"...
7e7117231bf25804555223e4bcb58773c763122a
ediuG/Coding-Dojo
/grade_loop.py
704
3.71875
4
import argparse scores = (91, 81, 71, 61, 0) grades = ("A", "B", "C", "D", "F") def score_range(string): value = int(string) if value > 100 or value < 0: msg = "%r is not in range[0-100]" % string raise argparse.ArgumentTypeError(msg) return value def main(argv): for num, score in e...
45caf65f327211be9d8b20084bd1133dfa254342
MowMowchow/laddr
/dataparser.py
1,915
3.65625
4
import json # a python program to filter the data # organized data into a json with field of education as keys # stored at each key is sex, then an array containg objects with fields of degree level and income filtered_data = {} for data_type in ['female', 'male', 'total']: with open('data/'+data_type+'_income_dat...
bcc1707e20748dc357cbd334ceab85c75c0862c3
rwankurnia/fundamental-python
/tugas06-02-2020.py
719
3.78125
4
## Home Work # if else: # Jika sebuah kata diawali dengan huruf vokal "a, i, u, e, o", tambahkan huruf ay # Jika tidak, taruh huruf pertama di paling beakang kemudian tambahkan ay ## Pake Return inputText = input("Masukkan kata : ") def changeWorld(text): if text[0] in ["a", "i", "u", "e", "o"]: text = ...
6dfc3a9d06ee4401a3d78ddb27e8bacd01884138
rwankurnia/fundamental-python
/Dictionary/dictionary.py
2,195
4.15625
4
# # DICTIONARY # # Menggunakan kurung kurawal {} # # Tidak menggunakan index, melainkan property # # Nama property ditulis menggunakan kutip (seperti string) # price = { # "apple" : 10000, # "grape" : 15000, # "orange" : 15000 # } # price["grape"] // 15000 # print(price["grape"]) ## 15000 # ===========...
b706b025cd312e6de3bd1e2d83aa2c4aa36f48b4
rwankurnia/fundamental-python
/slide2/if-elif-else.py
211
4.09375
4
umur = input("Masukkan Umur Kamu : ") umur = int(umur) if (umur >= 18) : print("Boleh Masuk") elif (umur >= 15 and umur < 18) : print("Boleh Masuk dengan orang tua") else: print("Tidak Boleh Masuk")
76ee52048a67b7c030aed22c68374083123abff6
rwankurnia/fundamental-python
/solved1.py
169
3.71875
4
import math x = 4 y = 3 z = 2 # w = (x + (y * z)) / (x * y) ** 2 # print(w) #================= #cara ke 2 w = (x + (y * z)) / (x * y) w = math.pow(w, z) print(w)
2a25141ee870025b2f3d55698dfcde2e31091d63
newsteinking/workspace_backup
/workspace_A/workspace_parkjj/Learn to Program with Minecraft Code실습/chapter8-functions/chapter8-5.py
110
3.515625
4
#(cost+2)*10 def calculate(cost): cost2=cost+2 cost2=cost2*10 return cost2 print(calculate(99997))
3069713e32d07be84a2047b5e77f57b3adacd0ec
newsteinking/workspace_backup
/workspace_A/workspace_parkjj/Learn to Program with Minecraft Code실습/chapter9-lists/chapter9-1.py
225
3.78125
4
a=[1,2,3,4] print(a[0]) a[0]=100 print(a) print(a.index(2)) ab=['aa','bb','cc'] b=(1,2,3) #DICTIONARY c={'a':34,'b':'yee'} list_a=['Hello','nice','to meet','you','I am logan'] print(list_a) list_a.append("test") print(list_a)
31485be0a189a277dd5fea7133025b78efda1779
newsteinking/workspace_backup
/workspace_K/workspace_jihyung/python/python_minecraft/Learn to Program with Minecraft Code실습/chapter6-ifStatements/test6.py
122
4.15625
4
number=int(input("your number")) if number<0: print("-") elif number==0: print("0") elif number>0: print("+")
b14974df59a688d232de9d21ff118e2385295d77
thelordofscrubs/pythonScripts
/hangman.py
1,892
3.609375
4
from os import system alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] pastGuesses = [] correctGuesses = [] def printGame(wl): wordDisplay = " " for x in range(wl): if word[x] in correctGuesses: wordDisplay += " "+word[...
e8950d3c93cd2fcdfeeb66189d633b087df94825
rytisss/SPbPUWinterSchool
/third_assignment/home_work.py
2,286
3.59375
4
import numpy as np import pandas as pd from sklearn.model_selection import train_test_split from sklearn.preprocessing import MinMaxScaler from sklearn.svm import SVR from sklearn import metrics def analyze(): """ use the dataset you've found yesterday and see what you can do with any algorithm you are we...
836a83360fdff65d8c9bd81668dcfc14411d849d
tgardela/battleships
/app/game/ship_placement.py
1,383
3.9375
4
from .ship import Ship def get_board_with_ships_placed_randomly(): board = get_empty_board() ship_sizes = [5, 4, 3, 2, 2, 1, 1] for size in ship_sizes: name = get_ship_name(size) board = get_board_with_ship_placed(board, size, name) return board def get_ship_name(size): ships = {...
bf9b2e171072f2921e33424a23cb2a125e853d7d
JesusUrtasun/Bioinformatics
/Introduction_to_Python/Introduction_Python_part2/Week_3_Pandas_Worksheet.py
2,278
4
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Apr 24 16:39:20 2020 @author: stephen """ import pandas as pd import numpy as np # ============================================================================= # [1] Reading in a CSV file # ==============================================================...
766655e45a19106e8ba29079aac7ed763261f043
bmuha1/holbertonschool-web_back_end
/0x00-python_variable_annotations/8-make_multiplier.py
289
3.625
4
#!/usr/bin/env python3 ''' Return a function that multiplies a float by itself ''' from typing import Callable def make_multiplier(multiplier: float) -> Callable[[float], float]: ''' Return a function that multiplies a float by itself ''' return lambda x: x * multiplier
2e21c5f9cde84b02370c12f0c17daa41d5c56b10
sseun07/pythonBasic
/Lecture3.py
1,369
4.71875
5
''' Where do you use for-loop? RANGE-함수 - range(a,b) *a is optional (is inclusive) // a 보다 크거나 같고, b 보다는 작은것 - create list ''' for each in range(16,25): print(each) l=[1,2,3,7,10,20,35] print(l[0]) for each in range(len(l)): print(l[each]) ''' len=length of the list ''' ''' NEGATIVE INDEX l[-1] : 뒤에서 첫번째 ...
ecc8b9f61a8f3ff4377112dd7220b80b601eac53
theja-mitta/pythonProject
/synopsis_nlp_parser.py
1,084
3.78125
4
import re import nltk from nltk.corpus import stopwords from nltk.tokenize import word_tokenize nltk.download('stopwords') def synopsis_parser(synopsis): # Remove punctuation text = re.sub('[^a-zA-Z]', ' ', str(synopsis)) # Converting synopsis text to lowercase text = text.lower() ...
51697b6ace3c3bcd1d27510adcda865dbff89b51
JC7642/Cis
/3/zad3/zad3.pyde
1,392
3.609375
4
def setup(): size(600, 600) textSize(80) global bialy bialy = (255, 255, 255, 255) # czasem warto stworzyć zmienną dla powtarzającego się elementu tak po prostu dla czytelności def draw(): print(pmouseX,pmouseY) clear() if keyPressed: if (key == CODED): if (keyCode == 37...
b584f1c718ad2ac0c831d4bf9c39ab2357b5f009
NHenkel/LPTHW
/Ex_36_final_version.py
5,219
4.15625
4
def start(): print "Wanna go on an adventure?" choice = raw_input("> ") if "yes" in choice or "Yes" in choice: adventure_time() else: dead ("You're a goddamn couch potatoe. ") def adventure_time(): print "Would you rather go on a survival trip or travel in time?" choice = raw_inpu...
575a0095523dd275b7e6a5f89266f4feae0afdbb
UCD-pbio-rclub/Pithon_JohnD
/July_18_2018/Problem_1.py
803
4.125
4
# Problem 1 # Write a function that reports the number of sequences in a fasta file import string import re import glob def fastaCount(): files = glob.glob('*') filename = input('Enter the name of the fasta file if unsure, enter ls for \ current directory listings: ') if filename == 'ls': for i in...
2d785931c5c1b868996879b436dfd48b9788a0d6
UCD-pbio-rclub/Pithon_JohnD
/July_18_2018/Problem_5.py
543
3.5
4
# Problem 5 # Create an instance of your 'Organism' class from last week. # Demonstrate pickling it to a file, and loading it from the file. # Note: when opening the file you may need to add the 'b' option import sys, pickle sys.path.append('/home/pi/Documents/Pithon_Directories/Pithon_JohnD') from July_11_2018.Proble...
739246247aff2cb821b435d4f74832615f5769a2
ChipEagle/python
/evenOdd.py
216
3.9375
4
for num in range(1,21): if num == 4 or num == 13: print (str(num) + " unlucky") elif num % 2 == 0: # even print (str(num) + " is even") else: print (str(num) + " is odd")
48f3487afa5f86416d96d285524e26c351c2c008
reginald1992/PythonFoundation
/PythonBasis/FunctionalProgrammingDecorator.py
3,850
3.953125
4
""" 装饰器Decorator:在代码运行期间动态增加功能的方式 """ # 函数也是一个对象,可以幅值给变量,所以通过变量也可以调用该函数 def now(): print('2018-5-30') f = now f() print(now.__name__) print(f.__name__) ''' 假设我们要增强now()函数的功能,比如,在函数调用前后自动打印日志,但又不希望修改now()函数的定义, 这种在代码运行期间动态增加功能的方式,称之为“装饰器”(Decorator) 本质上,decorator就是一个返回函数的高阶函数。所以,我们要定义一个能打印日志的decorator,可以定义如下: ''...
4cae14c7bc79058cc405ab09c1d622b1e07e2f2a
reginald1992/PythonFoundation
/PythonBasis/FunctionalProgrammingPartialFunction.py
1,316
4.46875
4
""" 偏函数--functools.partial的作用:把一个函数的某些参数给固定住(也就是设置默认值),返回一个新的函数,调用这个新函数会更简单。 """ import functools print(int('123456')) print(int('123456', base=8)) print(int('123456', 16)) print(int('101001', 2)) def int2(x, base=2): return int(x, base) print(int2('100000')) print(int2('101010101')) ''' functools.partial就是帮助我...
e56796b8794cabe350dfeeede633770c75f12f6d
Louis-Saglio/getter_setter_maker
/getter_setter_maker.py
4,698
3.671875
4
from write_in_file import insert_line_into_file, iter_file def create_class(verbose=False, nom_classe=None, input_attributs=None, tab=' '): if verbose: nom_classe = input("Entrez le nom de la classe: ") input_attributs = input("Entrez le nom des attributs séparés par des virgules: ") i...
a10c25b126621083b7239540fd2ed8ce9e600637
kalteherz/CodeWarsPython
/Molecule to atoms.py
1,183
3.5
4
import re import string pos = 0 def parse_molecule (formula): formula = "(" + formula + ")1" reg = re.compile("[A-Z][a-z]?|\[|\]|\(|\)|\{|\}|\d\d*") lexemes = reg.findall(formula) global pos pos = 0 def calc(): curr = {} global pos while pos < len(lexemes): ...
55957beaca9fd95a6a92e1cf1270650c3f0e139f
kalteherz/CodeWarsPython
/Next bigger number with the same digits.py
814
3.515625
4
def next_bigger(n): nstr = str(n) i = len(nstr) - 2 while i >= 0: j = i + 1 min = -1 while j < len(nstr): if int(nstr[j]) > int(nstr[i]): if (min == -1) | (int(nstr[min]) > int(nstr[j])): min = j j += 1 if not min ==...
3ac42406636240fd6288fb92b5f94501fe084125
kalteherz/CodeWarsPython
/Swap Row In Certain Columns of a Matrix.py
195
4.03125
4
def swap(matrix, row1, row2, *columns): for i in columns: matrix[row1][i], matrix[row2][i] = matrix[row2][i], matrix[row1][i] return matrix print(swap([[0, 1], [2, 3]], 0, 1, 0))
4ee9614800883048a408c931f0c947c990fc58ae
Aditya-kiran/Coding-practice
/coding_practice/tarjan_algorithm.py
2,522
4.0625
4
import collections from typing import List """ Algorithm used: Tarjan's Algorithm Tarjan's algorithm is based on depth first search (DFS). The vertices are indexed as they are traversed by DFS procedure. While returning from the recursion of DFS, every vertex V gets assigned a vertex L as a representative. L is a ver...
1496641047dfa29cc96599af9ff1bf2663ab0c06
maulik04/Programs_Python
/6.py
680
4.09375
4
#!/usr/bin/python -tt ####################### MAULIK BHENSDADIA ##################### def main(): name = str(raw_input("Enter a word: ")); ## CLI INPUT print len(name) vowels = 0 for character in name: ## Match vowel character in INPUT if character == 'a': vowels += 1 if character == 'e...
038361bd1621e24b6de9d87502e3d23f9da71f2d
venkatbalaji87/python-latest-task
/python/upperCaseProblem.py
236
3.796875
4
NumberOflines =[] while(True): getInput = input() if(getInput): NumberOflines.append(getInput.upper()) else: break print("Upper Case Values : \n") for getInput in NumberOflines: print(getInput)
8c5fb021a9d884ef31b164d528cd5c5a1222ba3f
venkatbalaji87/python-latest-task
/python/commaSeparator.py
120
3.59375
4
splitValues =[x for x in input("Enter the values to be sorted : ").split(",")] splitValues.sort() print(splitValues)
b618cf67d2f53031398a98f32b4edd75ba56b2bc
algakovic/PSO_Database
/tracker
2,237
3.578125
4
#!/usr/bin/env python '''Program to interact with PSO_DATABASE''' import sys from subprocess import call import sqlite3 conn = sqlite3.connect('pso_database.db') c = conn.cursor() '''Display all tables in relational database''' def print_tables(table): print(table) # Prints Table Header for row in c.execute...
6e37b693f045257bdac3220b19838b82a6b8ae44
HduiOSClub/HduiOSClub
/projects/闭文峰/Python/BWFwk1.py
1,271
3.734375
4
#!/usr/bin/python3 # -*- coding: UTF-8 -*- print ("Hello,World!"); #输出hello world sum = 0; #1-100的和 sum = ((1+100)*100)/2; print (sum); def FBNQ(n): #斐波那契数列 if n <= 0: return 0; elif n == 1: return 1; else: return FBNQ(n-1) + FBNQ(n-2); print (FBNQ(5)); def yanghui():...
87035c49aab60c7267e821943494132e722f97ec
Atul-Bhatt/Advanced-Python
/numeric.py
1,027
4.09375
4
# demonstrate objects number like behavior (operator overloading) class Point(): def __init__(self, x, y): self.x = x self.y = y # TODO: define repr function def __repr__(self): return f"<Point {self.x}, {self.y}>" # TODO: define add function def __add__(self, other): ...
ec073794a0367a46b404487724df61896ea8fd79
Atul-Bhatt/Advanced-Python
/customized_logging.py
911
3.578125
4
# demonstrate the use of customized logging import logging def anotherFunction(): logging.debug("This is another function.") def main(): # TODO: define the format string frmtstr = "%(asctime)s: %(levelname)s: %(funcName)s Line:%(lineno)d %(message)s" datestr = "%m/%d/%Y %I:%M:%S %p" # TODO: set...
402fbd754c53584ec8400f07a3c697f5c07e1b94
Atul-Bhatt/Advanced-Python
/itertools.py
1,304
4.28125
4
# advanced iterator functions in ther itertools package import itertools def testFunction(x): if x > 40: return False return True def main(): # TODO: cycle iterator can be used to cycle over a collection names = ["John", "Casey", "Nile"] cycle_names = itertools.cycle(names) print(nex...
16d3e19b342bdef345e1ca4a3529b844f467ff32
binex-dsk/law-enforcer
/constants/db.py
2,811
3.546875
4
from tables import conn def exists(table, values): # I could do this way better but this works """Checks if a row exists in a table. Params: table (sqlalchemy.Table): The table to check. values (dict): Values to check for existence. Return value: Whether the table exists or not (bool).""" ...
b84b69e4445cac8c2923c8f474ba1ba48120c3a6
schwerdt/Yahoo_and_API
/exercise1.py
3,568
3.9375
4
import urllib import sys import csv import datetime #The base url for yahoo finance to get stock prices is stored as a global #Update it here if it ever changes yahoo_url ="http://real-chart.finance.yahoo.com/table.csv?s=" def compute_stock_data(): #Ask the user for a ticker symbol, starting and ending dates ti...
d7a9c644b5954165f8c2eeca20dd9d988a0d1be6
wongstein/machine_learning_experiments
/PCA_features.py
2,945
3.53125
4
from matplotlib.mlab import PCA as mlabPCA from matplotlib import pyplot as plt from sklearn import decomposition from library import database def do_PCA_analysis(experiment_name, transformed_data, feature_header, city_id, number_components = None, graph_classification_list = None): #PCA pca = decomposition.P...
0a2ec74b681d34d78fff26dad5ee7599e538e590
weida8/Practice
/TreeConvert.py
2,460
4.15625
4
# File: TreeConvert.py # Description: HW 9 # Student's Name: Wei-Da Pan # Student's UT EID: wp3479 # Course Name: CS 313E # Unique Number: 50595 # # Date Created: 11/19/15 # Date Last Modified: 11/20/15 #class that create a binary tree class BinaryTree(object): def __init__(self, initVal): ...
22b618ffe23104007b7127fd4326682b6b0492ab
weida8/Practice
/smallmult.py
232
3.71875
4
def main(): check = False start = 20 while(check == False): for i in range(1, 21): if(start%i != 0): start +=1 #print(start) check = False break elif(start%1 == 0): check = True print(start) main()
a7d90e46da7880d9d7c5254e93e115251603bb19
weida8/Practice
/Books.py
4,631
3.953125
4
# File: Books.py # Description: Assignment 13 # Student Name: Wei-Da Pan # Student UT EID: wp3479 # Course Name: CS 303E # Unique Number: 51630 # Date Created: 5/4/15 # Date Last Modified: 5/6/15 def main(): # Create word dictionary from comprehensive word list comp_dict=create_word_dict() word_dict1=...
6333f1a77be500de703c9305180ddfb187599a68
weida8/Practice
/playpoker.py
12,819
3.96875
4
# File: playpoker.py # Description: homework assignment 3 play poker # Student's Name: Wei-Da Pan # Student's UT EID: Wei-Da Pan # Course Name: CS 313E # Unique Number: 50595 # # Date Created: 9/23/15 # Date Last Modified: 9/26/15 #I've had a really rough week and didn't get a chance to really work on this un...
862235b53165af3ae2939b342c2968ed12b89f27
Andriy-Hladkiy/ITEA_Python_Advance
/lesson_1/task/task_two.py
221
3.9375
4
country_dict = { 'Ukraine': 'Kiev', 'Russia': 'Moskow', 'USA': 'Washington', } country_list = ['Ukraine', 'Poland', 'USA'] for i in country_list: if i in country_dict: print(country_dict.get(i))
07c01bfed722a2d6816db0844a701ce9aa46d5af
cwkoss/RandomCode
/euler2.py
834
4.09375
4
#!/usr/bin/env python def fib(below): """ Return fibonacci as infinite iterator. >>> [x for x in fib(10)] [1, 1, 2, 3, 5, 8] """ a = 0 b = 1 while True: a, b = b, a + b if a >= below: return yield a def strat(below, multiple): """ Sum up al...
9f36d71dc7a3d0e17925d7ab47292a1acddabc7c
cwkoss/RandomCode
/euler25.py~
447
3.984375
4
#!/usr/bin/env python def fib(): """ Return fibonacci as infinite iterator. >>> [x for x in fib(10)] [1, 1, 2, 3, 5, 8] """ a = 0 b = 1 while True: a, b = b, a + b yield a def fibsize(mx): termnum = 1 for x in fib(): print termnum, x, len(str(x)) ...
4dd04c32ef48080abccfa10dba2c2fd29da42428
spencerT101/Flask_Calculator_Homework
/modules/calculator.py
256
3.75
4
def add(number_1, number_2): return number_1 + number_2 def subtract(number_1, number_2): return number_1 - number_2 def multiply(number_1, number_2): return number_1 * number_2 def divide(number_1, number_2): return number_1 / number_2
f356cdb6113fd2cc22d315f8cba8875327760c12
rivwoxx/python-Le
/exs/bi7.py
501
4.25
4
''' Escribir un programa que determine si un año es bisiesto. Un año es bisiesto si es múltiplo de 4 (por ejemplo 1984). Los años múltiplos de 100 no son bisiestos, salvo si ellos son también múltiplos de 400 (2000 es bisiesto, pero; 1800 no lo es). ''' def is_leap(year): if (year % 100 != 0 or year % 400 == ...
e3239f777cb603ec6ce33241242d1a9803f3c84b
rivwoxx/python-Le
/exs/col.py
1,126
3.984375
4
payment = 1000 av = float(input('Write you average c: \n')) while av > 10: av = float(input('Write you average c(In must be less than 10): \n')) if av >= 9.0: pyment = payment - (payment*0.2) print('You have 20% discount, you should pay: {}'.format(pyment)) elif av >= 8.0: pyment = payment - (payment ...
9e10e7d54efcef450d71c8fab28c4f59e5e4d04a
rivwoxx/python-Le
/exs/loops/loop1.py
475
3.78125
4
for i in range(11): print(i) print('') for i in range(10,0,-1): print(i) ix = 0 while ix < 11: # for i in range(11,0): print(ix) ix+=1 print('') ix = 10 while ix > 0: # for i in range(11,0): print(ix) ix-=1 var = 0 while var < 101: if var == 50: print('Hola yo soy el número ...
9e83de99094f6448a5b338363353762a57d14cb0
rivwoxx/python-Le
/oldstuff/reallyoldstuff/p1.py
725
4.0625
4
print "Hola, mi nombre es P1" nombre = raw_input ("Cual es tu nombre:") print "Un placer conocerte" + nombre Ayuda = raw_input ("Dime en que puedo ayudarte"+ nombre) print "Puedo ayudarte a buscar la tabla de multiplicar de varios numeros" numero = int(raw_input("Dame el numero de la tabla de multiplicar: ")) for x in...
58f9e931851b90d4c122f11b3590794ee7a0da28
rivwoxx/python-Le
/oldstuff/reallyoldstuff/PythonEx/IF/BMIcalc.py
214
4
4
name = "Paci" height_m = 2 weight_kg = 115 bmi = weight_kg /(height_m ** 2) print("bmi: ") print(bmi) if bmi < 25: print(name) print("is not overweight") else: print(name) print("is overweight")
382b2c0a01539c13eb8d19b9fd74c3e4054ec1eb
FarSayghani/HU_Programming
/les06/Oefening6_2.py
243
3.65625
4
getallenlijst = [2, 4, 6, 8, 10, 9, 7] zoekgetal = int(input('Geef getal: ')) gevonden = False for getal in getallenlijst: if getal == zoekgetal: gevonden = True if gevonden: print('het zoekgetal zit in de getallenlijst')
ceb54fc11fb89d2f1e5208bcbbd8c402f4da44b5
hl921/206final
/206_data_access.py
15,926
4
4
###### INSTRUCTIONS ###### #### Follow the Option 2 instructions for the SI206 final project. #### You are required to define a class Movie. It should accept a dictionary that represents a movie and have 3 instance variables and 2 methods. You need to save the each movie by saving it in instance variable or a defin...
ab1e1217e4bab37f1e071aafeef110dc1622ec48
CodecoolKRK20173/erp-mvc-hania-szymon
/model/inventory/inventory.py
2,844
3.765625
4
""" Inventory module Data table structure: * id (string): Unique and random generated identifier at least 2 special characters (except: ';'), 2 number, 2 lower and 2 upper case letters) * name (string): Name of item * manufacturer (string) * purchase_year (number): Year of purchase * durabi...
0f751485d08c2cef60bf1becd6279e8672dbc737
torzewicz/Space-Invaders
/alien.py
563
3.515625
4
import pygame from pygame.math import Vector2 class Alien(object): def __init__(self,game,x,y,add): self.game = game self.speed = 0.15 self.x = x self.y = y self.add = add self.toDestroy = False def move(self): self.x += self.speed + 0.02 * self.add ...
55e3fdb3e74b84f64e6bfc288f4a68b43001a38b
CharlieRider/project_euler
/problem4/problem4.py
960
4.40625
4
""" 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-digit numbers. """ def is_numeric_palindrome(n): str_n = str(n) if len(str(n)) % 2 == 0: first_split_reve...
84e3b629ed8fdb79e5d1a251b560ee10d8aaa3cb
jiedwards/ProgrammingChallenges
/Udemy/Python Data Structures and Algorithms/ArrayPairSum.py
253
3.515625
4
''' Given an integer array, output all the unique pairs that sum up to a specific value k. So the input: pair_sum([1,3,2,2],4) would return 2 pairs: (1,3) (2,2) NOTE: FOR TESTING PURPOSES CHANGE YOUR FUNCTION SO IT OUTPUTS THE NUMBER OF PAIRS '''
d8619ef32b3bfba59b5ce99ac306f69ea1a4ddf2
jiedwards/ProgrammingChallenges
/Udemy/Python Data Structures and Algorithms/UniqueCharacters.py
531
4.03125
4
''' Unique Characters in String Problem Given a string,determine if it is compreised of all unique characters. For example, the string 'abcde' has all unique characters and should return True. The string 'aabcde' contains duplicate characters and should return false. ''' def uni_char(s): uniqueLetters = set() ...
8dc59f988209b15a37ebf3d8a31ebc32355cb6e6
jiedwards/ProgrammingChallenges
/CodeWars/CountCharacters.py
199
3.890625
4
def count(string): letterMap = {} for letter in string: if letter in letterMap: letterMap[letter] += 1 else: letterMap[letter] = 1 return letterMap
8fd2d8ad2103e6aa4e927dd17586a11563d19f07
trmckean/ExerciseLog
/Backend/DailySwimLog.py
1,048
3.546875
4
# SwimLog keeps track of swimming activity # Imports # Class representing a daily log object i.e. the log containing date, yards, and minutes class DailySwimLog: # Init with day, yards, and minutes def __init__(self, date, yards=None, minutes=None): self.date = date self.yards = yards ...
302c9f7a3f2057d4f23f9a10fefce241f84dd6d6
sabinzero/various-py
/program nicu/main.py
148
4.15625
4
n = input("how many numbers: ") numbers = [] for i in range(n): num = input("number[%d]: " % i) numbers.append(num) print numbers
e3b2ea406823f0843bf6abb13b4acc0f8f07843a
sabinzero/various-py
/operations/main.py
254
4.1875
4
a=input("enter first number: ") b=input("enter second number: ") c=input("enter third number: ") S=a+b+c print "sum of the numbers = %d" % S P=a*b*c print "product of the numbers = %d" % P A=(a+b+c)/3 print "average of the numbers = %f" % A
95f7f7f121e468e55525dcfb510b2cf27e2637be
sabinzero/various-py
/to upper case/main.py
110
4.0625
4
letter = input("give letter to upper case it: ") print "the upper of %s is %s" % (letter, letter.upper())
5ddfc4aaf608997c4f91b66b9ecc0fff0dfce53b
sabinzero/various-py
/descending order/main.py
106
3.609375
4
a=input("a= ") b=input("b= ") if a>b: print "%d , %d" % (a,b) else: print "%d , %d" % (b,a)
a090f50bee3b3f2a57726d560582ae0e97524071
sabinzero/various-py
/prime number/main.py
210
4.15625
4
from math import sqrt num = input("enter number: ") x = int(sqrt(num)) for i in range(2, x + 1): if num % i == 0: print "number is not prime" exit(0) print "number is prime"
c8a8a22d0eec20ab17a33be6e1530e40e58658a6
sabinzero/various-py
/catalog/main.py
172
3.96875
4
student_name=input("give student name: ") n=input("get mark: ") while n > 10 or n < 1: print "the mark must be between 1 and 10" n=input("get mark: ")
7043c0f490f15aad3fd427e1e1edec4a1c3d5ebc
choigabin/Certificate_Cospro
/cospro_winter2/day02/g16.py
385
3.515625
4
#배열에서 k보다 큰 사람 def solution(height, k): answer = 0 n = len(height) for h in height: #키 배열의 길이만큼 포문 돌리기 if h > k: #h가 k보다 크다면, answer += 1 #answer에 1 증가 return answer height = [165, 170, 175, 180, 184] k = 175 ret = solution(height, k) print("함수의 반환값은 ", ret, "입니다.")
91b09cff879a3e4b5335d468313d19f3f0fe76c5
choigabin/Certificate_Cospro
/cospro_winter2/day02/g19.py
571
3.578125
4
#거스름돈을 리턴하는 함수 작성 def solution(price, money): sum = 0 for i in range(len(price)): #가격 리스트의 길이만큼 포문 돌리기 sum += price[i] #리스트의 모든 요소들의 합 구하기 if sum <= money: #가진 money가 sum보다 크다면 answer = money - sum #money - sum 계산하기 return answer else: #money가 sum보다 작다면, return -1 #-1 리턴...
b6c3e79133f73744769bc5dbd404b6da5453c5fb
choigabin/Certificate_Cospro
/cospro_winter2/day02/m01_08.py
479
3.78125
4
#거꾸로 읽어도 같은 회문을 확인하는 함수 수정하기 def solution(sentence): filtered = [] for s in sentence: if s != '' and s != '.': #s가 공백이거나, 온점이면, filtered.append(s) before = ''.join(filtered) #리스트를 문자열로 변환 print(before) filtered.reverse() after = ''.join(filtered) print(after) return b...
568087c96981ceed364dbaaaa77a61a3a0460402
hubls/p2_201611092
/w5Main.py
124
4
4
print "triangle!" print "input" q=raw_input("size:") q=int(q) for i in range(q): print " "*(q-i)+"*"*(i*2-1)
27c819d266511650232195444c632ad2ab79b4d2
hubls/p2_201611092
/w12main.py
2,804
3.96875
4
def writePythonTextFile(): myfile=open('python.txt', 'w') line1='Python is a widely used high-level, general-purpose, interpreted,\n' myfile.write(line1) line2='dynamic programming language.[23][24]\n' myfile.write(line2) line3='Its design philosophy emphasizes code readability, and...
e75f3868f08fdf866d2349ea8d5159fa0f998029
vis7219/Rosalind_Algorithms
/Complementing_A_Strand_Of_DNA.py
625
3.5625
4
# -*- coding: utf-8 -*- """ Created on Fri May 7 21:54:32 2021 @author: VISHAKMADHWARAJKADAM This python script contains code for getting a complementing strand of a given DNA Strand """ import os os.chdir('E:/Downloads') # Opening the Rosalind File DNA = open('rosalind_revc (1).txt', 'r') DNA = DNA.read() # Find...
3fc385ecf233e607d5d9ea30a3c1260463e36c91
jlisi321/Python-Learning-Programs
/coinCount.py
1,783
4
4
import math print("Coin Counter") #asking what the measurment will be weight_type = int(input("Are you measuring in grams(1) or pounds(2):")) #getting the weight of the coins print("\nEnter the weight of the coins you have below") pennies_weight = int(input("Pennies:")) nickles_weight = int(input("Nickles: ")) dimes_...
6b3cc99aeca778ebce79fcb8077fcd01cfb3a21d
mc256/Genomic_Tandem_Repeat_Detection
/play.py
1,696
3.578125
4
class Node: leaves = [] nodes = [] value = "" def __init__(self): self.leaves = [] self.nodes = [] self.value = "" pass def checkNodes(self, st): for idx in range(0, len(self.nodes)): if self.nodes[idx].value == st[0]: self.nodes[...
1270e97559ebdf7057a85873f3d1807e29ee74f6
1019350030wfj/python_demo
/house_payment_equality_corpus_interest.py
341
3.59375
4
# coding=utf-8 """ 等额本息 总支付利息:237096.11 本息合计:617096.11 每月 2571.23 总共240个月 """ initial_payment = 2571.23 total_month = 240 sum = 0 counter = 1 while counter <= 240: sum += initial_payment counter += 1 print("等额本息:第1月 到 第%d月 贷款总和为:%.2f " % (counter-1, sum))
93455efbdb07a6a3cb4a26b240f133b824138ce1
yinghsienwu/MachineLearningUdacity
/smartcab/smartcab/agent_2states.py
4,997
3.5
4
import random from environment import Agent, Environment from planner import RoutePlanner from simulator import Simulator class LearningAgent(Agent): """An agent that learns to drive in the smartcab world.""" def __init__(self, env): super(LearningAgent, self).__init__(env) # sets self.env = env, sta...
1d4dbbd05c87e7e6c175bf0c3950f6f9d444f3ed
KKrishnendu1998/NUMERICAL_METHODS_ASSIGNEMENT
/fibonacci_module.py
566
4.28125
4
'''it is a module to print first n fibonacci numbers creator : Krishnendu Maji ''' def fibonacci(n): # defining the function to print 1st n fibonacci numbers# a = 0 #the value of 1st number# b = 1 #the value of second number# i = 0 print('first '+str(n)+' ...
d985bd409b90cfd33fad5be448e9ac73ce0fee85
KKrishnendu1998/NUMERICAL_METHODS_ASSIGNEMENT
/unicode2.py
228
3.921875
4
'''programme to compute the sum of the unicode code points creator : Krishnendu Maji ''' S='mumbai' sum=0 for i in S: sum+=ord(i) print("the sum of the Unicode code points of the characters in S : ",sum) # printing the sum #
89c0367f41e76e87b8b5ef8ec7729d25b88a56ec
dineshmane/Python-For-DS
/04 Codes/select.py
432
3.734375
4
import sys if sys.argv[1]=="" : print("please enter the file name") else: try: f1 = open(sys.argv[1],"r") list1 = [] for i in f1.readlines(): list1.append(i.strip()) for i in sys.argv[2:] : print(list1[int(i)-1]) except FileNotFoundError as e: ...
d84bd80d0650043bd55efe8b291c57515ed41a62
pichuang/programming_in_python3
/iterators/iterators-5.py
593
3.6875
4
__author__ = 'roan' ''' Iterating in Reverse http://chimera.labs.oreilly.com/books/1230000000393/ch04.html#_discussion_61 ''' class Countdown(object): def __init__(self, start): self._start = start def __iter__(self): num = self._start while num > 0: yield num ...
b8d40fc717dbf5a350141e86bc16d1ceb1fe7e3a
sagar376/Program_for_life
/Cassandra/Missing_Subscriber/Find_and_replace.py
1,217
3.578125
4
def listToString(s): # initialize an empty string str1 = [] # traverse in the string for ele in s: str1 += ele # return string return str1 f = open("Test_file.txt", 'r') filedata = f.read() # replace_list = [31800009785, 31800019785, 31800029785, 31800039785, 31800049785, 3180005...
e81efc8f25e2edf7f11b24744da7c5b711e1be40
victorsznifer/dessoft1
/aluno2.py
102
3.609375
4
def maior(lista): a=lista[0] for x in range(1,len(lista)): if lista[x]>a: a=lista[x] return a
d8d5507549ba286ddd1de6f607f5bafdf0d38c65
CesarArellano/Curso-Python
/Clases/herencia.py
542
3.765625
4
class Animal: def __init__(self,nombre=''): self.nombre = nombre def comer(self): print("Comiendo") def dormir(self): print("Durmiendo") class Perro(Animal): #Perro hereda los atributos de la clase Animal def ladrar(self): print("Ladrando") class Gato(Animal): #Gato hereda los atributos de la clase Anim...
921a6dadda6575492671887e4109ebd21f65f82c
CesarArellano/Curso-Python
/Cadenas/busqueda.py
515
3.984375
4
mensaje = "Hola yo soy 'César'" resultado = mensaje.count("Cesar") # Cuantas veces aparece Cesar en el string resultado = "Cesar" in mensaje # Se encuentra en el string resultado = mensaje.find("César") # En que posición del arreglo aparece Cesar en la frase resultado = mensaje[resultado: resultado +len("Cesar")] #Imp...
04ec09463affa5216ff85535ddc174b5755c1618
CesarArellano/Curso-Python
/Ciclos_Condicionales/break_continue.py
170
3.640625
4
titulo = "Curso de Python 3" for caracter in titulo: if caracter == "P": continue #Termina los ciclos abruptamente, Continue: Salta al otro ciclo print(caracter)
48553e60cf30030ad805b77f4b68f6d570169728
CesarArellano/Curso-Python
/Ciclos_Condicionales/Ejercicios/5.py
1,171
3.515625
4
""" * @file 5.py * * @brief Mostrar en pantalla la palabra que más se repita junto con la * cantidad de veces que lo hace en base al texto del capítulo número uno * de Frankenstein * Nota: Tarda alrededor de 38 segs en procesar el texto * * @author Arellano Velásquez Cesar Mauricio * * @date 22/05/2019 """ import re, s...
7015c818b680c7a76f988f1ba9b1fcb25bf7162b
CesarArellano/Curso-Python
/Extras/Ejercicios/Serie 1/11.py
157
3.828125
4
num = 0 mayor = 0 while num != -99: num = int(input("Introduce un numero\n")) if num > mayor: mayor = num print("El número mayor es: {}".format(mayor))
b5a875f5d4f887e478c23ad8f2b5fa143fab3572
CesarArellano/Curso-Python
/Tuplas/comprimir.py
271
3.984375
4
tupla = (1,2,3,4,5) lista = [10,20,30,40,50] resultado = zip(tupla,lista) #resultado = tuple(resultado) resultado = list(resultado) print(resultado) """ uno,dos,tres,cuatro,cinco = tupla print(uno,dos,tres,cuatro,cinco) uno,*dos,cinco = tupla print(uno,dos,cinco) """
af4b0e4678498533e405cf15eba850115ca5d55d
CesarArellano/Curso-Python
/Extras/Ejercicios/Serie 1/4.py
247
3.859375
4
numprimo = int(input("Ingrese el número\n")) cont = 0 for i in range (1, numprimo + 1): if numprimo % i == 0: cont+=1 if cont == 2 : print("El número {} es primo".format(numprimo)) else: print("El número {} no es primo".format(numprimo))
e42397e4775f9c1309d8687462116956d91897e6
CesarArellano/Curso-Python
/Ciclos_Condicionales/condicionales.py
299
3.515625
4
color_luz = 'amarillo' login = 1 if color_luz == 'verde': print("Acceso al sistema") elif color_luz == 'amarillo': print("Alto parcial") else: print("Alto Total") variable = False if variable: print("Es verdadero") else: print("Es falso"); #False, "", '', {}, (), [], 0, 0.0 -> Valores False