blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
4b08fe5b347086939b9062ac9e0b82fab03e4e7f
psycoleptic/Python_class
/If Task 7.py
98
3.703125
4
print("x y x and y") for x in range(0,2): for y in range(0,2): print(x, y, x and y)
3c35233bf3598594d8a13645d950d25ac4d05bca
psycoleptic/Python_class
/Funk Task 8.py
747
4.34375
4
#Определите функцию, которая принимает значение коэффициентов квадратного уравнения и выводит значение корней или #предупреждение, что уравнение не имеет корней (в случае если детерминант оказался отрицательным) def s_eq(a, b, c): tmp = b**2 - 4*a*c if tmp < 0: print("Уравнение не имеет корней!...
080aea6d21d2c68e8140c49be96881b3bf444d01
psycoleptic/Python_class
/Task 1.py
190
3.703125
4
#Создайте список числовых значений от 0 до 100 (через циклы и генераторы) k = [] for i in range(1, 101): k.append(i) print(k)
08704a8d03cabc6a757eb3b85b46d39183095dfc
psycoleptic/Python_class
/Funk Task 10.py
486
4.40625
4
#Напишите функцию, которая для заданного в аргументах списка, возвращает как результат перевернутый список def revers(a, b): old_list = [] for i in range(a, b): l = i+1 old_list.append(l) i+= 3 new_list = list(reversed(old_list)) print(old_list) print(new_list) ...
fd7a957776812baefac574d08f40b54fa496793c
psycoleptic/Python_class
/Funk Task 3.py
78
3.859375
4
def power(n, pow = 2): return n**pow n = int(input()) print(power(n))
8ec0c4c13e8f5ce172c4b55c0d4b95f7534c2cab
drvpereira/spoj
/build a fence/solution.py
125
3.65625
4
from math import pi c = 1.0 / (2 * pi) l = int(input()) while l != 0: print('{0:.2f}'.format(l * l * c)) l = int(input())
2a7434fb3a7057dc27e867724caf14a0e46ee5b0
rtait/Python
/Temp Conversion with loop & Exception.py
402
4.03125
4
#!/usr/bin/env python while True: C = input("What is the temperature? or 'q' to quit \n") if C.lower() == 'q': print("See you next time...") break try: C = float(C) except ValueError: print("Please enter a number in numeric form \n") continue if C =...
aaf017d5dadeadfa9bea28e854428fc4476508e3
huanhuan18/mywork
/n元随机分给m个人/random_division.py
756
3.515625
4
import random def sum_judge(former, later, n): if former + later >= n: return False else: return True def main(n, m): money = n sum = 0 for i in range(m): div = random.randint(0, n) while True: if sum_judge(sum, div, n): if i...
3f8cb9e1f59013bbf846c772da92929caff6bc8b
tugba-star/class2-module-assigment-week05
/question4.py
760
3.8125
4
import secrets #module called secrets for generating a strong and secure random number. import string string_source=string.ascii_letters+ string.digits+ string.punctuation+string.ascii_letters+ string.digits+ string.punctuation #If we multiplied by 2, it would repeat the same.so we wrote twice separately. password=secr...
7465aa0e1d29ee3e476a789ad5edd7383924b641
johnmcneil/w3schools-python-tutorials
/2021-02-18.py
3,986
4.625
5
# dictionaries # store data in key: value pairs # ordered, changeable, does not allow duplicates # duplicate values overwrite existing ones # ordered as of Python 3.7. Unordered in Python 3.6 and earlier. thisdict = { "brand": "Ford", "model": "Mustang", "year": 1964 } print(thisdict) print(thisdict["brand"...
d7a0d968a0b1155703ec27009f4c673bab32416f
johnmcneil/w3schools-python-tutorials
/2021-02-09.py
2,405
4.40625
4
# casting to specify the data type x = str(3) y = int(3) z = float(3) # use type() to get the data type of a variable print(x) print(type(x)) print(y) print(type(y)) print(z) print(type(z)) # you can use single or double quotes # variables # variable names are case-sensitive. # must start with a letter or the u...
df2a11b4b05eb2a086825a7a996347f0f56a75ee
johnmcneil/w3schools-python-tutorials
/2021-03-05.py
1,466
4.65625
5
# regexp # for regular expressions, python has the built-in package re import re txt = "The rain in Spain" x = re.search("^The.*Spain$", txt) print(x) # regex functions # findall() - returns a list of all matches x = re.findall("ai", txt) print(x) x = re.findall("sdkj", txt) print(x) # search() - returns a match ob...
5eadd1dc51563de0b1e3ae4a905bf0e52a534790
krishnakesari/Python-Fund
/List Comprehension.py
1,576
3.984375
4
# Sequence def main(): seq = range(11) seq2 = [x * 2 for x in seq] print_list(seq) print_list(seq2) def print_list(o): for x in o: print(x, end = ' ') print() if __name__ == '__main__': main() # Only divisible by 3 def main(): seq = range(11) seq2 = [x for x in seq if x % 3 != 0] ...
c31786c6ad2645c08348c68592c2e95c1b924be9
krishnakesari/Python-Fund
/Operators.py
1,296
4.15625
4
# Division (/), Integer Division (//), Remainder (%), Exponent (**), Unary Negative (-), Unary Positive (+) y = 5 x = 3 z = x % y z = -z print(f'result is {z}') # Bitwise operator (& | ^ << >>) x = 0x0a y = 0x02 z = x << y print(f'(hex) x is {x:02x}, y is {y:02x}, z is {z:02x}') print(f'(bin) x is {x:08b}, y is ...
4e0088bb25588855455f58537abbabb1769b2459
ETDelaney/automate-the-boring-stuff
/05-01-guess-the-number.py
1,343
4.21875
4
# a game for guessing a number import random num_of_chances = 5 secret_number = random.randint(1,20) #print(secret_number) print('Hello, what is your name?') name = input() print('Well, ' + name + ', I am thinking of a number between 0 and 20.') print('Can you guess the number? I will give you ' + str(num_of_chance...
3ffe2c0498a5803ce844c361d1ead6c4887cef65
jasoncwilley/awesome-pizza-order-app
/custom_order.py
4,969
4.0625
4
def get_menu_selection(menu_items): """ Display a menu and return the user's selection """ print("\n") for menu_item in menu_items: print(menu_item) return input("\nPlease select an option from above. ") def display_selection_error(menu_selection): if menu_selection.isdigit(): ...
8d37af2dc7cf5fba984f7c35f343c6741a30653e
rustybailey/Project-Euler
/pe20.py
425
4.15625
4
""" n! means n * (n - 1) * ... * 3 * 2 * 1 For example, 10! = 10 * 9 * ... 3 * 2 * 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. Find the sum of the digits in the number 100! """ import math def sumFactorial(n): num = math.factorial(n) total = 0 whil...
192f8499af4c50361609cea044de368321be5da3
suitkk/demo01
/String.py
2,409
4.03125
4
#-*- codeing = utf-8 -*- #@Time : 2020/12/8 下午 02:16 #@File : String.py #@Softwore : PyCharm #字符串的方法都不会改变原字符串,若需要改变后的值,则需要重新赋值 import math import String from math import pi ''' word='字符串1'#不能直接换行 sentence="字符串2"#不能直接换行 paragraph=""" 段落1 段落2 段落3 """#可以直接换行 print(word) print(sentence) p...
569c07689b3914d9fb2ecf16b0e9d1e512b6d1d7
abispo/repositorioteste
/aula20210114/exercicios/ex_05.py
353
3.84375
4
if __name__ == '__main__': nome_do_produto = input("Digite o nome do produto: ") valor_do_produto = float(input("Digite o valor do produto: ")) desconto = 0.1 if valor_do_produto >= 100: valor_do_produto = valor_do_produto - (valor_do_produto * desconto) print(f"O produto '{nome_do_produt...
de6205d8055489055e31d071981db52482b04258
sergioc6/python-course
/basics/ejercicio5.py
305
3.84375
4
# Ejercicio 5 total = float(input("Ingrese el Total de la compra: ")) descuento = total * 0.15 totalConDescuento = total - descuento print(f"El total de la compra es: ${total}") print(f"El descuento de la compra es: ${descuento}") print(f"El total con descuento de la compra es: ${totalConDescuento}")
64df2883c6b3b3f16a29c0ab6b86ed71620d195b
MrAttoAttoAtto/CircuitSimulatorC2
/utils/MutableFloat.py
1,112
3.515625
4
class MutableFloat: def __init__(self, value=0.0): """ Live is constantly updated, value is updated only once an entire matrix set has been constructed, and old holds the last step's values :param value: The initial value of the Mutable Float """ self.value = value ...
7f6dd931dc6ad1b1cb187f0e22fe88bd5bc17918
simonmdsn/AL-DS_2020
/Week 6/Assignment 5.py
1,244
3.546875
4
""" Hvis et array/ en liste indeholder en permutation af tallene 0 til n-1 kan man definere kredse på samme måde som for puslespillet fra første forelæsning: et tal x, som står på plads y i arrayet, giver en pil fra plads y til plads x (dvs. hvis tallet 1 står på plads 4 i arrayet, er der en pil fra pla...
4a20c7e1f334b1e3643e93454480f2196b44bb52
simonmdsn/AL-DS_2020
/Week 6/Assignment 4.py
533
3.515625
4
""" Lav et python-program, som generer en tilfædldig permutation af heltallene fra 0 til n-1 (for et n som er en input parameter). I python kan man bruge lister samt funktionen shuffle fra modulet random. Udskriv tallene i din permuation """ import random def makeListFromNumberOfParameters(n, shuffle...
d23909d63299735beebb3954cc835727b87fa38b
myworkshopca/LearnCoding-March2021
/basic/types.py
564
4.15625
4
age = input("How old are you?") print("Age is: {0}".format(age)) print("35 / 2 = ", 35 / 2) print("35 // 2 = ", 35 // 2) a = 'Hello Somebody' print("Repeating \"{0}\" {1} times: {2}".format(a, 4, a * 4)) print("Try the named index placeholder:") print("Name: {name}, Age: {age}".format(age=100, name="Sean")) b = "He...
60e6bece731a9bed9cb6fc06f52bdf071ae20507
myworkshopca/LearnCoding-March2021
/basic/strings.py
447
3.671875
4
n = 135 # 35 / 2 = 17.5 print("{0} / 2 = {1}".format(n, n / 2)) # 35 // 2 = 17 print("{name} // 2 = {result}".format(name=n, result=(n // 2))) a = '234\n\t345 \'88\'' print("a = {av}".format(av=a)) b = '''234 4567 abc hello Again ''' print("b = {0}".format(b)) print("{vn} turn to UPPER: {upper}".format(upper=b.upp...
0b28960c574d501effe8cc84027c968dc102c6f5
henriquebraga/python3-concepts-and-exercises
/python_patterns/interpreter/interpreter.py
1,641
4.0625
4
#-*- coding: utf-8 -*- class Operation(object): def __init__(self, left_expression, right_expression): self._left_expr = left_expression self._right_expr = right_expression class Substraction(Operation): def __init__(self, left_expression, right_expression): super(Substraction, self).__init__(left_expres...
9100f2d567872b26825bdebb3a0d7361177b2791
henriquebraga/python3-concepts-and-exercises
/python_patterns/strategy/tax_calculator.py
409
3.53125
4
#-*- coding: UTF-8 -*- class Budget: def __init__(self, value): self._value = value @property def value(self): return self._value def ICMS(budget): return budget.value * 0.05 def ISS(budget): return budget.value * 0.08 def calculate_tax(budget, tax): return tax(budget) if __name__ == '__main__': budg...
96dbec78a1c12388218167d4aae7a44b88719352
henriquebraga/python3-concepts-and-exercises
/python_patterns/visitor/visitor.py
2,133
3.875
4
#-*- coding: utf-8 -*- class Operation(object): def __init__(self, left_expression, right_expression): self._left_expr = left_expression self._right_expr = right_expression class Substraction(Operation): def accept(self, visitor): return visitor.visit_substraction(self) def __init__(self, left_expressio...
4cd0a36daa30f0ba8e58b772fd7093b62664afd4
MXXXXXS/utils
/写完才发现有个叫copytree的函数.py
902
3.609375
4
from typing import Callable from os import listdir, makedirs from os.path import join, abspath, isdir, exists, dirname # 遍历一个文件夹内容到另一个文件夹下, 对每一个文件执行一个回调 def traverse(src: str, dest: str, cb: Callable[[str, str], None]) -> None: src = abspath(src) dest = abspath(dest) srcLen = len(src) if isdir(src) and...
9b44a3b18e1f19f6fa00466012f48237e4a1d3ea
sekichang/python_lesson
/src/chapter3/ch3_5.py
159
3.875
4
x = int(input("数値xを入力して下さい。=")) y = int(input("数値yを入力して下さい。=")) print("x / y の商は{}です。".format(x // y))
353266461b46677bb4f617428204baf550abc5ea
sekichang/python_lesson
/src/chapter3/ch3_6.py
230
3.625
4
age = int(input("年齢を入力して下さい。=")) if age < 20: print("未成年です") elif age < 65: print("成人です") elif age < 75: print("前期高齢者です") else: print("後期高齢者です")
95bc01c80476b229dba6c84dd71a43f07984f660
EdwardBetts/Decrypting-polyalphabetic-ciphers
/decrypt_polycipher.py
17,230
3.78125
4
#!/usr/bin/env python3 import sys from operator import itemgetter from itertools import zip_longest import string import logging as log import argparse from collections import Counter from math import gcd ## TODO # sanitaze input def cleanText(text): """ Removes the punctuation symbol, digits and whitespaces fro...
aa073424dda40ac53ae13d964b769a2287245806
ohadstatman/Data_portfolio
/first1.py
280
3.546875
4
import re file = open("actual-data-1.txt") lst=list() for line in file: if re.search("[0-9]+",line): x = re.findall("[0-9]+",line) lst.append(x) numbers =[] for l in lst: for num in l: numbers.append(int(num)) print(sum(numbers))
b495c945cfed8db9787f8d9fab4e3c02a5232dfb
shagunsingh92/PythonExercises
/FaultyCalculator.py
1,122
4.53125
5
import operator '''Exercise: My_faulty_computer this calculator will give correct computational result for all the numbers except [45*3 = 555, 56+9=77 56/6=4] ''' def my_faulty(): allowed_operator = {'+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.truediv} # ask the user for an input ...
4a79817aff8905494f734aee042cf4eaae2d24d5
davidvelichko52/RPN_calc_stacks
/cal.py
1,214
3.90625
4
class Stack: def __init__(self): self.list = [] def pop(self): return self.list.pop() def push(self, data): self.list.append(data) def length(self): return len(self.list) def print_stack(self): print([str(x) for x in self.list]) def calculate_rpn(input): ops = { "+": (lambda a,...
3302de8bad34c27c4ed7216b5d4b9fb786979c6c
allenc8046/CTI110
/P4HW4_Chris Allen.py
356
4.21875
4
import turtle redCross = turtle.Screen() x = turtle.Turtle() x.color("red") # set x turtle color x.pensize(3) # set x turtle width print("It's a red cross!") print () # use a for loop for redCross in range (4): x.forward(150) x.left(90) x.forward(150) x.left(90) ...
24f4f408872e9cf5367e519bf375ca02ee3c697f
HaoHan1997/Top10_Algorithms_in_DataMining
/Classification/Perceptron/Perceptron.py
1,278
3.90625
4
#!/usr/bin/python # -*- coding: utf-8 -*- ''' @author yangmu @version 0.1 @date 2016-03-04 ''' # This file is the implementation of perceptron learning algorithm. # Here, let's initialize w is a 2 dimention vectors, and b is 0 at the same time. # What's more, the learning ratio is 1 import os #test data training_s...
7566dca8940e578f76cc7f19b9f8ddfc20801ad0
moin59/Intelligent_Coffee_Machine
/source/python/coffeeMachine.py
4,812
3.71875
4
# author: Md Moin Uddin # Bremen Nov.15-2019 import os import time # Defined class for coffee machine class intelligent_CoffeeMachine(): # some condition initialized as boolean and set initial value def __init__(self): # boolean expression self.lidIsOpen = False self.filterIsInsert = F...
6e5824022722d452f0271b31c32f446f484daf58
gcampfield/Genetic-Algorithm
/main.py
829
3.578125
4
#!/usr/bin/python from __future__ import print_function from GA.simulation import Population_Simulation import matplotlib.pyplot as plt # Initialize the Population_Simulation FITNESS_RANKINGS = [65, 31, 38, 83, 58, 05, 51, 81, 04, 37] simulation = Population_Simulation(10, rankings=FITNESS_RANKINGS) # Print initial ...
00129adf4cbb2fda2215c499ba7392ca17e90b10
rafaelalmeida2909/Python-Data-Structures
/Linked Queue.py
2,268
4.28125
4
class Node: """Class to represent a node in Python3""" def __init__(self, data): self.data = data # Node value self.next = None # Next node class LinkedQueue: """Class to represent a Linked Queue(without priority) in Python3""" def __init__(self): self._front = None # The ...
b314cc818cdf04d37dbc36fae60f5f0ca354182e
divineunited/casear_cipher
/casear_cipher.py
2,649
4.125
4
def casear(message, n, encrypt=True): '''This casear encryption allows for undercase and capital letters. Pass a message to encrypt or decrypt, n number of positions (must be less than 26) where n will add to the alphabet for encryption and subtract for decryption, and optional encrypt=False to allow for decryption...
b431a5d705f2e296ea5d7b3e11d1beb74f2f0581
IAMZERG/mtgproject
/play.py
1,322
3.578125
4
def play(board, boardstates, ai=0): gameboard(board) actionfinished=0 command=[] if ai==1: command=board.actions num=0 if ai==0: command.append(input("\nDescribe the action being performed. ")) while board.actionfinished == 0: print ("\nPerforming action: "...
b8d9b21cbec699f810b94aa28cdd439ce9e6b170
IAMZERG/mtgproject
/playFunctObjects.py
10,923
3.515625
4
def play(board, boardstates, ai=0): gameboard(board) actionfinished=0 command=[] if ai==1: command=board.actions num=0 if ai==0: command.append(input("\nDescribe the action being performed. ")) while board.actionfinished == 0: print ("\nPerforming action: "...
4440650c8bd703e947b9f9f4515152bc364af817
BuddhaTheChef/NTHA2021
/solve.py
6,997
3.984375
4
import argparse, copy, math class PuzzleBoard(): def __init__(self, board_length, board_width): self.l = board_length self.w = board_width self.state = [[0 for _ in range(board_width)] for _ in range(board_length)] # Input: point - tuple cotaining (row_index, col_index) of point in s...
fb94d8f226c8f67636b5d1c06afe5f526dfa8139
INST326-103-Fall2018/group2
/hangman.py
4,596
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Name: Chris Davis # Directory ID: cdav1601 # Date: 2018-11-12 # Assignment: Midterm 2, Question 4 import sys import string import random #Opens a file given in command line and creates list def words_in_file(file): #Open file given in command line fhand =...
08baf450f2a1db63163391b5b3b12c8db1c8672f
akshayravichandran/literature-card-game
/test/test_deck.py
693
3.609375
4
from deck import Deck from constants import DeckType import unittest class Tests(unittest.TestCase): seed = 0 def test_standard_deck(self): d = Deck(DeckType.STANDARD) self.assertTrue(d, "Deck not initialized") self.assertTrue(d.cards, "No cards initialized") self.assertEqual...
0a15fcb8dcc1e8d66fe588af71f351494edf3058
shahharsh2603/twitter-coupon-crawler
/expirySetter.py
7,016
3.59375
4
from datetime import datetime from datetime import timedelta from utilities import Utilities import re class ExpirySetter: days_in_months = { 'January':(1,31), 'February':(2,28), 'March':(3,31), 'April':(4,30), 'May':(5,31), 'June':(6,30), 'July':(7,31), 'August':(8,31), 'September':(9,30), 'October':(10,3...
88f8a126ece525cdeafc73606109431f23f235c7
Serene1307/jing-rosie-ics-final
/final/TicTacToe.py
2,457
3.953125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Dec 2 15:21:00 2018 @author: rose """ import os class Board(): # initiate the board def __init__(self): self.cells = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " "] #display the board def display(self): a =...
807da3809ad79e89a762cdf5b56fefe1e1fd344f
Partha-debug/3DES_cryptor
/main.py
3,370
3.640625
4
from enc import img_encryptor from dec import img_decryptor def show_logo(): print(""" 3DES __ ____ _______ ___.__. ______ _/ |_ ____ _______ _/ ___\ \_ __ \ < | | \____ \ \ __\ / _ \ \_ __ \ \ \___...
73e2b71e6bffcc78e4811dc889314de9b9bfe71c
Naeempatel010/Face-Detection-using-FaceNet
/src/classifier.py
1,535
3.515625
4
# This is experimental section where the training is done to apply the face embedding to typical machine learning technique like Support Vector Machines from sklearn.utils import shuffle import face_recognition import os import joblib from sklearn import svm from sklearn.model_selection import train_test_split face_emb...
cf56a30e85609aa36b78a211630c445ffed9d5d7
MarianneLawless/Project-2018-Programming-and-Scripting
/iris.py
410
3.6875
4
# Marianne Lawless # Exercise 5 # Iris dataset downloaded from https://archive.ics.uci.edu/ml/datasets/iris with open("data/iris.csv") as f: #Open the file and automatically close for line in f: #loops through each line in the file, and prints the lines in the following format print('{:4} {:4} {:4} {:4}'...
60f1a1cd906d9e66a80ffb877635deb7fe3dc0f4
HangCoder/micropython-simulator
/tests/basics/class_number.py
280
3.671875
4
# test class with __add__ and __sub__ methods class C: def __init__(self, value): self.value = value def __add__(self, rhs): print(self.value, '+', rhs) def __sub__(self, rhs): print(self.value, '-', rhs) c = C(0) c + 1 c - 2 print("PASS")
01d58a97bfd3cac742b4dd50bedcc2a7b04712f5
ThaliaVillalobos/code2040
/Step3.py
878
3.5625
4
import urllib2 import requests import json def main(): #requsting information from API payload = {'token':'', 'needle':'', 'haystack': ''} data= requests.post("http://challenge.code2040.org/api/haystack", params = payload) #To view the information #print(data.text) #Coverting JSON string into...
bcee5543248c71eaaaead33647705312f2e89b2e
shiki7/leetcode
/0605: Can Place Flowers/solution.py
621
3.671875
4
class Solution: def canPlaceFlowers(self, flowerbed: List[int], n: int) -> bool: total = 0 N = len(flowerbed) if N == 1: if flowerbed[0] == 0: total +=1 else: for i in range(0, N): if flowerbed[i] == 0: if (i...
a37bcdfeac78cb6424b3d2fe0808557f6185f44a
shiki7/leetcode
/0002: Add Two Numbers/solution.py
933
3.65625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: digit = 0 sum = 0 up = 0 while l1 or l2 or up != 0: add_...
618f8b39110065e2806c7f7038128d4ef29db8d8
NonyeReeta/TextMorseConverter
/main.py
1,313
4.0625
4
chars = "abcdefghijklmnopqrstuvwsyz1234567890,.@/?'=()! " morse_codes = [".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", ".----", "..---", "...--", "......
1be6e43cbd10f9260a0d1d2e81ace8a51ae9e1e5
MeghaSajeev26/Luminar-Python
/examples/pgm5.py
73
3.78125
4
#find output a=5.0 b=25/5 if a is b: print(a) else: print(a is b)
7c4f5a725fb49a86333809956941866f45d0effb
MeghaSajeev26/Luminar-Python
/Advance Python/Test/pgm5.py
448
4.4375
4
#5. What is method overriding give an example using Books class? #Same method and same arguments --- child class's method overrides parent class's method class Books: def details(self): print("Book name is Alchemist") def read(self): print("Book is with Megha") class Read_by(Books): def rea...
3225cce32b9cfb3c5388a5083cf018dc1755a3e1
MeghaSajeev26/Luminar-Python
/Data collections/List/List Comprehension/demo2.py
220
3.890625
4
# arr=[2,3,4,5,6] # squares=[num**2 for num in arr] # print(squares) fruits=["mango","apples","orange"] #[('mango','mango'),('apples','apples'),('orange',orange)] pairs=[(fruit,fruit)for fruit in fruits] print(pairs)
2ec591c6575a256ede8dd8ca0366bbd4571715bd
MeghaSajeev26/Luminar-Python
/Flow controls/demo5.py
506
4
4
#grade of subject marks num1=int(input("enter sub1 mark")) num2=int(input("enter sub2 mark")) num3=int(input("enter sub3 mark")) num4=int(input("enter sub4 mark")) num5=num1+num2+num3+num4 if(num5>=180): print("A+") elif(num5>=168)&(num5<=179): print("A") elif(num5>=140)&(num5<=159): print("B+") elif(num5>=...
c73f59de5df93785d9950d07fa58e9815d3ad283
MeghaSajeev26/Luminar-Python
/Advance Python/Regular Expression/Rulesof_RE/rule2.py
174
3.625
4
#Rule 2--except a,b and c import re x="[^abc]" #except a,b or c matcher=re.finditer(x,"abt cQsfgh") for match in matcher: print(match.start()) print(match.group())
4efa803239a3f2de8687988a1f1f33b745f545f2
MeghaSajeev26/Luminar-Python
/Advance Python/Regular Expression/Rulesof_RE/demo2.py
207
3.828125
4
#Rules for validation of R.E #Rule--either a,b or c import re x="[abc]" #search either a,b or c matcher=re.finditer(x,"abt cQsfgh") for match in matcher: print(match.start()) print(match.group())
1b566d43be6f35ed68d46e0e5418c1a26d8f9313
MeghaSajeev26/Luminar-Python
/Data collections/Dictionary/demo5.py
181
4.09375
4
dict={'name':'megha','age':22,'place':'palakkad'} del dict['name'] #deleting a particular entry dict.clear() #clear all elements del dict #delete entire dictionary print(dict)
27d98a2762d5858fca94ac02ef450e4a47b21925
MeghaSajeev26/Luminar-Python
/Advance Python/Regular Expression/Examples/vehicleno.py
199
3.53125
4
#rule to validate vehicle registration number import re x="[K][L]\d{2}[A-Z]{2}\d{4}" n=input("Enter input") match=re.fullmatch(x,n) if match is not None: print("valid") else: print("Invalid")
9f9a506baa32ca4d7f7c69ed5d66eac431d0c37f
MeghaSajeev26/Luminar-Python
/Looping/for loop/demo6.py
212
4.21875
4
#check whether a number is prime or not num=int(input("enter a number")) flag=0 for i in range(2,num): if(num%i==0): flag=1 if(flag>0): print(num,"is not a prime") else: print(num,"is prime")
4c4572f969206e95be9f6532b31752a422acd0e7
MeghaSajeev26/Luminar-Python
/Functions/pallindrome2.py
115
4.15625
4
a=input("enter a string") b=a[::-1] if(b==a): print(a,"is pallindrome") else: print(a,"is not pallindrome")
b1fb4262fbaec727b8517cd468acb4aba2adc23e
MeghaSajeev26/Luminar-Python
/Functions/reverse_word.py
44
3.984375
4
#reverse a list a="abcd" b=a[::-1] print(b)
1b3ad19f0ab5cfe4b9c8ac2808115d6bce499dd5
MeghaSajeev26/Luminar-Python
/Flow controls/demo8.py
319
4.09375
4
#place of service age=int(input("enter your age")) sex=input("enter your sex") mar=input("enter your marital status") if(sex=='F'): print("work only in urban areas") elif(sex=='M')&(20>=age<=40): print("work anywhere") elif(sex=='M')&(40>=age<=60): print("work only in urban areas") else: print("ERROR")
faeab49dfed2ec4ce9772063fcd220d9b4eb59e1
MeghaSajeev26/Luminar-Python
/Advance Python/Regular Expression/Rulesof_Quantifiers/Rule5.py
212
4
4
#min and max group of 'a' import re x="a{2,3}" #min 2 a and max 3 a r="aaa abc aaaa aa cga" matcher=re.finditer(x,r) for match in matcher: print("match at:",match.start()) print("Group :",match.group())
cd4a8b02ac32153c308a9461a170c9086c91e948
MeghaSajeev26/Luminar-Python
/Advance Python/Regular Expression/Rulesof_Quantifiers/Rule7.py
212
4.375
4
#ending with 'a'----consider the whole string import re x="a$" r="aaa abc aaaa cga" #check string ending with 'a' matcher=re.finditer(x,r) for match in matcher: print(match.start()) print(match.group())
64f4cf84a9f9d15ec35b3cc34d87a0ec0ff70356
MeghaSajeev26/Luminar-Python
/Advance Python/Object oriented programming/Inheritence/demo1.py
586
3.875
4
#Multiple Inheritence #2 parent class for a single child class class Person: def details(self,name,age): self.name=name self.age=age print(self.name) print(self.age) class Mobile: def printval(self): print("I have 1+") class Child(Person,Mobile): def info(self,colleg...
92897ac91367b397622a60dee7d0d644c3997c6c
MeghaSajeev26/Luminar-Python
/Looping/demo6.py
169
4.0625
4
#read limits and print from lower to upper limit lim1=int(input("enter lower limit")) lim2=int(input("enter upper limit")) while(lim1<=lim2): print(lim1) lim1+=1
aa2a9b7162a504fe584bfc965d2534997d63e01b
Lcashe/Python
/main.py
2,955
3.75
4
from prettytable import PrettyTable import sys class Teacher(): def teacher_information_input(self): self.name = str(input("Enter teacher's name: ")) self.surname = str(input("Enter teacher's surname: ")) self.patronymics = str(input("Enter teacher's patronymics: ")) ...
6bd7154a5b9369d2a4cde07b1b60d62f8bee1a71
leonelparrales22/Curso-Python
/Clase_2-Operadorers_y_Expresiones/Clase_Parte_2_codigo.py
1,122
4.3125
4
# Expresiones Anidadas print("EXPRESIONES ANIDADAS") x = 10 # QUEREMOS SABER SI UN NUMERO ESTRA ENTRE 8 Y 10 # Si no cumple nos va a devolver un False # Si se cumple nos va a devolver un True # resultado = x>=8 and x<=10 resultado = 8 <= x <= 10 print(resultado) # Operadores con Asignación print("OPERADORES CON ASIGN...
157b7b83e799aa1487dedba04b5abd2148d92341
bryonkucharski/intelligent_visual_computing
/Assignment2 - A Neural Network for Eye Detection/trainNN.py
7,083
3.875
4
from __future__ import division import numpy as np from forwardPropagate import forwardPropagate from backPropagate import backPropagate from model import Model import utils import math def returnBatch(X, Y, bs): if bs==X.shape[0]: return X,Y idx = np.random.randint(0, X.shape[0], bs) return X[idx], Y[idx]...
ceeae41cd25d8da138203a53010da236281a8cf7
MariaPoliti/LCR
/LCR/frequency.py
2,210
3.859375
4
import numpy as np def freq_list(high_freq, low_freq, pts_per_decade=10): ''' Function that generates the frequency range used to investigate the impedance response of an electrical circuit Frequency Generator with log-spaced frequencies Parameters ---------- high_freq: single value (int ...
b8cd1abd1947af5b1b6d4fcd883a16df7bcbe75d
psalv/Rosalind
/Problems/8 - Counting Point Mutations.py
422
3.53125
4
__author__ = 'paulsalvatore57' def countPoints(file): """Counts point mutants between two equal length DNA strands""" file = open(file, 'r') original = None m = 0 for line in file: if original == None: original = line.rstrip() else: mutant = line.rstrip() ...
05984d56459fb9738b27f9bc1fe070ede6d948ea
uttam-kr/PYTHON
/Basic_oops.py
1,042
4.1875
4
#!/usr/bin/python #method - function inside classes class Employee(): #How to initialize attribute #init method def __init__(self, employee_name, employee_age, employee_weight, employee_height): print('constructor called') #('init method or constructor called') ---->This __init__ method called constructor self...
03cf64e69b0605cadb27645845b848a37ed4488e
mtokons/python-basics
/dictionary.py
235
4.03125
4
dictionaryExam = { "name" : "Ridoy", "id" : "12345", "year" : "2017" } dictionaryExam["name"] = "moss" print(dictionaryExam ['name']) print(dictionaryExam.get("name")) for x,y in dictionaryExam.items(): print(x,y)
4d4806bd1f67da65b79fda5605dcb4d2a04394f3
anupamsinghj/ML_LinearRegression
/LR.py
2,979
3.625
4
# Importing library import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression from sklearn import metrics # reading data file df = pd.read_csv("LR.csv") # checking data file print...
49f4d48bc9ccc29332f76af833fefa0383defea3
fadhilahm/edx
/NYUxFCSPRG1/codes/week7-functions/lectures/palindrome_checker.py
631
4.15625
4
def main(): # ask for user input user_input = input("Please enter a sentence:\n") # sterilize sentence user_input = sterilize(user_input) # check if normal equals reversed verdict = "is a palindrome" if user_input == user_input[::-1] else "is not a palindrome" # render result print("Y...
4872a55bfbdc17106db2640bbbf988bdab42ee65
fadhilahm/edx
/NYUxFCSPRG1/codes/week4-branching_statements/lectures/24_to_12.py
492
4.21875
4
print("Please enter a time in a 24-hour format:") hours24 = int(input("Hour: ")) minutes24 = int(input("Minute: ")) condition1 = hours24 // 12 == 0 condition2 = hours24 == 0 or hours24 == 12 time_cycle = "AM" if condition1 else "PM" hours12 = 12 if condition2 else (hours24 if condition1 else hours24 % 12) print("{hou...
c669a9b451f433634b95cfb59f2ebb7d8484a844
fadhilahm/edx
/NYUxFCSPRG1/codes/week8-lists/lab/maxinlst.py
127
3.65625
4
def max_val(lst): max = None for num in lst: if max is None or num > max: max = num return max
dc8dc2ac80836dae9a32ad92d0c3a701bcae4074
fadhilahm/edx
/NYUxFCSPRG1/codes/week8-lists/lectures/roll_the_dice.py
313
3.546875
4
# imports here from random import seed, randint from time import time def main(): # ask for user input user_input = int(input("Enter an integer: ")) print(list_of_dice_rolls(user_input)) def list_of_dice_rolls(n): # seed rng seed(time()) return [randint(1, 6) for _ in range(n)] main()
c90774a80721049b89b00f43f9bab31a1ed7285e
Jason-Cee/python-libraries
/age.py
879
4.1875
4
# Python Libraries # Calculating Age from datetime import datetime year_born = int(input("Enter year born: ")) month_born = int(input("Enter your month born: ")) day_born = int(input("Enter your day born: ")) current_year = int(datetime.today().strftime("%Y")) current_month = int(datetime.today().strftime("%m")) curr...
393b778150d3a861f4ebe4a3ec4ad4a4797ed753
DiksonSantos/Bozon_Treinamentos_Python
/Aula_12.py
281
3.828125
4
a = "Pizza" b = 30 c = "Suco" d = 3 print("As %s" %a, "Que custam %d" %b,"R$") print("Muito Boas") print("E o %s custa %d Reais" % (c,d)) print("Gosto de {0} Mas \n {1}R$ Esta Muito Caro para uma {0}\n Quentinha, prefiro um {2} de {3}R$ Que é Geladinho" .format(a,b,c,d))
d77058bbe4637423834c5f59e905f21721e16674
DiksonSantos/Bozon_Treinamentos_Python
/Aula_31_Modulos_Criando e Importando.py
966
4.125
4
# Modulo com funções variadas #Função que exibe mensagem de boas vindas: def mensagem (): print('Ralando pra sair dessa vida!\n') # Função para calculo de fatorial de um numero: def fatorial(numero): if numero < 0: return 'Digite um valor maior ou igual a Zero' else: if numero ==0 or numero ==1: return ...
27ceb3fce24d701a40587b94bcf6e6654aff2276
JacobK233811/BoardGameBonanza
/bgb_class_folder/bgb_classesv0.py
1,536
4.09375
4
bot_fav_color = "blue" # Creating a parent class to use for various games class Player: def __init__(self, name, fav_color): self.name = name self.fav_color = fav_color def __str__(self): if self.fav_color == "blue": return f"Hi {self.name}! My favorite color is...
4ab1fe162e01a389867b71e8a12ef31786b4d738
jeonghaejun/01.python
/ch05/ex02.py
557
4.0625
4
a = 3 if a == 3: print('3이다') if a > 5: print('5보다 크다') if a < 5: print('5보다 작다') country = "Korea" if country == "Korea": print("한국입니다") if country != "Korea": print("한국입니다") if "Korea" > "Japan": # 맨앞자리 K의 코드값이 J의 값보다 크기 때문에 한국이 더 크다 출력 print("한국이 더 크다") if "Korea" < "Japan": pr...
264e9468222fb4e6674410eab08618580ed09cf4
jeonghaejun/01.python
/ch08/ex04_리스트 관리 삽입.py
743
4.1875
4
# .append(값) # 리스트의 끝에 값을 추가 # .insert(위치, 값) # 지정한 위치에 값을 삽입 nums = [1, 2, 3, 4] nums.append(5) print(nums) # [1, 2, 3, 4, 5] nums.insert(2, 99) print(nums) # [1, 2, 99, 3, 4, 5] nums = [1, 2, 3, 4] nums[2:2] = [90, 91, 92] # 새로운 값들을 삽입 슬라이싱 print(nums) # [1, 2, 90, 91, 92, 3, 4] nums = [1, 2, 3, 4] nums[2] ...
4cdaf3fc5a721295ac801e010e6a97b33b3d91d1
JustAnAlien69/PythonStuff.3
/wordCount.py
153
3.71875
4
a = "my name is siri. I am in grade 8, in online school. I live in canada." b = a.split() count = 0 for d in b: count = count + 1 print(count)
6b264a70780c2c409105cc01ba351173da4509a1
activemeasures1189/Python-Apps
/App 4 - Book Database/frontend.py
3,039
3.65625
4
from tkinter import * import backend # Creating main window window = Tk() # Adding title to the window window.wm_title("Book Store Database System") def get_selected_row(event): try: global selected_tuple index = lb1.curselection()[0] selected_tuple = lb1.get(index) e1.delete(0,END) ...
f84ff93247b2ee23e1ec5d54713499ea853d7b96
bmampaey/SOLARNET-python-client
/SOLARNET/time.py
3,073
3.5
4
from datetime import datetime import dateutil.parser class Time: def __init__(self, *args, **kwargs): attrs = ['year', 'month', 'day', 'hour', 'minute', 'second'] # First case, we get a string if len(args) == 1 and isinstance(args[0], str): time = Time.from_string(args[0]) for attr in attrs: setatt...
3d76c3f3c7dfb7e255ad45cb6bbd0ae4061181a7
mingwy/spotboxpy
/opSpot/functions/diag.py
396
3.5625
4
# -*- coding: utf-8 -*- """ DIAG Diagonal operator and diagonals of an operator. Created on Mon Jul 15 15:57:24 2013 @author: User """ import numpy as np from size import size def diag(A): p = size(A) k = np.amin(p) d = np.zeros((k,1)) for i in range(k): v = np.zeros((p[1],1)) v[i]...
03f4a2bf29d0565807757d8005db671fe86b81a5
Tolga-Karahan/Python-Notlarim
/sets/sets.py
2,852
4
4
# set ler matematiksel kumelerin Python implementasyonudur # Herhangi tipten nesneler icerebilirler fakat kume olduklari icin her bir elemandan # yalnizca bir tane bulunmasi gerekir # set ler olusturulurken herhangi bir sequence ve ya diger iterable nesneler kullanilabilir set1 = set("A Python Tutorial") set2 = set(...
740c87debd65ef45c3828335575d43d14569f4f5
kitkitkit745/Load_Boston
/Load_Boston.py
4,477
3.75
4
""" 分类:离散型 回归:连续型 线性回归: 线性回归通过一个或者多个自变量与因变量之间之间进行建模的回归分析。 其中特点为一个或多个称为回归系数的模型参数的线性组合。 一元线性回归:涉及到的变量只有一个 多元线性回归:涉及到的变量两个或两个以上 f(x) = ∑(wi * xi) + b w权重 b偏置项,可以理解为w0*1 通用公式:ℎ(𝑤)= w0 + w1*x1 + … = w^T(转置)*x 列矩阵w = [[w0],[w1],[w2]], x = [[1], [x1], [x2]] 矩阵乘法numpy.muitiply(a, b) 损失函数(误差大小): yi为第i个训练样本的真是只 hw(xi)为第i个训...
10bfb07a871213d8d7f909be9980f4eff4a1551b
LLevella/ex1-8
/ex-1-7.py
5,920
3.671875
4
class FarmAnimal: def __init__(self, weight, growth, n_legs, cover, color, move_mode, speech, gender=""): self.weight = weight self.growth = growth self.n_legs = n_legs self.cover = cover self.color = color self.move_mode = move_mode self.speech = speech ...
064d9f39aad48d1e2618c63f5e850036feba45cb
ErikBjare/Coursera-ML-Py
/regression.py
2,529
3.671875
4
from numpy import * import unittest def linear_hypothesis(x, theta): """The linear hypothesis""" return dot(theta.T, x) def computeCost(x, y, theta, reg=None): """Does the same thing as computeCost.m and computeCostMulti.m""" m = len(x) diff_squared = square(linear_hypothesis(x, theta)-y) prin...
1ed492597830852cc3fdbdfff69bd5979970a3f2
595money/heart-disease-project
/end-to-end-heart-disease-classification.py
18,651
3.671875
4
# -*- coding: utf-8 -*- # --- # jupyter: # jupytext: # formats: ipynb,py:percent,md # text_representation: # extension: .py # format_name: percent # format_version: '1.3' # jupytext_version: 1.4.2 # kernelspec: # display_name: Python 3 # language: python # name: python3 #...
403f5380b65533c1239f5ce18b8e9cc0b1a6c6a2
AAM77/100-days-of-code
/round 1 code/r1d16_files/basic_math_operations.py
1,276
4.09375
4
# Name: Basic Mathematical Operations # Difficulty: 8 kyu # # --- sources --- # Website: CodeWars # URL: https://www.codewars.com/kata/basic-mathematical-operations/train/ruby # # # ################## # # # Instructions # # # ################## # Your task is to create a function that do...