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
c31a4b089ae0881dbfa572cff5495a78dd10ea47
DSWhite96/Campus_Price_And_Dice
/mystic_coast/campus/verification/verify_restaurant.py
946
3.75
4
''' verification/verify_restaurant.py This file holds methods for the purpose of server-side validation of the info sent by the user from add-restaurant.html ''' import re MIN_INPUT_LENGTH = 0 MAX_INPUT_LENGTH = 200 MIN_PHONE_LENGTH = 0 MAX_PHONE_LENGTH = 14 ''' PHONE_NUMBER_FORMAT = "(\d{3}) \w{3}-\w{...
386cac282a4aac4488105c7889b2c771a37f8a9e
cshelke/Algorithms
/QuickSort.py
444
3.875
4
__author__ = 'Cyril Shelke' # Lab 4 def swap(i,j): temp = A[i] A[i] = A[j] A[j] = temp def partition(A,p,r): pivot = A[r] i = p-1 for j in range(p,r): if A[j]<= pivot: i+=1 swap(i,j) swap(i+1,r) return i+1 def quicksort(A,p,r): if p<r: q = p...
bcf2ce4f16e1a2b55394031aa555c12784019ca3
shivesh01/Python-Basics
/Name&Scope/namespace_5.py
292
3.96875
4
def outer_function(): global a a = 20 def inner_function(): global a a=30 print("a =",a) inner_function() print("a =",a) a=10 outer_function() print('a =',a) #all references and assignments are to the global a due to the use of keyword global
63901aba5ab6c59a683850a21e4c11795e023215
shivesh01/Python-Basics
/Loop/loop_for_6.py
170
4
4
number =int(input("Enter an integer:")) # Range(0,11) here 11 is excluded for count in range(1,11): product = number * count print(number,"*",count,"=",product)
53ee1a6e306feea9dc67553f180d564bdf272917
shivesh01/Python-Basics
/list-com/list_com_4.py
106
3.546875
4
# Using if with List Comprehension number_list = [x for x in range(20) if x % 2 == 0] print(number_list)
3e8dbd37485b4e0b74dc34881484c9ca92881c05
shivesh01/Python-Basics
/tuples/tuple_11.py
80
3.75
4
# Iterating through tuple for name in ('Tom', 'Jerry'): print("Hello", name)
c43c7f51aff65b851a591bf7d00c96a0d8a160be
shivesh01/Python-Basics
/Project&problems/Example_30.py
425
4.28125
4
# Shuffle Deck of cards import random # In the program, we used the product() function in itertools module to create a deck of cards. This function performs the Cartesian product of the two sequences. from itertools import product deck = list(product(range(1, 14), ["Spade", "Heart", "Club", "Diamond"])) random.sh...
b599005c7e3b3993c7b68bb7e448d03d6395a33a
shivesh01/Python-Basics
/Project&problems/Example_43.py
452
3.84375
4
# count each vowel vowels = "aeiou" my_str = " Hello, have you tried our tutorial section yet?" my_str = my_str.casefold() count = {}.fromkeys(vowels,0) for char in my_str: if char in count: count[char] += 1 print(count) # # 2nd method by list and dictionary comprehension c= # # my_str = " Hello i m...
410e51e6a2f6b253ca1e8f134152a83d35826ecd
shivesh01/Python-Basics
/Dictionary-comprehension/Dict_com_8.py
233
3.96875
4
# if-else Conditional Dictionary Comprehension orginal_dict = {'jack': 28, 'micheal': 48, 'guido': 57, 'john': 33} new_dict_1 = {k: ('old' if v > 40 else 'young') for (k, v) in orginal_dict.items()} print(new_dict_1)
3e65855eebfc94eac668900c38b14d57f30b119b
shivesh01/Python-Basics
/Loop/loop_for_4.py
164
4.03125
4
languages = ['English','French','German'] #here langauge variable takes one iteration from languages list and prints for language in languages: print(language)
3ba40aba8da19c18347a440c2183ea5c708fd59f
shivesh01/Python-Basics
/list/list_4.py
181
4.3125
4
#We can add one item to a list using the append() method or add several items using extend() method. odd = [ 1, 3, 5] odd.append(7) print(odd) odd.extend([9,11,13]) print(odd)
b0f2accec2c4b4db6641c3c9b85bfcf9fae1e83f
shivesh01/Python-Basics
/Strings/str_searching.py
293
3.859375
4
def main(str): print(" your entered string \n\n",str) print(" is this str starts with good :",str.startswith("good")) print(" is this str ends with thon :",str.endswith("thon")) print(" find:",str.find('ython')) print(" count:",str.count("0")) main("good start in python")
aa1c3600d1dc8eafc53869799d12e3f7ce5fc189
shivesh01/Python-Basics
/Project&problems/Example_23.py
419
4.09375
4
# Find the numbers divisible by another number from a list num = int(input("Enter a number")) my_list = [12, 65, 54, 39, 102, 339, 221] result = list(filter(lambda x: (x % num == 0), my_list)) print(f"Numbers divisible by {num} are", result) ## Find factors # num = int(input(" Enter a num to find it's factor")) ...
2de461238cb94a660ac1b23de5a5abe653c808d4
shivesh01/Python-Basics
/Inheritance/Inheritance_multilevel.py
263
3.734375
4
class first(): def first(self,a,b): c=a+b; return c; class second(first): def m2(self): print("m2 method is called") class third(second): def m3(self): print("m3 method is called") obj1=third() print(obj1.first(100,99))
65e62f4761054c0cf0ac8911e1715c5537608c7c
shivesh01/Python-Basics
/Project&problems/Example_10.py
233
4.375
4
# check number +,- or 0 num = float(input("Enter number")) if num == 0: print("your entered number is zero") elif num > 0: print("You have entered a positive number") else: print("You have entered a negative number")
7eb49e34fcd1558cbea5b60b2d244864a3cf3b44
shivesh01/Python-Basics
/sets/set_2.py
146
4.03125
4
animals =set(["cat","dog","tiger","elephant"]) #passed a list inside a set function so, it will convert this list into a set. print(animals)
56f12d5a6ff25cfc4b523a8660272d53bb28db1a
shivesh01/Python-Basics
/Loop/loop_if_2.py
306
3.890625
4
student_score=float(input("Enter the score")) if student_score>=50: print("you have passed the exam") print("***congrations**") elif student_score < 50: print("you have failed the exam ") print("try again :)") else: print("invalid input ") print("Please enter a valid input")
918af8577d167cb37357196e2509ea35569e4682
shivesh01/Python-Basics
/Datatype/datatype_explict_3.py
327
4.21875
4
num_int = 123 num_str = "456" print("data type of num_int",type(num_int)) print("data type of num_str",type(num_str)) num_str = int(num_str) print("data type of num integer after typecasting:",type(num_str)) num_sum= num_int + num_str print("sum of num_int and num_str ",num_sum) print("data type of num_sum",type(nu...
932fedb69154cf09215cd4d6e7f7ef6f7b225c1c
shivesh01/Python-Basics
/Decorators/Decorators_2.py
139
3.609375
4
def inc(x): return x+1 def dec(x): return x-1 def operate(func,x): result = func(x) return result print(operate(inc,5))
b3cbce9f180707d7436f454abe4354e34321d491
shivesh01/Python-Basics
/Date&time/datetime_time_4.py
317
3.8125
4
from datetime import time # time(hour = 0, minute = 0, second = 0) a=time() print(a) # time(hour, minute and second) b=time(12,36,23) print(b) # time(hour, minute and second) c=time(hour=1,minute=50,second=56) print(c) # time(hour, minute, second, microsecond) d=time(11,32,23,4343) print(d) a=time(11,20,30,232)
5c24ca52d5ff6a63e2ee1a211db6edd2522df5cb
dpk9/text_adventure
/adventure.py
8,129
4.34375
4
# text adventure # David Kalish import random # Keep track of each room's contents ROOM_DICT = {} def main(): """See bottom section for how this function gets called initially. The main() function starts the game. It initializes the player's health, that they don't have the blue card, and resets the ROOM...
72118b758eed8e15d2fa174ecb09ca46786e9cf2
vedanthreddy25/MIET-Python
/OperatorOverloading.py
679
3.734375
4
class Student: def __init__(self,m1,m2): self.m1 = m1 self.m2 = m2 def __add__(self, other): a = self.m1 + other.m1 b = self.m2 + other.m2 t = Student(a,b) return t def __gt__(self, other): a = self.m1 + self.m2 b = other.m1 + ...
5cee17c6390705d7257bbfc822fd1aab813a5450
vedanthreddy25/MIET-Python
/Encapsulation.py
287
3.515625
4
class Shape: def __init__(self,a): self.__a = a def get_a(self): return self.__a def set_a(self,b): self.__a = b return self.__a class Rectangle(Shape): pass a = Shape(5) #print(a.__a) print(a.get_a()) print(a.set_a(10))
b13aa140ead3c01f5d212f74b87e8b7be89746a8
vedanthreddy25/MIET-Python
/Innerclass.py
565
3.53125
4
class Student: def __init__(self,name,rollno): self.name = name self.rollno = rollno self.lap = self.Laptop() def show(self): print(self.name, self.rollno) self.lap.show() class Laptop: def __init__(self): self.brand = "dell" ...
f90224cf60ab1e61b8f031261b5c4f34e6c5329f
lmjim/year1
/cs211/Notes/ExpressionNotes/ExpressionNotes.py
2,731
4.03125
4
""" Week 3 - Thursday Notes Live Coding Examples """ """In class: Postfix, S-expressions""" def eval_postfix(s: str) -> int: """Input should look like '5 3 + 4 *' Example: eval_postfix('5 3 + 4 *') -> 32 """ stack = [] tokens=s.split() for i in tokens: if i.isnumeric(): st...
023377a9182f891ac0d4f8a8de3d9f7c61d8ef82
lmjim/year1
/cs210/p1_1_quiz.py
2,417
3.796875
4
''' CIS 210 STYLE CIS 210 F17 Project 1 Author: Lily Jim Credits: N/A Add docstrings to Python functions implementing quiz 1 pseudocode. ''' def q1(onTime, absent): '''(Boolean, Boolean) -> None Returns appropriate phrase based on if someone was on time, late, or absent. Does not recogniz...
b7332b75ff57e2cf480b53e8594a119a0f7d0a35
lmjim/year1
/cs211/Notes/midterm/circle.py
631
4.0625
4
"""CIS 211 Midterm Question""" class Circle(object): def __init__(self, x, y, radius): self.x = x self.y = y self.radius = radius def move(self, dx, dy): self.x = self.x + dx self.y = self.y + dy def expand(self, factor): self.radius = self.radius * factor...
4e1681450c995583671cbc80abe6ae17ff63085c
lmjim/year1
/cs210/p42_binary.py
1,467
4.09375
4
''' Binary Encoding and Decoding CIS 210 F17 Project 4-2 Author: Lily Jim Credits: N/A Switch between decimal representation and binary representation ''' import doctest def dtob(n): '''(int) -> str Take a decimal representation of a non-negative integer and change it to binary represetat...
dd701404bbf09b357bdd5faec5512de7093ca871
lmjim/year1
/cs210/p61_testfunc_key.py
1,584
4.21875
4
""" CIS210 Project 6-1 Fall 2017 Author: [Solution] Credits: N/A Implement a function to test the string reverse functions from project 5 (iterative and recursive). Practice: -- user-defined test functions -- functions as parameters """ import p52_stringreverse_key as p5 def test_reverse(f): '''(fun...
f6f5dfdb13308e452891509f1e79f747c73f4af1
madhu20336/loop
/PatternNumber.py
149
3.953125
4
num=int(input("enter the number")) row=0 while row<=num: col=row while col>0: print(col,end="") col-=1 print() row+=1
34587fef25c03dc972b8cf67245ae8574629f94d
madhu20336/loop
/FibonacciSeries.py
137
3.984375
4
num=int(input("enter a number :")) a=0 b=1 sum=0 count=1 while count<=num: print(sum,'/n') count+=1 a=b b=sum sum=a+b
82fb50ac6c4ab1f8bcf31aa0ed184a2708140985
madhu20336/loop
/EnergyBar.py
745
4.0625
4
fix_number=5 chance=10 while chance>0: digit=0 number=int(input("enter a number to win the game: ")) if fix_number==number: print("you are win ! ,your guessing number is correct") break elif number==fix_number: diff=number-fix_number chance=chance-diff if chance <...
e7f06506466a498b14193e83539cf957437affb6
gabriel-card/mtg-prices
/pricer.py
1,051
3.515625
4
#!/usr/bin/python # -*- coding: utf-8 -*- import pandas import urllib import requests from bs4 import BeautifulSoup LIGAMAGIC_SEARCH_URL = "https://www.ligamagic.com.br/?view=cards%2Fsearch&" def get_prices(cards): prices = [] for card in cards: encoded_cardname = urllib.urlencode({"card": card}) ...
43c4c188867a065ad90e7992ffd4c9846f03af33
Rahilisavailable/Python-Files
/untitled0.py
271
3.75
4
# -*- coding: utf-8 -*- """ Created on Tue Jul 7 10:09:06 2020 @author: admin """ Name=input('Please enter your name :') print(Name) hobby=input('Please enter your hobby :') print(hobby) Age=input('Please enter your age :') print('Your age is '+ Age)
b06d39155863083eaa80b26b0fe05f3a292992ad
crskbel-ca/PythonBayesianStatistics
/AllenBDowney_ThinkBayes/src/euro3.py
4,307
3.734375
4
"""This file contains code for use with "Think Bayes", by Allen B. Downey, available from greenteapress.com Copyright 2012 Allen B. Downey License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html """ """This file contains a partial solution to a problem from MacKay, "Information Theory, Inference, and Learning Algorit...
826fb885f233ea03edffde38cb2342bda0236dea
dudulydesign/python_web_pratice
/webserver/py_though/bubble sort.py
747
4.15625
4
#Bubble Sort sampleList = [6,5,4,3,2,1] def bubbleSort(sourceBubbleSortList): #how long the list listLength = len(sourceBubbleSortList) i = 0 # the i here to count how many value not in while i < listLength-1: j = listLength - 1 # here to compare two value while j > i: print(" sourceBubble...
b769e39bf890db37aa2e38f41cd90be45e344bc3
dudulydesign/python_web_pratice
/webserver/web_server_py/webserver_socket3.py
816
3.734375
4
''' Function socket.socket creates a socket and returns a socket descriptor which can be used in other socket related functions The above code will create a socket with the following properties ... Address Family : AF_INET (this is IP version 4 or IPv4) Type : SOCK_STREAM (this means connection oriented TCP protocol)...
a68c1884fd6ed4aa09ffac0f5fe954b786c6a42a
JeisyLiu/Repository_Charlie
/VariousFeatures/NetWorks/getLocalIP.py
167
3.53125
4
import socket hostname = socket.gethostname() localIp = socket.gethostbyname(hostname) print("my hostname is:", hostname) print("my local ip address is:", localIp)
63c793f149fce2d9a7efe370963f0fc3e374f3f6
drderuiter/learn-asyncio
/learn_asyncio/2_tasks/3_a_real_program/__main__.py
1,406
3.8125
4
import asyncio import logging from learn_asyncio import configure_logging async def download_file(task_id: int, file_size: int): logging.info("Task %d started", task_id) "Alternatively, use the actual Task name by uncommenting the next line." # logging.info("%s started", asyncio.current_task().get_name()...
62f8410ff45e2352f7ac48cf8327c35a62371895
geraldfan/Automate-The-Boring-Stuff
/Chapter_9_Organizing_Files/selectiveCopy.py
699
4.25
4
#! python3 # selectiveCopy.py - Walks through a folder tree, then searches and copies for files with a particular extension (i.e. .jpg) import shutil, os folder = input('Enter the absolute filepath of' ' the directory you wish to copy from: ') extension = input("Enter the extension you'd like to copy:...
aeb7be8ffb07fe8acfe6f8b07bb1e52b2e3d50ba
Nspigarelli/advent_of_code_2020
/Advent of Code 2020/Day 2/day_2_pt2.py
687
3.578125
4
def day_2(report): valid_passwords = 0 for i in report: i = i.split(' ') letter_count = [(int(x) - 1) for x in i[0].split('-')] letter = i[1][0] password = i[2] if letter_count[1] <= len(password): if password[letter_count[0]] == letter or password[letter_coun...
6f8cc3d8dc1356bb21aaf6a23980f35d2d6d2f26
preparationh67/RaspberryBarSign
/light_pwm.py
738
3.59375
4
#!/usr/bin/env python import wiringpi as wpi pPWM = 26 pwmMinOn = 490 pwmMaxOn = 1024 pwmOn = 0 pwmValue = 800 def setup(): print "Setup Starting" wpi.wiringPiSetup() wpi.pinMode(pPWM, wpi.PWM_OUTPUT) wpi.pwmWrite(pPWM, 0) def loop(): global pwmValue while True: pwmIn = input("0,490...
cea3f2c19620b8acb8a46382e54375267d4f2359
asoo1221/Python
/EmployerPayCalucation.py
1,508
3.75
4
# week 4 lab solution employee pay calculation # Oct 18 # EC # constants RATES = 0.20 RATEM = 0.23 ALLOW_1 = 25000 ALLOW_2 = 20000 #inputs print("\t\tWelcome to the Payroll Program") empId = input("Please enter your employee id: ") name = input("Please enter your name: ") address = input("Please ent...
a317a99a149bfa5597521d3a8befdb86c4cedcb3
namnguyen6595/nguyenthanhnam-Labs-c4e19
/Lab3/freakingmath.py
827
3.75
4
from random import randint, choice # from evaluate import calc import evaluate x = randint (1, 10) y = randint (1, 10) op = choice(['+', '-', '*', '/']) error = randint (-1, 1) res = evaluate.calc(x, y, op) display_res = res + error print ("* "*20) print ("{0} {1} {2} = {3}".format(x, op, y, display_res)) print ("...
8de3358c7975c30e30ef0a25fc3a9611484dc72e
aniketag12/aniket-agrawal
/task 5/task5.py
522
4.0625
4
list_a = input() list_b = input() list1 = list_a.split() list2 = list_b.split() def common_elements(): common_items = 0 for number in list1: for numbers in list2: if list1.index(number) == list2.index(numbers): common_items+=1 return (" the common items are ",com...
1b0875c411cbcc7bdd39c5d9132a88cf8b8a6bc3
wuyuz/wanhe
/wanhe/utils/pagination.py
1,909
3.578125
4
class Pagination(object): """ 自定义分页 """ def __init__(self, current_page, total_count, base_url, params, per_page_count=10, max_pager_count=11): try: current_page = int(current_page) except Exception as e: current_page = 1 if current_page <= 0: ...
2727cd5d28e0dc1708e8b927e0c6874b67365b90
rodrigosantosti01/LingProg
/Exercicio8/atv02.py
1,639
3.953125
4
# 2. Escreva uma função que recebe uma lista de triplas e, para cada uma, gera uma # equação do segundo grau considerando que os elementos da tripla são os # coefcientes usualmente denominados a, b e c da equação. Note que a sua função # deverá devolver uma lista de equações. A geração das equações deve ser feita por #...
ef0a0f6f5e2069748d9990be91a0d47586c95e64
rodrigosantosti01/LingProg
/Exercicio4/atv06.py
682
3.9375
4
# 6 Espião: Escreva uma função que receba uma lista de # inteiros e retorne True se contém um 007 em ordem, mesmo # que não contínuo. Exemplo: # espiao([1,2,4,0,0,7,5]) --> True # espiao([1,0,2,4,0,5,7]) --> True # espiao([1,7,2,4,0,5,0]) --> False def espiao(lista): status="nada" for simbolo in lista: if simbol...
8b0e1fb5a628c393ee871205478499cf48cf5306
rodrigosantosti01/LingProg
/Exercicio3/atv11.py
1,054
4.1875
4
# 11. Faça um programa que faça 5 perguntas para uma pessoa sobre um crime. As perguntas são: # "Telefonou para a vítima?" # "Esteve no local do crime?" # "Mora perto da vítima?" # "Devia para a vítima?" # "Já trabalhou com a vítima?" # O programa deve no final emitir uma classificação sobre a participação da pes...
f961bc821004bc256dd9013f394d4206c71c2ea9
rodrigosantosti01/LingProg
/Exercicio7/atv01.py
259
3.859375
4
# 1 Defna a função somannat que recebe como argumento um número natural n # e devolve a soma de todos os números naturais até n. # Ex: somannat(5) = 15 somannat = lambda n: 1 if n==1 else n + somannat(n-1) assert(somannat(5) == 15) print(somannat(5))
1d17edcaed9eb5d2240581a04a6cdcbedfd2df13
rodrigosantosti01/LingProg
/Exercicio6/atv03.py
310
3.921875
4
# 3 Defna a função primnalg que recebe como argumento um número natural e # devolve o primeiro algarismo (o mais signifcatvo) na representação decimal de n. # Ex: primnalg(5649) = 5 # Ex: primnalg(7) = 7 def prim_alg(numero): return numero if numero<10 else prim_alg(numero//10) print(prim_alg(5649))
f63aa3cc09aa5c0e343b3cad3a10dea3f64b3994
rodrigosantosti01/LingProg
/Exercicio2/atv05.py
358
3.859375
4
# Atividade -5 # Escreva um programa que conta a quantidade de vogais em uma # string e armazena tal quantidade em um dicionário, onde a chave é # a vogal considerada. string = "nusum oasum, cacilds vidis litro aetrs" dict = {'a':string.count('a'), 'e':string.count('e'), 'i':string.count('i'), 'o':string.count('o'), ...
768ee386f425ccf5d07be6fa8d3e8310c63d802c
rodrigosantosti01/LingProg
/Exercicio2/atv08.py
2,128
3.65625
4
import sys agenda = {} def incluirNovoNome(nome="", telefones=[]): agenda[nome] = telefones return agenda def incluirTelefone(nome = "", telefone= ""): if nome not in agenda: deseja_inserir = int(input("nome não existe na agenda, deseja inserir?: \n 0-não ou 1-sim ")) if deseja_ins...
fbfdbf9be267396bd9d977b022bef08dc5fadd4d
rodrigosantosti01/LingProg
/Exercicio2/atv04.py
1,814
3.515625
4
# Atividde - 04 # Faça um programa que percorre uma lista com o seguinte # formato: [['Brasil', 'Italia', [10, 9]], ['Brasil', 'Espanha', [5, 7]], # ['Italia', 'Espanha', [7,8]]]. Essa lista indica o número de faltas que # cada time fez em cada jogo. Na lista acima, no jogo entre Brasil e # Itália, o Brasil fez 10 fa...
4b738e3636f3a1a31492bd5fddbd202733c602f3
rodrigosantosti01/LingProg
/Exercicio2/atv02.py
442
4
4
# Atividade 2 # Faça um programa que receba duas listas e retorne True se são # iguais ou False caso contrario. # Duas listas são iguais se possuem os mesmos valores e na mesma # ordem. lista=[] lista2=[] count=0 while count < 3 : numeros = int(input("Insira na primeira lista: ")) numeros2 = int(input("Insira na se...
629086daced0d0fc81ed7a4a7bc32042487ee250
rodrigosantosti01/LingProg
/Exercicio6/atv05.py
506
3.671875
4
# 5 Defina a função contemnparQ que recebe como argumento uma lista de números # inteiros w e devolve True se w contém um número par e False em caso contrário. # Ex: contemnparQ([2,3,1,2,3,4]) = True # Ex: contemnparQ([1,3,5,7]) = False contem_parQ = lambda w: False if len(w) == 0 or (w[len(w) - 1] % 2 != 0 and not...
860f2ff85024e2668c3268b1f98012f86fbc8863
rodrigosantosti01/LingProg
/Exercicio4/atv01.py
389
4.1875
4
# 1 Menor de dois pares: Escreva uma função que retorne o menor de dois números # dados se ambos os números forem pares, mas retorna o maior se um dos dois for # ímpar. Exemplo: # menor_de_dois_pares(2,4) --> 2 # menor_de_dois_pares (2,5) --> 5 def f(a,b): if a%2==0 and b%2==0: if a<b: return a return b else...
a4aa96617b60ed6f5a181dd27493ecd062423410
raperez81/Curso-basico-de-Python-practicas
/conversor.py
743
3.890625
4
menu = ''' Bienvenido al conversor de monedas 💰 1 - Pesos Colombianos 2 - Pesos Argentinos 3 - Pesos Mexicanos Elige una opción: ''' valor_dolares = 0 opcion = int(input(menu)) if opcion >= 1 and opcion <= 3: if opcion == 1: monto = float(input('Cuantos pesos colombianos deseas convertir: ')) v...
d3032c289e2da961248345aa78861fec64ba8afb
raperez81/Curso-basico-de-Python-practicas
/strings.py
65
3.78125
4
nombre = input('Ingrese su nombre: ') print(nombre.capitalize())
af92dcfcdfc1c806b3a56d3ff0e2b0d1790b7f33
warrior960812/JOUR7280-EXERCISE-
/Week3 list dict for while.py
3,509
3.953125
4
#!/usr/bin/env python # coding: utf-8 # In[9]: list1=["hello", "python",2018,814] # In[10]: list2=[1,2,3,4,5,6,7] # In[188]: print("list1[0]:",list1[0]) # In[18]: print("list2[1;5]:",list2[1:5]) # In[19]: list1+list2 # In[20]: list1*2 # In[23]: 2018 in list1 # In[25]: list2[3:] # In[27]...
0e607e75930d93cba8e74b71c13b870eabd58263
Kubster96/narcotic_sound_generator
/main.py
2,138
3.5
4
import argparse from song import Song from miditime.miditime import MIDITime import sys def main(): parser = argparse.ArgumentParser(description='Provide parameters!') parser.add_argument('tempo', help="Provide tempo of the song!", type=int) parser.add_argument('key', help="Provide key of the song!", type...
85da332639e3566b86d64e9447ae130fc2e34863
YooLc/Codes-Backup
/2020/4.2/fact.py
121
3.53125
4
s = 0 for i in range(1, 21): fact = 1 for j in range(1, i + 1): fact = fact * j s = s + fact print(s)
9e320d21577eecf0498263d6ca79100e193f1abd
tiff413/Year-1
/Analysing Obama's Most Frequently Used Words (Webscraping Project)/webscrape.py
2,404
3.78125
4
# WEBSCRAPER TO COLLECT AND PROCESS TRANSCRIPT TEXT # This algorithm was created to scrape the links to speeches in the White House # archive website that was used under Obama's presidency. The program reads a # txt file with all the urls to Obama's speeches collected by the previous # algorithm. It then iterates over ...
578494d75a99a79091946b96a93a13fc485c6c50
Szkeller/TDD_lab
/FizzBuzz.py
867
4.125
4
class FizzBuzz: ''' This is for TDD sample Author: Keller Zhang create date: 04/27 description: FizzBuzz Quiz When given number just can be divided by 3, then return 'Fizz'; When given number just can be divided by 5, then return 'Buzz'; Whe...
77ca192b6b1ae69cff091b7db9d94178c941c2ef
jiarmy1125/homework
/class01_homework2.py
734
3.65625
4
star = int(input("請輸入菱形範圍:")) a=star//2+1 #分層製作 for i in range(1,a): #菱形上半部 1~10 for j in range(0,(a-i)): #*前的空白 print(" ",end="") for k in range(0,(2*i-1)): #從*後開始判斷下一個*的位置 if k==0 or k==2*i-2: print("*",end="") else: print(" ",end="") pr...
17aa87989304e84380ebb3706df6570b20c2d93d
A-Alexander-code/My_python_games
/pokemon_battle.py
2,166
3.609375
4
from random import randint import os # pikachu -> pk # squirtle -> sqt # i -> initial # ac -> actual # lf -> life # pct -> percent base 1 # attack -> atk pk_ilf = 80 sqt_ilf = 90 lf_bar = 20 pk_lf = pk_ilf sqt_lf = sqt_ilf while pk_lf > 0 and sqt_lf > 0: # Se desenvuelven los turnos # Turno de pikachu ...
a57bbdd96c7f9cb440fa867cf28c97ec1673f027
adamelmohamad/catalyst
/user_upload.py
2,576
3.546875
4
import sys import re import psycopg2 import csv from email_validator import validate_email, EmailNotValidError def create_table(): sql = '''CREATE TABLE USERS(name CHAR(20),surname CHAR(20),email CHAR(100) UNIQUE)''' return sql all_arguments = " ".join(sys.argv) filename = re.search("--file .* ", all_argument...
7cb560fe72f493fea849d5b03273786926b44259
JuanjoMorell/CoinFlipper
/coinfliper.py
1,685
3.859375
4
import random, os, time, datetime, argparse # random: Modulo que implementa la generacion de numeros random # os: Funcionalidad del sistema # time: Funciones relacionadas con el tiempo # datetime: Clases para manipular fechas y tiempos # argsparse: Implementa el uso de linea de comandos # Variables tiradas = 0 cara =...
383c7b66d2e6c025f09270cf1e547d64556954aa
Shilinana/LearnPythonTheHardWayPractices
/ex18.py
633
4.3125
4
""" @Author:ShiLiNa @Brief:The exercise18 for Learn python the hard way @CreatedTime:28/7/2016 """ # this one is like your scripts with argv def print_two(*args): arg1, arg2 = args print "arg1:%r, arg2:%r" % (arg1, arg2) # ok, that *arg is actually pointless, we can just do this def print_two_again(ar...
89768748cf4abc99b56f383e025fe37a851579f8
justinelai/Sorting
/src/iterative_sorting/iterative_sorting.py
2,598
4.5625
5
def insertion_sort(list): for i in range(1, len(list)): # copy item at that index into a temp variable temp = list[i] # iterate to the left until reaching correct . # shift items to the right j = i while j > 0 and temp < list[j-1]: list[j] = list[j-1] ...
b1067e475bcfa76c1c99c0b97affb53167ec6227
Tech-Amol5278/Python_Basics
/c17 - debugging and exceptions/c17e1.py
432
3.6875
4
# create a funtion divide which returns answer # handle : zero divide error # only ints allowed # ZeroDivisionError: # print(devide(4,0)) def division(a,b): try: return (a/b) except ZeroDivisionError as err: ## as err: to get the default msg print(err) except TypeErro...
360d18510b49d486f1ac3190c7714843e88c86b6
Tech-Amol5278/Python_Basics
/c13 - advanced functions/c13e2.py
356
3.90625
4
# any and all functions practice # define a function to return the sum of the values in list l = [ 1,2,5,7,'Amol'] def mysum(*args): sum_val = 0 if all([type(i) in (int,float) for i in args]): for num in args: sum_val += num else: return 'Please cross check entered values' ...
393eda5958a2b8f86b86af13a3c6326716adcceb
Tech-Amol5278/Python_Basics
/c17 - debugging and exceptions/debugging.py
1,293
4.09375
4
# Debugging: # process of finding and resolving the problems within a computer program that prevents correct operation # of software or a system # Why Debugging? # 1. Our programs is not running and causing unexpected errors # 2. Our program is working but insights are not as exepected # Steps for De...
023cc1ff4de2107c91ddae8dc32b7fb9f9e31eb3
Tech-Amol5278/Python_Basics
/c19 - working with OS/os module part-2.py
719
3.8125
4
# OS module part 2 # to get the folder-subfolders and files from given directory import os import shutil x_dir = os.walk(r'D:\amol_lap_data\python_tutor') for current_path,folder_names,file_names in x_dir: print(f'current path: {current_path}') print(f'folder name: {folder_names}') print(f'file name: {file...
2851a656bd9f2bdc1b7877c587dd09a17e0fe219
Tech-Amol5278/Python_Basics
/c5 - list/c5_more_methods_to_add_data.py
626
4.15625
4
# count # sort method # sorted function # reverse # clear # copy # Count: Counts the string available in list fruits = ['apple','orange','banana','grapes','apple','apple','guava'] print(fruits.count('apple')) # Sort: sort the list contains in alphabetical/numeric order fruits.sort() print(fruits) numbers = [3,51,8...
43bce6c540aa4ad249c33ab9650e4e1b739a73cb
Tech-Amol5278/Python_Basics
/c5 - list/c5e4.py
522
4.4375
4
# define a function which returns a lists inside list, inner lists are odd and even numbers # for example # input : [1,2,3,4,5,6,7,8] # returns : [[1,3,5,7],[2,4,6,8]] ####### Sol ############################################### num1 = [1,2,3,4,5,6,7,8] def separate_odd_even(list1): sep_list = [] odd = [] ...
f383537b4da9f340610aaa7e4ee2e1fbf5b73147
Tech-Amol5278/Python_Basics
/c2 - strings methods/c2e2.py
218
4.21875
4
# ask username and print back username in reverse order # note: try to maje your program in 2 lines using string formatting #### Sol ##########################3 u_name = input("Enter your name: ") print(u_name[::-1])
b2f4764af78cd413500ed73dd32815ec90f38540
Tech-Amol5278/Python_Basics
/c3 - loops/c3e5.py
657
4.09375
4
# ask user for name # Example - Amol Chavan # print count of each words # output: # A : 1 # m : 1 # o : 1 # l : 1 # : 1 # C : 1 # h : 1 # a : 2 # v : 1 # n : 1 ########################### Sol ################################################################# name = input("Pl...
c63d2f0d276b658f3d7f21f7519d631410d03b1e
Tech-Amol5278/Python_Basics
/c2 - strings methods/c2_2.py
368
3.984375
4
#### Tut 30 ############################ # string method part 1 ####################################### name = "aMol S. cHaVan" # a. len() function print(len(name)) # b. lower() function print(name.lower()) # c. upper() function print(name.upper()) # d. title() function print(name.title()) # e. count() function -...
4e09df38fd41bfaa63801dffa2f1a822878deab4
Tech-Amol5278/Python_Basics
/c17 - debugging and exceptions/else and finally.py
675
4.28125
4
# Else and fianlly while True: ## Loop to accept input til true comes try: age = int(input("Enter a number: ")) except ValueError: # valueerror : optional only if we know the error which can come print("Please enter age only in integer ") except: # when error is unpredicta...
4875af36f272aa85eb08235bf3a25fe05b141214
Tech-Amol5278/Python_Basics
/c18 - read and write csv files/write csv files using read- existing csv file.py
1,002
3.875
4
# Writing csv file using existing csv file from csv import DictReader,DictWriter # if we want to keep the same header as of existing file with open('file4.csv') as rf: with open('write-dictreader.csv','w',newline='') as wf: csv_reader = DictReader(rf) csv_writer = DictWriter(wf,fieldnames=['firstn...
e3a71a4f1447e3fc0e6bf03654df9c63e1af56f2
Tech-Amol5278/Python_Basics
/c16 - oops/property and setter decorator.py
2,526
4.21875
4
# property and setter decorator # the below code from last slide it has below problems # 1. this accepts the negative amount for price # sol: write a validation not to accept negative numbers # using getter(),setter() # 2. After changing the price , complete specification shows the old price. ...
1990af0b8f76c76eaa907f985d091f44a32cad62
Tech-Amol5278/Python_Basics
/c5 - list/c5_list_intro.py
649
4.5
4
# Data Structures # List # List is ordered collection of items # We can store anything in lits like int, float, string numbers = [1,2,3,4] print(numbers) ## to print 2 from list print(numbers[1]) ## to access only and 1 and 2 print(numbers[:2]) ## to reverse the elements in list print(numbers[::-1]) ## to access only...
ab2c4617eaa1cf233172a7694c5608d06f0f6479
Tech-Amol5278/Python_Basics
/c18 - read and write csv files/write csv files- using dictwriter.py
824
3.671875
4
# Writing csv files # dictwriter # writerow - to append one row at a a time # writerows - to append multiple rows at a time from csv import DictWriter ## Importing DictWriter class from csv module with open('file4.csv','w',newline='') as f: ## newline='' to remove the blank lines csv_writer ...
0f2d251f21b8053ab9ede9d3b3457f327a0149c5
Tech-Amol5278/Python_Basics
/c3 - loops/c3e2.py
573
4.03125
4
# Exercise - watch coco # ask user's name and age # if user's name starts with ('a' or 'A') and age is above 10 then # print 'you can watch coco movie' # Else print 'sorry, you cant wathc coco' ############################### Sol #################################################################### name,age = input(...
a4ce6e679f5bff302c134d100a3405ca78fa8b77
Tech-Amol5278/Python_Basics
/c7 - dictionary/c7e2.py
628
4.0625
4
# users = { # 'name': 'Amol', # 'age' : 24 # 'fav_movies' : ['coco','avengers'], # 'fav_songs' : ['song1','song2'] # } # Get the info from user and store in dict and print in above format name,age = input("Please enter your name and age in comma separeted : ").split(',') fav_movies = input('Enter you...
d887bdd8ecc880308aa53a95d683833dd97163cf
Wang-Yann/LeetCodeMe
/python/LCP/LCP 01_guess-numbers.py
1,648
3.578125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : Rock Wayne # @Created : 2020-07-15 17:38:44 # @Last Modified : 2020-07-15 17:38:44 # @Mail : lostlorder@gmail.com # @Version : alpha-1.0 """ # 小A 和 小B 在玩猜数字。小B 每次从 1, 2, 3 中随机选择一个,小A 每次也从 1, 2, 3 中选择一个猜。他们一共进行三次这个游戏,请返回 小 # A 猜对了几次?...
e63d4f29a2472c091d473f9d7f6f67b6e5b73a21
Wang-Yann/LeetCodeMe
/python/CodingInterviews_2/09_yong-liang-ge-zhan-shi-xian-dui-lie-lcof.py
1,575
3.84375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : Rocky Wayne # @Created : 2020-04-23 23:47:11 # @Last Modified : 2020-04-23 23:47:11 # @Mail : lostlorder@gamil.com # @Version : alpha-1.0 # 用两个栈实现一个队列。队列的声明如下,请实现它的两个函数 appendTail 和 deleteHead ,分别完成在队列尾部插入整数和在队列头部删除整数的 # 功能。(若队列中没有...
fe69b2d90d0c12a0d74ca085d69fce9316ab9055
Wang-Yann/LeetCodeMe
/python/_0001_0500/0025_reverse-nodes-in-k-group.py
5,019
3.546875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : Rock Wayne # @Created : 2020-04-17 17:21:23 # @Last Modified : 2020-04-17 17:21:23 # @Mail : rock@get.com.mm # @Version : alpha-1.0 """ # 给你一个链表,每 k 个节点一组进行翻转,请你返回翻转后的链表。 # # k 是一个正整数,它的值小于或等于链表的长度。 # # 如果节点总数不是 k 的整数倍,那么请将最后剩余的节点...
8af0d23e3c7cf1a3e8f141ab2c2fd7b2d67f543b
Wang-Yann/LeetCodeMe
/python/_1001_1500/1447_simplified-fractions.py
1,985
3.578125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : Rock Wayne # @Created : 2020-07-09 23:50:20 # @Last Modified : 2020-07-09 23:50:20 # @Mail : lostlorder@gmail.com # @Version : alpha-1.0 """ # 给你一个整数 n ,请你返回所有 0 到 1 之间(不包括 0 和 1)满足分母小于等于 n 的 最简 分数 。分数可以以 任意 顺序返回。 # # # # 示例 1...
4ba544b29145f891828319cc0cb09dfd6f4206c8
Wang-Yann/LeetCodeMe
/python/_1001_1500/1316_distinct-echo-substrings.py
3,193
3.546875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : Rock Wayne # @Created : 2020-07-05 19:57:14 # @Last Modified : 2020-07-05 19:57:14 # @Mail : lostlorder@gmail.com # @Version : alpha-1.0 """ # 给你一个字符串 text ,请你返回满足下述条件的 不同 非空子字符串的数目: # # # 可以写成某个字符串与其自身相连接的形式(即,可以写为 a + a,其中 a 是...
da890184d2f668dd80efa0119a68f13163e80425
Wang-Yann/LeetCodeMe
/python/_0001_0500/0280_wiggle-sort.py
1,776
3.75
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : Rock Wayne # @Created : 2020-07-27 11:14:37 # @Last Modified : 2020-07-27 11:14:37 # @Mail : lostlorder@gmail.com # @Version : alpha-1.0 """ # 给你一个无序的数组 nums, 将该数字 原地 重排后使得 nums[0] <= nums[1] >= nums[2] <= nums[3]...。 # # 示例: # ...
47e9ed21637045dbac15ed907ff6163c12582738
Wang-Yann/LeetCodeMe
/python/CrackingTheCodingInterview_6/16_13_bisect-squares-lcci.py
3,629
3.625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : Rock Wayne # @Created : 2020-07-13 17:03:29 # @Last Modified : 2020-07-13 17:03:29 # @Mail : lostlorder@gmail.com # @Version : alpha-1.0 """ # 给定两个正方形及一个二维平面。请找出将这两个正方形分割成两半的一条直线。假设正方形顶边和底边与 x 轴平行。 # # 每个正方形的数据square包含3个数值,正方形的左下...
1f32e49292a833bcb71589e1b8b8fcc4061dbfc8
Wang-Yann/LeetCodeMe
/python/_0501_1000/0640_solve-the-equation.py
1,868
3.78125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : Rock Wayne # @Created : 2020-05-05 17:19:14 # @Last Modified : 2020-05-05 17:19:14 # @Mail : lostlorder@gamil.com # @Version : alpha-1.0 # 求解一个给定的方程,将x以字符串"x=#value"的形式返回。该方程仅包含'+',' - '操作,变量 x 和其对应系数。 # # 如果方程没有解,请返回“No solution”。...
84a9351557988906f9e6634e5586fadbbddb1412
Wang-Yann/LeetCodeMe
/python/_0001_0500/0230_kth-smallest-element-in-a-bst.py
1,955
3.515625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : Rock Wayne # @Created : 2020-04-22 10:49:42 # @Last Modified : 2020-04-22 10:49:42 # @Mail : rock@get.com.mm # @Version : alpha-1.0 # 给定一个二叉搜索树,编写一个函数 kthSmallest 来查找其中第 k 个最小的元素。 # # 说明: # 你可以假设 k 总是有效的,1 ≤ k ≤ 二叉搜索树元素个数。 # # 示例 ...
d8eed40120b5b0ffaa520d1e7b9812ca9b2adf38
Wang-Yann/LeetCodeMe
/python/_0501_1000/0507_perfect-number.py
1,950
3.8125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : Rock Wayne # @Created : 2020-05-05 15:49:18 # @Last Modified : 2020-05-05 15:49:18 # @Mail : lostlorder@gamil.com # @Version : alpha-1.0 """ # 对于一个 正整数,如果它和除了它自身以外的所有正因子之和相等,我们称它为“完美数”。 # # 给定一个 整数 n, 如果他是完美数,返回 True,否则返回 False # ...
d748b7e3164fdebb175d392f9add4fcc8fdb9b7d
Wang-Yann/LeetCodeMe
/python/_1001_1500/1283_find-the-smallest-divisor-given-a-threshold.py
2,188
3.671875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : Rock Wayne # @Created : 2020-07-02 08:00:00 # @Last Modified : 2020-07-02 08:00:00 # @Mail : lostlorder@gmail.com # @Version : alpha-1.0 """ # 给你一个整数数组 nums 和一个正整数 threshold ,你需要选择一个正整数作为除数,然后将数组里每个数都除以它,并对除法结果求和。 # # 请你找出能够使上述结果...
c49e925bec633a9b758dbb1fca5608820bb48dfc
Wang-Yann/LeetCodeMe
/python/_0001_0500/0057_insert-interval.py
3,084
3.671875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : Rocky Wayne # @Created : 2020-04-11 21:02:25 # @Last Modified : 2020-04-11 21:02:25 # @Mail : lostlorder@gamil.com # @Version : alpha-1.0 """ # 给出一个无重叠的 ,按照区间起始端点排序的区间列表。 # # 在列表中插入一个新的区间,你需要确保列表中的区间仍然有序且不重叠(如果有必要的话,可以合并区间)。 # # 示...
3aee65856c172593a619b2ec56a6ce9c04fb4a77
Wang-Yann/LeetCodeMe
/python/_1501_2000/1705_maximum-number-of-eaten-apples.py
2,948
3.609375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : Rock Wayne # @Created : 2021-02-26 08:56:48 # @Last Modified : 2021-02-26 08:56:48 # @Mail : lostlorder@gmail.com # @Version : 1.0 # 有一棵特殊的苹果树,一连 n 天,每天都可以长出若干个苹果。在第 i 天,树上会长出 apples[i] 个苹果,这些苹果将会在 days[i] 天后(也就 # 是说,第 i + days[i] ...
03a164047c8f9f61972841ec4c01266e9ade4e60
Wang-Yann/LeetCodeMe
/python/_0501_1000/0977_squares-of-a-sorted-array.py
2,099
3.65625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : Rock Wayne # @Created : 2020-06-19 08:00:00 # @Last Modified : 2020-06-19 08:00:00 # @Mail : lostlorder@gmail.com # @Version : alpha-1.0 """ # 给定一个按非递减顺序排序的整数数组 A,返回每个数字的平方组成的新数组,要求也按非递减顺序排序。 # # # # 示例 1: # # 输入:[-4,-1,0,3...