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 |
|---|---|---|---|---|---|---|
d1c69d4ad8c30b244c23d799ced55a0013e17b0e | preetising/if_else | /pizza.py | 635 | 3.984375 | 4 | day=input("enter the day..")
pizza=input("enter the pizza.....")
if day=="sunday":
if pizza=="large":
print("Browniew")
elif pizza=="medium":
print("garlic stick free")
else:
print("free coke")
elif day=="monday and tuesday":
if pizza=="large":
print("10% discount")
e... |
67dcf2f90962af4a64ae3e0907e051f558755771 | realme1st/Data-structurePython | /linkedlist3.py | 720 | 4.28125 | 4 | # 파이썬 객체지향 프로그래밍으로 링크드 리스트 구현
class Node:
def __init__(self,data,next=None):
self.data=data
self.next = next
class NodeMgmt:
def __init__(self,data):
self.head = Node(data)
def add(self,data):
if self.head == "":
self.head =Node(data)
else:
... |
518b2a75bf00af1119ef3071f02a896e54b190d1 | saji021198/player-set4 | /poweroftwo.py | 92 | 3.546875 | 4 | k=int(input())
import math
l=math.sqrt(k)
if l%2==0:
print("yes")
else:
print("no")
|
647038eb234a649335eaf5e8262891c1ca217968 | lagerfeuer/AdventOfCode2020 | /day08/main.py | 1,503 | 3.609375 | 4 | #!/usr/bin/env python3
from enum import Enum
class Result(Enum):
ENDLESS_LOOP = -1
OK = 0
CONTINUE = 1
class VM:
def __init__(self, code):
self.code = code
self.ip = 0
self.acc = 0
self.visited = set()
def run(self):
result = None
while (result := self.step()) == Result.CONTINUE:... |
fd9f8bc0d47166788a2934bf172deb625b4f1fe4 | lagerfeuer/AdventOfCode2020 | /day10/main.py | 781 | 3.578125 | 4 | #!/usr/bin/env python3
from collections import Counter
from functools import cache
def solve_part1(adapters):
chain = sorted(adapters + [0])
chain.append(chain[-1] + 3)
freq = Counter([b - a for (a, b) in zip(chain, chain[1:])])
return freq[1] * freq[3]
def solve_part2(adapters):
chain = sorted(adapters)... |
d2be3374666d516c41c2b6826fd38646c204a372 | kris-dey/MITx-6.00.2x | /Quiz/4.py | 872 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Jun 22 12:57:16 2018
@author: KrishanuDey
"""
def max_contig_sum(L):
""" L, a list of integers, at least one positive
Returns the maximum sum of a contiguous subsequence in L """
i = 0
j = 0
save = (i,j)
maxI = 0
while i in range(len(L))... |
e9305faae6b79578e601d67c7c2646bced4a6efb | 0wenwu/generic-dynamic-programming-solver | /dna.py | 3,905 | 4 | 4 | """
dna.py
This demos how to solve the DNA alignment problem with the generic DP solver.
The problem is to maximize the total score for aligning a pair of DNA sequences, reward a
score if for a local match, deduct for a substitution, and deduct another score for an
insert or a deletion.
"""
class DnaAlignGame(objec... |
c402b187e35e0c2b69aafd3f26ea0d65f48e4d14 | xcyi2017/exercise | /201777-2.py | 312 | 3.609375 | 4 | from functools import wraps
def outer(func):
@wraps(func)
def wrap(*args, **kwargs):
print('{:*^20}'.format('begin'))
results = func(*args, **kwargs)
print('{:*^20}'.format('end'))
return results
return wrap
@outer
def func1(x,y=1):
return x+y
print(func1(2)) |
51f1eee6f6652714366f4161216fc31ed7f1f6ba | Aleredfer/kata1_morse | /CalculadoraExperimento.py | 3,125 | 3.75 | 4 | from tkinter import *
from tkinter import ttk
class Calculadora(ttk.Frame):
def __init__(self, parent, **kwargs):
ttk.Frame.__init__(self, parent, height=kwargs["height"], width=kwargs["width"])
#Entrada:
self.caracter = IntVar()
self.entrada_entry = ttk.Entry(self, width=15, textv... |
9f8617003dc690f0dd3a2e27cab5ac47686f6004 | Kabirop121/indiastate | /ind.py | 134 | 3.53125 | 4 | import capsta as cp
state = input("Enter state name: ")
st = state.upper()
result = cp.capital.get(st)
print(f"{st} : {result}") |
b8150dd2a9b8ac4a4024d54fc3bba42415a88407 | Andong501/Algorithm-with-Python | /sequentialSearch.py | 369 | 4 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# sequential search
def sequentialSearch(alist, key):
result = []
for i in range(len(alist)):
if alist[i] == key:
result.append(i)
return result
if __name__ == '__main__':
alist = [23, 45, 78, 22, 123, 236, 123, 999]
key = 123
sequentialSearch(alist, key)
#co... |
4b052c08f9372d64e99ea6d07a50d9135f7a50f5 | nail82/final_exam | /batch_perceptron.py | 3,634 | 3.8125 | 4 | """
Ted Satcher
CS 640
Fall 2012
Final Exam
File: batch_perceptron.py
This modulue implements the batch perceptron algorithm.
"""
from __future__ import print_function
import numpy as np
import itertools as it
import make_data as md
import matplotlib.pyplot as plt
def separate(data):
"""Use the batch perceptron... |
c60016079108d6092ac6c9111791071c3cba18d3 | gallaghers18/Software-Design-Work | /webapp/api.py | 5,538 | 3.5625 | 4 | #!/usr/bin/env python3
'''
api.py
Sean Gallagher & David White, May 3, 2018
Adapted from example_flask_app.py by Jeff Ondich
'''
import sys
import flask
import json
import psycopg2
from config import password
from config import database
from config import user
app = flask.Flask(__name__)
def connect():
... |
aa4ce6ecc6fb88420a49637039adcf2a03640141 | Tcydus/010123131 | /assignment_2020-08-05/problem2/Readfile.py | 627 | 3.6875 | 4 | def readText(addr):
with open(addr,'r') as text_data:
data_list =[]
for line in text_data:
line_text = str(line).split("\n")[0]
collect_text = False
expression = ''
for c in line_text:
if collect... |
c11b80c052870d28adbd66c967e35e6a296712a9 | Tcydus/010123131 | /assignment_2020-08-05/problem1/circle_pygame.py | 861 | 3.703125 | 4 |
import pygame
from pygame.locals import *
import math
class Circle:
def __init__(self, x = 0, y = 0, r = 0, linewidth = 0, color = (0,0,0) , zoom = 1 ):
self.x = x
self.y = y
self.color = color
self.zoom = zoom
self.r = int(r *zoom)
self.linewidth ... |
8541a35267eb5a40ed0774366c2a05588da2ba65 | rbirkaur23/sum_of_digits | /digits_sum.py | 166 | 4.0625 | 4 | n=int(input("Enter a number: "))
total=0
while n!=0:
last_digit=n%10
total=total+last_digit
n=n//10
print("Sum of digits of entered number: ",total)
|
e9dc5549b793181d34a4def58995525e72414000 | kirkdotcam/lp-hammertime | /libs/signals.py | 1,288 | 3.734375 | 4 | import csv
# defines up function
def up(ohlc):
"""Returns true/false of whether a row increases in value over the day
Args:
row(ohlc dictionary)
"""
# test whether the stock rose on the day.
if ohlc["close"] > ohlc["open"]:
return True
else:
return False
# def... |
880ca2169d944f3e7646e35e25d81e870bfe22de | alexlu07/AI | /tictactoe/tictactoe.py | 3,643 | 3.9375 | 4 | """
Tic Tac Toe Player
"""
import math
import copy
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 h... |
5d8bb2f89ca565c2da1a1c992634910785c97946 | annkon22/chapter5 | /ex9.py | 483 | 4.09375 | 4 | #Implement the bubble sort using simultaneous assignment
import random, time
def bubble_sort(a_list):
for pass_num in range(len(a_list) - 1, 0, -1):
for i in range(pass_num):
if a_list[i] > a_list[i + 1]:
temp = a_list[i]
a_list[i] = a_list[i + 1]
... |
33b6aad2a090e91c53e69914c0dc8a7568b725c1 | seanpal/Bongo-PythonTest | /task2.py | 1,182 | 3.890625 | 4 | class Person(object):
def __init__(self, first_name, last_name, father):
self.first_name = first_name
self.last_name = last_name
self.father = father
def __str__(self):
return f"{self.father}"
person_a = Person("first_name", "last_name","father")
person_b = Person("fi... |
68c25d060aa5d51c17e529c71c75d2d5f1956a45 | spencertse122/Learning-LearnPythonTheHardWay | /ex34.py | 498 | 4 | 4 | animals =['bear', 'python3.6', 'peacock', 'kangaroo', 'whale', 'platypus']
print(
"""
Instructions:
----------------------------
1. The animal at 1.
2. The third (3rd) animal.
3. The first (1st) animal.
4. The animal at 3.
5. The fifth (5th) animal.
6. The animal at 2.
7. The sixth (6th) animal.
8. The animal at 4.
--... |
ea801878078968a3de91b4df6b92fdb3adb77dde | spencertse122/Learning-LearnPythonTheHardWay | /ex48/ex48/lexicon.py | 1,934 | 4 | 4 | # Defining Game Lexicon
game_lexicon = {
'direction' : ['north', 'south', 'east', 'west', 'down', 'up', 'left', 'right', 'back'],
'verb' : ['go', 'stop', 'kill', 'eat'],
'stop' : ['the', 'in', 'of', 'from', 'at', 'it'],
'numbers' : [i for i in range(0, 10)]}
... |
8b42da94c31fe3e05e9c77c9e286134a93ebcce9 | CaioMassucato/CifraVigenere | /Utils.py | 6,818 | 3.9375 | 4 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
from functools import reduce
from Constantes import IC_portugues, IC_ingles, frequenciasIngles, frequenciasPortugues, dicionario
# Encontra os fatores de um dado número n
def Fatores(n):
return set(reduce(list.__add__,
([i, n//i] for i in range(1, in... |
7a183fdbe4e63ee69c2c204bfaa69be6e7e29933 | demelziraptor/misc-puzzles | /monsters/monsters.py | 2,634 | 4.125 | 4 | import argparse
from random import randint
"""
Assumptions:
- Two monsters can start in the same place
- If two monsters start in the same place, they ignore eachother and start by moving!
- All monsters move at each iteration
- For some reason, the monsters always move in the same order...
- This monster world runs p... |
349cb6b10ae1affa50838b3d88d634101c5553c0 | kwohl/python-multiple-inheritance | /flower-shop.py | 2,628 | 4.125 | 4 | class Arrangement:
def __init__(self):
self.flowers = []
def enhance(self, flower):
self.flowers.append(flower)
class MothersDay(Arrangement):
def __init__(self):
super().__init__()
def enhance(self, flower):
if isinstance(flower, IOrganic):
self.flowers... |
bc496b6ae41555bac85ba5056a35c552d637911a | iashraful/bongo-python-coding-test | /object_depth/main.py | 1,235 | 3.640625 | 4 | #!/usr/bin/env python
def has_next_label(dictionary):
if type(dictionary) == dict:
return True
return False
def is_a_class_object(data):
return hasattr(data, '__dict__')
def object_depth_checker(data, depth=1):
if not isinstance(data, dict):
return False, 'Expected Dictionary.'
... |
610c50765138ffbfd03c2bfbf2c2bb4656e3979c | Ritika-Das/Designs_Using_Python_Turtle | /(1) 24-Point Star.py | 168 | 3.609375 | 4 | import turtle
t = turtle.Turtle()
for c in ['red', 'green', 'blue', 'purple']:
for i in range (1,7):
t.color(c)
t.forward(75)
t.left(90)
t.left(15)
|
947bdaf3046415305c55468b20c454009484832f | bengarlock/weather_tool | /weather_app.py | 682 | 3.65625 | 4 | import requests
import json
from config import api_key
zip_code = "07071"
country_code = "us"
api_url = f"http://api.openweathermap.org/data/2.5/weather?zip={zip_code},{country_code}&appid={api_key()}&units=imperial"
def get_weather():
data = requests.request("GET", api_url).content
output = json.loads(data)
... |
cb3aa374095a3dd0f8c3f83697962e43d8809d61 | becca4011/SW-Expert-Academy | /10804_문자열의 거울상.py | 252 | 3.703125 | 4 | T = int(input())
mirror = {'b' : 'd', 'd' : 'b', 'p' : 'q', 'q' : 'p'}
cnt = 1
for i in range(T):
st = list(input())
st.reverse()
print("#%d" % cnt, end=" ")
for j in st:
print(mirror[j], end="")
print()
cnt += 1 |
269918d17671aef10a44cf6c97805a9509f3ae65 | becca4011/SW-Expert-Academy | /5549. 홀수일까 짝수일까.py | 129 | 3.8125 | 4 | T = int(input())
for i in range(T):
N = int(input())
print("#%d Even" % (i + 1) if N % 2 == 0 else "#%d Odd" % (i + 1))
|
d927fecd196dab0383f022b4a5669a47e7f9fb37 | Oyelowo/GEO-PYTHON-2017 | /assignment4/functions.py | 2,671 | 4.40625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Sep 27 11:15:48 2017
@author: oyeda
"""
##You should do following (also criteria for grading):
#Create a function called fahrToCelsius in functions.py
#The function should have one input parameter called tempFahrenheit
#Inside the function, create a variable called converte... |
6057f2bbd745f706a82e5c1bd48a645497c8520c | Oyelowo/GEO-PYTHON-2017 | /ass3/untitled0.py | 1,496 | 3.75 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Sep 22 08:54:32 2017
@author: oyeda
"""
word = 'lowo'
print word[0]
print word[1]
print word[2]
print word[3]
word2 = "mayor"
for char in word2: print (char)
length = 10
for letter in 'geomatics': length = length + 1
print length
for letter in 'dayom': print (letter)
pri... |
ad92d846cdfd229667bf41543d2a6d30c67599d2 | sebastiankennedy/learning-python | /basic/06/advance2.py | 328 | 3.875 | 4 | movies = {
'妖猫传': ['黄轩', '染谷将太'],
'无问西东': ['章子怡', '王力宏', '祖峰'],
'超时空同居': ['雷佳音', '佟丽娅'],
}
actor = input('你想查询哪个演员?')
for movie, actors in movies.items():
if actor in actors:
print('%s出演了电影%s' % (actor, movie))
|
071c9035acde6768d3626eaed9dd3deff23c90b5 | sebastiankennedy/learning-python | /basic/12/advance.py | 439 | 3.796875 | 4 | class Robot:
name = '瓦力'
username = ''
def __init__(self):
self.username = input('你好,请问贵姓')
print('你好,%s。我是%s。遇见你,真好。' % (self.username, self.name))
def say_wish(self):
content = input('请输出你的愿望')
print(self.username + '的愿望是:')
for i in range(0, 3):
p... |
7a01243e06a7815888231f6d496d52b120b36f8d | Lucimore/JetBrains-Zookeeper | /Problems/Desks/task.py | 355 | 3.796875 | 4 | # Posted from EduTools plugin
# put your python code here
first_group = int(input())
second_group = int(input())
third_group = int(input())
if first_group % 2 != 0:
first_group += 1
if second_group % 2 != 0:
second_group += 1
if third_group % 2 != 0:
third_group += 1
answer = int((first_group + second_grou... |
5e82e7fe6341a2c54e120733a3c56a110dcb5fb8 | Lucimore/JetBrains-Zookeeper | /Problems/Good rest on vacation/task.py | 208 | 3.671875 | 4 | # Posted from EduTools plugin
# put your python code here
days = int(input())
food = int(input())
flight = int(input()) * 2
hotel = int(input())
total = days * food + (days - 1) * hotel + flight
print(total) |
4f7e55665f64bd599980c021b76ed942443b3987 | BoydEBrown/Kata-Samples | /tritype.py | 258 | 3.859375 | 4 | def triangle_type(a, b, c):
tri = [a,b,c]
sorted(tri)
tri.sort()
if tri[0] + tri[1] <= tri[2]:
return 0
elif tri[0]**2 + tri[1]**2 > tri[2]**2:
return 1
elif tri[0]**2 + tri[1]**2 == tri[2]**2:
return 2
else:
return 3
triangle_type(7,4,5)
|
71a2a5492d162b6ccf24bacf2ec859ae36c6763c | PiaNgg/t08.chunga_huatay | /concatenacion.py | 4,186 | 3.96875 | 4 | #ejercicio 01
print("AMOR"+"CRUZ") #se concatena 2 cadenas para ser imprimidas
#ejercicio 02
hola="hola Fids" #asignacion de un valor para la variable hola
print(hola+" deje menos tarea") #se imprime la concatenacion una variable y una cadena
#ejercicio 03
mine="Mi nombre es: " ... |
ca0d0d446cbc2a2cbf3f0f99a4ce6358cb913ccf | PiaNgg/t08.chunga_huatay | /iteracion.chunga.py | 1,211 | 4.15625 | 4 | #EJERCIOIO 1
fruta="Pera"
for i in fruta:
print(i)
print("-----")
#EJERCIOIO 2
fruta="Manzana"
for i in fruta:
print(i)
print("-----")
#EJERCIOIO 3
fruta="platano"
for i in fruta:
print(i)
print("-----")
#EJERCIOIO 4
fruta="Mango"
for i in fruta:
print(i)
print("-----")
... |
72c4e9878a1665b90156257c8762edb73ecb1cdb | suchi-dev/python-practice | /tuples.py | 356 | 3.96875 | 4 | our_tuple = 1,2,3,"A", "B", "C"
print(type(our_tuple))
my_tuple = ("A", "B", "C", "D", 4,5,6)
print(my_tuple[0:3])
#tuples are immutable
our_list = [1,2,3,4,5,6]
our_list[2] = 100
print(our_list)
# my_tuple[2]= 100
A = [1,2,3,4,5]
print(tuple(A))
A = tuple(A)
print(type(A))
(A,B,C) = 1,2,3
print(A)
D,E,F = ['d', 'e', ... |
c4a1ee4f24d23edf5e1889da7fd18dd5c37942da | suchi-dev/python-practice | /slicer.py | 324 | 4.0625 | 4 | #get user email address
email = input("What is your email address?: ").strip()
# get user name
username = email[: email.index("@")]
# get domain name
domain = email[email.index("@")+1:]
#format message
output = "Your user name is {} and your domain name is {}".format(username, domain)
#display output message
print(out... |
ea197989c8030e441b9eb4601ccc236e4f871425 | jedoyt/NBA_MVP_Prediction_Model | /nbaPlayers_StatsScraper.py | 4,560 | 3.59375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Nov 10 21:21:35 2019
@author: jedunalivia
"""
# Import libraries
import requests
from bs4 import BeautifulSoup
import pandas as pd
from datetime import datetime
import os
def scrapeNBAStats(year=datetime.now().year, type='per_game'):
'''
Scrap... |
6dbce3ddcc7d56ae902de1d5126c628cc797a6ae | jixuege/studypython | /day-1/guess_age.py | 284 | 3.6875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#Author: Leon xie
# guess ages games
age = 20
gues_age = int(input("age:")) # str --> int
print(type(gues_age))
if gues_age == age:
print("right!!")
elif gues_age > age:
print("try smaller.....")
else:
print("try bigger...") |
7f9ab9d0e39c8d9fda8e8b41f0d318ebfedadafc | jixuege/studypython | /day2/while练习.py | 397 | 3.828125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#Author: Leon xie
pangzi_age= 22
count = 0
while count <3:
guess_age = input("age:")
if guess_age.isdigit():
guess_age=int(guess_age)
else:
continue
if guess_age >22:
print("guess big")
elif guess_age == 22:
print("guess... |
14265fcb05c67d2b45d8bfe5ccb5f97c8b28295d | Dartnimus/for-Andersen | /name_Vyacheslav.py | 420 | 4.375 | 4 | '''
Составить алгоритм: если введенное имя совпадает с Вячеслав,
то вывести “Привет, Вячеслав”, если нет, то вывести "Нет такого имени"
'''
name = input("Введите имя ")
if name == 'Вячеслав':
print("Привет, {}".format(name))
else:
print("Нет такого имени") |
9a0712847cca30e489ed0adfc3ccdf9ddb560e4c | SangwookCheon/mitocw600SC | /mitocw600SC/problem_set_5/testing.py | 2,087 | 3.796875 | 4 | import string
# # class Test(object):
# # def __init__(self, word):
# # self.word = word
# # def get_word(self):
# # return self.word
# # def if_text(self):
# # return True
# #
# # boy = Test('boy, I am')
# # print boy.get_word()
# #
# # class SubTest(Test):
# # def __init__(self... |
a42ab8aeeae9f79f91e74c3ad09f61d4be210c4b | SangwookCheon/mitocw600SC | /mitocw600SC/problem_set_2/ps2_newton.py | 3,352 | 4.40625 | 4 | # 6.00 Problem Set 2 - Newton (problem 1,2,3)
# Name: Sangwook Cheon
# Collaborators (Discussion): None
# Collaborators (Identical Solution): None
# Time: 1 hour 30 minutes
def evaluate_poly(poly, x):
"""
Computes the polynomial function for a given value x. Returns that value.
Example:
>>> poly = (0.... |
a306a1b7a8c5e1613c62c85985adda0d189c5dfb | stjordanis/TUM_Metaheuristics | /metaheuristics/problem.py | 1,967 | 3.65625 | 4 | import numpy as np
import math
'''
This file represents an instance. Input parameters are n (=number of flights) and m (=number of gates). The data
are created randomly based on formulas proposed by Lim et al. (2005).
'''
# this class only creates instances (objects) of the problem
class Problem:
def __i... |
1c8bba38aa1991129277a4f138d04da511a68bdf | slacr/oslab-archive | /projects/mersenne/trunk/src/m2/examples/llt_worker.py | 4,701 | 3.5625 | 4 | """API for permforming the Lucas Lehmer primality test"""
import time
"""Exception classes for primes()"""
class LucasLehmerError(Exception): pass
class OutOfRangeError(LucasLehmerError): pass
class NotAnIntegerError(LucasLehmerError): pass
def lucas_lehmer(p):
""" Implementation of Lucas Lehmer test to determine ... |
b81c800e12e78fa78c1d185470e34bf52cffd616 | slacr/oslab-archive | /projects/mersenne/trunk/src/llt/generateprimes.py | 2,547 | 3.6875 | 4 | #!/usr/bin/python
"""Script to generate primes and pickle the results
TODO:
- add python's equivalent of getoptlong to this thing so we can
pass command line options.
This script is a driver for primes.py. It takes an integer
from the command line, opens a log file, and calls generate_primes.
Addit... |
3432acb4e6da5c8685d2ff21f30de822b19e2751 | bernardokang/pythonist | /necessary_sufficient_condition.py | 1,368 | 3.734375 | 4 |
"""
necessary condition and sufficient condition::
calculate which condition is necessary for, and sufficient for
디베이트의 영역인 것이지 --왜 그렇게 생각하는지가 중요한거야, 딱 딱 이게 그거고 이게 그거고 그런게 아니라
테크닉은
자체만으로도 되는지(아니면 다른 조건이필요한지 -1)
없으도 가능한지-2
"""
A = input("\n관계를 알고 싶은 첫번째 단어를 입력해\n")
B = input("\n그리고 두번째 단어를 입력해\n")
fset = [ A, B ]... |
e1664d098af743a06471a91a3610ccf67eb06809 | Tsai-Yueh-Ting/AE401-Python | /進階成績運算2.py | 616 | 3.546875 | 4 |
scorelist=[] #
num=int(input("全班人數:"))
for i in range(num):
name=input("輸入姓名:")
grade=input("輸入成績:")
scorelist.append(str(name))
scorelist.append(int(grade))
total=0
for j in range(1,num*2,2):
total=total+scorelist[j]
H=0
L=100
HN="X"
LN="Y"
for g in range(1,num*2,2):
... |
449e2ff454db39dd937484237366bcf8c07f81b0 | Tsai-Yueh-Ting/AE401-Python | /成績試算.py | 398 | 3.75 | 4 | num=input("請輸入人數:")
scorelist = []
最高分=0
最低分=100
for i in range(int(num)):
grade=input("輸入成績:")
scorelist.append(int(grade))
if int(grade)>最高分:
最高分=int(grade)
if int(grade)<最低分:
最低分=int(grade)
print("平均:",sum(scorelist)/int(num))
print("最低分是:",最低分)
print("最高分是:",最高分) |
d05fb5979c088dfdede2f759772c2b489fdceccf | Tsai-Yueh-Ting/AE401-Python | /用while寫烏龜繞蝸牛殼狀走.py | 287 | 3.734375 | 4 | import turtle
T=turtle.Turtle()
T.color('purple')
T.shape('turtle')
canvas=turtle.Screen()
canvas.title('用while寫烏龜繞蝸牛殼狀走')
canvas.bgcolor('violet')
count=0
count=int(count)
while count<300:
T.forward(count)
T.left(5)
count+=0.05
turtle.done() |
6baa2c121d03d1aaccfec3c86589d8954f3d8597 | MennoWiesenekker/Python | /Valuta omrekenen 2.py | 1,741 | 3.703125 | 4 | print("Let op, voer de invoer in met de aangegeven afkortingen. Deze code is hoofdlettergevoelig.")
print("Kies bij het invoeren uit [euro,dollar,gbp,dkk]")
def berekening(invoer,naar,bedrag):
if invoer == "euro":
if naar == "dollar":
return "$" + str("{: .2f}".format(bedrag /100 *116))
... |
a61a41cd8f0ddd88fc387f11970fba949dd07929 | FWRobins/PCPP | /JSON/JSON_requests.py | 3,381 | 3.890625 | 4 | """
Implement CRUD on JSON data via node.js server
"""
import json
import requests
key_names = ['id', 'brand', 'model', 'production_year', 'convertible']
key_widths = [10,15,10,20,15]
def show_head():
"""print headers"""
for (name,width) in zip(key_names, key_widths):
print(name.ljust(width), end='|... |
c84824522e21b09f7dad681e9b984aa75803067b | 109-marzouk/kattis | /nodup/solution.py | 151 | 3.5 | 4 | # https://open.kattis.com/problems/nodup
s = raw_input().split()
i = True
for w in s:
if s.count(w) > 1: i = False; break
print "yes" if i else "no"
|
2eb228366d50dccff0b5d75be03df7b7296f3d2a | barrucadu/phd | /thesis/scripts/venn.py | 878 | 3.546875 | 4 | #!/usr/bin/env python
import sys
def lines(fname):
out = set()
with open(fname, 'r') as f:
for line in f:
out.add(line)
return out
f1 = sys.argv[1]
f2 = sys.argv[2]
f3 = sys.argv[3]
lines1 = lines(f1)
lines2 = lines(f2)
lines3 = lines(f3)
print "In %s: %d" % (f1, len(lines1))
print ... |
46512d7345b798ed5c8f29c4ddc18489dd7c7687 | jshiv/root | /repos/template/template/utils.py | 4,317 | 3.9375 | 4 | import os
import sys
import datetime as dt
import shutil
def create_dir(path, dirDict = {}):
'''
Tries to create a new directory in the given path.
**create_dir** can also create subfolders according to the dictionnary given as second argument.
Parameters
----------
path : string
... |
1c5798fc962e4b2138d1ef673ab2c55ec7a415f8 | AndrewKalil/holbertonschool-machine_learning | /supervised_learning/0x01-classification/4-neuron.py | 2,631 | 4.09375 | 4 | #!/usr/bin/env python3
""" Neuron """
import numpy as np
class Neuron:
"""Neuron Class
"""
def __init__(self, nx):
"""Instantiation method
Args:
nx (int): number of input features to the neuron
"""
if type(nx) != int:
raise TypeError("nx must b... |
f158ca8d94b1e275a907636f81b537fafb09ace4 | AndrewKalil/holbertonschool-machine_learning | /supervised_learning/0x03-optimization/10-Adam.py | 751 | 3.5625 | 4 | #!/usr/bin/env python3
""" Description """
import tensorflow as tf
def create_Adam_op(loss, alpha, beta1, beta2, epsilon):
"""updates a variable in place using the Adam optimization algorithm
Args:
loss is the loss of the network
alpha is the learning rate
beta1 is the weight used for... |
623f9660bb431dd80c842d08d9c6df4b1ee79d41 | AndrewKalil/holbertonschool-machine_learning | /supervised_learning/0x03-optimization/7-RMSProp.py | 759 | 3.78125 | 4 | #!/usr/bin/env python3
""" Description """
import numpy as np
def update_variables_RMSProp(alpha, beta2, epsilon,
var, grad, s):
""" updates a variable using the RMSProp optimization algorithm
Args:
alpha is the learning rate
beta2 is the RMSProp weight
ep... |
39d03f4241cbd869891edcbc2a967c3c429b8201 | AndrewKalil/holbertonschool-machine_learning | /math/0x00-linear_algebra/6-howdy_partner.py | 240 | 3.515625 | 4 | #!/usr/bin/env python3
""" Contains the cat_arrays functio """
def cat_arrays(arr1, arr2):
""" concatenates two arrays """
new_list = list(arr1)
for i in range(len(arr2)):
new_list.append(arr2[i])
return new_list
|
7bc649100dd5978c65b92727fdb1bcae49e4718a | AndrewKalil/holbertonschool-machine_learning | /supervised_learning/0x03-optimization/9-Adam.py | 989 | 3.703125 | 4 | #!/usr/bin/env python3
""" Description """
def update_variables_Adam(alpha, beta1, beta2, epsilon, var, grad, v, s, t):
"""updates a variable in place using the Adam optimization algorithm
Args:
alpha is the learning rate
beta1 is the weight used for the first moment
beta2 is the weig... |
78f5904620ab9b3df545ff6c2ca5d4b3effb9d4e | AndrewKalil/holbertonschool-machine_learning | /supervised_learning/0x13-qa_bot/4-qa.py | 797 | 3.578125 | 4 | #!/usr/bin/env python3
"""Create a basic Q/A input loop"""
question_answer = __import__('0-qa').question_answer
semantic_search = __import__('3-semantic_search').semantic_search
def qa_bot(corpus_path):
"""Create a basic Q/A input loop
corpus_path: is the path to the corpus of reference documents
"""
... |
6654c0ab08c3c9e1923453496bcef787a4a690b7 | AndrewKalil/holbertonschool-machine_learning | /supervised_learning/0x01-classification/multicreate.py | 297 | 3.875 | 4 | #!/usr/bin/python3
nFiles = int(input("Enter the number of files: \n"))
fileType = str(input("Enter the file type (eg: main): \n"))
fileExt = str(input("Enter file extension: \n"))
for i in range(nFiles + 1):
open(str(i) + "-" + fileType + fileExt, "w+")
print("Files creted successfully")
|
8913aa3c08840276a068ebe6b6d6d69afe519167 | AndrewKalil/holbertonschool-machine_learning | /unsupervised_learning/0x02-hmm/1-regular.py | 2,114 | 4.28125 | 4 | #!/usr/bin/env python3
""" Regular Markov chain """
import numpy as np
def markov_chain(P, s, t=1):
"""determines the probability of a markov chain being in a
particular state after a specified number of iterations
Args:
P is a square 2D numpy.ndarray of shape (n, n)
represent... |
74e0dc697df5e4b8f4e99572e8a49eac72d250d0 | AndrewKalil/holbertonschool-machine_learning | /supervised_learning/0x06-keras/13-predict.py | 491 | 3.828125 | 4 | #!/usr/bin/env python3
""" Keras """
import tensorflow.keras as K
def predict(network, data, verbose=False):
"""
makes a prediction using a neural network
:param network: network model to make the prediction with
:param data: input data to make the prediction with
:param verbose: boolean that de... |
b36bf8e444273ec5bdd9730250b3d469cbaf604e | oscarhscc/algorithm-with-python | /程序员面试经典/面试题 01.07. 旋转矩阵.py | 1,759 | 3.859375 | 4 | '''
给定一幅由N × N矩阵表示的图像,其中每个像素的大小为4字节,编写一种方法,将图像旋转90度。
不占用额外内存空间能否做到?
示例 1:
给定 matrix =
[
[1,2,3],
[4,5,6],
[7,8,9]
],
原地旋转输入矩阵,使其变为:
[
[7,4,1],
[8,5,2],
[9,6,3]
]
示例 2:
给定 matrix =
[
[ 5, 1, 9,11],
[ 2, 4, 8,10],
[13, 3, 6, 7],
[15,14,12,16]
],
原地旋转输入矩阵,使其变为:
[
[15,13, 2, 5],
[14, 3, 4, 1... |
5fc27573583583f3a0c081bd5d8fcb0fafa3e415 | oscarhscc/algorithm-with-python | /程序员面试经典/面试题 08.14. 布尔运算 .py | 1,845 | 3.625 | 4 | '''
给定一个布尔表达式和一个期望的布尔结果 result,布尔表达式由 0 (false)、1 (true)、& (AND)、 | (OR) 和 ^ (XOR) 符号组成。实现一个函数,算出有几种可使该表达式得出 result 值的括号方法。
示例 1:
输入: s = "1^0|0|1", result = 0
输出: 2
解释: 两种可能的括号方法是
1^(0|(0|1))
1^((0|0)|1)
示例 2:
输入: s = "0&0&0&1^1|0", result = 1
输出: 10
提示:
运算符的数量不超过 19 个
'''
class Solution(object):
def countE... |
c37ca8bbf429f840b99e8ef30b47ea012d962a25 | oscarhscc/algorithm-with-python | /程序员面试经典/面试题 17.14. 最小K个数.py | 477 | 3.75 | 4 | '''
设计一个算法,找出数组中最小的k个数。以任意顺序返回这k个数均可。
示例:
输入: arr = [1,3,5,7,2,4,6,8], k = 4
输出: [1,2,3,4]
提示:
0 <= len(arr) <= 100000
0 <= k <= min(100000, len(arr))
'''
class Solution(object):
def smallestK(self, arr, k):
"""
:type arr: List[int]
:type k: int
:rtype: List[int... |
0f86187c9843afe254f4b159df8df17e0675440e | oscarhscc/algorithm-with-python | /程序员面试经典/面试题 16.15. 珠玑妙算.py | 1,569 | 3.5625 | 4 | '''
珠玑妙算游戏(the game of master mind)的玩法如下。
计算机有4个槽,每个槽放一个球,颜色可能是红色(R)、黄色(Y)、绿色(G)或蓝色(B)。例如,计算机可能有RGGB 4种(槽1为红色,槽2、3为绿色,槽4为蓝色)。作为用户,你试图猜出颜色组合。打个比方,你可能会猜YRGB。要是猜对某个槽的颜色,则算一次“猜中”;要是只猜对颜色但槽位猜错了,则算一次“伪猜中”。注意,“猜中”不能算入“伪猜中”。
给定一种颜色组合solution和一个猜测guess,编写一个方法,返回猜中和伪猜中的次数answer,其中answer[0]为猜中的次数,answer[1]为伪猜中的次数。
示例:
... |
10bdc4469eed69ca023ea62ae20cfad45fd8a5ef | oscarhscc/algorithm-with-python | /LeetCode/844. 比较含退格的字符串.py | 1,442 | 3.84375 | 4 | '''
给定 S 和 T 两个字符串,当它们分别被输入到空白的文本编辑器后,判断二者是否相等,并返回结果。 # 代表退格字符。
注意:如果对空文本输入退格字符,文本继续为空。
示例 1:
输入:S = "ab#c", T = "ad#c"
输出:true
解释:S 和 T 都会变成 “ac”。
示例 2:
输入:S = "ab##", T = "c#d#"
输出:true
解释:S 和 T 都会变成 “”。
示例 3:
输入:S = "a##c", T = "#a#c"
输出:true
解释:S 和 T 都会变成 “c”。
示例 4:
输入:S = "a#c", T ... |
cfa644b1a44fcbed66ab1e8314bcd8765617b509 | oscarhscc/algorithm-with-python | /LeetCode/463. 岛屿的周长.py | 1,231 | 3.671875 | 4 | '''
给定一个包含 0 和 1 的二维网格地图,其中 1 表示陆地 0 表示水域。
网格中的格子水平和垂直方向相连(对角线方向不相连)。整个网格被水完全包围,但其中恰好有一个岛屿(或者说,一个或多个表示陆地的格子相连组成的岛屿)。
岛屿中没有“湖”(“湖” 指水域在岛屿内部且不和岛屿周围的水相连)。格子是边长为 1 的正方形。网格为长方形,且宽度和高度均不超过 100 。计算这个岛屿的周长。
示例 :
输入:
[[0,1,0,0],
[1,1,1,0],
[0,1,0,0],
[1,1,0,0]]
输出: 16
'''
class Solution(object):
... |
d4c7408abe8032e6b8de8a910ab7235593de9d81 | oscarhscc/algorithm-with-python | /剑指offer/替换空格.py | 733 | 3.90625 | 4 | '''
题目描述
请实现一个函数,将一个字符串中的每个空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。
'''
# 这道题很简单,没什么好说的,替换就完事了。
# 解法1
# -*- coding:utf-8 -*-
class Solution:
# s 源字符串
def replaceSpace(self, s):
# write code here
return s.replace(' ', '%20')
# 解法2
# -*- coding:utf-8 -*-
cl... |
46b464a07b98bd5724b0c919a0405d1c8ff80a1f | oscarhscc/algorithm-with-python | /LeetCode/39. 组合总和.py | 1,325 | 3.734375 | 4 | '''
给定一个无重复元素的数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合。
candidates 中的数字可以无限制重复被选取。
说明:
所有数字(包括 target)都是正整数。
解集不能包含重复的组合。
示例 1:
输入:candidates = [2,3,6,7], target = 7,
所求解集为:
[
[7],
[2,2,3]
]
示例 2:
输入:candidates = [2,3,5], target = 8,
所求解集为:
[
[2,2,2,2],
[2,3,... |
4ab8636bff1e49af3f9ab190ac05b48dedbb0099 | oscarhscc/algorithm-with-python | /剑指offer/变态跳台阶.py | 884 | 3.609375 | 4 | '''
题目描述
一只青蛙一次可以跳上1级台阶,也可以跳上2级……它也可以跳上n级。求该青蛙跳上一个n级的台阶总共有多少种跳法。
'''
'''
因为每次可以跳1-n级台阶,那么我们假设在第n级台阶的跳法数为f(n),
那么f(n) = f(n-1) + f(n-2) + ... + f(2) + f(1),
所以就有f(n-1) = f(n-2) + ... + f(2) + f(1),这样的话就有
f(n) = 2 * f(n-1)
'''
# 解法1
# -*- coding:utf-8 -*-
class Solution:
def jumpFloorII(self, number)... |
8d74f4301bf7991cb074cef06762b89662cbb786 | oscarhscc/algorithm-with-python | /程序员面试经典/面试题 03.01. 三合一.py | 1,990 | 3.875 | 4 | '''
三合一。描述如何只用一个数组来实现三个栈。
你应该实现push(stackNum, value)、pop(stackNum)、isEmpty(stackNum)、peek(stackNum)方法。stackNum表示栈下标,value表示压入的值。
构造函数会传入一个stackSize参数,代表每个栈的大小。
示例1:
输入:
["TripleInOne", "push", "push", "pop", "pop", "pop", "isEmpty"]
[[1], [0, 1], [0, 2], [0], [0], [0], [0]]
输出:
[null, null, null, 1, -1, -1, true]... |
19581628d49147c117f82e698929eb5f44c7cf8e | oscarhscc/algorithm-with-python | /LeetCode/60. 第k个排列.py | 1,363 | 3.65625 | 4 | '''
给出集合 [1,2,3,…,n],其所有元素共有 n! 种排列。
按大小顺序列出所有排列情况,并一一标记,当 n = 3 时, 所有排列如下:
"123"
"132"
"213"
"231"
"312"
"321"
给定 n 和 k,返回第 k 个排列。
说明:
给定 n 的范围是 [1, 9]。
给定 k 的范围是[1, n!]。
示例 1:
输入: n = 3, k = 3
输出: "213"
示例 2:
输入: n = 4, k = 9
输出: "2314"
'''
class Solution(object):
def getPermut... |
e0ec0274319c8697c8b1d6fe5af7eb542cbbf5ba | oscarhscc/algorithm-with-python | /剑指offer/表示数值的字符串.py | 746 | 3.765625 | 4 | '''
题目描述
请实现一个函数用来判断字符串是否表示数值(包括整数和小数)。例如,字符串"+100","5e2","-123","3.1416"和"-1E-16"都表示数值。 但是"12e","1a3.14","1.2.3","+-5"和"12e+4.3"都不是。
'''
# 解法1:正则表达式匹配
# -*- coding:utf-8 -*-
import re
class Solution:
# s字符串
def isNumeric(self, s):
# write code here
return re.match(r"^[\+\-]?[0-9]*(... |
d0273ffbff4d0fc242fa935c5b04f02a691c5bf7 | oscarhscc/algorithm-with-python | /程序员面试经典/面试题 17.04. 消失的数字.py | 663 | 3.65625 | 4 | '''
数组nums包含从0到n的所有整数,但其中缺了一个。请编写代码找出那个缺失的整数。你有办法在O(n)时间内完成吗?
注意:本题相对书上原题稍作改动
示例 1:
输入:[3,0,1]
输出:2
示例 2:
输入:[9,6,4,2,3,5,7,0,1]
输出:8
'''
class Solution(object):
def missingNumber(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if nums ==... |
a6294a87e8243c04b4a2ba59729d7fbad87337b6 | oscarhscc/algorithm-with-python | /程序员面试经典/面试题 16.11. 跳水板.py | 920 | 3.859375 | 4 | '''
你正在使用一堆木板建造跳水板。有两种类型的木板,其中长度较短的木板长度为shorter,长度较长的木板长度为longer。你必须正好使用k块木板。编写一个方法,生成跳水板所有可能的长度。
返回的长度需要从小到大排列。
示例:
输入:
shorter = 1
longer = 2
k = 3
输出: {3,4,5,6}
提示:
0 < shorter <= longer
0 <= k <= 100000
'''
class Solution(object):
def divingBoard(self, shorter, longer, k):
"""
... |
75464f7bfb40c0fe0fe3fffc11dd31799b991f02 | oscarhscc/algorithm-with-python | /程序员面试经典/面试题 10.11. 峰与谷.py | 859 | 4.03125 | 4 | '''
在一个整数数组中,“峰”是大于或等于相邻整数的元素,相应地,“谷”是小于或等于相邻整数的元素。例如,在数组{5, 8, 6, 2, 3, 4, 6}中,{8, 6}是峰, {5, 2}是谷。现在给定一个整数数组,将该数组按峰与谷的交替顺序排序。
示例:
输入: [5, 3, 1, 2, 3]
输出: [5, 1, 3, 2, 3]
提示:
nums.length <= 10000
'''
class Solution(object):
def wiggleSort(self, nums):
"""
:type nums: List[int]
:rtype: No... |
1be2caed8549931b1729c447abe5b10e61e3fd38 | oscarhscc/algorithm-with-python | /剑指offer/链表中环的入口结点.py | 1,411 | 3.640625 | 4 | '''
题目描述
给一个链表,若其中包含环,请找出该链表的环的入口结点,否则,输出null。
'''
'''
运用快慢双指针,如果两个指针相遇,那么证明链表中存在环。
A-------B-------
| |
C-------
假设有环,在C点相遇。这个时候快指针走的路程为:AB + k * (BC + CB) + BC,
慢指针走的路程为:AB + BC。因为快指针走的路程为慢指针的2倍,所以有:
AB + k * (BC + CB) + BC = 2 * (AB + BC)
所以有 AB = k * (BC + CB) - BC ==> AB = (k-1) * (BC + CB) + CB... |
5050f231ae598b846a683215a60d80c2239072c1 | oscarhscc/algorithm-with-python | /剑指offer/求1+2+3+...+n.py | 343 | 3.71875 | 4 | '''
题目描述
求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。
'''
# 递归的思想进行求和
# -*- coding:utf-8 -*-
class Solution:
def Sum_Solution(self, n):
# write code here
return n and n + self.Sum_Solution(n - 1) |
15ab62a8a9ad2357b0dbca96932da169bac6cab0 | oscarhscc/algorithm-with-python | /程序员面试经典/面试题 08.03. 魔术索引.py | 733 | 3.671875 | 4 | '''
魔术索引。 在数组A[0...n-1]中,有所谓的魔术索引,满足条件A[i] = i。给定一个有序整数数组,编写一种方法找出魔术索引,若有的话,在数组A中找出一个魔术索引,如果没有,则返回-1。若有多个魔术索引,返回索引值最小的一个。
示例1:
输入:nums = [0, 2, 3, 4, 5]
输出:0
说明: 0下标的元素为0
示例2:
输入:nums = [1, 1, 1]
输出:1
提示:
nums长度在[1, 1000000]之间
'''
class Solution(object):
def findMagicIndex(self, nums):
"""
... |
d9d934e204e8a0503d96f17fc16433cc2ba42a2e | oscarhscc/algorithm-with-python | /LeetCode/538. 把二叉搜索树转换为累加树.py | 984 | 4.125 | 4 | '''
给定一个二叉搜索树(Binary Search Tree),把它转换成为累加树(Greater Tree),使得每个节点的值是原来的节点值加上所有大于它的节点值之和。
例如:
输入: 原始二叉搜索树:
5
/ \
2 13
输出: 转换为累加树:
18
/ \
20 13
'''
# Definition for a binary tree node.
# class TreeNode(object):
#... |
284d316afe2296d87660447f7087dd3566a64a08 | oscarhscc/algorithm-with-python | /LeetCode/129. 求根到叶子节点数字之和.py | 1,744 | 3.9375 | 4 | '''
给定一个二叉树,它的每个结点都存放一个 0-9 的数字,每条从根到叶子节点的路径都代表一个数字。
例如,从根到叶子节点路径 1->2->3 代表数字 123。
计算从根到叶子节点生成的所有数字之和。
说明: 叶子节点是指没有子节点的节点。
示例 1:
输入: [1,2,3]
1
/ \
2 3
输出: 25
解释:
从根到叶子节点路径 1->2 代表数字 12.
从根到叶子节点路径 1->3 代表数字 13.
因此,数字总和 = 12 + 13 = 25.
示例 2:
输入: [4,9,0,5,1]
4
/ \
9 0
... |
f3ba8d69055d3fc6f314f38dba62609f5a55cae1 | Excalibur79/My-CodeChef-Solutions | /democodechef.py | 83 | 3.671875 | 4 |
while True:
ele = int(input())
if ele == 42:
break
print(ele)
|
1632e51b421d98056ded658e05af2be9b9f11dc4 | Excalibur79/My-CodeChef-Solutions | /secondmax.py | 272 | 4.03125 | 4 | temp=0
arr=[]
n=int(input("Enter the number of elements-"))
print("Enter the elements\n")
for i in range(n):
arr.append(int(input()))
max=arr[0]
for j in range(1,n,1):
if arr[j]>max:
temp=max
max=arr[j]
print("The second maximum number is:",temp)
|
636a9a2202c1ee98af501041515a813c7955db17 | mniesiolowski/WSB_LAB2 | /Lab2_OdwrotnaKolejnosc.py | 174 | 3.6875 | 4 |
print("Wpisz słowo, które ma zostać wyświetlone w odwrotnej kolejności:")
x = input()
l_x = len(x)
for i in range(l_x, 0, -1):
print(x[::-1])
|
87d9b994c1711d4912e688e3f6840d4387ccede7 | radhadevulapally/Python-HW | /pypoll/pypoll_main.py | 1,713 | 3.90625 | 4 | #importing required libraries
import csv
#Declaring variables and lists to place new values
total_votes = 0
persons = {}
candidates_percent_dict = {}
winner = "NONE"
count = 0
candidate_votes_dict= {}
#Reading the given CSV file
myfile='data.csv'
with open (myfile,'r') as csv_file:
csv_reader=csv.reader(csv_file,del... |
693d779efd4d0067ed9266dec2912dc61024eb1c | Nofiya-Gandhi/listofpositive | /positive.py | 250 | 4.09375 | 4 | #input numbers
inputlist = input("Enter numbers saperated by space:")
list1=inputlist.split()
list2=[]
for element in list1:
if int(element) > 0:
list2.append(int(element))
print("\nlist of positive numbers: \n")
print(list2)
|
fba36c0d75af67de50f03709cc636113ed895810 | bkleeman/STEP-suggestions | /quantification.py | 11,018 | 3.625 | 4 | from collections import defaultdict
from math import atan, sqrt
import numpy as np
def quantify(tracked_storms: np.ndarray, precip_data: np.ndarray, lat_data: np.ndarray, long_data: np.ndarray,
time_interval: float, pixel_size: float) -> tuple:
"""Quantitatively describes individual storms in terms o... |
d87445e936b1f14de2f84cd644571e5bd96452dc | lusaisai/RandomPlayer | /src/audio.py | 1,803 | 3.53125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Sep 22 13:53:09 2012
@author: lusaisai
This program will randomly pick songs to play, numbers of songs and search pattern can be provided.
In the backend, a sqlite db is needed, in which there's table called music with only one column full_path.
The sqlite db can be created ... |
5210d0ede0d5803b6d3cf8e4b1c1caa99d39b652 | mogalter/AdventOfCode2020 | /Day-5/Python_Day5_Part1_Solution.py | 897 | 3.890625 | 4 | def get_mid(start, end):
return (start+end)//2
def find_seats():
seat_ids = open("seating.txt", "r")
highest_seat = float('-inf')
rows = 128
cols = 7
for seating_instruct in seat_ids:
seating_instruct = seating_instruct.strip()
rows_end = rows
rows_start = 0
cols_end = cols
cols_start = 0
for step in... |
abec848bf2d01987e21f03f704d622e9e1edf900 | mogalter/AdventOfCode2020 | /Day-5/Python_Day5_Part2_Solution.py | 1,275 | 3.828125 | 4 | def get_mid(start, end):
return (start+end)//2
def find_seats():
seat_ids = open("seating.txt", "r")
rows = 128
cols = 7
boarded = []
for seating_instruct in seat_ids:
seating_instruct = seating_instruct.strip()
rows_end = rows
rows_start = 0
cols_end = cols
cols_start = 0
for step in seating_instruc... |
8e37445c1a21cc8fe452facf156647b6fed44ae7 | Blackbird002/Spring2017-CS410 | /Pgm6/program6.py | 6,165 | 3.921875 | 4 | #Riad Shash (Ray)
#ID: n845y337
#Program #6
#CS 410
#Description:This program encode/decodes zipcodes/barcodes that it reads from a user specified file.
#The user has two choices when the program starts: either encode a zip code(s) or decode bar code(s)
#When saving to a file, this program puts a zip code/bar co... |
26144b4784b9602b473a8d1da19fe8b568fdc662 | blackdragonbonu/ctcisolutions | /ArrayStringQ3.py | 948 | 4.4375 | 4 | '''
The third question is as follows
Write a method to decide if two strings are anagrams or not.
We solve this by maintaining counts of letters in both strings and checking if they are equal, if they are they are anagrams. This can be implemented using a dictionary of byte array of size 26
'''
from collections impor... |
308251bd470c1e01b7b040cb5befb54a9af8035a | blackdragonbonu/ctcisolutions | /ArrayStringQ4.py | 388 | 4.0625 | 4 | '''
The problem statement
Write a method to replace all spaces in a string with ‘%20’
'''
def simple_solution(str):
return str.replace(' ',"%20")
def solutions(str,method):
if method=="simple_solution":
print ("The modified string is {0}".format(simple_solution(str)))
if __name__=="__main__":
str=input("En... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.