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
303797671d5929a03947f9f31b29ddb5fbc1ff02
praveenkumarjc/tarzanskills
/sets.py
197
3.59375
4
basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'} print(basket) x='orange' in basket print(x) a = set('abracadabra') b = set('alacazam') print(a-b) print(a|b) print(a&b) print(a^b)
d767ec63125269174573fe75a1401b0d5de7d4b7
praveenkumarjc/tarzanskills
/lists.py
563
3.859375
4
names=['praveen','hari','nanda','salman'] print('praveen'in names) print('praveen'not in names) print('naresh'in names) print(names.index('hari')) print(names[0]) print(names[::-1]) names.append('samarth') print(names) names[2]='varun' print(names) names.remove('salman') print(names) del names[2] print(names) names.pop...
58a645546ebf6b3ad32c2b3c852f1b6fd8232a1a
Jennivine/ProgComp
/Shunting yard/infix to postfix.py
1,679
3.65625
4
stack = [] def inTopost(infix): ans = "" invalid = False for c in infix: if c.isdigit() or c.isalpha(): ans += c else: if c == "(": stack.append(c) elif c == ")": while stack[-1] != "(": ans += stack.pop...
63d3cf83a80834e6359815c6940382c3dd2de0e0
FilipElander/Master_Thesis_Semantic_Segmentation
/ImageCrop.py
1,497
3.578125
4
## Script for cropping images in an entire folder # used for fitting a dataset for Machine Learning Network # The script crops from centre of the image ## USAGE ## # Temrinal arguments: Input_folder output_folder widht height file_type # Example: ImageCrop.py /Desktop/input Desktop/output 320 320 png from glob im...
7117c1a834da1c75c4a3a6fa7013bf0c320e9e1b
McarvalhoM/Estrutura-sequencial
/12.py
96
3.515625
4
h = float(input('digite sua altura')) i = (72.7 * h) - 58 print('seu peso ideal é', (i), 'kg')
63b496f2f0687d79b109c3f29853eed992f7f7d0
McarvalhoM/Estrutura-sequencial
/6.py
88
3.640625
4
r= int(input('Digite o raio da circunferencia')) conta= (3.14*r**2) print(conta, 'm²')
1432edf98dc6ec8b15f3d32c74d4c15130a9f6c4
3dzyy/opener
/opener/__init__.py
717
3.671875
4
""" opener ====== Open the lock puzzle solver. Usage ----- Solve an open the lock puzzle:: from opener import get_keys number_of_positions = 3 invalid_digits = (5, 2, 3) similarity_conditions = ( ([9, 6, 4], 2), ([2, 8, 6], 1), ([1, 4, 7], 1), ([1, 8, 9], 1) ) invalid_positioned_values = ((9, 1), (6,...
43cea9201f8c5fba2d663b0d92d3571b2599cca1
Nitish-Kamath/Python-Real-World-Project
/emailsender/01.py
571
3.59375
4
import smtplib to = input("Enter the e-mail id of recipient:\n") content=input("Enter the content for mail:\n") def sendEmail(to,content): server=smtplib.SMTP('smtp.gmail.com',587) # gmail service uses 587 as port number server.ehlo() #make the communication between the smtp server of gmail server.s...
fa84dc59b86523f30bcf87e0aff56368dc5cc9ed
dmxj/icv
/tests/test_jiahe.py
121
3.59375
4
N = 10 i = 0 total = 0 while i < N: x = float(input()) if 100 <= x <= 200: total += x print(total)
3fb2aadaca4c4070255960c3f7e3899259080843
poozzab/datastructures
/trees/problems/examples/NamedTuple.py
503
3.796875
4
# example code from a hackerrank problem that utilized namedtuple # this is being archived in my github so that I can remember how awesome this feature is # https://www.hackerrank.com/challenges/py-collections-namedtuple/ from collections import namedtuple N = int(input()) n = N Student = namedtuple('Student',input())...
de9d9a7f7a64de35f448b0457e03745a590fe0d3
greghaskins/multi-raffle
/raffle.py
1,676
3.96875
4
#!/usr/bin/env python import random # ------------------ # Raffle algorithm # ------------------ def raffle(number_of_winners, entries, random_source): winners = set() # hold unique values only hat = list(entries) while len(winners) < number_of_winners: hat_size = len(hat) if ha...
3a36cc505ef104ee060be86f81675f1cb7f7e5e1
tmrob2/LearningAndReasoning
/helpers_tutorials/decorators_ex.py
570
3.5
4
import time def time_it(f): def inner(*args, **kwargs): start = time.time() result = f(*args, **kwargs) end = time.time() print(f.__name__+' took: '+str((end-start)*1000)+' ms') return inner @time_it def calc_square(numbers): result = [] for number in numbers: r...
4f185354ba8a87e65a6ce207ec54c40d5a7d0cb2
jrexmo/Old-Code-Jams
/trouble_sort.py
963
3.671875
4
def quick_trouble(ints): list1 = [] list2 = [] for i in range(len(ints)): if i%2 ==0: list1.append(ints[i]) else: list2.append(ints[i]) list1 = sorted(list1) list2 = sorted(list2) a = [] first_current = 0 second_current = 0 for i in range(len(i...
b6feb00cb4dc6e1503b7ad48f9878087107a6058
ohiliazov/kpi
/algorithms/task_bubble_sort.py
1,957
3.953125
4
import random BUBBLE_COMPARISONS = BUBBLE_ASSIGNMENTS = 0 def bubble_sort_swap_flag(array): global BUBBLE_COMPARISONS, BUBBLE_ASSIGNMENTS length = last_swap_index = len(array) for i in range(length - 1): is_sorted = True for j in range(1, last_swap_index): BUBBLE_COMPARIS...
e2871a487a2d343ae87f5e3d67fba48278e48938
ohiliazov/kpi
/programming/term2/kp3.py
5,196
3.78125
4
import math import matplotlib.pyplot as plt class Point: def __init__(self, x: [int, float], y: [int, float]): self.set_x(x) self.set_y(y) def __str__(self): return f"Point({round(self.x, 2)}, {round(self.y, 2)})" @property def coordinates(self): return self.x, self.y...
1b97e333ed94444488c776e1d042ddd21046997b
ohiliazov/kpi
/programming/term1/polish_calculator.py
5,811
3.734375
4
""" Курсова робота Тема: Калькулятор. За заданим символьним рядком з математичною формулою обчислити значення функції в заданій точці (з використанням польського інверсного запису) Виконав: Гілязов Олександр Ігорович Група: ІС-зп81 """ import argparse import math import operator MATH_CONSTANTS = { "e": math.e, ...
294f585a3157c00ac9715652d820869dd4494586
EvilminexD/Mision_06
/Mision 6 (Imposible).py
1,950
3.5
4
# Autor: Ithan Alexis Pérez Sánchez, A01377717 # Descripción: Mision 6 # El codigo empieza después de esta linea import math import random import pygame ANCHO = 800 ALTO = 800 BLANCO = (255, 255, 255) NEGRO = (0, 0, 0) def dibujar(r, R, L): pygame.init() ventana = pygame.display.set_...
2b562c8f799a4904304bf0b5828b2fbf2c41bdde
muppet2011ad/ADS1920-Coursework
/q1.py
2,588
3.515625
4
# q1.py written by jsbl33, December 2019 # Tested using Python 3.8.1 (because that's what happens to be in the Manjaro repos) # If buckets cannot be found, the function will output this in the console. def hash_quartic(keys): table = ["-"]*23 # Initialise hash table array for key in keys: # Iterate over t...
c20845c4ad6b70154c6c470028b39c4d2de269e5
thiagohissa/BalanceSheetAnalysis
/Finance/financial.py
1,896
3.859375
4
import math class Financial: @staticmethod def calcROI(roi): print("Calculating ROI...") avg1 = roi[1] avg5 = avg10 = 0 for i in range(1, (len(roi)-1)//2): avg5 += roi[i] for i in range(1, len(roi)): avg10 += roi[i] avg1 = round(avg1) ...
c9929ad011e4fd48d0ea759928b49d4303c0e6d2
amanji/quartet_phylogeny_algorithm
/searchtree.py
1,895
3.578125
4
class SearchTree: def __init__(self, rootid, subtree_edges): self.left = None self.middle = None self.right = None self.leftlist = [] self.middlelist = [] self.rightlist = [] self.rootid = rootid self.subtree_edges = subtree_edges def getLeftChild(self): return self.left def getMiddleChild(self):...
cf4d0104a7f73ba9e519df0dc91acab1ea4a08c0
RishiMagudia/VROC-Treasure-Hunt
/classes/map.py
1,037
3.859375
4
class Map: #initializing variables def __init__(self): self.sList = [] self.pList = [] #blitting/printing the prioritized list of items def drawMap(self, screen): for m in range(len(self.sList), 0, -1): img = self.sList[m-1].getImage() pos = self...
21c27b2235971f513118300efce2bd1c65298d4e
Sathathinesh/Semester_06
/CO544 Machine Learning and Data Mining/LAB03/ex1.py
1,541
3.890625
4
# CO544 - Machine Learning and Data Mining # Lab 04 - Exercise 01 # E/15/366 #Importing numpy module import numpy as np #Importing pandas module import pandas as pd from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split from sklearn.datasets import load_iris #Importing ...
6996d908c879d262226ff1601ba70f714c861714
Olb/python_call_analysis
/Task2.py
2,634
4.15625
4
""" Read file into texts and calls. It's ok if you don't understand how to read files """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 2: Which telephone number spent the ...
dae3601858aa1cf63334507dfe1f58661f2fec8e
jpowelliv/Object-Oriented-Programming
/ceasarcyrpt/caesar_decrypt.py
460
3.84375
4
#Joseph Powell #CIS 225-01 #9/25/18 #decode to words def main(): message = input("Lets decode! ") #loop for letter in message: ch = chr(ord(letter)-1) print(ch, end=" ") main() '''#decode to numbers def main(): message = input("Enter the message to decode:...
b79f29d6fdee99d416542975997158af50d940d0
Guilherme2020/atividadeAlgoritmo
/uri1235.py
719
3.515625
4
def main(): array = [] while True: maior = 0 try: palavra = input() sub_palavra = input() for i in range(len(palavra)): for j in range(i+1,len(palavra)): if palavra[i:j] in sub_palavra: ...
1c7d5426ceb1cf36c7052cc34872c4bd0160d238
Guilherme2020/atividadeAlgoritmo
/lista6/quest17.py
208
3.625
4
def substr(texto,comeco,qtd): sub_texto = texto[comeco:comeco+qtd] print(sub_texto) def main(): texto = input("Digite uma sentenca: ") substr(texto,2,5) if __name__ == "__main__": main()
7245ee579ff47139070f90a71984fa0f0811e6f3
Guilherme2020/atividadeAlgoritmo
/lista6/quest16.py
220
3.921875
4
def diagonal(): palavra = input("Digite uma palavra: ") espaco = "" for letra in palavra: print(espaco + letra) espaco += " " def main(): diagonal() if __name__ == "__main__": main()
80001478af3c99534e23a56925f269270eae1d35
humada05/interview_cake
/count_change.py
500
3.71875
4
''' Solution: Addapted from this link in Berkeley's CS 61a: http://composingprograms.com/pages/17-recursive-functions.html#example-partitions ''' # Code def count_change(amount, denominations): denominations.sort() return count_partitions(amount, denominations) def count_partitions(amount, coins): if amount == 0:...
566c8b0e04efd87d19c1f040dc67cb749a0cfa9c
molinapuentesmayra/ADCS_A00354816
/Lab04_A00354816/Lab2_A00354816.py
2,576
4.09375
4
# Lab 2: Analisis Diseño y Construccion de Software # Mayra Molina # A00354816 import csv # myPowerList class # defines method for a given list # methods add, remove items, sort list # merge as suffix or prefix another list, # save and read from file class myPowerList: def __init__(self, lst): self.powe...
d4e4237b028f4c5c5eddab63e1f294125bcb7d86
njager/01-Guessing
/main.py
3,098
3.984375
4
import sys, random assert sys.version_info >= (3,7), "This script requires at least Python 3.7" quit = False play_game = input("Hi! Want to play a game (Y/Yes or N/No)?") #determine play or no play play_game = play_game.lower() while play_game != "yes" or "y": if play_game == "yes" or play_game == "y": q...
8c1d7aaf2dc749ef6a7fa26872e4d1abd494795e
AdamWu1979/dwilib
/dwi/stats.py
9,078
3.53125
4
"""Statistical functionality.""" from collections import defaultdict import math import random import numpy as np from scipy import stats import sklearn.metrics import sklearn.preprocessing import dwi.util def rmse(a, b): """Root mean square error.""" a = np.asarray(a) b = np.asarray(b) return np.s...
5ff4055b84aa7837d842b955a85ed13f22f9c268
Caleb-Fu/N-queens-problem
/CISC352-group code.py
7,364
4.03125
4
import random class grid(object): #initialize each grid def __init__(self): self.hasQ = False # whether Queen is on this grid. self.threatened = 0 # threatened value. def board(size): #create a new board and accept input representing length (AxA) board=[] for i in range(...
aea2e318383bffd979bb33b479b8ddc247033938
LrpljL/leetcodes
/ex_3.py
1,201
3.78125
4
""" 给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。 输入: "abcabcbb" 输出: 3 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。 输入: "bbbbb" 输出: 1 解释: 因为无重复字符的最长子串是 "b",所以其长度为 1。 """ class Solution: def lengthOfLongestSubstring(self, s: str) -> int: if not s: return 0 # 字符串为空 n = len(s) max_length = 0 #最长子字符串长度 ...
2f75210048b8ea6e3df61dcde43f7cdf9ce4d8d7
blockjon/pythoninterviewpractice
/linkedlist-single.py
2,051
4.03125
4
class Node(object): def __init__(self, data, next_node=None): self.data = data self.next_node = next_node def get_next(self): return self.next_node def get_data(self): return self.data class LinkedList(object): def __init__(self, head=None): self.head = hea...
574d28b1fa72b6c8432f38f4415be5240bd70016
wei2060i/Helpers
/py-study/study03.py
792
4.03125
4
if True: print(2) print(29) if True: print(3) # 代码块 缩进代码块开始,结束缩进代码块结束,缩进是按 四个空格算的 print(44) # a = input("请输入内容:") # 用户输入,返回的是字符串 # print(a) if False: print("无法输出") else: print("能输出") # if-elif 注意缩进 if False: print("无法输出") elif True: print(33) else: print(44) # 多参数输出格式,前后位置无所...
c950a13fe3cebc8f569a82ef63ad98e180ef3708
yjsdut/sklearn-linear-regression
/easy_linear_example.py
880
3.640625
4
import numpy as np import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression # 产生数据 x = np.linspace(0,10,50) # 在规定的时间内,返回固定间隔的数据。他将返回“num”个等间距的样本 print(x.shape) # 0到10等间隔产生50个数 shape:(50,) 一维向量 noise = np.random.uniform(-2, 2, size=50) y=5*x+noise # 创建模型 linear =LinearRegression() # 拟合模型 lin...
52719b204d8a7905681be901d4e6b1cf175b3338
anniepod/Chapter-8-HW
/ClassWork.py
155
3.765625
4
def count_a(text, letter): count = 0 for c in text: if c == letter: count += 1 return(count) print(count_a("banana", "x"))
65dedba551cbc718ca56bc9fa7371417e9f24378
ShruthiSiva/Smart-Wheelchair
/UI/layouts.py
1,979
3.53125
4
#File name: floatlayout.py #Have to define callback functions to trigger from buttons press. # # import imageRecognition import kivy from kivy.app import App from kivy.uix.floatlayout import FloatLayout from kivy.uix.image import Image import RPi.GPIO as GPIO #Setup pins for Raspberry Pi-ARduino Interface arduino_pi...
2bfe3fa627cf773f19e3f31036b9a477cc0a620f
Emmet-Mc-Ginnity/Simple-File-Mover
/FileMover.py
3,739
4.125
4
""" A simple module to transfer files from one directory to another """ import os import shutil def get_all_files(directory): """ Returns all of the files in a given directory, including nested ones :param directory: String - directory to retrieve the files from :return: List - containing each file ...
f8bbc339348bf1407d9c3a291eca4d7f726e4536
gernd/python_code_samples
/mixed.py
200
3.5
4
# command line arguments can be handled via sys.argv import sys print("The following arguments where given:") # as in c, the first argument contains the filename for arg in sys.argv: print arg
bd96c093db3459d05694cbb8723694be69945206
TikhonovaElena/cs102
/practice/homework01/vigener.py
1,591
3.8125
4
def encrypt_vigenere(plaintext, keyword): """ >>> encrypt_vigenere("PYTHON", "A") 'PYTHON' >>> encrypt_vigenere("python", "a") 'python' >>> encrypt_vigenere("ATTACKATDAWN", "LEMON") 'LXFOPVEFRNHR' """ ciphertext = '' pos = 0 for char in plaintext: if ord('a') <= ord(c...
6720210af16c7a9fc6d534975cbbdabe9816321e
ashwinsingh30/RecessionPrediction
/DateParseres.py
756
3.53125
4
import datetime def parse_date(date): date = date.split("/") m = date[1] # if(int(m)<10): # m="0"+m d = date[0] y = date[2] return datetime.datetime.strptime(m + d + y, "%d%m%Y").date() def parse_excel_date(date): date = date.split("/") m = date[1] # if(int(m)<10): # ...
bff97089ac4d572fdffcdc00a0a6e4120ed36a75
luqasz005/testy
/kol2_gr2.py
2,418
3.96875
4
# # Class diary # # Create program for handling lesson scores. # Use python to handle student (highscool) class scores, and attendance. # Make it possible to: # - Get students total average score (average across classes) # - get students average score in class # - hold students name and surname # - Count total attend...
241f836b50ae58f6221d96256cee4167cade7973
faisalshahbaz/urduhack
/urduhack/normalization/__init__.py
708
3.5
4
# coding: utf8 """Normalization module""" from .character import normalize_characters, normalize_combine_characters from .util import punctuations_space, digits_space, remove_diacritics __all__ = ["normalize_characters", "normalize_combine_characters", "punctuations_space", "digits_space", "normalize", ...
0170ef6ab75eabba6ea5d625930e5bce55722bdc
arthursc98/Faculdade
/Linguagem de Programação I/1B.py
480
3.609375
4
x=list(map(int,input("Digite a sequencia: ").split())) soma=0 divisor=0 deno=[] if len(x)<5: print('Minimo 5 valores') else: for i in range(len(x)): if i<2: deno.append(x[i]*0.3) divisor+=0.3 elif i>=2 and i<len(x)-2: deno.append(x[i]*0.1) ...
d5fda8c93da399c8cf112cf2a3cbe46486542924
ramilsitdikov/mail_spam_filter
/bag_of_words.py
5,170
3.78125
4
# -*- coding: UTF-8 -*- import codecs import glob import random def standart_string (_str): ''' #функция очищает строку от лишних знаков пунктуации и пробелов :param _str: any string :return: lower string without disign, whitespace ''' new_str = _str.lower() new_str = new_str.strip() ne...
3f2ffd427b3ad719a82844e3962c9c1b69a4d4a9
jacqxu00/iX-Data-Science
/exercise0/prework.py
2,004
3.75
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' Jacqueline Xu iXperience 23 May 2019 Pre-Work ''' ''' “Git Can Facilitate Greater Reproducibility And Increased Transparency in Science” As replicable data is important in all scientific research, software engineering is no different. In the fast-paced innovative wor...
3ac19384376e783bbdd12f31c384efee3062c83d
mtskillman/advent_of_code_2015
/day_11.py
1,755
3.640625
4
def first_requirement(string, lookup_table): #return bool count = 1 last_value = -10 for char in string: if lookup_table[char] == last_value + 1: count += 1 else: count = 1 if count == 3: return True last_value = lookup_table...
d793538d7b901a9456a7fdcd884c14e8d70841f9
tlatkdgus1/BetaFarming
/reward_calculator/additional_lane.py
1,413
3.625
4
class AdditionLane: def __init__(self, starting_height: int, rewards_per_block: float): self._lane = 0 self._rewards_per_block = rewards_per_block self._latest_block = 0 self._reward_start_height = starting_height def update_lane(self, current_block: int, total: float): ...
59858e66eb9e86f1503fe9afb90d1186226a569a
richardmanasseh/hort503
/lpthw/ex4.py
1,427
4.40625
4
# Ex 4: Variables and Names # Variables are "words" that hold a value FRUIT = peach # # The operand to the left of the = operator (FRUIT) is the name of the variable # The operand to the right (peach) is the value stored in the variable. # A variable is similar to the memory functionality found in most calc...
6c3532589b88192fd0ff2b029cb0f9fd631aaf22
richardmanasseh/hort503
/lpthw/ex7.py
940
4.1875
4
# More Printing & Formatting print("Mary had a little lamp.") print("Its fleece was white as {}. ".format('snow')) print("And everywhere that Mary went.") print("." * 10) # Prints string (".") ten times # By default python’s print() function ends with a newline, because it comes with a parameter called ‘end’. # By def...
9fed24a2a440c14883e062c59ea8d402a52e772c
richardmanasseh/hort503
/lpthw/ex29.py
2,422
4.25
4
# What If # At the end of each working day,the balance of a bank account is considered... # IF the account is overdrawn, charges are applied to the account. # So we ask the question: is the account overdrawn? Yes (=True) or No (=False) # Algorithm: # Step 1 Define your problem: we apply charges to a bank accoun...
75bb09a361e33624f85c545e37210a78639f9d1b
richardmanasseh/hort503
/Assignments/lpthw/Assignment02/ex13.py
987
4.125
4
from sys import argv script, first, second, third = argv # module sys is not imported, rather just argv has been imported as a variable. # Python modules can get access to code from another module by importing the file/function using import # sys = system library, contains some of the commands one needs in order to ...
10c285eac3b32f8ac5a940963dafffcd1b057cf1
richardmanasseh/hort503
/Assignments/Assignment05/ex36.py
1,916
4.0625
4
# Ex 35: Branches and Functions from sys import exit def national_park(): print("This park is has beutiful animals. How many have you seen?") choice = input("> ") if "0" in choice or "1" in choice: how_much = int(choice) else: dead("Man, learn to type a number.") if how_much < 50...
2a303f20dfe2844ea99580423d4e18af81d6c5ee
richardmanasseh/hort503
/Assignments/lpthw/Assignment02/ex7.py
968
4.3125
4
print("Mary had a little lamp.") print("Its fleece was white as {}. ".format('snow')) print("And everywhere that Mary went.") print("." * 10) # what'd that do? Prints string ten times # By default python’s print() function ends with a newline. # # Python’s print() function comes with a parameter called ‘end’. By defau...
a18a42ff4815c6954e5c4cdf8ea1a172f7d16cd4
richardmanasseh/hort503
/Assignments/Assignment04/ex21.py
1,115
4.34375
4
# Functions Can Return Something # The print() function writes, i.e., "prints", a string in the console. # The return statement causes your function to exit and hand back a value to its caller. def add(a, b): # this (add) function is called with two parameters: a and b print(f"ADDING {a} + {b}") # we print what our...
eaba342178fd0cd9efd60ed6816a213412396edf
richardmanasseh/hort503
/lpthw/ex33.py
1,525
4.3125
4
# While-Loops # The while loop tells the computer to do something as long as the condition is met # it's construct consists of a block of code and a condition. # It works like this: " while this is true, do this " i = 1 # intially i =1 while i <= 10: # loop condition, interpreter first checks if this condtion is tru...
146c53314aab4ca0e157fde0e8b62a38f01218a0
Misara/RPSProject
/RpsGameLogic.py
5,484
3.78125
4
# -*- coding: utf-8 -*- """ This is the file for the game logic for RPS """ PTS_ROCK = 3; PTS_PAPER = 2; PTS_SCISSORS = 1; # functions def init_player(name): """ initialize player """ p = {} p['total_pts'] = 0 p['wins_game'] = 0 p['prev_move'] = 0 p['move_used'] = 0 p['name'] = name p[...
1f705901c10ff76150116cb8c947d45e4635c820
phuongnam7899/NguyenPhuongNam-Fundamental-C4E23
/session1/intro.py
96
3.640625
4
print("Hello,world") n= input("what is your year of birth?") print("tuoi cua ban la: ",2018-n)
c7519e2397277e58726df9f6bffe7f670876dc5a
phuongnam7899/NguyenPhuongNam-Fundamental-C4E23
/lab3/f_math1.py
496
3.84375
4
from random import * point = 0 while True: a= randint(1,11) b= randint(1,11) c= randint((a+b-2),(a+b+2)) print(a,"+",b,"=",c) ans = input("t/f? ") if ans == "t": if a + b == c: print("true") point += 1 else: print('false') break ...
a28dd7c0b5e30f83347488456dc85320d7504741
phuongnam7899/NguyenPhuongNam-Fundamental-C4E23
/session4/homeworkss4/hw5.py
1,344
4.03125
4
quiz={ "if x=8,then what is the value of 4(x+3)?" : [35,36,40,44], "i am 20 year old now and my brother is 5,how many years later will my age double my brother one?" : [5,10,15,20], "i have 3 apples, when my mother come back from market,she bought me more 3 pineapple, how many pineapple would i have? " : [3...
9522982f6fbb02b13750ca1891413671090adbba
phuongnam7899/NguyenPhuongNam-Fundamental-C4E23
/web3/homeworkweb3/optional.py
1,801
3.625
4
import mlab from to_do_list import To_do_list mlab.connect() def new_to_do(): name = input("Enter your new to-do: ") description = input("Add more description: ") completed = "No" new_todo = To_do_list(name= name,description=description,completed=completed) new_todo.save() print("Saved") def v...
2319e2f38ff9395cbb923f828147668c4363796e
phuongnam7899/NguyenPhuongNam-Fundamental-C4E23
/session3/homeworkss3/hw1.py
275
3.546875
4
print("hi there,this is a supper user gate way") usname=input("User name: ") if usname != "c4e": print("u are not a superuser") else: pas=input("Password: ") if pas != "codethechange": print("password incorrect") else: print("welcome, ",usname)
127a6b325c909c80049061e79fd193786062a346
phuongnam7899/NguyenPhuongNam-Fundamental-C4E23
/session4/for_dic.py
179
4.03125
4
person={ "name":"h.duc", "place": "Hai Phong", "age":23, } for k in person.keys(): print(k) for v in person.values(): print(v) for k,v in person.items(): print(k,v)
2768129483f7ebfea85631617ae487e2ac13bb8f
phuongnam7899/NguyenPhuongNam-Fundamental-C4E23
/session4/homeworkss4/study.py
350
3.75
4
string = input("enter string: ").lower() str_list =list(string) str_list.sort() k=[] for i in str_list: while True: if i in k: break else: if i == " ": break else: print(i, str_list.count(i), sep=": ") k.append(i) ...
4e6928280d8c5fa9883809daa35aa08a1bd52069
C-CCM-TC1028-102-2113/tarea-4-Diegozaldivar
/assignments/17NCuadradoMayor/src/exercise.py
208
3.96875
4
def main(): n = int(input("Escribe un numero : ")) #escribe tu código abajo de esta línea p = 1 while p ** 2 < n: p = p + 1 print(p) if __name__ == '__main__':
26df5995c34443863f7204d98fbd32112735ca9b
yv2149/adventofcode
/2016/Jour23.py
3,811
3.546875
4
#!/usr/bin/python from __future__ import print_function import re def print_v(*args): # print(*args) pass class regs: def __init__(self, instructions, a=0, b=0, c=0, d=0): self.regs = {"a" : a, "b" : b, "c" : c, "d" : d} self.inst = list(map(lambda x: x.split(), instructions)) # p...
4daa1b3397d24857f5310f5ed8a9f84fb6b2fe3f
yv2149/adventofcode
/2020/Jour05.py
373
3.5
4
#!/usr/bin/env python3 import sys def seat_id(s): return int(s.translate(s.maketrans("FBLR", "0101")), 2) if __name__=="__main__": with open(sys.argv[1]) as f: l = sorted([seat_id(l.strip()) for l in f]) print("Part 1 : {}".format(max(l))) r = [i for x,y in zip(l, l[1:]) for i in range(x+1, y...
42f44412e3cf5e61219220b4e43bf45763ec32b9
yv2149/adventofcode
/2018/Jour10.py
1,733
3.53125
4
#!/usr/bin/python from __future__ import print_function import sys import re class Point: def __init__(self, position, velocity): self.x = position[0] self.y = position[1] self.dx = velocity[0] self.dy = velocity[1] def tick(self): self.x += self.dx self.y += s...
c8e8fe79fd998a719caea43df19aa026d77d5053
yv2149/adventofcode
/2016/Jour16.py
901
3.515625
4
#!/usr/bin/python def generate_data(d): e = map(lambda x: x^1, d) e.reverse() return d + [0] + e # print generate_data([1]) # print generate_data([0]) # print generate_data([1,1,1,1,1]) # print generate_data([1,1,1,1,0,0,0,0,1,0,1,0]) def checksum(d): while len(d) % 2 == 0: c = [] for...
9cd8f5c4ef4f35a65e29ebbb2a2e58e913171f94
yzh1903test/gittest
/OS模块.py
6,191
3.5625
4
#!/usr/bin/python #-*-c0ding:utf-8-*- #OS内置模块,作用:python与PC系统进行交互 import os #1.获取当前目录的路径 os.getcwd() print(os.getcwd()) #2.chdir(路径名),作用:切换路径 os.chdir("OS_2") print(os.getcwd()) #. 代表当前目录 ##os.curdir print(os.curdir) #.. 代表上一级目录 ##os.pardir print(os.pardir) os.chdir('..') print(os.getcwd()) #"os.name" 获取操作系统的类型 prin...
82c33f0f0eb8d7972767b88ff6a5f70fa5991a65
yzh1903test/gittest
/面向对象.py
9,886
3.59375
4
# -*- coding: utf-8 -*- # @Time : 2019/7/22 上午9:03 # @Author : 废柴 # @Project: teach # @FileName : 面向对象.py # @Software: PyCharm # @Desc : ============================================== # Life is Short I Use Python!!!                      === # If this runs wrong,don't ask me,I don't know why;  === # If this...
954b0001967b0e1ce9fac050a57ace05157fa736
rapoulson/learning_python
/drinkselector2.py
2,388
3.828125
4
from sys import exit def stir_my_rye(): print "On a scale of 1-10, how adventurous are you feeling this evening?" next = raw_input("> ") if next < 5: print "Let's try a Vieux Carre!" print """ 1 oz rye 1 oz cognac 1 oz sweet vermouth .25 oz Benedictine 2 dashes each of Angostura and Peychaud's bi...
45259171931a5ecc13060356ff359f52207a91e5
namanm97/py
/6a.py
172
3.953125
4
def maximum(l): if len(l) == 1: return l[0] else: return max(l[0],maximum(l[1:])) #l[1:] #is called slicing list1=[10,30,40] print(maximum(list1))
caa4b0b0e71dd789c59bd624d7ee932a9bd5e006
Praveenvirat/quiz-project
/Question.py
427
3.5
4
class Question: def __init__(self, question, choice1, choice2, choice3, choice4, answer): self.question = question self.choice1 = choice1 self.choice2 = choice2 self.choice3 = choice3 self.choice4 = choice4 self.answer = answer def is_answer_correct(se...
57a0315522093751af054ca900fbd16c4ab30f8b
shruti310gautam/python-programming
/function.py
291
4.25
4
#You are given the year, and you have to write a function to check if the year is leap or not. def is_leap(year): leap = False if (year%4 == 0 and year%100 != 0) or (year%400 == 0) : leap = True return leap #Sample Input=1990 #Sample Output=False
5aa49bc46b7594304d612e72975addd2cf7e1dfc
shruti310gautam/python-programming
/loop.py
242
3.953125
4
#Read an integer N. For all non-negative integers i<N, print i*i . See the sample for details. if __name__ == '__main__': n = int(raw_input()) for i in range(0,n) : print (i*i) #Sample Input = 5 #Sample Output #0 #1 #4 #9 #16
44fb9ace23ba690cf6d250505a4ffdc32bc47981
piwonskp/takathon
/examples/result_validation/factorial.py
771
3.625
4
def factorial(n): """ spec: title: Factorial domain -1: title: Should be incalculable for negative values description: Function raises proper exception when called with negative value throws ValueError('factorial() not defined f...
0ea2ca342318d1080a49f051ce0a9f3f775c2733
loudDD/worm
/try.py
2,565
3.5625
4
#coding=utf-8 # import re # #1、匹配一行文字中的所有开头的字母内容 # s = "i love you not because of who you are, but because of who i am when i am with you" # print(re.findall('(\w)\w*\s*',s)) # #2、匹配一行文字中的所有开头的数字内容 # s = "i love you not because 12sd 34er 56df e4 54434" # print(re.findall(r"(\d)\d*",s)) # #4、 只匹配包含字母和数字的行 # s = "ilov...
5ee21d4883b9a1202b8aec307718e347fca271b3
msorbaro/chessAI
/AlphaBetaAI.py
7,374
3.984375
4
#Morgan Sorbaro #11/3/17 #Chess Minimax program #This program implements the minimax algorith to play chess #imports import chess import math #Node class to store values associated with states in the minimax algorithm class ABAI_Node(): #keeps track of the value and the move def __init__(self, value, move): ...
561d1d3de85e1ca00d93c249837883f5b51eda39
TonGarcia/rna-xor
/OO_XOR_RNA.py
5,367
3.546875
4
# coding: utf-8 # In[1]: # get_ipython().run_line_magic('matplotlib', 'inline') # get_ipython().run_line_magic('config', "InlineBackend.figure_format = 'retina'") import copy import numpy as np import pandas as pd from random import uniform import matplotlib.pyplot as plt def MSE(y, Y): return np.mean((y-Y)**...
7b1675b89bb46ba26f4350b786ef66b13e87e805
Kumar-Neelamegam/PythonBasics
/Section2/Lesson 12.py
236
3.90625
4
# Boolean myAge = input("Enter your age:") hisAge = input("Enter his age:") if (myAge < hisAge): print("He is older than you") elif (myAge > hisAge): print("He is younger than you") else: print("You two have the same age")
0dd2c58383812cd18ddea6f788d508d38a95a1d1
Daewooki/Algorithm
/BOJ_Python3/BOJ10870.py
264
4.09375
4
# BOJ10870 # Recursive Fibonacci num = int(input()) def fibonacci(num): if num <= 2: return 1 else: return fibonacci(num-1) + fibonacci(num-2) if(num>=2): print(fibonacci(num)) elif(num==1): print(1) else: print(0)
f485c5a58c0774d0ef5ec230ebf62361849d7a3f
wgatharia/csci131
/5-loops/exercise_3.2.py
411
4.40625
4
""" File: exercise_3.2.py Author: William Gatharia This code demonstrates using a while loop. """ #loop and print numbers from 1 to 10 using a while loop number = 1 while True: print(number) #increment number #short hand for increasing number by 1 #number += 1 number = number + 1 #...
8809682dbdf0cdde94e113e189b8f889d95d0592
wgatharia/csci131
/3-data_types/exercise_4.5.py
355
4.03125
4
""" File: exercise_4.5.py Author: William Gatharia This code demonstrates writing random numbers to a text file. """ import random file_name = input("Enter file name: ") #open file file = open(file_name, 'w') for i in range(500): r = random.randint(0, 500) #write random number to file file.wr...
9c57d15737d791e29ed0927b0554a2907da0a3ff
wgatharia/csci131
/5-loops/exercise_3.9.py
240
4
4
""" File: exercise_3.9.py Author: William Gatharia This code demonstrates substration using the -= operator. """ number = 100 for n in range(1, 12): #decrease number using -= number -= n print(number) print(number)
6ed837a38409824ea879a118ad197960cbb69809
wgatharia/csci131
/8-lists_and_dictionaries/exercise_5.4.py
429
4.09375
4
""" File: exercise_5.4.py Author: William Gatharia This code demonstrates slicing lists. """ #create a list of colors colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'] print("----------------Items in List--------------------------") print(colors) #get first two colors in a list c...
6973f75edff40a6b80aee7f1d8453bd7d9d7406e
wgatharia/csci131
/6-functions/exercise_6.3.py
418
3.859375
4
""" File: exercise_6.3.py Author: William Gatharia This code demonstrates function as first class data object in a function. i.e. passing a function as an argument in a function """ def runFunction(function_arg, data_arg): return function_arg(data_arg) #run tests on math functions import math pri...
3ba43c09951a64352df2ae84f86fa00a05078fa5
asritha1620/AITPL2135
/2nd and 4th largest no..py
345
4
4
print("Enter the numbers") l=[int(i)for i in input().split()] if len(l)<2: print("minimum 2 elements are required") else: l.sort() if len(l)>=4: print("2rd largest is:{0} and 4th largest is:{1}".format(l[-2], l[-4])) else: print("2rd largest is:", l[-2], " \nlength less than 4,can't find ...
037d8d249ed91e1d2c664b467a5a3c7d2c9278fa
asritha1620/AITPL2135
/2nd and 4th large inlist.py
343
4.09375
4
l=[] n=int(input("enter number of elements in the list: ")) if n<2: print("can't find required largest numbers") for i in range(n): l.append(int(input("enter element:"))) l.sort() if n >= 4: print("2nd largest is:",l[-2] ,"and 4th largest is :",l[-4]) else: print("2nd largest is", l[-2] ,"\n l...
8ea26770abc749c5f5ba736f601843b36fffbb04
Miriam295/PycharmProjects
/tasks/bank_task.py
4,766
3.90625
4
class Customer: last_id = 0 def __init__(self, firstname, lastname): self.firstname = firstname self.lastname = lastname Customer.last_id += 1 self.id = Customer.last_id def __repr__(self): return 'Customer[{},{},{}]'.format(self.id, self.firstname, self.lastname) ...
8c4800968ebafe77d07b642a7841206dae5de0fa
Cheater115/acmp
/Python/0819.py
168
3.8125
4
length, width, height = map(int, input().split()) area = (length * width + length * height + width * height) * 2 volume = length * width * height print(area, volume)
bd7938f70e7217c7090f576e9a421cb69d2bd390
Cheater115/acmp
/Python/0892.py
347
3.515625
4
seasons = { 1: 'Winter', 2: 'Winter', 3: 'Spring', 4: 'Spring', 5: 'Spring', 6: 'Summer', 7: 'Summer', 8: 'Summer', 9: 'Autumn', 10: 'Autumn', 11: 'Autumn', 12: 'Winter', } nMonth = int(input()) season = seasons.get(nMonth, None) if season is not None: print(season...
19abaeacf3e9ecf4bd73134018b5415795308b78
Cheater115/acmp
/Python/0296.py
207
3.78125
4
price = int(input()) basilio = price // 5 if (price - basilio * 5) % 3 == 1: basilio -= 1 elif (price - basilio * 5) % 3 == 2: basilio -= 2 alica = (price - basilio * 5) // 3 print(basilio, alica)
50a196ef982ec6d9130cfbf007915a8c619d9b2f
rosmoke/DCU-Projects
/week10/func_contains.py
313
3.65625
4
def bsearch(a,q): low = 0 high = len(a) while low < high: mid = (low + high) / 2 if q > a[mid]: low = mid + 1 else: high = mid return low def contains(a,q): position = bsearch(a,q) if position < len(a) and a[position] == q: return True else: return False #print contains([2,3,6,6,7,8], 21)
d22b9bed3b012277bc43cbf4255c017d35e98be7
rosmoke/DCU-Projects
/week26/geometry_91.py
1,211
3.9375
4
import math class Point(object): def __init__(self, x, y): self.x = x self.y = y def distance(self, other): return((math.sqrt((other.x - self.x) ** 2 + (other.y - self.y) ** 2)), [self.x,self.y]) class Shape(object): def __init__(self, points): self.points = points def sides(self): side1 = self.points[0]...
4b0afab8746ce64c7b820b8995b3bbad98a3641a
rosmoke/DCU-Projects
/week21/sphere_12.py
505
3.546875
4
import sys import math start_r = float(sys.argv[1]) increment_r = float(sys.argv[2]) end_r = float(sys.argv[3]) radius = "Radius (m)" area = "Area (m^2)" volume = "Volume (m^3)" dash = "-" print('{:>0} {:>15} {:>15}'.format(radius, area, volume)) print('{:>0} {:>15} {:>15}'.format(dash * 10, dash * 10, dash * 12)) ...
682537eaa0332fb69b26a413f27fa9349b55ca35
rosmoke/DCU-Projects
/sample_exam/folder_111_demo.py
1,189
3.6875
4
from folder_111 import File, Folder def main(): # Create an empty folder print('Initialise empty folder...') folder = Folder() # Create some files print('Initialise some files...') f1 = File('poem.txt', 'joe') f2 = File('readme.txt', 'max', 1000, 'r') f3 = File('secret.txt', 'fred', 1...
58cee711bc1e30d717aad90083e1c496d66cb391
rosmoke/DCU-Projects
/week3/sum-five-abs.py
103
3.609375
4
sum = 0 times = 0 while times < 5: current = input() sum += abs(current) times = times + 1 print sum
852017068c236340d7255791843f5dfe62a67df9
rosmoke/DCU-Projects
/week4/reverse-string.py
140
3.8125
4
s = raw_input() i = 0 letter = len(s) word = "" while i <= len(s): word += s[letter:letter + 1] i = i + 1 letter = letter - 1 print word