blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
850a952fa5c525483525fe13c10fe77a66127e15 | Veselin-Stoilov/softuni_projects-python-fundamentals | /basic_syntax_exercise/Ester_cozonacs.py | 681 | 3.671875 | 4 | budget = float(input())
flour_price = float(input()) #price/kg
eggs_price = flour_price * 0.75
milk_price_1_liter = flour_price * 1.25
cozonac_price = eggs_price + flour_price + milk_price_1_liter/4
colored_eggs_counter = 0
cozonac_counter = 0
lost_eggs = 0
money_left = budget
while money_left > 0:
if money_left < ... |
f591174abf17897672d379b03361e75e1f717260 | douzhenjun/python_work | /ex020202.py | 2,811 | 4 | 4 | class SequenceList():
def __init__(self):
#初始化顺序表函数
self.SeqList=[]
#创建顺序表函数
def CreateSequenceList(self):
print("*********************************************************")
print("*Please input datas and press 'Enter' key to ensure, if you want to end, please input '#'.*")
print("***********************... |
4c62389b9c5e29db56e06adf78661b8464fd2f24 | formazione/pythonquiz | /domande aperte da inserire/question_without_tips.py | 2,742 | 3.9375 | 4 | import random
import os
''' How to...
Go to the end end insert the questions like you see in lista_domande
you can put more possible answers using #
you can add a list of possible answer in the question with #
'''
def add_questions(lista_domande):
''' creates a string with all call to input with questions and an... |
e280359bf58b6a0ea16de889f870a66c6e394ac6 | jearldean/hb-hw4-accounting-scripts | /melon_info.py | 678 | 4.28125 | 4 | """Print out all the melons in our inventory."""
import json
# Stored my nested dict in a .json file
with open('melons.json') as f:
melon_data = json.load(f)
for melon_name in melon_data:
""" Use a nested dict to print all melon data.
{
"Cantaloupe": {
"price": 2.00,
"seeds"... |
60899eb59f51d2dc5bc537b71f7accd5634b6217 | StanfordVL/hand_eye_calibration | /hand_eye_calibration/python/hand_eye_calibration/quaternion.py | 10,592 | 3.65625 | 4 | from numbers import Number
import numpy as np
import random
class Quaternion(object):
""" Hamiltonian quaternion denoted as q = [x y z w].T.
Can be instantiated by:
>>> q = Quaternion(x, y, z, w)
>>> q = Quaternion(q=[x, y, z, w])
>>> q = Quaternion(q=np.array([x, y, z, w]))
"""
q = np.array([0.0, 0.0... |
e4a81503e9151d29f0adacdb8c04a7ae136cdcaa | Ca-moes/FPRO | /RE07/grades.py | 546 | 3.59375 | 4 | def sort_grades(records):
from statistics import mean
aa = sorted(records, key = lambda x : x[1])
bb = sorted(aa, key = lambda y : y[0])
cc = sorted(bb, key = lambda z : mean(z[2]), reverse = True)
result = tuple(cc)
return result
print(sort_grades((('Maria', 'up20190001', (60, 70, 80)),
... |
07ff041ace1c881ded4ebd72b300779337c8f7dd | jiaxinhuang/python-test-code | /leetcode/LengthofLastWord.py | 461 | 3.859375 | 4 | #-*- coding:utf-8 -*-
'''
Created on 2017年4月20日
@author: huangjiaxin
'''
class Solution(object):
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if not s:
return 0
sList = s.strip().split()
if len(sList) <= 0:
return 0
... |
c12a882c51f984ca7c797c77363a505c9c4ddaa7 | NimalGv/Python-Programs | /MYSLATE/A2-Programs/Day-1/2.sum_of_odd_numbers.py | 254 | 4.34375 | 4 | # -*- coding: utf-8 -*-
"""
sum of "n" odd numbers:
3: 1+3+5=9;
5: 1+3+5+7+9=25;
10: 1+3+5+7+9+11+13+15+17+18=100;
thus-> Sum of "n" odd numbers = (n*n)
"""
num=int(input())
print("Sum of Odd : ", num*num)
|
acd80a9a6960d4d65667d9fd007a75a2416142fb | Catalina-AR/python-2020 | /python_stack/python/OOP/MathDojo.py | 653 | 3.640625 | 4 | class MathDojo:
def __init__(self):
self.result = 0
def add(self, num, *nums):
self.result += num
for a in nums:
self.result += a
return self
def subtract(self, num, *nums):
self.result -= num
for a in nums:
self.result -= a
retu... |
94f995b7a4e1256f9e4190f214c9e69854a19345 | muneerqu/AlgDS | /Part1/07-Data Structure/01-List and Tuple.py | 749 | 3.96875 | 4 | #
#
#
def main():
game = ['Rock', 'Paper', 'Scissors', 'Lizard', 'Spock']
print(game[1:3])
print(game[0:4:2])
i = game.index('Paper')
print(game[i])
game.append('Computer')
game.insert(0, 'Radio')
print_list(game)
game.remove('Lizard')
n = game.pop() # remove from the en... |
bfc928862eb24f6473f345b2b0f2a4d84d474849 | farnazjmo/CTI-110 | /P4HW3_NestedLoops_FarnazJeddiMoghaddam.py | 462 | 4.1875 | 4 | # This program displays a stair-step pattern
# 10.17.19
# CTI-110 P4HW3 - Nested Loops
# Farnaz Jeddi Moghaddam
def main():
num_steps=6 # Define number of iterations
for r in range(num_steps):
print('#',end='',sep='') # Print the first '#'
for c in range(r): ... |
45ac5c7a81c543da84da77dd30dcb5b3e523a526 | YosukeKira/main | /Python/chapter2/2-5/pass.py | 199 | 3.609375 | 4 | n = int( input("数値を入力(3でpass)") )
if n == 3:
pass
else:
print("passされませんでした")
print("処理を完了しました")
v = 30
if v % 2 == 0: print("偶数です")
|
f3a7a21f803dba494f62f9aafe5a79e95e4eff88 | aliensmart/python | /practices/Hackerranck/list_comprehension.py | 598 | 3.609375 | 4 | # https://www.hackerrank.com/challenges/list-comprehensions/problem
# x, y, z, n = int(input()), int(input()), int(input()), int(input())
# print ([[a,b,c] for a in range(0,x+1) for b in range(0,y+1) for c in range(0,z+1) if a + b + c != n ])
x = int(input())
y = int(input())
z = int(input())
n = int(input())
# my_l... |
a6432671748bb03c6fc5b2a207cae5ee2e1211e8 | inverseundefined/DataCamp | /02-Intermediate_Python_for_Data_Science/05-Case_Study_Hacker_Statistics/06-Visualize_the_walk.py | 1,164 | 4.625 | 5 | '''
Visualize the walk
Let's visualize this random walk! Remember how you could use matplotlib to build a line plot?
import matplotlib.pyplot as plt
plt.plot(x, y)
plt.show()
The first list you pass is mapped onto the x axis and the second list is mapped onto the y axis.
If you pass only one argument, Python... |
542b25003411cd038718f3c6ab49c2dccab345cc | TianyaoHua/LeetCodeSolutions | /Odd Even Linked List.py | 904 | 3.828125 | 4 | # Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def oddEvenList(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
even_head = head.next
odd = ListNo... |
edf534f94f02dd757080a76caf54ead01fdde2ac | Sum-Sovann2018/Bootamp4 | /55_matrix_subtraction.py | 752 | 4 | 4 | def matrix_substraction(mat1, mat2):
mat3 = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]
print("Matrix 1:")
for i in range(len(mat1)):
for j in range(len(mat1)):
print(mat1[i][j], end = "\t")
print()
print("\nMatrix 2:")
for i in range(len(mat2)):
for j in range(... |
d1372ac0066bc525f0b00a1215a9e4d6061cf3ce | ashishksinghin/BITSAssignments | /ACI_Assignment1/GridTravel.py | 16,655 | 3.59375 | 4 | #!/usr/bin/env python
# coding: utf-8
# # ACI Assignment 1: Grid Travel Agent
#
# ### Assignment Group 12
#
#
# | Name | Student ID |
# | :- | :- |
# | Shiva Bansal | 2020FC04280 |
# | Ashish Kumar Singh | 2020FC04285 |
# | Ashish Kumar Verma | 2020FC04142 |
# | Ganesh P S | 2020FC04024 |
# | Deepam P... |
f74d6b347ff88bc1d740b61c094e78a489b4cf62 | alicodermaker/public_code | /stock_market/analyse_berkshire_letters/analyse.py | 919 | 3.578125 | 4 | from nltk.corpus import stopwords
import re
counts = dict()
def word_count(str):
words = str.split()
filtered_words = [word for word in words if word not in stopwords.words('english')]
for word in filtered_words:
if word in counts:
counts[word] += 1
else:
counts[word] = 1
def analyse():
for key, value... |
bba42ab90280c470debafe5eec823433e4a263a0 | Scott-S-Lin/Python_Programming_ChineseBook | /ch5/std_stream.py | 648 | 3.59375 | 4 | #filename: Std_stream.py
#function: use the stdout and stderr for printing data
#output to stdout: using sys.stdout.write("data")
#output to stderr: using sys.stderr.write("data")
import sys
while True:
print ("\n while iteration ...",end=' ')
# reading from sys.stdin (stop with Ctrl-D):
try:
indata = input("... |
d1817fd44c41528abbe8d337ee523a888613428a | cherylb/AdvProg | /hw1_template cb.py | 2,279 | 4.1875 | 4 | #1. fill in this function
# it takes a list for input and return a sorted version
# do this with a loop, don't use the built in list functions
zz
def sortwithloops(input):
"""sorts a list using loop
returns sorted list"""
temp = input[:] # create copy of list to change
pos = temp.index(min(temp))
... |
0f3eeabff70c5f46345cbb80e5b0ea00c727bb48 | pratherb7750/CTI110 | /M4HW2_Pennies_FirstLast_BrucePrather.py | 1,072 | 4.125 | 4 | #This program calculates the amount in dollars of working for pennies
#June 19,2017
#CTI-110 M4HW2_Pennies_For_Pay
#Bruce Prather
#Set the accumlator, totalAmount, to 0.
totalAmount = 0
# Ask user how many days
num_days = int(input('How many days did you work?'))
# Name columns for table
print ('\t' ... |
ffa3c7a4cfee5835c30a9a92798c22d9ecd6fe0c | BigPeshh/Calculator | /CalculusCalc.py | 655 | 3.921875 | 4 | print("====================================================")
print(" Calculus Calculator ")
print("====================================================")
print(" Please select the number of the operation needed ")
print("____________________________________________________")
print... |
fb63bf5ac1796fe8a05d23c1d230160a933293c9 | serkancam/byfp2-2020-2021 | /hi-A3/kacAyYasadin.py | 245 | 3.578125 | 4 | d_yil = int(input("hangi yıl doğdun:"))
d_ay = int(input("kaçıncı ayda doğdun :"))
# while True:
# d_ay = int(input("kaçıncı ayda doğdun "))
# if 0<d_ay<=12:
# break
k_ay = (2020-d_yil)*12+(11-d_ay)
print(k_ay)
|
b45d46ef3db729dea3c559f5ff8ddcf9131914e8 | Tduncan14/PythonCode | /heroLoops.py | 480 | 4.21875 | 4 | #create a tuple with some items
inventory =("sword","shield","armor","healing potion")
# print the tuple
print("\n The tuple inventory is: ")
print(inventory)
#print each element in the tuple
print("\nYour items:")
for item in inventory:
print (item)
#get the length of a tuple
if "healing potion" in inventor... |
57596a5c1b3be6bcaa5bc38614e269c1dbf66993 | StormRoBoT/MyPythonEssentialsClass-2015 | /samples/quicksort/thread-main.py | 1,699 | 3.515625 | 4 |
import threading
import random
class F(threading.Thread):
def __init__(self, items, depth=0):
super().__init__()
self.items = items
self.result = None
self.depth = depth
self.verbose = True
def run(self):
indent = ' ' * self.depth
prefix = "{}{}:".form... |
baa949aa2ae208181a4d1f5467e0af060b3db204 | Jayesh598007/Python_tutorial | /Chap6_conditional_and _logical_operators/07_prac1_greatest_of_all.py | 516 | 4.15625 | 4 | num1= int(input("enter the no1: \n"))
num2= int(input("enter the no2: \n"))
num3= int(input("enter the no3: \n"))
num4= int(input("enter the no4: \n"))
if (num1> num4): # here we get greatest amony both as 'f1'
f1 = num1
else:
f1 = num4
if (num2>num3): # here we get greatest amony both as 'f2'
f2 = num... |
0bf31836bd409a021030f718ba497272089df396 | getsadzeg/python-codes | /src/datetime.py | 260 | 3.65625 | 4 | import time
import calendar
localtime = time.asctime(time.localtime(time.time())) # formatted local time
print "Local time:", localtime
cal = calendar.month(2016,1);
print "Calendar of January in 2016:",cal
isLeap = calendar.isleap(2017); # False
print isLeap |
79f7d0e5f6540f132cba222872fd6b09155e787e | desonses/Calculo-multivariable | /coordenadas.py | 4,085 | 3.890625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Nov 23 17:26:19 2018
@author: Fredy M
UAEM
desonses@gmail.com
"""
import funciones
def menu():
done = 1
while (done == 1):
print('################ Cambio de coordenadas ################')
print('Selecciona una opcion:')
pr... |
2cfe201d7d430685ac49b1d4068adc5aa96d7e7a | PhilippSteinmann/scraper | /testing/async_filewrite_tester.py | 838 | 3.53125 | 4 | import csv
import threading
import random
import time
class WriteToCSV(threading.Thread):
def __init__(self, lock):
threading.Thread.__init__(self)
self.lock = lock
def run(self):
print "IN THREAD"
a = random.randint(1, 10)
b = random.randint(1, 10)
c = random.r... |
d3abf9323cc79fd88b46ada948fd81ba0863bd11 | www111111/A1804_02 | /07/siyouFuxi.py | 1,105 | 4.125 | 4 | #子类的属性和父类属性相同,会执行子类本身的属性:重名
#属性,方法,私有化不可继承,不要重名
'''
class Father(object):
def __init__(self):
self.xing='王'
self.height=180
def kaice(self):
print('开车。。。。')
def __dubo(self):
print('赌博')
class Son(Father):
pass
大头儿子=Son()
print(大头儿子.xing)
大头儿子.kaice()
#大头儿子.__dubo()
大头儿子.... |
79ade8f55812a27a796e9cead4db31812a69fdab | Jsos17/Python_Todo_App | /src/todo_logic.py | 779 | 3.5 | 4 | from src.todo import Todo
def check_filename(filename):
return len(filename) <= 4
def file_ending(filename):
return filename[len(filename) - 4:]
def todo_modify(line, inputs):
fields = line.strip().split("|")
todo_fields = []
for i in range(5):
if inputs[i] == "":
if i < le... |
32aa087b810849494c10dff42ec548053c375891 | shahrajesh2006/RainingRobots | /Rajesh/SudentClass2.py | 648 | 4.125 | 4 | class Student:
#Constructor is nothing but a helper function to create object
def __init__(self,name,grade):
self.name=name
self.grade=grade
#Function to print student information
def printStudentInformation(self):
print("Student Information- Name:"+self.name+" Grade: "+self.gr... |
1ea38c5f3259251858c1d04f398fdb85a6af3851 | Nauqcaj/itp-w1-highest-number-cubed | /highest_number_cubed/main.py | 495 | 4.15625 | 4 | """This is the entry point of the program."""
def highest_number_cubed(limit):
previous_number = 1
while True:
current_number = previous_number + 1
if current_number ** 3 > limit:
return previous_number
previous_number = current_number
#Altermative Answer
'''
num... |
b4c60eb9c55fa99ad0da07812cfefbfcb2c74c2c | James-McNeill/TimeSeriesAnalysis | /Python/correlation.py | 2,910 | 3.546875 | 4 | """
#----------------------------------------------------------------------------------+
# This python client gives you an ability to: |
# - Perform correlation analysis on the final list of independent and |
# dependent variable transformations ... |
c6b508792236a940fc9097ac8d53dd7ee80a0326 | tiejongd/raspi_study | /raspi/code/0508.py | 183 | 3.671875 | 4 | # -*- coding: utf-8 -*-
import sys, os
i = 0;
while True:
a = int(raw_input("input number (0 to exit): "))
print"you entered", a
if a == 0:
break
print 'exit'
|
fa05f0b02b344e78401092fcbb26d9d31aef668d | emellars/euler-sol | /039.py | 841 | 4.03125 | 4 | #Runtime ~26.5s.
import math
#Takes list [a, b, c] and checks if a^2 + b^2 == c^2.
def pythagoras(triplet):
return triplet[0]**2 + triplet[1]**2 - triplet[2]**2 == 0
#Generate all pythagorean triples [a, b, c] where a>b>c, a+b+c=p.
def triplets(p):
triples = []
for a in range(1, math.floor(p/3... |
9f3abc69ef49760475fa6a80eb2a923565f9706e | AdamZhouSE/pythonHomework | /Code/CodeRecords/2616/61020/294953.py | 207 | 3.5625 | 4 | T = int(input())
# result = ''
for i in range(T):
A_and_B = input().split()
A = int(A_and_B[0])
B = int(A_and_B[1])
if (2 <= B) and (B <= A):
print('1')
else:
print('0')
|
943c515dfdbbafc44ddc3e1b3e3b60b8c27ef2fd | Baidaly/datacamp-samples | /6 - introduction to databases in python/from SQLAlchemy results to a Graph.py | 475 | 3.75 | 4 | '''
We can also take advantage of pandas and Matplotlib to build figures of our data. Remember that data visualization is essential for both exploratory data analysis and communication of your data!
'''
# Import Pyplot as plt from matplotlib
import matplotlib.pyplot as plt
# Create a DataFrame from the results: df
df ... |
c5878c7ae27842ab68271abe34db4851ee4e039e | Lord-Gusarov/holbertonschool-higher_level_programming | /0x0B-python-input_output/5-save_to_json_file.py | 390 | 4.0625 | 4 | #!/usr/bin/python3
"""Save Object to a file
"""
import json
def save_to_json_file(my_obt, filename):
""""Writes an Object to a text file, using a JSON representation
Args:
my_obt (any): a Python object that we want saved in a file
filename (str): name of the file to save/write the object to
... |
919d352183221e6c9924f2093cdf2ad98d785db1 | kolefrazier/PHYS2300-Assignments | /Assignments/Assignment 2/Exercise 2.8.py | 1,086 | 3.84375 | 4 | #--------------------------------------------------------------------------------
# G e n e r a l I n f o r m a t i o n
#--------------------------------------------------------------------------------
# Name: Exercise 2.8
#
# Usage: Utilize the Numpy Python package to perform calculations on arrays.
#
# Description: C... |
5b4e061fab662b4b3f3d6eab4a519a13564f3e9e | RicardoEngComp/Meus-Projetos | /Exercícios Python/Python/Scripts/002.py | 232 | 3.546875 | 4 | nome = input('Nome? ')
dia = input('Dia de nascimento: ')
mes = input('MEs: ')
ano = input ('ano: ')
anoAtual = input('Ano de Hoje: ')
idade = anoAtual
print('Data de nascimento: ', dia, '/', mes, '/', ano)
print('Idade: ', idade)
|
c8f607060a0a2c006d2602aca8045e51c4b5f04a | YahyaNaq/INTENSIVE-PROGRAMMING-UNIT | /cumul_sum_lst.py | 334 | 3.953125 | 4 | # Python Program to Find the Cumulative Sum of a List where the ith Element is the Sum of the First i+1 Elements From The Original List
lst1=[1,2,3,4,5]
lst2=[]
for i in range(len(lst1)):
ind=0
for j in range(i+1):
ind+=lst1[j]
lst2.append(ind)
print("Origin list: {}\nCumulative sum list: {}".forma... |
600617c175ad1a07d97cafa92e5f06087ba8e5d6 | ColmHughes/day-16-20---Boggle | /recursion.py | 210 | 3.90625 | 4 | l = [13, 8, 7, 21, 19, 6]
def isinlist(l, n):
if l[0] == []:
return False
elif l[0] == n or isinlist(l[1:], n):
return True
print(isinlist([13, 8, 7, 21, 19,6], 21))
|
1e98367952ea079d0b62c0259efd67c16c32c6f8 | sponrad/morsels | /format_ranges/format_ranges.py | 1,072 | 3.890625 | 4 | def format_a_range(start, end):
if start == end:
return '{}'.format(start)
return '{}-{}'.format(start, end)
def format_ranges(the_range):
my_ranges = []
the_range = sorted(list(the_range))
current_range_start = current_range_end = last_val = the_range.pop(0)
for i in the_range:
... |
23621fdc7a3de478e4bc5719a17df5445a9cd914 | hiroyaonoe/Competitive-programming | /AtCoder/本番/ABC/ABC157/A.py | 75 | 3.578125 | 4 | a=int(input())
if a%2==0:
ans=a/2
else:
ans=a//2+1
print(int(ans))
|
d080c447157998bc1b979e188026929fecd2a49a | kovkir/bmstu-ca-labs | /lab_6/src/table.py | 1,966 | 3.515625 | 4 | from algorithms import *
from color import *
def fill_table(x_arr, y_arr, methods):
table = [[0 for i in range(7)] for j in range(6)]
step = x_arr[1] - x_arr[0]
for i in range(len(x_arr)):
table[i][0] = x_arr[i]
table[i][1] = y_arr[i]
for j in range(2, len(methods) + 2):
... |
9f9e5e9d8fd85b0f7ecf7e0cc044f16be04b3192 | nnay13/PyqT-Repo | /tranposition_cipher.py | 1,496 | 4.1875 | 4 | """Implements the transposition Cipher
"""
import math
def crypt(message, key):
"""Crypt a string with the Transposition Cipher
Arguments:
message {string} -- String to crypt
key {int} -- key for the transposition cipher
Returns:
String -- Crypted message
"""
if key >=... |
f7e96fed1700514c529d002a4a2ec3c0d82c6c39 | CesarMRodriguez/Cutucucthulu | /model/port.py | 539 | 3.578125 | 4 | #Por ahora no se usa
class Port:
def __init__(self):
self.port_number = 0
self.description = ""
self.state = ""
def getPortNumber(self):
return self.port_number
def setPortNumber(self, port_number):
self.port_number = port_number
def getDescription(self):
... |
680b811ecc5419e6c471762ceba9d7adb076f9cb | NightRoadIx/ejemplo1 | /tareas del primer bloque/tarea13.py | 816 | 3.5 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Oct 16 23:00:34 2020
@author: ALEXIS20012
"""
print("serie de Padovan")
m=0
while(m<1):
valor=int(input("ingrese el tamaño que desea que se produzca:"))
if(valor<4):
for k in range(0,valor,1):
print("1",end=(","))
elif(valor<6):
... |
02f223ef129cc404d052f68355f951f92870722b | mkaragoz4/Python_Week_4 | /week4-4.py | 1,367 | 3.9375 | 4 | import Sum, Divide, Minus, Multiple
while True:
try:
a = int(input('Which calculation you want to do: \n1-Sum \n2-Minus \n3-Multiple \n4-Divide\n'))
if 0<a<5:
x = float(input('Please enter 1. value : '))
y = float(input('Please enter 2. value : '))
if a==1:
... |
31fa8eb73abddc01f592b219842515c31cec97d8 | sauravgsh16/DataStructures_Algorithms | /g4g/DS/Trees/Binary_Search_Trees/Checking_and_Searching/17_largest_number_equal_to_or_less_than_N.py | 768 | 3.828125 | 4 | ''' Find largest number equal to or less than N '''
class Node(object):
def __init__(self, val):
self.val = val
self.left = None
self.right = None
def find_max_for_N(root, n):
if not root:
return -1
if root.val == n:
return n
elif root.val < n:
... |
5ff6331d07b304f522ce3fa94b88989620432521 | Adarsh-Liju/Python-Course | /DIGITS.py | 908 | 3.984375 | 4 | n=int(input("Enter the Four Digit Number"))#inputing four digit number
dig1=n%10#removing individual digit
rem1=n//10#the number after digit is removed
print("The digit is :",dig1,"The remaining number after removal",rem1)#display digit 1
sum=dig1
dig2=rem1%10#removing individual digit
rem2=rem1//10#the number a... |
d7157b0cb9bfee2d431aebb67bb2dbb9bf98ae41 | preetsimer/database-python- | /database-SQl.py | 906 | 3.765625 | 4 |
#question 1
import sys
import sqlite3
con=sqlite3.connect('Students.db')
#question 2
cursor = con.cursor()
query = 'create table stu_details(Name varchar(20),Marks int(3))'
cursor.execute(query)
con.commit()
for i in range(1,11):
names=input("Enter name: ")
marks=int(input("Enter marks: "))
if marks>=0 a... |
97a2e10ba237051ecce4a16c2b12d1bbd17e530a | EpsilonHF/Leetcode | /Python/241.py | 848 | 4.25 | 4 | """
Given a string of numbers and operators, return all possible
results from computing all the different possible ways to
group numbers and operators. The valid operators are +, - and *.
Example 1:
Input: "2-1-1"
Output: [0, 2]
Explanation:
((2-1)-1) = 0
(2-(1-1)) = 2
"""
class Solution:
def diffWaysToCompute... |
a1b342549871758c5ebd7981afeb8db1c109facb | jcp0578/practise-Python | /codewar/Counting Duplicates-7k/Counting Duplicates.py | 897 | 3.90625 | 4 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
import cw as test
debug = 1
def debug_print(flag, out):
if debug:
print("temp" + str(flag) + ":" + str(out))
def duplicate_count(text):
# Your code goes here
out_temp = 0
count_t = [0] * 128
for temp in text:
if ord(temp) >= ord('a') ... |
2d9a0c8321abc55beee59a8ebe850d1ae7dd577d | hummingbird-12/-MapReduce-Bigram-Counter | /Reducer.py | 672 | 3.625 | 4 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
from sys import stdin, stdout
bigram = {} # dictionary to store bigram count
while True:
inp = stdin.readline() # read single line from input
if inp == "": # check for empty input string
break # end loop
comb, n = inp.strip().split("\t") # store bigram ... |
b82b122a872e569d04497c2990be1edff3ad8223 | ltgood01/Python-2018 | /google.py | 585 | 4 | 4 | import datetime
import random
name=input("What your name")
while True:
answer = input("I am the magic eight ball" + str(name) + "Whats your wish!(Type stop if you want to quit.)")
randnum = random.randint(0, 3)
if randnum == 0:
print("no chances at all for " + str(answer))
elif randnum == 1:
... |
d5b22626ee30ce3cc75803c36b1f18d5ec3c825c | swcide/algorithm | /week_1/03_02_find_max_occurred_alphabet.py | 1,221 | 3.984375 | 4 | input = "hello my name is sparta"
'''
실패....
'''
# def find_max_occurred_alphabet(string):
# alpabet_array = [chr(i+97) for i in range(26)]
# arr = []
# for i in alpabet_array:
# if not string.isalpha():
# for j in string:
# if i == j:
# arr.append(i)... |
364dab84f6b0280143d143255db46672814c7c1e | JosephLevinthal/Research-projects | /5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/226/users/4129/codes/1800_2571.py | 120 | 3.78125 | 4 | s = input("Escreva:")
saida = ""
for i in range(len(s)):
if(s[i].upper() != "A"):
saida = saida + s[i]
print(saida) |
a76252d64dde418389017e5384b97594b0e64f84 | ArtyomMinsk/codewars | /arithmetic_progression.py | 330 | 3.765625 | 4 | def find_missing(sequence):
s = sequence[0]
if (sequence[1] - sequence[0]) == (sequence[2] - sequence[1]):
diff = sequence[1] - sequence[0]
else:
diff = sequence[3] - sequence[2]
ap = [s + i * diff for i in range(len(sequence))]
for j in ap:
if j not in sequence:
... |
179e5e2b1270f220a50c1ade40edd636015925fe | luma24/CNA340_Python | /5.2 Program Painting a wall-lab.py | 3,113 | 4.25 | 4 | # Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
# print('{:.2f}'.format(your_value))
#
#
# (1) Prompt the user to input a wall's height and width. Calculate and output the wall's area (integer).
#
# Enter wall height (feet):
# 12
# Enter wall width (feet):
#... |
8f6cef3ea791ad3237f9183761e7291616f252ab | EgonFerri/AML-lab1 | /Assignment/Identification/dist_module.py | 1,274 | 3.5 | 4 | import numpy as np
import math
# Compute the intersection distance between histograms x and y
# Return 1 - hist_intersection, so smaller values correspond to more similar histograms
# Check that the distance range in [0,1]
def dist_intersect(x,y):
zipped = list(map(min, list(zip(x,y))))
dist = 1 - (0.5... |
b70bf977df89876d0c8c331fe5c20b6e5805fee8 | szarbartosz/mownit-lab | /src/lab1/zad5.py | 425 | 3.5 | 4 | import numpy as np
from bitstring import BitArray
def checkNormalization(number):
binum = BitArray(float=number, length=32)
if binum[1:9].bin == '00000000' and binum[9] == 0:
x = 'de'
else:
x = ''
print(number)
print(f'Is {x}normalised', int(binum[0]), binum[1:9].bin, binum[9:].bin... |
20cde5e4f25eeacb461ef6cf5594c3ebd88f1279 | Tulip2MF/100_Days_Challenge | /Ceasar Cypher/ceasar_cipher.py | 468 | 3.71875 | 4 | import ceasar_cipher_decoding
import ceasar_cipher_encoding
action = input("Type 'encode' to encrypt, type 'decode' to decrypt:\n").lower()
text = input("Type your message:\n").lower()
shift = int(input("Type the shift number:\n"))
output = ""
message = []
if action == "encode":
output = ceasar_cipher_encoding.enc... |
be76670b07bf22f4c249d2fcb94a656d7f27f511 | BlueInked/python-pit | /rpg-script.py | 1,472 | 3.734375 | 4 | import random
#player choice of class
class rogue:
hpmax = 50
hpmin = 10
atkl = 15
atkh = 30
class wizard:
hpmax = 60
hpmin = 10
atkl = 20
atkh = 40
class warrior:
hpmax = 75
hpmin = 10
atkl = 30
atkh = 60
class bard:
hpmax = 40
hpmin ... |
17eaa9e40cf3445cddf9e819b16a4977b7ba7c3d | gpiotti/linearp | /oe/pivot.py | 761 | 3.546875 | 4 | from collections import OrderedDict
import csv
myfile = open('pivot.csv', 'w')
def readCsv(path):
with open(path, 'r') as f:
reader = csv.reader(f)
return list(reader)
temp = OrderedDict()
csv_input = readCsv('assignment.csv')
for row in csv_input:
teacher = row[0]
temp[teacher] = []
... |
89f45c5e6e15160ef29cadfdba4b5a608d172653 | AyushVtejpal123/python-flask-assingment | /day-16.py | 967 | 4.4375 | 4 | # Day 16:
import pandas as pd
# 1. Write a Pandas program to convert a dictionary to a Pandas series.
# Sample Series:
# Original dictionary:
# {'a': 100, 'b': 200, 'c': 300, 'd': 400, 'e': 800}
# Converted series:
# a 100
# b 200
# c 300
# d 400
# e 800
# dtype: int64
d1 = {'a': 100, 'b': 200, 'c':3... |
bedba808d9673a3838ee61d3fa77fe73d276a830 | kingbj940429/Coding_Test_Solution | /beak_joon/b_2839_unsolved.py | 406 | 3.53125 | 4 | ''' 2839번 설탕 배달 '''
if __name__ == "__main__" :
sugar = int(input())
bag = 0
while sugar >= 0 :
if sugar % 5 == 0 : # 5의 배수이면
bag += (sugar // 5) # 5로 나눈 몫을 구해야 정수가 됨
print(bag)
break
sugar -= 3
bag += 1 # 5의 배수가 될 때까지 설탕-3, 봉지+1
else :... |
3308bdc0e5b8c25e39ebab6b8f303dd1ec030f1d | ablade/CodingChallenge | /Python3/insertionSort.py | 477 | 3.90625 | 4 |
def insertionSort(a):
for i in range(1,len(a)):
iptr = i
cptr = i - 1
val = a[i]
while cptr >= 0:
if val < a[cptr]:
a[iptr] = a[cptr]
iptr -= 1
cptr -= 1
else:
a[iptr] = val
break... |
18e820485ed36b52cdc2d92c6bea43d6f452fa5a | PhilippeCarphin/tests | /Python_tests/generator_send.py | 1,167 | 3.59375 | 4 |
def my_gen():
n = 0
for a in range(10):
ret = n*a
print(f'yielding ret={ret}')
yield ret
print(f'waiting for d')
d = yield
print(f'Received d={d}')
n += d
def test_my_gen():
gen = my_gen()
print('generator created')
print('next -->')
p... |
583bb89d0df069578d691144af531c140106646a | arjunhmalhotra/turtleart | /abstract.py | 2,728 | 4.21875 | 4 |
import turtle
def drawDot(george,x, y, radius):
'''
This function uses recursive principals to draw hundreds of hexagons.
To change the depth, change the radius size below. Inputs are
george the turtle, starting x coordinate, starting y coordinate, and radius
of the circle. Output is a turtle d... |
43e389c235f174a0e22758382809cb2d34b98dfd | vishrutkmr7/DailyPracticeProblemsDIP | /2023/01 January/db01072023.py | 949 | 3.875 | 4 | """
You are given a dataset represented as an integer array, nums that contains values between one and n.
Inside the data set, an error has occurred such that one of the values between one and n has been
duplicated to another number between one and n. Because of this, one of the values between one and n
appears twice a... |
6bfe39d4d94c0becf7787af6e5299569357600f3 | jvitasek/VUT-FIT-IPP-Proj2 | /parser.py | 22,135 | 3.546875 | 4 | #!/usr/bin/env python3
#CST:xvitas02
"""!
@package parser.py
Parsing C files for specified values.
This module carries out the most important function
in this project – it parses the assigned values from
the content of a file and returns the number of matches.
"""
import os
import re
import itertools
import sys
c... |
4c59fc96cfc76a03d897ed99459fef03ec926a43 | zhangfengwe/python | /python/study/python01_03/python03_strFormat/StrFormat_Template.py | 282 | 3.5 | 4 | #使用模板字符串格式化字符串
'''
使用string模块中Template,通过关键字参数(包含等号的参数),关键字参数使用$定义
'''
from string import Template
tmpl = Template("Hello world ----$langu")
tmpl = tmpl.substitute(langu="python")
print(tmpl) |
5fb27a14ce6db7b69c120836d966a84a65d64870 | rammohanbethi/Basic-openCV-Tutorials | /Day-2/Crop_Image.py | 516 | 3.53125 | 4 | import cv2
path = r'D:\opencv tutorials\Day-1\tiger.jpg'
img = cv2.imread(path)
print(img.shape)
#frame size
width, height = 400,400
ImgResize=cv2.resize(img,(width,height))
print(ImgResize.shape)
#image cropping
imgCropped = img[0:120,200:240]
#resize the cropped image
imCropResize = cv2.resize(imgCropped,(img.shap... |
dfe1b71f4bca7dc0438ae83fd418ad131fb8aba9 | huzaifahshamim/coding-practice-problems | /Lists, Arrays, and Strings Problems/1.3-URLify.py | 1,061 | 4.1875 | 4 | """
Write a method to replace all spaces in a string with '%20'. You may assume that the string
has sufficient space at the end to hold the additional characters, and that you are given the "true"
length of the string. (Note: if implementing in Java, please use a character array so that you can
perform this operation i... |
7dab233f6fad59c0b5339155d4e3d0451087da0c | edybahia/python2018 | /Condicionais/if e else.py | 315 | 4.03125 | 4 |
idade = int(input("Digite a sua idade"))
if idade >= 18:
print(" Você é maior de idade")
else:
print('Você é menor de idade')
# perceber que em C tem a questão do (;) aqui não há necessidade
# a condição para substituir o then em (C) é apenas os (:)
# else necessita está com os (:) ao final |
b492cd4bb86fbd62a106e8d32ff6b85cd9ff1097 | cybersaksham/OpenCV-Tutorials | /T01_images.py | 695 | 3.609375 | 4 | import cv2
# Reading image
"""
0 - Grayscale
1 - Coloured (Default)
-1 - Unchanged
"""
img = cv2.imread("lena.jpg", 0)
# If image does not exists then img will be None otherwise it will be matrix of pixels
print(img)
# Showing Image
cv2.imshow("Window Title", img) # This window destroy immediately
# In order to sto... |
1b3978021c5ab22b7539d2b5bba96f551c871a66 | raymondmar61/pythoncrashcourse | /ch5ifstatementstaketwo.py | 6,266 | 4.28125 | 4 | #Python Crash Course Chapter 5 If Statements
#for loop, in, not in, are included
cars = ["audi","bmw","subaru","toyota"]
for eachcar in cars:
if eachcar == "bmw":
print(eachcar.upper())
else:
print(eachcar.title())
requested_toppings = ["mushrooms","onions","pineapple"]
print("mushrooms" in requested_toppings) #... |
7592588ddcd51643b36705425d4f176e8d57ecb3 | ajithkumar98/guvi | /PALIN.py | 78 | 3.734375 | 4 | str=input()
rev=str[::-1]
if str==rev:
print("YES")
else:
print("NO")
|
3e08c1c0e6e0b19fcf376566265447579a7c9f7b | RussellCaletena/cpe101-final | /listPractice/2.py | 489 | 3.75 | 4 | lines = ['Hello there.',
'How now brown cow?',
'I like cheese']
def line_counts(list1, character):
newList = []
i = 0
while i < len(list1):
number = characterCount(list1[i], character)
newList.append(number)
i += 1
print (newList)
def characterCount(string ,ch... |
e9bc0fc3f22ae4b9bc8a71ca19ec29ee8c80e767 | GiorCocc/python_project-unipr | /Esercitazione4/high_scores.py | 556 | 3.765625 | 4 | class HighScores:
def __init__(self):
self._campo=[]*10
def add(self, p, n):
self._campo.append((p,n))
self._campo.sort(reverse=True)
def print(self):
for i in self._campo:
print(i)
def main():
scores=HighScores()
punteggio=1
... |
e8439739d7ea19837ff04182a92c70de487dd9c6 | saulorodriguesm/ifsp-exercises | /Python/Lista 3/exer6.py | 120 | 3.53125 | 4 | soma = 0
for contador in range(1, 101):
soma += contador
print("A soma dos cem primeiros números naturais é",soma) |
5df296b0e6df80c0f8be2d3c4cfa74edae88c95f | bilal684/INF8215 | /TP1/src/part1.py | 2,197 | 3.5 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Sep 8 10:43:22 2018
@author: Bilal Itani, Mohammed Esseddik Ben Yahia, Xiangyi Zhang
"""
import numpy as np
import time
import copy
from queue import Queue
def bfs(graph, places):
"""
Returns the best solution which spans over all attractions indicated in 'places'... |
25bf30af38203b97a2902e17440cc6e3e4b56ce9 | guilhermepardo/Projetos | /Python/CursoEmVideo/pythonteste/exercicio12.py | 206 | 3.640625 | 4 | preco = float(input('Digite o preço do produto: '))
desconto = preco * 0.05
novoPreco = preco - desconto
print('O produto custava {:.2f}, com o desconto, passou a custar {:.2f}'.format(preco, novoPreco))
|
f18b71359b59af27717f1eba1cf7f4a8739b21b2 | rosworld07/pythonprograms | /python programs/progrm22_year i sleap or not.py | 144 | 3.9375 | 4 | # year i sleap or not
year =int(input("enter year "))
if year%4==0:
print("leap year ")
else:
print("not leap year")
|
4e8787a91d66a8eb65e7ce55afae9e36c06bccdc | jsh854/Hacktoberfest2021 | /python/sieveOfEratosthenes.py | 328 | 3.515625 | 4 | #python implementation od sieve of eratosthenes
def sieve(n):
prime = [True for i in range(n+5)]
prime[0]=False
prime[1]=False
pnt = 2
while(pnt<=n**0.5):
if prime[pnt]==True:
for j in range(pnt*pnt,n+5,pnt):
prime[j]=False
pnt+=1
for i in range(2,n):
if prime[i]==True:
p... |
7f13051a051d2b2af4b91c5f3cbe6ace08b94be8 | fridriks98/Forritunarverkefni | /Python_projects1/Mímir verkefni/mimir_verkefni/strings and/verkefni6.py | 276 | 4.15625 | 4 | name = input("Input a name: ")
name_change = name.split(', ')
last_word = name_change[0].capitalize()
lastname = last_word[0:len(last_word)]
first_name = name_change[1]
first_initial = first_name[:1].capitalize()
new_name = first_initial + ". " + lastname
print(new_name)
|
5c29a88c8ee03fbe6ecc3945a415362135d09985 | jcshott/interview_prep | /max_depth_bin_tree.py | 2,621 | 3.921875 | 4 | class Node(object):
def __init__(self, val=None):
self.value = val
self.leftChild = None
self.rightChild = None
def __repr__(self):
return "<value: {}, leftChild: {}, rightChild: {}>".format(self.value, self.leftChild, self.rightChild)
class BinarySearchTree(object):
def ... |
861fdd3c71437cffb62c3811568ce72673236c41 | django-group/python-itvdn | /домашка/starter/lesson 7/Aliona Baranenko/add_task.py | 135 | 3.53125 | 4 | import random
my_list = []
for i in range(10):
my_list.append(random.randint(0, 10))
print(my_list)
print(my_list[::-1]) |
a0d40786d1cf42afc5faa016989bc83f5c180619 | IAmAbszol/DailyProgrammingChallenges | /DailyProgrammingBookChallenges/Review/DynamicProgrammingPractice/largest_rectangle.py | 2,103 | 4.03125 | 4 | '''
Perform a histogram approach using DP.
This is like the house problem, instead we store all the results from
the previous in the current row.
Then we perform histogram analysis like the largest rectangle problem in a histogram.
To fully explain.
We start at the first row, calculate the solution or prev wh... |
ddf6e559278ea2c6ddf27e34c5841a8ef0341099 | daniellehwang/python0802 | /Function1.py | 977 | 3.5 | 4 | #Function1.py
# 리턴을 하지 않는 함수
def setValue(newValue):
#지역변수
x=newValue
print("지역변수: ", x)
# 호출
result = setValue(5)
print(result)
def swap(x,y):
return y,x
#호출
result = swap(3,4)
print(result)
# 디버깅 연습
def intersect(prelist, postlist):
#지역변수
result = []
#H(0) | A(1) |M(2)
for x in pr... |
8b9b8e7462a3718ff17c0eb4cab0fe8021ce6a92 | rnsdoodi/Programming-CookBook | /Back-End/Python/Basics/Part -4- OOP/03 - Single Inheritance/02_delegating_parent.py | 1,729 | 3.8125 | 4 | from math import pi
from numbers import Real
class Person:
def __init__(self, name):
self.name = name
class Student(Person):
def __init__(self, name, student_number):
super().__init__(name)
self.student_number = student_number
class Circle:
def __init__(self, r):
... |
494fde529a0f8d049e1e3194205eefce233a7abe | Pauekn/project_euler | /number_3.py | 590 | 3.96875 | 4 | #!/usr/bin/python
"""
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
"""
import sys
def is_prime_number(number):
if number < 2:
return False
for i in range(2, (number//2)+1):
# When i reaches more than the half, there are no more ... |
bf2babfd2117ac0aea117c5f7acc39984ceefa6f | lixiang2017/leetcode | /leetcode-cn/2185.0_Counting_Words_With_a_Given_Prefix.py | 679 | 3.75 | 4 | '''
执行用时:40 ms, 在所有 Python3 提交中击败了53.81% 的用户
内存消耗:15.2 MB, 在所有 Python3 提交中击败了21.19% 的用户
通过测试用例:95 / 95
'''
class Solution:
def prefixCount(self, words: List[str], pref: str) -> int:
return sum(w.startswith(pref) for w in words)
'''
执行用时:40 ms, 在所有 Python3 提交中击败了53.81% 的用户
内存消耗:15.1 MB, 在所有 Pytho... |
91e704ace1130d00e5936c6cb5df64a9fef44431 | jboles31/Python-Sandbox | /functions_part1/exercises.py | 1,613 | 3.828125 | 4 |
def single_letter_count(string, char):
return len([x for x in string.lower() if x == char.lower()])
print(single_letter_count('Hello', "h"))
print(single_letter_count('Hello', "z"))
print(single_letter_count('Hello', "l"))
#
def multiple_letter_count(string):
result = {char: 0 for char in string}
print(re... |
26cabbe820d897a05852cc6ed1098d0c0b1d26db | MacHu-GWU/pyclopedia-project | /pyclopedia/p03_stdlib/_datapersistance/sqlite3/syntax_SELECT.py | 951 | 3.828125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Select sql syntax.
"""
import sqlite3
connect = sqlite3.connect(":memory:")
cursor = connect.cursor()
def iter_cursor(cursor, arraysize=20):
"""fetch n data from cursor at each time. If query hits millions of data,
this will keep memory usage low.
"""
... |
5ec3a32eaf6aebd496c37b3cbee47c5d7893097c | SamueldaCostaAraujoNunes/Design-Patterns | /Observer/calculadora.py | 618 | 3.984375 | 4 | from abc import ABC, abstractmethod
class Calculo(ABC):
def __init__(self, x, y):
self.x = x
self.y = y
super().__init__()
@abstractmethod
def calcular(self):
pass
class Soma(Calculo):
def calcular(self):
return self.x + self.y
class Subtrai(Calculo):
... |
77527f899eeffe9705beca1b0ba61f90b7e5374a | lakshuguru/Hacker-Rank | /19_interface.py | 1,192 | 4.125 | 4 | '''The AdvancedArithmetic interface and the method declaration for the abstract divisorSum(n) method are provided for you in the editor below.
Complete the implementation of Calculator class, which implements the AdvancedArithmetic interface. The implementation for the divisorSum(n) method must return the sum of all... |
dbffc5e04ea38ca43f3bd2f0b3f93270723ef94e | isabella232/solexcc-example-workers | /led/script/default.py | 2,018 | 3.71875 | 4 | import sys
from lib.led_control import LEDControl
leds = LEDControl()
def toColor(str):
if str == "red":
return [0, 125, 0]
elif str == "green":
return [125, 0, 0]
elif str == "blue":
return [0, 0, 125]
elif str == "purple":
return [0, 125, 125]
elif str == "yellow":
return [125, 125, 0]
elif str ==... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.