blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
6f7f1896166d6259b80ff6a70dc193e1ac68a207
vrtineu/learning-python
/usando_modulos/manipulando_textos/ex027.py
258
4.03125
4
# Lê o nome completo de uma pessoa e mostra o primeiro e o último nome separadamente. n = str(input('Digite seu nome completo: ')).strip() nome = n.split() print('Seu primeiro nome é {} e o seu último nome é {}.'.format(nome[0], nome[len(nome) - 1]))
cde4215bd18527f9e8def2f0659ecdb8dda5947e
vrtineu/learning-python
/modulos/ex109/ex109.py
551
3.84375
4
# Modifique as funçoes que foram criadas no desafio 107 para que elas aceitem um parametro a mais, informando se o valor retornado por elas vai ser ou nao formatado pela funçao moeda(), desenvolvida no desafio 108. import moeda p = float(input('Digite o preço: R$')) print(f'A metade de {moeda.moeda(p)} é {moeda.metade...
f9c039ffaff77743d61918e60c2a8c80cb6f73db
vrtineu/learning-python
/lacos_de_repeticao/for/ex047.py
258
3.96875
4
# Crie um programa que mostre na tela que mostre todos os números pares que estão no intervalo entre 1 e 50. print('Vou mostrar na tela os números pares de 1 a 50!') for c in range(2, 51, 2): if c % 2 == 0: print(c, end=' ') print('Pronto!')
c8c978da8f52e87c68c957cab8c79bb028cb3747
vrtineu/learning-python
/funcoes/ex097.py
403
4.125
4
# Faça um programa que tenha uma função chamada escreva(), que receba um texto qualquer como parametro e mostre uma mensagem com tamanho adaptável. # Ex: input escreva('Olá, Mundo!') # output: # ------------------ # Olá, Mundo! # ------------------ def escreva(txt): tam = len(txt) + 4 print(f"{...
bae66e7d3100380949014c290d7975673b73034e
vrtineu/learning-python
/lacos_de_repeticao/for/ex051.py
401
3.921875
4
# Desenvolva um programa que leia o primeiro termo e a razão de uma Progressão Aritmética. No final, mostre os 10 primeiros termos dessa progressão. primeiro = int(input('Digite o primeiro termo da PA: ')) razão = int(input('Digite a razão da PA: ')) décimo = primeiro + (10 - 1) * razão for c in range(primeiro, décimo...
600821c12e8f3fb2fe9ede8224120803859eda7c
hardhary/PythonByExample
/Challenge_044.py
547
4.15625
4
# 044 Ask how many people the user wants to invite to a party. # If they enter a number below 10, ask for the names and after each name display “[name] has been invited”. # If they enter a number which is 10 or higher, display the message “Too many people”. def inviteparty(): number = int(input("How many persons ...
8251bf36e37c6d3c8da5995e727671bb2f198333
hardhary/PythonByExample
/Challenge_072.py
425
4.40625
4
#072 Create a list of six school subjects. Ask the user which of these subjects they don’t like. #Delete the subject they have chosen from the list before you display the list again. def subjects(): subjects = ['Mathematics','Spanish','Art','Geography','Music','Natural History'] print(subjects) answer = i...
71eda5f98f7def3ce5b40189c7e23098c32fb391
hardhary/PythonByExample
/Challenge_144.py
522
3.875
4
#Challenge144 database import sqlite3 file = open("BookList.txt","w") with sqlite3.connect("BookInfo.db") as db: cursor = db.cursor() cursor.execute("SELECT Name from Authors") for x in cursor.fetchall(): print(x) print() selectauthor = input("Enter an author's name: ") print() cursor.execute("SELECT * FRO...
15eb5cadccb05aebfecff83b2784bae7f5649b4f
hardhary/PythonByExample
/Challenge_074.py
470
4.125
4
#074 Enter a list of ten colours. Ask the user for a starting number between 0 and 4 and an end number between 5 and 9. #Display the list for those colours between the start and end numbers the user input. def colors(): colors = ['blue','yellow','green','purple','gray','balck','white','gray','red','orange'] s...
0b3f2803657917f1e47ba03e426bd0dc93489c04
hardhary/PythonByExample
/Challenge 001.py
217
4.375
4
#001 Ask for the user’s first name and display the output message Hello [First Name] def firstName(): FirstName = input("Enter your First Name: ") print("The answer is " + FirstName) firstName()
f7022f98bbf162f9e083567c438d9cd8446d12e4
hardhary/PythonByExample
/Challenge_026.py
647
4.3125
4
# 026 Pig Latin takes the first consonant of a word, moves it to the end of the word and adds on an “ay”. # If a word begins with a vowel you just add “way” to the end. For example, pig becomes igpay, banana becomes ananabay, and aadvark becomes aadvarkway. # Create a program that will ask the user to enter a word and ...
35af5899b370bf099dcf2f4021d0501456409319
hardhary/PythonByExample
/Challenge_034.py
868
4.40625
4
# 034 Display the following message: # If the user enters 1, then it should ask them for the length of one of its sides and display the area. If they select 2, it should ask for the base and height of the triangle and display the area. # If they type in anything else, it should give them a suitable error message. def ...
1b77b2abe756c691dec917140927d346b15f2a39
hardhary/PythonByExample
/Challenge_047.py
640
4.3125
4
#047 Ask the user to enter a number and then enter another number. #Add these two numbers together and then ask if they want to add another number. #If they enter “y", ask them to enter another number and keep adding numbers until they do not answer “y”. #Once the loop has stopped, display the total. def addingnumbers...
795949a87259bbf8b6871eb8aa5208f40524790e
hardhary/PythonByExample
/Challenge_135.py
785
4.21875
4
#Create a simple program that shows a drop-down list containing several colours and a Click Me button. #When the user selects a colour from the list and clicks the button it should change the background of the window to that colour. #For an extra challenge, try to avoid using an if statement to do this. from tkinter i...
4de4af46b7d72b9d1b5646c6c8e6360db446322e
hardhary/PythonByExample
/Challenge_053.py
188
3.90625
4
#053 Display a random fruit from a list of five fruits. import random def fruits(): fruits = ["apple","bannana","grapes","orange","strawberry"] print(random.choice(fruits)) fruits()
d60fc7a91fd69f504945d75bb48955e89798acda
hardhary/PythonByExample
/Challenge_064.py
451
4.0625
4
#064 Draw a five-pointed star. import turtle def star(): turtle.shape("turtle") for i in range(0,1): turtle.forward(200) for i in range(0,1): turtle.right(140) turtle.forward(200) turtle.right(140) turtle.forward(200) turtle.right(14...
22954d314b50c6792a861a795ae33cf4f940eba1
hardhary/PythonByExample
/Challenge_008.py
340
4.21875
4
# 008 Ask for the total price of the bill, then ask how many diners there are. Divide the total bill by the number of diners and # show how much each person must pay. def totalbill(): totalbill = int(input("What is the total bill?: ")) diners = int(input ("How many diners are?: ")) return totalbill/diners ...
397380605cacc865d715997c86cdc1768f92f4ca
hardhary/PythonByExample
/Challenge_090.py
620
4.3125
4
#090 Ask the user to enter numbers. If they enter a number between 10 and 20, save it in the array, otherwise display the message “Outside the range”. #Once five numbers have been successfully added, display the message “Thank you” and display the array with each item shown on a separate line. from array import * def...
d9739aa69a5e9e1e0619a3055c0245743b09d84c
hardhary/PythonByExample
/Challenge_023.py
582
4.375
4
# 023 Ask the user to type in the first line of a nursery rhyme and display the length of the string. # Ask for a starting number and an ending number and then display just that section of the text (remember Python starts counting from 0 and not 1). def nurseryrhyme(): phrase = input("Enter the first line of nurser...
bf8da9c82410dfc3aab3c213f4fe142d7beec61e
hardhary/PythonByExample
/Challenge_028.py
219
4.0625
4
# 028 Update program 027 so that it will display the answer to two decimal places. def multiplyby2(): number = float(input("Enter a number whit bunch of Decimals: ")) print (round(number*2,2)) multiplyby2()
c108ad3c85c040f3849bdea1f5a57ca45aa09f09
hardhary/PythonByExample
/Challenge_110.py
605
4.40625
4
#110 Using the Names.txt file you created earlier, display the list of names in Python. #Ask the user to type in one of the names and then save all the names except the #one they entered into a new file called Names2.txt. def openfile(): names = [] file = open('Names.txt','r') for data in file.readli...
e64f67fbc5472bce35080efffa9b32055cadb7ad
hardhary/PythonByExample
/Challenge_066.py
327
4.09375
4
# 066 Draw an octagon that uses a different colour (randomly selected from a list of six possible colours) for each line. import turtle import random colors = ['red','green','gray','blue','yellow'] for i in range(0,8): turtle.color(random.choice(colors)) turtle.forward(50) turtle.right(45) turtle.exitonc...
fbd757f2ee3aa3c398eb4f0af52ea4e7fbb8e470
winstonplaysfetch/binf2111-woo-python
/Final Question4.py
743
4.09375
4
#! /usr/bin/env python #Write a script that takes a protein sequence as raw input and calculates its molecular weight input = "AMQQQ" #Create a dict from file that contains amino acids as keys and their molecular weights as values. weightsdict = {} with open("aamw.txt") as file: for line in file: if line....
0649c6c7ae52b0a2e1c0aee358ec5d1bd3165bc9
winstonplaysfetch/binf2111-woo-python
/reverseDNA.py
432
4.375
4
#!usr/bin/env python #Get a DNA sequence from the user print("This script will transcribe your DNA sequence") userdna = raw_input("Enter DNA sequence: ") #Replace A with T newdna= userdna.replace("A","%temp%").replace("T","A").replace("%temp%","T") #Replace G with C transcripteddna = newdna.replace("G","%temp%").repl...
3ce84aff2485ba4df87493836716c7dd06055cb2
avinash2fly/Machine-Learning-A-Z
/Part 1 - Data Preprocessing/data_preprocessing_template_final.py
2,533
3.875
4
# Data Preprocessing Template # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset------------------- dataset = pd.read_csv('Data.csv') # take all the lines and except the last columns. X = dataset.iloc[:, :-1].values # take all the lines/rows and o...
baecbd435f16d0ac63cc6cf409df86dcc2c38ed2
EtoKazuki/python_practice
/ex10.py
663
3.890625
4
year = int(input("年>")) month = int(input("月>")) day = int(input("日>")) weekday = (year + (year // 4) - (year // 100) + (year // 400) + ((13*month+8) // 5) + day) % 7 if weekday == 0: weekday = "日曜日" elif weekday == 1: weekday = "月曜日" elif weekday == 2: weekday = "火曜日" elif weekday == 3: weekday = "水曜日"...
24598df012fd93695cb2aacab9a9293f49ac622d
SaadTalaat/Algorithms-bag
/Multi-Paradigm/RB2Tree.py
3,052
3.65625
4
from Queue import * RED = 'red' BLACK = 'black' class BST(): __root = None class Node(): __value = None __key = None __left = None __right = None __color = None def getRight(self): return self.__right def setRight(self, node): assert node != None self.__right = node def getLeft(self): ret...
854ea0f27dc3e0b35d55c05249fa7a284a383ab7
SaadTalaat/Algorithms-bag
/Multi-Paradigm/LinkedList.py
3,091
3.8125
4
''' Created on Mar 27, 2011 @author: saad ''' class LinkedList(): class LinkedListElement(): __value = None __prev = None __next = None def __init__(self,value): self.__value = value def setNext(self,next): self.__next = next ...
5596d20faa126a06cbf3a4c816bcded3be8d3f9b
SaadTalaat/Algorithms-bag
/Multi-Paradigm/graphs/Graph/Path.py
3,102
3.53125
4
from Graph import Graph from Queue import Queue import random class Path(): # Generic data structure __graph = None __edgeTo = [] __oldVertices = [] # depth first execlusive __visited = [] __origin = None def __init__(self, graph, vertex): if not isinstance(graph, Graph): return None if graph.getIndex(v...
fe73c2bddd837483af9d114c2bb9793ffa0dc533
jamarrhill/Assignment-6.b
/add_surname.py
540
3.96875
4
# Name: Jamar Hill # Date: 11/3/2020 # Description: Assignment 6.b def add_surname(first_names_lst): """Adds Kardashian to names with K in the 0 position of the string""" full_names_lst = [name + ' Kardashian' for name in first_names_lst if name[0] == 'K'] """Returns full name including Kardashian to the v...
216dfcb172c6d7ddf186d1e428c5cc574f657eff
pyqqc/USACO
/xkn/m13crypt1/crypt1.py
2,355
3.59375
4
""" ID: xknxkn1 LANG: PYTHON3 TASK: crypt1 """ f=open("crypt1.in",'r') N=int(f.readline().strip()) dsetstr=f.readline().strip().split(" ") dset=list(map(int,dsetstr)) dset.sort() dsetstr=list(map(str,dset)) print("N,dsetstr,dset",N,dsetstr,dset) allgood=[] line1=[0,0,0,0] line2=[0,0] line3=[0,0,0,0] line4=[0,0,0,0]...
04d16b986ad16cbf00b0b6f95f6943c78dc133a2
pyqqc/USACO
/xkn/m02ride/m02ride.py
541
3.515625
4
""" ID: xknxkn1 LANG: PYTHON3 PROG: ride TASK: ride """ fin = open ('ride.in', 'r') fout = open ('ride.out', 'w') line1=fin.readline() print("l1",line1) line2=fin.readline() print("l2",line2) def numchar(ichar): return ord(ichar)-ord('A')+1 print(numchar('Z')) p1=1 for chrn in line1: print('_',chrn) p1*=...
af2de4e8def1b3ff8f27262ebce2486a7c80fec6
fairytien/PHY131-FA19
/image_processing/enlarge_2x2.py
661
3.75
4
# Double the size of an image. import image myimg = image.Image("golden_gate.png") win = image.ImageWin(2*myimg.getWidth(), 2*myimg.getHeight()) myimg.draw(win) myimg.setDelay(1, 100) def enlarge_2x2(img): imgScale = image.EmptyImage(2*img.getWidth(), 2*img.getHeight()) for row in range(img.getHeight()): ...
f7d674ea9dff33030f1a724bc9b69b1258801c1f
santosh0634/basic-prog
/demo8.py
179
3.609375
4
#simple addition prog def sum(): no1=100 no2=200 return no1+no2 no3=sum() print(no3) print(type(no3)) print("sum()=",sum())#out put=300,<class,'int'>,sum()=300
b52eeeacfa29ec997c7920c72537113b7599a87b
craigfay/Google-Foundations-Path
/Problem 01 - Subsequence/googleFoundations1.py
2,010
4.03125
4
# https://techdevguide.withgoogle.com/paths/foundational # Created 10.01.2017 by CB Fay # Updated 10.18.2017 by CB Fay # Given a string S and a set of words D, find the longest word in D that is a subsequence of S. S = 'hearing' D = ['a', 'bee', 'caribou', 'devastated', 'ear', 'car', 'earing', 'in', 'frantic',...
82b05ec1cf838435371c822d019132dc035dde6e
miisiker/isike
/isiklbot.py
2,005
3.5625
4
# coding: utf-8 # In[ ]: height = [ [0,1,1,0], [0,1,1,0], [0,1,1,0], [0,1,1,0], [0,1,1,0] ] isBlue = [ [False,False,False,False], [False,False,False,False], [False,False,False,False], [False,False,False,False], [False,False,False,True] ] isOn = [ [False,False,False,False], [False,False,False,Fal...
2233a1b235d65b1a72d225b90d462eb0d0bba5d6
jcoriell/csc132spring
/01 More On Objects/inheritance.py
939
3.90625
4
class Vehicle: def __init__(self, owner): self.tire_count = None self.has_engine = None self.owner = owner # skipping getters/setters for now def __str__(self): return f"owner = {self.owner}, tires = {self.tire_count}, engine = {self.has_engine}" class C...
8070b29be467c62432f861b0d24f051cda306c47
jcoriell/csc132spring
/02 More On Data Structures/dictionaries.py
1,719
4.71875
5
# Dictionaries are sets of keys. Each key has a value associated with it. # We says dictionaries are sets of key-value pairs # keys are unique. values don't need to be unique # Example of a dictionary: Info of a user user = { 'first_name': 'Josh', 'last_name': 'Coriell', 'zip_code': 71270 } # Accessing ...
a9ac29e463b41d3a38f63f9601e0dbc14a68f9f5
Maquiavelosan/Python-cousre
/Hola_mundo.py
1,070
3.53125
4
#Imprimir Mensaje desde una variable mensaje="Holis holiwis" print (mensaje) print (mensaje.upper()) #Cambiar a mayusculas print (mensaje.lower()) #Cambiar a minúsculas #Concatenar variables de texto nombre = "Alfredo" apellido = "Carbajal" print(nombre + " " + apellido) #Concatenar una variable e imprimir la concat...
95cba2510a417762938804165fb2fe3d4bbce4ff
Maquiavelosan/Python-cousre
/Tarea 2/Tarea 2-4.py
279
3.5
4
#Pedir al usuario un número del 1 al 1024 e imprimir este número en binario print("Ingrese un múmero entre el 1 y el 1024") dato=input() binario=bin(int(dato)) texto=str(binario) texto=texto.lstrip("0b") print(f"El número {dato} equivale en binario a: {texto}")
44228ee164d0881f843f702692340cf2ad96414c
Maquiavelosan/Python-cousre
/Listas/Tarea 3-3.py
277
3.5625
4
bicicletas= ["SHIMANO", "GIANT", "CANNONDALE", "SPECIALIZED", "TREK"] tamaño=len(bicicletas) contar=0 while contar < tamaño: print(f"Me gustaria comprar una bicicleta {bicicletas[contar]} para hacer ejercicio e ir a todos lados en ella\n") contar = contar +1
a00b5bfa6affbcca5a1a4dfe2ebc9c09d36a9059
Maquiavelosan/Python-cousre
/Listas 2/Tarea 4-7.py
1,028
3.90625
4
""" 7.0 - (Bonus: No espero que lo terminen esta semana porque no hemos visto condiciones pero si quieren pueden comenzar a hacer intentos de como resolverlo. Por favor no lo busquen en internet) 7.1 - Genera el codigo (usando ciclos) para generar la lista con los numeros primos entre el 1 y el 1000 (https://es.wiki...
d2a5e61a03c2592f730bcf6df0d5030d43faa5b1
mickey1cx/learn_phyton
/src/stepic.org/course_67/lucky_ticket.py
269
3.59375
4
# python 3.7 # https://stepik.org/lesson/5047/step/7?unit=1086 ticket = input() a = int(ticket[0]) + int(ticket[1]) + int(ticket[2]) b = int(ticket[3]) + int(ticket[4]) + int(ticket[5]) if a == b: print("Счастливый") else: print("Обычный")
2fcc34966596cbc93de55f03ab21cef668ee1f7d
mickey1cx/learn_phyton
/src/stepic.org/adaptive/multiple_list_index_search.py
567
3.734375
4
# https://stepik.org/lesson/21975/step/2?adaptive=true&unit=5235 numbers = '5 8 2 7 8 8 2 4'.split() # input() search_value = '8' result = [] for i in range(len(numbers)): if numbers[i] == search_value: result.append(i) if len(result) > 0: print(*result) else: print('None') # 2 result = [] for idx...
6411de3ee74a74bb5c87ce9eb621081363fe0473
udaychugh/HackerBlocks
/Algorithms/Prime Generator.py
576
3.640625
4
def checkPrime(num): if num==0 or num==1 : return False elif num==2 : return True elif num%2==0 : return False else : i=2 while(i*i<=num): if(num % i==0): return False i=i+1 return True ...
9d33e481f42e2cfdbabe554922202a06416d72c0
corben15/ML_projects
/python_proj/nn_np.py
16,148
4.28125
4
''' Nicholas Corbett Deep Learning 6850 Programming Assignment 2 ''' import numpy as np import math import matplotlib.pyplot as plt import matplotlib.image as mpimg import os import time import pickle import random ''' Activation function is the Rectified Linear Unit function. If the value is greater than zero then ...
eaa9f7ef3d894cf7af3e03c5919a176a48345ea3
xiaonanQua/python_project
/tensorflow_learn/machine_learning/gradient_descent.py
983
3.796875
4
""" 对于一个假设的线性函数,使用梯度下降法最小化其损失函数 """ import numpy as np import matplotlib.pyplot as plt # 定义训练、测试的数据和标签 train_data = (((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41)) test_data = (((515, 22, 13), 555), ((61, 35, 49), 150)) parameter_vector = [2, 4, 1, 5] m = len(train_data) # ...
c376f6e63948d2e60c7633c17912b5769967b97a
xiaonanQua/python_project
/data_structure/search/sequentialsearch.py
2,836
3.84375
4
""" 查找表是由同一个类型的数据元素(或记录)构成的集合。 关键字是数据元素中某个数据项的值,又称键值。若此关键词可以唯一地标识一个记录,则称此关键字为主关键字。 对于识别多个数据元素的关键字,称为次关键字。 查找就是根据给定的一个值,在查找表中确定一个其关键字等于给定的数据元素或记录 查找表分为静态查找表(Static Search table)、动态查找表(Dynamic Search Table)。 静态查找表:只有查找操作的查找表。(1)查询某个特定数据元素是否在表中。(2)检索某个特定数据元素和各种属性 动态查找表:在查找过程中同时插入查找表中不存在的数据元素,或者从查找表中删除已经存在的某个数据元素。 """ de...
283fcc6f36a853ad6e7dafec2409682c7d008b0d
xiaonanQua/python_project
/tensorflow_learn/basic_tensorflow/graph.py
2,114
4.09375
4
""" 定义:tensorflow的计算过程可以表示为一个计算图(Computation Graph),也称为有向图,在计算图上可以直观地看到数据的计算流程。 操作节点:计算图上的每一个操作可以看成一个节点,每一个节点都可以有任意的输入和输出。 边连接:若一个运算的输入是另一个运算的输出,则这两个运算存在依赖关系,两者之间通过边(Edge)相互连接。 依赖控制:有一类的边不存在数据流动,而是起着依赖控制的作用。也就是起始节点执行后再执行目标节点,来达到条件控制的目的。 需要注意:不同计算图上的变量不能共享,也就是不能调用其他计算图上的变量。对于自己定义的计算图通常设置成默认。 """ import tensorflow as tf...
b74a24523b0e633767be334664feee2568ce7904
HardProgrammer/pythonRoad
/com/study/inputInfo.py
555
4.15625
4
''' 获取输入框的内容: python2中使用的是raw_input()获取输入内容,python3没有 ''' import getpass # 输入信息 name = input("your name:") age = input("your age:") # 隐藏输入 password = getpass.getpass("your password:") # 获取变量的数据类型,在输入语句中,默认获取的数据为字符串(str)类型 print (type(age)) print("name = ",name ,",age = ", age, ",password =...
eb882d557b2355ca8a4d7758f2ba269e26c9cd71
HardProgrammer/pythonRoad
/com/study/map.py
423
4.09375
4
# map用于接收参数是List的函数,方便遍历参数里面的元素 def f(x): return x * x # 使用map对函数进行输出,python3要用list去接收才可以进行正常输出 print(list(map(f, [1, 2, 3, 4, 5, 6, 7, 8, 9]))) # 函数实现第一个字母大小,其他字母小写 def toUpper(x): return x[0].upper() + x[1:].lower() print(list(map(toUpper, ["LXW", "liSa", "hello"])))
c2f3904f81a3e77b327f94dfd7ad3c7c9d9da6ba
HardProgrammer/pythonRoad
/com/study/function/function_1.py
1,088
3.875
4
''' 函数传参 1.实参和形参 2.参数默认值 3.多参数传递 ''' def passAdd(): # 添加一个占位符,当还没有决定编写该函数的功能时,先使用pass占位符防止报错 pass # 函数里的参数代表的是形式参数,而调用的是时候传来的参数为实际参数 def add(a, b): return a + b print(add(1, 2)) # 设定默认参数进行返回 def adds(a=5, b=2): return a + b print(adds()) print...
f81aeeeff92fdf9a6aa2de5ce99469fd9913542c
HardProgrammer/pythonRoad
/com/study/list_a.py
957
4.0625
4
list_test = ["aaa", "aaa", "eee", "bbb", "ccc", "ddd"] print("排序前的数据:", list_test) # 反转 list_test.reverse() print("反转后的数据:", list_test) # 排序 list_test.sort() print("排序后的数据:", list_test) # 获取list的总个数 print(len(list_test)) # 获取list中某元素的个数 print(list_test.count("aaa")) # 列表的拼接 list_two = ["eee", "...
0022545df3d6913ca911db81ed0d0a9945bd2cd0
HardProgrammer/pythonRoad
/com/study/filter.py
407
3.734375
4
import math # 过滤函数--输出1-100偶数 def is_int(x): return x % 2 == 0 # 用list来接收结果集 print(list(filter(is_int, range(1, 101)))) # 判断1-100的平方根是否是整数 def is_sqr(x): r = int(math.sqrt(x)) # 将r强制转化为int型,然后判断它的平方是不是原来的数 return r * r == x print(list(filter(is_sqr, range(1, 101))))
3364d83d3848c16d089b05206a8b56fafb9f194b
MOHAMMADArsalan/learnig-python
/basic_calculator.py
388
4.375
4
num_1 = input("Enter First Number: ") num_2 = input("Enter Second Number: ") operator = input("Operator: ") num_1 = float(num_1) num_2 = float(num_2) result = "Invalid Operator" if operator == "+": result = num_1 + num_2 elif operator == "-": result = num_1 - num_2 elif operator == '/': result = num_1 / n...
32875e282a6b5127b6846f3ef85094767886194c
no-timing/CODE
/AutokeyPlaintext.py
1,182
4
4
''' Autokey Cipher - Plaintext Programmer: Ai Zhengpeng Date: 2017-08-31 Function: Encrypt(plaintext, key) -> ciphertext Decrypt(ciphertext, key) -> plaintext ''' def Encrypt(plaintext, key): ciphertext = "" i = 0 for letter in plaintext: if letter.islower(): c = chr((ord(letter) - ord(...
69ae9592d756cbce15b2450d843f08c8ed6a44bb
no-timing/CODE
/Keyword.py
1,310
4.125
4
''' Keyword Cipher Programmer: Ai Zhengpeng Date: 2017-08-30 Function: Encrypt(plaintext, key) -> ciphertext Decrypt(ciphertext, key) -> plaintext ''' def Encrypt(plaintext, key): ciphertext = "" table = "" for letter in key: if letter.isalpha() and table.find(letter.lower()) == -1: tab...
160ef5d3f4e549a0eedc3772ff985cdf92aee7de
eric-risbakk/PythonOpenCL-Experimenting
/Exercises/Exercise05/Python/vadd536.py
3,524
3.546875
4
# # Vadd # # Element wise addition of two vectors (c = a + b) # Asks the user to select a device at runtime # # History: C version written by Tim Mattson, December 2009 # C version Updated by Tom Deakin and Simon McIntosh-Smith, October 2012 # Ported to Python by Tom Deakin, July 2013 # # Import the ...
5ffc3e58aee7b5165b2fce05baee25c541f85478
tommirrington/52167-Programming-and-Scripting
/01_fibname.py
886
4.25
4
# Tom Mirrington #Exercise 1 response #My name is Tom, so the first and last letter of my name (T + M = 20 + 13) give the number 33. The 33rd Fibonacci number is 3524578. #Exercise 2 # A program that displays Fibonacci numbers using people's names. def fib(n): """This function returns the nth Fibonacci number.""...
67073102e45b84b628f2fb7a84a4615fff2480ec
zoya111/quiz
/hangman.py
3,382
3.875
4
import random import termcolor from termcolor import colored print(colored("*******************************","green")) print(colored("*******************************","green")) print(colored("************HANGMAN************",'blue')) print(colored("*******************************","green")) print(colored("*************...
ae4992c7cc493cc1887d2b587b3f3e2593d13176
ricardoveri/faculdade
/bibiExemploFilme.py
216
3.515625
4
def filmesAnoDuracao(lista, ano, duracao): resposta = [] for i in range(len(lista)): if(Filmes[i][1] == ano) and (Filmes[i][2] < 120): resposta.append(lista[1][0]) return resposta
ddb3a4bf8d9252e042f0dd6c5b3d52910a921bf0
shaoyy147/DAT210x-python_datascience
/Module3/Module3 - Lab2.py
1,338
3.78125
4
# coding: utf-8 # # DAT210x - Programming with Python for DS # ## Module3 - Lab2 # In[1]: import pandas as pd import matplotlib.pyplot as plt import matplotlib # In[2]: # Look pretty... # matplotlib.style.use('ggplot') plt.style.use('ggplot') # Load up the wheat seeds dataset into a dataframe. We've stored a...
d6384f73ba92e84e8f24092a7e0a4e6e2e0c4826
FlorentNKada/performanceTesting
/dirac/myDIRACClient.py
2,538
3.546875
4
############################################################################### # myDIRACClient.py # ############################################################################### """This script is used to spawn as many client threads as we want, and every one...
ddfe0391d91d4c62558617a90ede3c129046782c
Pandaxia8/SUDA_UNGEE_CODE
/复试/2019/Code/ArthurRen/2019.py
5,358
3.5
4
import math from typing import List class Solution: def __init__(self): self.dataFilename = "../../Data/Data.txt" self.outputFilename = "output.txt" self.arr = [] self.res = [0 for _ in range(10)] self.primeGenerator = Solution.findNextPrime() self.debug = False ...
b554a878f254caa34f0036534b24e2d7bbc3d325
Pandaxia8/SUDA_UNGEE_CODE
/复试/2016/复试上机题/Code/HMY777/2016.py
1,569
3.6875
4
# - 文本文件input.txt由若干英文单词和分隔符(空格、回车、换行)组成,根据如下说明编写程序统计不同单词出现的次数(频度)。将统计结果按出现频度从高到低排序,并将出现频度大于5的单词及其频度输出到文件output.txt中。 # - 文件格式单词,次数,每个单词占一行 # - 多个连续分隔符被视为一个分隔符 # - 大小写敏感,即大小写不同的为两个单词 # - 每个单词长度不超过20个字符 # - 单词的数量未知,使用静态大数组将扣5分 class Solution(object): def __init__(self): self.words = [] self.word_dic...
78236d061519223ac9d621c396ce83c36db41aca
Pandaxia8/SUDA_UNGEE_CODE
/复试/2010/Code/HMY777/2010.py
1,476
3.6875
4
class Solution(object): def __init__(self): self.numLst=[] self.read_file() self.maxNum=0 self.minNum=0 self.maxPrime=0 self.midMinNum=0 self.midMaxNum=0 self.read_file() self.process_data() self.write_file() def read_file(self): ...
c144ddf2767665bf42e9f6244588cf88a0194d75
yttrium25/Prime-number-deep-learning
/data/Is_prime.py
182
3.5
4
import math from sympy import sieve def prime_list(n): item = [] for i in sieve.primerange(1, n): item.append(i) return item print(prime_list(2**30))
6422cb308d53cd4ab0904b44748cc604c160d956
BenoitHage/CS50
/pset6/readability/test.py
308
3.84375
4
textMain = "Test test!" letterCounter = 0 for isLetter in textMain: if isLetter.isalpha(): letterCounter += 1 print(letterCounter) # number of letter for isLetter in textMain: testCurrent = isLetter.isAlpha() if (testCurrent == True): letterCounter += 1
3698fb3b1667f94a62615d7cb7ddf55467711828
travisleeb/ProjectEuler
/Python/prob3.py
759
3.984375
4
""" The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? """ #Using Prime Factorization method def getLargestPrimeFactor(num): result = num factor = 2 #Since a Prime is divisible by 1, we start with 2 #We loop until the largest factor is the resul...
25c49926dea37a46e691999929717a076ff15643
vvbaliga/PythonCourse
/Google-IT-Automation/Week1-3/7Multiple.py
263
4.28125
4
""" Write a script that prints the multiples of 7 between 0 and 100. Print one multiple per line and avoid printing any numbers that aren't multiples of 7. Remember that 0 is also a multiple of 7. """ for i in range(0,100): if i%7 == 0: print(i)
6f6c7baac9cc28d9007d708dceab6db809d5321f
vvbaliga/PythonCourse
/Google-IT-Automation/Week1-3/sumSquares.py
187
3.796875
4
def square(n): return n*n def sum_squares(x): sum = 0 for n in range(10): sum += square(n) print(n) return sum print(sum_squares(10)) # Should be 285
9519b568ad161b8eb8dfe12d6dff4cb7121fc02e
cjopengler/easybook
/daily/datetime_demo/datetime_demo.py
1,434
3.703125
4
#!/usr/bin/env python 3 # -*- coding: utf-8 -*- # # Copyright (c) 2020 PanXu, Inc. All Rights Reserved # """ 时间与日期 Authors: PanXu Date: 2020/11/07 10:56:00 """ from datetime import datetime my_time = datetime(year=2020, month=11, day=7, hour=11, minute=3, second=2) # 格式化输出 FORMATE_1 = '%Y-%m-%d %H:%M:%S' FORMA...
4bdcd0a6d851ce013b20d33b22ee6c2fb6168b39
emil622/PYTHON_LUNCH
/mirror_words.py
615
3.515625
4
import sys #------------------------------------------------------------------------------- # Name: mirror_words.py # Purpose: Exercise # writes a given word reversed. # # Author: E.M. # # Created: 23.03.2012 # Copyright: (c) emilutz09@gmail.com 2012 # Version 1.0 # Licence: ...
01e90467990cdd0144afbbf80dfd8f7e5b00817f
sunday1103/Notebook
/language/python/basic/class_oop.py
687
4.15625
4
class basic: """This is the basic class""" classVar = 100 def __init__(self, a, b): self.a = a self.b = b def print(self): print(self.a, self.b) class derivedClass(basic): """Derived class""" def __init__(self, a, b): basic.__init__(self, a, b) print('...
63b1f6cf9b63e49843f2aa9ca266d81da10d5e88
sunday1103/Notebook
/algorithm/basic algs/DP/LeetCode/findNumberOfLIS.py
2,169
3.5625
4
# Input: [1,3,5,4,7] # Output: 2 # Explanation: The two longest increasing subsequence are [1, 3, 4, 7] and [1, 3, 5, 7]. class Solution(): def findLengthOfLIS(self, nums): """ 寻找最长递增子串的长度 :type nums: List[int] :rtype: int """ ''' 子问题:以第i个数字结尾的最长子序列长度 F(i) ...
695dae1af813a5dbc237e4172d5512405d361c0d
DGalbichek/ptimeandstuff
/mysite/legodb.py
1,590
3.53125
4
import datetime import sqlite3 class LegoDb(): def __init__(self): self.db = sqlite3.connect('legodb.sqlite') self.cursor = self.db.cursor() try: self.cursor.execute(''' CREATE TABLE IF NOT EXISTS legosetcounts( id INTEGER PRIMARY KEY, set...
3568bad221a3f2e49aa89b119cd45339e13d5fbd
jpmunz/project-euler
/python/44.py
655
3.5625
4
from helpers import test, pentagonal_number def find_pentagonal_sum_and_difference(): pentagonals = set([]) n = 1 while(True): pn = pentagonal_number(n) for previous in pentagonals: diff = pn - previous if diff != previous \ and diff in pentagonals...
28490b818bf0f23d4f20668bafb50fce96fbe7ef
jpmunz/project-euler
/python/40.py
538
3.53125
4
from helpers import test def consecutive_digits(n): digits = [] i = 1 while(True): for d in str(i): digits.append(int(d)) if len(digits) >= n: return digits i += 1 def evaluate_consecutive_expression(): digits = consecutive_digits(1000000) expre...
b334e5b293359396dd67964d7e2c702e2d05be51
jpmunz/project-euler
/python/42.py
717
3.796875
4
import string from helpers import test, triangle_number, is_triangle_number def word_to_value(word): value = 0 for letter in word: value += string.lowercase.index(letter.lower()) + 1 return value def count_triangle_words(words): count = 0 for word in words: value = word_to_value...
710b3f36ba3f63f9f1d5e94a297b5702e1ef3fb5
fandrefh/curso-python-django
/chute_v2.py
645
3.8125
4
from random import randint print("Bem vindo!!!") # print(numero_sorteado) novo_jogo = True while novo_jogo != False: numero_sorteado = randint(1,100) contador = 1 while True: chute = int(input("Chute um número: ")) if chute == numero_sorteado: print("Parabéns, você é foda.") ...
fcebc85e0097cd5853b84c9634ba028e302a8a4b
brickdonut/2019-fall-polytech-cs
/2z.py
153
3.65625
4
import math n=int(input("team:")) S=math.factorial(n)//math.factorial(n-3) D=math.factorial(n) print("top places:" +str(S)) print("all places:" +str(D))
c81aa6a6448d8974ee39d691496137a2d03cbee5
cdart1/Tech-Academy-Projects
/The_Tech_Academy_Python_Projects/Assignments/Abstraction.py
651
4.09375
4
# Abstraction Assignment from abc import ABC, abstractmethod # base/abstract class Building class Building(ABC): def enter(self): print("I am entering...") @abstractmethod def exit(self, throughWhat): pass # child class class School(Building): def exit(self, throughWhat): p...
2e0ba28158e5d1ef73dd521ef95b99ef4c7e46dc
cdart1/Tech-Academy-Projects
/The_Tech_Academy_Python_Projects/Assignments/Assignment3.py
1,393
4.46875
4
# # Python: 3.8.5 # # Author: Courtney Dart # # Description: To write a script that creates a dB and adds # new data into the dB. Practice looking up # files end with '.txt' and printing # the file names to the console. # leverage the met...
aa61c024de1fa1cb8d61e356ad25228a3f73269d
mariapaula017/Programacion-
/Clases programación/clase2.py
735
3.9375
4
# Estos son booleans que son variables que solo valen # # verdadero falso pruebaV = True pruebaF = False print(pruebaF) print(pruebaV) pruebaV = pruebaF print ("pruebaV") edad = 20 estatura = 1.55 peso = 57 NOMBRE = "Maria Paula Suarez V" print("#"*15,"Mayor Edad", "#"*15) isMayorEdad = edad >= 18 print(isMayorEdad)...
c9aa416ced7be7cb193aa18a0f7c0ae0815f8472
mariapaula017/Programacion-
/Clases programación/Talleres/Taller1.py
929
4.21875
4
#----Constantes----# numeroA = 17 numeroB = 20 #----Mensajes----# MENSAJE_MAYOR = "El numero A es mayor que el numero B" MENSAJE_MENOR = "El numero A es menor que el numero B" MENSAJE_IGUAL = "El numero A y B son iguales" MENSAJE_DIFERENTE = "El numero A es diferente al numero B" #----Operaciones----# sumar = numeroA...
7ac3747d91a2998b62dacab83e88d34def575076
h-betz/CourseraMachineLearningPython
/machine_learning_ex2/cost_function.py
677
3.8125
4
from machine_learning_ex2.sigmoid import sigmoid import numpy as np """ Compute cost and gradient for logistic regression J = COSTFUNCTION(theta, X, y) computes the cost of using theta as the parameter for logistic regression and the gradient of the cost w.r.t. to the parameters. """ def cost_function(theta, x, y...
19532121a998f728854f43c2fca9f9807ec134f2
julinvictus/python-noobs
/ex20.py
925
4.09375
4
from sys import argv script, input_file = argv def print_all(f): print f.read() # function print_all to print all content of input file def rewind(f): f.seek(0) # function rewind to go to beginning (0) of input file def print_a_line(line_count, f): print line_count, f.readline() # function print_a_line to pri...
b0079a77a53ac6c456a3d7d4ee6da45f8e6ec480
julinvictus/python-noobs
/ex19_extra.py
766
3.59375
4
# romeu e julieta is a Brazilian candy made of # cheese and goiabada (guava paste) def romeu_e_julieta (cheese_count, boxes_of_goiabada): print "You have %d cheeses!" % cheese_count print "You have %d boxes of goiabada!" % boxes_of_goiabada print "Man that's enuf for a Brazilian party!" print "Get a ca...
195c29e3da540b87eb7c00d80ebdbc2c9ea1d036
julinvictus/python-noobs
/sudoku2.py
4,873
4
4
#I mostly just copied each function from your solution #and tried to understand the code import os import random def parse_board(filename): f = open(board_filename) board = [] for line in f.readlines(): line = line.strip() row = line.split(' ') board.append(row) return board ...
be10223ebb9f867a1d8640bf10b3c36b580ccf44
EsauM10/evolutive-computing
/Travelling Salesman/main.py
4,794
3.765625
4
import math from population import City, Individual, Population import matplotlib.pyplot as plt from random import random, randint WIDTH = 500 HEIGHT = 500 def generate_cities(max_cities:int)->list: ''' Retorna uma lista com pontos aleatórios representando cidades ''' return [City(randint(0, WIDTH),...
c1662d2428ac3fa7f7d62c83be13f7c8df0931d4
Taizul1579/Pythonbasic
/Square_Of_Any_Number.py
139
4.1875
4
# square of any number while True: a = int(input("You Want To Know The Square Of The Number:")) print('Result OF Square:',a*a)
de3db93bdd7dba21e76bfda72a83ffba7e7bb2ce
Taizul1579/Pythonbasic
/Remailder_Of_Any_Number_Without_Function.py
215
4.15625
4
# remainder Of any number while True: a = int(input("Enter The Dividend Number : ")) b = int(input("Enter The Divisor Number : ")) Quotient = "Quotient Number", (a / b) % 2 * 2 print(Quotient)
19c673e04332f7da99dc09d6b017cf6d435c69ae
PeacefulAlien/Python_Version_Control_Exercise
/class_queue.py
1,424
4.25
4
#queue data structure #queue structure follows FIFO principle class class_queue(): def __init__(self): self.items_list = [] def enqueue(self, item): self.items_list.append(item) #pop out the first element of the stack #False means empty queue def dequeue(self): if self.items_list != [...
040e379febcebab682a038859e76e303591610df
UTKars123/pythonProject1
/time123.py
365
3.90625
4
import time initial1=time.time() k=0 while(k<45): print("this is me") k+=1 time.sleep(1) print("while loop run time",time.time()-initial1) initial2=time.time() i=0 for i in range(45): print("this is you") i+=1 print("for loop run time",time.time()-initial2) # localtime=time.asctime(tim...
4067e93edf67be2399b03f5cc1259bbd0f6e7684
UTKars123/pythonProject1
/exercise 2.py
693
3.921875
4
#task to make faulty calculator #45*3=555,56+9=77,56/6=4 d=["+","-","*","/"] d1=int(input("enter the value of d1\n")) d2=int(input("enter the value of d2\n")) d3=input("enter the symbol of addition,substraction,multiplication,division:\n") if d3 in d[0]: if d1==56 and d2==9: print("77") else: ...
bbfb574df107bec52617ea8acc447fd763fff282
MukulKirtiVerma/General-Computer-Science-Problem
/String_permutation.py
334
3.546875
4
# -*- coding: utf-8 -*- """ Created on Tue Apr 7 01:01:37 2020 @author: Mukul Kirti Verma """ def permu(st,l,r): if(l>=r): print(''.join(st)) else: for i in range(l,r): st[l],st[i]=st[i],st[l] permu(st,l+1,r) st[l],st[i]=st[i],st[l] s="asd" ...
9d9160e6a68b662c008ca14aa6ffc7dbf6531222
MukulKirtiVerma/General-Computer-Science-Problem
/1.Linear_Search.py
321
3.59375
4
# -*- coding: utf-8 -*- """ Created on Sat Apr 4 12:07:21 2020 @author: Mukul Kirti Verma """ arr=[4,7,4,3,3,5,6,8,5,3,2,4,6,78,6,3] search_element=2 result='not found' for i in arr: if(i==search_element): result=i print('found at',i) break if(result=='not found'): pri...
eb5e40def4977ce7f16f65f09bc393c5714c1989
MukulKirtiVerma/General-Computer-Science-Problem
/fibonacci_seriese.py
376
3.6875
4
# -*- coding: utf-8 -*- """ Created on Sat Apr 4 20:58:11 2020 @author: Mukul Kirti Verma """ x=int(input('enter total no of element to be print: ')) n1=1 n2=1 if(x==1): print(1) elif(x==2): print(1,1) else: print(n1) print(n2) x=x-2 while x: print(n1+n2) t...
9e5824ca55f1dac540fc31819f50feffc40b5c65
prajjwalkumar17/DSACodes
/Python/Sorting Duplicates Containing N-1.py
609
4.15625
4
''' Given an array a[] of size N which contains elements from 0 to N-1, you need to find all the elements occurring more than once in the given array. Input: N = 5 a[] = {2,3,1,2,3} Output: 2 3 Step 1: First check all the values that are present in an array then go to that values as indexes and increment by the siz...
cf9537f53d7d9e48cec3ba6dbf0c98ce13004848
boconlonton/data-validation-sb
/src/utils.py
587
3.75
4
import csv from collections import namedtuple from contextlib import contextmanager def read_file(file_name): """ Read csv file, skip the header row """ with open(file_name) as f: reader = csv.reader(f, delimiter=',', quotechar='"') # Skip the header next(reader) yield ...