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 |
|---|---|---|---|---|---|---|
7b212d9286819cbb2d01df249eba9f299a312336 | rahulcse1/MachineLearning | /src/python_tutorial/basic.py | 1,099 | 3.890625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 9 18:59:37 2022
@author: amar
"""
welcome = '''
Hello world
this is amar jeet
we are learning python for machine learning
i am a backend developer
java spring boot microservices react
'''
print (welcome)
s_demo = 'amarjeet'
... |
d55a6fe5c29b7afd3054c5bf51020127eb4b34b3 | joelgarzatx/portfolio | /python/HandlingDatabases_Homework/src/handlingdatabase.py | 1,018 | 3.890625 | 4 | """
Program verifies that every animal eats at least one food.
My approach to answering the question is to count the number
of animals, then compare that count with the number of those
animals appearing with a minimum of one food item.
"""
import mysql.connector
from database import login_info
if __nam... |
85a51d61b732376117df72a995fa2ec336b07de0 | joelgarzatx/portfolio | /python/Lesson04_Homework/src/guess.py | 523 | 3.671875 | 4 | # The fun part here was matching the output, and not printing the hint to guess higher or lower on the fifth try.
secret = 12
usertry = 0
while True:
uin = int(input("Guess a number: "))
usertry += 1
if uin == secret:
print("Correct! Well done, the number was", secret)
break
e... |
ef00297b73a78574e2e9dae9306dcbdfab4c9bae | joelgarzatx/portfolio | /python/Python4_Homework07/src/addarg_decorator.py | 640 | 3.5625 | 4 |
def addarg(first_arg):
"Returns a decorator that inserts a first argument."
def func_dec(f):
"Decorates a function to insert a first argument"
def func_prepend(*args, **kwargs):
"Inserts a first argument"
return f(first_arg, *args, **kwargs)
return func_p... |
7a4f8c8d68bd58f1cd327f3e41bc09329a5c3e6a | joelgarzatx/portfolio | /python/Python3_Homework03/src/decoder.py | 752 | 4.125 | 4 | """
Decoder provided function alphabator(list) accepts an integer list,
which returns the list of integers, substituting letters of the alphabet
for integer values from 1 through 26
"""
def alphabator(object_list):
""" Accepts a list of objects and returns the objects from
the list, replacing inte... |
7bcc1c5d342cdbc29ae5c927832e8a3ff655c6f1 | joelgarzatx/portfolio | /python/Python4_Homework09/src/module_inspector.py | 474 | 3.625 | 4 | '''
This code imports a module and will print a list of functions in the module
in the format of the function name and argument, as it would appear in a
def statement.
'''
import smtplib as m
import inspect
lst_of_functions = inspect.getmembers(m, inspect.isfunction)
for function in lst_of_functions:
... |
492654ed8361cedecc75d5ef2ee0ad96653a3fd1 | joelgarzatx/portfolio | /python/jgarza.147.6538.1.Python3_Homework01/src/adder.py | 301 | 3.828125 | 4 | '''
adder.py: adder function that adds together two integer type object
Integer values as string or float are not accepted.
'''
import numbers
def adder(a, b):
if isinstance(a, numbers.Integral) and isinstance(b, numbers.Integral):
return a + b
else:
raise TypeError |
74346a945e98271381e5b224a5c1ed0ad772efac | sejvlpet/multi_pacman | /game.py | 3,295 | 3.625 | 4 | import grid
import MCTS
"""
This file contains methods for game play
"""
def getDistance(pos1, pos2):
return abs(pos1[0] - pos2[0]) + abs(pos1[1] - pos2[1])
def valid(row, col, maze):
return row < len(maze) and col < len(maze[0]) and row >= 0 and col >= 0 and maze[row][col] != grid.WALL
def getNeighbo... |
43f22a35020251b59c412161f7dd738a7347e43a | Trietptm-on-Security/Write-up | /Hack-me-if-you-can-3/Crypto-Stegano/Script for Sudoku.py | 751 | 3.671875 | 4 | import Image
image = Image.open("map.png")
result = Image.open("map.png")
def move(row1, col1, row2, col2):
xsize, ysize = image.size
delta_x = xsize / 9
delta_y = ysize / 9
part1 = image.crop(((col1 - 1)*delta_x, (row1 - 1)*delta_y, col1*delta_x, row1*delta_y))
result.paste(part1, ((col2 - 1)*delta... |
667f43f7f74b4735843e24cc47b0f0a793c6a7b8 | kyletau67/tauK | /03_occupation/portendGreatness_tangM-tauK.py | 1,294 | 3.5 | 4 | #Portends Greatness -- Michelle Tang and Kyle Tau
#SoftDev1 pd 6
#K06 -- StI/O: Divine your Destiny!
#2018-09-13
import csv
import random
file = open("occupations.csv", "r") #open and read the file
occupations = file.readlines() #lines of the file are put into the list, occupations
file.close() #close the file since... |
276598db137491a92ed2961de1d82939e97efed2 | bronyamcgrory1998/Selection-Statements | /3.4 selection.py | 415 | 3.875 | 4 | #Bronya McGrory
#2.4
#04/10/14
mark= int(input("what was the mark?"))
if mark <=40:
print ("you recieved a U")
elif mark <=50:
print ("you recieved a E")
elif mark <=60:
print ("you recieved a D")
elif mark <=70:
print ("you recieved a C")
elif mark <=80:
print ("you recieved a B")
elif mark... |
bb47cb2a447892832f217c28d2570902d1c9709e | AdamBorg/PracCP1404 | /Prac03/asciiTable.py | 774 | 4.21875 | 4 | def main():
lower = 33
upper = 127
num_entered = get_number(lower,upper)
print("{:>3} {:>6} \n".format(num_entered, chr(num_entered)))
print_ascii_table(lower, upper)
def get_number(lower,upper):
num_entered = 0
exit_character = 'e'
while num_entered < 33 or num_entered > 127 or exi... |
b45f5e7b93aa808e159e747802b0de4e723d024b | Okaks/GamingPy | /gaming.py | 1,997 | 4.09375 | 4 | secret_number = 8
guess_limit = 0
guess_count = 0
outOfGuesses = False
def guess_limit(level):
if level == "Easy":
guess_limit = 6
guess_count = 0
guess_count += 1
if level == "Medium":
guess_limit = 4
guess_count = 0
guess_count += 1
if lev... |
e71d8b488cf69f1e7849961e3c9e1f4f1a3fc2d0 | bhupesshhh/GUESS-MY-NUMER | /main.py | 1,555 | 4.0625 | 4 | import random
# Game Initiation
print("GUESS MY NUMBER!!!\n")
print("Number lies between (1-100)\n")
limit = input("Do you wanna start the game? (yes/no)")
if limit.lower() == "yes":
# Start the game with Yes only
gameplay = True
gameon = True
print("\nLet's start the game!\n")
else:
gameplay = False
game... |
35d3cd4df4fa8faa92d994c5a11eff0f2396dcd2 | anner-wang/robot-code | /path_planing/01_path_search.py | 2,481 | 4.03125 | 4 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
# ----------
# User Instructions:
#
# Define a function, search() that returns a list
# in the form of [optimal path length, row, col]. For
# the grid shown below, your function should output
# [11, 4, 5].
#
# If there is no valid path from the start point
# to the goa... |
762c24cd0fd6de8dc4ec599e70d169b01456d670 | patrickbrouwer/winc_backend_opdrachten | /opdracht_005_strings/strings.py | 2,311 | 3.625 | 4 | # 1. maak een variabele aan voor elke speler
# 2. voorbeeld: `hans = 'Hans van Breukelen'`
hans = 'Hans van Breukelen'
print(hans)
berry = 'Berry van Aerle'
print(berry)
frank = 'Frank Rijkaard'
print(frank)
ronald = 'Ronald Koeman'
print(ronald)
adri = 'Adri van Tiggelen'
print(adri)
gerald = 'Gerald Vanenburg'
print(... |
ae2357e9ae0dc6da9f2aef9c4bd6897259cf9018 | sstoudenmier/CSCI-280 | /Assignment5/PathNode.py | 1,798 | 4.15625 | 4 | '''
Class representing a map location being searched. A map location is defined by its (row,
column) coordinates and the previous PathNode.
'''
class PathNode:
def __init__(self, row=0, col=0, previous=None):
self.row = row
self.col = col
self.previous = previous
'''
Gets the row... |
e9ede82bf52bf0aceb23575bc99e0acf5d9a31c0 | L200170157/Prak_ASD | /02_D_157.py | 6,790 | 3.84375 | 4 | """1"""
class Pesan(object):
def __init__(self, sebuahString):
self.teks = sebuahString
def cetakIni(self):
print (self.teks)
def cetakPakaiHurufKapital(self):
print(str.upper(self.teks))
def cetakPakaiHurufKecil(self):
print(str.lower(self.teks))
def jumKar(self):
return len(self.teks)
def ... |
fc10f31f42bfc57448a80fd2ea6edd2de8cf20e1 | KamKhos/HangmanGame | /hangman.py | 2,558 | 4 | 4 | import os
first_game = "Yes"
mistakes = 0
list_of_spaces = []
list_of_spaces_and_letters = []
def word_space_string(word):
emp_list = []
for each_letter in word:
emp_list.append("_")
space_string = " ".join(emp_list)
print(space_string)
def add_letter_to_list(word, space_list, letter_and_spac... |
1a7361a7a16e9251b5402431862cc5701df2af4e | JuanManuEstrada/Programas- | /Tabla.py | 332 | 3.875 | 4 | Numero = input("Dame un numero del 1 al 9: ")
Numero = int(Numero)
# Pedimos la variable del 1 al 9
# Que el valor dado sea en int
for i in range(1,11):
Salida = "{} x {} = {}"
# Se van a multiplicar el numero dado en su tabla
# dando la multiplicacion correcta del 1 al 10
print(Salida.format(Numero,i... |
e9b25b88dfd0896bb238a3bdd05f3bd6ad61d422 | OmarSadigli/Typiing-Speed-Measure-App | /main.py | 3,934 | 3.734375 | 4 | from tkinter import *
import math
from words import words
import random
# --------------- CONSTANTS --------------- #
TEXT_COLOR = "#ff7a00"
BG_COLOR = "#ffefcf"
timer_ = None
wpm = 0
current_high_score = 0
random_word = random.choice(words)
def word_counter(*args):
global wpm, random_word
if... |
b8e0e7bb09098d3470458211331885555a417662 | russian-droid/100DoC_D03 | /main.py | 2,717 | 4.25 | 4 | #following Udemy course: 100 days of code by Angela Yu
number = int(input ('Please enter an intger?\n'))
x=number%2
if x==0:
print ('that is an even nunber')
else:
print ('that is an odd number')
print(x)
#-----------------------------------
print ('\n\n-------WELCOME TO THE BMI CALCULATOR-------')
weight =... |
3a41918c0f0137427561146e947191acd06963a5 | akash639743/Python_Assignment | /Dictionary.py | 912 | 4.5 | 4 | # Dictionary
#1. Create a Dictionary with at least 5 key value pairs of the Student
students={1:"akash",2:"rohit",3:"simran",4:"mohit",5:"sonam"}
print(students)
# 1.1. Adding the values in dictionary
students[6]="soni"
print(students)
# 1.2. Updating the values in dictionary
students.update({7: "mukesh"})
print(... |
b983ae86176ffd7877a2e0b6351249487a5215cd | akash639743/Python_Assignment | /Access_Modifiers.py | 2,223 | 4.125 | 4 | # Access Modeifiers
# 1. Create a class with PRIVATE fields
class Geek:
# private members
__name = None
__roll = None
__branch = None
# constructor
def __init__(self, name, roll, branch):
self.__name = name
self.__roll = roll
self.__branch = branch
# private member function
def __displayDetails(sel... |
258fc52882d3ac5b30881aa07b30b4e1be57625d | akash639743/Python_Assignment | /Array.py | 3,809 | 4.4375 | 4 | # Array
# 1. Write a function to add integer values of an array
from array import *
arr=array('i',[])
n=int(input("Enter the Length of the array"))
for i in range(n):
x =int(input("Enter the Length of the array"))
arr.append(x)
print(arr)
# 2. Write a function to calculate the average value of an array o... |
2a73c06a7ce301eb9bc59146a93cd3af7ee8d566 | jhmanchola/Learning-curve | /Problem-Solving/Showing multiple time zones on axis labels/Showing multiple time zones on axis labels.py | 3,061 | 4.0625 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Show different time zones as labels in a graph
#
# In step 3 of this document, a piece of code was created to allow the x-axis of a graph to show two different time zones for each value.
# ## 1. Create a dataframe to use as an example
# In[6]:
import pandas as pd
import ... |
04bbccf6a949e757cc610df708780a65d0842b72 | adnanshahz2018/Interview-Coding-Problems | /palindromestring.py | 643 | 4.03125 | 4 |
string = 'aaaabbaa'
string = 'racecaracecamadamr'
string = 'abcdefghijklmadamabcdefghijklj'
def find_palindrome(string): # the longest pal wil be string / 2 in length
length = len(string)
count = 0
for z in range(length+1,-1,-1):
for i in range(len(string)-(z-1)): # bigger the c => lesser the i... |
0b732ca9a6a612c6f91f0b86b89a5b96b4035923 | adnanshahz2018/Interview-Coding-Problems | /spiralprint.py | 1,387 | 3.5 | 4 | # COMPLETED
# A = [[1,2,3],
# [4,5,6],
# [7,8,9]]
# A = [ [ 1, 2, 3, 4 ],
# [ 5, 6, 7, 8 ],
# [ 9, 10, 11, 12 ],
# [ 13, 14, 15, 16 ],
# [17, 18, 19, 20],
# [21, 22, 23, 24] ]
A = [[1],[2], [3], [4], [5], [106]]
rowend = row = len(A) # the end bound... |
5cdd44d8fe7aab8641195e65ff9c05a49ff26df7 | adnanshahz2018/Interview-Coding-Problems | /arrayzigzag.py | 668 | 3.5625 | 4 | # COMPLETED
A = [4,3,7,8,6,2,1]
A = list(range(12,20))
A = [11,12,23,24,25,10]
# A = [1,4,3,2]
def zigzag(A):
Z = []
A.sort()
print('sorted = ',A)
if (len(A)%2 == 0):
jump = int(len(A)/2)
print('jump = ', jump)
for i in range(int(len(A)/2)):
Z.append(A[i])
... |
eaf51afa470cdb8bb97633aa5d624075d47ba331 | dieg0varela/holbertonschool-higher_level_programming | /0x06-python-classes/5-square.py | 1,044 | 4.3125 | 4 | #!/usr/bin/python3
"""Define class Square"""
class Square:
"""Class Square"""
def __init__(self, new_size=0):
"""Init Method load size"""
if (isinstance(new_size, int) is False):
raise TypeError("size must be an integer")
if (new_size < 0):
raise ValueError("siz... |
b3e5cf9980169c1f7ef7a2546f79f965d3d34e12 | dieg0varela/holbertonschool-higher_level_programming | /0x0B-python-input_output/9-student.py | 445 | 3.671875 | 4 | #!/usr/bin/python3
'''Student Module'''
class Student:
'''Student Class'''
def __init__(self, first_name, last_name, age):
'''Init function'''
self.first_name = first_name
self.last_name = last_name
self.age = age
def to_json(self):
'''to_json Function'''
d... |
3c8374bfdcac02646aa651cb2eca1f4b79f0dbb9 | thorenscientific/py | /TypeTrip/TypeTrip.py | 422 | 4.15625 | 4 | # A simple script demonstrating duck typing...
print "How trippy are Python Types??"
print "Let's start with x=1...."
x = 1
print "x's value:"
print x
print "x's type:"
print type(x)
print "Now do this: x = x * 1.01"
x = x * 1.01
print "x's value:"
print x
print "x's type:"
print type(x)
print "... |
9f2335a9d22ab13e1f259148491a75432778ac24 | thorenscientific/py | /foundations-of-python-network-programming/python3/09/verbose_http.py | 916 | 3.53125 | 4 | #!/usr/bin/env python
# Foundations of Python Network Programming - Chapter 9 - verbose_handler.py
# HTTP request handler for urllib2 that prints requests and responses.
import io, http.client, urllib.request, urllib.error, urllib.parse
class VerboseHTTPResponse(http.client.HTTPResponse):
def _read_status(self):
... |
38d076f47e15d364f3545da1674ca5601170eec1 | thorenscientific/py | /Simple Programs/8 lines - Command line arguments, exception handling.py | 548 | 3.984375 | 4 | #8 lines - Command line arguments, exception handling
#!/usr/bin/env python
# This program adds up integers in the command line
import sys
#Cool trick to set command line args directly
try:
__file__ # "___file___" is quite literally, the name of this file
print "The name of this file is: ", ___fil... |
149005de27790b81ff33b811650763c776815d50 | thorenscientific/py | /Learn_to_Program_with_Minecraft_Code/chapter12-classes/birdClass.py | 890 | 3.84375 | 4 | class Bird(object):
def __init__(self, name, wingspan):
self.name = name
self.wingspan = wingspan
def birdcall(self):
print("chirp")
def fly(self):
print("flap")
class Penguin(Bird):
def swim(self):
print("swimming")
def birdcall(self):
pri... |
f4d000dfabc55e0e9a2a830e91bb0f6058fc9485 | risaueno/mabuc | /helper.py | 1,016 | 3.640625 | 4 | import time
import numpy as np
def TicTocGenerator():
"""Generator that returns time differences"""
ti = 0 # initial time
tf = time.time() # final time
while True:
ti = tf
tf = time.time()
yield tf - ti # returns the time difference
TicToc = TicTocGenerator()
de... |
d3416936d063012f0ad2dbc0099e37cdc478351c | gentrexha/machine-learning | /Project 1 - Classification/examples/betim_classification.py | 20,699 | 3.671875 | 4 | # post preprocessing supervised classification
# lunch the script and it will guide you
import pandas as pd
import numpy as np
import os
# print('Welcome to the supervised classification script for CAIA vector')
# try:
# cores = int(input('Please enter the number of CPU cores to use (in a simple computer, better to ... |
9bfb9f61df7c6d7f7b8dcb8bafe5830f5d9370f8 | DREADNAUGHT160/Quiz-python_progfram- | /main.py | 743 | 3.515625 | 4 | from question_model import Question
from data import question_data
from quiz_brain import QuizBrain
question_bank = []
# TODO: TO CONVERT THE QUESTION INTO A LAST OF OBJECTS
for question in question_data:
question_text = question["text"]
question_answer = question["answer"]
new_question = Question... |
ef4ca85c57127a6d6355053bff5e7c47458a5a63 | lzj-learn/LJtest | /LJtest4.py | 3,221 | 3.546875 | 4 | import time
import random
# 循环的break和continue
for a in range(10):
if a == 4:
continue # 这里使用continue就会跳过4的那次循环
if a == 5:
break # 这里使用break表示到了5的那次循环后就会直接结束循环
print(a)
# 九九乘法表的break
for x in range(1, 10):
for y in range(1, x+1):
if x == 3:
break # 这个break只会结束一... |
57384ac75746afb7a2360b67939026dad06a1dfb | AnaCoda/CanadianComputingCompetition | /CCC2018/Junior/J5WIP.py | 1,168 | 3.8125 | 4 | def find_shortest_path(graph, start, end, path=[]):
path = path + [start]
if start == end:
return path
if start not in graph:
return None
shortest = None
for node in graph[start]:
if node not in path:
newpath = find_shortest_pat... |
7f00893483be3139bb93422da9e8f65cb6d9d093 | funakoshiapi/Python-Projects | /proj07.py | 16,798 | 4.03125 | 4 | # Project 7
# Opens a data file, and allows the user to observe TSA information data:
# table of data, and a data ploted graph.
# The data is mostly from 2002 to 2009
'''
The programs starts by asking for a file
name. If the file exists it is opened.
If not it prompts the user to try a different
fil... |
903f3b71fe888af1f8da5b2bdc6480a74e61fd49 | funakoshiapi/Python-Projects | /proj10.py | 23,266 | 3.984375 | 4 | import tools
import gameai as ai
from checkers import Piece
from checkers import Board
from string import ascii_lowercase
import string
"""
This programm allows the user to play checkers against a artificial intelligence sytem
It features a board displayed on the screean and display the moves made, hints of m... |
9444f2fec93deb412cb8e3ada3dbb80fd4b27f9c | C-TAM-TC1028-003-2113/tarea-1-EdgarCordex | /asignaciones/09Telefono/src/exercise.py | 373 | 3.671875 | 4 | def main():
# escribe tu código abajo de esta línea
pass
texts= int(input("Numero de mensajes:"))
megas= float(input("Numero de megas:"))
minutes= int(input("Numero de minutos:"))
# Formula del costo
costo= float(mensaje+megas+minutos)*0.80
# Muestra del resultado final al usuario
print("El costo por mes ser... |
0ed7b6613918ff3aeb28970919561908e8899682 | Simobergius/starter-snake-python | /app/snake.py | 9,833 | 3.53125 | 4 |
import random
import json
import pprint
import point
import helpers
class snake:
def __init__(self):
self.lastDir = 'up'
self.strategy = 'eat'
self.nearestApple = { "x": 0, "y": 0 }
self.distanceToNearestApple = 100000000000
self.target = { "x": 0, "y": 0 }
def doAction... |
5ba200feae196cfaa2e5770f326af79e30bdbc2d | Simobergius/starter-snake-python | /app/Python-Snake/Python-Snake/snake.py | 13,210 | 3.578125 | 4 |
import random
import json
import pprint
import point
import helpers
class snake:
def __init__(self, useDebug, name):
self.name = name
self.lastDir = 'up'
self.strategy = 'eat'
self.nearestApple = { "x": 0, "y": 0 }
self.distanceToNearestApple = 100000000000
self.tar... |
51c28572bb0431407138dab7f4a21f68db4de271 | luizfpq/PythonDjango | /Exercicios IFSP/ex3.py | 824 | 4.15625 | 4 | # -*- coding:utf-8 -*-
'''
@author: LuizQuirino
@contact: luizfpq@gmail.com
Exercício 3
Escreva um programa que leia do usuário o nome e RA de 3 alunos e armazene essa
informação em um dicionário, relacionando o RA ao nome do aluno
Peça ao usuário para informar um RA e exiba o nome do aluno associado
'''
from soups... |
9d4ec1040d65e5ca00c2eee9ebe815863eebedd0 | LegendaryK/SkillSanta_assignments | /SkillSanta.py | 408 | 3.90625 | 4 | my_list = [10, 3, 6, 78, 22, 109, 99, 1]
list_second = [5, 2234, 655, 983, 22, 100]
# Task 1
print(max(my_list))
# Task 2
my_list.sort()
print("Second largest element is:", my_list[-2])
print("My list now is", my_list)
# Task 3
merged = my_list + list_second
print(sorted(merged))
# Task 4
first = my... |
882b2597a4b78fa15166ea5005858f09ffb6331e | g4hsean/BinAuthor | /BinAuthorPlugin/ExternalScripts/minhash/minhash.py | 3,944 | 3.5 | 4 | __author__ = 'titan'
import random
import binascii
import pickle
import os
string1 = "Shakespeare produced most of his known work between 1589 and 1613"
string2 = "Shakespeare produced most of his work after 1589"
numOfShingles = 3
numOfUniqueHashCodes = 200
hashNumbers = []
maxShingleID = 2**32-1
nextPrime = 4294967... |
6e993351c6511678d2af72b2789a3177b660b814 | CyberPatriot/LearnCodingtheHardWay | /Python/Ex04/ex4_phrasz_input.py | 214 | 3.5625 | 4 | #import fileinput
print "\nD00d, let's add things. Give me two numbers to add:"
input_var1 = input("Number 1: ")
input_var2 = input("Number 2: ")
print "(",input_var1," + ",input_var2,") = ",input_var1+input_var2
|
938d2e3bad99c36b20496d35f79f9ab7afe54b9a | damont/jconf | /src/pythonClassMaker.py | 7,961 | 3.84375 | 4 | """Credit to David Monts, circa 2017
The pythonClassMaker module.
This module inherits from the base class maker and uses the extracted
information in order to create a Python class for extracting JSON, verifying JSON,
and recreating JSON.
"""
from classMaker import *
class PythonClassMaker(ClassMaker):
"""The Pyt... |
6714e84b9f7f3548eb12d7eb7ecd8e79b9ffd98b | fabricio-hunt/python-exercises | /calc-media-aluno.py | 690 | 3.828125 | 4 | #Crie um programa que leia duas notas de um aluno e calcule sua média,
#mostrando uma mensagem no final, de acordo com a média atingida:
#– Média abaixo de 5.0: REPROVADO
#– Média entre 5.0 e 6.9: RECUPERAÇÃO
#– Média 7.0 ou superior: APROVADO
nota1 = float (input('Digite sua primeira nota: '))
nota2 = f... |
fbb47d62e044dc80b62dd4d1bb8dc5d0d582e284 | Ash-CodePlatoonSummer2021/fibonacci | /python/fibonacci_spec.py | 255 | 3.515625 | 4 | from fibonacci import fibonacci
print(fibonacci(0) == 0)
print(fibonacci(2) == 1)
print(fibonacci(5) == 5)
print(fibonacci(8) == 21)
print(fibonacci(11) == 89)
print(fibonacci(14) == 377)
print(fibonacci(17) == 1597)
print(fibonacci(20) == 6765) |
7833cf78c5295c8ae6809b74d509580195b9598b | RiflerRick/foobar | /Level3/Part3/testSolution1.py | 12,105 | 3.703125 | 4 |
class BunnyEscape:
def __init__(self, maze):
self.queue=[(0,0)]
self.maze=maze
self.maxRow=len(maze)-1
self.maxCol=len(maze[0])-1
self.weights={}
self.removableWalls=[]
self.visited=[]
for i in range(len(maze)):
for j in range(len(ma... |
3e8b5b2c7e71c304d487320e433f5b5bb7ba6fcd | RiflerRick/foobar | /Level3/Part2/testIntLimit.py | 122 | 3.515625 | 4 | a='1'
for i in range(50):
a+='0'
b=int(a)
c=0
b-=25
print(b)
while b>0:
c+=1
b=int(b/10)
print(b)
print(c) |
bb576deaf971b82051c11c6e0a27b1f7a640a6ed | mintsatan/labs_informatics | /laba3/lab_03_05.py | 737 | 3.96875 | 4 | '''
c
'''
d2 = dict(bananas=3,apples=5,oranges=2,bag="basket")
d5 = d2.copy() #
print("Dict d5 copying d2 = ", d5)
#
print("Get dict value by key d5['bag']: ", d5["bag"])
print("Get dict value by key d5.get('bag'): ",
d5.get('bag'))
print("Get dict keys d5.keys(): ", d5.keys()) #
print("Get dict values d5.va... |
69060f6d564606d86e18a6805179dccc41f9b955 | kikutou/autobank | /createNewDb.py | 563 | 3.734375 | 4 | #!python2.6
# -*- coding: utf-8 -*-
import sqlite3
con = sqlite3.connect("autobank.db",isolation_level=None)
sql = u"""
create table if not exists bank (
id varchar(20) PRIMARY,
mail varchar(100),
url varchar(200),
loginId varchar(50),
password varchar(50)
);
"""
con.execute(sql)
sql = u"insert into bank v... |
7f8d16a664a5265a78fe76d94daba2aebda7d712 | aimanyounises1/Computer_vision_assigments_and_practicing | /Assignment4/ex4_utils.py | 8,524 | 3.625 | 4 | import numpy as np
import matplotlib.pyplot as plt
import cv2
"""
@Author : Aiman Younis
Comments : I will submit my main , please run my main in order to see the answers.
Thank You shai :))
"""
def ID() -> int:
return 207054354
pass
def disparitySSD(img_l: np.ndarray, img_r: np.ndarray, disp_range: (i... |
597d5e88212e0f8455065df8525ddf7d2209ecc5 | ming0223/SW-Proj2-Team1 | /20171633-서형석-assignment2.py | 167 | 3.859375 | 4 | while(1) :
n = int(input("Enter a number: "))
if(n == -1) : break
answer = 1
for i in range(1, n+1):
answer = answer * i;
print(str(n)+"! = "+str(answer))
|
a9be551263a2e55cd0a0546ca246543cc05e5044 | 24jkeen/Quantitative-analysis-of-approaches-to-group-marking | /ModelFiles/PA1.py | 2,755 | 3.59375 | 4 | import random
# Function takes the ideal mark and modifies it randomly
def StudentRanking(RankedStudentMark):
ReturnMark = RankedStudentMark + random.randrange(-16,16)
if ReturnMark > 100:
return 100
elif ReturnMark < 0:
return 0
else:
return ReturnMark
# To remove randomne... |
677550b2081791ffc73afdc577a9836ffb642d69 | shultzc41/pysql | /pysql.py | 8,789 | 3.75 | 4 | #!/bin/python3.8
#Python program for interacting with a MySQL database.
import sys, getopt, os.path, mysql.connector
from mysql.connector import errorcode
# Setting global variables.
###########################
# Program version.
version = "1.0"
# Hostname/IP Address of database server that we will connect to.
host ... |
b41d9a5e87642e53a38e1182b34342a700545d75 | mclaffey/thermostat | /weather/weather.py | 4,653 | 4.03125 | 4 | #!/usr/bin/env python
"""Poll for last 48 hours of weather
This queries http://w1.weather.gov/obhistory/KCLT.html, which only provides the last 48 hours.
This includes functionality to create a database to house past entries. The intention is that
the script can be called hourly to keep the database populated with th... |
e67bad0236c749721093a6c767a4a957a2011622 | GreyAlien502/je3 | /errors.py | 2,405 | 3.546875 | 4 | import traceback
from .server import response
class HTTPError(Exception):
def __init__(self,code,message=None):
if message == None:
message = {
400: '''\
400 Bad Request
The 400 (Bad Request) status code indicates that the server cannot or
will not process the request due to something tha... |
c524086b12f5e87e3caf1774e7e8eb843d242dea | aa962135230/100examples | /54.py | 214 | 3.5 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
if __name__=='__main__':
a =input('please input your number:')
b = len(a)
c= []
for i in range(-b+2,-b+6,1):
c.append(a[i])
print(a[i])
print(c) |
608b38c44a64ad7224f5b302d6678a4d74a6c935 | aa962135230/100examples | /11.py | 187 | 3.921875 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
def rabbit(num):
i = 1
a,b = 1,1
while i <= num:
yield a
i += 1
a,b = b , a+b
list = [x for x in rabbit(20)]
print(list) |
366be6771066ec24e2666830e80fa4091ee38f75 | aa962135230/100examples | /26.py | 161 | 3.859375 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
def fun(n):
if n==1 or n == 0:
return 1
else:
return n*fun(n-1)
for i in range(1,6):
print(fun(i)) |
9befc275b7b2a0096509b0f9f38dda44fb72d75a | aa962135230/100examples | /88.py | 132 | 3.90625 | 4 | n = 1
while n<=7:
a = int(input('your num is :'))
while a<1 or a>50:
a = int(input('your num is :'))
print(a*'*')
n += 1 |
180d170e521347b41efd623448eed264038bc090 | aa962135230/100examples | /56.py | 329 | 3.578125 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
if __name__=='__main__':
from tkinter import *
canvas = Canvas(width = 800,height = 600,bg = 'yellow')
canvas.pack(expand=YES,fill=BOTH)
k = 1
j = 1
for i in range(0,26):
canvas.create_oval(310-k,250-k,310+k,250+k,width = 1)
k += j
j += 0.3
m... |
9d7f379137bbd23d816888f4daaa56cebe991e22 | aa962135230/100examples | /31.py | 399 | 4.09375 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
weeklist = {'M': 'Monday','T': {'u': 'Tuesday','h':'Thursday'}, 'W': 'Wednesday', 'F':'Friday','S':{'a':'Saturday','u':'Sunday'}}
letter1 = input('请输入第一个字母:')
letter1 = letter1.upper()
if (letter1 in ['T','S']):
letter2 = input('请输入第二个字母:')
print(weeklist[letter1][... |
fc8456226692d3066e03d52d42c9dfe0c43aec59 | flora5/py_simple | /asyncio_test.py | 1,377 | 3.8125 | 4 | """
While the threading module
implements concurrency
through application threads
and multiprocessing implements
concurrency using system processes,
asyncio uses a single-threaded,
single-process approach in which parts of
an application cooperate to switch tasks
explicitly at optimal times
... |
29f8dc58745775e55d09b2abf77ba47319e24ac8 | flora5/py_simple | /function_eg.py | 1,091 | 3.84375 | 4 |
def avg(first, *rest):
print rest
print len(rest)
return(first + sum(rest))
print avg(10,1,1,1,1) # rest is a tuple
class A:
class_attr = 1.0 # class attribute
__weight = 120 #__private_attrs can not access outside the class
def print_hello(self): #self must be the first argument
... |
c1ad2b3ac87e01b9a230b71b9aca5af6bb34d9ed | flora5/py_simple | /map_reduce_filter.py | 1,062 | 4.21875 | 4 | """
filter(function or None, sequence) -> list, tuple, or string
Return those items of sequence for which function(item) is true. If
function is None, return the items that are true. If sequence is a tuple
or string, return the same type, else return a list.
"""
str = ['a','b','c','d']
def func(s):
if ... |
4988b7981d35fa21e9ea46791efb30b23a8041be | wangshibo321/1807 | /13day/05-创建一个池子.py | 486 | 3.5 | 4 | from multiprocessing import Pool
import time
def show():
for i in range(10):
time.sleep(1)
print("哈哈哈")
p = Pool(3) #创建一个池子,可以装无限个进程
for i in range(3):
p.apply_async(show) #添加一个进程到池子里面 非阻塞添加进程 3个进程同时执行
#p.apply(show) #阻塞添加进程 30遍的任务 3个进程依次执行10遍
print("添加成功")
p.close() #关闭池子
p.join() #不支持传超时时间
print("嘿嘿嘿")
|
d2cb4fe5ec147ac8d6a49fefd9037cbaf7eeca30 | VoldemarTim/hw | /4.py | 677 | 3.609375 | 4 | # 4. Написать декоратор с аргументом-функцией (callback),
# позволяющий валидировать входные значения функции
# и выбрасывать исключение ValueError, если что-то не так, например:
# def val_checker...
# ...
#
#
# @val_checker(lambda x: x > 0)
# def calc_cube(x):
# return x ** 3
#
#
# >>> a = calc_cube(5)
# 125
# ... |
1dcc7c279c5b6a8b6ea4207a8c24b933ec946079 | J-A-S-0-N/money-manager-pt1- | /money manager(pt1)/main.py | 990 | 3.71875 | 4 | from os import system
from time import sleep
global list
list = []
def delete(item):
list.remove(item)
def add(item):
list.append(item)
def main():
while True:
system("cls")
print(list)
print("add[a]")
print("delete[d]")
inp = input("... |
8a883c4d185f3e2a0fecdb031a5f2c5b84f87a93 | AK6263/Sierpinski-s-gasket | /chaos.py | 776 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
@author: Abhay Kshirsagar
"""
import turtle
import math
import random
a=turtle.Turtle()
wn =turtle.Screen()
a.shape('blank')
wn.bgcolor('black')
a.color('white')
sc=a.getscreen()
a.speed(0)
x,y = [0.0,216.51,-216.51],[250.0,-125.0,-125.0]
def ranpt(b,c):
a = rando... |
a5b0f77c97283440242406a5d18a4c26d9f6a52f | kartik-kumar71/CollegeStuff | /class_py/fitness_1.py | 152 | 3.765625 | 4 | lst = list(map(float,input("Enter the weight loss seperated by space ---> ").split()))
print ('The average weight loss is {}'.format(sum(lst)/len(lst))) |
2c0cd4a94e86048f61470ba8f5e0f9bdb3bb1d4d | kartik-kumar71/CollegeStuff | /class_py/retire.py | 317 | 3.578125 | 4 | __author__ = "Kartik"
(years,amount) = list(map(int,input("Enter the years and amount seperated by space ---> ").split()))
while years == 0 or amount == 0:
print ("Incorrect values")
(years,amount) = list(map(int,input("Enter the years and amount seperated by space ---> ").split()))
print (years*amount)
|
19cad7ce7c9c51d0dda9043ac7ede2f8394a1056 | kartik-kumar71/CollegeStuff | /class_py/bulgarian.py | 386 | 3.6875 | 4 | import random
def random_ints_with_sum(n):
"""
Generate positve random integers summing to `n`.
"""
while n > 0:
r = random.randint(1, n)
yield r
n -= r
piles = list(random_ints_with_sum(45))
piles =
print (piles)
"""
def operation():
if len(piles) != 9:
piles.appen... |
c12bf91981fc6c3da928419f0db163662eea1798 | Riverfount/pacote-desafios-pythonicos | /14_mimic.py | 1,888 | 4.25 | 4 | """
Leia o arquivo especificado via linha de comando.
Faça um split() no espaço em branco para obter todas as palavras
no arquivo, em vez de ler o arquivo linha a linha, é mais facil obter
uma string gigante e fazer o split uma vez.
Crie um dicionario "imitador" que mapeia cada palavra que aparece no arquivo
com a lis... |
6e6eb4896f20d5d1adb9813aa68efd3ba3a4ab98 | lyltj2010/leetcode | /is_palindrome/solution.py | 431 | 4 | 4 | class Solution:
def is_palindrome(self, string):
# use two pointers
i, j = 0, len(string)-1
while i <= j:
# skip non alpha char
while not string[i].isalpha():
i += 1
while not string[j].isalpha():
j -= 1
a, b = string[i].lower(), string[j].lower()
if a != b:
return False
i += 1
... |
471aed991ef565b9379500e5ce53c817e22389d7 | lyltj2010/leetcode | /climbing_stairs/solution2.py | 456 | 3.953125 | 4 | # -*- coding: utf-8 -*-
"""
You are climbing a stair case.
It takes n steps to reach to the top.
Each time you can either climb 1 or 2 steps.
In how many distinct ways can you climb to the top?
"""
class Solution(object):
# time O(n); space O(1)
def climb_stairs(self,n):
# iterate fibonacci
# dp
dp = [1 for i... |
23d40d4a0abc9534cf1659a0b1ec37df5b2a8157 | eunha812/OSP_2_2019113754 | /py_lab2/my_pkg/bin_con.py | 250 | 3.640625 | 4 | #!/usr/bin/python
def convert(inb):
s = str(inb)
m = '0b'
s = m + s
value = int(s,2)
o = format(value, 'o')
h = format(value, 'X')
print("=> OCT> " + str(o))
print("=> DEC> " + str(value))
print("=> HEX> " + str(h))
print()
print()
|
4bf62cc6b369abe2b1caf32d4d68cbbf839bc435 | myytchYY/TYmyytch.github.io | /HA/BUAD5042Binpacking-master/binpacking.py | 2,650 | 3.90625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Mar 19 15:57:44 2018
@author: tianc
"""
def binpack(articles,bin_cap):
""" You write your heuristic bin packing algorithm in this function using the argument values that are passed
articles: a dictionary of the items to be loaded into the bins: the ... |
e1e47a1d92f3f111b1000eeaad289b49f5dfc093 | Harshithamurthy/untitled | /Demo.py | 276 | 3.953125 | 4 | listvar = [10, 20 , 30, "Apple", "Banana", "Cherry"]
def lengthlist(listvar):
count = 0
for x in listvar:
count = count + 1
return count
#print("The length of list is", lengthlist(listvar))
i = lengthlist(listvar) - 1
while i>=0:
print(listvar[i])
i = i - 1 |
934ded3806d552b45d89f66255d133760a43f7d2 | amari-at4/University-Admission-Procedure | /Topics/Split and join/Triangle/main.py | 192 | 3.921875 | 4 | def number_of_chars(n):
return 1 + (2 * n)
height = int(input())
width = ((height - 1) * 2) + 1
for i in range(height):
line = "#" * number_of_chars(i)
print(line.center(width))
|
249ba2b3e876ac62d72cbeaada3b0d3cf36fd21a | melyxlin/cs591_c2_assignment_5 | /problem3/problem3.py | 1,640 | 4.09375 | 4 | def s2i(s):
"""
takes in a string s and returns the string representation of the integer i
"""
#return integer
returnint = 0
#loop to interate through all the characters in s
for digit in s:
#changing digit c to the integer representation of it
digitint = ord(digit) - or... |
bd1e7a783825fe7c13f29554b19eb5a57851aa43 | MingfeiPan/leetcode | /array/33.py | 1,608 | 3.59375 | 4 | class Solution:
def search(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: int
"""
if not nums:
return -1
lo = 0
hi = len(nums) - 1
while lo < hi:
mid = int((lo + hi) / 2)
... |
b69494430f1e6dc297e4662227b1ccb6d105a1e9 | MingfeiPan/leetcode | /stack/71.py | 645 | 3.578125 | 4 | class Solution:
def simplifyPath(self, path):
"""
:type path: str
:rtype: str
"""
arr = path.split('/')
stack = []
for s in arr:
if s is '' or s == '.':
continue
if s == '..':
try:
sta... |
968bbd577798b363339f980fdb9b7aa32f4d5246 | MingfeiPan/leetcode | /array/56.py | 839 | 3.765625 | 4 | # Definition for an interval.
# class Interval:
# def __init__(self, s=0, e=0):
# self.start = s
# self.end = e
class Solution:
def merge(self, intervals):
"""
:type intervals: List[Interval]
:rtype: List[Interval]
"""
if not intervals:
return... |
168c4419fa930b83a360e6b850f18637cdc28f03 | Domantas231/hangman0.05 | /code.py | 984 | 3.5625 | 4 | import random
class ch():
def __init__(self, char, guessed):
self.char = char
self.guessed = guessed
file = 'words.txt'
with open(file, 'r') as f:
data = f.readlines()
def r():
word = random.choice(data)
return word
def convert(word):
word1 = []
for s in word:
... |
22dcc17d8f620746e1d0c49f94c438becceb9911 | romanticegg/Spiking-C3D | /nengo/networks/product.py | 1,985 | 3.5625 | 4 | import numpy as np
import nengo
from nengo.networks.ensemblearray import EnsembleArray
def Product(n_neurons, dimensions, input_magnitude=1, net=None):
"""Computes the element-wise product of two equally sized vectors.
The network used to calculate the product is described in
`Precise multiplications wi... |
c92c54e7112e3f2c85c615d6a553f93e9737b7d3 | EgorZamotaev/PythonLabs | /Lab3/3.1/main_game.py | 4,948 | 3.609375 | 4 |
from npc import NPC
import pygame
from pygame import *
from blocks import Platform
from random import randrange, randint
from finish import Finish
WIN_WIDTH = 1010 # Ширина создаваемого окнa
WIN_HEIGHT = 1010 # Высота
DISPLAY = (WIN_WIDTH, WIN_HEIGHT) # Группируем ширину и высоту в одну переменную
BACKGROUND_COLOR... |
eb15ea7e58754523e6a00951b39286ccc5129bd7 | evgenyvaleev/pygorithms | /pygorithms/algorithms/sorting/quicksort.py | 412 | 3.953125 | 4 | def quicksort(items):
"""O(n * log n)."""
if len(items) < 2:
return items
else:
pivot_index = len(items) // 2
pivot = items[pivot_index]
left = [num for i, num in enumerate(items) if num <= pivot and i != pivot_index]
right = [num for i, num in enumerate(items) if num... |
5f36c7aa39dfa67ee8807aac3da09602ae9a4af3 | evgenyvaleev/pygorithms | /tests/algorithms/test_recursive_binary_search.py | 662 | 3.875 | 4 | from pygorithms.algorithms.recursive_binary_search import recursive_binary_search
def test_recursive_binary_search_first_element():
items = [1, 2, 3, 4, 5, 6, 10, 55, 67, 2456]
target = 1
res = recursive_binary_search(items, target)
assert res == 0
def test_recursive_binary_search_element_in_the_m... |
24f0a3e66ba8fae1455ed2dc4bcae6b6220c223d | evgenyvaleev/pygorithms | /pygorithms/data_structures/queue/linked_list_queue.py | 479 | 3.75 | 4 | from .queue import Queue
from pygorithms.data_structures.linked_list import LinkedList
class LinkedListQueue(Queue):
def __init__(self):
self._items = LinkedList()
def __len__(self):
return len(self._items)
def enqueue(self, item):
self._items.append(item)
def dequeue(self):... |
5a2ec512a2ce2364cb485a071abd6ac310c50ddf | PilarNew/graphic-interfaces.python-tkinter | /08-Alertas.py | 792 | 3.71875 | 4 | from tkinter import *
from tkinter import messagebox as MessageBox
ventana= Tk()
ventana.config(
bd=70
)
def sacarAlerta():
# MessageBox.showinfo("Alerta", "Hola soy Pilar")
# MessageBox.showwarning("Alerta", "Hola soy Pilar")
MessageBox.showerror("Alerta", "ERROR")
def salir(nombre):
resultado =... |
6117d4756e94747d4677c0e112054eafffb0b520 | psiionik/CodingProblems | /LeetCode/DailyPractice/numJewelsinStones.py | 438 | 3.625 | 4 | def numJewelsInStones(J, S):
"""
:type J: str
:type S: str
:rtype: int
"""
resulting_dict = {}
if (J == "" or S == ""):
return 0
for i in J:
resulting_dict[i] = 0
resultsum = 0
for i in S:
if (i in resulting_dict):
resultsum += 1
... |
2480e76fa58dc59f2fc751ffc81b54c2a18fa19c | psiionik/CodingProblems | /DailyCodingProblem/easy/nOrderApi.py | 1,793 | 4 | 4 | """
You run an e-commerce website and want to record the last N order ids in a log. Implement a data structure to accomplish this with the
following API:
1. record(order_id): adds the order_id to the log
2. get_last(i): gets the ith last element from the log. i is guaranteed to be smaller than or equal to N.
Be as ef... |
c79d8c9cc141e01d126d70d9b4fc1518b381b6a5 | psiionik/CodingProblems | /LeetCode/DailyPractice/longestSubstringsNumber.py | 368 | 4 | 4 | """
Use dynamic programming.
"""
def longest_substrings_number_sol1(prefixes, numbers):
def main():
prefixes = [
"+12345",
"+1234",
"+1500000",
"+1",
"+4444"
]
numbers = [
"+123456789",
"+2345",
"+14000000"
]
print(longest_su... |
58cacbff4458c3b8a61ef878ead9f9a12143b245 | psiionik/CodingProblems | /LeetCode/DailyPractice/shortestWayToFormString.py | 1,849 | 4.0625 | 4 | """
From any string, we can form a subsequence of that string by deleting some number of characters (possibly no deletions).
Given two strings source and target, return the minimum number of subsequences of source such
that their concatenation equals target. If the task is impossible, return -1.
"""
def shortest_way... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.