blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
5d105331052818558742bc74a88b8bc02978a40a | wenjie711/Leetcode | /python/137_single_Num2.py | 452 | 3.78125 | 4 | #!/usr/bin/env python
#coding: utf-8
class Solution:
# @param {integer[]} nums
# @return {integer}
def singleNumber(self, nums):
one = 0
two = 0
three = 0
for i in range(len(nums)):
two |= one & nums[i]
one ^= nums[i]
three = two & one
... |
39068a965cfff9d2ca75fdfe8135d25c52b13142 | jovicamitrovic/ori-2016-siit | /vezbe/01-linreg/src/solutions/linreg_simple.py | 1,645 | 3.578125 | 4 | """
@author: SW 15/2013 Dragutin Marjanovic
@email: dmarjanovic94@gmail.com
"""
from __future__ import print_function
import random
import matplotlib.pyplot as plt
def linear_regression(x, y):
# Provjeravamo da li su nam iste dimenzije x i y
assert(len(x) == len(y))
# Duzina liste x i... |
fd10e971ea57316b742f15932f0c0d17613e6e4f | jovicamitrovic/ori-2016-siit | /vezbe/01-linreg/src/bonus/birth_rate.py | 1,521 | 3.625 | 4 | # -*- coding: utf-8 -*-
"""
@author: Stefan Ristanović SW3/2013
@email: st.keky@gmail.com
- Description:
Birth Rates,
per capita income,
proportion (ratio?) of population in farming,
and infant mortality
during early 1950s for 30 nations.
- Conclusion:
In that period of... |
afe9f6bb6ba3598cb26b52432df699531c19d968 | ChihChiu29/ml_lab | /image_recognition/hotspot_on_noise_classification.py | 4,037 | 4.0625 | 4 | """Academical examples on image classifications.
This module is an experiment for classifying images. The goal is to train a
model that can successfully identify images annotated in certain way. The
annotation is a small image that's super-imposed on a background image.
"""
import keras
import numpy
from keras import ... |
12daf4f361701b49e3a14820d6bb91d337497de1 | bjskkumar/Python_coding | /test.py | 1,591 | 4.28125 | 4 | # name = "Jhon Smith"
# age = 20
# new_patient = True
#
# if new_patient:
# print("Patient name =", name)
# print("Patient Age = ", age)
#
# obtaining Input
name = input("Enter your name ")
birth_year = input (" Enter birth year")
birth_year= int(birth_year)
age = 2021 - birth_year
new_patient = True
if new_... |
6f582a234b2c9264a2bf877047ac7c9a66b22ae4 | dnackat/cs50x-intro-to-comp-sci | /sentimental/vigenere.py | 1,727 | 4.03125 | 4 | # vigenere.py
import sys
import string
# Define a main function to match C code
def main():
# Check if input is correct
if len(sys.argv) == 1 or len(sys.argv) > 2 or not str.isalpha(sys.argv[1]):
print("Usage ./vignere k")
sys.exit(1)
else:
# Convert key to lowercase
key ... |
487e1b65563ee4502403216662ee64a4f119d78b | DmytroLopushanskyy/lab11_part2 | /polynomial/polynomial.py | 5,656 | 4.34375 | 4 | """
Implementation of the Polynomial ADT using a sorted linked list.
"""
class Polynomial:
"""
Create a new polynomial object.
"""
def __init__(self, degree=None, coefficient=None):
"""
Polynomial initialisation.
:param degree: float
:param coefficient: float
""... |
ee30fcac54df14dc48870f687033ce02266bb5c9 | prasadnaidu1/django | /Adv python practice/QUESTIONS/14.py | 125 | 3.859375 | 4 | n=int(input("enter no :"))
lst=[]
for x in range(0,n):
if x%2!=0:
lst.append(x)
else:
pass
print(lst) |
cb25bb6cd9b6a5ef56ac747b131369787d0efa78 | prasadnaidu1/django | /Adv python practice/method override/KV RAO OVERRIDE2.py | 1,096 | 3.984375 | 4 | class numbers(object):
def __init__(self):
print("i am base class constructor")
def integers(self):
self.a=int(input("enter a value : "))
self.b=int(input("enter b value : "))
self.a,self.b=self.b,self.a
print("For swaping integers of a, b : ",self.a,self.b)
print... |
abb0668e938b64b6cf404a3d11aa50b2e4d1d463 | prasadnaidu1/django | /Adv python practice/OOPS/constructer.py | 798 | 3.78125 | 4 | class sample:
comp_name = "Sathya technologies"
comp_adds = "Hyderabad"
def __init__(self):
while True:
try:
self.employee_id = int(input("Enter a No : "))
self.employee_name = input("Enter a Name : ")
print("Company Name : ",sample.comp_na... |
d463732ff9853cf2872192e16a3ff1dda5ba763c | prasadnaidu1/django | /Adv python practice/OOPS2.py | 360 | 3.859375 | 4 | #Write a program on class example without creating any object.
class demo:
comp_name="Prasad Technologies"
Comp_adds="hyd"
@staticmethod
def dispaly(x,y):
print("Company Name:",demo.comp_name)
print("Company Adds :",demo.Comp_adds)
i=x
j=y
print("The sum of above ... |
e597d95e27d3968b8316fcb844a7ec26576dbca7 | prasadnaidu1/django | /Adv python practice/sisco3.py | 5,404 | 3.859375 | 4 | lst = []
while True:
name = input("Enter Name : ")
lst.append(name)
ans = input("Continue press y : ")
if ans == "y":
continue
else:
print(lst)
res = len(lst)
print(res)
break
class management:
def putdetails(self):
self.type=input("Enter Type Of I... |
7c4b8a424c943510052f6b15b10a06a402c06f08 | prasadnaidu1/django | /Adv python practice/QUESTIONS/10.py | 845 | 4.125 | 4 | #Question:
#Write a program that accepts a sequence of whitespace separated words as input and prints the words after removing all duplicate words and sorting them alphanumerically.
#Suppose the following input is supplied to the program:
#hello world and practice makes perfect and hello world again
#Then, the output s... |
ee21470f4fda9757bd0e754f2b3dceb80c6fe4af | prasadnaidu1/django | /Adv python practice/ASSIGNMENT2.py | 3,046 | 3.953125 | 4 | basic_salary = float(input("Enter Your Salary : "))
class employee:
def salary(self):
tax=input("If You Have Tax Expenses Press y/Y : ")
if tax=="y":
ta=float(input("Enter How much TaxExpenses You Have(In The Form Of Percentage): "))
ta_r=ta/100
self.taxes=basic_... |
56431060c05fe0ab91e9b1e4c6ac3939d3936b47 | prasadnaidu1/django | /Adv python practice/QUESTIONS/9.py | 474 | 4.03125 | 4 | #Question£º
#Write a program that accepts sequence of lines as input and prints the lines after making all characters in the sentence capitalized.
#Suppose the following input is supplied to the program:
#Hello world
#Practice makes perfect
#Then, the output should be:
#HELLO WORLD
#PRACTICE MAKES PERFECT
lst=[]
while ... |
f676db3d1fc4f349b7ddb2dec69723782cd4d1d2 | jakeloria02/Python_AI | /Main.py | 884 | 3.859375 | 4 | import requests, json
leave = {"exit", "leave", "end", "bye"}
GREETINGS = {"hello", "hey", "yo", "boi", 'hey man', 'hey boi', 'hey 117', 'hey [117]', "heyo", "heyy"}
GREETING_RESP = {"Hello", "Hey", "Hello, Sir!"}
WEATHER = {'whats the weather today?', "weather", 'whats the weather?', 'whats the weather today', 'w... |
32fdb667ad72b8d13d7d844bde4491b0955165d4 | thisislsj/smart-reservation | /logicpy.py | 695 | 3.578125 | 4 | msg=["02","07","3"]
msgSimple="batman"
print("msg is ",msgSimple)
seatsAvailable=50
referencecode=5
while True:
msgInput=input("Type the msg: ")
print(msgInput)
if msgInput=="superman":
if seatsAvailable >0:
referencecode=referencecode+1
seatsAvailable=seatsAvailable-1
... |
570740ed8b072e0b249309b15d33f27f2b94d158 | nupur24/python- | /untitled4.py | 592 | 3.5625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon May 21 14:16:32 2018
@author: HP
"""
while True:
s = raw_input("enter string : ")
if not s:
break
if s.count("@")!=1 and s.count(".")!=1:
print "invalid"
else:
s = s.split("@")
#print s
usr = s[0]
print usr... |
47f0ab0709c616b62f4871047f350b935cc1a6e2 | nupur24/python- | /nupur_gupta_12.py | 303 | 4.03125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue May 15 12:01:08 2018
@author: HP
"""
def br():
s,b,g=a
if g%5 > s:
return False
if s+b*5 >= g:
return True
else:
return False
a=input("enter numbers:")
print br()
|
11b760a6ae93888c812d6d2912eb794d98e9c3e0 | mohadesasharifi/codes | /pyprac/dic.py | 700 | 4.125 | 4 | """
Python dictionaries
"""
# information is stored in the list is [age, height, weight]
d = {"ahsan": [35, 5.9, 75],
"mohad": [24, 5.5, 50],
"moein": [5, 3, 20],
"ayath": [1, 1.5, 12]
}
print(d)
d["simin"] = [14, 5, 60]
d.update({"simin": [14, 5, 60]})
print(d)
age = d["mohad"][0]
print(age)
for k... |
76b21b47b0166c5a98529751abbba6323d8aef43 | JacquesAucamp/Factorial-Digits | /JAucamp_factorial_digits.py | 2,435 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Oct 8 12:41:16 2021
@author: User-PC
"""
import sys
#==========================================================
# CALCULATION FUNCTION
#==========================================================
def SumOfFactorialDigits(x):
digits_sum = 0
# Cr... |
0c4c7448b192fe9f90938a8e3bceae6b10844fd8 | henrylu518/LeetCode | /Best Time to Buy and Sell Stock III.py | 1,342 | 3.828125 | 4 | """
Author: henry, henrylu518@gmail.com
Date: May 23, 2015
Problem: Best Time to Buy and Sell Stock III
Difficulty: Medium
Source: http://leetcode.com/onlinejudge#question_123
Notes:
Say you have an array for which the ith element is the price of a given stock on day i.
Design an algorithm to f... |
e92b6ffddca5f7d7764278e8fca08da691e8da5c | henrylu518/LeetCode | /Combinations.py | 1,246 | 3.578125 | 4 | """
Author: Henry, henrylu518@gmail.com
Date: May 13, 2015
Problem: Combinations
Difficulty: Easy
Source: http://leetcode.com/onlinejudge#question_77
Notes:
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.
For example,
If n = 4 and k = 2, a solution is:... |
f7ced0cc2205948a24e69d0aaf2ec99d2fd8a09e | henrylu518/LeetCode | /Sqrt(x).py | 735 | 3.8125 | 4 | """
Author: Henry, henrylu518@gmail.com
Date: May 13, 2015
Problem: Sqrt(x)
Difficulty: Easy
Source: http://leetcode.com/onlinejudge#question_69
Notes:
Implement int sqrt(int x).
Compute and return the square root of x.
Solution: Binary search in range [0, x / 2 + 1].
There is also... |
a4dd4cde4800d2071a460bb53d0c8a26b1b1f4d8 | henrylu518/LeetCode | /Search Insert Position.py | 456 | 3.671875 | 4 | class Solution:
# @param {integer[]} nums
# @param {integer} target
# @return {integer}
def searchInsert(self, nums, target):
low, high = 0, len(nums) - 1
while low <= high:
middle = (low + high) / 2
if nums[middle] == target:
return middle
... |
66201819201c710b9bc3cb6b66eec783d1450b6b | henrylu518/LeetCode | /Remove Duplicates from Sorted List II.py | 1,139 | 3.5 | 4 | """
Author: Henry, henrylu518@gmail.com
Date: May 14, 2015
Problem: Remove Duplicates from Sorted List II
Difficulty: Easy
Source: https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list-ii/
Notes:
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only... |
00da27e1e70bac78566304625fe1cec186b7a587 | henrylu518/LeetCode | /Jump Game II.py | 1,513 | 3.546875 | 4 | """
Date: May 18, 2015
Problem: Jump Game II
Difficulty: Easy
Source: http://leetcode.com/onlinejudge#question_45
Notes:
Given an array of non-negative integers, you are initially positioned at the first index of the array.
Each element in the array represents your maximum jump length at that positi... |
ce9f6b1070b57982cc521fbe9672d18fced43a58 | henrylu518/LeetCode | /Populating Next Right Pointers in Each Node.py | 1,915 | 4.0625 | 4 | """
Author: Henry, henrylu518@gmail.com
Date: May 16, 2015
Problem: Populating Next Right Pointers in Each Node
Difficulty: Easy
Source: http://leetcode.com/onlinejudge#question_116
Notes:
Given a binary tree
struct TreeLinkNode {
TreeLinkNode *left;
TreeLinkNode *right;
TreeLinkNod... |
d112900cddfe3b0bbef72efeeb697dfc6cbe86bb | zman0225/python_cryptography | /ciphers/detectEnglish.py | 1,294 | 3.546875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: ziyuanliu
# @Date: 2014-02-07 18:12:47
# @Last Modified by: ziyuanliu
# @Last Modified time: 2014-02-07 21:23:50
UPPERLETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
LETTERS_AND_SPACE = UPPERLETTERS + UPPERLETTERS.lower() + ' \t\n'
def loadDictionary():
dictionar... |
b6ba17928cbcb5370f5d144e64353b9d0cd8fcbd | Mohsenabdn/projectEuler | /p004_largestPalindromeProduct.py | 792 | 4.125 | 4 | # Finding the largest palindrome number made by product of two 3-digits numbers
import numpy as np
import time as t
def is_palindrome(num):
""" Input : An integer number
Output : A bool type (True: input is palindrome, False: input is not
palindrome) """
numStr = str(num)
for i in range(len(numS... |
82aff3d2c7f6ad8e4de6df39d481df878a7450f7 | sree714/python | /printVowel.py | 531 | 4.25 | 4 | #4.Write a program that prints only those words that start with a vowel. (use
#standard function)
test_list = ["all", "love", "and", "get", "educated", "by", "gfg"]
print("The original list is : " + str(test_list))
res = []
def fun():
vow = "aeiou"
for sub in test_list:
flag = False
... |
8d6df43f43f157324d5ce3012252c3c89d8ffba4 | superyaooo/LanguageLearning | /Python/Learn Python The Hard Way/gpa_calculator.py | 688 | 4.15625 | 4 | print "Hi,Yao! Let's calculate the students' GPA!"
LS_grade = float(raw_input ("What is the LS grade?")) # define variable with a string and input, no need to use "print" here.
G_grade = float(raw_input ("What is the G grade?")) # double (()) works
RW_grade = float(raw_input ("What is the RW grade?"))
F... |
2de9b9b92b49f32c62e9d86b0c69985f8fb4bb85 | superyaooo/LanguageLearning | /Python/Learn Python The Hard Way/ex39.py | 1,069 | 3.953125 | 4 | ten_things = "Apples Oranges Crows Telephone Light Sugar"
print "Wait there's not 10 things in that list, let's fix that."
stuff = ten_things.split(' ') # need to add space between the quotation marks.
more_stuff = ["Day","Night","Song","Frisbee","Corn","Banana","Girl","Boy"]
while len(stuff) != 10:
nex... |
edfb7ae4988150d17c6fb84b68e44ecdc8d17806 | superyaooo/LanguageLearning | /Python/Learn Python The Hard Way/ex40ss.py | 322 | 3.609375 | 4 | # experiment version 2
cities = {'CA': 'San Francisco', 'MI': 'Detroit',
'FL': 'Jacksonville'}
cities['NY'] = 'New York'
cities['OR'] = 'Portland'
for city in cities.items():
print "City:", city
for state,city in cities.items():
print "Places to move:", (state,city)... |
a3ae3bea53a3b19012f0b93749ac8c8aaa6a2427 | superyaooo/LanguageLearning | /Python/Learn Python The Hard Way/ex14s.py | 649 | 4.0625 | 4 | from sys import argv
script, user_name = argv
prompt = 'What you say?' # prompt could be random things. it shows up at line 9,12,15.
print "Hi,%s!%s here :)" %(user_name,script)
print "Need to ask you some questions."
print "Do you eat pork,%s?" % user_name
pork = raw_input(prompt)
print "Do you ... |
66ec728580a3be763105fe44f399b5f98f3c449f | AndreyAD1/18_price_format | /format_price.py | 837 | 3.640625 | 4 | import argparse
def get_console_arguments():
parser = argparse.ArgumentParser()
parser.add_argument('price', type=float, help='Enter a price.')
arguments = parser.parse_args()
return arguments
def format_price(price):
if type(price) == bool:
return None
try:
real_num_price = ... |
62d2ca63e780982a75df63ebba2853fa1a3de150 | TylerGarlick/intermediate-python-course | /my_list.py | 218 | 3.5625 | 4 | def main():
r = [4, -2, 10, -18, 22]
print(r[2:6])
print(f'len list of {r[-1]}')
t = r.copy()
print(f'is t the same as r? {t is r}')
c = r[:]
print(f'is t the same as r? {t is c}')
main()
|
5476eab2b0b2834ebb789d623703fdded5e4fa3e | RomarioGit/AED_1 | /AED26.py | 1,351 | 4 | 4 |
class aluno:
def __init__(self,nome,cpf,nota):
self.nome = nome
self.cpf = cpf
self.nota = nota
def get_nota(self):
if not self.nota == 0:
return True
return False
def cadastrar_aluno(lista_alunos):
nome = input("Informe o nome: ")
cpf = input("Info... |
15e2d34d87b113c8f3b48ae4e0478541f8af8960 | chrisesharp/aoc-2018 | /day25/constellation.py | 1,682 | 3.609375 | 4 | import sys
def find_constellations(input):
points = {}
for line in input.split():
point = tuple(map(int, line.split(',')))
assimilated = False
linked = {}
for known_point in list(points.keys()):
if close_enough(known_point, point):
points, linked = as... |
9789e52489b57ddc65791d841e5f693c0e3924a4 | selinali2010/hello-world | /oneRoundYahtzee.py | 1,685 | 3.921875 | 4 | from random import choice
rolls = {
0:"None",
1: "Pair",
2: "Two Pairs",
3: "Three of a kind",
4: "Four of a kind",
5: "Yahtzee!",
6: "Full House",
7: "Large Straight"
}
dice = []
for x in range(5):
dice.append(choice([1,2,3,4,5,6]))
print "Dice %i: %i" % (x + 1, dice[x])
#find the number of rep... |
44f8726cd570bf4339a767dde3e62713463da2b5 | Vladyslav92/Python_HW | /lesson_6/4_task.py | 378 | 3.828125 | 4 | # Поиск минимума с переменным числом аргументов в списке.
# def min(*args): ....
enter = [10, 20, 35, 5, 6, 2, 7, 15]
def min(*args):
base_list = args
sorted_list = []
for i in base_list:
for j in i:
sorted_list.append(j)
result = sorted(sorted_list)
return result[0]
print(m... |
86902979397a947dd5d85874129c8d1aab949ac6 | Vladyslav92/Python_HW | /lesson_2/3_task.py | 536 | 4.21875 | 4 | # На ввод подается строка. Нужно узнать является ли строка палиндромом.
# (Палиндром - строка которая читается одинаково с начала и с конца.)
enter_string = input('Введите строку: ').lower()
lst = []
for i in enter_string:
lst.append(i)
lst.reverse()
second_string = ''.join(lst)
if second_string == enter_string:... |
3de9c9f7af71fd66a0b8336e9c0a4fdcbf538973 | Vladyslav92/Python_HW | /lesson_7/2_task.py | 616 | 3.625 | 4 | # Реализовать примеры с functools - wraps и singledispatch
from functools import singledispatch, wraps
def dec_function(func):
"""Function in function"""
@wraps(func)
def wrapps():
"""decorated function"""
pass
return wrapps
@dec_function
def a_function():
"""Simple Function"""
... |
1f84a5ede2aa4aa8d8fea4921dc1bc53e66e9d91 | Vladyslav92/Python_HW | /lesson_11/3_task.py | 1,024 | 4 | 4 | # Реализовать класс который будет:
# 3.a читать из ввода строку
# 3.b проверять, что строка состоит только из скобочек “{}[]()<>”
# 3.c проверять, что строка является правильной скобочной последовательностью - выводить вердикт
class Brackets:
def __init__(self):
self.line = ... |
6cefa99cdb92c9ed5738d4a40855a78b22e23b1b | Vladyslav92/Python_HW | /lesson_8/1_task.py | 2,363 | 4.34375 | 4 | # mobile numbers
# https://www.hackerrank.com/challenges/standardize-mobile-number-using-decorators/problem
# Let's dive into decorators! You are given mobile numbers.
# Sort them in ascending order then print them in the standard format shown below:
# +91 xxxxx xxxxx
# The given mobile numbers may have +91, 91 or 0 wr... |
d2f3d3b79ad81c34394ed3cfa336b07f5edaceff | viniandrd/Biodiesel-Simulator | /utils/logginprinter.py | 656 | 3.625 | 4 | import sys
class LoggingPrinter:
def __init__(self, filename):
self.out_file = open(filename, "w")
self.old_stdout = sys.stdout
# this object will take over `stdout`'s job
sys.stdout = self
# executed when the user does a `print`
def write(self, text):
self.old_std... |
3f5e5c7307e293db831a422f71e762d559edee95 | saravey2021/homework-week-11 | /Homework week 11/fri2.py | 347 | 3.96875 | 4 | def getPrice(fruitName):
if fruitName=="banana":
return 2
if fruitName=="apple":
return 5
if fruitName=="orange":
return 1
print("banana price is:"+str(getPrice("banana"))+" dolars")
print("Orange price is:"+str(getPrice("orange"))+" dolars")
print("apple price is:"+str(getP... |
1ac6e401e05a22f94610ceb0e2aee0d7350cd3c2 | Zoranc1/boggle | /boggle.py | 2,220 | 3.5625 | 4 | from string import ascii_uppercase
from random import choice
def make_grid(colums,rows):
return { (c,r) : choice(ascii_uppercase)
for r in range(rows)
for c in range(colums)}
def potencial_neighbours(position):
c, r = position
... |
3aa3b572f2561c795397cc40a3ee0e6eb522f036 | pranavvm26/RandomProblemCodes | /find_longest_palindrome.py | 1,488 | 4.09375 | 4 | import copy
palindrome_list = []
def find_palindrome(palindrome_string):
longest_current_palin = 0
list_p = list(palindrome_string)
for i in range(2, len(list_p), 1):
duplicate_string = copy.deepcopy(list_p)
del duplicate_string[0:i]
_set = list_p[0:i]
res = "".join(_set) i... |
66d4bc1aec1f41337454123409ef597b1ea9ae8d | timmywilson/pandas-practical-python-primer | /training/level-1-the-zen-of-python/dragon-warrior/peppy.py | 836 | 4 | 4 | """
This code (which finds the sume of all unique multiples of 3/5 within a
given limit) breaks a significant number of PEP8 rules. Maybe it doesn't even
work at all.
Find and fix all the PEP8 errors.
"""
import os
import sys
import operator
INTERESTED_MULTIPLES = [3, 5] # constants should be all caps ... |
554db1fd0a01073381a9877a33c4d1859e6e2915 | maralex2003/OlistDojo1 | /dojo/ativ_1e2/categories.py | 1,114 | 3.5 | 4 | class Category:
def __init__(self, id: int, name: str):
self.__id = id
self.__name = name
def set_id(self, id: int) -> None:
self.__id = int(id)
def get_id(self) -> int:
return self.__id
def set_name(self, name: str) -> None:
self.__name = name
def get_na... |
68ece26086a0fdc492e49949c1ca30df1a784ec2 | maralex2003/OlistDojo1 | /aula016/05_assert_classes.py | 1,304 | 4.09375 | 4 | # Com assert podemos testar as classes e seus métodos
# podendo verificar objetos da classe e
# o resultado de seus comportamentos
class Product:
def __init__(self, name:str, price:float)->None:
self.name = name
self.price = price
@property
def name(self)->str:
return self.__name... |
b19a1447ed25ec4da8414b703a3aa433394eeb36 | charliesan16/Python-Estudio-Propio | /cantidadFilasPiramide.py | 226 | 3.9375 | 4 | bloques = int(input("Ingrese el número de bloques de la piramide:"))
altura=0
while bloques:
altura=altura+1
bloques=bloques-altura
if bloques <= altura:
break
print("La altura de la pirámide:", altura)
|
b6a922d94e92769c5ab73e7fa0bb9d200147e17b | charliesan16/Python-Estudio-Propio | /Hola Mundo.py | 146 | 3.6875 | 4 | def suma(a,b):
return a+b
a=int(input("ingrese el valor de a="))
b=int(input("ingrese el valor de b="))
s=suma(a,b)
print("La suma es de=",s)
|
46bc1461ea1fa5794bfc6ec29b021550c54dc7d0 | Ashutoshcoder/python-codes | /Aggregation/groupAccordingToStateAndMatching.py | 1,741 | 3.78125 | 4 | """
Author : Ashutosh Kumar
Version : 1.0
Description : Grouping according to state and then finding state with population >100
Then we are finding the biggest city and smallest city in the State.
Email : ashutoshkumardbms@gmail.com
"""
import pymongo
import pprint
myclient = pymongo.MongoClient('mongodb://localhost... |
ce2e70a9d3734bacde1fd864de4ade2c53734d17 | Ashutoshcoder/python-codes | /user_nobash.py | 769 | 3.671875 | 4 | '''
Author : Ashutosh Kumar
PRN : 19030142009
Assignment: Read all the usernames from the /etc/passwd file and list users
which do not have bash as their default shell
'''
fp = ""
try:
# opening file in read mode
fp = open('/etc/passwd', 'r')
# extracting every user from the file
for line in fp:
... |
530bfb68b165b1948f17c85ad7853059150d4806 | Ashutoshcoder/python-codes | /Mongo-Example-Implementation/Bank/employeeManager.py | 2,770 | 3.609375 | 4 | '''
Author : Ashutosh Kumar
Version : 1.0
Description : Creating a Employee Management Functions(Insert,Update,Delete)
Email : ashutoshkumardbms@gmail.com
'''
import sys
import pymongo
myclient = pymongo.MongoClient('mongodb://localhost:27017/')
mydb = myclient['empolyeedata']
mycol = mydb['employees']
def main():... |
2c9d97b447fc0a3aaf464660c88ac4b9264023e7 | Ashutoshcoder/python-codes | /data-science/barGraph.py | 518 | 3.5 | 4 | """
Author : Ashutosh Kumar
Version : 1.0
Description : Plotting bar graph in Python
Email : ashutoshkumardbms@gmail.com
"""
import numpy as np
import matplotlib.pyplot as plt
city = ["Delhi", "Beijing", "Washingtion", "Tokyo", "Moscow"]
pos = np.arange(len(city))
Happiness_index = [60, 40, 70, 65, 85]
plt.bar(pos, ... |
2d9c35e286e33a57bb0a441324fa16fc1c9f9793 | kozl-ek/module_0 | /Kozlova.EV_1.py | 2,018 | 3.53125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[6]:
import numpy as np
number = np.random.randint(1,100) # загадали число от 1 до 100
print ("Загадано число от 1 до 100")
def change(a): #Задаем функцию, изменяющую размер шага. Размер шага не должен быть меньше одного, чтобы избежать зацикливания.
if a!=1:
... |
89d6646ac4c27cbd605a3c4d3459eb2762875229 | ezefranca/hackerrank-30-days | /day6/day6.py | 368 | 3.65625 | 4 | #!/bin/python3
import sys
n = int(input().strip())
strings = []
for i in range(0, n):
string = input().strip()
strings.append(string)
arr = list(strings[i])
odd = []
even = []
for j in range(0, len(arr)):
if j % 2 == 0:
even.append(arr[j])
else:
odd.appen... |
3d2c01cd94f0aea380e3dd5605d501ab44a5fbaf | TR18052000/DAY-3-ASSIGNMENT | /list.py | 159 | 3.75 | 4 | list = [1, 2, 3, 4, 5, 6]
print(list)
list[2] = 10
print(list)
list[1:3] = [89, 78]
print(list)
list[-1] = 25
print(list)
|
0f65ea15f4845b8b3e5f5117af59444a5a666cbe | thomaskost17/QHWSDGNCB | /src/models/lorenz.py | 1,169 | 3.671875 | 4 | '''
File: lorenz.py
Author: Thomas Kost
Date: 08 August 2021
@breif function for lorenz chaotic system, and plotting script
'''
import numpy as np
import matplotlib.pyplot as plt
def lorenz(x :np.array, beta: np.array)->np.array:
'''
x: position state vector of lorenz system
beta: vector o... |
466900753c34afb3fb85f7a23563005515d2cd78 | jacobdanovitch/COMP1005_TA_Portal | /solutions/a4/soln.py | 3,269 | 3.578125 | 4 | #Author: Andrew Runka
#Student#: 100123456
#This program contains all of the solutions to assignment 4, fall2018 comp1005/1405
#and probably some other scrap I invented along the way
def loadTextFile(filename):
try:
f = open(filename)
text = f.read()
f.close()
return text
except IOError:
print(f"File {fi... |
781fc5a0241560371636b46c096d0a476fce622d | henrypalacios/transactions_account | /backend_api/src/foundation/write_lock.py | 1,196 | 3.875 | 4 | from threading import Thread, Condition, current_thread, Lock
class ReadersWriteLock:
""" A lock object that allows many simultaneous "read locks", but
only one "write lock." """
def __init__(self):
self._read_ready = Condition(Lock())
self._readers = 0
def acquire_read_lock(self):
... |
90be014b94c2b6a63f759e191759412965cc0acd | ModelPhantom/raspberrypython | /pygametest/hellopython.py | 367 | 3.59375 | 4 | import pygame
width=640
height=480
radius=100
stroke=1
pygame.init()
window=pygame.display.set_mode((width,height))
window.fill(pygame.Color(255,255,255))
while True:
pygame.draw.circle(window,pygame.Color(255,0,0),(width/2,height/2),radius,stroke)
pygame.display.update()
if pygame.QUIT in [e.type for e ... |
0b40c91c5a9f2316d0bb16155a00f77857d74df1 | soporte00/python_practice | /01_vacattion_system_for_rappi_employees.py | 2,172 | 3.703125 | 4 | import os
'''
sections
key section
1 A. clientes
2 Logística
3 Gerencia
employees
key time(years) vacations(days)
1 1 6
1 2-6 14
1 7 20
2 1 7
2 2-6 15
2 7 22
3 1 10
3 2-6 20
3 7 30
'''
while True:
os.system("clear")
prin... |
57c4893c2f0db4ad531c725146b92b5ee066f7ed | bmoser12/608-mod3 | /custom-object.py | 473 | 3.78125 | 4 | #use this to figure out a bill total including tip and tax
def tip_amount(total,tip_percent):
return total*tip_percent
def tax_amount(total, tax_percent):
return total*tax_percent
def bill_total(total,tax,tip):
return total+tip_amount+tax_amount
total = 100
tip_percent = .20
tax_percent = .075
tax = ... |
d21033c6e4ba17697dcbdf20072ab069d3e4779c | imrehg/coderloop | /missile/python/missile | 1,760 | 3.84375 | 4 | #!/usr/bin/python
import sys
def findlongest(nums):
"""
Dynamic programming: O(n^2)
based on:
http://www.algorithmist.com/index.php/Longest_Increasing_Subsequence#Dynamic_Programming
"""
n = len(nums)
if n == 0:
return 0
length = [1]*n
path = range(n)
for i in xrange(1, n):
... |
f3032a78f96bd74011401e625d5f20c263cad637 | TheGavinCorkery/BattleshipPythonGame | /Player.py | 1,570 | 3.828125 | 4 | from Board import Board
class Player():
def __init__(self):
self.my_board = Board()
self.guess_board = Board()
self.opponent_board = []
self.hits = 0
#Control all methods to guess a spot on opponents board
def guess_spot(self):
print('Here is your current guessing b... |
6dd2950189bb6d780432ea24b884b5a01b6406cd | Joghur/modbus-reader | /data/queries.py | 1,820 | 3.625 | 4 | import sys
from utils.files import import_config
"""Methods for manipulating a SQlite database
Create and insert methods
SQL queries are defined at top of file
"""
# getting database configurations
config = import_config('config_database.json')
# guard clause in case config file doesn't exist
if not config:
sy... |
6cd9cc1bb0048fc3414916d3da5652c816258ba6 | noah-daniel-mancino/algorithms-on-the-side | /max_line.py | 804 | 3.546875 | 4 | """
You can characterize each line by the m and b in y = mx + b. Do this for each
pair of lines, and see which ones pops up the most.
"""
def max_points(points):
lines = set()
lines_frequency = {}
for index, point in enumerate(points):
other_points = points[index + 1:]
print(other_points)
... |
198648ec4ed8b8019cbb6ce31ec4e561429f9600 | TheSliceOfPi/Practice-Questions | /sumSquareDiff.py | 551 | 4 | 4 | '''
The sum of the squares of the first ten natural numbers is,
The square of the sum of the first ten natural numbers is,
Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is .
Find the difference between the sum of the squares of the first one hundred na... |
3ef4d753b1429f9cdb1ea4ed7a02fbe80387a3ac | Scarlett4431/LeetCode | /150.py | 901 | 3.515625 | 4 | #150. Evaluate Reverse Polish Notation
class Solution(object):
def evalRPN(self, tokens):
"""
:type tokens: List[str]
:rtype: int
"""
stack= []
for t in tokens:
if t!='+' and t!='-' and t!='*' and t!='/':
stack.append(t)
else:
... |
27ea6e6eec457d29ee6f9cc7d147043649c9f5e8 | shami09/IvLabs | /conditionex3.1.py | 206 | 3.859375 | 4 | hrs = input("Enter Hours:")
h = float(hrs)
rate=input("Enter Rate:")
r=float(rate)
if h > 40:
nom=h*r
ep=(h-40)*(r*0.5)
pay=nom+ep
else:
pay=h*r
print("Pay:",pay) |
231f69494ca4939e8d1d698aa49559a526f7cc8a | DHSZ/igcse-pre-release-summer-2021-22 | /task2.py | 6,778 | 4.21875 | 4 | """
Summer 2021 - Pre-release material
Python project to manage a electric mountain railway system
Author: Jared Rigby (JR)
Most recent update: 19/03/2021
"""
# Task 1 - Start of the day
train_times_up = [900, 1100, 1300, 1500] # Train times for going up the mountain
train_seats_up = [480, 480, 480, 480]... |
f4a47627b293951f8f6c408628b7034809e5c68a | emildoychinov/Talus | /loader/cogs/ttt.py | 6,769 | 3.671875 | 4 | from discord.ext import commands
import time
#a util function that will be used to make a list into a string
makeStr = lambda list : ''.join(list)
class tictactoe(commands.Cog):
def __init__(self, bot, comp_sign='x', p_sign='o'):
self.bot = bot
self.pos=0
self.p_move = -1
s... |
fb04a8d334283582cca10c9ae04126e97476f4f9 | wchi619/Python-Assignment-1 | /a1_wchi3.py | 6,844 | 4.53125 | 5 | #!/usr/bin/env python3
"""
OPS435 Assignment 1 - Fall 2019
Program: a1_wchi3.py
Author: William Chi
This program will return the date in YYYY/MM/DD after the given day (second argument) is passed. This program requires 2 arguments with an optional --step flag.
"""
# Import package
import sys
def usage():
"""Begi... |
4deb99f3c3c58525f632d85d77c748be62a7ce5b | juraj80/Python-Data-Stuctures | /10/romeo.py | 430 | 3.8125 | 4 | ''' print the ten most common words in the text '''
import string
handle=open('romeo-full.txt')
counts=dict()
for line in handle:
line=line.translate(None,string.punctuation)
line=line.lower()
words=line.split()
for word in words:
if not word in counts:
counts[word]=1
else:
counts[word]=counts[word]+1
res... |
cf8efc269f8d53acd9b41e2bc876a32f3b11c620 | juraj80/Python-Data-Stuctures | /09/bigcountA.py | 596 | 3.53125 | 4 | name = raw_input("Enter file:")
if len(name) < 1 : name = "mbox-short.txt"
handle = open(name)
emails=list()
for line in handle:
line=line.rstrip()
if line=="":continue
if not line.startswith("From:"):continue
words=line.split()
emails.append(words[1])
counts=dict()
for email in emails:
if not e... |
4bd83144bd8246dd40fd063efb8ccb6808ab4abf | juraj80/Python-Data-Stuctures | /07/enterfile.py | 171 | 3.59375 | 4 | inp=raw_input("Enter a file:")
try:
file=open(inp)
except:
print "Error. Please Enter a File."
exit()
for line in file:
line=line.rstrip()
print line
|
f81888b47c87ceefa5f458913dbcc47319dfc185 | chavadasagar/python | /fectorial.py | 204 | 3.875 | 4 | n = int(input("enter number"))
fec = 1
for x in range(1,n+1):
fec = fec * x
print(fec)
'''
# using recursion
def fec(n):
if n == 1:
return 1
else:
return n * fec(n-1)
'''
|
a1d76dd2a74db5557596f2f3da1fbb2bf70474d2 | chavadasagar/python | /reverse_string.py | 204 | 4.40625 | 4 | def reverse_str(string):
reverse_string = ""
for x in string:
reverse_string = x + reverse_string;
return reverse_string
string = input("Enter String :")
print(reverse_str(string))
|
6992e8064e8031e1b0023071471f937152b69263 | Dakarai/war-card-game | /main.py | 3,338 | 3.53125 | 4 | import random
suits = ('Clubs', 'Diamonds', 'Hearts', 'Spades')
ranks = ('2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A')
values = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'T': 10, 'J': 11, 'Q': 12, 'K': 13, 'A': 14}
war_cards_count = 3
class Card:
def __init__(self, suit... |
4ca802795b88b9a184cb4fedd62ad242a5ba59e4 | theballkyo/GetA | /classes/gradebar.py | 1,594 | 3.53125 | 4 | from tkinter import *
class Progressbar():
obj_progress = False
def __init__(self, root, max_width, max_height, score):
bar = Label(root)
bar.place(x=60,y=30)
self.canvas = Canvas(bar, width=max_width-2, height=max_height)
self.canvas.pack()
self.color = self.get_color... |
86643c2fe7599d5b77bdcbe3e6c35aa88ba98ecc | aemperor/python_scripts | /GuessingGame.py | 2,703 | 4.25 | 4 | ## File: GuessingGame.py
# Description: This is a game that guesses a number between 1 and 100 that the user is thinking within in 7 tries or less.
# Developer Name: Alexis Emperador
# Date Created: 11/10/10
# Date Last Modified: 11/11/10
###################################
def main():
#... |
4978f92dab090fbf4862c4b6eca6db01150cf0b7 | aemperor/python_scripts | /CalcSqrt.py | 1,059 | 4.1875 | 4 | # File: CalcSqrt.py
# Description: This program calculates the square root of a number n and returns the square root and the difference.
# Developer Name: Alexis Emperador
# Date Created: 9/29/10
# Date Last Modified: 9/30/10
##################################
def main():
#Prompts user for a + num... |
a7eda8fb8d385472dc0be76be4a5397e7473f724 | petyakostova/Software-University | /Programming Basics with Python/First_Steps_in_Coding/06_Square_of_Stars.py | 237 | 4.15625 | 4 | '''Write a console program that reads a positive N integer from the console
and prints a console square of N asterisks.'''
n = int(input())
print('*' * n)
for i in range(0, n - 2):
print('*' + ' ' * (n - 2) + '*')
print('*' * n)
|
62e95db13611d9a6ecbdbb070b9b176d673b81f2 | petyakostova/Software-University | /Programming Basics with Python/First_Steps_in_Coding/04_Triangle_Of_55_Stars.py | 300 | 3.984375 | 4 | '''
Write a Python console program that prints a triangle of 55 asterisks located in 10 rows:
*
**
***
****
*****
******
*******
********
*********
**********
'''
for i in range(1,11):
print('*'*i)
'''
for i in range(1, 11):
for j in range(0, i):
print('*', end="")
print()
''' |
3f25e4489c087b731396677d6337e4ad8633e793 | petyakostova/Software-University | /Programming Basics with Python/Simple-Calculations/08-Triangle-Area.py | 317 | 4.3125 | 4 | '''
Write a program that reads from the console side and triangle height
and calculates its face.
Use the face to triangle formula: area = a * h / 2.
Round the result to 2 decimal places using
float("{0:.2f}".format (area))
'''
a = float(input())
h = float(input())
area = a * h / 2;
print("{0:.2f}".format(area))
|
b8e9d1e43fb13bbe5056d92687169e83393add1a | Isaac51743/Algorithms-in-Python | /src/recursion/recursion1.py | 739 | 4.0625 | 4 | # 12/18/2020
def fibonacci(index):
if index == 0 or index == 1:
return index
return fibonacci(index - 1) + fibonacci(index - 2)
print(fibonacci(4))
# assuming a and b are both integer, return type is double
def a_power_b(a, b):
if a == 0 and b <= 0:
return None
elif a == 0 and b > 0:... |
09ff50c23a5e27d558ed1c7769439bf28b0243e3 | Isaac51743/Algorithms-in-Python | /src/bits_probability_dfs/probability.py | 2,830 | 3.609375 | 4 | import random as r
import heapq as hq
def shuffle_poker(array):
if len(array) != 52:
return
for idx in range(52):
random_idx = r.randint(idx, 51)
array[idx], array[random_idx] = array[random_idx], array[idx]
test_array = [i for i in range(52)]
shuffle_poker(test_array)
print(test_arr... |
21e2669bf38725d1cd712ed2b7ffd2c01dfb5ed4 | Isaac51743/Algorithms-in-Python | /src/code_review3.py | 2,409 | 3.59375 | 4 | import math
def dropped_request(time_list):
if len(time_list) == 0:
return 0
dropped_num = 0
for index in range(len(time_list)):
case1 = index >= 3 and time_list[index] - time_list[index - 3] + 1 <= 1
case2 = index >= 20 and time_list[index] - time_list[index - 20] + 1 <= 10
... |
b37c28841c34b9a4b44052326d39f4dd7f0c12ae | donaldex/code | /repeat_str.py | 202 | 3.984375 | 4 | def repeat_str():
s = input("Enter string: ")
t = input("Enter int>=0: ")
n = int(t)
print(n*s)
print("anni is stupid")
# return "ddddd"
##repeat_str()
print(repeat_str())
|
15e9c4495517c834dca50c81383cace908117392 | larinanatalia/class | /hw6.py | 1,875 | 3.9375 | 4 | class Animal:
satiety = 'hungry'
def __init__(self, name, weight):
self.name = name
self.weight = weight
def feed(self):
self.satiety = 'animal ate food'
class Bird(Animal):
eggs = 'dont have eggs'
def pick_eggs(self):
self.eggs = 'we picked eggs'
class Goose(B... |
550a70f93c012bb9255ed755c18a74a203ed480f | nkhalili/py-samples | /02/08-conditional-operators.py | 173 | 4 | 4 |
x = 5
y = True
if x == 5 and y:
print('true')
# ternary operator
hungry = 0
result = 'feed the bear now!' if hungry else 'do not feed the bear.'
print(result) |
9790fb0d75f15431ca643b1f65319a329460c902 | nkhalili/py-samples | /02/11-loops-input.py | 320 | 3.796875 | 4 | secret = "secret"
pw = ''
while pw != secret:
if pw == '123': break
pw = input('Enter secret word:')
else: # in case while breaks, else won't run
print('>Secret key is correct.')
animals = ('bear', 'bunny', 'dog', 'cat')
for pet in animals:
print(pet)
else:
print('>Items finished.') |
3197f5ebde279a17087f81362239b07685067bba | nkhalili/py-samples | /02/03-blocks.py | 307 | 3.84375 | 4 | x = 42
y = 73
# Blocks define by indentation e.g. 4 spaces
if x < y:
z = 100
print("x < y: x is {}, y is {}".format(x, y))
## in python blocks do not define scope, Functions, objects, module DO.
# z has the same scope as x and y even though its block is different!
print("z is: ", z)
|
d90948ed064194d3f86571ec3c38f3680a2a9552 | TestardR/Python-algorithms-v1 | /sentence_reversal.py | 507 | 3.9375 | 4 | def rev_word(str):
return " ".join(reversed(str.split()))
def rev_word1(str):
return " ".join(str.split()[::-1])
def rev_word2(str):
words = []
length = len(str)
space = [' ']
i = 0
while i < length:
if str[i] not in space:
word_start = i
while i < leng... |
bb2c102167c19e3531e76e3b29da34608283ece8 | MikolajTwarog/Artificial-Intelligence | /connect4/board.py | 3,330 | 3.6875 | 4 | #!/usr/bin/env python3
class Board:
def __init__(self):
self.board = [[0]*7 for i in range(6)]
self.moves = 0
self.end = False
def check_vertical(self, row, column, who):
line = 0
for i in range(row, 6):
if self.board[i][column] == who:
... |
87f5fd7703bafe4891fb042de2a7f1770c602995 | BreeAnnaV/CSE | /BreeAnna Virrueta - Guessgame.py | 771 | 4.1875 | 4 | import random
# BreeAnna Virrueta
# 1) Generate Random Number
# 2) Take an input (number) from the user
# 3) Compare input to generated number
# 4) Add "Higher" or "Lower" statements
# 5) Add 5 guesses
number = random.randint(1, 50)
# print(number)
guess = input("What is your guess? ")
# Initializing Variables
ans... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.