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 |
|---|---|---|---|---|---|---|
092b2594f9159f72119349177487a3c0ffe8ebde | kronecker08/Data-Structures-and-Algorithm----Udacity | /submit/Task4.py | 1,306 | 4.15625 | 4 | """
Read file into texts and calls.
It's ok if you don't understand how to read files.
"""
import csv
with open('texts.csv', 'r') as f:
reader = csv.reader(f)
texts = list(reader)
with open('calls.csv', 'r') as f:
reader = csv.reader(f)
calls = list(reader)
call_outgoing = []
call_incoming = []
fo... |
d7392f50d90594336eb4a19f144149b7e341aef6 | manmohanalla2/aisera | /binary_tree_balanced.py | 939 | 3.953125 | 4 | class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def height(root):
if root is None:
return 0
return max(height(root.left), height(root.right)) + 1
def isBalanced(root):
if root is None:
return True
lh = height(root.... |
713433e5e5191c6b054b30ad4de22ad0cb344dd3 | zhanghongdatongji/zhd | /python/readTest_1.py | 148 | 3.796875 | 4 | from sys import argv
textfile=raw_input("Please print a txt filename: ")
text=open(textfile)
print"The content of %s:"% textfile
print text.read()
|
62a996b24e753aadd9bfdcff066e3337e5d7a1e9 | zhanghongdatongji/zhd | /python/ex14_1.py | 65 | 3.75 | 4 | a={1,2,3}
b={1:'a',2:'b',3:'c',4:'d'}
for i in a:
print b[i]
|
d3760baba77aa112d2860cbeed1ef56f378347be | iamrobinhood12345/economic-models | /base-model.py | 2,642 | 4.21875 | 4 | # Basic Flow of Money Model
import sys
MODEL_NUMBER = 1
INPUT_STRING = """
MAIN MENU:
Input amount to loan (integer).
Input 'q' to quit program.
"""
EXIT_STRING = """
Thank you, goodbye!
By Ben Shields <https://github.com/iamrobinhood12345>... |
622c64cf7a941c74e53410901a721f1b010959c5 | NikhilReddy101995/Parkinglot | /src/tests.py | 5,353 | 3.5 | 4 | from vehicle import vehicle
from Parkinglot import Parkinglot
import unittest
class TestSum(unittest.TestCase):
def test_vehicle_class(self):
vehicleobj=vehicle('KA-01-HH-1234','red')
self.assertEqual(vehicleobj.RegestrationNo,'KA-01-HH-1234', "Should be KA-01-HH-1234")
def test_Park... |
6f650cbf03581db1df2139992b6831985fa7d9bc | arisskz6/learnPython | /chapter03/list_pop_004.py | 166 | 3.8125 | 4 | # Remove elements from the list
motorcycles = ['honda', 'yamaha', 'suzuki']
last_owned = motorcycles.pop()
print(f"The last motorcycle I owned was a {last_owned}.")
|
a868af86d0102fe2aafd0b10782840ecad86768e | KC1988Learning/TkinterLearning | /tutorial/grid.py | 2,025 | 4.15625 | 4 | import tkinter as tk
from tkinter import ttk
from window import set_dpi_awareness
def greet():
# add strip() to remove whitespace in string
print(f"Hello {user_name.get().strip() or 'World'}! How are you?")
set_dpi_awareness()
root = tk.Tk()
root.title("Greeting App")
# configure row and column property of ... |
e22c8d1f179a588ff8b178c85ceb8f1e82602ae0 | Neapol94/python | /dwa.py | 4,839 | 3.6875 | 4 | import sqlite3
import random
# utworzenie połączenia z bazą przechowywaną na dysku
# lub w pamięci (':memory:')
con = sqlite3.connect('C:/sqlite/db/football.db')
# dostęp do kolumn przez indeksy i przez nazwy
con.row_factory = sqlite3.Row
# utworzenie obiektu kursora
cur = con.cursor()
class Team:
def __getite... |
ef96866981773d191c95ba2fccb4f83d0ed188a4 | woneata/ATM | /auth.py | 4,436 | 4.03125 | 4 | # register
# -first name, last name, password, email
# -generate user id
# login
# - account number, email and password
# bank operations
# Initializing the system
import random
import validation
import database
import login
from getpass import getpass
# database = {
# 648957: ['Woneata', 'Stallworth', 'wonea... |
b36edf86ded06abda81f4b92e812602d529b3a9b | jaunRuizz/Script-Correos-Electronicos | /Enviar_correos_gmail-V1.0.py | 1,633 | 3.734375 | 4 | # Librerias a utilizar
import smtplib
# Mensaje que enviaremos y el asunto
def Msg():
Mensaje = input("Ingresa el mensaje que deceas mandar: ")
Subject = input("Ingresa el asunto del mensaje: ")
Mensaje = "Subject: {}\n\n{}".format(Subject, Mensaje)
# Esta funcion retorna el mensaje q... |
dd143660a1253a1c2b5acf66fee8394ac81bd90b | Zpp-hub/python-object-oriented | /函数/9# 闭包.py | 2,769 | 3.578125 | 4 | # -*- coding: utf-8 -*-
# 将函数作为返回值返回,也是一种高阶函数
# 这种高阶函数我们也称为叫做闭包,通过闭包可以创建一些只有当前函数能访问的变量
# 可以将一些私有的数据藏到的闭包中
'''
闭包:
在一个外函数中定义了一个内函数,内函数里运用了外函数的临时变量,并且外函数的返回值是内函数的引用。这样就构成了一个闭包。
一般情况下,在我们认知当中,如果一个函数结束,函数的内部所有东西都会释放掉,还给内存,局部变量都会消失。但是闭包是一种特殊情况,
如果外函数在结束的时候发现有自己的临时变量将来会在内部函数中用到,就把这个临时变量绑定给了内部函数,然后自己再结束。
'''
# ... |
be0671e270c1be675a1433ea965bd29c807c7426 | sunilsrivatsav/Python-Tutorials | /sorting/binary_search.py | 627 | 3.859375 | 4 | list = [1,6,9,15,34,55,78]
## list should be sorted for binary search
list.sort()
num_pos = -1
def binarysearch(n,list):
L = 0
U = len(list)-1
while(L<=U):
#### calculate mid and compare the value
mid = (L+U)//2
if list[mid]==n:
globals()['num_pos']=mid
retur... |
ce4c8e9a4888f8ccf497d39c76c45cad212a65e3 | mynameisfiber/Misc-Old-Projects | /l-systems/dragon1.py | 711 | 3.5625 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
# Made by Michael Gorelick (mynameisfiber@gmail.com)
# Copyleft 2009
# Dragon Curve
# variables : X Y
# constants : F + −
# start : FX
# rules : (X → X+YF), (Y → FX-Y)
# angle : 90°
import turtle, pytools
set = "FX"
rules = {"X":"X+YF","Y":"FX-Y"}
for n in range(10):
ne... |
31f0b78bee04330369a96b936e35b83ab7499333 | mynameisfiber/Misc-Old-Projects | /euler/problem1.py | 161 | 4.15625 | 4 | #!/usr/bin/python
"""Find the sum of all the multiples of 3 or 5 below 1000."""
sum=0
y=3
while y<1000:
if y % 3 == 0 or y % 5 == 0:
sum+=y
y+=1
print sum
|
f2f7e8fcddc8bbec69bc2ece961863041e29d6a5 | mynameisfiber/Misc-Old-Projects | /euler/problem5.py | 281 | 4.0625 | 4 | #!/bin/local/python
"""What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?"""
test= 0
found=1
while found != 0:
test += 20
found = 0
for i in range(1,20):
found += test % i
print "Tested: ", test, "Remainder of: ", found
print test
|
cedf71f34ee07503c6757d483a0cb2a8cdd55d79 | mynameisfiber/Misc-Old-Projects | /euler/problem6.py | 302 | 3.78125 | 4 | #!/usr/local/python
"""Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum."""
sumSquares=0
squareSum=0
for i in range(1,101):
sumSquares+=i*i
squareSum+=i
print squareSum*squareSum,sumSquares
print (squareSum*squareSum-sumSquares) |
2b076d8fc8fcc03a28a5c31caa6edbab4125cd5e | PaulaPascualParra/ChecksPalidrome | /test/functionTest.py | 1,158 | 3.625 | 4 | import unittest
from src import function
class PalindromeOptimized(unittest.TestCase):
PALINDROME = "abba"
NOT_PALINDROME = "abba3"
def test_whenPalindromePass_returnTrue(self):
self.assertTrue(function.is_palindrome_optimized(self.PALINDROME))
def test_whenPalindromeNotPass_returnFalse(self... |
8f5a6a13f8131ff2627be7c834007706edf02c71 | karim-aboelazm/PyCheckio_ScientificExpedition | /Bird Language/mission.py | 869 | 4 | 4 | VOWELS = "aeiouy"
def translate(phrase):
new_phrase = ''
skip = 0
for x in phrase:
if x in VOWELS and skip == 0:
new_phrase += x
skip = 3
elif x not in VOWELS and skip == 0 and x != ' ':
new_phrase += x
skip = 2
elif x == ' ':
... |
5261f065293b87835b76e3b2f373c3a3210a8d2e | AlexandrZaharov/Alex | /main_part.py | 6,985 | 3.59375 | 4 | import sys
import pygame
from pygame.rect import Rect
pygame.init()
'Задаём размеры экрана'
width = 1000
height = 600
'Параметры игры'
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption('VOLLEYBALL')
clock = pygame.time.Clock()
'Описываем класс операций с векторами'
class Vector:
... |
5ffd89395a2b61700c1af3010f002e0a15f08c32 | makmoreAUT/PGP-AIML | /MovieLens_Project_Delivery_Makarand_More.py | 9,946 | 3.625 | 4 | #!/usr/bin/env python
# coding: utf-8
# ### Project - MovieLens Data Analysis
#
# The GroupLens Research Project is a research group in the Department of Computer Science and Engineering at the University of Minnesota. The data is widely used for collaborative filtering and other filtering solutions. However, we will... |
8249cedbf1128d2b67132504a097ff6296fda9ab | zdenekN61/airports | /modules/airports.py | 4,490 | 3.609375 | 4 | """A module to gets informations about airports
from http://www.airlines-inform.com
It is neccesary to do few 'steps' before you get what you wanted.
- gets records for country(links to airports, feedbacks, etc.).
- sorted it, gets only airports links.
- gets informations you wanted(name, IATA, ICAO, we... |
bc2fc52ef8379ebc0a13d9f3378e561094dd8851 | JasonLeemz/code | /test.py | 1,010 | 3.78125 | 4 | # -*- coding: utf-8 -*-
import time
import threading
import Queue
# lock = threading.Lock()
#待发送队列
awaite_queue = Queue.Queue()
def enqueue(data):
awaite_queue.put(data)
def call(data):
pass
def send():
while True:
if not awaite_queue.empty():
call(awaite_queue.get())
queue = Qu... |
6f34c3b7719f21c2cdec11499c979d5be9e9ce08 | diegohbrandl/aprendendo-python | /cursoPython/aula7a.py | 314 | 3.921875 | 4 | n1 = int(input('digite o valor 1 >>> '))
n2 = int(input('Digite o valor 2 >>> '))
s = n1 + n2
m = n1 - n2
mu = n1 * n2
d = n1 / n2
e = n1 ** n2
di = n1 // n2
print('A soma >> {}\n subtração >> {}\n multiplicação >> {}\n divisão >> {}\n elevação >> {}\n divisão inteira >> {}\n'.format(s, m, mu, d, e, di))
|
54c12f0bb114c1561934224918da8d6079679d2a | tikitae92/Python-IS340 | /Ch2/emailTemplateEx.py | 304 | 3.859375 | 4 |
#ask user to enter the inputs
studentName=input("Enter student name: ")
GPA=float(input("Enter student GPA: "))
SEMESTER="Fall"
YEAR=2020
emailTemplate="""Dear %s,
Your current GPA for the %s %d is %.2f.
CSULB Admission
"""
print(emailTemplate %(studentName,SEMESTER,YEAR,GPA))
|
2187a231f1f106cda0dc9fd7729392c5077865f2 | tikitae92/Python-IS340 | /EC2/LeeEC2Q1.py | 2,796 | 3.515625 | 4 | #Import library
from openpyxl import *
from statistics import *
from textblob import TextBlob
#Load excel file
exFile=load_workbook("rest.xlsx")
#Confirm the active sheet
sheet1TL=exFile.active
#Make a list for star ratings from excel
starRatings=[]
for i in range (2,24):
starRating=sheet1TL.cell(c... |
24e335ecf0a79e60026e0a3f41f5277b7ab839ef | tikitae92/Python-IS340 | /Ch4/whileCheckout2.py | 1,011 | 4.15625 | 4 | #example of sale transaction in a store
#cashier doesnt know the # of items in a cart
#input price
#add to total and display in the while loop
#starts sale transaction and ends it when no items are left
#keep track of # of items in customer shopping cart
#print total # of items
#stop when user enter -1
#if nega... |
d0853f8cb4f8c42a8eee4953747c003189c352be | sanyatkach/1repository | /classes.py | 1,081 | 3.78125 | 4 | import random
import itertools
class Card:
def __init__(self, rank, suit):
self.rank = rank
self.suit = suit
def __str__(self):
return f'{self.suit} of {self.rank}'
class Deck:
def __init__(self):
self.cards = []
ranks = (2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K... |
8cfcf8427871ec90c2a2a285d431335ee39ea7b8 | chsasank/sitk-docs | /build/html/_downloads/plot_image.py | 13,046 | 3.78125 | 4 | """
Image Basics
************
Image class is basic container for image data in SimpleITK.
It can hold 2 or 3 dimensional images and pixel can be either be a scalar or a vector.
A RGB image for example, is a 2 dimensional image with 3 component vector pixel.
.. contents:: Contents
:local:
:backlinks: none
C... |
087c3d3ce89cd5bea2db43d87f3261da28f2740b | UlisesRamirez/Clicker | /MainGame.py | 2,299 | 3.90625 | 4 | from Resources import MoneyClass
from Resources import UpgradesClass
mainPlayer = MoneyClass.Money(100)
mainPlayer.initializeUpgrades()
# main game function, needs to read input and perform actions
# It's called in the final while loop
def inputClassification():
function = input(': ').lower().split()
if funct... |
a6c0106ee6341367e9d48fbdbd7f80463b1e8d80 | tyang98/PyProjects | /src/hangman.py | 1,622 | 4.0625 | 4 | # hangman.py
# Anne Bracy (awb93)
# March 28, 2018
"""Module with one class: a SecretWord"""
class SecretWord():
"""A word to be guessed by a user in a game of hangman.
Instance attributes:
secret_word: the word being guessed [str of lower case letters]
display_word: word as the user sees i... |
e8749dcd4e057a8849457e0eb548b8dc2db17c12 | ulphidius/flask_docker_course | /flask_docker_course/user.py | 285 | 3.5625 | 4 | class User():
def __init__(self, id, username, age):
self._id = id
self._username = username
self._age = age
def as_dict(self):
return {
'id': self._id,
'username': self._username,
'age': self._age
}
|
7810b41dd2bb66d38294c487a0518f743e8284f2 | Jlamba2108/The-Pong-Game | /main.py | 2,782 | 3.8125 | 4 | from turtle import *
from paddle import Paddle
from ball import Ball
from scoreboard import Scoreboard
import time
screen = Screen()
screen.bgcolor("black")
screen.setup(width=800, height=600)
screen.tracer(0)
player_name1 = screen.textinput(title=" ", prompt="Enter Player 1 Name :")
player_name2 = screen.textinput(tit... |
fbf74dfb475b7f1d3ee5e7a247c6c40b3a615d0e | camarena2/camarena2.github.io | /secretworld.py | 800 | 4.25 | 4 |
print(" Welcome to the Secret Word Game. Guess a letter in the word, then press enter:")
from random import choice
word = choice(["table", "chair", "bottle", "plate", "parade", "coding", "teacher", "markers", "phone", "grill", "friends", "fourth", "party"])
guessed = []
while True:
out = ""
for letter in... |
219e4b12d647c28e5472d07ccf113e778a389bcb | camarena2/camarena2.github.io | /name_generator.py | 460 | 3.734375 | 4 |
import random
first = ("Amy", "Bob", "Billy", "Ben", "Alyssa", "Natalie", "Mari", "Christian", "Cora", "Lalo", "Joel", "Eric", "Erika", "Eugene", "Mazikeen", "Linda", "Chloe", "Benneth")
second = ("James", "Kerry", "Mate", "Camino", "Flotando", "Botella", "Tableta", "Mesa", "Madera", "Dolbiniak", "Jenski", "Spy", "Ana... |
ae10401635bd3492cf1d7372dbccfa5f89a0fee9 | TechnoMom/Learn-Python-the-Hard-Way-3-Exercises | /ex36.py | 4,879 | 4.0625 | 4 | from sys import exit
def tunnel2():
print """The tunnel branches yet again. The left side slopes down, while
the right side slopes up. Which way do you go?"""
choice = raw_input("> ")
if choice == "left":
smalltreasure()
elif choice == "right":
dead("You come out on cliff full of ha... |
93cc3dd4c06bbdf37b63c788d2362bec2a105966 | allbackoff/test_data_generation_with_PDG | /evaluation/gcd.py | 235 | 3.9375 | 4 | def gcd(a, b):
if a < b:
a, b = b, a
while b > 0:
a %= b
a, b = b, a
return a + b
def main():
a = int(input())
b = int(input())
print(gcd(a, b))
if __name__ == "__main__":
main()
|
041dbf38767b723327ebf197bba3cf02bbf10a5b | raymccarthy/codedojo | /adam/firstWork/adam.py | 461 | 4.21875 | 4 | calculator = "Calculator:"
print(calculator)
one = input("Enter a number: ")
two = input("Enter another number: ")
three = input("Would you like to add another number?: ")
if three == "yes" or three == "Yes":
thre = input("What would you like that number to be: ")
answer = float(one) + float(two) + float(thre)... |
884515ba53243e1e5f761d236b7cd7b172b216d8 | R-Babz/hello-world | /Week3_Assignment_Babikir.py | 1,234 | 3.875 | 4 | import json
sort_field = ''
while (True):
sort_field = input('Please enter the sort field name: ')
if sort_field == 'gender' or sort_field == 'state' or sort_field == 'sale_date':
break
print('Invalid value, please try again!')
filename = 'Assignment_3_datafile.json'
... |
a7ea7d24373085e6822da0ff924304b434ed8d52 | pasanchamikara/ec-pythontraining-s02 | /data_structures/tuples_training.py | 507 | 4.46875 | 4 | # Tuples are unchangeable once created, ordered and duplicates are allowed.
vegetable_tuple = ("cucumber", "pumkin", "tomato")
# convert his to a set and assign to vegetable_set
# get the lenght of the tuple vegetable_tuple
fruit_tuple = ("annas", )
# get the result of print(type(fruit_tuple)) with and without com... |
709feda61e29e21d1ac7cf0d6fcaabd15eaf305f | cezar-r/celearn | /celearn/model_selection.py | 688 | 3.96875 | 4 | #!/usr/bin/env python
# coding: utf-8
"""
Contains functions that can be used to manipulate data so that it can be used for fitting models
"""
import random
def train_test_split(X, y, test_size = .25):
"""Splits X and y into training and testing data
Parameters
----------
X: 2D list
y: 2D list
... |
8c3863a27a0185e62b9b7f13096904d611cabc7a | sergeisaburov/python_lesson_5 | /разработка_3_.py | 3,058 | 4.125 | 4 | # Необходимо реализовать модуль divisor_master. Все функции модуля принимают на вход натуральные числа от 1 до 1000.
# Модуль содержит функции:
# 1) проверка числа на простоту (простые числа - это те числа у которых делители единица и они сами);
import random
def IsPrimeNumber(number):
divisor = 2
# while number ... |
7fa31936b3b9db69fa95870a8af0c8fb2d56882f | yongtao-wang/leetcodes | /algorithms/linked_list.py | 6,819 | 3.953125 | 4 | # -*- coding: utf-8 -*-
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class LinkedList(object):
def addTwoNumbers(self, l1, l2):
"""
# 2
You are given two non-empty linked lists representing two non-n... |
91b25c3cbd1a0ecebcca51f1e18ae9e6e31387a7 | nohens/diary | /seunghyun/algorithmn/programmers/level1/2_str_to_int_test.py | 143 | 3.609375 | 4 | def int_to_str(num):
return str(num)
def test_int_to_str():
assert int_to_str(1234) == '1234'
assert int_to_str(-1234) == '-1234'
|
ed65053d99b6697021962bb32d8f47b1ca3c1aa3 | rariera/ruseRun | /testcurses.py | 1,111 | 3.84375 | 4 | from curses import wrapper
import curses
def main(stdscr):
'''The main function which will run throughout the game.'''
curses.initscr()
window = curses.newwin(15, 30, 1, 1) #creating a window that is 15x15
window.box() #a box appears around the window
gameMap = '''
####################
###.#...####... |
a409c32fcd83e4afe42ace8c7a3cae07bfbb047e | ravikrranjan/learning-python | /while_loop.py | 257 | 4 | 4 |
number = 8
guess = int(input("I'm thinking a number between zero to ten, Can I gusess ? "))
while True:
if guess == number:
break
else:
guess = int(input('Nope, Try agian :'))
print("You gussed it, I was thinking about", number)
|
24e6fe06c5234e7e097071c0328f686c45451d4e | ravikrranjan/learning-python | /python_example/literal.py | 403 | 3.921875 | 4 | fruits = ["apple", "mango", "orange"] # list
numbers = (1, 2, 3) # tuple
alphabets = {'a': 'apple', 'b': 'ball', 'c': 'cat'} # dictionary
vowels = {'a', 'e', 'i', 'o', 'u'} # set
print(fruits)
print(numbers)
print(alphabets)
print(vowels)
print(type(fruits))
print(type(numbers))
print(type(alphabets))
print(type... |
2556f690aa4ee14e8b60289e77e080c9d4a85dd7 | ravikrranjan/learning-python | /python_example/pass.py | 491 | 3.75 | 4 |
def getName():
pass
# return "Ravi"
print(getName()) # None
def getName():
pass
return "Ravi"
print(getName()) # Ravi
def greet(name):
"""
This function greets to the person passed
is as a parameter
"""
print("Hello", name, ". Good morning!")
greet("Ravi")
print(greet(... |
a93cf5e01d29b6ad82b181ea1c83c3ba84aad804 | ravikrranjan/learning-python | /exercise_string.py | 507 | 4.0625 | 4 | # create a program that asks the user for his first name , his middle name and his last name. then print
firstName = input("Enter your first name: ")
middleName = input("Enter your middle name: ")
lastName = input("Enter your last name: ")
print("Your initilas are " + firstName[0] +
" " + middleName[0] + " " + ... |
4698677374d2cb97e05f4cd01373651e893c4cfb | vandinhovicosa/python3Em6Horas | /2 Sintaxe em Python/variaveis.py | 245 | 3.8125 | 4 | # variaveis em python
#Strings
name = 'Genocidas vivem mortos matando os vivos.'
print(name)
#Float
number =12.5
print(number)
#inteiro
number1 = 12
print(number1)
#boolean
a = True or False
print(a)
#Complexo
numero_complexo = 12+5j
print(numero_complexo) |
11e164cb40431510a90c4b198187603bf5ffe521 | schipeltaper/Smartgrid | /classes/battery.py | 3,208 | 4.0625 | 4 | '''
* battery class
*
* Programmeertheorie
* Optimum Prime
*
* The battery class saves all the information concering the batteries inside the configuration.
*
'''
from classes.house import House
class Battery():
'''
The battery class saves all the important information too the battery in the configuration
... |
de938c72a00969af4e4518f6c61fbff8d0c32695 | schipeltaper/Smartgrid | /visualization/check50_to_visualization.py | 3,351 | 4.0625 | 4 | '''
* Visualization class
*
*
* Programmeertheorie
* Optimum Prime
*
* The Check_to_visualization class creates a visualization of all the houses, batteries and cables of a result.
'''
import matplotlib.pyplot as plt
import json
import numpy as np
class Check50_to_visualization():
'''
The initialization re... |
04b8cd3fb9f141dd754cbdbd0ec6db814c7805e6 | Kritchai242/basicpython | /whileloop.py | 104 | 3.625 | 4 | i=1
while i<=100:
if i%10==0:
print(i)
else:
print(i,end=",")
i=i+1
|
6f36fb6427c6ab744ecc08f67112a5454516dd45 | Kritchai242/basicpython | /list.py | 892 | 3.9375 | 4 | # การสร้างข้อมูลแบบ List
number = [5, 8, 13, 24, 7, 16]
name = ['Jhon', 'Jane', 'Jame', 'Chai']
Mixed = [10, 25, 75, True, 'Krichai']
# การเข้าถึงสมาชิกใน List
print(number[5])
print(name[3])
print(Mixed[2], Mixed[3])
# การนับสมาชิกใน List
print("สมาชิกทั้งหมดชิก", len(number))
# การสร้าง List แบบว่าง
data = []
# การเพ... |
6d2b06ebe279933bfaec64883289b897948d81ee | haider10shah/python-tricks | /functions.py | 1,905 | 4.3125 | 4 | def yell(text):
return text.upper() + '!'
def greet(func):
greeting = func('How are you')
return greeting
def whisper(text):
return text.lower() + '...'
def speak(text):
def whisper(t):
return t.lower() + '...'
return whisper(text)
def get_speak_func(text, volume):
def whispe... |
ed5e4a4e7015b476a213a326489eab757db82b42 | JoshuaR830/HAI | /Lab 1/Excercise 4/ex2.py | 409 | 4.03125 | 4 | wordEntered = input("Enter a word with an affix")
affixes = ['pre', 'un', 'ality', 'ning', 'es']
for affix in affixes:
lengthOfAffix = len(affix)
word = ""
if(wordEntered.endswith(affix)):
word = wordEntered[:-lengthOfAffix]
break
elif (wordEntered.startswith(affix)):
word = wo... |
32d6e902356eeec9d4cfcab5bd4f1c8d4398dea3 | JoshuaR830/HAI | /Lab 1/Excercise 4/ex9.py | 272 | 4.28125 | 4 | words = ["This", "is", "a", "word", "list"]
print("Sorted: " + sorted(words))
print("Original: " + words)
words.sort()
print("Original: " + words)
# sorted(words) prints does not change the order of the original list
# words.sort() changes the original order of the list |
6b15dbc9edd9a6ecc5d6d4892dd3960295eeea78 | defjin/RepeatBook | /알고리즘퍼즐68기초편/01_앞뒤가같은10진수만들기_book.py | 425 | 3.5 | 4 | num = 11
while True:
num_10 = str(num)
#1
#num_2 = bin(num)[2:]
#num_8 = oct(num)[2:]
#2
#num_2 = bin(num).replace("0b","")
#num_8 = oct(num).replace("0o","")
#3
num_2 = "{0:b}".format(num)
num_8 = "{0:o}".format(num)
# 16진수는 0x
if num_2 == num_2[::-1] and num_8 == nu... |
7718f20ff6d0baf4a5a741e84ffd1ef6afd62dd4 | MarkHooks/unit_eleven | /breakout.py | 4,293 | 4.03125 | 4 | import pygame, sys
import ball
import brick
import paddle
from pygame.locals import *
def main():
# Constants that will be used in the program
APPLICATION_WIDTH = 400
APPLICATION_HEIGHT = 600
PADDLE_Y_OFFSET = 30
BRICKS_PER_ROW = 10
BRICK_SEP = 4 # The space between each brick
BRICK_Y_OFF... |
3a628384b38f87b482b519ece2fb3bc77af35c17 | poa28451/AdventOfCode | /Day1-Frequency.py | 877 | 4.03125 | 4 | def check_frequency(filename: str):
input_file = open(filename)
freq_change_list = input_file.readlines()
freq_list = set() # Use set instead of list because of element searching performance
frequency = 0
is_duplicated = False
round = 0
while not is_duplicated: # Perform frequency... |
ff7f4d0409ba6d8901461f743609e639ee6ee5f4 | sabharsh/GPS_Data_Retrieval | /ada_gps.py | 2,273 | 3.796875 | 4 | """
Main Function: get_location(gps_uart)
Returned value: "<utc_time>, <latitude>, <longitude>, <num_satellites>, <altitude>, <heading>, <speed>"
Note: GPS pins depend on the UART initialization in the calling function.
Reference: https://cdn-learn.adafruit.com/downloads/pdf/adafruit-ultimate-gps.pdf
"""
from p... |
4adf21e7fede5d38adadca613284aec10c340125 | FarrelRamdhani/BasicWithFarrel | /Program/Program Sederhana Mencari Modus.py | 372 | 3.75 | 4 | def Modus(list_angka):
count = 0
terbanyak = list_angka[0]
for i in list_angka:
flag = list_angka.count(i)
if flag >= count:
count = flag
terbanyak = i
return(terbanyak)
while True:
a = input("Masukkan list angka : ")
list_angka = a.split()
print("M... |
0fdac6ba0c12be57e9d07c067ce5be5042971876 | BurlaSaiTeja/Python-Codes | /Lists/Lists05.py | 342 | 4.21875 | 4 | """
Write a Python program to generate and print a list of first and last 5 elements where the values are square of numbers between 1 and 30 (both included).
"""
def sqval():
l=list()
for i in range(1,31):
l.append(i**2)
print(l[:5])
print(l[-5:])
sqval()
"""
Output:
[1, 4, 9, 16, 25]
[676, 72... |
3272a3d2e28e842e95a6747884197aac3f7669b5 | BurlaSaiTeja/Python-Codes | /Tuples and Sets/TaS01.py | 266 | 4.0625 | 4 | """
Write a Python program to replace last value of tuples in a list.
Sample list: [(10, 20, 40), (40, 50, 60), (70, 80, 90)]
"""
l=[(10,20,40),(40,50,60),(70,80,90)]
print([x[:-1]+(100,)for x in l])
"""
Output:
[(10, 20, 100), (40, 50, 100), (70, 80, 100)]
"""
|
e6d70677ef935a09ae34b36f0be4c47a35729a9e | BurlaSaiTeja/Python-Codes | /Lists/Lists04.py | 263 | 4.0625 | 4 | """
Write a Python program to print the numbers of a specified list after removing even numbers from it.
"""
lists = [58,38,75,78,39,20,48,57,84,32,45,23,42]
for n in lists:
if n % 2 != 0:
print(n, end = " ")
"""
Output:
75 39 57 45 23
"""
|
20bd68b0b1d0d376d4db261b05ba3004ce03be08 | BurlaSaiTeja/Python-Codes | /Lists/Lists09.py | 464 | 3.78125 | 4 | """
Write a python program to count the number of vowels and consonants in a file.
"""
import re
with open("test.txt", "w") as file:
file.write("This is the story of our lifes in quarantine!!!")
with open("test.txt", "r") as file:
f = file.read()
total=len(re.findall("[A-Za-z]", f))
vowels = len(re.f... |
76092f0d84d828c39b4b43af7f627727999e5d7a | dhdddp/Python_dd | /play_num.py | 685 | 3.90625 | 4 | import random #导入标准库
def play_game(num):
while True:
a = int(input("Please input a number:"))
if a > num:
print("The number is bigger")
elif a < num:
print("The number is smaller")
else:
print("You are right!")
b = (input("Whether to ... |
a4a6687b6d7e2cb36c3a6441c2cf220e486c76c8 | LAMBHHA/jan_22_calculator | /tests/test_add.py | 203 | 3.515625 | 4 | """
Tests the add() function of the calculator.
"""
from calculator import add
def test_two_plus_two():
"""
If given 2 and 2 as parameters, 4 should
be returned
"""
assert add(2,2)
|
71aa549d386b900d4af1864fd2ae6da027274d1d | Laowpetch/Coding_Game | /Fibonacci.py | 171 | 3.703125 | 4 | fib = [0,1]
x = int(input())
for i in range(x):
if i==1 or i==2:print(fib[i],"",end='')
else:
fib.append(fib[i-1]+fib[i-2])
print(fib[i],"",end='') |
bcd294b4f61fcd750550bcb207ebd050e41e9dea | FlorSousa/AngiosPy | /ChaveC.py | 32,165 | 3.671875 | 4 | def encontra_familia_chave_C():
c1 = input("A.Pétalas unidas às sépalas, formando com estas um unico tubo\nB.Pétalas livres das sépalas\nEscolha a opção:").upper()
if c1 == "A":
return "\n"+" "*3+"A Familia não pode ser encontrada na Chave C. Retorne e use a Chave B.\n"
elif c1 == "B":
... |
e1017d9c6cbab30425de1998944e9fcbe14995a7 | danielwangai/ds-algorithms | /ds/linked_lists/more_operations.py | 3,515 | 4.1875 | 4 | from basic_operations import Node, LinkedList
class LinkedList2(LinkedList):
def __init__(self):
self.head = None
self.tail = None
def remove_duplicates_sorted_iterative(self):
"""
removes all duplicates from a sorted linked list
complexity: O(n)
"""
t... |
1e712a1f685152f5ef5086dcdaaf647cacc8e325 | calphie/learnNLP | /sec1/solve_08.py | 328 | 3.53125 | 4 | input_string = "All your bases belong to us."
def cifer(sentence:str):
def transform(s:str):
if s.islower() :
return chr(219-ord(s))
else :
return s
return "".join(map(transform, sentence))
redecode = lambda x : cifer(cifer(x))
print(cifer(input_string), redecode(input_s... |
27ec9a4b6fd899bc06ff529a9a69c1eb800b51d5 | satoru4fun/alura-python3-oo-2 | /modelo.py | 2,441 | 3.640625 | 4 | class Programa:
def __init__(self, nome, ano):
self._nome = nome.title()
self._ano = ano
self._likes = 0
@property
def nome(self):
return self._nome.title()
@nome.setter
def nome(self, novo_nome):
self._nome = novo_nome.title()
@property
... |
c4fc5db8e72419e6e9ee49750330c255ce8490b4 | kschrader/Impatient | /part4/src/scripts/tokenizer.py | 543 | 3.84375 | 4 | #!/usr/bin/env python
# encoding: utf-8
import re
import sys
pat_l = re.compile("\w.*")
pat_r = re.compile(".*\w")
def tokenize (line):
"""
split a line of text into a stream of tokens, while scrubbing the tokens
"""
for token in map(lambda t1: re.search(pat_r, t1).group(), map(lambda t0: re.search(... |
e9ffcaced1121fa20de7c5f4df840bc8821a3c58 | anc1revv/coding_practice | /leetcode/easy/letter_capitalize.py | 490 | 4.375 | 4 | '''
Using the Python language, have the function LetterCapitalize(str) take the str
parameter being passed and capitalize the first letter of each word.
Words will be separated by only one space.
'''
def letter_capitalize(input_str):
list_words = input_str.split(" ")
for word in list_words:
for i in range(le... |
2ff7d1e0dad9636250e83261c15ef3ee780b66e5 | Swastik-Saha/Python-Programs | /Sum_Of_Odd&Even_Number_Uptil_The_Number.py | 329 | 3.921875 | 4 | def OddEvenSum(num):
sum_even = 0
sum_odd =0
for i in range(1,num+1):
if i%2 == 0:
sum_even = sum_even + i
if i%2 == 1:
sum_odd = sum_odd + i
print "Even Sum:" + str(sum_even)
print "Odd Sum:" + str(... |
1be473558f330634d25f27a28548c79b8ffe77dc | Swastik-Saha/Python-Programs | /Perfect_Number.py | 304 | 3.828125 | 4 | #Perfect Number
#6 = 1 + 2 + 3
def perfect(num):
sum =0
for i in range(1,num):
if(num%i == 0):
sum = sum + i
if(sum == num):
return "It is a perfect number"
else:
return "It is not a perfect number"
|
68f4148246ff590a46afe3b73fb3ba7c7d76aabc | Swastik-Saha/Python-Programs | /Sum_&_Average_Of_An_Array.py | 238 | 4.0625 | 4 | #Sum & Avg of an array
def sum_avg_arr(length):
arr = []
for i in range(0,length):
arr.append(int(raw_input("Enter an element: ")))
print arr
print sum(arr)
print (sum(arr)/length)
|
6d062eaaa19734e73822019780cb54a174a1e17b | Swastik-Saha/Python-Programs | /More_Operations_On_Strings.py | 1,380 | 4.03125 | 4 | #More Operations on Strings
def findCapital():
string = raw_input("Enter a string with a capital letter: ")
for i in range(0,len(string)):
if(string[i] < "a") and (string[i] >="A"):
return string[i]
def anagramChecker() :
string1 = raw_input("Enter the f... |
7c529d9a8fbe5d7f47cf1952c29265019d3ebc7b | Swastik-Saha/Python-Programs | /Operations_On_Strings.py | 1,670 | 3.8125 | 4 | #Operations on Strings
def checkPalindrome():
string = raw_input("Enter a string")
if(string == string[::-1]):
return "It is a Palindrome"
else:
return "It is not a Palindrome"
def readConcatenate():
str1 = raw_input("Enter a string: ")
str2 = ra... |
2b3c1bc9399793ce14fd920e8dfda39062655465 | Swastik-Saha/Python-Programs | /Recognize&Return_Repeated_Numbers_In_An_Array.py | 472 | 4.1875 | 4 | def repeated():
arr = []
length = int(raw_input("Enter the length of the array: "))
for i in range(0,length):
arr.append(int(raw_input("Enter the elements of an array: ")))
arr.sort()
count = 0
for i in range(0,length):
print "The number t... |
b3b80e3cf36d0b73bb5cc1e416321539440ef356 | Swastik-Saha/Python-Programs | /Accept_Two_Numbers_And_Check_If_They_Are_Equal.py | 243 | 3.828125 | 4 | def accept_and_check():
num1 = int(raw_input("Enter the first number:"))
num2 = int(raw_input("Enter the second number:"))
if num1 == num2:
return "Equal"
else:
return "Unequal"
|
6bd72ef22b59c9fc4f50fac7bbf51a7c6e13fe71 | Swastik-Saha/Python-Programs | /Output_Alternate_Elements_Of_An_Array.py | 279 | 3.984375 | 4 | def alternateArray():
length = int(raw_input("Enter the length of the array: "))
a =[]
for i in range(0,length):
a.append(int(raw_input("Enter the elements of the array: ")))
for i in range(0,length,2):
print a[i]
|
af9abe8c3928fd15a9bd730231fe30df92d4a810 | alexandersetiadi01/introducing-to-programming-LAB | /calculator(lambda).py | 386 | 4.09375 | 4 | a = input(": ")
b = input(': ')
operator = input("choose operator: ")
A = int(a)
B = int(b)
op = str(operator)
if op == "+":
add = lambda A,B: A+B
print(add(A,B))
elif op == "-":
min = lambda A,B: A-B
print(min(A,B))lamb
elif op == "/":
div = lambda A,B: A/B
print(div(A,B))
... |
91901fc30b7ff0224bf87a6a22584aa7592091e4 | KellyInnovation/file-loading-exercise | /file_loading.py | 1,303 | 3.78125 | 4 | import json
with open('store_data.json', 'r') as data_file:
json_data = json.load(data_file)
prices = []
def most_expensive():
for item in json_data:
prices.append(item['price'])
high_price = max(prices)
for item in json_data:
if item['price'] == high_price:
print("Most Expensive Item: ", item['... |
12e0a683ac674c6935e8dede9af4909f1406e791 | chihhua-liu/Python_Basic | /demo20.py | 965 | 3.578125 | 4 | # demo20 reduce
from pprint import pprint
import collections
from functools import reduce
course = collections.namedtuple('course', ['name', 'field', 'attendee', 'remote'])
print(type(course))
print(course)
poop = course(name='poop', field='python', attendee=10, remote=False)
bdpy = course(name='bdpy', field='pyth... |
ca5df4f31371f89d5f96dfec2e3dff98a8325d93 | chihhua-liu/Python_Basic | /demo7.py | 565 | 3.640625 | 4 | #demo7
x1 = 30000
print('x1={0:d}/{0:} in decimal, {0:b} in binary'.format(x1))
print('x1={0:o} in octal, {0:x} in hexadecimal'.format(x1))
print('%10s' % '0123456789')
print('%10s' % '0123456789' * 2)
print()
print('%10s' % '0123456789'[:5])
print('%-10s' % '0123456789'[:5])
print('%10s' % '中文')
print()
print('{:10}'... |
45c0ef8d7220c77288f7744c7a5889cc1d1feede | JoaoRicardoSimplicio/Exercicios-do-Uri | /LinguagemPython/exercicio2922_salas_de_aula.py | 347 | 3.5 | 4 | while True:
try:
SalaA, SalaB = input().split(" ")
SalaA = int(SalaA)
SalaB = int(SalaB)
if SalaA>SalaB:
SalaA, SalaB = SalaB, SalaA
elif SalaA==SalaB:
SalaA = 0
SalaB = 1
R = (SalaB-SalaA)-1
print(R)
except EOFError:
... |
e80ccdc4916b7c57098a665485f413a77204bf31 | phamd1989/ProgrammingChallenges | /LongestSequenceDecreasing.py | 4,359 | 4.1875 | 4 | # this is to solve the Longest Increasing Subsequence problem
# the idea is to record all possible solutions up to this element of the orginial list
# recursive function: L[i+1] = best_solution[i].append(this element at i+1)
from operator import itemgetter
def longest_sequence_decreasing(input_arr, solutions, curr)... |
971881bad3c2980c5c2875ff07d1ac50d2a45299 | wojtekminda/Python3_Trainings | /SMG_homework/10_2_Asking_for_an_integer_number.py | 2,299 | 4.53125 | 5 | '''
Write input_int() function which asks the user to provide an integer number
and returns it (as a number, not as a string). It accepts up to 3 arguments:
1. An optional prompt (like input() built-in function).
2. An optional minimum acceptable number (there is no minimum by default).
3. An optional maximum acceptabl... |
ce348ff15587ff3fb311bcccafd282cab337debd | wojtekminda/Python3_Trainings | /SMG_homework/08_3_Oscars_database_editor_Piotr.py | 3,465 | 4.5 | 4 | '''
Building upon 'What did they win their Oscars for?' exercise, create an interactive editor of the awards file.
The session with the script is as follows:
1.The awards file is read into memory as a list of dictionaries.
2.The number of entries is printed to the screen.
3.The user is repeatedly asked to provide a com... |
27fbd388408a01b18393f328c052253b0d3939a7 | wojtekminda/Python3_Trainings | /SMG_homework/07_2_Elevator_logs_Piotr.py | 3,864 | 4.5625 | 5 | '''
Whenever an elevator stops on a floor, it writes the floor number into a log file. Each day has its own line in the log file.
Every line starts with a date in YYYY-MM-DD format.
Then, separated by spaces, there follow floor numbers on which the elevator stopped on that day.
Lines in the log file are sorted by date ... |
09c024e3dfde0a07e652fd8bfb02357b736bc1ac | wojtekminda/Python3_Trainings | /SMG_homework/01_3_Should_I_go_out.py | 1,319 | 4.15625 | 4 | '''
A user is trying to decide whether to go out tonight.
Write a script which asks her a few yes-no questions and decides for her according to the following scheme:
[NO SCHEME]
'''
raining = input("Is it raining? ")
if raining == "yes":
netflix = input("Is the new episode on Netflix out already? ")
if netflix... |
4bf5e4949b66a0367ee82bc50afc5a187167d215 | wojtekminda/Python3_Trainings | /SMG_classwork/65_zadanie_parse_file.py | 1,130 | 3.734375 | 4 | def dateParser(date):
date = date.split('-')
if not date[0].isdigit():
raise ValueError('wrong form of year element')
year = int(date[0])
if not date[1].isdigit():
raise ValueError('wrong form of month element')
month = int(date[1])
if not date[2].isdigit():
raise Valu... |
9414987fd904d84ab005c435533fde5ec43494cc | wojtekminda/Python3_Trainings | /SMG_homework/05_1_Joining_text_columns_GUI_grid.py | 2,317 | 3.640625 | 4 | '''
Write a script which reads two files and writes their contents to the screen.
Corresponding lines from the files are printed on the same line, separated by a space character.
If one of the files is longer, its remaining lines are printed on their own.
Both file paths may be fixed and hard-coded in the script.
'''
... |
cb443cdd78503240ac5d9520d431f7c77799d3a9 | wojtekminda/Python3_Trainings | /SMG_classwork/74_def_args_kwargs.py | 325 | 3.59375 | 4 | # https://www.agiliq.com/blog/2012/06/understanding-args-and-kwargs/
def f(a, b, c=1, d=2, *args):
print(a, b, c, d, args)
def g(a, b, c=1, d=2, **kwargs):
print(a, b, c, d, kwargs)
f(1, 2, 3, 4, 5, 6, 7, 8, 9)
g(1, 2, 3, 4, x=100, y=200)
def h(a, b, c, d, e):
print(a, b, c, d, e)
z = [5, 6, 7]
h(1, 2,... |
275912dbd200ced42fc50e7ac216be7b38ba40e8 | wojtekminda/Python3_Trainings | /SMG_classwork/12_zadanie_operator_modulo.py | 566 | 3.65625 | 4 | words = list()
print("Tworzymy liste slow")
print("(Jezeli wypisales juz wszystkie -> nacisnij Enter)\n")
print("Podaj slowo")
word = input()
while word != "":
words.append(word)
print("Podaj slowo")
word = input()
print("Powiedz po ile slow w linii chcesz wypisywac")
number_of_words = input()
int_number... |
981c1dd6768b840cd6d77d9cbb34f5717486ecea | wojtekminda/Python3_Trainings | /SMG_classwork/68_zadanie_parenthesis.py | 531 | 3.8125 | 4 | def parenthesis_check(text):
start_counter = 0
stop_counter = 0
for sign in text:
if sign == '(':
start_counter = start_counter + 1
elif sign == ')':
stop_counter = stop_counter + 1
if stop_counter > start_counter:
return False
return s... |
d557fd6ee9751d4dd3bcc92b933a5314edcb9198 | wojtekminda/Python3_Trainings | /SMG_classwork/16_zadanie_strip.py | 299 | 3.90625 | 4 | words = list()
print("Tworzymy liste slow")
print("(Jezeli wypisales juz wszystkie -> nacisnij Enter)\n")
print("Podaj slowo")
word = input()
word_strip = word.strip()
while word:
words.append(word_strip)
print("Podaj slowo")
word = input()
word_strip = word.strip()
print(words)
|
8ef263ba765afcdcd77706c50defb499541b70fa | soulforever/CorePythonProgramming | /chapter7/functions.py | 5,806 | 4.0625 | 4 | # -*- coding: utf-8 -*-
"""
Home work of chapter 7.
"""
__author__ = 'guti'
def print_dict():
"""
Problem 7-3, print dict keys and values in different order
:return: None
"""
d = {'host': '10.0.1.1',
'port': 8080,
'database': 'sqlite',
'service': 'weather'}
k_list =... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.