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
616c561094512c1b30d675d12b815ceb706e08a1
bigmario/linear_regression_Python
/main_seaborn.py
1,444
3.734375
4
from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression from sklearn.metrics import mean_squared_error import pandas as pd # Manejo de datos import seaborn as sns # Creación de gráficas y visualización de datos import numpy as np import matplotlib.pyplot as plt def mai...
33aafc24cdb469ea4788b2d454e3b294e9a2a792
pvashwini/SafariPython
/Lists.py
760
3.984375
4
names = ["Jim", "Fred", "Sheila"] print(names) print(names[0]) names[0] = "Frederick" # Lists are mutable print(names) names.sort() # "Natural" order, defined by __gt__ etc. print(names) names.sort(reverse=True) names.sort(key=lambda s: len(s)) print(names) # slicing: numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] print...
51e93f83049972d01dfd742a3486142f94ed8083
mwbond/utdf
/src/chart.py
2,425
3.5625
4
# Matthew Bond # A simple class for easy output of charts class Chart(): def __init__(self, data=None, col_names=None, row_names=None): data = data or [] self.data = [] for row in data: self.add_row(row) self.col_names = col_names or [] self.row_names = row_names...
5004b5a07052a9a93a37d2750345226351763be4
leesohyeon/Python_ac
/1105/tupleex/TupleTest02.py
526
3.8125
4
#튜플의 요소 추출하기 t1 = (1,2,'a','b') print(t1[0]) print(t1[1: ]) print(t1[:3]) #맨 처음부터 3미만까지 #튜플함수 #1.요소를 모두 더하는 함수 :sum() tup = (1,2,3,4,5) print(sum(tup)) # 2.튜플의 최대 최소값구하는 함수 : max(), min() print("최대값 :",max(tup)) print("최소값 :",min(tup)) # 3.요소의 개수를 모두 세는 함수 : count(요소) print(tup.count(1)) # 4.요소의 인덱스 번호르 구...
f9a0080cdfbc17309d3a144bab87306f48acfbd1
leesohyeon/Python_ac
/1105/forex/ForTest05.py
620
3.90625
4
# 구구단 출력 # # 1) 2단만 # for i in range(1,10): # print("2 * %d = %d"%(i,2*i)) # print() # #단수 입력받아 출력 # # gugudan=int(input("단수를 입력해주세요 : ")) # for i in range(1,gugudan+1): # for j in range(1,10): # print("%d * %d = %d"%(i,j,i*j)) # # #강사님 코드 # gugudan=int(input("단수를 입력해주세요 : ")) # for j in range(1,10): #...
57d37978eb9141b6e5999076892d60fc7d20644c
leesohyeon/Python_ac
/1111/classex/ClassTest04.py
570
3.78125
4
class Card: # 변수(속성,특징) width = 150 # 클래스 변수 height = 250 # shape = "" # number = 0 def __init__(self, shape, number): self.shape = shape # 인스턴스(객체) 변수 self.number = number c1 = Card("heart", 4) c2 = Card("spade", 7) # 클래스 변수 호출방법 # print(Card.width) # print(Car...
258e85f6a0ff4f135eda1da2f3d275f37d48aedf
leesohyeon/Python_ac
/1029/listex/ListTest04.py
355
3.796875
4
#리스트의 수정, 변경, 삭제 lst = [1,2,3] lst[2] = 10 print(lst) lst = [1,2,3,4,5] # lst[1] 첫번째의 요소를 'a','b','c'로 바꿔보세요 # case1 lst[1]=['a','b','c'] print(lst) #[1, ['a', 'b', 'c'], 3, 4, 5] =>리스트 자체가 들어감 # case2 lst[1:2]=['a','b','c'] print(lst) #[1, 'a', 'b', 'c', 3, 4, 5] 괄호 빠짐
8e2faaea8043ebe6e7ff7c578e9e76524484c2a6
leesohyeon/Python_ac
/classanswer/Exam06.py
980
3.609375
4
class Discount: def __init__(self, product): if product == "Clothing": self.dc = 0.6 elif product == "Cap": self.dc = 0.7 else: self.dc = 0.8 class Clothing(Discount): def __init__(self, pay): #정답 : 바로 아래 2줄 작성하기 self.pay = pay ...
9d46a40e614b4b3e908c5db6d9f4a630568ef5d4
leesohyeon/Python_ac
/classexam/Exam03.py
315
3.515625
4
# Exam03 class FirstClass: def setData(self, value): self.data = value def display(self): print(self.data) # 정답 # # x.setData("데이터") y.setData(3.14159) x.dispaly() y.dispaly() """ 데이터 3.14159 위의 내용이 출력될 수 있도록 코드를 완성해보세요. """
46b5fd1812dfc2369ea4c7253ddaf03352cc01e9
leesohyeon/Python_ac
/1105/tupleex/TupleTest05.py
1,107
3.5
4
""" """ def check(id, pw): accounts = [ ("kildong", "qwer1234"), ("dangoon", "garlic"), ("harrypotter", "malfoy"), ] for (dbid,dbpw) in accounts: if dbid == id: if dbpw==pw: return 1 else: return 0 return -1 """ ...
a6e69034367d91fbb55df80b9a003bd13bdcbdfc
leesohyeon/Python_ac
/1104/functionex/FunTest03.py
927
3.515625
4
''' 아이디 패스워드 전달받아 둘다 일치시 1리턴 아이디만 일치ㅣ 0리턴 아이디 불일치 -1리턴 ''' # result=0 # id=input("아이디를 입력해주세요 :") # pw=input("패스워드를 입력해주세요 :") # def id(dbid,dbpw): # if id==dbid and pw==dbpw: # result = 1 # elif id==dbid and pw!=dbpw: # result = 0 # elif id!=dbid: # result = -1 # num=id("thgus","123...
5b2ed97b63af68e139c1c4f9b4e2d741b6387cd3
Somanathpy/Build_real_Applications
/Python_Basics/building_programs/textpro.py
384
3.78125
4
'''total_message = '' while True: message = input("Say Something:") if message == '\end': break elif "who" in message or "why" in message or "how" in message or "what" in message: message = ' ' + message.title() + "?" else: message = ' ' + message.title() + "." ...
aab55777df8fa6ba9229c58a756c99580bf4975f
swiggins83/codeeval
/fbchal.py
973
4.03125
4
import string import operator import sys def findBeauty(pathname): """Find the maximum beauty of strings from a file.""" letters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] for s in open(pathname, 'r').readlines(): lettercount = {} ...
fe8b8a741c2d9034ee182d980f4547425ab5b93e
swiggins83/codeeval
/primepal.py
326
3.609375
4
import sys import math def main(): for i in range(1,1000): if str(1000-i)[0] is str(1000-i)[2] and isprime(1000-i): print 1000-i break def isprime(n): for i in range(2,n): if n % i is 0: return False return True if __name__ == "__main__": m...
95f1e5cae66526d4e40f470a3e82b8c78c212bf1
swiggins83/codeeval
/fizzbuzz.py
665
3.859375
4
import sys def fizzbuzz(pathname): """Replaces numbers in a string if it is divisible by params.""" for line in open(pathname, 'r').readlines(): split = str(line).split(" ") for i in range(1,int(split[2])+1): if (i % int(split[0]) is 0) and (i % int(split[1]) is 0): ...
8d2f0c63e465a18c202d1da147011b0f35aba02d
amateusz/Czekaj
/main2.py
8,592
3.53125
4
from PIL import Image, ImageTk import tkinter as tk from tkinter import filedialog from math import sqrt from random import random from colour import Color # Image 2 is on top of image 1. # IMAGE1_DIR = "X:/python/obrazy/1.jpg" # IMAGE2_DIR = "X:/python/obrazy/2.jpg" # Brush size in pixels. BRUSH = 45...
85220822c1d7bd977e64e7d6df73cb4b02755fdd
adityakangune/PICT-PPS-FE-Lab-Projects-Experiments-
/SCD(Smallest Common Divisor).py
199
3.625
4
x=int(input("Enter the number:")) y=int(input("Enter the number:")) l=[] for i in range(2,min(x,y)+1): if x%i==0 and y%i==0: l.append(i) print(l) print("GCD:",max(l)) print("SCD:",min(l))
80b9e552ce411eb7a1f7ca7fcbf21bb69e8a8208
adityakangune/PICT-PPS-FE-Lab-Projects-Experiments-
/Group B Extra 3 Binary.py
371
3.984375
4
''' Problem Statement:Write a Program in Python to input binary number from user and convert it into decimal number. ''' temp=0 count=0 b=int(input("Enter a binary Number:")) while(b>0): a=b%10 b=b//10 if(a==1): temp=temp+(2**count)*a count+=1 print(temp) if(a!=0 and a!=1): ...
c7698fb58ff087c1da49a7534ee5c58d791f56eb
adityakangune/PICT-PPS-FE-Lab-Projects-Experiments-
/Assignment 2 Operation On Numbers.py
537
4.09375
4
''' Write a Program in Python to accept N numbers from user. Compute and display maximum in list, minimum in list, sum and average of numbers. ''' n=int(input("Enter length of list:")) l=[] for i in range(n): e=int(input("Enter the element number:".format(i+1))) l.append(e) avg=sum(l)/n print("The li...
a0c3985fe9c84bcc230516e9ddbfae57e09092e6
Ch1pStar/Foobar
/queue/solution.py
285
3.5
4
def answer(start, length): end = length*length; i = 0 line = length group_start = start res = 0 while(line>0): i=0 while(i<line): res = res^(group_start+i) i+=1 group_start += length line-=1 return res print answer(17,4) print answer(0,3)
367a942e100bb56393329a36b01387872b8c7088
roshan2004/python-workshop
/distance.py
2,637
3.671875
4
import numpy as np import argparse import os # Write all functions definitions def calculate_distance(coords1, coords2): x_distance = coords1[0] - coords2[0] y_distance = coords1[1] - coords2[1] z_distance = coords1[2] - coords2[2] distance = np.sqrt(x_distance ** 2 + y_distance ** 2 + z_distance...
16d8dd34584e0b7bddc27bd9bddddbea2be24baf
fibeep/calculator
/hwk1.py
1,058
4.21875
4
#This code will find out how much money you make and evaluate whether you #are using your finances apropriately salary = int(input("How much money do you make? ")) spending = int (input("How much do you spend per month? ")) saving = salary - spending #This line will tell you if you are saving enough money to eventual...
8ba498b66d9a5599f11e4101c036fbfcc35cbc23
mike-sherman1/python-scripts
/quadratic-solver.py
787
3.90625
4
#This program solves and plots quadratic equations. import math import pylab as pylab while True: try: a = float(input("Enter a: ")) except EOFError: break b = float(input("Enter b: ")) c = float(input("Enter c: ")) if (b**2 - 4*a*c) < 0: print("no real solutions") ...
fc2c9c8a6c87498ee6a323eb66d106565ac3638e
vojtechruz/pyladies-homework
/04_rock_paper_scissors.py
1,120
3.953125
4
# -*- coding: UTF-8 -*- # Změň program Kámen, Nůžky, Papír tak, aby opakoval hru dokud uživatel nezadá "konec". tah_cloveka = '' while tah_cloveka != 'konec': tah_pocitace = 'kamen' tah_cloveka = input('kámen, nůžky, nebo papír? ') if tah_cloveka == 'kamen': if tah_pocitace == 'kamen': ...
a804cabc2f4919c8aeaac491b0d638142bac8de8
manassikri/AdventCode
/sol4_SecondPart.py
2,824
3.6875
4
file = open("temp3.txt", "r") #print(file.read()) arr = ["byr", "iyr" ,"eyr" ,"hgt" ,"hcl" ,"ecl" ,"pid" ,"cid"] credentials = {} count=0 ans=0 fl = 1 c=0 for line in file.readlines(): if line == '\n': #print("reached deadline") #print(count) fl=1 if count==8 or (count==7 and "cid" not i...
b86ee72843ccaec78b5d5ae29559152395a984c9
SpencerBeloin/Python-files
/sentinelloop.py
300
3.734375
4
# sentineloop.py def main(): sum =0.0 count = 0 x = eval(input("Enter a number (negative to quit) >> ")) while x >= 0: sum = sum + x count = count + 1 x = eval(input("Enter a number (negative to quit) >> ")) print("The average of the numbers is ", sum/count) main()
70d685a8de9f8222a7cbe41ea292812c76810e9e
SpencerBeloin/Python-files
/trig.py
376
3.921875
4
# function for testin trig in python import math def main(): print("Testing trig functions ") print() # if a and be are equal value should = math.sqrt(c)? # SUCCESS it does! a, b, c = eval(input(" please eneter coefficients a,b,c : ")) value=math.sqrt(c*math.cos(a)**2+c*math.sin(b)**2) pr...
7d090650fc7fc908e6a8914310b12878ce38dd80
SpencerBeloin/Python-files
/factorial.py
228
4.21875
4
#factorial.py #computes a factorial using reassignment of a variable def main(): n= eval(input("Please enter a whole number: ")) fact = 1 for factor in range(n,1,-1): fact = fact*factor print fact main()
02cf43e0fbc8f701a5c57a8f87ee32c6475469d0
mayad19-meet/meet2017y1lab4
/fruit_sorter.py
244
4.21875
4
new_fruit=input('what fruit am i storing?') if new_fruit=='apples': print('bin 1!') elif new_fruit=='oranges': print('bin 2!') elif new_fruit=='olives': print('bin 3!') else: print('error!! i do not recognize this fruit!')
0e4b133eba2337b2e30e389d1fe95606bf439233
annettemathew/rockpaperscissors
/rock_paper_scissors.py
2,038
4.1875
4
#Question 2 # Write a class called Rock_paper_scissors that implements the logic of # the game Rock-paper-scissors. For this game the user plays against the computer # for a certain number of rounds. Your class should have fields for how many rounds # there will be, the current round number, and the number of wins ...
c22af83365c93cb293f5f4c54ee7a0626771dd73
christophedlr-afpa/python-ex-saison8
/Scripts/8.7.py
1,808
3.953125
4
x: int = 0 y: int = 0 move: int = 0 checkerBoard: int = [[0 for i in range(8)] for j in range(8)] x = int(input("Indiquez une ligne où vous positionner : ")) y = int(input("Indiquez une colonne où vous positionner : ")) checkerBoard[x][y] = 1 if move == 0 and (x < 0 or x > 8) and (y < 0 or y > 8): print("Positio...
1314ada139ff8456fb57ceccf9404da78d50df0e
atulmkamble/100DaysOfCode
/Day 26 - Nato Phonetic Codes/main.py
593
3.96875
4
# Import required libraries import pandas as pd from art import logo def main(): print(logo) # Read the file df = pd.read_csv('nato_phonetic_alphabet.csv') # Create dictionary of letters and corresponding codes nato_dict = {row.letter: row.code for (index, row) in df.iterrows()} # Get the us...
50888ff04c2d2ad05058c3ff77a6a94a2cd93fcf
atulmkamble/100DaysOfCode
/Day 19 - Turtle Race/turtle_race.py
1,896
4.46875
4
""" This program implements a Turtle Race. Place your bet on a turtle and tune on to see who wins. """ # Import required modules from turtle import Turtle, Screen from random import randint from turtle_race_art import logo def main(): """ Creates turtles and puts them up for the race :return: nothing ...
d70fb4d40081bda2356d7f9909c5873a7ab3a126
atulmkamble/100DaysOfCode
/Day 21 - Snake Game (Part 2)/main.py
1,529
4.125
4
""" This program implements the complete snake game """ from turtle import Screen from time import sleep from snake import Snake from food import Food from scoreboard import Scoreboard def main(): # Setup the screen screen = Screen() screen.setup(width=600, height=600) screen.bgcolor('black') scr...
4bbc20f176f7f2f5bbe176e03b8f9ff3b3fef1f9
atulmkamble/100DaysOfCode
/Day 12 - Number Guessing Game/number_guessing_game.py
3,040
4.3125
4
""" This program implements a guessing game. User has to choose a level (easy/hard) and get some guesses. In those assigned guesses, user has to guess the number that the computer has randomly generated from 1 to 100. """ from random import randint from number_guessing_game_art import logo from time import perf_counte...
cec29c33017cd1b9398ea08710e6ff219a43933c
atulmkamble/100DaysOfCode
/Day 10 - Calculator/calculator.py
1,736
4.21875
4
""" This program implements the classic calculator functionality (Addition, Subtraction, Multiplication & Division) """ from calculator_art import logo def add(n1, n2): return n1 + n2 def subtract(n1, n2): return n1 - n2 def multiply(n1, n2): return n1 * n2 def divide(n1, n2): return n1 / n2 ...
02089de9852f240b5ff07e1ca47e8e41e19537c2
atulmkamble/100DaysOfCode
/Day 4 - Rock Paper Scissors/rock_paper_scissors.py
2,029
4.3125
4
""" This program is a game of rock, paper and scissors. You and the program compete in this game to emerge as a winner. The program is not aware of your choice and it's a fair game. Please follow the directions in the program. """ from random import randint from time import perf_counter from time import process_time ...
88d8b8b316fdf720e874b50d8a0c44995713a8a3
vholley/Algorithms-Python-Practice
/propositional_logic.py
10,285
3.953125
4
''' propositional_logic.py This program has functions for evaluating logical propositions and producing a truth table with given propositions. ''' import itertools from copy import copy ''' format_prop(prop) Returns the proposition, formatted in string form. Parameters: prop (list): proposition i...
f97594ad3514fa073068bc4f54194ab13abeaec3
duochen/Python-Kids
/Lecture06_Functions/Homework/rock-paper-scissors-game.py
891
4.15625
4
print("Welcome to the Rock Paper Scissors Game!") player_1 = "Duo" player_2 = "Mario" def compare(item_1, item_2): if item_1 == item_2: return("It's a tie!") elif item_1 == 'rock': if item_2 == 'scissors': return("Rock wins!") else: return("Paper wins!") elif...
0521148bcb7a77b349c2fb25dd0b084032cd7d17
anandmk10/Python-Basics
/for.py
160
3.71875
4
#! /usr/bin/python dict={"name":"asd","id":4} print(dict) z={(input("enter the first value")):int(input("enter the second value"))} dict.update(z) print(dict)
5b792ccd97f2e1fc45310dec59bae6e03ad9a2a6
anandmk10/Python-Basics
/dice.py
252
4
4
import random dice=['1','2','3','4','5','6'] u_inp=input("enter your number ") if ( u_inp<='6' and u_inp>='0'): if(u_inp == random.choice(dice)): print("Winner") else: print("Better luck next time") else: print("check your number",u_inp)
3c8d59d825fedfaee245bd7be915edf28ea6c7fe
AbhiroopC96/100DaysOfCode
/Day3-2.py
987
3.796875
4
exp=[2400,2000,1500,2000,1200] #for x in exp: # print(sum(x)) This does not work as int object is not iterable. total=0 for x in exp: total+=x print(total) exp=[2400,2000,1500,2000,1200] total=0 for i in range(len(exp)): print('Month',(i+1),'Expense',exp[i]) total+=exp[i] print('Total Expense: ',total...
c2abe9e5d0fce7f2cfbb6657e98349b4cfcbd591
JohannesHamann/freeCodeCamp
/Python for everybody/time_calculator/time_calculator.py
2,997
4.4375
4
def add_time(start, duration, day= None): """ Write a function named add_time that takes in two required parameters and one optional parameter: - a start time in the 12-hour clock format (ending in AM or PM) - a duration time that indicates the number of hours and minutes - (optional) a starting day...
a277979234ccb93df87bbb68fefe8b96fab279d0
joseph-zhang/P4What
/tf-learn/firstCNN_mnist_10.py
3,866
3.65625
4
#!usr/local/env python #!coding=utf-8 # fist step for CNN learning, a CNN-version mnist sovler import tensorflow as tf import numpy as np import matplotlib.pyplot as plt from tensorflow.examples.tutorials.mnist import input_data """ this procedure will download and read the mnist data set automatically training da...
6e8db6bd303152d658db33d4d3dffc83216ef726
joseph-zhang/P4What
/PfDA/py_review/thread_02.py
1,125
3.734375
4
#!usr/local/env python #coding=utf-8 # In previous file, a simple threading usage was shown # note that thread of python is limited because GIL lock # sub-thread has a same blcok of memory, so some clock mechanisms are imported # Exclusive lock! import time, threading A_SMALL_NUM = 10 A_BIG_NUM = 100 balance = 0 lock...
21710932610d9c368969c86ea9b1ddeabdbe195a
joseph-zhang/P4What
/tf-learn/firstNN_05.py
2,255
3.84375
4
#!usr/local/env python #!coding:utf-8 # here is just a beginner-NN implementation # Nework structure: input_layer_size = 1, hiddden_layer_size = 10, outpit_layer_size = 1 import matplotlib.pyplot as plt import tensorflow as tf import numpy as np # basic procedure for net construction def add_layer(inputs, in_size, out...
d558996c3f65d13be718d47b980f3122c40a564e
joseph-zhang/P4What
/tf-learn/regularization_15.py
2,757
3.53125
4
#!usr/local/env python #coding=utf-8 # here is an example about regularization method to prevent overfitting # collection structure in TF is also used # a basic NN structure is implemented, we use raw API to do this instead of using tf.layers.xx # to show the whole process better import tensorflow as tf import numpy as...
674e73fc3242f4a424af7c418d5d53b684bf2e10
leansabio/Tp1-Aspiradora
/aspiradora modelo.py
1,406
3.90625
4
#medio ambiente class Baldoza: #1 es sucia estado=1 class Aspiradora(Baldoza): #estado=1 posicion="izquierda" def __init__(self, baldoza): self.baldozaactual=baldoza def limpiar(self): self.baldozaactual.estado=0 def izquierda(self, baldoza): ...
24a362c0b913d89691f7c7e768819c89f05d4bd2
ShamsZayan/HarryPotterBattle
/SHAMS_HarryPotterBattle/main.py
3,854
3.921875
4
from Harry import Harry from Voldemort import Voldemort if __name__ == '__main__': # creating objects from Harry and Voldemort subclasses harry = Harry() voldemort = Voldemort() # checking if their health greater than 0 or not to know if the war end or not while harry.get_health() > 0 and...
24cd7e7fe58706da75445535fa5df34d525ef2d1
james-w-balcomb/website-scraper-python
/website_scraper_python/ats_utilities/ats_numbers.py
3,429
4.15625
4
import math def get_digit_count(number): """ https://stackoverflow.com/questions/2189800/length-of-an-integer-in-python # Using log10 is a mathematician's solution # Using len(str()) is a programmer's solution # The mathematician's solution is O(1) [NOTE: Actually not O(1)?] # The programmer'...
e4fc4b53e49fb44be9d4f1a0879948264fbf635d
prasannarajaram/python_programs
/palindrome.py
340
4.6875
5
# Get an input string and verify if it is a palindrome or not # To make this a little more challenging: # - Take a text input file and search for palindrome words # - Print if any word is found. text = raw_input("Enter the string: ") reverse = text[::-1] if (text == reverse): print ("Palindrome") else: print...
f09e7535bec676026ef5090ff77098e8c2c07cef
bhuanand/practice
/Euler5.py
724
3.734375
4
import sys import argparse def gcd(a, b): if b == 0: return a else: return gcd(b, a % b) def lcm(a, b): return (a * b) // gcd(a, b) if __name__ == '__main__': parser = argparse.ArgumentParser(prog='Euler5.py') parser.add_argument('--start', type=int, default=1, help='List of multi...
8ab9a0d20936a7bf34d07eb5cf0d661aed3659ef
trgomes/estrutura-de-dados
/teste2.py
1,823
3.5
4
from collections import Counter def quadrados_menores(n): quadrados = [] for q in range(1, n + 1): if q ** 2 <= n and q ** 2 not in quadrados: quadrados.append(q ** 2) else: return quadrados return quadrados def soma_quadrados(n): if n == 0: return [0]...
33565088ea7a8dced6e7474507b09b3f94999bbe
mahmoudyaseen/GenaticsCoursework
/CurveFitter vectorized solu/CurveFitter.py
8,103
3.671875
4
# -*- coding: utf-8 -*- """ Created on Fri Nov 1 16:37:40 2019 @author: MahmoudYassen """ import numpy as np import matplotlib.pyplot as plt def fitnessFunction(individuals , X , Y): ''' take population , X , Y and return error and predicted Y for each chromosome ''' #individuals is array of sh...
9c44966369a1273f2a488a596eb8fb09336c5f16
paulacaicedo/TallerAlgoritmos
/ejercicio33.py
325
3.9375
4
#EJERCICIO 33 numero_1=int(input("Introduzca un primer valor: ")) numero_2=int(input("Introduzca un segundo valor: ")) if numero_1>numero_2: print("El numero mayor es: ",numero_1) if numero_1==numero_2: print("Los numeros son iguales") else: numero_1<numero_2 print("El numero mayor es: ",nume...
ed449bf457721fcd8232038dbfaf5f6a71d682f0
paulacaicedo/TallerAlgoritmos
/ejercicio19.py
409
3.890625
4
#EJERCICIO 19 import math x1=float(input("Introduzca el valor de x1: ")) x2=float(input("Introduzca el valor de x2: ")) y1=float(input("Introduzca el valor de y1: ")) y2=float(input("Introduzca el valor de y2: ")) if x1>=0 and x2>=0 and y1>=0 and y2>=0: d=math.sqrt(pow(x1-x2,2)+pow(y1-y2,2)) print("La dista...
710a9c325c13c809f149076971a947961aa85dcb
paulacaicedo/TallerAlgoritmos
/ejercicio23.py
201
3.75
4
#EJERCICIO 23 segundos=int(input("Introduzca los segundos: ")) minutos=int(segundos/60) minu=int(minutos%60) seg=int(segundos%60) horas=int(minutos/60) print(horas," h ",minutos," min ",seg," seg")
ecb07d698171050181118c045cd1e96db4af0c10
paulacaicedo/TallerAlgoritmos
/ejercicio62.py
276
3.8125
4
#EJERCICIO 62 suma=0 n=int(input("Ingrese un numero: ")) m=int(input("Ingrese un numero mayor al anterior: ")) if n>m: print("SE LE PIDIO QUE EL SEGUNDO NUMERO FUERA MAYOR!!") else: while n<=m: print("Numero Natural: ",n) suma=suma+n n=n+1 print("La suma es: ",suma)
77a615d0f8af2248c28cf857192f3185b1b85808
paulacaicedo/TallerAlgoritmos
/ejercicio3.py
129
3.921875
4
#EJERCICIO 3 #CUADRADO DE UN NUMERO x=int(input("Introduzca un numero: ")) r=pow(x,2) print("El cuadradado de: ",x," es ",r)
f993283ec857e4843cc6ea403a19b95669c2d437
paulacaicedo/TallerAlgoritmos
/ejercicio35.py
800
4.125
4
#EJERCICIO 35 numero_1=int(input("Introduzca un primer valor: ")) numero_2=int(input("Introduzca un segundo valor: ")) numero_3=int(input("Introduzca un tercer valor: ")) #NUMERO MAYOR if numero_1>numero_2 and numero_1>numero_3: print("El numero mayor es: ",numero_1) if numero_2>numero_1 and numero_2>numero_...
c4c2e885326f0cd26ff36e2ed91203f8827d52a2
paulacaicedo/TallerAlgoritmos
/ejercicio1.py
177
3.75
4
#EJERCICIO1 #CONCATENAR DOS STRINGS letra_1=input("Introduce la primera palabra: ") letra_2=input("Introduce la segunda palabra: ") print(str(letra_1) + " " + str(letra_2))
83521ef239ce52fa8282a630f024801b5cb99565
paulacaicedo/TallerAlgoritmos
/ejercicio13.py
381
3.953125
4
#EJERCICIO 13 variable_a=float(input("Introduzca el primer valor: ")) variable_b=float(input("Introduzca el segundo valor: ")) print("El valor de a es: ",variable_a) print("El valor de b es: ",variable_b) variable_c=variable_a variable_a=variable_b variable_b=variable_c print("Valores cambiados") print("El valor d...
b7e17754967457ca944c63a5bb742ddf8b08abf2
paulacaicedo/TallerAlgoritmos
/ejercicio58.py
81
3.6875
4
#EJERCICIO 58 x=0 while x<=20: if x%2==0: print("Numeros pares: ",x) x=x+1
87134d483c92601572d4a5278e079a2fd1b97609
elizabethorysyuk/my_python
/get_parity.py
457
3.9375
4
num=int(input("Введите целое число:\n")) def zel(num): return round(num)-num def zel1(num): return 1-abs(zel(num)) num1=print(zel1(num)) def fun1(num1,m=2): return (num1)%m num2=print(fun1(num1)) if num1==1 and num2==0: print ("Число четное") elif num1==1 and num2>0: print ("Число нечетное") elif num1==1 and n...
6d83d86b6dc5575c14b08f90519198848bec0782
akrizanic/advent17
/day9/puzzle1and2.py
663
3.546875
4
import sys file_name = sys.argv[1] input_file = open(file_name, "r") input_str = input_file.readline() i = 0 lvl = 0 lvl_sum = 0 garbage = False garbage_chars = 0 while i < len(input_str): char = input_str[i] i += 1 if char == "!": i += 1 continue if not garbage and char == "<": ...
87744f5b154e70319279784937d843b7a3622e14
akrizanic/advent17
/day4/puzzle2.py
1,116
3.796875
4
inputFile = open("i2.txt", "r") # also returns true if same word def is_anagram(w1, w2): if len(w1) != len(w2): return False if w1 == w2: return True to_match = len(w1) matched = [] for i in range(0, to_match): for j in range(0, to_match): if j not in matched: ...
c599b4c48939fc98c8157d6f2bef84fd197e1b4e
evanmiracle/python
/ex11.py
412
3.953125
4
print("How old are you?", end=' ') age = input() print("How tall are you?", end=' ') height = input() print("How much do you weigh?", end=' ') weight = input() print(f"So, you're {age} old, {height} tall and {weight} heavy.") print("Let's play a number guessing game . . .") print("Guess a number . . . (type...
9fbf936bdf5c6f4798aa4ce97146394de3dadc40
evanmiracle/python
/ex5.py
1,230
4.15625
4
my_name = 'Evan Miracle' my_age = 40 #comment my_height = 72 #inches my_weight = 160 # lbs my_eyes = 'brown' my_teeth = 'white' my_hair = 'brown' # this works in python 3.51 print("Test %s" % my_name) # the code below only works in 3.6 or later print(f'Lets talk about {my_name}.') print(f"He's {my_heigh...
9d691101c22dea8f9319c60ded6da8af0fc6aae8
evanmiracle/python
/ex15.py
490
4.0625
4
from sys import argv script, filename = argv txt = open(filename) # open command takes a parameter and returns a variable value (opens the file you specify) print(f"Here's your file {filename}:") print(txt.read()) # call the read function on txt. Give a file a command with . name of command and any par...
988bfca3161e32cfa436ff45a54d834d2585678b
aeronsimshihwin/CS50x-Introduction-to-Computer-Science
/pset6/greedy.py
1,046
4.03125
4
def main(): while True: #ask user how much x, change, is owed #assumption made: input, x will be in $ and cents, not cents only x=float(input('Enter how much change is owed: $')) if x<0: print("Monetary change should be postive. Try again.") x=float(input('Ent...
c1825da2c57e017dd0ae2fb548ee10abe057dd3b
SilversRL-Yuan/CC150_Python
/Chapter1/1.6.py
536
3.671875
4
#1.6 N*N matrix rotate by 90 degrees #Not in place def rotate_90degree(matrix1): N = len(matrix1) newmax = [[0 for j in range(0,N)] for i in range(0,N)] for i in range(0,N): for j in range(0,N): newmax[j][N-i-1] = matrix1[i][j] return newmax l = [[1,2,3], [4,5,6], [7,8,9]] print(rotate_90degree(l)) #In place ...
431dfcd20a64260039c8fcaa3f6b408902db9f93
SilversRL-Yuan/CC150_Python
/Chapter2/2.2.py
674
4.0625
4
#2.2 Find the nth from the end of a singly linkedlist. #eg. 8->10->5->7->2->1->5->4->10->10 then the result is 7th to last node is 7 import linkedlist l1 = linkedlist.LinkedList() print(l1) l1.AddNode(3) l1.AddNode(7) l1.AddNode(3) l1.AddNode(5) print(l1) l1.InsertNode(3, 2) print(l1) def Fnd_end_nth(lists,n): if n <...
3e2a322101147dcedbc46fb319d4c103b46976e9
jjunio01/competicao-uri
/1004.py
252
3.765625
4
''' Produto Simples Ler dois valores inteiros, calcular o produto entre eles e armazenar na variável PROD. Formato do resultado(saída) Ex: PROD = 50 ''' A = int(input()) B = int(input()) PROD = A * B print('PROD = {}'.format(PROD))
cf1ff8887579be328667dbb22d7f98b61a7225c2
arty-hlr/CTF-writeups
/2019/adventofcode/4/solve1.py
545
3.53125
4
start = 152085 end = 670283 def not_decreasing(digits): for i in range(len(digits)-1): if digits[i+1] < digits[i]: return False return True def two_adjacent(digits): ok = False for i in range(len(digits)-1): if digits[i+1] == digits[i]: ok = True return ok ...
c7be2766e3c32eef6d6588d2baab991f4a51ce22
arty-hlr/CTF-writeups
/2019/evlz/bad_compression/decompress.py
389
3.703125
4
import binascii flag = "evlz" b = "" for i in range(len(flag)): b += bin(ord(flag[i]))[2:].zfill(8) def printable_flag(string): hexstring = '' for i in range(len(string)//8): hexstring += hex(int(string[i*8:i*8+8], 2))[2:] print(hexstring) flag = binascii.unhexlify(hexstring).decode() ...
edd6e9612875d54a40c034fd470731137f59bf2b
AparnaVikraman/MySolutions
/trie.py
2,301
4
4
class TrieNode(): def __init__(self): self.children = [None]*26 self.isLeaf = False class Trie(): def __init__(self): self.root = self.getNode() def getNode(self): return TrieNode() def get_index(self, char): return ord(char) - ord('a') def insert(self, k...
b27f8ad87ed30cf438ff07f71645a7df78a54221
AparnaVikraman/MySolutions
/maximum_element.py
1,300
3.859375
4
class StackNode(): def __init__(self, val, curmax=0): self.val = val self.curmax = curmax class Stack(): def __init__(self): self.top = -1 self.node = [] self.max = 0 def isempty(self): return self.top == -1 def push(self, val): self.top += 1 ...
d83eb518707989d23ee0989809ce3c52bab901b3
AparnaVikraman/MySolutions
/list.py
336
3.6875
4
class Node: def __init__(self, data, next_node): self.data = data self.next_node = next_node class LinkedList: def __init__(self, head=None): self.head = None def insert_data(self, data): node = Node(data, None) if self.head is None: self.head = node ...
5204daaef67721495cd2bf137d21ff70c374b393
adeshshukla/python_tutorial
/loop_for.py
719
4.15625
4
print() print('--------- Nested for loops---------') for i in range(1,6): for j in range(1,i+1): print(j, end=' ') # to print on the same line with space. Default it prints on next line. #print('\t') print() print('\n') # to print two lines. print('-------- For loop In a tuple with break ----------------') # f...
e4a005fc50a5231e30967e0bf1ddc6912c02ec37
DasBehemoth/OrdnerNr2
/Class10/example5.py
639
3.859375
4
def square_numbers(x): # mit den drei anfuehrungszeichen kann man definition dazu machen, wird dann angezeigt, stichwoerter muessen so sein """ :param x: number to square :type x: int :return: :rtype: int or float """ return x**2 def cube_numbers(x): return x**3 def check_square_numbe...
cae21ceef8fb032447e7c75258290ba6038ad295
DasBehemoth/OrdnerNr2
/Class10/example4 test.py
624
3.578125
4
import example2 as calk # man kann es umbenennen def check_addition(): assert calk.addition (10,20) == 30 # assert checkt ob das das was dannach kommt wahr ist # TEST DRIVEN DEVELOPMENT (TDD) nennt man dieses testen assert calk.addition (10, -10) == 0 def check_subtract(): assert calk.subtrahieren(2,3) ==...
754dbceb038cd836ba4138178fbe228ac02d7792
DasBehemoth/OrdnerNr2
/Class11/11.2.Vehicles.py
2,483
3.984375
4
class Vehicle: def __init__(self, brand, model, kilometers_done): self.brand = brand self.model = model self.kilometers_done = kilometers_done def list_vehicles(self): print "" print self.brand + self.model + " (%s)"%self.kilometers_done print "" ...
c51e7996bd170e4380e19de0e0c6cd9302611d41
pankon/ml
/tools.py
4,370
3.875
4
# basic tools for doing ml class TwoDArray(object): # yes, I know everything exists in numpy already. """A basic 2d array >>> arr = TwoDArray(2, 2) >>> print arr # doctest: +NORMALIZE_WHITESPACE [ [0, 0], [0, 0] ] >>> arr2 = TwoDArray(2, 2, [[1, 1], [2, 3]]) >>> print arr2 #...
003efada87d68cf4a61bf8829b64c9596bd97129
RounakChatterjee/SEM2_Assignment4
/Codes/Unif_dist_Py.py
1,009
3.9375
4
''' CREATING UNIFORM DISTRIBUTION WITH PYTHON ======================================================================= Author: Rounak Chatterjee Date : 25/05/2020 ======================================================================= This Program creates a uniform distribution using numpy's random number genrator...
362ad9bee2489d2197d33680768f7089ef13eaf3
austindunn/mumt-502
/create_spectrograms/create_spectrograms.py
4,707
3.6875
4
""" This script creates a bunch of square spectrograms from short audio clips. Usage: python create_spectrograms.py [class dir] [destination] [frame length] [image size] [amp threshold] where... [class dir] is the name of the directory containing directories named for e...
33280c59c5a2c573134e0833886bb92b123d348f
GeorgeIulian23/mid_exam
/mid_exam2.py
1,426
4.0625
4
lista_nume = ['Maria', 'Irina', 'Claudiu', 'Ionut', 'Irina', 'Matei', 'Irina', 'Maria', 'Claudiu'] #1. Sortati lista dupa nume #2. Determinati numarul de aparitii al fiecarui nume #3. Listati numele care apare de cele mai multe ori in lista initiala. #4. Listati numele care apare de cele mai putine ori in lista init...
6c7dbcc05d70f9de2ae0931fb9b08b0fccaa4199
amSahar/python
/lesson 16.py
268
3.65625
4
tuple_1=('python', 'بايثون', 'java','3.14') ''' tuple_1=('python', 'java', 'c++') tuple_2=('python', ) tuple_3=() print(tuple_1) print(tuple_2) print(tuple_3) print(tuple_1[1]) for x in tuple_1: print(x) del tuple_1 print(tuple_1) ''' print(tuple_1[0:4])
e4d0fc3a5f1937a65cfe5b1f713b557b2debb279
amSahar/python
/lesson 11.py
443
4.09375
4
""" x=10 print(x>5 or x<9) x=["sky","star"] y=["sky","star"] z=y print (x is not y) #true print (y is not z) #false print (x is not z) #true print (x != y) #false print (x != z) #false print (z != y) #false """ x=["sun","moon","star"] y=["sky","cloud","rainbow","star"] print ("sky" in y) print ("sky" in x) ...
b9b6f6b806818098ed6d50bcd85ae6a7787fc69f
amSahar/python
/lesson 35.py
110
3.734375
4
''' x=lambda a : a+10 print(x(5)) x=lambda a,b:a*b print(x(5,6)) ''' x=lambda a,b,c:a+b+c print (x(5,6,2))
ca0e358ea678b2c375709e2efb286194b58cc697
Annie677/me
/week3/exercise3.py
2,483
4.40625
4
"""Week 3, Exercise 3. Steps on the way to making your own guessing game. """ import random def not_number_rejector(message): while True: try: your_input = int(input(message)) print("Thank you, {} is a number.".format(your_input)) return your_input except: ...
71048b20ae914d974cbc1ce65a2c7b0c3ed69a3c
RamuSannanagari/python_practice_files
/Exception Handling/EXCEPTION_HANDLING1.py
664
4
4
# -*- coding: utf-8 -*- """ Created on Fri Jan 19 18:48:28 2018 @author: abhi """ import sys class Numericvalid(Exception): def __str__(self): return "Please enter Values greater than 100" try: n1=input("Enter a N1 number : ") n2=input("Enter a N2 number : ") if int(n1)...
e4800e163a275f87499fa57da7cb05ebed0a1c5b
RamuSannanagari/python_practice_files
/functions/Generators Example2.py
296
3.71875
4
# -*- coding: utf-8 -*- """ Created on Tue Dec 5 06:25:06 2017 @author: abhi """ def gen(): for i in range(10): X = yield i print(X) G =gen() #print(next(G)) #G.send(78) #G.send(88) print(next(G)) print(next(G)) print(next(G))
9af7ea22dd7278d1c21dfd3a7228298e490eb5b6
RamuSannanagari/python_practice_files
/functions/lambda_ex3.py
235
3.59375
4
# -*- coding: utf-8 -*- """ Created on Mon Dec 18 12:10:00 2017 @author: abhi """ def f(n1): return lambda n1:n1+n1 x=f(4) print(x(4)) def f1(n1): def f2(n2): return n1+n2 x=f1(4) print(x)
d067919826f09749a04d369c33e3aea9d1146496
AbdullahElagha/fakeTweeter
/Programs/fakeTweeter/generateTweetBody.py
576
3.703125
4
from __future__ import print_function import os, sys from PIL import Image, ImageOps, ImageDraw, ImageFont def generateTweetBody(): textInput = input("Enter the text you wish to display on the tweet") print(textInput) tweetBody = Image.open("blankBodyTweet.jpg") # set the font and size fnt = I...
57b7548fe903112716a1d603959df502b7454503
craignicholson/P2-1
/gradientdescent.py
4,384
4.40625
4
# -*- coding: utf-8 -*- """ Spyder Editor """ import numpy as np import pandas as pd from sklearn.linear_model import SGDRegressor """ In this question, you need to: 1) Implement the linear_regression() procedure using gradient descent. You can use the SGDRegressor class from sklearn, since this class uses gradie...
479f6b16c802f72487faadb6555b584debb9d4ea
pitanshu/python_programs
/lists_program/count_of_elements_length_gr2_first_character_eq_last_character.py
209
3.5625
4
# -*- coding: utf-8 -*- """ Created on Tue Nov 3 11:41:16 2020 @author: pitan """ list=['abc','aba','121','1234'] cntr=0 for i in list: if((len(i)>=2)and(i[0]==i[-1])): cntr=cntr+1 print(cntr)
2b8af562a20f45b02660c503a9a1264d3905a469
aryanjuyal37/E-Commerce
/Part_1.py
119
3.65625
4
x=input("Enter price of 1st item- ") y=input("Enter price of 2nd item- ") add= int(x)+int(y) tax=add*0.1 print(add+tax)
10054b21be49bc24ea3b3772c97c116bf425533b
L51332/Project-Euler
/2 - Even Fibonacci numbers.py
854
4.125
4
''' Problem 2 Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued...
c95785e7ba031426688407b6ff81e6f9bb8730d5
MackMarcos/CursoEmVideo-ExerciciosPython
/Exercicios-Python/desafio30.py
209
4.09375
4
# Crie um programa que leia um numero inteiro e mostre se ele é par ou impar numero = int(input('Digite um numero: ')) if numero%2 == 0: print(f'Este numero é par!') else: print(f'Numero impar!')
3da543385ebf63ce7a85c2157fdfbb7cedfc0a2c
toshiro10/BigData
/hadoop/src/element_by_row/reducer_0.py
1,151
3.640625
4
#!/usr/bin/env python3 import sys nb_blocks = 2 def join(elements_L, elements_R): if len(elements_L) > 0 and len(elements_R) > 0: for el_l in elements_L: print('{}\t{}'.format(el_l, elements_R)) #on fabrique les lignes et colonnes current_index = 0 index = 0 elements_L = [] eleme...