blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
f07c61785d1b9877b8f058c83de3bdaa2b1089d9
HamsalekhaSuryadevara/pythonlearning
/import_module_exploring_std_lib.py
7,280
4.125
4
#we can import directory only currect file and impoertd files in the same directory import input_import_module_exploring_std courses=['mat','cat','rat'] print(input_import_module_exploring_std.find_index(courses,'rat')) #calling find_index function from the imported module #when we import the module we can use all var...
8c0605a444abc710ed8ba429db0b4dc8fe2d0b65
shahfasal/machine-learning-
/Machine Learning A-Z /Part 2 - Regression/Section 5 - Multiple Linear Regression/mlr.py
1,487
3.53125
4
import numpy as np import matplotlib.pyplot as plt import pandas as pd #importing dataset dataset = pd.read_csv('50_Startups.csv') x = dataset.iloc[:, :-1].values y = dataset.iloc[:, 4].values #encoding categorical data from sklearn.preprocessing import LabelEncoder, OneHotEncoder label_encoder = LabelEncoder() x[:,3...
c1e729425e20ff8fcd62f56fd29b3f548e9f8dc3
xiaolongbjcp/learnpy
/ex9_reduce.py
139
3.546875
4
def foo(x, y): return x*10+y L1 = [x for x in range(10,0,-1)] L2 = reduce(foo, L1) L3 = reduce(lambda x, y: x*10 + y, L1) print (L2)
26fe8c27764121987dadf372b18c88f88d9bcbd0
xiaolongbjcp/learnpy
/ex16_seudodict.py
422
3.71875
4
class Dict(dict): """docstring for Dict""" def __init__(self, **kw): super().__init__(**kw) def __setattr__(self, key, value): self[key] = value def __getattr__(self, key): try: return self[key] except KeyError: raise AttributeError("'Dict' object has no attribute '%s'" % key) # d = Dict(a=1, b=2...
0fb7f2e779ba48f4685a0796fb18c6a95ac84151
xiaolongbjcp/learnpy
/ex10_str2float.py
318
3.5625
4
from functools import reduce def str2float(s): intp = list(s.split('.')[0]) parp = list(s.split('.')[1]) l = len(parp) intp = reduce(intf, intp) parp = reduce(intf, parp)*1.0/pow(10, l) return intp + parp def intf(x, y): return (int(x)*10 + int(y)) print('str2float(\'123.456\') =', str2float('123.456'))
63e1556949bddfb484c1ef6acd074de31a5432f2
izn/meetup-python-type-hints
/demo/bank.py
948
3.875
4
""" 4º Meetup Python """ class BankAccount: """ BankAccount class """ def __init__(self, initial_balance = 0.0): self.balance = initial_balance def deposit(self, amount): """ Deposits to a Bank account """ self.balance += amount def withdraw(self, amount): """ Withdraw...
88b37722bed95db59555943bec70042842b0afb0
lemonh4733/YTPlaylistConverter
/links.py
167
3.515625
4
links = [] linksLenght = int(input("Enter playlist lenght: ")) for i in range(linksLenght): data = str(input("Enter "+str(i+1)+" link: ")) links.append(data)
f210bf3797d3c41bbb2ee84be673a7ffe40803b9
itsnotericlk/Sir-Jude-s-Assignment
/no. 7.py
177
3.78125
4
def convert(list): number = [] for i in list: number.append(len[i]) return number if name == ' main ': words = list(input('Enter words:')).split
d838903b2ca73f37a5081fddaec5ac42ce916b9b
KonstantinGanzew/All_project
/coursera/two week/checkers.py
237
3.671875
4
x = int(input()) y = int(input()) x1 = int(input()) y1 = int(input()) a = x1 - x a1 = y1 - y if a1 < 0: print('NO') else: if a < 0: a = a * -1 if a == 1 and a1 == 1: print('YES') else: print('NO')
76288341fe7538e296e92596a791eae85a659aa4
KonstantinGanzew/All_project
/coursera/two week/List of squares.py
180
3.515625
4
a = int(input()) - 1 b = 1 c = 1 d = str(c) + ' ' while True: if c < a: b += 1 c = b**2 d += str(c) else: break d += ' ' print(d[0:-1])
ca0d399617ea6a5ff2c9bc25f7031b59b8b00b62
KonstantinGanzew/All_project
/coursera/two week/Even and odd.py
278
3.78125
4
a = int(input()) b = int(input()) d = int(input()) even = 0 odd = 0 if a % 2 == 0: even += 1 else: odd += 1 if b % 2 == 0: even += 1 else: odd += 1 if d % 2 == 0: even += 1 else: odd += 1 if even >= 1 and odd >= 1: print('YES') else: print('NO')
28125f60d6ebe11f7eab65aab09bec3d7e9ba0b2
KonstantinGanzew/All_project
/Python для детей, Самоучитель по программированию/chet.py
155
3.78125
4
age = 24 if age % 2 == 0: for i in range (0, age, 2): print(i) else: print(0) for i in range (1, age, 2): print(i) print(age)
a5c80522b34fcd44dae6521e7debddd756b9fca9
ccropper/Exercism
/python/word-count/word_count.py
216
3.640625
4
import collections import re def word_count(phrase): words_list = re.findall("[0-9a-zA-Z']+", phrase) words_list = (word.lower().strip("'") for word in words_list) return collections.Counter(words_list)
41fe0167874fb415751086d85ed22b5adcd623ff
avivp16-meet/MEET-YL1
/paint.py
1,610
3.734375
4
import turtle turtle.speed(0) turtle.hideturtle() a=2 b="z" def circle (color,x,y,size): turtle.begin_fill() turtle.color(color) turtle.pu() turtle.goto(x,y) turtle.pd() turtle.circle(size) turtle.end_fill() turtle.penup() #green def green_c1(x,y): circle("green",x,y,1) def gree...
628a3709a23eb9b1f5a9cecfda5ad5360cb42e80
patricklaidlaw/programming_python3_excercises
/chapter1/average1_ans.py
497
3.890625
4
#!/usr/bin/env python3 numbers = [] while True: try: line = input("enter a number or Enter to finish: ") if not line: break numbers.append(int(line)) except ValueError as err: print(err) count = len(numbers) sum = sum(numbers) lowest = min(numbers) highest =...
bee5464d5479086e77f493c0ed515a4c0baedb6e
dzsnowings/girlswhocode
/Python/escape_game.py
9,651
4.34375
4
start = ''' You wake up and find yourself in a dark room. Your hands are tied, and the lights are off. Choose your answers by typing a choice enclosed in ''. ''' def giveUp(): print('''You've decided to accept your fate or being trapped in this room forever. You rethink your life decisions for the next 5 minut...
4c451f1d59bdf9d2d5bc086b045b70e4a475699c
RosaJanssen/projecto
/Code/Algoritms/random.py
17,850
3.84375
4
from ..Classes.classes import Protein import random from pprint import pprint import matplotlib.pyplot as plt import csv import numpy as np def create_random(protein): """ This function creates a random protein route, given the protein structure (protein.name_list) and the start coordinates. It first plac...
9e6d24263447b7ff009d90b81797916b33ce984c
henrytxz/my_python_repo
/core/built-in-functions/try_reduce.py
1,186
4.28125
4
# reduce(function, iterable[, initializer]) # Apply function of two arguments cumulatively to the items of iterable, # from left to right, so as to reduce the iterable to a single value. # For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) # calculates ((((1+2)+3)+4)+5). # The left argument, x, is the accumulated v...
b9b316b2cb1af3e9fb37253d219e84f821c56c2f
henrytxz/my_python_repo
/hackerrank/wk_of_code_25/append_and_delete.py
1,890
3.96875
4
""" https://www.hackerrank.com/contests/w25/challenges/append-and-delete """ from verbose_assert import verbose_assert def append_and_delete(s, t, k): ls = len(s) lt = len(t) num_same_chars = count_number_same_chars(ls, lt, s, t) if yes_reason_1(ls, lt, k) or yes_reason_2(ls, lt, k, num_same_chars): ...
ba997a4560703113cf9148889102a0debace7879
henrytxz/my_python_repo
/core/tree/prefix_tree.py
3,081
3.9375
4
""" this module contains the main logic to implementing the auto-completion feature using a prefix tree every node in the prefix tree can have any of the lower case alphabet or * * marks the end of a word """ class Node(object): def __init__(self, key, children=[]): self.key = key self.children = ...
0c85f703cf75c8a558a543597a9910ff44234575
henrytxz/my_python_repo
/design_programs/code_from_scratch/regex.py
2,959
3.671875
4
import string def match(pattern, string): """ returns the longest substring of string that fits the pattern """ set_remainders = pattern(string) if not set_remainders: return None shortest_remainder = min(set_remainders, key=len) return string[:len(string)-len(shortest_remainder)] def lit(...
6039890608cfec1511ab5b7186a2714c110b7165
henrytxz/my_python_repo
/code_wars/factors.py
1,911
4.1875
4
def factors(x): if not isinstance(x, int) or x<1: return -1 else: bigger_factors = [] smaller_factors = [] import math # bigger_factors.append(x) values_to_check = range(int(math.floor(math.sqrt(x)))) # for x = 54: 0 to 6 for i in values_to_check: ...
995b60891a24b0bfce248bff98d29173e85d5189
henrytxz/my_python_repo
/design_programs/code_from_lessons/lesson3/interpreter.py
4,665
3.75
4
#--------------- # User Instructions # # Complete the search and match functions. Match should # match a pattern only at the start of the text. Search # should match anywhere in the text. def search(pattern, text): "Match pattern anywhere in text; return longest earliest match or None." for i in range(len(text...
8e8182d90f150fb01d716c831819c71b55be8084
henrytxz/my_python_repo
/code_wars/linked_list/alternating_split.py
1,411
4.03125
4
from unittest import test class Node(object): def __init__(self, data=None, next=None): self.data = data self.next = next class Context(object): def __init__(self, first, second): self.first = first self.second = second def prepend(head, data): if head is None: re...
918a81657b90edf71e2d113866d001810709cc17
henrytxz/my_python_repo
/core/callable_object_example.py
600
3.65625
4
class Factorial(object): def __init__(self): self.cache = {} def __call__(self, n): if not isinstance(n, int): return 'Factorial expects a non-negative integer argument' if n < 0: return 'Factorial expects a non-negative integer argument, got {}'\ ...
5c323bcca137e3b740fbe15b5dda3bc94ba8b7ee
henrytxz/my_python_repo
/hackerrank/wk_of_code_24/shashank_palindromic_strings/shashank_palindromic_strings.py
2,742
3.71875
4
# # def chars_from_string(string): # chars = dict() # for i in range(len(string)): # chars.setdefault(string[i], []).append(i) # return chars # # def find_beg_str_char_also_in_end_str(beg_str, end_str_chars, i=0): # i = 0 # while i != len(beg_str): # if beg_str[i] not in end_str_char...
df149fad459ce30905769080c31de4ee3775aa77
henrytxz/my_python_repo
/core/iterator.py
259
3.515625
4
import random def die_rolls(): while True: yield random.randint(1, 6) results = [] for i in range(int(1e5)): results.append(next(die_rolls())) # call next(generator) print sum(results)/float(len(results)) # close to 3.5 print die_rolls()
b7ae4ece3f7de509e2fdb5ed1235e0688333d56e
uzahoor/logs-analysis
/newsdata.py
1,318
3.65625
4
#!/usr/bin/env python2 # Database code for the DB Forum, full solution! import psycopg2 DBNAME = "news" def execute_query(query): """Execute a query and return the results as an array of tuples.""" try: db = psycopg2.connect(database=DBNAME) except psycopg2.Error as e: print "Database fa...
f18b61727a9a31cc1eda507fa82240e3b1e84a1c
phrdang/wrrf-spark
/practice/rect_area.py
371
4.0625
4
# Rect Area # Create a function called rect_area which takes 2 parameters: # length and width (of a rectangle) and returns the rectangle's # area. Then print the result of calling rect_area at least 3 # times with various lengths and widths. def rect_area(length, width): return length * width print(rect_area(5, ...
67f4583d8152bd079a3c3cf324133994cb15cbc2
phrdang/wrrf-spark
/examples/functions.py
1,352
3.984375
4
def square(x): print(x * x) def greet(name, greeting_type): if greeting_type == "SHIELD": print("I hear Tahiti's a magical place, " + name) elif greeting_type == "Star Wars": print("May the Force be with you, " + name) elif greeting_type == "Star Trek": print("Live long and pro...
ed17b412d0df2fff6bbd69e6403632fc7e7ab268
amrudesh1/Bios_Pentest_Task
/Easy/Python/ceasercipher.py
1,216
3.953125
4
def encrypt_string(plain_text, key): encrypted_text = '' for i in range(len(plain_text)): if not plain_text[i].isalnum(): encrypted_text = encrypted_text + plain_text[i] elif plain_text[i].isupper(): encrypted_text = encrypted_text + chr((ord(plain_text[i]) + key - ...
7c698dcc32f39516a262c92b28f629d1dd5fa020
MuathAlhooshani/Explore-US-Bikeshare-Data
/bikeshare.py
8,989
4.09375
4
#!/usr/bin/env python # coding: utf-8 # In[3]: import time import pandas as pd import numpy as np CITY_DATA = { 'Chicago': 'chicago.csv', 'New York': 'new_york_city.csv', 'Washington': 'washington.csv' } def get_filters(): """ Asks user to specify a city, month, and day to analy...
dae3031a0119ae6c0011f3afc56cda6c0478f3a6
NicMetras/python-encryption
/crypto.py
2,002
3.5625
4
from Crypto.Cipher import AES from Crypto import Random from Crypto.Protocol.KDF import PBKDF2 import os # *** Encryption Functions *** def encrypt(text, key, key_size = 256): pad = lambda s: s + b"\0" * (AES.block_size - len(s) % AES.block_size) text = pad(text) initialization = Random.new().read(16) ...
20ddf6d8b010b47a3dd8ffc740c4a22b8e68f13e
eliantony/projects
/face_rec.py
577
3.546875
4
import face_recognition picture_of_me = face_recognition.load_image_file("eli.jpg") my_face_encoding = face_recognition.face_encodings(picture_of_me) print(len(my_face_encoding)) face1 = my_face_encoding[0] unknown_picture = face_recognition.load_image_file("test3.jpg") unknown_face_encoding = face_recognition.face_...
d5143a71df6657464fe3d81ca01f3e7a913d435f
aidashiraliyeva/PragmatechFoundationProject
/Tasks/main.py
1,503
3.6875
4
programMenusu=""" ----Proqram Menusu---- 1- Qeydiyyatdan keç 2- Daxil ol """ """ 1- Qeydiyyatdan keç """ users=[] class User: def __init__(self,_id,_ad,_soyad,_email,_username,_password): self.Id=_id self.Ad=_ad self.Soyad=_soyad self.email=_email self.usern...
934811942f25a08f125d9740509b44fb14f5b836
Lucas-Saraiva/Gerenciador_senha
/InterfaceGerenciador/MenuListagem.py
840
3.765625
4
import sqlite3 from tkinter import * conn = sqlite3.connect('password.db') cursor = conn.cursor() cursor.execute(''' CREATE TABLE IF NOT EXISTS users ( service TEXT NOT NULL, username TEXT NOT NULL, password TEXT NOT NULL ); ''') def show_service(): cursor.execute(''' SELECT service FROM us...
d92d05cb782cf7271530b224bd4f0fcba84c4255
anagonousourou/contests-prog
/Python/hackerrank/BasicDataTypes/ListComprehensions.py
302
3.71875
4
if __name__ == '__main__': x = int(input()) y = int(input()) z = int(input()) n = int(input()) mylist = [(i, j, k) for k in range(z+1) for j in range(y+1) for i in range(x+1) if i+j+k != n] mylist.sort() mylist = [list(triplet) for triplet in mylist] print(mylist)
f743d3575a3c2eef1b982aa28bf17159aebe1f01
anagonousourou/contests-prog
/Python/hackerrank/Strings/swap_case.py
436
4.125
4
""" From https://www.hackerrank.com/challenges/swap-case/problem?isFullScreen=true """ def swap_case(s_string): """ change the case of the letter in s, lowercase -> uppercase and uppercase -> lowercase :param s """ return str.join("", [character.upper() if character.islower() else character.lower() ...
7b3f69e17d69874e11eaf97ac6172b9215cb292a
adito0/AditiFlix_A3
/AditiFlix_App/domainmodel/review.py
1,731
3.53125
4
from datetime import datetime from AditiFlix_App.domainmodel.movie import Movie class Review: def __init__(self, movie, review_text, rating): if (type(rating) is not int and type(rating) is not float) or (rating < 1) or (rating > 10): self.__rating = None else: self.__rat...
8dde4b8af06f69d99117082de65e7df716199044
vieiraguivieira/PhytonStart
/ranges.py
103
3.828125
4
#for i in range(0, 20, 2): #print("i is now {}".format(i)) for i in range (0,101, 7): print(i)
a7a7d9878a7fa0fe0045db04abcf89a777000243
Wojtbart/Python2020
/3_7.py
399
3.890625
4
# 3.7 class Time: def __init__(self, seconds=0): self.s = seconds def __str__(self): return "{} sec".format(self.s) def __repr__(self): return "Time({})".format(self.s) time1 = Time(12) time2 = Time(3456) print(time1.__str__()) print time1, time2 # Python wywołuje str...
7b58f44bb996bc9b705833a48343fc1b35a37b05
sriharsha96/speckbitppa
/fix_blog.py
318
3.75
4
in_str = input("Enter the faulty string : \n") # in_str = "HarshaIsTheBest" in_str = "{} A".format(in_str) p_str = in_str k=[] ptr = 0 for key_char in range(1, len(p_str)): if p_str[key_char].isupper() : k.append(p_str[ptr:key_char]) ptr = key_char print("The new string is \n ") print(' '.join(k))
fd1212646664e51b461f5df8a6c49364b8da5610
pgw928/TIL
/algorithms/inflearn/section2/8.py
517
3.734375
4
import sys sys.stdin = open('section2/input.txt', 'rt') n = int(input()) arr = list(map(int, input().split())) def isPrime(x): if x==1: return False i = 2 while i*i<=x: if x%i==0: return False i += 1 return True # def reverse(x): # return int( str(x)[::-1] )...
b517d8496fd0b877f1b9c397b4460bf4eb2fce76
Alex9583/En_garde
/cartes.py
3,950
3.984375
4
# -*- coding: utf-8 -*- from random import randrange liste = [1, 2, 3, 4, 5] def initialise(ppioche=None, pdefausse=None): """Initialise la pioche et la défausse""" #ppioche et pdefausse sont des listes pour les parties chargées if (ppioche is None) and (pdefausse is None): pioche = liste * 5 ...
23d2250df8ed360a2793849b02372fceb92d30a4
farruhilhamov/python-m1
/oop.py
2,487
4
4
#!/usr/bin/env/ python3 import abc class Human(object): age = 0 @staticmethod def sum(x,y): return x+y @classmethod def div(cls,x,y): return cls.age*x*y @abc.abstractmethod def soul(self): pass name = "" age = 0 surname = ""...
d92d5c7a1f8061b966a617aa69b31a2e78797486
farruhilhamov/python-m1
/lindemann.py
854
3.53125
4
from os import write #class Group: # album = [] # def __init__(self,group,album,song): # self.group = group # self.album_name = album # self.songs = [] # # def albumpacker(self): # self.album.append(self.song) def main(): file = open("albums.txt","a+") ...
135fb79ccfa1c7b1a4c08710d0a0f74383fefa4f
farruhilhamov/python-m1
/for.py
207
3.8125
4
#!/usr/bin/env/ python3 #comment def main(): imin = int(input('min: ')) imax = int(input('max: ')) for i in range (imin,imax): print(i, i**2) if __name__ == "__main__": main()
1d5283ac945830a84e93c68b3a674ab62e6b0804
llsh2011/pythoncode
/27/function.py
1,236
3.5625
4
#encoding=utf-8 # -*- coding: utf-8 -*- print max(1,2) print'max(1,2) = ',max(1,2) print 'int(\'123\')=',int('123') def my_abs(x): if x >= 0: return x else: return -x print my_abs(2) print my_abs(-2) def sum2N(n): sum = 0 for x in range(n): sum = sum + x return sum print sum2...
48759900f58a5c9c045c12e0d606a65349cc3158
kvitajin/SPJA
/pokusCv1/stfu.py
556
3.890625
4
def invert(lst): tmp='' for i in lst: if i>='a': tmp+=i.upper() else: tmp+=i.lower() return tmp slovnik={'hello':'ahoj', 'one':'jedna', 'two':'dva', 'three':'tri', 'four':'crtyri'} def dict(slovnik, word): if word in slovnik...
5e71d8bdadf95cf636bc406ca6fbe6b47f234071
ericrosko/python_practice
/list_problem.py
989
3.828125
4
#!/usr/bin/env python3 ''' Author: Eric Rosko Date: June 11, 2018 Description: File: list_problem.py ''' import sys # allows me to get command line arguments def find_largest_with_nested_lists(*items): # print("items", items, type(items)) largest = None current = None for item in items: ...
7fcf3e18d05a25be89d2e2685e98663e282c8028
Vinicius-asf/python_study
/test_loop.py
129
3.71875
4
#for x in range(0,3): # print("Fale %d " % (x) + "Ou isso %d " % (x)) #print(x) #a = [1,2,3,4,5,6] #for x in a: # print(x)
b52a1a51a34e52ac92660acdbdc5d4309516fdd0
timegao/othello
/othello_game_starter/calculate.py
6,803
3.65625
4
from collections import defaultdict import copy class Calculate: '''Calculates legal moves for both players''' '''Calculates coordinate for computer to place disk''' @staticmethod def legal_moves(player): '''Populates self.moves dictionary with valid moves''' directions = [...
bcad38a290d8e26545f69855a15e0b4028a29933
atshudy/ATM
/cs521/src/model/test_accounts.py
2,583
3.609375
4
import unittest from cs521.src.model.bank import Bank from cs521.src.model.checking_account import CheckingAccount from cs521.src.model.savings_account import SavingsAccount from cs521.src.model.address import Address __author__ = 'ATshudy' class TestAccounts(unittest.TestCase): bank = Bank() acct1 = Checki...
ebc9af4279ad964352293bdaecaa1b3bb1cc37c1
woffkass/stepik_python_level_1
/examp_16.py
159
3.609375
4
genom = input() genom = genom.upper() count = 0 for i in genom: if i == 'C' or i == 'G': count += 1 result = count * 100 / len(genom) print(result)
6f161dd8084acf559718c5efd7003f38828cdd9d
EvgeniiyaR/tasks
/splitting_into_chunks.py
1,375
3.734375
4
""" На вход программе подаются две строки, на одной символы, на другой число nn. Из первой строки формируется список. Реализуйте функцию chunked(), которая принимает на вход список и число, задающее размер чанка (куска), а возвращает список из чанков указанной длины. Формат входных данных: На вход программе подается...
979980cd99a5693e4c83ea91cbdf2f420a443d81
dipanbhusal/Python_practice_programs_2
/ques7.py
471
3.53125
4
friends_list = [('Henry', 'Smith', 22),('Bishwo', 'Poudel', None),('Nawaraj', 'Poudel', 19),('Dipan', 'Bhusal', 21),('Rita', 'KC', 25),('Hari', 'Khadka', None)] sum_age = 0 count = 0 for i in friends_list: if i[2] != None: count += 1 sum_age += i[2] avg_age = sum_age//count for i in friends_list: ...
414f277490156d77573b67dd6557c6babbb1dde8
dipanbhusal/Python_practice_programs_2
/ques8.py
185
3.796875
4
def is_prime(number): if number <= 1: return False for i in range(3,number): if number % i == 0: return False return True print(is_prime(199))
bcec2d55dff4a280c702f53b60959bd8fdca4e20
alehpineda/IntroAPython-Practicas
/U4 - Funciones/U4T2 - Sintaxis de las funciones/U4T2P1.py
959
3.765625
4
""" U4 - Funciones T2 - Sintaxis de las funciones P1 - Partes de la funcion Las funciones estan definidas por tres componentes: 1. El encabezado, que incluye la palabra clave def, el nombre de la funcion y cualquier parametro que la funcion requiera. Ejemplo: def hola_mundo(): #Esta no tiene par...
8c28e05314881fad3d66fe7d82e4f4a57de05c01
alehpineda/IntroAPython-Practicas
/U3 - Condicionales y Control de Flujo/U3T4 - if, else y elif/U3T4P3.py
883
3.828125
4
""" Unidad 3 - Condicionales y Control de Flujo. T4 - If, Else y Elif P3 - Si no... La sentencia else complementa al if. Un par if/else dice: "Si esta expresion es verdad, corre este codigo; Si no, corre este otro codigo". A diferencia del if, el else no depende de una expresion. Por ejemplo: if 8>9: ...
1f8e8c21cb836afd1a89f0d1cd38acac1fbcceaa
alehpineda/IntroAPython-Practicas
/U2 - Cadenas y consola/U2T4 - Print avanzado/U2T4P3.py
785
3.625
4
""" U2T4 - Print avanzado Ahora que ya sabes imprimir a la consola, veamos algunas cosas mas avanzadas de print """ """ Ej 03 - Formateo de cadenas, parte 1. Excelente trabajo hasta ahora! Una mas y hacemos review. Vimos anteriormente que podiamos accesar a los caracteres individualmente de una cadena utilizando un...
21da3e8c7d00a4fc9549233890ecd7394a61892a
alehpineda/IntroAPython-Practicas
/U3 - Condicionales y Control de Flujo/U3T5 - Review/U3T4Review.py
870
3.953125
4
""" Unidad 3 - Condicionales y Control de Flujo. T4 - Review El gran if. Excelente trabajo hasta ahora! Esto es un resumen de lo que vimos esta unidad. Comparadores 3<4 5>=5 10==10 12!=13 Operadores booleanos True or False (3<4) and (5>=5) esto() and not aquello() Condicionales ...
e49cbd25092a7e65e643ca973cd97d9f3ffeaf8d
alehpineda/IntroAPython-Practicas
/U1 - Sintaxis de Python/U1T2 - Espacios en blanco y sentencias/U1T2P1.py
1,429
4.125
4
# -*- coding: utf-8 -*- """ U1T2 - Espacios en blanco y enunciados Ahora que conocemos y entendemos lo que son las variables, los valores y la asignacion, veamos que son los espacios en blanco y los enunciados. Las sentencias del lenguaje Python. """ """ Ejercicio 01 - Que es un enunciado? Un enunciado en Python e...
3884249b284d476c87307d73e925097126b19a72
yxdragon/imp_pythonstudy
/lesson02/iffor.py
107
3.828125
4
a = 50 if a>=90: print('A') elif a>=80: print('B') elif a>=60: print('C') else: print('Z')
8925e858715603b2bb672bcf3549c8f129a99c5b
yxdragon/imp_pythonstudy
/lesson11/geom.py
513
3.875
4
from math import pi point = (1,1) rect = [3,5] circle = 1 def point_area(p):return 0 def rect_area(r): return r[0]*r[1] def circle_area(c): return pi*c**2 print(point_area((2,4))) print(rect_area((3,5))) print(circle_area((1))) def geom_area(geom): if isinstance(geom, int):return circle_area(geom) ...
f68d6c2d6b9f5e32469b976fc8402f3d6edf6a05
WanChantavilasvong/big-data-spring2018
/week-02/submission/pset1.py
5,169
4.34375
4
#------------------------------------------- ##A. Lists #A.1 Create a list containing any 4 strings. list_a = [1, 2, 3, 4] # EH: these aren't strings - these are integers! #A.2 Print the 3rd item in the list. print(list_a[2]) #A.3 Print the 1st and 2nd item int he list using [:] index slicing. print(list_a[0:2]) #A...
fa35d40ee06e9da742e3fbcc24633a1ac7c89529
saladcat/route_transfer
/test/test_ref.py
193
3.5
4
class A(object): def __init__(self): self.a = 1 self.b = 2 def change(a): a.a = -1 if __name__ == '__main__': dic = {} a = A() change(a) print(a.a)
d845e34461954a7cf3138b06366d28f6a4a47b71
visuc9/prdrco
/App/utils/encrypt.py
1,701
4.03125
4
# The purpose of this file is to manage password encryption and decryptions. from cryptography.fernet import Fernet import getpass import os # Encryption Class class Encrypt: # def __init__(self): # print('Encrypt Class Initialized') # Creates an encryption key, which can then be stored as an Enviro...
66472baf88ff38d42794ee96e7175cd56d9068ea
keshav-Analyst/Programmers-Community
/Basic/Calculate Factorial of A Number/SolutionByKeshav.py
199
4.25
4
#Factorial #input the digit for which the factorial is to be calculated n= int(input()) #create a temp variable fact=1 for i in range(1,n+1): fact=fact*i #print the result print(fact)
2fff8659b6e441340270c8bb581527ab6f13a28d
anoushaf/TapTap
/Source_Code/Tools/gen_song_SQL.py
4,400
3.8125
4
#!/usr/bin/env python3 # This script takes a csv filename as its first parameter and outputs # SQL queries to insert the song information into the database. import sys #Song class stores information on the song and generates Insert queries for the song class Song: def __init__(self): self.name = None ...
5a658b57cbb241e0a0fd34608d926276facb14b5
Antimarvin/Codeeval
/Easy/SumOfPrimes/SumOfPrimes.py
502
3.671875
4
__author__ = 'Richard L. Sweat Jr.' def prime(i, primes): for prime in primes: if not (i == prime or i % prime): return False primes.add(i) return i def get_primes(n): primes = set([2]) i, p = 2, 0 while True: if prime(i, primes): p += 1 if...
ffa2eaa31dc5c7983e4352155969bcfa0a2dbcf2
GilbertoPoot07/Ejercicios-Python
/5.-rotacion.py
292
3.796875
4
a=int(input("Ingresa un numero ")) b=int(input("Ingresa un numero ")) c=int(input("Ingresa un numero ")) d=int(input("Ingresa un numero ")) e=int(input("Ingresa un numero ")) lista = [a,b,c,d,e] print lista print [b,c,d,e,a] print [c,d,e,a,b] print [d,e,a,b,c] print [e,a,b,c,d]
cf74184f1ad50a7d7b9ad22acc9b053d8d9a62b1
GradyLee/learn-python
/normalize.py
486
4.0625
4
#!/usr/bin/env python3 # -*- coding utf-8 -*- ''' 利用map()函数,把用户输入的不规范的英文名字,变为首字母大写,其他小写的规范名字 ''' def normalize(name): if len(name) == 0: return None s = str.upper(name[0]) + "".join(list(map(str.lower, name[1:]))) return s ''' return s.capitalize(name) ''' if __name__ == "...
bad1b79ce3ab5e28d66f6c0b10ca502f3abc0472
valenpy/py_duplicates
/duplicates.py
265
3.921875
4
"""module duplicates""" from typing import List def find_duplicates(lst: List[int]) -> int: """ Count duplicate elements in a list. :param lst: lst :return: int """ uniq_lst = {x for x in lst if lst.count(x) > 1} return len(uniq_lst)
548629ddd53185227439b92e493cdf59dcd0e61a
cfreeman22/python-exercises
/python_introduction_exercises.py
587
4.53125
5
# 1 Open Visual Studio Code and install the Python extension. This will provide nice editing features when writing Python code. #Ensure that you have the correct version of Python installed by running the command in this lesson that prints the version # of Python that you have installed. # Create a hello world progra...
d4bcca5d5aacf8f0c95cddff424b4962c92d4b8d
freaker2112/GEOMETRIC-SEQUENCE-FORMULA
/main.py
366
3.90625
4
n = int(input ('please enter the part of the sequence you are trying to find')) r_raw1 = int(input ('please enter the first number in the sequence')) r_raw2 = int(input ('please enter the second number in the sequence')) a1 = int(input ('please enter the first number in the sequence again')) r_solved = r_raw2 / r_raw1 ...
bd119ad29112d06dcb7a784b009e62fd45a837a7
danr18/Python-Programs
/trig_functions.py
257
3.53125
4
import math import stdio import sys # Get t from command line, as a float. t = float(sys.argv[1]) # Convert t to radians. t = (t * math.pi)/180 # Write the value of sin(2t) + sin(3t). stdio.writeln((math.sin(2 * t)) + (math.sin(3 * t)))
ae05ee34b057c85dd4e82ac7e27ccf3469f8ed23
joseph-zhong/practice
/leetcode/array/merge_intervals.py
530
3.859375
4
#!/usr/bin/env python3 """ Merge Intervals https://leetcode.com/problems/merge-intervals/ """ class Interval(object): def __init__(self, s=0, e=0): self.start = s self.end = e def merge(intervals): """ """ sorted_intervals = sorted(intervals, key=lambda x: x.start) res = [] for...
dbd2e5c9dd4c6dd0b772f05b7acd602351bfbafd
joseph-zhong/practice
/archive/Valid_Anagram.py
310
3.71875
4
class Valid_Anagram: # @param {string} s # @param {string} t # sorts s and t then compares the two # @return {boolean} def isAnagram(self, s, t): s = ''.join(sorted(s)) t = ''.join(sorted(t)) return (t == s) # main.py s = Valid_Anagram() s.isAnagram("123", "32a1")
994f18ad537e91a1b69ff4c26f45618ea8bd2429
joseph-zhong/practice
/ctci/4/is_subtree.py
833
4.28125
4
#!/usr/bin/env python3 """ 4.10: Check Subtree """ from binary_tree import Node def equals(r1, r2): if r1 is None and r2 is None: return True elif r1 is None or r2 is None: return False elif r1.val != r2.val: return False return equals(r1.left, r2.left) and equals(r1.right, r2....
f12570643facc0ffc9b5e3331f8ec10fc97ad34a
joseph-zhong/practice
/ctci/4/construct_min_bst.py
673
3.90625
4
#!/usr/bin/env python3 """ 4.2 Minimal Tree """ from binary_tree import Node def constructMinBst(vals): """ Given a sorted list of unique integers, this returns a binary search tree of minimum height. """ def recurse(i, j): if j - i == 0: return None mid = j // 2 + i // 2 ...
1a3fe287bca5556155dc46e15f383ec90dce4f47
adaptive-learning/geography-data-libs
/proso/geography/places.py
2,156
3.6875
4
# -*- coding: utf-8 -*- """ Basic functionality to work with place data. """ from dfutil import load_csv def from_csv(place_csv, placerelation_csv=None, placerelation_related_places_csv=None): """ Loads place data from the given CSV files. Args: place_csv (str): name of the file con...
39bf5bcf949d370587c67622d3a9942c0ff9e9bb
ivnxyz/practicas-programacion-inviertete
/Daniel Rosales/pesoenotroplaneta.py
218
3.625
4
#Calcular peso en otro planeta peso=70 gravedadTierra=9.78 gravedadMarte=3.72 formulaDespejadaMasa=int(input("peso:"))/gravedadTierra pesoMarte=formulaDespejadaMasa*gravedadMarte print("Tu peso en Marte es:",pesoMarte)
c3df87f7dab4e39905f2d9314bc6cf28446e2394
ivnxyz/practicas-programacion-inviertete
/Frida/tablas2.py
86
3.5
4
lista=[1,2,3,4,5,6,7,8,9,10] m=1 for num in range(10): m += 1 print([lista])
af27f48da8ace55ab443766248e81c48ac1bccfc
ivnxyz/practicas-programacion-inviertete
/Frida/dado.py
113
3.5625
4
import random dado= input("presiona enter para tirar el dado") for numero in dado: print(random.randrange(1,7,1))
5800ea7643ea5b6c96d4af7dfb9bca9c80bbfac3
ivnxyz/practicas-programacion-inviertete
/Juan Valencia/2.py
192
3.875
4
frase = input("") pal = frase.replace(" ", "") if pal == pal[::-1]: print("La frase que ingresaste SÍ es un palíndromo.") else: print("La frase que ingresaste NO es un palíndromo.")
fe0cd891a87ddf2e27b78417d753fe636dc548ee
ivnxyz/practicas-programacion-inviertete
/Dana Lucas/practica1.py
2,379
4.125
4
#NÚMEROS #1.sacar el area de un circulo pi = 3.1416 radio = 1.1 formula = pi * radio**2 print(formula) #2.devuelve el valor absoluto #3.calcular propinas subtotal = 44.50 propina = .10 totalPropina = subtotal * propina total = subtotal + totalPropina print(subtotal) print(total) #4.calcular peso en otro planeta ma...
5ae6ceeeb901e894cffeea799712f8f170434060
ivnxyz/practicas-programacion-inviertete
/karen/diccionarios.py
1,407
4.28125
4
#crear un dicionario de capitales y paises min.5 paises={"austria":"viena","brasil":"brasilia","bolivia":"sucre","camerun":"yaundé","buntán":"thimphu"} #escribe un enunciado donde lea "la capital x es y" print("la capital de austria es",paises["austria"]) print("la capital de brasil es",paises["brasil"]) print("la capi...
986372f829f5fe4fda6449c556fd54018f3750b0
gerardomojica/gm_ie
/src/models/linear_regression.py
9,135
3.6875
4
# Test file to train a linear model: linear regresssion # 01/25/2016 import numpy as np from scipy.optimize import minimize, fmin, fmin_bfgs import scipy.optimize as op from SoftMax import SoftMax # from numpy.random import randn,randint # Linear model def linear_model(w,x): return np.dot(w.T,x) def gradient(y,w,x)...
f09a8ae71213b04977575dda6976c8c601d2e44a
dineshkanchi1/Hackerrank
/The Minion Game.py
338
3.6875
4
def minion_game(str1): a=0 b=0 vowels='AEIOU' for i in range(len(str1)): if(str1[i] in vowels): a=a+(len(s)-i) else: b=b+(len(s)-i) if(a<b): print("Stuart "+str(b)) elif(a>b): print("Kevin "+str(a)) else: print("Draw") # you...
f9067f269de537642a0ac66c852fc07c19113444
marcoisgood/Leetcode
/0279. Perfect Squares.py
762
3.8125
4
""" Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. Example 1: Input: n = 12 Output: 3 Explanation: 12 = 4 + 4 + 4. Example 2: Input: n = 13 Output: 2 Explanation: 13 = 4 + 9. """ class Solution: _dp = [0] def numSquares(self, n): ...
129d7b2f326baa67568302abae348a0c3322adc5
marcoisgood/Leetcode
/0033.Search-in-Rotated-Sorted-Array.py
1,599
4.125
4
""" Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]). You are given a target value to search. If found in the array return its index, otherwise return -1. You may assume no duplicate exists in the array. Your algorith...
75ed22fd12656ef2f58e23b576f6441e4a392980
marcoisgood/Leetcode
/0377. Combination Sum IV.py
806
4.03125
4
""" Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target. Example: nums = [1, 2, 3] target = 4 The possible combination ways are: (1, 1, 1, 1) (1, 1, 2) (1, 2, 1) (1, 3) (2, 1, 1) (2, 2) (3, 1) Note that different seque...
16d85703e64681af60ff0e9cffe2a55a276c4683
marcoisgood/Leetcode
/0230.Kth-Smallest-Element-in-a-BST.py
1,138
3.9375
4
""" Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note: You may assume k is always valid, 1 ≤ k ≤ BST's total elements. Example 1: Input: root = [3,1,4,null,2], k = 1 3 / \ 1 4 \ 2 Output: 1 Example 2: Input: root = [5,3,6,2,4,null,null,1], k = 3 ...
a3f5b41a6f3d78fcde2f5e93c1633b249cacde52
marcoisgood/Leetcode
/1150. Check If a Number Is Majority Element in a Sorted Array.py
977
4.46875
4
""" Given an array nums sorted in non-decreasing order, and a number target, return True if and only if target is a majority element. A majority element is an element that appears more than N/2 times in an array of length N. Example 1: Input: nums = [2,4,5,5,5,5,5,6,6], target = 5 Output: true Explanation: The val...
c0c853d58d6a8f97e098338e1162347475505b0e
marcoisgood/Leetcode
/0416. Partition Equal Subset Sum.py
1,469
3.859375
4
""" Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal. Note: Each of the array element will not exceed 100. The array size will not exceed 200. Example 1: Input: [1, 5, 11, 5] Output: true Explan...
ba6174edd7ec15ea690dd77643ebc4ff59273a3d
marcoisgood/Leetcode
/0560. Subarray Sum Equals K.py
1,300
3.734375
4
""" Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k. Example 1: Input:nums = [1,1,1], k = 2 Output: 2 """ class Solution: # def subarraySum(self, nums, k): # left, right, count = 0, 1, 0 # # for i in range(len(nums...
3b058444ab55da669bd9320b79df9cc0807b5771
marcoisgood/Leetcode
/1198. Find Smallest Common Element in All Rows.py
821
3.859375
4
""" Given a matrix mat where every row is sorted in strictly increasing order, return the smallest common element in all rows. If there is no common element, return -1. Example 1: Input: mat = [[1,2,3,4,5],[2,4,5,8,10],[3,5,7,9,11],[1,3,5,7,9]] Output: 5 """ class Solution: def smallestCommonElement(self, ma...
600515adc51769d9a16a3530ca2f29b8e1491015
marcoisgood/Leetcode
/0215.Kth-Largest-Element-in-an-Array.py
560
4.1875
4
""" Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Example 1: Input: [3,2,1,5,6,4] and k = 2 Output: 5 Example 2: Input: [3,2,3,1,2,4,5,5,6] and k = 4 Output: 4 Note: You may assume k is always valid, 1 ≤ k ≤ array's length...
b6829ec46f79f97d4fd74e166962d343127baba7
marcoisgood/Leetcode
/0162. Find Peak Element.py
1,640
4.125
4
""" A peak element is an element that is greater than its neighbors. Given an input array nums, where nums[i] ≠ nums[i+1], find a peak element and return its index. The array may contain multiple peaks, in that case return the index to any one of the peaks is fine. You may imagine that nums[-1] = nums[n] = -∞. Exam...
35aa22887202f7fafd52676c22926fd2543fc695
marcoisgood/Leetcode
/0938. Range Sum of BST.py
956
3.90625
4
""" Given the root node of a binary search tree, return the sum of values of all nodes with value between L and R (inclusive). The binary search tree is guaranteed to have unique values. Example 1: Input: root = [10,5,15,3,7,null,18], L = 7, R = 15 Output: 32 Example 2: Input: root = [10,5,15,3,7,13,18,1,null,6],...