blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
f5c58e281c315b60b44426eff8ccb551624691a1 | KIMZI0N/bioinfo-lecture-2021-07 | /src/028.py | 738 | 3.75 | 4 | #! /usr/bin/env python
seq = "ATGTTATAG"
'''
#1 if문
list=[]
for i in range(len(seq)):
if seq[i] == 'A':
list.append('T')
elif seq[i] == 'T':
list.append('A')
elif seq[i] == 'G':
list.append('C')
elif seq[i] == 'C':
list.append('G')
l = ''.join(list)
print(l)
'''
#2 강사님
co... |
a36002de7981c81dc1f4170809a47c37b2cca0d5 | pnads/advent-of-code-2020 | /day_06.py | 3,730 | 4.0625 | 4 | """--- Day 6: Custom Customs ---
As your flight approaches the regional airport where you'll switch to a much
larger plane, customs declaration forms are distributed to the passengers.
The form asks a series of 26 yes-or-no questions marked a through z. All you
need to do is identify the questions for which anyone i... |
049494c7eb2cd4b110164def15827503b616ef2e | sprotg/2020_3h | /algoritmer_og_datastrukturer/heap.py | 968 | 3.5625 | 4 | from random import randint
class Heap():
def __init__(self):
self.a = [randint(1,100) for i in range(10)]
self.heap_size = len(self.a)
def left(self, i):
return 2*i + 1
def right(self, i):
return 2*i + 2
def parent(self, i):
return (i-1)//2
def max_heap... |
f7179afa985135e89d3f83e772db20440c361106 | sprotg/2020_3h | /algoritmer_og_datastrukturer/sorting.py | 848 | 3.9375 | 4 | from random import randint
import time
import matplotlib.pyplot as plt
antal = []
tid = []
def bubbleSort(arr):
n = len(arr)
# Traverse through all array elements
for i in range(n-1):
# range(n) also work but outer loop will repeat one time more than needed.
# Last i elements are already in ... |
e3cdc173691a2ccdcdda891e41258f4fcc970b4c | sprotg/2020_3h | /databaser/database_start.py | 2,168 | 3.703125 | 4 | import sqlite3
#Her oprettes en forbindelse til databasefilen
#Hvis filen ikke findes, vil sqlite oprette en ny tom database.
con = sqlite3.connect('start.db')
print('Database åbnet')
try:
con.execute("""CREATE TABLE personer (
id INTEGER PRIMARY KEY AUTOINCREMENT,
navn STRING,
alder INTEGER)""")
... |
74bda556d528a9346da3bdd6ca7ac4e6bcac6654 | adaoraa/PythonAssignment1 | /Reverse_Word_Order.py | 444 | 4.4375 | 4 | # Write a program (using functions!) that asks the user for a long string containing multiple words.
# Print back to the user the same string, except with the words in backwards order.
user_strings = input('input a string of words: ') # prompts user to input string
user_set = user_strings.split() # converts stri... |
7b35393252d51e721ffddde3007105546240e5df | adaoraa/PythonAssignment1 | /List_Overlap.py | 1,360 | 4.3125 | 4 | import random
# Take two lists, say for example these two:...
# and write a program that returns a list that
# contains only the elements that are common between
# the lists (without duplicates). Make sure your program
# works on two lists of different sizes.
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
b = [1, ... |
8b396545767f1cd2d9cd925bd6006542116cbc4c | Mercy435/python--zero-to-mastery | /Advanced Python Object Oriented Programming.py | 8,816 | 4.34375 | 4 | # OOP
# 1.
class BigObject: # creating your class
pass
obj1 = BigObject() # instantiate means creating object
obj2 = BigObject() # instantiate
obj3 = BigObject() # instantiate
print(type(obj1))
# 2. gaming company
class PlayerCharacter: # make it singular
membership = True # class object attribute (t... |
1cd49270025286ef2a143bde60119ff410c4fb63 | Mercy435/python--zero-to-mastery | /Testing_in_python/testing_exercise.py | 988 | 3.71875 | 4 | import unittest
import random_game_testing
class TestGame(unittest.TestCase):
# 1
def test_input(self):
answer = 5
guess = 5
result = random_game_testing.run_guess(answer, guess)
self.assertTrue(result)
def test_inputw(self):
answer = 15
guess = 5
... |
ed46bde96311d2f53554158365edc3c8280f4a34 | kgupta1542/interviewQs | /Daily-Coding-Problem/dcp004.py | 669 | 3.78125 | 4 | #Refer to Daily Coding Problem #3
def findMissingInt(x):#find lower and upper, checks if in x, declares as missing, finds smallest missing
missing = 0
temp = -1
for i in range(len(x)):
if x[i] >= 1:
lower = x[i] - 1
upper = x[i] + 1
if upper in x or lower in x:#Fulfills last three reqs
temp = u... |
c8174a43df4b0e5dab7d954db25f41a3c604094a | Liangmiaomiao123/yiyuan | /demo02.py | 500 | 3.78125 | 4 | #缩进indent
a=int(input('请输入数字:'))
if a>0:
print('a大于零')
else:
print('a小于零')
#字符串
i="i'm fine"
print(i)
#查看字符编码
print(ord('a'))
print(ord('A'))
#字符串
name=input('请输入您的名字:')
age=input('请输入您的年龄:')
print('我叫%s,今年%d岁'%(name,int(age)))
#创建列表
classmates=['zhang1','zhang2','zhang3','zhang4','zhang5']
print(classm... |
97ab0921063f3db55af7f5dbcbea99cf5409489a | HuXuzhe/algorithm008-class02 | /Week_09/541.反转字符串-ii.py | 840 | 3.515625 | 4 | '''
@Descripttion:
@version: 3.X
@Author: hu_xz
@Date: 2020-06-23 15:03:24
@LastEditors: hu_xz
@LastEditTime: 2020-06-23 15:33:23
'''
#
# @lc app=leetcode.cn id=541 lang=python
#
# [541] 反转字符串 II
#
# @lc code=start
class Solution(object):
def reverseStr(self, s, k):
"""
:type s: str
:type ... |
2d7c7a182da252c7ace81b792290ddc36b3b6447 | HuXuzhe/algorithm008-class02 | /Week_03/236.二叉树的最近公共祖先.py | 985 | 3.546875 | 4 | '''
@Descripttion:
@version: 3.X
@Author: hu_xz
@Date: 2020-05-06 14:27:39
@LastEditors: hu_xz
@LastEditTime: 2020-05-08 11:52:57
'''
#
# @lc app=leetcode.cn id=236 lang=python
#
# [236] 二叉树的最近公共祖先
#
# @lc code=start
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# ... |
7036212232a843fe184358c1b41e5e9cb096d31d | andrew5205/MIT6-006 | /ch2/binary_search_tree.py | 1,377 | 4.21875 | 4 |
class Node:
# define node init
def __init__(self, data):
self.left = None
self.right = None
self.data = data
# insert into tree
def insert(self, data):
# if provide data exist
if self.data:
# 1 check to left child
# compa... |
6141ec333d44e99c0c1968f7a21a9d6d83f56c3d | aliazani/python-exercise | /fun.py | 306 | 3.6875 | 4 | from random import randint
answer = 209
guess = randint(1, 2000)
print(guess)
mini = 1
maxi = 2000
count = 0
while guess != answer:
guess = randint(mini, maxi)
if guess > answer:
maxi = guess
elif guess < answer:
mini = guess
count += 1
print(guess)
print(count)
|
eed8a14cb453e976317a8e2ecbce711e627ebe83 | aliazani/python-exercise | /review.py | 388 | 3.71875 | 4 | class Celsius:
def __get__(self, instance, owner):
return 5 * (instance.fahrenheit - 32) / 9
def __set__(self, instance, value):
instance.fahrenheit = 32 + 9 * value / 5
class Temperature:
celsius = Celsius()
def __init__(self, initial_f):
self.fahrenheit = initial_f
t = ... |
05588ff773753216a4345b4a3fd7ad903f7aec3f | aliazani/python-exercise | /getter&setter.py | 359 | 3.90625 | 4 | class Circle:
def __init__(self, diameter):
self.diameter = diameter
@property
def radius(self):
return self.diameter / 2
@radius.setter
def radius(self, radius):
self.diameter = radius * 2
small_one = Circle(10)
small_one.radius = 20
print(small_one.diameter)
print(small... |
aea31ea7e2069290e0fc0931d00e0d57018cca75 | aliazani/python-exercise | /class_number_string.py | 1,343 | 4.03125 | 4 | class NumberString:
def __init__(self, value):
self.value = str(value)
def __str__(self):
return f"{self.value}"
def __int__(self):
return int(self.value)
def __float__(self):
return float(self.value)
def __add__(self, other):
if '.' in self.value:
... |
6d3c2605deadcf5d437323ee455866506b42dabd | khaiduong/lpy | /Learn_Project/6th_day/6.3.py | 688 | 3.875 | 4 | """
Write a python script which write to file 64out.txt, each line contains line
index, month, date of month (Feb 28days).
E.g::
1, January, 31
2, February, 28
"""
import calendar
from sys import argv
def write_days_monthname_to_file(year=2016, filename=None):
try:
std_int = int(year)#raw_input(std_int))
e... |
f8e3c787070297a6a7554baaf61eef82fb9c0f67 | Picik-picik/Python | /Chapter 03. 프로그램 사용자로부터의 입력 그리고 코드의 반복/03-2 입력받은 내용을 숫자로 바꾸려면.py | 3,596 | 3.515625 | 4 | Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 22:39:24) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> # 03-2 입력받은 내용을 숫자로 바꾸려면
>>>
>>> # 프로그램 사용자로부터 '문자열'이 아닌 '수'를 입력받으려면 어떻게 해야 할까?
>>> # 파이썬은 수를 입력받는 함수를 제공하지 않는다. 대신에 문자열의 내용을 수로 바꿀 때
>>> # 사용할 수 있... |
bfee9aead792afa056a6254d96037a18856d594c | mariamingallonMM/AI-ML-W3-LinearRegression | /p37/ridge_regression.py | 7,425 | 3.921875 | 4 | """
This code implements a linear regression per week 3 assignment of the machine learning module part of Columbia University Micromaster programme in AI.
Written using Python 3.7
"""
# builtin modules
import os
#import psutil
import requests
import sys
import math
# 3rd party modules
import pandas as pd
import nu... |
53151036235900e092ebba543a029f333ef8228f | monilezama/inteligencia_artificial | /lezamaMonicaT3.py | 5,708 | 3.609375 | 4 |
# Este archivo contiene un programa con varias funciones incompletas, que el
# usuario tiene que terminar.
# Las configuraciones del tablero son una lista de listas
# pe meta = [[1,2,3],[8,0,4],[7,6,5]] donde 0 es el blanco
# Ab es una lista de tuple de la forma (node,padre,f(n),g(n))
# g(n) es la longitud d... |
d459bade9a96ebe9963e0d240e2724506b9f7665 | TitoSilver/codigoFacultad | /diccionario/practica.py | 6,558 | 3.671875 | 4 | from algo1 import *
from mydictionary import *
from myarray import *
from linkedlist import *
#=========================================#
#ejercicio 4
def igualString(text1,text2):
#función que verifica si dos strings son iguales
#creamos un dic con los elementos del text2
if len(text1)==len(text2):
... |
8eb212398880ce375cf3541eac5fcd73c1ab95fe | Srbigotes33y/Programacion | /Python/Aprendizaje/Condiociones anidadas/Taller Condiciones2/Ejercicio_5.py | 1,767 | 4.125 | 4 | # Programa que solicita 3 números,los muestra en pantalla de mayor a menor en lineas distintas.
# En caso de haber numeros iguales, se pintan en la misma linea.
# Solicitud de datos
n1=int(input("Ingrese tres números.\nNúmero #1: "))
n2=int(input("Número #2: "))
n3=int(input("Número #3: "))
# En caso de que no se pr... |
b3f93af0e701d69fe601fa45a19863f742fa0e49 | Srbigotes33y/Programacion | /Python/Traductor binario/main.py | 3,260 | 4.0625 | 4 | # Traductor que convierte decimales y caracteres a binario y visceversa.
# Importación de la libreria de conversores
from conversor_binario import *
# Solicitud de datos decimal a binario
def solicitud_decimal_binario():
bandera = True
while bandera:
decimal = input("\nIngrese el número decimal (X p... |
25b2d05140a1397680d93d95c6a305f6c39f5602 | Srbigotes33y/Programacion | /Python/Aprendizaje/Condiociones anidadas/Taller Condiciones2/Ejercicio_4.py | 1,043 | 4.15625 | 4 | # Programa que pide 3 números y los muestra en pantalla de menor a mayor
# Solicitud de datos
n1=int(input("Ingrese tres números.\nNúmero #1: "))
n2=int(input("Número #2: "))
n3=int(input("Número #3: "))
# Determinacion y exposición de los resultados
if n1>n2 and n2>n3:
print("\nEl orden de los números es:\n",n3... |
7d3db72a696aaa2ce106381c13f94b983447ae41 | Srbigotes33y/Programacion | /Python/Aprendizaje/Ciclo For/Taller for/Ejercicio_1.py | 1,210 | 3.984375 | 4 | # Programa que lee los lados de n triangulos e informa el tipo de triángulo y la cantidad de tringulos de cada tipo
veces=int(input("¿Cuántos triángulos va a ingresar?\nTriángulos: "))
equilatero=0
isoceles=0
escaleno=0
print("Ingrese el valor de cada lado del triángulo: ")
for i in range(1,veces+1):
lado1=int(i... |
94ec7029af42fab2fc4ab0082f21a99505977bd0 | Srbigotes33y/Programacion | /Testing y Debugging/POO/3_atrubitos_metodos2.py | 750 | 3.703125 | 4 | # Se define la clase Auto
class Auto:
rojo = False
# Método __init__ o constructor, instancia el objeto al momento de ser llamada la clase.
def __init__(self, puertas=None, color=None):
self.puertas = puertas
self.color = color
if puertas != None and color != None:
print... |
3380b8cb3334eb26b54958785764f0220bf0e9a6 | Srbigotes33y/Programacion | /Python/Aprendizaje/Ciclo For/Taller for/Ejercicio_5.py | 615 | 4.09375 | 4 | # Progrma que calcula el factorial de un número
factorial=1
numero=int(input("Ingrese el número a calcular el factorial: "))
if numero<0:
print("El número no puede ser negativo")
elif numero>50000:
print("El número es demasiado grande")
else:
for i in range(1,numero+1):
factorial=factorial*numero
... |
e6e5d947ff4072402a040cdb5efb6f19e32b3ad8 | Srbigotes33y/Programacion | /Python/Aprendizaje/Pruebas/Critografia.py | 624 | 3.671875 | 4 | #Critografia E=3, A=4, O=0, B=8
#Sapo=54p0 ; ALEJO= 413J0
palabra=input("Ingrese una palabra o frase: ").upper()
i=0
nueva=""
while(i<len(palabra)):
if(palabra[i]=="a"):
nueva=nueva+"4"
elif (palabra[i]=="e"):
nueva=nueva+"3"
elif (palabra[i]=="l"):
nueva=nueva+"1"
elif (palabra[... |
f423d11aa0d16c8959e8899f15e1761a4fe6a16a | zhtiansweet/DataStructure | /StackByQueue.py | 1,428 | 3.6875 | 4 | __author__ = 'tianzhang'
# Implement a stack with two queues
import Queue
class stack:
def __init__(self):
self.queue1 = Queue.Queue()
self.queue2 = Queue.Queue()
def push(self, x):
if self.queue1.empty():
self.queue2.put(x, False)
else:
self.queue1.pu... |
7f04fcd227b6abbc473ac21f48241b9d0e88296f | jarulsamy/boxSim | /src/sim.py | 11,428 | 3.796875 | 4 | #!/usr/bin/env python3
"""
Simple simulator for the shortest-path-to-target problem.
+------------------------------------------------------------------------------+
| |
| □ ------------------------------------- ... |
aabdf3585e0921c82e2753eabc623be348f63000 | aleksbel/python-project-lvl1 | /brain_games/games/prime.py | 486 | 3.9375 | 4 | from random import randrange
GAME_TOPIC = 'Answer "yes" if given number is prime. Otherwise answer "no".'
def is_prime(n):
d = 3
while d * d <= n and n % d != 0:
d += 2
return d * d > n
def new_round():
# Odd numbers only
x = randrange(1, 1000, 2)
# Correct answer
if is_prime(x... |
c92ac1ecaf837ff1e754475007b37ff58e30ab28 | shilpageo/pythonproject | /functions/factorial.py | 356 | 3.921875 | 4 | #method1
def fact():
num=int(input("enter number"))
fact=1
for i in range(1,num+1):
fact*=i
print(fact)
fact()
#method2
def fact(n1):
fact=1
for i in range(1,n1+1):
fact*=i
print(fact)
fact(5)
#method3
def fact(num1):
fact=1
for i in range(1,num1+1):
fact*=i... |
25732642d700e35e08b653d3cb7dbab3adb4fc6e | shilpageo/pythonproject | /functions/demo1.py | 343 | 3.953125 | 4 | #def functionname(arg1,arg2):
#fn statemnt
#fncall()
#fn without arg and no return type
#fn with arg and no return type
#fn with arg and return type
#1st method(without arg and no return type)
#.............
def add():
num1=int(input("enter a number1"))
num2=int(input("enter a number2"))
sum=num1+nu... |
962aaa4964ae4989cce63115c3ccf6397161a36e | shilpageo/pythonproject | /collections/demo6.py | 96 | 3.59375 | 4 | #insert 1 to 100 elements into a list
lst=[]
for i in range(101):
lst.append(i)
print(lst)
|
e32224443d385bc3aa0b5caa0291a1537e44ff3f | shilpageo/pythonproject | /collections/word count.py | 214 | 3.671875 | 4 | #split line of data can be split into word by word
line="hai hello hai hello"
words=line.split(" ")
dict={}
count=0
for i in words:
if i not in dict:
dict[i]=1
elif i in dict:
dict[i]+=1
print(dict) |
fa492076ecbfed6856da7e20a3bf7a06464dbdb3 | shilpageo/pythonproject | /functional programming/lambda fn.py | 844 | 4.0625 | 4 | #lambda keyword is used
#ad=lambda num1,num2:num1+num2
#print(ad(10,20))
#function
#---------
#def sub(num1,num2):
# return num1-num2
#lambda function
#----------------
#sub=lambda num1,num2:num1-num2
#print(sub(20,13))
#mul=lambda num1,num2:num1*num2
#print(mul(10,20))
#div=lambda num1,num2:num1/num2
#prin... |
10145e2e0f1a58ea60288828d7c09f87399ca253 | ngocthuan94/Python-Thuan-2 | /myFirstPython/first.py | 118 | 3.828125 | 4 | print('hello from a file')
print( 'My name is Thuan. Have a nice day!')
x= 20
while x > 3:
print (x)
x -= 3
|
e9aa4621abbe5b8b60fa7bc02b3a54ba2f42531a | sharmar0790/python-samples | /misc/findUpperLowerCaseLetter.py | 241 | 4.25 | 4 | #find the number of upper and lower case characters
str = "Hello World!!"
l = 0
u=0
for i in str:
if i.islower():
l+=1
elif i.isupper():
u+=1
else:
print("ignore")
print("Lower = %d, upper = %d" %(l,u)) |
94f1c45ba972a5e598b11d8db7068135ccdcc79b | sharmar0790/python-samples | /graphing/barGraphPlotting.py | 654 | 3.546875 | 4 | import matplotlib.pyplot as p
import csv,numpy as np
list_hurricanes = list()
list_year = list()
with open("../data/Hurricanes.csv", mode="r") as h:
reader = csv.DictReader(h)
for row in reader:
print(row)
list_hurricanes.append(row.get("Hurricanes"))
list_year.append(row.get("Year"))
... |
4b6bf4b0865f101b5545c7cb1033c5738c33dc3b | sharmar0790/python-samples | /misc/factors.py | 267 | 4.28125 | 4 |
nbr = int(input("Enter the number to find the factors : "))
for i in range(1, nbr+ 1 ):
if (nbr % i == 0):
if i % 2 == 0:
print("Factor is :", i , " and it is : Even")
else:
print("Factor is :", i , " and it is : Odd")
|
916ae65531ca61db7f61c5c0b30f8f7c0f5ca99c | MorphisHe/NumericalAnalysis | /linear_algebra/linear_system/gauss_elimination.py | 1,776 | 3.640625 | 4 | '''
Author: Jiang He
SBU ID: 111103814
'''
import time
import numpy as np
'''
A is a matrix (square)
B is a col vector
'''
def forward_elimination(A, b):
'''
N = len(A)
for j in range(N-1):
for i in range(j+1, N):
mij = A[i][j] / A[j][j]
for k in range(j, N):
... |
4de948a13a9c7415536a74070b4f4792108e7e40 | createwv/exploring_python | /language/variables/functions_main.py | 107 | 3.53125 | 4 | def add_numbers(first_num, second_num):
sum = first_num + second_num
return sum
print(add_numbers(1,2))
|
560998d4f73fc42ba65c869a1ba50160f59600dc | Vinicius-Tessaro/Python | /solar_yesol.py | 1,454 | 3.609375 | 4 | con_t = float (input ('Digite o valor do consumo total(em KWh): '))
qnt_f = int (input ('Digite a quantidade de fases do motor: '))
con_r = float
if qnt_f == 1:
con_r = con_t-30
elif qnt_f == 2:
con_r = con_t-50
else:
con_r = con_t-100
con_rd = float (con_r/30)
hrs_sp = float (input ('digite Horas sol p... |
6772ec2535d0416e96d0d0a82cdc3359ba8c1341 | 603627156/python | /day-01/03-练习-求最大值.py | 458 | 3.5625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time :
# @Author : tangbo
# @Site :
# @File :
# @Software:
#求这个list的最大的两个值
list = [1,2,3,2,12,3,1,3,21,2,2,3,4111,22,3333,444,111,4,5,777,65555,45,33,45,5000]
#方法一、
list.sort()
print(list[-2:])
#方法二、
max = 0
max1 = 0
#max_list = []
for i in list:
if max<... |
4cbdbc1b64a1500d6c1f02ee3f665a0721f6f6e8 | jblazzy/Weather | /Weather.py | 2,346 | 4.03125 | 4 | """
-- Weather.py
-- Josh Blaz
-- Denison University -- 2019
-- blaz_j1@denison.edu
"""
import requests
import datetime
import calendar
def UnixConverter(timestamp):
"""
Converts Unix Timestamps to readable time.
See https://timestamp.online/article/how-to-convert-timestamp-to-datetime-in-python for Unix-t... |
8ca83b341856182afc219534f0f80040a639eb7a | mareis/inf1-2021 | /Thonny/oppgaver3_1.py | 338 | 3.921875 | 4 | tall1 = float(input("Skriv in et tall: "))
talle = float(input("Skriv in et tall til: "))
if tall1 > tall2:
print(f'{tall1} er større enn {tall2}.')
#print(tall1, "er større enn", tall2)
elif tall2 > tall1:
print(f'{tall2} er større enn {tall1}.')
elif tall1 == tall2:
print(f'{tall1} er lik {tall... |
0fffed88c100ea269eb0c1da41846323a0003698 | mareis/inf1-2021 | /Thonny/input_og_sqrt.py | 156 | 3.734375 | 4 | from math import sqrt
n = input("Skriv iunn det du ønsker å ta kvadratroten till: ")
n = int(n)
kvadratrot = sqrt(n)
print("kvadratroten er", kvadratrot) |
a182d55b5efe26137379a07556a8a04e001878fc | MehmetCanBOZ/AI_minimaxalgoritm_tictoctoe_game | /tictactoe.py | 3,532 | 3.890625 | 4 | """
Tic Tac Toe Player
"""
import math
X = "X"
O = "O"
EMPTY = None
def initial_state():
"""
Returns starting state of the board.
"""
return [[EMPTY, EMPTY, EMPTY],
[EMPTY, EMPTY, EMPTY],
[EMPTY, EMPTY, EMPTY]]
def player(board):
"""
Returns player who has the next ... |
5f364e19483cf86257903c17167941a190da1bd8 | traders-see/pytohn1 | /program/if for .py | 1,819 | 3.625 | 4 | # if的意思(如果)的意思, 他的输出必须是布尔值,
'''
if 条件A满足布尔值
elif 条件B满足布尔值
elif 条件C满足布尔值
else 以上所有条件都不满足的时候执行
'''
# symbol = 'btcusd'
# if symbol.endswith('usd'): # a条件
# print(symbol, '美元计价')
# elif symbol.endswith('btc'): # b条件
# print(symbol, '比特币计价')
# elif symbol.endswith('eth'): # c条件
# print(symbol, '以太坊计价')... |
3f4868748b96cde0ad69c6724fbc780f11489d27 | CapsLockAF/python--tqa-hw-tasks | /p1/task4-pythoncore-CapsLockAF/src/squares_sum.py | 155 | 3.578125 | 4 | def squares_sum(n):
# Type your code
count = 1
res = 0
while count <= n:
res += count**2
count += 1
return res
|
b9bff2a8e344dabb03de95bfd95e9f2ac59f1cc5 | WillLuong97/MultiThreading-Module | /openWeatherAPI.py | 4,137 | 3.75 | 4 | '''
OpenWeatherMap API, https://openweathermap.org/api
by city name --> api.openweathermap.org/data/2.5/weather?q={city name},{country code}
JSON parameters https://openweathermap.org/current#current_JSON
weather.description Weather condition within the group
main.temp Temperature. Unit Default: Kelvin, Metric... |
66c870b15db3040c1030deb637c4e5b8998897ff | bukovskiy/Coursera-Data-Structures-and-Algorithms-Specialization | /algorithmic_toolbox/week2/fibonacci.py | 400 | 3.921875 | 4 | # Uses python3
def fibNonRecursive(n):
counter = 1
array=[0,1]
while counter < n:
number = array[counter]+array[counter-1]
# print(number)
counter = counter+1
array.append(number)
return array[-1]
def main():
c = {0:0,1:1,2:1}
n = int(input())
p... |
8fc1a31146fa1377e33283d271c58144c5492a41 | Muha-tsokotukha/PyGame | /TSIS-6/11.py | 170 | 3.765625 | 4 | def perf(a):
summ = 1
x = 2
while x <= a:
if a % x == 0:
summ += x
x += 1
return summ/2 == a
x = int(input())
print(perf(x))
|
9f4e38cd4a6a1e6f2ec380f64571e72634ddb1a2 | Muha-tsokotukha/PyGame | /week3-4/classing2.py | 410 | 3.671875 | 4 | class transport():
def __init__( self, brand, model ):
self.brand = brand
self.model = model
def brnd(self):
print(self.brand)
class cars(transport):
def __init__(self, brand,model,price):
super().__init__(brand,model)
self.price = price
def prs(self):
... |
2ab5b0f7a4a6071ab828ed713a990ed4b0e8c51f | Muha-tsokotukha/PyGame | /week10_Tsis7/2_3.py | 803 | 3.6875 | 4 | import pygame
pygame.init()
screen = pygame.display.set_mode((480,360))
x = 50
y = 100
done = False
step = 5
while not done:
for events in pygame.event.get():
if events.type == pygame.QUIT:
done = True
press = pygame.key.get_pressed()
if press[pygame.K_UP]: y -=... |
8ea6c2251009090a4b37666cc05741637705ae66 | madinamantay/webdev2019 | /week10/Informatics/3/for/K.py | 76 | 3.53125 | 4 | a = int(input())
s=0
for i in range(a):
s += int(input())
print(s)
|
3cb4b68000a36fb919a7766351baf05f84c1a6a3 | sumi89/Numpy_based_CNN | /cnn_numpy_utils.py | 2,708 | 3.546875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 16 18:09:03 2017
@author: Anthony
"""
import cnn_numpy as layer
def cnn_relu_forward(x, w, b, cnn_param):
"""
A convenience layer that performs a convolution followed by a ReLU.
Inputs:
- x: Input to the convolutional layer
- w, b, conv_param: We... |
3ec1466ffce05f83b108a81a83c5aeef1f999a05 | ethan-douglass/SHSPythonWork | /Chapter 2/Exersises/(2-10) Adding_Comments.py | 296 | 3.671875 | 4 | # Adds a Name to a quote
famous_person = "Albert Einstein"
message = f'{famous_person} once said,"A person who never made a mistake never tried anything new."'
print(message)
#Asks Eric if he wants to learn python
message = "\nHello Eric, would you like to learn some Python today?"
print(message)
|
9b4ca5602cbf2ce9bb25e5d5ce8faa29d7d3e7c2 | wiktoriamroczko/pp1 | /04-Subroutines/z31.py | 107 | 3.859375 | 4 | def reverse(tab):
return tab[::-1]
tab = [2, 5, 4, 1, 8, 7, 4, 0, 9]
print (tab)
print (reverse(tab)) |
3b50eb1cf1d948aeff1a9e9b41cde7f7efaa8b90 | wiktoriamroczko/pp1 | /06-ClassesAndObjects/z7.8.9.py | 683 | 3.703125 | 4 | class University():
# konstruktor obiektu (metoda __init__)
def __init__(self):
# cechy obiektu (pola)
self.name = 'UEK'
self.fullname = 'Uniwersytet Ekonomiczny w Karkowie'
# zachowania obiektu (metody)
def print_name(self):
print(self.name)
def set_name... |
02b28b1caa84961387b5bbdce17aa7dd531afb48 | wiktoriamroczko/pp1 | /10-SoftwareTesting/programs/zadanie6pkt.py | 1,008 | 3.765625 | 4 | class Macierz():
def __init__(self,m,n):
self.m = m
self.n = n
def stworzMacierz(self):
self.macierz = [[0 for a in range(self.m)]for b in range(self.n)]
return self.macierz
def rand(self):
import random
for i in self.macierz:
for j ... |
a0f15910ea6d931d057bc6e61e57b84c28f15622 | wiktoriamroczko/pp1 | /07-ObjectOrientedProgramming/z14.py | 814 | 3.984375 | 4 | class Phone():
def __init__(self, phone_number, brand, operating_system):
self.phone_number = phone_number
self.brand = brand
self.operating_system = operating_system
self.is_on = False
def turn_on(self):
self.is_on = True
def turn_off(self):
... |
88cd3bb80fcae3d0b2630154be9887310cbe9ea9 | wiktoriamroczko/pp1 | /02-ControlStructures/zadanie49.py | 471 | 3.921875 | 4 | print ('| PN | WT | SR | CZ | PT | SB | ND |')
nrDniaTygodnia =3
print ('| '*nrDniaTygodnia, end='')
for i in range(1, 31):
if i < 10:
print ('|', i, end=' ')
elif i >=10:
print ('|', i, end=' ')
if i == 7-nrDniaTygodnia:
print ('|')
if i == 14-nrDniaTygodnia:
print ... |
4a374436c0bf4099eb09579a49d15befe5b27c50 | wiktoriamroczko/pp1 | /07-ObjectOrientedProgramming/z16.py | 710 | 3.75 | 4 | class Student():
def __init__(self, name, surname, album):
self.name = name
self.surname = surname
self.album = album
def __str__(self):
return f'{self.name} {self.surname} {self.album}'
def __eq__(self,other):
return self.album == other.album
... |
fd8b41ce2736ce7e7818be2855f5b4bd01b64db1 | wiktoriamroczko/pp1 | /02-ControlStructures/1.py | 357 | 3.78125 | 4 | x = int(input('wprowadź liczbę: '))
if x % 2 == 0 and x >= 0:
print (f'{x} jest liczbą parzystą i dodatnią')
elif x % 2 == 0 and x < 0:
print (f'{x} jest liczbą parzystą i ujemną')
elif x % 2 != 0 and x >= 0:
print (f'{x} jest liczbą nieparzystą i dodatnią')
else :
print (f'{x} jest liczbą niepa... |
628b0675e9e0ce68c1b7f212ac66fc26c1f6b1e8 | wiktoriamroczko/pp1 | /01-TypesAndVariables/BMI.py | 287 | 3.9375 | 4 | height = int(input("Podaj wzrost w cm:"))
x = height/100
weight = int(input(("Podaj wagę w kg:")))
bmi = weight/x**2
print (f"wskaźnik BMI: {bmi}")
if bmi >= 18.5 and bmi <= 24.99:
print ("waga prawidłowa")
elif bmi< 18.5:
print ("niedowaga")
else:
print ("nadwaga")
|
fa2a9583c449a012a6ed19295f87e00d94b79bc1 | wiktoriamroczko/pp1 | /02-ControlStructures/zadanie39.py | 92 | 3.546875 | 4 | a = 0
b = 1
c = 0
for i in range(51):
print(a, end=' ')
c = a+b
a = b
b = c |
4f5fa5eb22637e05980a2e6c97f7f19e691540ac | Svengeelhoed/nogmaals | /duizelig/duizelig5.py | 228 | 3.609375 | 4 | banaan = input("vindt u ook bananen lekker?")
poging = 1
print(poging)
while banaan != "quit":
banaan = input("vindt u ook bananen lekker?")
poging = poging + 1
print(poging)
if banaan == "quit":
quit()
|
8c18d8b92868feb42bc1570ee7d5dd5f9fc3d757 | RomyNRug/pythonProject2 | /Week 4/Week 4.py | 1,186 | 3.9375 | 4 | import turtle
def draw_multicolor_square(animal, size):
for color in ["red", "purple", "hotpink", "blue"]:
animal.color(color)
animal.forward(size)
animal.left(90)
def draw_rectangle(animal, width, height):
for _ in range(2):
animal.forward(width)
animal.left(90)
... |
cbc542bd2d87fe3291b7b58cfac7ad584ca0037c | RomyNRug/pythonProject2 | /Week 5/Exercises5.4.6.py | 987 | 3.84375 | 4 | #1
def count_letters(text):
letter_counts = {}
for letter in text.lower():
if letter.isalpha():
if letter not in letter_counts:
letter_counts[letter] = 1
else:
letter_counts[letter] += 1
return letter_counts
def print_letter_counts(letter_cou... |
a2f83dfcfdc486d479192c74fffe1b9ca6c7b82c | scmartin/python_utilities | /GAOptimizer/population.py | 8,594 | 3.5625 | 4 | # ToDo:
# - redesign evolution algorithm to create a new population
# without replacing any of the old population. Then, take
# top 50% of parent and child populations
# - add threading for creating child population
# - add convergence criteria
#
import numpy as np
from abc import ABC, abstractmethod
import xml.et... |
3b084397643d6a5276f75f7b4abe42e7b487ccd3 | trup922/ExtractCompetitorKeywords | /venv/Include/FindKeywords.py | 4,289 | 3.5625 | 4 | import requests
from bs4 import BeautifulSoup
from urllib.parse import urljoin
import re
import heapq
import difflib
#helper function for removing all occurences of an item from a list, will come in hand when we will filter out certain words from a string
def remove_values_from_list(the_list, val):
return [value fo... |
e4abf277d6f7e139a1a8c52d0101707400a92396 | Marcbaer/02.01.Deploying_Forecasting_Model_using_AzureML_SDK | /Train_LSTM.py | 735 | 3.515625 | 4 | import matplotlib.pyplot as plt
from LSTM_LV import Lotka_Volterra
#Define model and training parameters
n_features=2
n_steps=12
hidden_lstm=6
Dense_output=2
epochs=250
#Lotka Volterra data parameters
shift=1
sequence_length=12
sample_size=2000
#Build, train and evaluate the model
LV=Lotka_Volterra(shift,seq... |
8d1ae76c20631b26a86436a0a4a02a0fdb73699a | nedchewnabrJCU/Sandbox | /Finished Practicals/prac_02/randoms.py | 917 | 4.09375 | 4 | import random
print(random.randint(5, 20)) # line 1
print(random.randrange(3, 10, 2)) # line 2
print(random.uniform(2.5, 5.5)) # line 3
# What did you see on line 1?
# The number seen was "5".
# What was the smallest number you could have seen, what was the largest?
# Smallest number is "5", largest numbe... |
0fec5b9ccde19b79c8751870433d1c3fad64c483 | gauravthadani/ml-learning | /python/demo_dtc.py | 800 | 3.953125 | 4 | #Introduction - Learn Python for Data Science #1
#youtube link = https://www.youtube.com/watch?v=T5pRlIbr6gg&t=3s
from sklearn import tree
import graphviz
#[height, weight, shoe size]
X = [[181, 80, 44], [177, 70, 43], [160, 60, 38], [154, 54, 37],
[166, 65, 40], [190, 90, 47], [175, 64, 39], [177, 70, 40], [15... |
18bd45cd6fa90bd71e719888237f80fc44908984 | leonh/pyelements | /examples/a7_generators.py | 801 | 3.875 | 4 | from examples.a1_code_blocks import line
# generators use yield something
def integers():
for i in range(1, 9):
yield i
integers()
print(line(), integers())
# Generator objects execute when next() is called
print(line(), next(integers()))
chain = integers()
print(line(), list(chain))
def squared(seq)... |
b0c33c8848844a6a025ee5c145f1ef1373ba3c30 | x223/cs11-student-work-Aileen-Lopez | /practice_makes_perferct.py | 160 | 4.125 | 4 | number = input("give me a number")
def is_even(input):
if x % 2 == 8:
print True
else:
print False
#can't get it to say true or false
|
ece16e9a25e880eaa3381b787b12cecf86625886 | x223/cs11-student-work-Aileen-Lopez | /March21DoNow.py | 462 | 4.46875 | 4 | import random
random.randint(0, 8)
random.randint(0, 8)
print(random.randint(0, 3))
print(random.randint(0, 3))
print(random.randint(0, 3))
# What Randint does is it accepts two numbers, a lowest and a highest number.
# The values of 0 and 3 gives us the number 0, 3, and 0.
# I Changed the numbers to (0,8) and the res... |
5db2ce733c009c2807c8179ef38c2dae82c46036 | x223/cs11-student-work-Aileen-Lopez | /find_odds.py | 157 | 3.65625 | 4 | list = [3,4,7,13,54,32,653,256,1,41,65,83,92,31]
def find_odds(input):
for whatever in input:
if whatever % 2 == 1:
print "whatever"
|
e12e1a8823861cee15aee0f931bcc4f117d3e514 | KNootanKumar/prototype-for-Notifying-user-of-a-database-through-mail | /youtube_video_list.py | 778 | 3.8125 | 4 | import sqlite3
#print("hello")
conn =sqlite3.connect("Youtube_videos.db")
cur=conn.cursor()
#print("hiii babes")
cur.execute("CREATE TABLE IF NOT EXISTS youtube_videos(id INTEGER,tittle text , url text)")
#print("hello baby")
cur.execute("INSERT INTO youtube_videos VALUES(12,'Video_12','https://www.youtube.com/watch?v=... |
016c7e2da4516be168d3f51b34888d12e0be1c5d | adrian-calugaru/fullonpython | /sets.py | 977 | 4.4375 | 4 | """
Details:
Whats your favorite song?
Think of all the attributes that you could use to describe that song. That is: all of it's details or "meta-data". These are attributes like "Artist", "Year Released", "Genre", "Duration", etc. Think of as many different characteristics as you can.
In your text editor, create ... |
40ec1ba7e942414a776398fba3730f76d3471fb7 | star83424/python-practice | /python-practice/sorting.py | 5,137 | 3.984375 | 4 | def swap(nums, i, j):
tmp = nums[i]
nums[i] = nums[j]
nums[j] = tmp
class SortUtils:
@staticmethod
def bubble_sort(nums):
print(f'start sorting {nums}')
for i in range(len(nums) - 1):
for j in range(len(nums) - 1):
if nums[j] > nums[j+1]:
... |
9987ab52003b44485eca176c04f343d30a0e937a | star83424/python-practice | /python-practice/binary_search_tree.py | 1,984 | 3.921875 | 4 | from sorting import SortUtils
class Node:
def __init__(self, val=None, left=None, right=None):
self.val = val
self.left = left
self.right = right
def print(self):
print(f'val: {self.val}, left: "{self.left}, right: {self.right}')
def build_binary_search_tree(nums):
root =... |
6dba0696232cf84d9d0f5625f8e58972f892d179 | Robo4al/robot | /step.py | 1,606 | 3.546875 | 4 | import time
from machine import Pin
'''
[StepMotor]
Por padrão, ao criar um objeto do tipo StepMotor os pinos utilizados do Roberval serão:
- PIN1 = 18
- PIN2 = 19
- PIN3 = 22
- PIN4 = 23
* Fases do motor:
a) phase IN4 = [0,0,0,1]
b) phase IN4 and IN3 = [0,0,1,1]
c) phase IN3 = [0,0,1,0]
d) phase IN3 and... |
6657511dc98487fd3160d8fbe9bfee4975f5cb6d | mkatzef/difference-checker | /DifferenceChecker.py | 7,078 | 3.8125 | 4 | """ Number base, and to/from ASCII converter GUI. Now supporting Fractions
Author: Marc Katzef
Date: 20/4/2016
"""
from tkinter import *
#from tkinter.ttk import *
class Maingui:
"""Builds the gui in a given window or frame"""
def __init__(self, window):
"""Places all of the GUI elements in th... |
f1dd49c9897bd996a589f1421a058fed769e444d | AnttiVainikka/ot-harjoitustyo | /game/src/UI/move.py | 1,056 | 3.546875 | 4 | # pylint: disable=no-member
import pygame
pygame.init()
from Classes.character import Character
def move(character):
"""Registers if the player presses or releases the arrow keys and configures the main character based on it."""
for event in pygame.event.get():
if event.type == pygame.QUIT:
... |
95b5e8ce6cfb6939b7c7eb12614f655792453046 | kaen98/python_demo | /ChapterFive/5-3.py | 203 | 3.640625 | 4 | alien_color = ['green', 'yellow', 'red']
alien_one = 'green'
if alien_one in alien_color:
print('alien color is green, +5 points')
alien_two = 'white'
if alien_two in alien_color:
print('+5 points') |
1c3ab432c612e27d412d644ff7386660a18a209a | Evohmike/Password-Locker | /Display.py | 8,410 | 4.125 | 4 | #!/usr/bin/env python3.6
from creds import Credentials
from user import User
def create_account(username,password):
'''
This function creates new account
'''
new_user = User(username,password)
return new_user
def save_new_user(user):
'''
This function saves a user
'''
User.save_user(user)
def logi... |
c0fcc2f027faf50b1e329d5f5e4ef07f6228eff3 | mercado-joshua/Tkinter__Program_Password-Generator | /main.py | 3,720 | 3.546875 | 4 | #===========================
# Imports
#===========================
import tkinter as tk
from tkinter import ttk, colorchooser as cc, Menu, Spinbox as sb, scrolledtext as st, messagebox as mb, filedialog as fd
import string
import random
class Password:
"""Creates Password."""
def __init__(self, adjectives, ... |
8e2115c1623bfb4c296b2c4ec8a88ce21dd41e93 | nalin2002/Cryptography-Encryptions | /upload_file_to_googledrive.py | 1,232 | 3.5 | 4 |
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
import os
def Upload_File_GD(filename):
gauth=GoogleAuth()
gauth.LocalWebserverAuth()
drive=GoogleDrive(gauth)
local_file_path=" " # The path of the file in the system
for file in os.listdir(local_file_path):
... |
4da4b5e0a87f9220caa5fb470cac464fe17975cb | aniketpatil03/Hangman-Game | /main.py | 1,650 | 4.125 | 4 | import random
stages = ['''
+---+
| |
O |
/|\ |
/ \ |
Death|
=========
''', '''
+---+
| |
O |
/|\ |
/ |
|
=========
''', '''
+---+
| |
O |
/|\ |
|
|
=========
''', '''
+---+
| |
O |
/| |
|
|
=========''', '''
+---+
| |
O |
... |
6f308a43412f0cdeca2b3764cf5c2b84be15f98e | apostonaut/6.00.1x | /problem_sets/probset2/pay_off_fully.py | 732 | 3.71875 | 4 | def pay_off_fully(balance, annualInterestRate):
"""
Calculates the minimum monthly payment required in order to pay off the balance of a credit card
within one year
:param balance: Outstanding balance on credit card
:type balance: float
:param annualInterestRate: annual interest rate as a decim... |
20694cf0fb96be02c7eb330b5eb4e020d1e162ec | zouzhuo939/python | /冒泡排序.py | 194 | 3.828125 | 4 | # array = [4,5,6,4,6,3,9]
# for i in range(len(array)):
# for j in range(i+1):
# if array[i]<array[j]:
# array[i],array[j]=array[j],array[j]
# print(array)
|
5ef84c9d17063edd0bc3f5351c291cf46b1cf2c0 | qinghao1/cmpe561 | /FST.py | 1,004 | 3.609375 | 4 | class State:
#Transition list is a list of tuples of (input, output, next_state)
def __init__(self, state_num):
self.state_num = state_num
#self.transition is a hashmap of input -> (output, next_state)
self.transition = {}
def add_transition(self, _input, _output, next_state):
self.transition[input] = (_outp... |
4e292f2cd12f9adeb7df2ddc5bdd927b706beef1 | DStar1/word_guessing_game | /srcs/print_graphics.py | 3,497 | 3.59375 | 4 | import os
from termcolor import colored, cprint
class Graphics:
def __init__(self):
self.body_parts = [ colored("O", "magenta", attrs=["bold"]),
colored("|", "green", attrs=["bold"]),
colored("-", "red", attrs=["bold"]),
colored("-", "red", attrs=["bold"]),
colored("/", "blue", attrs=["... |
149ad2636c553b6dd7717586d306a9a343260295 | FredericoTakayama/TicTacToe-Project | /projeto1.py | 5,668 | 4 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#tic tac toe - project1 study python
import os
SQUARE_SPACE_V=5
SQUARE_SPACE_H=9
TABLE_SPACE=29
def draw_x(pos_x,pos_y,table_matrix):
# matrix_x=[[0]*SQUARE_SPACE_H]*SQUARE_SPACE_V
# x=''
# for i in len(matrix_x):
# if i < (SQUARE_SPACE_H/2)... |
b696c672826c50de8f03c45055ca4553031c7f02 | JNFernandes/Python-Scripts | /Tic Tac Toe/player_choice.py | 375 | 4 | 4 | def player_choice(board):
position = int(input('Choose a position from 1 to 9 (ONLY INTEGERS): '))
while position not in range(1,10) or not check_space(board,position):
print('Either you selected an already filled position or the number is out of range! Try again')
position = int(input('Choo... |
b5ab8666d6d080ea2022313f0e484f60fb94a229 | JNFernandes/Python-Scripts | /Morse_Code/main.py | 340 | 3.953125 | 4 | from decode_encode import encoding,decoding
from logo import logo
print(logo)
message = input("Type message to encode: ").upper()
decoding_msg = input("Do you want to decode? Type 'y' for yes or 'n' for no: ").lower()
if decoding_msg == 'n':
encoding(message)
else:
decoding(message,encoding(message))
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.