blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
314e9d5310173623eb38aa00c32031b59e891575 | ceyhunsahin/TRAINING | /EXAMPLES/EDABIT/EARLIER/47_reverse_the_string.py | 1,861 | 4.1875 | 4 | """
Reverse the String (with a catch)
Create a function that takes a string and returns the reversed string. However there's a few rules to follow in order to make the challenge interesting:
The UPPERCASE/lowercase positions must be kept in the same order as the original string (see example #1 and #2).
Spaces must be ... |
2a81465b6f68e14efcd657e40a08599d388be299 | Tirren/howtocode | /fibonacci.py | 300 | 3.75 | 4 | def fibb(x):
fib0 = 0
fib1 = 1
fibval = []
while True:
fib = fib0 + fib1
fib0 = fib1
fib1 = fib
if fib > x: break
fibval.append(fib)
return tuple(fibval)
def showfibb(x, y):
print(y.join(str(x) for x in fibb(x)))
showfibb(50, ' | ')
|
0b0087d31cc350ef9ec40584aff5bcc5593d7479 | adamcanray/canrayPythonLoginShellBasic | /login_static_data/login_static_data.py | 1,028 | 3.703125 | 4 | # static data
user = {
1 : { "username" : "ujang", "password" : "ujang123"},
2 : { "username" : "maman", "password" : "maman12" },
3 : { "username" : "unih", "password" : "unih123"},
}
# validation
def validationLogin(username, password):
result = ""
# proccess
for u in user:
# cek user... |
8104cbb627ff96f0daf3135b602bd9a25e88d83c | t8ggy/Python_Exercises | /final_grade.py | 433 | 4 | 4 | name = str(input("Enter your name: "))
homework = int(input("Enter your homework score: "))
assessment = int(input("Enter your assessment score: "))
exam = int(input("Enter your exam score: "))
def add_calc(number1, number2, number3, number4):
answer= (number1+number2+number3)/number4*100
return answer
Final_... |
df05179f4df475ed8f39e7fb021301a42fa2868c | lucaslmrs/blackjack | /jogo/jogador.py | 4,774 | 3.75 | 4 | """
todo/*------------------------------------------------------+
| Projeto | BLACKJACK |
|----------------------------------------------------------|
| Linguagem | Python |
|----------------------------------------------------------|
... |
8392c78093d4d68c63db665dc3827f8095954b5f | 7german7/python_comands | /practicas/conversiones.py | 847 | 4.21875 | 4 | # *******************************************************CONVERSIONES********************************************************
# Algunas de las funcionalidades que nos ofreced Python son las conversiones, las cuales nos permiten modificar o cambiar el
# tipo de dato que contiene una variable
numero = 4
print float(numer... |
bcf9e660e833d8f82db23f0d79b37fdbb794ae70 | nipunwijetunge/Brahmilator | /brahmi_backend/word_finder_module/possible_word_finder.py | 2,207 | 3.921875 | 4 | from math import pow
# function to find all subsequence for given letters
# example given letters is abc
# subsequence for above example is abc , a , bc , ab , c , a , b , c
def subsequences(str):
allWordList = []
posibilities = []
n = len(str)
opsize = int(pow(2, n-1))
for counter in range(opsi... |
e1c9c1eaa85d9245125af0a5a7e2b9b3f07e340e | Chanukacnm/project | /util/books.py | 2,735 | 3.609375 | 4 | import urllib.request
import json
# 324991-stuy-YAU093CG
def get_key(key_type):
'''Gets the api key from keys.JSON base on the key_type'''
with open('keys.JSON', 'r') as f:
keys = json.load(f)
# print(keys)
return keys.get(key_type)
def google_books_data(query):
'''Returns the search ... |
e1a5ddd4ef9137a6029c3d1dc2d06d9a03bd7444 | clarkwalcott/CSPractice | /fizzbuzz.py | 566 | 4.21875 | 4 | # Purpose: Display a list of numbers 1 to n. If a number is divisible by 3, output "Fizz". If a number is divisible by 5,
# output "Buzz". Finally, if a number is divisible by both 3 and 5, output "FizzBuzz".
def fizzbuzz(n):
numList = list()
myDict = {3:"Fizz", 5:"Buzz"}
for i in range(1,n+1):
... |
40ea8078dce794612a3b7f7ba22df9709f03ea74 | ThomasjD/Week2 | /Restaurant.py | 874 | 4.0625 | 4 | #Make a class called Restaurant. The __init__ method for Restaurant should store two attributes. a restaurant_name and a cuisine_type. Make a method called describe_restaurant() that prints these two pieces of information, and a method called open_restuarant() that prints a message indicating that the restaurant is ope... |
acaa991435d7c55fdb0f8716b6bd789ccc7dcf7e | alu0100530964/Equipo_3_E | /src/solucion.py~ | 1,597 | 4 | 4 | #!/usr/bin/python
#!encoding: UTF-8
import sys
import math
def calcular_geo (n,p):
if (n>1):
q=1-p
probabilidad=(q**(n-1))*p
else:
probabilidad=p
return (probabilidad)
def calcular_geo1 (n,p):
probabilidad=0
for i in range (1,n+1):
sumaprobabilidad=calcular_geo(i,p)
probabilidad+=sumaprob... |
1a2adfe3e6a875bd38b70e3615fa4e6736ca5847 | marko-knoebl/courses-code | /2022-05-30-python/day2/for_loops.py | 392 | 4.5 | 4 | names = ["Alice", "Bob", "Charlie"]
for name in names:
print("Hello, " + name + "!")
# print all positive entries
numbers = [2, 5, -3, 8, 1, -5]
for number in numbers:
if number > 0:
print(number)
# print the biggest element
biggest_item = numbers[0]
for number in numbers:
if number > biggest... |
b90f32c40fcfd9308552c8f21a6b0133799cb8b7 | sashakrasnov/datacamp | /29-statistical-simulation-in-python/2-probability-and-data-generation-process/05-birthday-problem.py | 1,682 | 3.953125 | 4 | '''
Birthday problem
Now we'll use simulation to solve a famous probability puzzle - the birthday problem. It sounds quite straightforward - How many people do you need in a room to ensure at least a 50% chance that two of them share the same birthday?
With 366 people in a 365-day year, we are 100% sure that at least... |
c6a5b32819efa899d70ada3a0911fb5300acf76f | lws803/cs1010_A0167 | /SomeProgs/Python Stuff/03 Saturday DUNMAN HIGH PRELIM 2013/task4.py | 3,232 | 3.84375 | 4 | class Node(object):
def __init__(self,name = '',score = 0,ptr = None):
self.name = str(name)
self.score = int(score)
self.ptr = ptr
def get_name(self):
return self.name
def set_name(self,new):
self.name = new
def get_score(self):
return self.score
de... |
ef7585d8467cb998042d32d97add1493bb7043ad | BreezyVP/GWC2019 | /RandList.py | 140 | 3.734375 | 4 | list = [5, 3, 7, 1, 8]
list.sort()
print(list)
print(list.pop())
list.extend([2, 4, 6, 9])
print(list)
print(list.sort())
print(list[::2])
|
f1c1d7c77f8af5789825e3d35e0d2dac135b0684 | ravikumarvj/DS-and-algorithms | /arrays/binary search/shifted_array.py | 2,157 | 4 | 4 | ### COPIED ### VERIFIED
'''
1. Find a given number num in a sorted array arr:
arr = [2, 4, 5, 9, 12, 17]
2. If the sorted array arr is shifted left by an unknown offset and you don't have a pre-shifted copy of it, how would you modify your method to find a number in the shifted array?
shiftArr = [9, 12, 17, 2, 4, 5]
E... |
d6a63f62c846dee7752db2cc21e70308d34f9eae | skv-sergey/coursera_python_starter_VSHE | /week2/exercise/17.Monte_Cristo.py | 580 | 3.609375 | 4 | a, b, c = int(input()), int(input()), int(input())
d, e = int(input()), int(input())
# a, b, c, d, e = int(1), int(1), int(1), int(1), int(1)
if a <= b and a <= c:
if b <= c:
a, b = a, b
elif c <= b:
b, c = c, b
elif b <= a and b <= c:
if a <= c:
a, b, = b, a
elif c <= a:
... |
7961d302423591ffd311f55ba3c6e5bbcbeed4d1 | jlunder00/blocks-world | /location.py | 1,323 | 4.1875 | 4 | '''
Programmer: Jason Lunder
Class: CPSC 323-01, Fall 2021
Project #4 - Block world
9/30/2021
Description:
This is a class representing a location in the block world. It has a list of the blocks it contains, keeps track of which block is on top, and has the ability to place a given block on its stack and remove on... |
b3dcb6d282a2ef82cbf1b2f32cc2f70e8fadcd08 | voyagerodin/Algorithms | /Lection_19_heap.py | 732 | 3.953125 | 4 | # ==================================================
#
# Lection 19.
# Heap structure
#
# ==================================================
class HeapStructure:
def __init__(self):
self.values = []
self.size = 0
def insert(self, x):
self.values.append(x)
self.size += 1
... |
171868fa9b5052d4e09bc0ec87effb18de31c048 | Rupesh1101/DSA | /Array/Sentence_Reversal.py | 828 | 3.96875 | 4 | # Python tricks :-
def reverse(sen):
print(" ".join(sen.split()[::-1]))
reverse(" This is the best ")
def reverse1(sen):
print(" ".join(reversed(sen.split())))
reverse1("hii john, how are you doing ?")
# Algorithms :-
def reverse2(sen):
words = []
length = len(sen)
spaces... |
b51c0ab350253771be69d53647ff8d8447222952 | retournerai/learn_python3_the_hard_way | /ex35d.py | 4,505 | 4.21875 | 4 | from sys import exit # use exit attribute (function) in the import module from python sys package
def gold_room(): # function name parameter
print("This room is full of gold. How much do you take?") # show text message
choice = input('> ') # variable = user input prompt
if "0" in choice or "1" in choi... |
f21b9fa1e7983ea0cf34843a421c28757ce237bd | ISP19/uml | /movie/movie.py | 892 | 3.90625 | 4 | class Movie:
def __init__(self, name: str, genre: str, showtime: str):
self.name = name
self.genre = genre
self.showtime = showtime
class Seat():
"""
to check the seat that is already booked or not
"""
def __init__(self):
self.is_booked = False
class Theatre():
... |
7371e45ddb1c2902e7bb85f6584abc85dc138382 | Aasthaengg/IBMdataset | /Python_codes/p03469/s884542061.py | 106 | 3.875 | 4 | s = list(map(str,input().split("/")))
if s[0] == "2017":
s[0] = "2018"
print(s[0]+"/"+s[1]+"/"+s[2]) |
f6dc216747f009694a9d722269e2935a36f5b355 | akriticg/Google_Interview_Prep | /05_GFG_count_triplets.py | 942 | 4.15625 | 4 | '''
Count triplets with sum smaller than a given value
Given an array of distinct integers and a sum value. Find count of
triplets with sum smaller than given sum value. Expected Time Complexity
is O(n2).
Examples:
Input : arr[] = {-2, 0, 1, 3}
sum = 2.
Output : 2
Explanation : Below are triplets with sum le... |
f9f61fb0610c3b38295941dcfbf59f6892a413e1 | beetee17/week3_greedy_algorithms | /week3_greedy_algorithms/4_maximum_advertisement_revenue/dot_product.py | 1,206 | 3.875 | 4 | # Uses python3
import sys
def max_dot_product(a, b):
"""Task. Given two sequences 𝑎1,𝑎2,...,𝑎𝑛 (𝑎𝑖 is the profit per click of the 𝑖-th ad) and
𝑏1,𝑏2,...,𝑏𝑛 (𝑏𝑖 is the average number of clicks per day of the 𝑖-th slot), we need to
partition them into 𝑛 pairs (𝑎𝑖,𝑏𝑗) such that the sum ... |
cfc3743ed4a1ea555ea6760f21605ddc99312acd | jetbrains-academy/introduction_to_python | /Condition expressions/If statement/if_statement.py | 366 | 4.1875 | 4 | name = "John"
age = 17
if name == "John" or age == 17: # Check that name is "John" or age is 17. If so print next 2 lines.
print("name is John")
print("John is 17 years old")
tasks = ["task1", "task2"] # Create new list
if len(tasks) != 0:
print("Not an empty list!")
tasks.clear() # Empty the list... |
8921e73323f4f712f1d47d4232b17ecc05df3f28 | PeteyCoco/mastermind_solver | /Mastermind.py | 3,757 | 3.78125 | 4 | ###############################################################
#
# The following program solves a 'n' games of Mastermind using
# a random guessing algorithm. Results of games are stored
# in a csv in the locatio of this script.
#
###############################################################
import sys
import... |
0d8408a2e413cad43bd541ddff19eddb3b9686ae | cfcv/Projeto_infracom | /Q2/database.py | 3,827 | 3.578125 | 4 | import user
import os
import sqlite3
class DataBase(object):
def __init__(self):
self.conn = sqlite3.connect('users.db')
self.cur = self.conn.cursor()
self.cur.executescript("""
CREATE TABLE IF NOT EXISTS Users(
id INTEGER PRIMARY KEY AUTOINCREMENT, ... |
daffc9d57948bb77a4e725fdf7d2fb590e71856b | Upasana360/All-My-Python-Programs | /ch5ex4.py | 243 | 4.0625 | 4 | def odd_even(l):
list1=[]
list2=[]
for i in l:
if (i%2==0):
list1.append(i)
else:
list2.append(i)
list3=[list2,list1]
return list3
list5=[1,2,3,4,5,6,7,8,9]
print(odd_even(list5)) |
e8d82408fd86a43730d3725abd619189c1950b0e | JPatricio/jcrawl | /jcrawl/jcrawl.py | 1,354 | 3.75 | 4 | """
A python application to extract all links from an HTML document.
Start with a seed URL and crawl every new link found, without revisiting a page.
No helper libraries allowed. Only Regex, Requests, and urllib as primary tools.
Once all the links are extracted from a website, assemble a site map in the standard for... |
9523382b045e43256ee22471b6cfc8f93d7536f9 | don2101/APS_problem | /SWEA/python/BruteForce/Combination.py | 1,149 | 3.796875 | 4 | n = 5
r = 3
array = [i for i in range(n)]
temp = [0 for i in range(n)]
count = 0
# start를 뽑고, start 부터 n-r+k까지 다시 combination.
def combination(array, temp, k, start):
global r
global n
global count
if k == r:
print(temp[:r])
count += 1
return
for i in range(start, n-r... |
a020d4a48592475b4dcbdcab53d35acfaf0e26f8 | 20111AFRANKRF/M03 | /(ACTUALIZACIÓN)-EJERCICIOS-COMENTADOS/BUCLE BASICO-act.py | 1,123 | 3.9375 | 4 | #!/bin/python
# -*-coding: utf-8-*-
"""
Hacer un bucle que lea una opción del usuario del 1 al 5.
Imprime “La opción seleccionada es: 2”
Cuando sea 5 sale del bucle.
"""
#######################################################################
# IMPORTS #
#################################################... |
cc719a66497b4289de1bdb8a486c04f8d7c563ad | Rickysmm/ALC_Robot | /Features/Libraries/IMU/calc_avg_angle.py | 1,002 | 4.34375 | 4 | from array import *
import math
# Sample array to compare to standard mean
angle_values1 = array('f', [0.0, 30.0, 60.0, 90.0])
# Sample array to compare with 360-deg values
angle_values2 = array('f', [0.0, 270.0, 300.0, 330.0])
# This function takes in a list of angles. Converts angles to radians
# in order to use ... |
863a0b48e23650b6a73436bf603deb8cca7934b1 | InakiHCChen/cthoop | /inputDNA.py | 4,119 | 3.5625 | 4 | # -*- coding:utf-8 -*-
import re
class Reader():
def __init__(self, file_name):
self.file = open(file_name)
self.check()
def __del__(self):
"""Ensure that file is properly closed when the Reader
instance is destroyed."""
self.file.close()
def check(self):
"""Implemented ... |
27339eb0644a480604d7aaad91f8519bc8ce3e1d | ilyapas/Halite-II | /pathfinding.py | 3,149 | 3.625 | 4 | import hlt
import logging
import math
from hlt.entity import Entity, Ship, Planet, Position
def navigate(ship, target, game_map, speed, avoid_obstacles=True, max_corrections=90, angular_step=1,
ignore_ships=False, ignore_planets=False, clockwise=True, iteration=0):
"""
Move a ship to a specific t... |
731baf7af8e0729b750d43e738b4c06b66e7f248 | 06milena/CRUD-contactos-terminal-con-MySQL | /contactos.py | 1,123 | 3.8125 | 4 | opcion=1
contactos = []
while opcion !=0:
print('.............................')
print(' SELECCIONE UNA OPCION DEL')
print(' MENÚ ')
print('1. crear contacto')
print('2. leer todos los contactos')
print('3. actualizar un contacto')
print('4. eliminar contacto')
print('5. S... |
c5cecbe2c2fa5ad712540e654c9ea34554d7a6b6 | aliceqin12/ShowMeTheCode | /0005/A0005.py | 800 | 3.5625 | 4 | import os
import glob
from PIL import Image
def resize_image(max_width, max_height, filepath):
"""
:param max_width:
:param max_length:
:param filename: 图片路径
:return:
"""
if os.path.exists(filepath):
pics = glob.glob(r'*.jpg')
for pic in pics:
image = Image.open(... |
9a618efe241ee6a3ac8dabe4ade07f54b76fa05a | rurickdev/LenguajesProgramacion | /cifrado_caesar.py | 861 | 3.875 | 4 | '''
Proyecto 2
Integrantes equipo:
Maqueo Poisot Rurick
Peña Lopez Daniel Elihu
'''
import sys
'''
realiza el cifrado desplazando hacia la derecha si la ubicacion del caracer es par
y a la izquierda si no lo es, regresa la cadena ya cifrada
'''
def cifrar(cadena, rec):
cadCifrada = ""
i = 0
while ... |
2f07534f385bf3f0c61762d8e20025f9e1442924 | andresgfranco/adan_square | /companies_selection/computing_companies.py | 832 | 3.984375 | 4 | #!/usr/bin/python3
"""Module to create function computing"""
import companies
#from companies import Company
team_members = int(input("How many team members do you have?"))
members_results_dict = {}
for instances in range(team_members):
#we don't know how many members will be in the team so
#that's why I su... |
1ef9374ec9811315c622ea731c129852324d0ee8 | peterk1198/office-hour-queue | /src/queue.py | 522 | 3.890625 | 4 | # This is the basic queue
class Node:
def __init__(self, data):
self.data = data
self.next = None
class ClassQueue:
def __init__(self):
self.head = None
self.rear = None
def is_empty(self):
return self.head is None
def enqueue(self, item):
temp = Nod... |
86fe68b0fc2023dec8b91a91e4f931a29482ae82 | KimWoongwon/2A_2 | /게임분석(GameAnalysis)/201021/ex_05.py | 814 | 3.703125 | 4 | # 동계올림픽 클래스
class WinterIOC:
ice_choice = ""
apply_count = 0
def ice_game(self, value):
self.apply_count = value
print("=" * 55)
print("■ 동계올림픽 클래스를 생성하는 프로그램")
print("-" * 55)
print("1. 클래스 생성완료 : WinterIOC")
print("-" * 55)
print("2. 인스턴스 생성 : MyGame")
print("-" * 55)
myGame = WinterIOC()
p... |
18e36d98ee56655d851c86f4af068c5f021004d6 | MorkHub/MorkPy | /postfix.py | 3,493 | 3.984375 | 4 | bidmas = {'*':3,
'/':3,
'+':2,
'-':2,
'(':1,
')':1}
alpha = 'ABCDEFGHIJKLNOPQRSTUVWXYZ0123456789.'
class Stack:
"""python implementation of a stack data structure """
def __init__(self):
self.items = []
self.length = 0
def push(self... |
d59b2ae877ed8592e380b5edc953957e0231985f | boydbelshof/project-iwo | /code.py | 5,277 | 4 | 4 | import sys
# Name: Boyd Belshof
# Student: S3012158
# Date: 25-03-2018
# Description: This program checks in which place in the Netherlands the most political parties
# are mentioned. The program consists out of 4 files, the code.py, the clean_man_names.txt,
# clean_woman_names.txt and parties.txt
# clean_man_names a... |
b56b5e79473c4a69208ff90abb3e529cb4ea6702 | Aravind2595/MarchPythonProject | /functions/demo1.py | 1,284 | 4.28125 | 4 | #functions
#.............
#syntax
#..........
#def fnname(argument1,argument2):
#fn statement
#callinf fuction name
#.......................
#fnname() #using fnname
#1.fn without argument and no return type
#2.fn with argument and no return type
#3. fn with argument and return type
#1.fn without argument and ... |
5c1189a27376df7c76ed4ae95bec5d1193b67e73 | Aasthaengg/IBMdataset | /Python_codes/p03486/s720861669.py | 130 | 3.75 | 4 | a = list(input())
b = list(input())
a.sort()
b.sort(reverse=True)
if ''.join(a) < ''.join(b):
print('Yes')
else:
print('No') |
2a0088861fb9a11f15be432a7b788e2781b32ad9 | nathanielng/python-snippets | /machine-learning/hyperparameter_opt.py | 4,490 | 3.515625 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Hyperparameter Optimization
#
# ## 1. Introduction
#
# This is a demonstration for hyperparameter optimization
# with a comparison with the results from scipy.optimize.minimize
#
#
# ### 1.1 Setup
#
# Dependencies
#
# ```bash
# pip install hyperopt
# ```
# In[1]:
impo... |
d5aae336d719b4c918d687b0e47185400ff9b3ba | shedolkar12/DS-Algo | /Tree/level_order_traversal.py | 1,294 | 3.9375 | 4 | class Queue:
def __init__(self):
self.items = []
def isEmpty(self):
return self.items == []
def enqueue(self, item):
self.items.insert(0,item)
def dequeue(self):
return self.items.pop()
def size(self):
return len(self.items)
class Node:
def __init__(s... |
226968bd61249d257b942f2a8279f18b7e465aa4 | kangli-bionic/algorithm | /lintcode/423.py | 793 | 3.625 | 4 | """
423. Valid Parentheses
https://www.lintcode.com/problem/valid-parentheses/description?_from=ladder&&fromId=37
"""
class Solution:
"""
@param s: A string
@return: whether the string is a valid parentheses
"""
def isValidParentheses(self, s):
# write your code here
stack = []
... |
ff957c3a767d9ac0e68388dfb45de41f87ed9382 | jeryfast/piflyer | /piflyer/old/async,threads,ipc/asyncio_example1.py | 572 | 3.609375 | 4 | # Create a coroutine
import asyncio
timeout=1
coro = asyncio.sleep(1, result=3)
# Submit the coroutine to a given loop
future = asyncio.run_coroutine_threadsafe(coro, loop)
# Wait for the result with an optional timeout argument
assert future.result(timeout) == 3
try:
result = future.result(timeout)
except asyncio... |
a6d28a7c39c4e14f6d004abd998bb747a7c9cb4c | hellojessy/CSCI-1100 | /Homeworks/Homework 9/hw9_part2.py | 2,685 | 3.578125 | 4 | import json
import textwrap
busIn = input('Enter a business name => ')
print(busIn)
k = open('businesses.json')
# FUNCTION CRETAED TO FIND REVIEWS FOR GIVEN BUSINESS
def reviewBus(businessID):
f = open('reviews.json')
countRev = 0
for lineN in f:
review = json.loads(lineN)
... |
00042a832e46bf5699c18e8cb5e14f248d39c23e | matyasfodor/advent-of-code-solutions | /day_08/task1.py | 344 | 3.640625 | 4 | def solution():
escaped_length = 0
unescaped_length = 0
with open('day_08/input.txt', 'r') as input_file:
lines = [raw_line.rstrip() for raw_line in input_file]
for line in lines:
escaped_length += len(line)
unescaped_length += len(eval(line))
return escaped_le... |
9d2895a4a5381a1112d670a06a2ffdd038637930 | HaoChen-ch/shlcom | /model/tcn_test.py | 2,227 | 3.5 | 4 | import numpy as np
from keras.utils import to_categorical
import pandas as pd
from sklearn.preprocessing import LabelEncoder
def data_generator():
# input image dimensions
img_rows, img_cols = 23, 30
# (x_train, y_train), (x_test, y_test) = mnist.load_data()
labelencoder = LabelEncoder()
x_train =... |
7fe0049a1c843d7d6e24b3e707afc4acf73d58c2 | HaemiLee/CS151-Proj3-SceneInScene | /better_shapelib.py | 19,393 | 4 | 4 | #This code holds various shape and aggregate shape functions made from loops.
# Haemi Lee
# CS 151, Fall 2018
# September 25, 2018
# Project 3: Scenes Within Scenes
import turtle
import sys
turtle.tracer(False)
#Instantly draws the scene
def goto( x,y ):
#Sends turtle pen to ( x,y )
print('goto(): going to', x... |
0519056b0c4855c6a40631e37c622d5c1a47edf2 | mallimuondu/python-homworks | /opperations/02.py | 515 | 4.15625 | 4 |
#a = 3
#b = 4
#c = a ** b
#print (c)
#x = 5
#print(x)
#x = 5
#x += 3
#
#print(x)
#x = 5
#x -= 3
#
#print(x)
#x = 5
#x *= 3
#print(x)
#x = 5
#x /= 3
#print(x)
#x = 5
#x%=3
#print(x)
# comparisin opperraters
#x = 5
#y = 3
#
#print(x == y)
#
# returns False because 5 is not equal to 3
#x = 5
#y = 3
... |
3d0374c035c156d0529987889cf9f697e19cab43 | zhoupengzu/PythonPractice | /project/project2.py | 1,623 | 4.21875 | 4 | '''
Mr. Vincent works in a door mat manufacturing company. One day, he designed a new door mat with the following specifications:
Mat size must be X. ( is an odd natural number, and is times .)
The design should have 'WELCOME' written in the center.
The design pattern should only use |, . and - characters.
Size: 7 x... |
30e8ed198790cfeedc8ccf0e2f2192b6c43dbdb5 | Rebell-Leader/bg | /REST/rest-api-sections-master/section2/10_args_and_kwargs.py | 839 | 4.03125 | 4 | def my_method(arg1, arg2):
return arg1 + arg2
def my_really_long_addition(arg1, arg2, arg3, arg4, arg5):
return arg1 + arg2 + arg3 + arg4 + arg5
my_really_long_addition(13, 45, 66, 3, 4)
def adding_simplified(arg_list):
return sum(arg_list)
adding_simplified([13, 45, 66, 3, 4])
# But you need a list :(... |
cb6c57094899a2594e1b2726fe1d07a0ebcd72f8 | UzairIshfaq1234/python_programming_PF_OOP_GUI | /set .py | 167 | 3.890625 | 4 | name_dict={"key1":"value1","key2":"value 2"}
print(name_dict["key1"])
print(name_dict["key2"])
print("______________________________")
x=name_dict.get("key2")
print(x) |
bbf143a47460b3cfefb760dff061686438736238 | claudiodornelles/CursoEmVideo-Python | /Exercicios/ex094 - Unindo dicionários e listas.py | 1,861 | 3.984375 | 4 | """
Crie um programa que leia nome, sexo e idade de várias pessoas, guardando os dados de cada pessoa em um dicionário e todos os dicionários em uma lista. No final, mostre:
1 - Quantas pessoas foram cadastradas.
2 - A média de idade do grupo.
3 - Uma lista com todas as mulheres.
4 - Uma lista com todas as pessoas com ... |
4e553dce095d429952e7161b0c857aaf811d1472 | swilsonmfc/oop4ds | /10_classes.py | 1,677 | 4.34375 | 4 | # %% [md]
# # Introduction
# * Real world objects have state and behavior
# * Software objects have state and behavior
# * State = variables
# * Behavior = functions
# %% [md]
# # Class
# * A Class is our building block for modeling the real world
# * In python we define a class as a template for objects we want ... |
757f3c843ba953ecb90b495591b32a23f983d788 | SaiVK/Leetcode-Archive | /code/Peeking-Iterator.py | 348 | 3.75 | 4 | class PeekingIterator(object, ):
def __init__(self, iterator):
self.listVal = []
while iterator.hasNext():
self.listVal.append(iterator.next())
def peek(self):
return self.listVal[0]
def next(self):
return self.listVal.pop(0)
def hasNext(self):
ret... |
c6a94d4c7a51386c0214a50714257fb6236bb258 | chrisbog/IOTEventNotification | /log_conf.py | 1,729 | 3.703125 | 4 | """
This Code provides the logging mechanisms for our application. It provides a singleton that will be used by all
functions within our software.
"""
import logging
import logging.handlers
import logging.config
def singleton(cls):
"""
This singleton function prevents the user from instantiating multiple ins... |
9e59ecbf54fe1c92cd7d68dfd1ab109c74702c59 | Flood1993/ProjectEuler | /p146.py | 596 | 4.15625 | 4 | """
n /
n**2 + 1 must be prime -> n**2 must be even -> must be even
n**2 + 3 must be prime -> sum of digits of n**2 must be 1 % 3
Since none of the values of n**2 + [5, 11, 15, 17, 19, 21, 23, 25] cannot make a prime number:
n**2 will be an even number. -ON HOLD-
"""
from functions import primes_up_to
primes = prim... |
e349105436865a1fef5b16c9f50aa357d97ccd81 | vinayk98/pycharm_project | /cube.py | 134 | 4.40625 | 4 | #to calculate the cube of any number.
num=int(input('enter any number:'))
#we can find the cube of num,num*num*num.
print(num*num*num) |
8e3a5e5c40f2b97206955b5b837c996a0d10b530 | prabudhakshin1/CodingPractice | /OldOldOld/Sorting/MergeSort.py | 788 | 3.90625 | 4 | #! /usr/bin/env python
import sys
def mergesort(inp, left, right):
if (left==right):
return [inp[left]]
middleElem = left+((right-left)/2)
leftArr = mergesort(inp, left, middleElem)
rightArr = mergesort(inp, middleElem+1, right)
result = []
i=0
j=0
while (i<len(leftArr) and ... |
394e4c6f4bfe743f1e3732b622a3d91e9bb9016e | surapat12/DataStructAlgo-Grader-KMITL | /Week1/highlight.py | 339 | 3.640625 | 4 | if __name__ == '__main__':
print('*** Reading E-Book ***')
text, highlight = input('Text , Highlight : ').split(',') # highlight will be just a single character
out=''
for i in range(len(text)):
if text[i] == highlight:
out += "[" + text[i] + "]"
else:
out += tex... |
d1e8cdbd0e8a2d78bc4216023c12140a4b9b03c2 | Milamin-hub/Pytest | /py/test3.py | 282 | 3.921875 | 4 | i = 1
while i < 11 :
print(i)
i += 1
print("Конец программы")
for i in range(1, 11):
print(i)
print("Конец программы")
x = 1 + i \
+ 1
z = (1 + i + # перенос строки
+ i )
print(x, "\ Перенос строки")
|
d5c7efe1c7f1345be4b3fa2bdc3c1cb218c532e7 | riya1794/python-practice | /py/list functions.py | 815 | 4.25 | 4 | list1 = [1,2,3]
list2 = [4,5,6]
print list1+list2 #[1,2,3,4,5,6]
print list1*3 #[1,2,3,1,2,3,1,2,3]
print 3 in list1 #True
print 3 in list2 #False
print "length of the list : "
print len(list1)
list3 = [1,2,3]
print "comparsion of the 2 list : "
print cmp(list1,list2) # -1 as list1 is small... |
1cc04f634e250f2917a95c854ca1a86ff0bea862 | LucasValada/Exercicios | /calculandodescontos.py | 186 | 3.703125 | 4 | n1 = float(input("Qual o preço do produto?"))
x = n1-(n1 * 5 / 100)
print("O produto que custava R${:.2f}, na promoção está com desconto de 5%, vai custar R${:.2f} ".format(n1, x))
|
236e56eec1a0d61980724eefdafbdec6e8f865c1 | akki2790/Python-Projects | /vowel_count.py | 521 | 4.09375 | 4 | def vowel_count():
vowels="aeiou"
ip_str = raw_input("Enter a string: ")
ip_str = ip_str.lower()
count={}.fromkeys(vowels,0)
for char in ip_str:
if char in count:
count[char]+=1
return count
print vowel_count()
def vowel_count():
vowels = 'aeiou'
ip_str = raw_inp... |
2a95832f54304a64f2afc9aed30b44f2fbc23ca0 | narendrayediginjala/algorithms | /binarySearchTree.py | 738 | 3.9375 | 4 | class Node:
def __init__(self,data,parent):
self.data=data
self.leftChild=None
self.rightChild=None
self.parent=parent
class bst:
def __init__(self):
self.root=None
def insert(self,data):
if self.root is None:
node = Node(data,None)
self.root=node
else:
self.insert_... |
b37559dec6de14ec5a6bcf4856c1b4b4b8bb0d47 | xeonye/LearnOpenCV | /OCR-KNN.py | 1,699 | 3.59375 | 4 | import cv2 as cv
import numpy as np
from matplotlib import pyplot as plt
# ##### Digits Recognition
# img = cv.imread('res/digits.png')
# gray = cv.cvtColor(img,cv.COLOR_BGR2GRAY)
# # Split th image to 5000 cells, each 20x20 size
# cells = [np.hsplit(row,100) for row in np.vsplit(gray,50)]
# # Make it into array
# x... |
99dd324b4fbde4366cd74b8e4849285c282dac83 | swipswaps/micrOS | /micrOS/LM_light_sensor.py | 1,274 | 3.546875 | 4 | """
Source: https://how2electronics.com/temt6000-ambient-light-sensor-arduino-measure-light-intensity/
"""
from sys import platform
__ADC = None
def __init_tempt6000():
"""
Setup ADC
read 0(0V)-1024(1V) MAX 1V input
read_u16 0 - 65535 range
"""
global __ADC
if __ADC is None:
... |
9e269efdc314310ebb01fa0c35f95fb22845e493 | sonyasha/python-challenge | /PyParagraph/main.py | 1,555 | 3.5625 | 4 | import os
from statistics import mean
import re
filepath = os.path.join('raw_data', 'paragraph_1.txt')
with open(filepath, 'r', encoding='latin-1') as txt:
wordsLength = [] # List for keeping all word's length
for line in txt: # Iterate through the line of text
for word in line.split(): # It... |
5ee43ed7ea3c908040b3343fcc9c4932de743387 | vladsergeichev/some_projects | /oop_4.py | 559 | 3.5 | 4 | class Nikola:
"""
Задача с сайта - https://smartiqa.ru/python-workbook/class#4
"""
# Строго задать атрибуты класса
__slots__ = ['name', 'age']
def __init__(self, name, age):
self.name = name
if self.name != 'Николай':
self.name = f'Я не {self.name}, а Николай'
... |
0fd5cd622621ead63cb10dc266ea38caebfb89c7 | losnikitos/coursera | /course3/week2/top_order.py | 1,893 | 3.8125 | 4 | # python3
class Graph:
def __init__(self, n_vertices=0, edges=[]):
self.removed = []
self.vertices = set(range(n_vertices))
self.edges = [set() for _ in range(n_vertices)]
for edge in edges:
a, b = edge
self.edges[a - 1].add(b - 1)
def read(self):
... |
b4865478cdfda9e2f7b6f37b21ea16cf1d0307b6 | arzanpathan/Python | /Assignment 4.py | 1,043 | 3.765625 | 4 |
###################################
# Armstrong No From 1 to 1000
print('\nArmstrong No From 1 to 1000\n')
for i in range(1,1000):
s=0
t=i
while(i!=0):
r=i%10
s=s+(r**3)
i=i//10
if(s==t):
print(s)
# PATTERNS
##################################
print('\nFIRST PATTERN\n')
... |
ae16d0ac5fe7d8291934311e1a6c9fabbc0195c3 | Ghosoun33/testProject | /Day42.py | 794 | 3.734375 | 4 | Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:13:57) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> class person:
def __init__(self, name, age):
self.name = name
self.age = age
def myfunc(self):
print('Hello my name is ' + self.name)
... |
b93efb7496c3bc628f9fb0844313ab660e044443 | ryudongjae/Python-Algorithm | /data_Sturcture/LinkedList/LinkedList003.py | 1,163 | 4.09375 | 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:
node = self.head
... |
7c6faf472fb57a6fe42eec9a0f280788275182a0 | chloexu310/ITP449 | /ITP449_HW04_XU_YANYU/ITP449_HW04_Q2_XU_YANYU.py | 1,675 | 3.5625 | 4 | #Yanyu Xu
#ITP_449, Spring 2020
#HW04
#Question 2
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv('avocado.csv')
pd.plotting.register_matplotlib_converters()
df['Date'] = pd.to_datetime(df['Date'])
df.set_index("Date",inplace=True)
conventional = df[df["Type"]=="conventional"]
#calculate the av... |
8815a0523f601c32df8828bf890f0228d1967725 | mbrown34/PowdaMix | /main.py | 287 | 3.578125 | 4 | """
Created on November 10, 2012
@author Matthew
"""
import menus
import sys
gameOver = False
while gameOver != True:
gameOver = menus.start()
#simple loop to continue game execution while a value is not returned to the menus.main()
#indicating that the game should be terminated.
|
0751f25e26525035bd27869b974d64d35bc0e7fc | thinkreed/pyf | /cs101/unit23/23_4.py | 328 | 3.578125 | 4 | def is_list(p):
return isinstance(p, list)
def deep_count(p):
sum = 0
for e in p:
sum += 1
if is_list(e):
sum += deep_count(e)
return sum
print(deep_count([1, 2, 3]))
print(deep_count([1, [], 3]))
print(deep_count([1, [1, 2, [3, 4]]]))
print(deep_count([[[[[[[[1, 2, 3]]]... |
25ec1f869bae984d7b89467df8df0a346f6531f6 | nikostsio/Project_Euler | /euler12.py | 337 | 3.578125 | 4 | import math
def factor_quantity(n):
quantity = 0
for i in range(1,math.ceil(math.sqrt(n))+1):
if n%i == 0:
quantity += 2
if i*i == n:
quantity -= 1
return quantity
def main():
number = 1
for i in range(2,1000000):
number+=i
if factor_quantity(number)>500:
print(number)
break
if __name__ == '__m... |
fe38de0381533dc5844eb10bb307b3b27ba857d0 | palanuj402/Py_lab | /File/q12.py | 270 | 3.875 | 4 | #num=int(input("Enter a num: "))
print("****FizzBuzz Game******")
for i in range(1,101):
if((i%3==0) and (i%5==0)):
print("FizzBuzz")
elif(i%3==0):
print("Fizz")
elif(i%5==0):
print("Buzz")
else:
print(i)
|
998e41595da981448d2bfb78e2c36f276b7197c2 | nojongmun/python_basics | /step07_object/object/objectEx1.py | 1,343 | 3.640625 | 4 | '''''
클래스 : 사용자가 만드는 자료형
클래스 명 : Person
name : str
age : int
score : float
setPerson(name, age, score)
viewPerson
'''''
class Person:
name = ''
age = 0
score = 0.0
def setPerson(self, name, age, score):
self.name = name
self.age = age
self.score = score
def viewPerson(s... |
1703e6fbb40639c2c124e2b63cc93bcac68d62f9 | a7744hsc/LeetCode-Solutions | /LeetCode-python/218.the-skyline-problem.py | 4,808 | 3.671875 | 4 | #
# @lc app=leetcode id=218 lang=python3
#
# [218] The Skyline Problem
#
# https://leetcode.com/problems/the-skyline-problem/description/
#
# algorithms
# Hard (38.53%)
# Likes: 3715
# Dislikes: 193
# Total Accepted: 202.6K
# Total Submissions: 525.5K
# Testcase Example: '[[2,9,10],[3,7,15],[5,12,12],[15,20,10],... |
82b11a41f765413552bce3d61043be118a989ca5 | guohaoyuan/algorithms-for-work | /leetcode/老是做不对的/第三梯队/20. 有效的括号 easy 没思路/isValid.py | 1,135 | 4.0625 | 4 | """
创建一个栈,一个哈希表(哈希表中存放左括号:右括号)
1. 特殊情况:如果字符串为空。直接返回True
2. 遍历字符串s:
如果当前栈stack为空,或者当前字符是右括号,直接入栈
如果当前栈存在:
如果当前栈顶元素==哈希表中对应的左括号:右括号,表示匹配上了,还需要pop栈顶元素
否则,表示没有匹配上,直接返回False
3. 如果上面的遍历操作结束,stack依旧存在,返回False;否则返回True
"""
class Solution:
def isValid(self, s: str) -> bool:
i... |
69e0be5311eaf19bd19e47118cf9024c586115ce | Crank68/python_basic | /Module16/09_friends/main.py | 489 | 3.71875 | 4 | friends = [0 for _ in range(int(input('Кол-во друзей: ')))]
IOUs = int(input('Долговых расписок: '))
for number in range(1, IOUs + 1):
print(f'\n{number} расписака')
whom = int(input('Кому: '))
fromm = int(input('От кого: '))
money = int(input('Сколько: '))
friends[whom - 1] -= money
friends[f... |
c14519f52403b3bfc7b16ec83b1923ba268849ba | achrefbs/holbertonschool-interview | /0x09-utf8_validation/0-validate_utf8.py | 677 | 3.921875 | 4 | #!/usr/bin/python3
"""
determines if a given data set represents a valid UTF-8 encoding.
"""
def validUTF8(data):
"""
determines if a given data set represents a valid UTF-8 encoding.
"""
n = 0
for d in data:
r = format(d, '#010b')[-8:]
if n == 0:
for bit in r:
... |
f54474724203b80c8ef458a7c053963c16a592a0 | wilsonfr4nco/cursopython | /Modulo_Intermediario/funcao_parte4/aula35_2.py | 227 | 3.875 | 4 | """
Escopo de variável em python
"""
def func():
variavel1 = 'wilson'
return variavel1
def func2(arg):
print(arg)
var = func()
func2(var) # passando o valor de uma função para outra sem usar variável global
|
5644cad46903516c573f84cc8cf2e1d807e05717 | Ar7115/Mision-04 | /Reloj.py | 2,872 | 3.796875 | 4 | # Autor: Luis Armando Miranda Alcocer
# Descripción: Convertir la hora de un formato de 24 horas a uno de 12 horas.
def calcularHorasFormatoDoce (horasFormatoVeinticuatro): #Clasifica las horas, si se teclea 13, se regresa 1, y así sucesivamente.
if horasFormatoVeinticuatro == 13:
horasFormatoDoce = 1... |
5d728047710f7ca27714813542a27abbcb338acb | nada96k/python | /cashier.py | 651 | 3.84375 | 4 |
itm = input('Item (enter "done" when finished): ')
gros=[]
while itm != "done":
a={'name':'' ,'price':0.0 ,'quantity':0 }
a['name']=itm
price = float(input('Price: '))
a['price']=price
quantity = int(input('Quantity: '))
a['quantity']=quantity
gros.append(a)
itm = input('Item (enter "done" when finishe... |
05e3b457072f12a2041d2e40ee3a89a01b31dd7d | Monster-Moon/hackerrank | /baekjoon/09/3053.py | 79 | 3.703125 | 4 |
from math import pi
r = int(input())
print(pi * (r ** 2))
print(2 * (r ** 2)) |
6d8d06f581bfe3d5c2f10145258e93453aad9610 | ethan-morgan/IntroToProg-Python | /Assignment05.py | 4,642 | 3.8125 | 4 | # ------------------------------------------------------------------------ #
# Title: Assignment 05
# Description: Working with Dictionaries and Files
# When the program starts, load each "row" of data
# in "ToDoToDoList.txt" into a python Dictionary.
# Add the each dictionar... |
784adda40fdd577586fadd3dc339ea18cea2a07c | mudouasenha/python-exercises | /ex25.py | 265 | 3.84375 | 4 | def check_list_contains_value(value_list, number):
for value in value_list:
if number == value:
return True
return False
print("1", check_list_contains_value([ 1, 5, 8, 3 ], 1))
print("7", check_list_contains_value([ 1, 5, 8, 3 ], 7))
|
a7eb9aa1fa0e83b21e1d46edff404aeff370f40c | rishabmsaini/Python-Projects | /Machine Learning/Pneumonia Detection/cnn.py | 2,482 | 3.875 | 4 | # Convolutional Neural Network
# Part 1 - Building the CNN
# Importing the Keras libraries and packages
from keras.models import Sequential # To initialize our NN
from keras.layers import Conv2D # To add convolutional layers
from keras.layers import MaxPooling2D # To add pooling layers
from keras.layers import Flatten ... |
dd206e6a5a43041afb0b0c0d642a9812aae3e2e3 | Forif-PythonClass/Assignments | /Bojung/2강/2_4 list addition.py | 154 | 3.8125 | 4 | num = 0
add = 0
sum_list = [1,2,-20]
while num <= 2 :
add = add + int(sum_list[num])
num = num + 1
print 'The sum of the list is ' + str(add)
|
3043df792fff6b7c31a8a72d5dcee289a92189ce | samueljackson92/simple-turing-machine | /turing_machine.py | 2,711 | 3.5625 | 4 | #############################################
# Simple Turing Machine
# Author: Samuel Jackson (slj11@aber.ac.uk)
# Date: 11/2/13
#############################################
from argparse import ArgumentParser
import re
pointer = 0 #instruction pointer
tape = None #tape of symbols
program = [] #the program to r... |
5e200db6ae9fdd4764b0fdcce2e795c63db1ba63 | Rashika233/Task | /if_else2.py | 192 | 3.921875 | 4 | x=eval(input('Enter the value of x'))
y=eval(input('Enter the value of y'))
if x==100:
print('Value is 100')
if y==200:
print('Value is 200')
else:
print('error occoured')
|
a8408992021336287975ad791477fdc627dced9e | mahdavipanah/pynpuzzle | /algorithms/breadth_first_search.py | 701 | 3.609375 | 4 | """
pynpuzzle - Solve n-puzzle with Python
Breadth-first search algorithm
Version : 1.0.0
Author : Hamidreza Mahdavipanah
Repository: http://github.com/mahdavipanah/pynpuzzle
License : MIT License
"""
from .util.tree_search import Node
from collections import deque
def search(state, goal_state):
"""Breadth-firs... |
c7aba82dcca986efab22cc2a17f65cafaf581c52 | SR-Sunny-Raj/Hacktoberfest2021-DSA | /04. Arrays/TwoDimensionalArrays.py | 1,135 | 3.640625 | 4 | import numpy as np
twoDArray = np.array([[11, 15, 10, 6], [10, 14, 11, 5],
[12, 17, 12, 8], [15, 18, 14, 9]])
print(twoDArray)
# newTwoDArray = np.insert(twoDArray, 1, [[1,2,3,4]], axis=0)
# print(newTwoDArray)
print(len(twoDArray))
newTwoDArray = np.append(twoDArray, [[1, 2, 3, 4]], axis=0)
p... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.