blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
7ef5e58cc5853c231f5ab123381e1d1e94d878d2
bishnoiagrim/Python-practice
/level 1/assignment3/whileloop.py
11,037
4.0625
4
#while loops #Assignment3 on while loop #Agrim Rai - 11d #2/9/2021 ''' ASSIGNMENT 3 WHILE LOOP Q1)Print SFS 5 times. Q2)Calculate the factorial of a given number. Q3)WAP to calculate and print the sums of even and odd integers of the first n natural numbers. Q3.5) WAP to input integers till user wants...
d9677584568315fd0394686442ccd34a87b65cfa
dexterneutron/pybootcamp
/level_3/countstrings.py
381
3.953125
4
"""Exercise 1: Write a Python program to count the number of strings where the string length is 2 or more and the first and last character are the same from a given list of strings. Sample List : ['abc', 'xyz', 'aba', '1221'] """ INPUT_LIST = ['abc', 'xyz', 'aba', '1221'] count=0 for el in INPUT_LIST: if(el[0] =...
81123ca58739a42f3ced7c8a21dc03bade6605c0
MaximilianKlein92/Step-Intervall-Trainer
/Command-LineTrainer.py
3,291
4.15625
4
# This Programms runs a Timer for a Pyramid-Intervall training # where the pause is as long the exercise #import time for the time.sleep(x) funktion what will pause the code for 1 second import time def Duration (a = 0): # The user can determine the length of the Rounds in minutes. If one does not enter the cor...
892ebff59dd719ffd214f1d53c99ea4976627bf8
Inimesh/PythonPracticeExercises
/2 if statement exercises/Ex_57.py
447
4.40625
4
## A program that determines if a year is a leap year ## # propmting user input year = float(input("Please enter a year to find out if it is a leap year: ")) # Checking leap year conditions if year % 400 == 0: leap = True elif year % 100 == 0: leap = False elif year % 4 ==0: leap = True else: leap = Fal...
4b0b542d1962fcb68060e4f16978058b439e981f
DrakeVorndran/aStar_maze_solving
/Maze.py
2,081
4.1875
4
class Maze: """ A class for repersenting mazes """ def __init__(self, height=10, width=10, walls=[], start=(0,0), end=None): """ walls should be an array of tuples, with the first value being the x coord and the second value being the y coord of a cell (indexed at 0 with the top ...
9ee0dd3becfc27e093c00769cbdcbdb172ae4445
pavel-malin/python_work
/hello_admin.py
2,775
4.125
4
# Say hello to all users user_name = ['adam', 'guest1', 'guest2', 'admin', 'fiz'] if user_name: for user_names in user_name: print("Hello user: " + user_names.title() + ".") else: print("Adding list users") if user_name: for user_names in user_name: print("Hello user: " + user_names.titl...
4fbcf8d260db5294fada0a858efc71f25a18a1f4
coniconon-zz/py4e_2019
/course_1/assignment_03_01/rateperhour_v2.py
265
4.0625
4
hrs = input("Enter Hours:") rate = input("Enter Rate:") h = float(hrs) r = float(rate) if h <= 40.0 : pay = h * r print(pay) elif h > 40.0 : extra_hours = h - 40.0 extra_pay = extra_hours * (r * 1.5) pay = (40.0 * r) + extra_pay print(pay)
cd44535dcecb619a30090ac78f0bf17dc8acb454
ximena777/ejercicio1
/ejercicio1_c.py
133
3.609375
4
#1.c def suma(numero1,numero2): print int(numero1)+int(numero2) N1=raw_input("Ingrese N1:") N2=raw_input("Ingrese N2:") suma(N1,N2)
33702906214d2a29ee565f946a85eaa984c21577
Hipstha/scrapping
/python/poo.py
587
3.625
4
class Casa: #Constructor def __init__(self, color): self.color = color self.consumo_de_luz = 0 self.consumo_de_agua = 0 # todas los métodos deben tener self def pintar(self, color): self.color = color def prender_luz(self): self.consumo_de_luz += 10 def abrir_ducha(self): self.co...
20a7d698d41662b08767a75fa422c26825c8b48c
haru-256/bandit
/policy/_stochastic_bandits.py
5,692
3.5625
4
"""define some policy""" from abc import ABC, abstractmethod from typing import Union import numpy as np from ._check_input import _check_stochastic_input, _check_update_input class PolicyInterface(ABC): """Abstract Base class for all policies""" @abstractmethod def select_arm(self) -> int: """...
96adfdfef9aa2143fd6f78289912644eb167d68b
inigopm/text2imageApp
/util/pictures.py
1,128
3.84375
4
from os import listdir, rename from os.path import isfile, join import random def retrieve_pictures_names_in_folder(folder_path: str): """ This functions returns a list with the file names of a given folder. folder_path (str): path of the folder that we are going to check """ pictureList = [] ...
15874f6bc1f1eb758e9728a3de44aa23e90f0de2
hsiang0107/python
/python101/2017/multipler.py
303
3.921875
4
InputStr = input('Please input an integer:') num = int(InputStr) if num <= 0: raise ValueError('must greater than 0 !') for first in range(1, num+1): for second in range(1, num+1): result = first * second print('{0} * {1} = {2}'.format(first, second, result)) print('')
b6d25d3ebf44030cb11854bbccd227191e6edc03
omer-ayhan/Python101
/Alıştırmalar/alıştırma_2.1.py
596
3.953125
4
def computePay(hrs): if hrs>=0 and hrs<=40: # pay is 10 TL between 0 and 40 hours pay = 10 elif hrs>40: # pay is 15 TL if it's more than 40 hours pay = 15 else: print("please enter a valid number") quit() # computes the brut pay return hrs * pay try: ...
ac52a754e13dadc34c4ee80c2e58c655a6d037bf
vivek28111992/Python_100Days
/Day19/generator.py
831
4.28125
4
""" The generator is a simplified version of the iterator """ def fib(n): """builder""" a, b = 0, 1 for _ in range(n): a, b = b, a+b yield a """ The generator evolved into a coroutine. The generator object can send()send data using methods, and the sent data will become yieldthe value obtained by the e...
5e5a42db9755e7b76ad8ad842e6c759e480723d9
pbarton666/PES_Python_examples_and_solutions
/solution_python1_chapter05_function.py
895
4.25
4
#solution_python1_chapter05_function.py def outer_function(operation, subtract_this): "takes an operation and a number to subtract" thing_to_subtract=subtract_this def add_me(a, b): "adds two numbers" return (a + b) def mult_me(a, b): "multiplies two numbers" return a * b #a dict of pos...
eefe89bd4b1b648369f0a34143bc0397ad686811
khadak-bogati/Introduction-to-Computer-Science-and-Programming-Using-Python
/Prblomeset2.py
3,236
3.96875
4
Write a program to calculate the credit card balance after one year if a person only pays the minimum monthly payment required by the credit card company each month. The following variables contain values as described below: balance - the outstanding balance on the credit card annualInterestRate - annual interest ra...
63920c7febe60b5bbb68790bec7ed607e53cf47f
QiWang-SJTU/AID1906
/Part1 Python base/02Object_oriented/03Exercise_code/Day09/assignment01.py
496
3.59375
4
class Cat: def __init__(self, name, age, sex): self.name = name self.age = age self.sex = sex def play(self): print("有一只名为%s,%d岁的%s猫在玩耍" % (self.name, self.age, self.sex)) my_cat = Cat("Eva", 2, "母") my_cat.play() class Computer: def __init__(self, brand):...
4290b0544db0ba87e6af6de075b7407681ea30d3
acidjackcat/codeCampPython
/Training scripts/Cars_p1.py
163
3.65625
4
fname = 'Igor' lname = 'Awesome' print(('Hello {0}, your full name is {0} {1}'.format(fname, lname))*5) geeks = 'Geeks for Geeks' print(('{0}'.format(geeks))*3)
0989915dc33ecb8742d063b957087de16d058abc
CyberAmmo/book-scraping
/menu.py
942
4
4
from app import books USER_CHOICE = '''Enter one of the following: - 'b' to look best books - 'c' to look at the cheapest books - 'n' to get the next book on the page - 'q' to exit Enter your choice: ''' def print_best_books(): best_books = sorted(books, key=lambda x: x.rating * -1)[:5] for book in bes...
23735f7b40479d0d73e9fd548c79bf986443a3bd
jaxonL/adventofcode
/2018/5/polymer.py
6,958
3.8125
4
# assuming ascii input test1 = 'dabAcCaCBAcCcaDA' test2 = 'aabAAB' test3 = 'Xxadf' test4 = 'XxSsdDIijNnJACszZScZfFhHQyYrRqzdXTtxDEeNnGgOaAcCMcCLlMmogQeEqGgFfGyYuUOIiYyhHlLmUulAUKkudDOoDdaLGRrgoDdDdGgRruUhJLljQqdwWDZzHXxppPTwWCcZzDmfFlLPpdDSsgGtFfTEeTOotyYMOGgkJjKZUuQdNnDhHvVntKkTNqTjJeEVkZzttTYyTDdIiRrqQyYYyxbBXLlKHhvt...
70dbdf2df86bb5bc27e885a4d688efca99c650c2
jbrummal/pythonclass
/Alta3DropBox/listcsv-02.py
632
3.765625
4
#!/usr/bin/python3 """using csv data""" import csv def main(): # subscriberdat = open('mockcsv.csv', 'r') with open(r'C:\Users\Achimedes\Dropbox\2019-05-06 vzw pyans\mockcsv.csv', 'r') as subscriberdat: subscriberlist = csv.reader(subscriberdat, delimiter=",") print(subscriberlist) ...
0c590e8a3273592e5efdb213ac2d171ca647b580
yamendrasinganjude/200244525045_ybs
/day9/vehicalRegNumValidOrNot.py
377
3.890625
4
''' 4. Write a python program to check given car registration number is valid Maharashtra state registration number or not? ''' import re vehicalNum = input("Enter Vehical Number : ") matched = re.fullmatch("MH\d{2}[A-Za-z]{2}\d{4}", vehicalNum) if matched != None: print(vehicalNum, "is Valid Vehical number..") els...
9b1b2dc8229db4749f30b1af329ea27b28120206
shahil-chauhan/python_programs
/Q9.py
652
3.796875
4
''' Write a program that computes the net amount of a bank account based a transaction log from console input. The transaction log format is shown as following: Suppose the following input is supplied to the program: D 300 D 300 W 200 D 100 D means deposit while W means withdrawal. Then, the output should be: 500 '''...
472d50778779715026cb861317989330d882418a
kujin521/pythonObject
/第五章/列表/range函数生成列表.py
584
4.3125
4
'''任务:输入一个整数num,用range()函数产生一个从num开始的10个整数组成的列表listx; 将列表listx中的每个元素的值乘以2,形成一个新的列表listy,输出两个列表。 ''' #####请在下面标有序号的注释后面填写程序##### # (1)输入整数num num=int(input()) # (2)用range()函数产生列表 listx listx=list(range(1, 11)) # 输出列表 print(listx) # (3)将列表listx中的每个元素的值乘以2,形成一个新的列表listy listy=[x*2 for x in listx] # 输出列表 print(listy) #...
e4e1c66403e0416a9bde8b2610b2a2a809171023
alona22193/wwc
/conditionals.py
1,105
4.1875
4
#temp = int(raw_input('What is the temperature?')) #print('You should bring the following items:') #if temp <= 40: # print('Coat') # print('Hat') # print('Gloves') #elif temp <= 70: # print('Coat') # print('Hat') #else: # print('Nothing!') #meal_price = raw_input('How much was your meal?') #tip = f...
26b3637b63a007a57d880156dfb1f3b274ba4dc7
josh-W42/huffman_encoding
/problem_3.py
10,607
4.09375
4
import sys, heapq def huffman_encoding(data): ''' Compresses the data given by encoding it into binary by the huffman algorithm. Args: data(str): information to be compressed Returns: Encoded Data(str) of binary code. A tree generated from the huffman algorithm used...
06a68e0677fa8a7489a032be611ce5dd0b86e3b7
shruticode81/GeekforGeek_quiestions
/hackerrank/shape.py
313
3.796875
4
t = int(input()) for _ in range(t): shape = input().lower() a = int(input()) b = int(input()) if shape == "rectangle" and a == b: print(a*b) elif shape == "square": print(int((a*b)/2)) elif shape == "triangle" : print(a*b) else: print("0")
36eabb29fc258c68e6f0ae60d50df17fd141adb8
chasegarsee/code-challenges
/Algorithms/BinarySearch.py
448
3.890625
4
# Eliminate half the numbers every time with binary search. def binary_search(list, item): low = 0 high = len(list) - 1 while low <= high: mid = low + high guess = list[mid] if guess == item: return mid if guess > item: high = mid - 1 els...
0b6a66b3d565c4d8523e1f2e8e1e8fa2a12adc8e
IvanDimitrov2002/school
/tp/oct_25.py
1,009
3.5625
4
from time import sleep class Iterable: def __init__(self, max): self.max = max self.numbers = [] def __iter__(self): if(len(self.numbers) == self.max): return iter(self.numbers) self.number = 0 return self def __next__(self): if(self.number < s...
319a46ca2dfea84d5572e32af20063402713992a
nidhijain1/Testingworld
/prime Number.py
217
4.03125
4
num=int(input()) if num>1: for i in range(2,num): if (num%i)==0: print("number is not prime"+ str(num)) break else: print("number prime"+str(num)) #prime number
3775f7f5e332ff2a68a8db42a1cd37e96b43a650
Roy-Wells/Python-Code
/算法第四版(python)/第一章 基础/04Stack.py
446
3.984375
4
""" P79.栈 class queue.LifoQueue(maxsize=0) LIFO即Last in First Out,后进先出。与栈的类似,使用也很简单,maxsize用法同03Queue。 ***其实在python中不区分队列以及栈, 只有"queue.Queue"(FIFO先进先出队列)以及"queue.LifoQueue"(LIFO后进先出队列)两种不同的队列方法。 """ import queue q = queue.LifoQueue() for i in range(5): q.put(i) while not q.empty(): print(q.get(...
d7c8fa183d6fdd48047ed136934baa7c3303f85a
ZihengZZH/LeetCode
/py/PalindromePartitioning.py
822
4.09375
4
''' Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For example, given s = "aab", Return [ ["aa","b"], ["a","a","b"] ] ''' # Divide the string to check whether two parts are palindrome # Further check if each part conta...
87dcbac8aca5550f816ef581dc33bdbfcf4f68ce
AceRodrigo/CodingDojoStuffs
/Python_Stack/_python/python_fundamentals/Rodriguez_Austin_VS_Loop_Basic_2.py
2,545
3.734375
4
# #Challenge 1 Biggie Size # def biggie(arr): # newArr = [] # for i in range(len(arr)): # if arr[i] >= 0: # newArr.append("big") # else: # newArr.append(arr[i]) # return newArr # print(biggie([-1, 2, 5, -5])) # #Challenge 2 Count Positives # def myFunc(a): # c...
027d1c883526bfbc0012997510da979e635ff811
ivadimn/py-input
/skillbox/basic/module26/module26-3.py
1,830
3.765625
4
import random """ class CountIterator: __count = 0 def __iter__(self): CountIterator.__count = 0 return self def __next__(self): result = CountIterator.__count CountIterator.__count += 1 return result my_iter = CountIterator() for i_elem in my_iter: print(i_e...
692a526cc2dded414d36932bb6dd43bbf078a222
Galileo0/security_system_based_on_etherum
/Auth-out/RTQR.py
2,700
3.6875
4
import zbar from PIL import Image import cv2 from pyzbar.pyzbar import decode #import Gate_BC def main_j(): """ A simple function that captures webcam video utilizing OpenCV. The video is then broken down into frames which are constantly displayed. The frame is then converted to grayscale for better cont...
b71fb0836babcf687d42dd234a11e8d68b7944c8
KimTaesong/Algorithm
/CodingTest_Study1/week20/가운데글자가져오기.py
172
3.53125
4
def solution(s): n = len(s) if n % 2 == 0: return s[n//2-1:n//2+1] return s[n//2] s = ["abcde", "qwer"] for i in range(2): print(solution(s[i]))
2e0875fc7774a1e62af7d6ddfac85e3e9a4f3cec
tsuetsugu/vimrc
/develop/learn_python/rename_files.py
493
3.71875
4
import os def rename_files(): # (1) get file names from folder file_list = os.listdir("/Users/toshi/develop/learn_python/prank") print(file_list) saved_path = os.getcwd() print("Current Woking Directry is "+saved_path) os.chdir("/Users/toshi/develop/learn_python/prank") # (2) for each file,...
507a7ac5f9f7931d7440cb02898b59587bdd3f72
MaChimal/AdventOfCode2020
/day3/day3_1.py
345
3.59375
4
### Day 3: Toboggan Trajectory ### ## Part 1 answer = 0 map_ = [] for _x in open("day3.txt"): _x = _x.strip() map_.append(_x) row = 0 col = 0 m = len(map_) while row+1 < m: row += 1 col += 3 position = map_[row][col % len(map_[row])] if position == "#": ans...
cf8b2753725788fa9ad8975e8d5cea2d67fa7f7c
h-sdl/projet-npm3d
/src/RANSAC.py
3,558
3.703125
4
# -*- coding: utf-8 -*- import numpy as np from utils.ply import write_ply, read_ply import time def compute_plane(points): """ Computing a plane passing through 3 input points Parameters ---------- points : 3x3 numpy array (3 points stacked in a row-wise way) Returns ------- point :...
b781f95699002cdfc89722537cf237b7a5fd2faa
therealiggs/oldpystuff
/test.py
1,301
3.515625
4
with open('smartguy.txt') as file: text = [line for line in file] def code(word,key): ans = [] klst = list(key) i = 0 for line in word: k = ord(klst[i%len(klst)]) e=line.encode('cp1251') s = bytes([(byte + k)%256 for byte in e]) ans+= s.decode('cp125...
c69c71417cd1719b40e855f0c1e918d24c2190c3
Juahn1/Ejercicios-curso-de-python
/ejercicio_3_radio_y_longitud.py
342
3.671875
4
import math try: r= float(input("Ingrese el radio: ")) def area_y_longitud(r): area = math.pi*(r**2) longitud = 2*math.pi*r print(f"El area es {area:.4f} y la longitud es {longitud:.4f}") print("") area_y_longitud(r) print("") except: ValueError print("Ingre...
50255d80b0dcbc597be403f026aca7d04a348043
gabrielpereirapinheiro/client-server-python
/Server.py
4,486
3.703125
4
from socket import * #SERVER #Victor Araujo Vieira #Gabriel Pereira Pinheiro #Funcao que mostra na tela o que foi recebido def show_index(message,aux): print 'Foi recebido a mensagem-> ',message[len(message)-3] print 'index -> ',aux[0] if(len(aux)==3): print 'flag -> ',aux[2] if(aux[2]=='0'): print '-----...
47320b36008dcb00c789c0e08ff99db94e2956bb
tongbc/algorithm
/src/justForReal/maxSlidingWindow.py
635
3.515625
4
from collections import deque class Solution: def maxSlidingWindow(self, nums, k): res = [] bigger = deque() for i, n in enumerate(nums): # make sure the rightmost one is the smallest while bigger and nums[bigger[-1]] <= n: bigger.pop() # ...
b0c3843186deeea22f9bd41cdccce569b5b0396e
Moejay10/IN4110
/Assignment5/exercise_5_3/collect_dates.py
5,638
3.84375
4
#!/usr/bin/env python # importing modules import argparse import numpy as np import requests as req import os import sys import re import pandas as pd import datetime sys.path.append('../') from exercise_5_1.requesting_urls import get_html def main(): """Tests the implementation of the functions find_dates ...
011437353074417d751107a03bd7aa973bb25b8b
cubeguerrero/euler-problems
/010/solution.py
435
3.703125
4
import math def is_prime(n): for i in range(2, round(math.sqrt(n))): if n%i == 0: return False return True def solution(n): total = 0; for i in range(2, n): if is_prime(i): total += i; return total if __name__ == "__main__": import time start_tim...
1ab73524eae5070af7f7500adc46c88359de4616
anatdaplanoi/PML-Project-PSIT
/sexrate.py
1,101
3.53125
4
"""This program is shows graph about percentage teenage pregnancy of the second period.""" import pylab def main(): """The graph shows the sex rate""" read = open("/Users/porpiraya/Desktop/data_sexrate.txt", "r") da_lis = [] da_year = [] da_per_a = [] da_per_b = [] count = 0 for i in re...
598954f677b595b0c90dcd04aef3cc947a60082a
spardok/IFT383
/IFT383-06py/HO6-1.py
687
3.828125
4
#!/usr/bin/python varIn1 = raw_input("Please enter the first exam score in the form score/max: ") varIn1 = eval(varIn1 + str(0.0)) varIn2 = raw_input("Please enter the second exam score in the form score/max: ") varIn2 = eval(varIn2 + str(0.0)) varIn3 = raw_input("Please enter the third exam score in the form score/max...
e9fd87575633712fede583bb4636ea2b87124775
kaia-c/RoverClass
/pressureSensor.py
1,044
4.0625
4
import turtle from Arduino import Arduino pin=14 #A0 startPressure=295 #the reading we get with no pressure startSize=10 #which we will equate with drawing a radius of 10px modifyFactor=10 #modified by a factor of 10 board=Arduino('9600', 'COM6') board.pinMode(pin, 'INPUT') #set up turtle pe...
10f45dd13a77c3b5888a28af64cf6d6b4de7c13e
archiver/spoj
/histogra.py
759
3.59375
4
from collections import namedtuple import sys Info=namedtuple('Info',('start','height')) def maxarea(hist): stack=list() top=lambda : stack[-1] area=0 for pos,height in enumerate(hist): start=pos while True: if not stack or height>top().height: stack.append(Info(start,height)) ...
22974e861fc3fef6eafa7e0d78ca01a523729247
Snoblomma/HackerRank
/Python/Math/Find Angle MBC/FindAngleMBC.py
240
3.578125
4
import math AB = int(input()) BC = int(input()) AC = math.sqrt(AB**2 + BC**2) MC = AC/2 BM = MC s = (BM**2+BC**2-MC**2)/(2*BM*BC) phi = math.degrees(math.acos(s)) degree_sign= u'\N{DEGREE SIGN}' print (str(str(round(phi))) + degree_sign)
1aa6f9f8e8575ead340cda9cc1eb42e7d0735458
DaHuO/Supergraph
/codes/CodeJamCrawler/16_0_2/ronitrex/Beatrix.py
708
3.609375
4
def flip(N): global i if '-' not in N: return if '+' not in N: i+=1 return if N[0]== '-': x = N.index('+') NewN = N[:x] OldN = N[x+1:] NewN = NewN.replace('-','+') N = NewN+OldN # print(NewN, OldN, N, 'Craft') # print(N) ...
4e3d0feafa9b5d36a2c089c64ad0e8a213c0edc5
xiaoxiae/MO-P-68
/Teoretické/Úloha 3/uloha3.py
1,330
3.84375
4
from functools import cmp_to_key def translatePoints(points, x, y): """Translates the coordinates of points.""" for point in points: point[0] += x point[1] += y def comparator(p1, p2): """The comparator used for the sorting""" value = p1[0] * p2[1] - p2[0] * p1[1] if value < 0: ...
7db4b4cc814c8be54c1e9b786e66f3241ead5b56
zhaoyufei007/Coursera-Python-for-everybody
/Assignment 7.2.py
958
4.25
4
Write a program that prompts for a file name, then opens that file and reads through the file, looking for lines of the form: X-DSPAM-Confidence: 0.8475 Count these lines and extract the floating point values from each of the lines and compute the average of those values and produce an output as shown below. Do ...
ff204244ecf4286177f8fb385107e5d9b492cad8
snowdj/cs_course
/Algorithms/challenges/lc054_spiral_matrix.py
587
4.21875
4
""" Time: O(m*n) Space: O(min(m,n) * m*n) extra space for recursion, or O(m*n) iteratively. Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example, Given the following matrix: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] You should return [1,2,3,6,9,8,7,4...
42aca9aa6fd8ed60bcb594295c98ef9d48376da0
JeffreyAsuncion/CodingProblems_Python
/Lambda/alphabeticShift.py
986
4.3125
4
""" Given a string, your task is to replace each of its characters by the next one in the English alphabet; i.e. replace a with b, replace b with c, etc (z would be replaced by a). Example For inputString = "crazy", the output should be alphabeticShift(inputString) = "dsbaz". Input/Output [execution time limit] ...
a87a2d44698a187c6150f47ae02006bb29702271
audreyemmely/Python-programming
/testExercise1.py
215
4
4
age = int(input("Digite a sua idade: ")) if age >= 18: print("Parabéns, você já pode ser preso! :)") elif age > 0 and age < 18: print("Você ainda é menor de idade.") else: print("Idade inválida.")
4ca71ae53fe20410ab36d4e86e9dec1461f8a619
haohsun/TQC-Python
/PYD210.py
267
4
4
side1 = eval(input()) side2 = eval(input()) side3 = eval(input()) perimeter = side1 + side2 + side3 #TODO if side1 + side2 > side3 and side3 + side2 > side1 and side1 + side3 > side2: print(perimeter) else: print("Invalid") """ Invalid """
5045d97166a5b439a9f49eb42d008d0b44c0e1bd
VivekaMurali/Python
/py lab exam/p1.py
222
4.34375
4
#1.Write a recursive function to find factorial of a number. def fact(n): if n==1: return 1 else: return n*fact(n-1) n=int(input("Enter a number:")) print('Factorial of',n,'is',fact(n))
49c029af3c4396ebc2498257c562b9b7d41e9fe4
EachenKuang/LeetCode
/code/110#Balanced Binary Tree.py
1,331
3.75
4
# https://leetcode.com/problems/balanced-binary-tree/description/ # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): # 1 使用104中的maxDepth def isBalanced(self, root): ...
41c0031cf363922f4a0684ff2243f47b7c319b48
blakegolliher/boxes
/drawabox.py
470
3.75
4
#!/usr/bin/python import sys import argparse parser = argparse.ArgumentParser() parser.add_argument("width", type=int, help="The width of the box.") parser.add_argument("height", type=int, help="This will be the height of the box.") args = parser.parse_args() width = args.width height = args.height def box(width,hei...
292327f8d7600e4d96df958ea7a8b7a237ef4fc4
harshitpal660/harshitpal660
/practise set-4.py
1,335
3.90625
4
'''Q1 WAP to store 7 fruits in a list entered by the user''' # f1=input("Enter Fruit number 1: ") # f2=input("Enter Fruit number 2: ") # f3=input("Enter Fruit number 3: ") # f4=input("Enter Fruit number 4: ") # f5=input("Enter Fruit number 5: ") # f6=input("Enter Fruit number 6: ") # f7=input("Enter Fruit numb...
894aa72d87fbbd6829b96364bcb5a26ddbd38f58
vulmoss/practice
/0610/2.py
482
3.578125
4
#!/usr/bin/env python # coding=utf-8 class Student(object): @property def score(self): return self._score @score.setter def score(self,value): if not isinstance(value, int): raise ValueError('score must be an integer!') if value < 0 or value > 100: raise ...
a54fad0fe57dfacfb125203156aac5064856b539
RedL0tus/CSClassworks
/2017-11-PythonTasksII/semordnilap.py
718
4.34375
4
#!/usr/bin/env python3 #-*- encoding:utf-8 -*- """Computer Science P classword finding semordnilap words""" def get_semordnilap(filename): """Find semordnilap words inside the given file""" semordnilap_list = [] wordlist = [] file = open(filename) for line in file: wordlist.append(line.stri...
73426fb529d95a506d390ad388f4c30b2375cabf
yuthreestone/LanQiao-Learning
/第十届蓝桥杯大赛c++大学C组/年号子串.py
90
3.609375
4
num=2019 s='' while num: s+=chr(ord('a')+num%26-1).upper() num//=26 print(s[::-1])
94bfeceb46937903fb45e9de651f5c7d82aeef13
Taoge123/OptimizedLeetcode
/LeetcodeNew/python/LC_391.py
2,911
3.984375
4
""" Given N axis-aligned rectangles where N > 0, determine if they all together form an exact cover of a rectangular region. Each rectangle is represented as a bottom-left point and a top-right point. For example, a unit square is represented as [1,1,2,2]. (coordinate of bottom-left point is (1, 1) and top-right poin...
0c910491b386a0c3966b77e24c2d1b8ffb50d296
chicocheco/checkio
/elementary/digits_multiplication.py
876
4.15625
4
# done in 2 hours # next time: to iterate over digits, convert to string. After variable 'last' gets a value it can be merged with # the variable 'product' because I'm interested only in the product of the last two number in next iterations. def checkio(number: int) -> int: new_list = [num for num in str(number)] ...
865befb4b9b9df2dc2fdae262270f526cd550217
LeslieWilson/python_playground
/Chapt10.py/elevenProblem.py
2,079
4.125
4
""" Leslie Wilson April 12 2018 elevenProblem.py """ from random import * class Card(object): """creates card object with a rank and suit""" def __init__(self, rank, suit): self.rank = rank self.suit = suit def getrank(self): """deliniates the rank of a card depending on wha...
6efd439875102c004205f2200834c0315d8c2b56
Akhileshbhagat1/All-prectice-of-python
/mergingTWOlistItemsINTOaSingleLIST.py
501
4.0625
4
# merging two list's values into a single list # list1 = [1, 2, 3, 4] # list2 = ['a', 'b', 'c', 'd'] # list1.extend(list2) # print(list1) # or # list3 = [1, 2, 3, 4] # list4 = ['q', 'e', 'w', 't'] # # list5 = [] # for i in list3: # list5.append(i) # for j in list4: # list5.append(j) # print(list5) # or # li...
9f887a30ec14e4eff437c4e0a031ef2c61cc59b8
Brandon-Martinez27/python-exercises
/control_structures_exercises.py
11,965
4.375
4
#!/usr/bin/env python # coding: utf-8 # ### 1. Conditional Basics # #### a. prompt the user for a day of the week, print out whether the day is Monday or not # In[1]: valu = input("Enter day of the week: ") print(valu) # In[2]: if valu.lower() == 'monday': print("Today is Monday") else: print("Today i...
5df896df051c8ce0ff5cc2f76d2476ee10283f8e
navnoorsingh13/GW2019PA2
/venv/Session20B.py
433
4.125
4
import pandas as pd numbers = [10, 20, 30, 40, 50] ages = {"John":30, "Jennie":26, "Jim":12, "Jack":22, "Joe":33} S1 = pd.Series(numbers) S2 = pd.Series(ages) print(S1) print() print(S2) print("----------") # Access Elements in Series by indexing print(S1[1]) print(S2["John"]) # Slicing in Series print(S1[1:]) pr...
8c4559a5e60bf4d40e20b6ffcb027234962c828e
Silentsoul04/FTSP_2020
/CodeBasics_Pandas/Reshape_dataframe_using_melt()_Pandas.py
3,133
3.65625
4
# -*- coding: utf-8 -*- """ Created on Mon Apr 13 11:11:49 2020 @author: Rajesh """ import pandas as pd df = pd.read_csv('E:\CodeBasics_Pandas\Pandas_CSV_CB\weather4.csv') df.head() ------------- day chicago chennai berlin 0 Monday 32 75 41 1 Tuesday 30 77 43 2 ...
272594cf74dc71f9ddf702062cc8e429cfcfb255
poojithayadavalli/Graph
/detectCycle.py
1,329
3.546875
4
""" Pandu is interested in solving problems on Graph data structure and while he is solving those problems he noticed a problem statement as follows: Given a directed graph with V vertices and E edges. You need to detect whether the graph contains any cycle formation of vertices or not. If it is cyclic graph print "y...
f0bdf58a9957eafcf68ab1f4094929d561b5a6b3
loveiset/corePythonExercises
/13-20.py
1,203
3.75
4
class Time60(object): # def __init__(self,hr=0,min=0): # self.hr=hr # self.min=min def __str__(self): return '%02d:%02d' % (self.hr,self.min) def __repr__(self): return '%s("%02d:%02d")' % self.__class__,self.hr,self.min def __init__(self,*val): if type(val[0]) is tuple: self.hr=val[0...
24ec1f5b3116f3817ed69f952f018d7206c7d990
anjolinea/Python-for-Everybody
/ch10ex2.py
400
3.546875
4
fname = input("Enter file name>> ") if len(fname) < 1: fname = "mbox-short.txt" fhand = open(fname) hours_dict = dict() for line in fhand: if line.startswith("From "): words = line.split() hour = words[5].split(":")[0] hours_dict[hour] = hours_dict.get(hour, 0) + 1 for hours_address, h...
0b6982fc578b598e8ddf7c0010ba5b23f2fa5fd1
clarkkentzh/python
/class/fa_son.py
713
3.71875
4
#coding=utf-8 # 父类的方法和变量都会被子类继承,__init__也会被继承 class Father(object): def __init__(self,name): self.name = name door = 4 def fun(self): print "这是父类的方法" class Son(Father): pass # 子类在父类的基础上改变变量 class Son1(Father): door = 2 # 子类在父类的基础上增加方法,也可以改变父类的方法 class Son2(Father): def fun(se...
c2cdf683a1e49be60236ac180495a67455024e3c
nekapoor7/Python-and-Django
/PythonNEW/Practice/StringVowels.py
163
3.984375
4
"""Python | Program to accept the strings which contains all vowels""" import re s = input() s1 = s.lower() ss = re.findall(r'[aeiou]',s1) print(len(ss)) print(ss)
800f1dacfb7aa116b363286f562d003fad274de1
yiguming/python
/15_29.py
425
3.5625
4
#!/usr/bin/env python import re #800-555-1212 #patt = '(\(\d{3}-?\)?\d{3}-\d{4}' patt = r'(\d{3}-|\(\d{3}\))?\d{3}-\d{4}' phonenumber1 = "800-555-1212" phonenumber2 = "555-1212" phonenumber3 = "(800)555-1212" m1 = re.match(patt,phonenumber1) m2 = re.match(patt,phonenumber2) m3 = re.match(patt,phonenumber3) if m1 is not...
64c7f810bdb85e7c40be429ea30163a9e30b2b53
lukeolson/cs450-f20-demos
/demos/upload/nonlinear/Newton's Method.py
701
4.125
4
#!/usr/bin/env python # coding: utf-8 # # Newton's Method # In[85]: import numpy as np import matplotlib.pyplot as pt # Here's a function: # In[86]: def f(x): return x**3 - x +1 def df(x): return 3*x**2 - 1 xmesh = np.linspace(-2, 2, 100) pt.ylim([-3, 10]) pt.plot(xmesh, f(xmesh)) # In[87]: guess...
792831fa222f22b4cf36de5ccb02cb651f0fc3d0
joaocbjr/EXERCICIOS_curso_intensivo_de_python
/exe6.7.py
737
3.78125
4
print('\n6.7 – Pessoas:\n' ' Comece com o programa que você escreveu no Exercício ' '6.1(página 147). Crie dois novos dicionários que representem' ' pessoas diferentes e armazene os três dicionários em uma ' 'lista chamada people. Percorra sua lista de pessoas com ' 'um laço. À medida que percorrer ...
aef2854cd60157967dbac9fe2792ace0dc56f764
amkelso1/Module11
/inheritance/Employee.py
720
3.53125
4
""" Author: Alex Kelso Date:10/4/2020 program: employee.py purpose: constructor and method for employee info """ from datetime import date class Employee: """Employee Class""" # Constructor def __init__(self, lname, fname): self.last_name = lname self.first_name = fname @property ...
9a044a6fbe03e13716778c0ade33ff9f5e743ac3
code-learner37/Think-Python
/chapter6.py
1,320
3.9375
4
# 4 - 6 - 2017 # Chapter 6 # 6-1 ''' The program prints 9 90 8100 it sums the values of all arugments in function c and then times it by 10, and finally return the sqaure of it. ''' # 6-2 Ackermann function def ack(m, n): if m == 0: return n + 1 if m > 0 and n == 0: ret...
76d23754a4e1ae9fa09325cdbd766899ce87f857
yuyurun/nlp100-2020
/src/ch01/ans09.py
608
3.84375
4
#!/usr/bin/env python # -*- coding:utf-8 -*- import random def shuffle_word_str(text): ans = '' for word in text.split(): if len(word) > 4: l_word = list(word) create_word = l_word[0] + ''.join(random.sample( l_word[1:len(word)-1], len(l_word)-2)) + l_word[len(w...
0d3f33e045f6b86fcedd06f1331650a4989b3d28
rzhang1654/pyco
/4a.py
327
3.59375
4
#!/usr/bin/env python def iterable(obj): try: iter(obj) return True except TypeError: return False # Driver Code for element in [34, [4, 5], (4, 5),{4,5}, {"a":4}, "dfsdf", 4.5]: print(element, " is iterable : ", iterable(elem...
09b1ed79fe8c5d2dc4269789b4759e3bc353eb2e
rahul0124/Guvi_programs
/p50.py
168
3.796875
4
num=int(input()) while(1): if num%2==0: num=num//2 if num==1: print("yes") break else: print("no") break
f2f6896ca5dbd303a5bcfebb3859a7fd3bf16d15
jeff-cangialosi/learn_python
/ex5.py
857
4.125
4
# Exercise 5 # This was coded while listening to the Hamilton soundtrack mb_name = 'Giannis' mb_age = 25 # I think this is correct mb_height = 84 # Also a guess but probably close mb_weight = 260 # Hopefully close mb_eyes = 'Brown' mb_teeth = 'White' mb_hair = 'Black' print(f"Let's talk about {mb_name}.") print(f"He'...
a495d3279d9ad169d6168b2a3cb149355f0d75b7
jangjichang/Today-I-Learn
/Algorithm/Programmers/H-Index/test_h_index.py
724
3.515625
4
citations = [4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6] result = 6 def test_simple(): assert solution(citations) == result def solution(citations): # citations = sorted(citations, reverse=True) # answer = 0 for value in range(max(citations), 0, -1): up = 0 for i in citations: ...
41b026b1fd9ea77f1a5fcdd82c2bf3dc203673c9
balajisomasale/Udacity_Data-Structures-and-algorithms
/P0/Task2.py
1,492
4.125
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 ...
68b6376e2bf444eb23b81be18899b82397761590
devdattachore/selenium-python-practice
/src/1_python/5_fileHandling/writeFile.py
343
4.5
4
# read a file and # reverse its contents and # write reversed contents in file with open("test.txt", "r") as reader: lines = reader.readlines() print(lines) with open("test.txt", "w") as writer: reversedLines = reversed(lines) print(reversedLines) for line in reversedLines: ...
c125b76f8cf43a78219a886c740a6a44b0c2d985
DamonMok/PythonLearning
/MySQL数据库_MySQL与Python交互_2.增加、删除、修改数据.py
1,396
3.71875
4
from pymysql import * def main(): # 1.创建数据库连接 conn = connect(host="localhost", port=3306, user="root", password="damonmok", database="python_db") # 2.获取游标对象 cursor = conn.cursor() # 3.1 新增数据并返回受影响的函数 # count = cursor.execute('insert into student values (default,"张小猪", 22, "保密", 3, "1998-01-0...
442e0e475eeb79e5a2a3899dbf6d77e0b8a1d09f
charlottetan/Algorithms-2
/Sorting/selection_sort.py
374
3.875
4
def selection_sort(array): start = 0 while start < len(array) - 1: lowest = start for i in range(start + 1, len(array)): if array[lowest] > array[i]: lowest = i swap(array, start, lowest) start += 1 return array def swap(array, idx1, idx2): ar...
39cdfa13db87b5ba5040555acc2b70c337c8c029
Byung-moon/AI_Hulnno_Academy_HighClass
/2020_0805_day3/kerasFunc.py
1,265
3.53125
4
import keras import numpy as np x_train = np.array([0, 1]) y_train = x_train * 2 + 1 print(x_train) print(y_train) x_test = np.array([2, 3]) y_test = x_test * 2 + 1 print(x_test) print(y_test) # 입력을 받는 입력 layer 만듦 # 입력 데이터의 모양을 알려주기 위해 shape 지정 x = keras.layers.Input(shape=(1,)) print(type(x)) ...
9d4d0f7eb52a1ec180a221318528e1214a3b95f0
Heejeloper/-edwith-Python-
/2/boolean_index.py
254
3.5625
4
import numpy as np def boolean_index(X, condition): return X[eval(str("X")+condition)] X = np.arange(32, dtype=np.float32).reshape(4, -1) print(boolean_index(X, "== 3")) X = np.arange(32, dtype=np.float32) print(boolean_index(X, "> 6"))
bce9bfc3bd973ce93f247da50de4394025d71e48
daniel-reich/turbo-robot
/x5o7jTvzXjujvrh6t_16.py
632
4.5625
5
""" The iterated square root of a number is the number of times the square root function must be applied to bring the number **strictly under 2**. Given an integer, return its iterated square root. Return `"invalid"` if it is negative. ### Examples i_sqrt(1) ➞ 0 i_sqrt(2) ➞ 1 i_sqrt(7) ➞ 2 ...
116c0b50644d7674c1d6674bc8c4fad9fb71d1bd
EricSchles/learn_python
/intro/data_structures.py
503
4.21875
4
# A data structure is just a structure for your data party_list = ["dip","chips","wine","beer","hats"] print("1st element of party list is",party_list[0]) print("2nd element of party list is",party_list[1]) print("5th element of party list is",party_list[4]) print("let's look at the party list, in it's entirety", ",...
2f5b9047455441aa0075ac28572d1c0780b89d93
jananee009/Project_Euler
/SieveOfEratosthenes.py
1,501
4.03125
4
import math class SieveOfEratosthenes: def __init__(self): self.listOfNumbers = [] # checks if a given number is prime or non prime. def isPrime(self,num): sqrtNum = int(math.sqrt(num)) for i in range(2,sqrtNum+1): if num % i == 0: return False return True # Returns a list of all prime numbe...
e97072115cfd22ea3f699e8c2a6cea6421be1ae2
wubek/ProjectEuler
/euler/euler020.py
534
4.125
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! """ def factorial(number): starter = 1 for i in range(2,number+1): starter *= i ...
9f2c3269f527db098a08c0b70e17bc7a3a31c611
Neguentropie67/NSI_2021_2022
/NSI_terminale/chapitre1_modularité_et_mise_au_point/mathematiques/fonctions.py
815
4.0625
4
# n! = n * (n-1) * (n-2) * ... * 3 * 2 * 1 # 5! = 5 * 4 * 3 * 2 * 1 = 120 # Les standars de docstring : https://stackoverflow.com/questions/3898572/what-is-the-standard-python-docstring-format def factorielle(n: int) -> int: """ Fonctions factorielles qui retourne la factorielle de l'entrée n! = n * (n-1)...
7002ff89feb14b83f52b32491fb304f8892ae1a9
ZiUNO/CodeCraft
/utils/graph.py
8,012
3.53125
4
# -*- coding: utf-8 -*- """ * @Author: ziuno * @Software: PyCharm * @Time: 2019/3/27 20:39 """ class Graph(object): def __init__(self): self.__roads = [] self.__crosses = [] self.__graDic = {} self.__roadDic = {} self.__crossDic = {} @property def graDic(self): ...
56af8acd09e1a45d8091a3844a3e2c0e331f7517
frclasso/turma3_Python1_2018
/Cap14_Funcoes/testeFunc.py
435
3.953125
4
#!/usr/bin/env python3 # definindo uma funcao - def # def my_func(parametros): # return parametros # # # chamada de funcao # print(my_func('Argumentos')) def Func(this, that, other, *args, **kwargs): print() print('This is a test function', kwargs['one'], kwargs['two'], kwargs['tree'], ...
2eb9fddea1fe9d5c1cde3d90f0e8832eaa8f7006
LRBeaver/Eduonix
/db_testing_trwo.py
954
3.578125
4
__author__ = 'lyndsay.beaver' import sqlite3 as sql def create_market(): #market= {'ABC':rnd.randint(10,20), 'DEF': rnd.randint(10,20), 'XYZ': rnd.randint(10,20)} stocks = ['ABC', 'DEF', 'HGI', 'LMK', 'OMN', 'PQR', 'STU', 'XYZ'] #prices = [] #for x in range(len(stocks)): #prices.appen...