blob_id stringlengths 40 40 | repo_name stringlengths 5 119 | path stringlengths 2 424 | length_bytes int64 36 888k | score float64 3.5 5.22 | int_score int64 4 5 | text stringlengths 27 888k |
|---|---|---|---|---|---|---|
6587705a15a43d121ada8b53d580f45b36d1e2c8 | eronekogin/leetcode | /2023/maximum_ascending_subarray_sum.py | 439 | 3.546875 | 4 | """
https://leetcode.com/problems/maximum-ascending-subarray-sum/
"""
class Solution:
def maxAscendingSum(self, nums: list[int]) -> int:
i, n = 0, len(nums)
maxSum = 0
while i < n:
currMax = nums[i]
while i + 1 < n and nums[i + 1] > nums[i]:
i += 1
... |
c4b51157af0a2f83dbb36fbf9d2b45872a6377f5 | artificially-ai/nltk_tutorial | /src/hello_nltk.py | 2,837 | 4.03125 | 4 | """
Organisation: ekholabs
Author: wilder.rodrigues@ekholabs.ai
"""
'''
Understand the context of a text.
concordance()
- Displays all occurrences of a word along with the contexy.
similar()
- Returns a list of words that appear in similar context - usually synonyms.
common_con... |
7bc3c03c37cb86d00fc41aa3cbe43fedf00c3991 | karanjakhar/python-programs | /ty.py | 2,122 | 4.125 | 4 |
print("1.Program to find whether a number is Even or Odd using function")
def number():
x=int(input("Enter the Number : "))
if(x%2==0):
print("Even Number")
else:
print("odd Number")
number()
print("2.Program to Display calculator using function")
def cal():
print("1. Add ... |
6f03e6d4331aa5d194dc6281320da6565ac087bd | TypeKazt/CS260 | /hw5/make_heap.py | 1,050 | 3.671875 | 4 | #!/usr/bin/env python
def left(H, i):
result = (i+1)*2
if result > len(H):
return None
return result - 1
def right(H, i):
result = (i+1)*2
if result >= len(H):
return None
return result
def parent(H, i):
if i == 1:
return None
result = int((i+1)/2)
return result - 1
def swap(H, nodeA, nodeB):
temp =... |
dc7d9ff423e3d6a8fca2463e258e1e4aee826537 | Coliverfelt/Desafios_Python | /Desafio039.py | 1,066 | 4.1875 | 4 | # Exercício Python 039: Faça um programa que leia o ano de nascimento de um jovem e informe,
# de acordo com a sua idade, se ele ainda vai se alistar ao serviço militar,
# se é a hora exata de se alistar ou se já passou do tempo do alistamento.
# Seu programa também deverá mostrar o tempo que falta ou que passou do pra... |
72a307fee0909cb767cc94b6de139738e92f9163 | mattecora/AmI-Labs | /python-lab1/ex02.py | 179 | 3.875 | 4 | my_str = input("Insert a string: ")
my_len = len(my_str)
if my_len < 4:
print("String too short!")
else:
print(my_str[0] + my_str[1] + my_str[my_len-2] + my_str[my_len-1]) |
b2b2d1816132a8ae7fad5de203377ef1cf3fa777 | Kalaiselvan1503/Guvi1 | /fibonaci_till_n.py | 124 | 3.65625 | 4 | #huhduiofhio
n=int(input())
a=1
b=1
print(1,1,end=" ")
while(n-2):
c=a+b
a=b
b=c
print(c,end=" ")
n=n-1
|
97321458b6e591457dab39c96319bfb93b5abd7f | igorvalamiel/material-python | /Exercícios - Mundo 1/013.py | 176 | 3.671875 | 4 | x = float(input('Digite o seu salário:'))
p = (15 / 100) * x
a = x + p
print('Se seu chefe te premiasse com um aumento de 15%, o seu salário seria de {} reais.'.format(a))
|
7097e8e4f67363d584b1e94bfa40f000dcb132ce | larryokubasu5460/Algorithms | /brute force/bubble sort.py | 342 | 4.25 | 4 |
def bubble_sort(array):
for i in range(len(array)-1):
index=i
for j in range(i+1,len(array)):
if array[index]>=array[j]:
array[index], array[j]=array[j],array[index]
array=[100,234,45,3,67,895,32,4,8,67,3,2,4,67,841,34,6]
print("array ",array)
bubble_sort(array)
print(... |
4902fae3babb5b92a207ad45786e12c7014023a1 | gituser182/PythonFiles | /TestCode/Reversing.py | 418 | 3.6875 | 4 | #test reverse
print ('...Inversing a string...')
message = input('Typ een bericht:')
translated = ''
i = len(message) - 1 #-1: telt vanaf nul! Eerste element staat op message[0]
print('lengte bericht = ', len(message))
while i >=0:
print ('bericht[', i ,']', message[i])
translated = translated + message[i]
... |
85b8e65cdec6313ead22529a193bd3177060450e | Elsabalabala/LearnGit | /nwmath.py | 420 | 3.71875 | 4 | #!usr/bin/env python
#coding=utf-8
def add(a, b):
return a + b
def subtract(a, b):
if isinstance(a,int) and isinstance(b,int):
return a - b
else:
return "error input"
def multiply(a, b):
return a * b
def divide(numerator, denominator):
if denominator!=0 and isinstance(den... |
7a47f38a8939f15871306f5090248b4e4e32912b | iordanistavridis/- | /ergasia1.py | 1,133 | 3.53125 | 4 | from random import shuffle
measurement = input("Enter the size of the square:")
measurement = int(measurement)
list1 = []
x = measurement/2
pl = int(x)
rest = measurement-pl
count=0
for v in range(100):
for j in range(measurement):
examplelist = []
examplelist = [0] * rest + [1] * pl
shuffle(ex... |
1dccd108be9057d4d28a3cec2e17565f87179bfb | aiaurora/hy | /hy.py | 302 | 3.71875 | 4 | name=input("姓名:")
print('嗨!',name)
a = int(input('今天有沒有下雨? 0:無,1:有' ))
if a == 1:
print('留在家裡吧!')
elif a == 0:
print('出去玩吧!')
else :
print('???')
b = float(input('今天氣溫攝氏幾度?'))
b = b * 9 / 5 + 32
print('華氏:', b, '度') |
5b027cc5029f8c1895298db12fc3f6ec0d2c4ba8 | hongliang5623/vanyar | /script/sort/quick_sort.py | 2,687 | 3.625 | 4 | # -*- coding: utf-8 -*-
def QuickSort(arr,firstIndex,lastIndex):
if firstIndex<lastIndex:
divIndex = Partition(arr,firstIndex,lastIndex)
print divIndex
QuickSort(arr, firstIndex, divIndex)
QuickSort(arr,divIndex+1,lastIndex)
else:
return
def Partition(arr,firstIndex,l... |
941d2f5a9dd8c68fd172d8cbb623427f3fa91fc0 | mleef/PSS | /scripts/line_breaks.py | 423 | 3.5 | 4 | # Helper script to add line breaks between newly concatenated FASTA file.
import sys
def addLineBreaks(file):
f = open(file, 'r+').read()
# For every sequence, insert a line break before it
out = f.replace(">", "\n>")
print(out)
def main(argv = sys.argv):
f1 = argv[1]
addLineBreaks(f1)
if __na... |
d47d5227a23921efbb42201b4a887fd42bff53ee | AndrewDunham/BasicPython | /getIcalDetails.py | 314 | 3.515625 | 4 | file = open(inputFile,"r")
#Read each line and split them into the type and details
lines = file.readlines()
for line in lines:
#Get the line type and details of each line
lineType = line.split(':')[0]
lineDetails = line.split(':')[1]
lineDetails = lineDetails.rstrip()
|
566bc6c5e45bc43c7d7448afd29304c7fd8321ab | danelia1998/pycharm-projects | /checkerr.py | 918 | 3.734375 | 4 | def method_friendly_decorator(method_to_decorate):
def wrapper(self, lie, datvirtva):
if datvirtva == 100:
print("luci must take {} dollars".format(100))
elif 100 > datvirtva >= 80:
print("luci must take {} dollars".format(80))
elif 80 > datvirtva >= 60:
p... |
c5a802d24b8a8da2e75503f071dad2b1de5fbeed | whitej9406/cti110 | /P3LAB_White .py | 697 | 4.15625 | 4 | # CTI-110
# P3LAB - Debugging
# Jacob White
# 10/4/2018
# This program takes numeric grade input and outputs the letter grade.
def main():
# system uses 10-point grading scale
# Define scores
A_score = 90
B_score = 80
C_score = 70
D_score = 60
# user input
scor... |
50f516d0cc49c2e3bf247270f826b201dd3033cf | LukeOsburn/K-Nearest-Neighbours-Explained-Simply | /KNearestNeighboursCalculatingTheSkilloftheModel.py | 3,104 | 3.53125 | 4 | import numpy as np
from sklearn import cross_validation
import pandas as pd
from math import sqrt
from collections import Counter
import matplotlib.pyplot as plt
from operator import itemgetter
#Lets predict the class for the test data and compare with actual and calculate the percentage of succcesful predicti... |
ef73dec02c04e1b7d3aea00dcb21a309ccfc3cce | jannejaago/prog_alused | /3/yl3.1.py | 115 | 3.8125 | 4 | kord = int(input("Sisestage mitu korda äratada: "))
while kord >= 1:
print("Tõuse ja sära!")
kord -= 1
|
c8710f2df1a2a0b886e8d9f56ebe5cad6554f781 | ChinmayaKinnarkar/Python | /python-numerical-computing-with-numpy.py | 28,044 | 4.3125 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Numerical Computing with Python and Numpy
#
# 
#
# ### Part 6 of "Data Analysis with Python: Zero to Pandas"
#
#
# This tutorial series is a beginner-friendly introduction to programming and data analysis using the Python programming lan... |
8495e9311f5e23b4bb0ca76993ee1f3edc8ba0ec | Wenbin-Xiao/LeetCode | /code/125.py | 548 | 3.671875 | 4 |
# 给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写。
# 说明:本题中,我们将空字符串定义为有效的回文串。
class Solution:
def isPalindrome(self, s: str) -> bool:
s_temp = ""
for i in range(len(s)):
if s[i].isdigit() | s[i].isalpha():
s_temp = s_temp + s[i]
if s_temp == "":
return True
... |
06fe9d9f0fcd8c22d379d0fa2a902a908d855b38 | iEuler/leetcode_learn | /q1286.py | 2,106 | 3.78125 | 4 | """
1286. Iterator for Combination
Medium
https://leetcode.com/problems/iterator-for-combination/
Design an Iterator class, which has:
A constructor that takes a string characters of sorted distinct lowercase English letters and a number combinationLength as arguments.
A function next() that returns the next combinati... |
b6a6d6fa0c4b72f7629031f607dbdc1f4e30d016 | weihsuanchou/algorithm_py | /counterfeit.py | 3,174 | 3.75 | 4 |
#AVG190500T
# Hello World program in Python
#1: reqirement first 3 eng_chars, upper and distinct
#2: reqirement year 1900~2019
#3: reqirement index faceamount before last letter
#4: reqirement after faceamount must be a len=1 eng_char
serialNumber = ["AVG190420T", "RTF20001000Z","QWER201850G","AAA2019100B","QWER2018... |
eb4535d30b54c529181b4e30fedec00dd76b0845 | sagnikghoshcr7/DSA-AlgoExpert-Practice_Solutions | /Dynamic Programming/maxSubsetSumNoAdjacent.py | 1,112 | 3.671875 | 4 | """
Maximum Subset Sum With No Adjacent Elements
Write a function that takes in an array of positive integers and returns
an integer representing the maximum sum of non-adjacent elements in the array.
If a sum cannot be generated, the function should return 0.
Sample input: [75, 105, 120, 75, 90, 135]
Sampl... |
410102283d361cb272da43539da4dedbeba57aa8 | hartantosantoso7/Belajar-Python | /program_for_loop.py | 582 | 3.796875 | 4 | # membuat program menggunakan For-loop, List dan Range
banyak = int(input("Berapa banyak data? "))
nama = []
umur = []
for data in range(0, banyak):
print(f"data {data}")
print("==========================")
input_nama = input("Nama: ")
input_umur = int(input("Umur: "))
print("====================... |
7ff206fd06700318b72a52a87b586da736e7de64 | sksr99/grade-calculator | /grade_calculator.py | 2,348 | 4.28125 | 4 | def main():
"""Takes user grade inputs and puts them into grade calculator function"""
reading_amt = []
quiz_amt = []
exam_amt = []
lab_amt = []
readings = input("Reading grades: ").split()
for reading in readings:
reading = int(reading)
reading_amt.append(reading)... |
4c865e27cd4fc70f05ef4154077c72825f55eceb | Mongoose556/RSR | /main.py | 2,702 | 3.984375 | 4 |
#BASED ON :http://www.miielz.com/WWIII/Media/Red%20Storm%20Rising%20Board%20Game%20Basic%20Rules.pdf
# class factory example http://code.activestate.com/recipes/86900/
# generate random integer values
import random
from unit import Unit
######################################################################... |
d218aa7eef3c1579d6155b3bcf18fe8d8534886a | Amisha328/reinforcement-learning-implementation | /WindyGridWorld/windyGridWorld.py | 5,389 | 3.796875 | 4 | import numpy as np
class State:
def __init__(self, state=(3, 0), rows=7, cols=10):
self.END_STATE = (3, 7)
self.WIND = [0, 0, 0, 1, 1, 1, 2, 2, 1, 0]
self.ROWS = 7
self.COLS = 10
self.state = state # starting point
self.isEnd = True if self.state == self.END_STATE... |
b60c4b374805b49175dc0ca3892512c7bcc6d1f8 | DebabrataSharma/atlantis-assignment | /assignment-3/general.py | 2,111 | 3.984375 | 4 | from math import radians, cos, sin, asin, sqrt, atan2,pi
from config import *
def split_coordinates(city1_coordinate,city2_coordinate):
'''
split the coordinates of both cities and store in an array
'''
city1_arr = city1_coordinate.split(", ")
city2_arr = city2_coordinate.split(", ")
result... |
bcbebf353ed42d1d978f1a7a1d380b845712e61f | xuongtrantrieu/Basic-Python | /level_2/question 7.py | 227 | 3.5625 | 4 | def xy_dimension(n, m):
xy = [[0 for j in range(m)] for i in range(n)]
for i in range(n):
for j in range(m):
xy[i][j] = i * j
return xy
if __name__ == '__main__':
print(xy_dimension(3, 4))
|
7be0266fd9cefcb2cb4a47c42cc0894dc6a2ad05 | oscarhscc/algorithm-with-python | /剑指offer/树的子结构.py | 1,023 | 3.90625 | 4 | '''
题目描述
输入两棵二叉树A,B,判断B是不是A的子结构。(ps:我们约定空树不是任意一个树的子结构)
'''
# -*- coding:utf-8 -*-
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
# 将pRoot1的本身或者左右子树和pRoot2进行比较,看是否有相同的树结构
def HasSubtree(self, pRoot1, p... |
af8a43a3bb0ee6aa95117fa5dc16377b4f1dde64 | eechoo/Algorithms | /LeetCode/EditDistance.py | 1,341 | 3.9375 | 4 | #!/usr/bin/python
'''
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)
You have the following 3 operations permitted on a word:
a) Insert a character
b) Delete a character
c) Replace a character
'''
class Solution:
# @re... |
a9b07569cd2b813904c475007434564d929f68b6 | JosephLevinthal/Research-projects | /5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/223/users/4178/codes/1679_1100.py | 471 | 3.625 | 4 | # Teste seu código aos poucos.
# Não teste tudo no final, pois fica mais difícil de identificar erros.
# Ao testar sua solução, não se limite ao caso de exemplo.
var1 = int(input("Entrada: "))
if var1 == 2:
msg="Tartaruga"
elif var1 == 5:
msg="Garca"
elif var1 == 10:
msg="Arara"
elif var1 == 20:
msg="Micro-leao-do... |
861f6918f6c1a63fe9bf513a7caece1602474e62 | cmdtvt/R421-python-course | /Chapter9/task9-1.py | 995 | 4.5 | 4 | '''
The exercise in the 9th chapter focuses on one of the most powerful tools in the Python language, the datatype list, and the first assignment is a simple exercise to create. Define a list which has four items, strings "Blue","Red","Yellow" and "Green". After this, make a slice from the list which contains only the ... |
f8bb42ec80ca07a20cdb56f3e77d41e2ecfb2d73 | Lucas-Guimaraes/Reddit-Daily-Programmer | /Easy Problems/201-210/204easy.py | 855 | 3.515625 | 4 | #https://www.reddit.com/r/dailyprogrammer/comments/2xoxum/20150302_challenge_204_easy_remembering_your_lines/
#Unfortunately, macbeth.txt was deleted from this challenge.
lines = open("macbeth.txt").read().splitlines()
phrase = "Eye of newt" #can be replaced with input
#Function to grab start of dialogue
f... |
3d32cb71877e361472084166551286e7f4180f15 | motrembley/databaseProject | /DBProjMain.py | 4,447 | 4.15625 | 4 | def patient():
print("---PATIENT FUNCTION---")
x = -1
while x == -1:
print("What would you like to do?")
print("1. Enter your information\n2. check your results\n3. Find a nearby hospital")
temp = int(input())
if temp == 1:
#Enter Information
... |
a0e7efbfa84d866b62966916fc74dcd45eb09138 | skyeaaron/ICU | /datefunctions.py | 1,543 | 4.1875 | 4 | # -*- coding: utf-8 -*-
"""
Module with functions for handling dates in buildmon
"""
from datetime import datetime, timedelta
def generate_datestrings(date2 = datetime.now()):
"""
returns today's date and yesterday's date
as strings formatted %YYYYMMDD
if date2 is supplied, must be in datetim... |
c96789816affb3da605627b0f0cbfad2bb5779b7 | Mohit2597/Python | /Data Structure/lists.py | 3,263 | 4.4375 | 4 | #!/usr/bin/env python3
my_list=[2,3,4,"Python",6,7,5.8]
my_empty_list=[]
# ****IMPORTTANT****
# modificatin don't use the print
# if you want to modify the data assign it to new variable and print that variable
# dir(list)
# without __something__ these are the opertions you can perform on the lists
# list... |
d13906287c6290398246581cdd2cc92b3d9c4a34 | qz5e20/Data-Structure | /fibnacci.py | 639 | 3.6875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Feb 8 23:58:54 2021
@author: user
"""
def fibnacci(n):
if n==1 or n==2:
return 1
else:
return fibnacci(n-1)+fibnacci(n-2)
print(fibnacci(10))
def fibnacci_no_recurision(n):
f=[0,1,1]
if n>2:
for i in range (n-2):... |
e8f6b53623aa240eb25087a0c731f065871814b0 | 404232077/python-course | /ch08/8-1-9-組合.py | 410 | 3.75 | 4 | class Leg():
def __init__(self, num, look):
self.num = num
self.look = look
class Animal():
def __init__(self, name, leg):
self.__name = name
self.leg = leg
def show_name(self):
return self.__name
def show(self):
print(self.show_name(),'有', self.leg.num, '... |
749529c91a4c34b7b3f989b7e489be785b08302a | arimontoya/GWC.SIP | /practice.py | 147 | 3.53125 | 4 | def calc_total(list):
total = sum(list)
print (total)
return total
my_list = [1, 2, 3, 4, 5, 6, 7, 8, 9]
calc_total(my_list)
|
bef2ee2e61378ae5221c76d0d05b9d7bd80492f3 | xs2pranjal/data_structures | /non_linear/min_heap.py | 1,670 | 3.625 | 4 | import sys
class MinHeap:
def __init__(self):
self.maxsize = sys.maxsize
self.size = 0
self.Heap = [0] * (self.maxsize + 1)
self.Heap[0] = sys.maxsize
self.FRONT = 1
def leftChild(self, pos):
return 2 * pos
def isLeaf(self, pos):
if 2 * pos >= self... |
334ca4d0067ec0190e7ee412b9f7d3735e9ed266 | leonardotdleal/python-basic-course | /decision-structure/decision-structure.py | 1,135 | 4.25 | 4 | age = 25
if age < 18:
print('Age less than 18')
else:
print('Age more than 18')
vehicle = {'type': 'motorcycle', 'brand': 'Honda', 'potency': 140}
if vehicle['type'] == 'motorcycle' and vehicle['brand'] == 'Honda':
print('Vehicle is a motorcycle')
else:
print('Vehicle isn\'t a motorcycle')
result = ... |
6c48c4bc1574a657d3da5b60c6ad28263d1f9a78 | tonmoy50/uiu | /Simultion Lab/extra/sumu_1.py | 3,310 | 3.796875 | 4 | import numpy as np
import random as rnd
def demand():
random_digit = rnd.randint(1, 100)
daily_demand = 0
if ( random_digit >= 1 and random_digit <= 10 ):
daily_demand = 0
elif ( random_digit >= 11 and random_digit <= 35 ):
daily_demand = 1
elif ( random_digit >= 36 a... |
0823c11bc0a96b72078384fd0afcc1759ba4fe62 | deepali1232/divya-coding-classes | /numpy_library_function/numpy_shape.py | 167 | 3.65625 | 4 | import numpy as np
n1=np.array([[1,2,3],[4,5,6]])
print(n1.shape)
n1.shape=(3,2)
print(n1.shape)
n2=np.array([[1,2,3,4],[4,3,2,1]])
print(n2)
n2.shape=(4,2)
print(n2) |
a639ef8f75ecb9e064bdf026a638229241b2e292 | JenishLunagariya/BasicPython | /collection.py | 383 | 3.859375 | 4 | # program compare inputed key with keys in database and answer the value if any,otherwise shows
# wrong key message
def dic(key):
dic1 = {
'car': 'tesla',
'bike': 'ktm',
'plane': 'honda',
}
if key in dic1.keys():
return dic1[key]
else:
return 'key is unavailable i... |
0c698b79cb85efbb5ed52de25c5f96f2d0271e41 | VSablin/numpy_for_your_grandma | /5_Challenges.py | 2,508 | 4 | 4 | # In this script, we go through lesson 5 of Python NumPy for your
# Grandma course: Challenges. Web link here:
# https://www.gormanalysis.com/blog/python-numpy-for-your-grandma-challenges/
# %% Import libraries
import numpy as np
# %% Challenge 1:
# Given a 10x2 array of floats where the 1st column contains some nan ... |
a2e495fdc47015c860dc2e716dfa6d8a401a6538 | HareshNasit/LeetCode | /Array/third_max.py | 366 | 3.796875 | 4 | def thirdMax(self, nums):
"""
https://leetcode.com/problems/third-maximum-number/submissions/
:type nums: List[int]
:rtype: int
"""
nums_set = set(nums)
nums_list = list(nums_set)
nums_list.sort(reverse = True)
if len(nums_list) > 2:
re... |
5902db7897e29d0b10adf47e0398a5ba1c4d51a9 | UzairJ99/PythonLeetCode | /uniqueOccurancesCount.py | 689 | 3.734375 | 4 | class Solution:
def uniqueOccurrences(self, arr):
count = {}
#count occurances of each item and add to dictionary
for x in arr:
if (checkKey(count,x)):
count[x] += 1
else:
count[x] = 1
print(count)
un... |
d1603ebe9f16caa9ce55ee4b109c114be143ef54 | vnikos/CodeBootcamp | /ex3.py | 216 | 3.953125 | 4 | import math
a = float(input("Enter side a: "))
b = float(input("Enter side b: "))
c = float(input("Enter side c: "))
r = (a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c)
A = math.sqrt(r)/4
print ("The triangle area is: ", A)
|
b1da4221179e54d76064d0a06b0ea8c3bb057139 | hiroshees/mypygame2 | /chapter02/test05.py | 129 | 3.625 | 4 | import random
for i in range(5):
print(random.random())
print("*"*10)
for i in range(10):
print(random.randint(1,6))
|
cf1054d06fee5fabcd7495239a2e43612bf32d64 | Xithriub/Future | /EDUCATION/using_list.py | 1,552 | 3.890625 | 4 | shoplist=['Яблоки','Манго','Морковь','Бананы']
print('Я должен сделать',len(shoplist),'покупки.')
print('Покупки:',end='^-^')
for item in shoplist:
print(item,end=' ')
print('\nТакже нужно купить риса')
shoplist.append('Рис')
print('Теперь мой список покупок таков:',shoplist)
print('ОТсортирую-ка я свой список')
s... |
8e3a5077bd2a0bff80b4e621221dde01a71d9ce1 | PauloVilarinho/algoritmos | /ListasFabio/Lista2/fabio02_q16.py | 553 | 3.765625 | 4 | """
Questão: Lista 2 16
Descrição: calcula aprovação de um aluno
"""
def main():
#entrada
nota1 = float(input("digite sua primeira nota: "))
nota2 = float(input("digite sua segunda nota: "))
#processamento
media = (nota1+nota2)/2
if media >= 7 :
resultado = "Aprovado"
else :
exame_final = float(input("dig... |
bf9a569ab9dbd9c0e02835cf49447530b7d0ad96 | svanis71/codewars | /codewars.python/tests/write_out_numbers_test.py | 1,879 | 3.6875 | 4 | import unittest
from write_out_numbers import number2words
class WriteOutNumbersTests(unittest.TestCase):
"""
Tests for https://www.codewars.com/kata/52724507b149fa120600031d/train/python
"""
def test_low(self):
self.assertEqual(number2words(0), "zero")
self.assertEqual(number2words(... |
05231e00271f4f9a9377146e2950bdb30baaa427 | salimuddin87/Python_Program | /python3/Tutorial/inheritance/overloading.py | 939 | 4.28125 | 4 | """
python does not supports method overloading by default. But there are different ways to achieve method
overloading in Python.
"""
class Student:
def add(self, datatype, *args):
if datatype == 'int':
answer = 0
if datatype == 'str':
answer = ''
for x in args:
... |
81e79a296274f695e51e55cda45af668a5e07e04 | Takayoshi-Matsuyama/study-of-deep-learning | /10_数値微分.py | 3,669 | 3.578125 | 4 | import numpy as np
import matplotlib.pylab as plt
import matplotlib.pyplot as plt2
from mpl_toolkits.mplot3d import axes3d
from matplotlib import cm
def numerical_diff(f, x):
h = 1e-4 # 0.0001
return (f(x + h) - f(x - h)) / (2 * h)
def function_1(x):
return 0.01*x**2 + 0.1*x
def function_2(x):
re... |
ef5795ae36a69d0c1330598680afd4618d42b328 | Rokesshwar/Coursera_IIPP | /week 4/week 4a/week 4aPractise_exercise_2.py | 380 | 4.0625 | 4 | # List reference problem
###################################################
# Student should enter code below
a = [5, 3, 1, -1, -3, 5]
b=a
b[0]=0
print(b)
###################################################
# Explanation
#this is because when we give a new element in the existing
#elements positi... |
8e6b8da50abad89beae18889b2f987fd587fb639 | fchikwekwe/tkinter-by-example | /root.py | 260 | 3.5 | 4 | import tkinter as tk
class Root (tk.Tk):
def __init__(self):
super().__init__()
self.label = tk.Label(self, text ="Hello World", padx=20, pady=20)
self.label.pack()
if __name__=="__main__":
root = Root()
root.mainloop()
|
c3f2d1d93db241cf9094aea86b4e3504f8ab84f5 | W-R-Ramirez/Scrabble-Solver | /GUI.py | 2,339 | 4.25 | 4 | import Tkinter, tkFont
from starter import numbers_to_letters
def make_board(board):
for i in range(8):
i = i+1
line = board.create_line(i*50,100,i*50,600)
line = board.create_line(0,(i*50)+100, 450,(i*50)+100)
for i in range(2):
i = i+1
line = board.create_line(0,99+i*15... |
e5443b2cef49826d6516c44869eaff665af1201b | cakarlen/School | /Python/Lab Test 2/KarlenChase.py | 1,566 | 3.875 | 4 | # Author: Chase Karlen
# Email: chase@uky.edu
# Section: 002
from graphics import *
from math import sqrt
def distance(point1, point2):
# all four parameters are integers
# they represent the coordinates of two points
# the distance between the two points is returned
return float(sqrt((point2.getX() -... |
689da854fc52105fe33bd0698a375e1ea20635a5 | nuSapb/basic-python | /Day1/class/lib/class_encapsulation.py | 755 | 3.875 | 4 | class Base(object):
def __init__(self):
print('__init__ base class')
class User(Base):
__name = None
__is_staff = False
def __init__(self, name='Anonymous'):
self.__name = name
super(User, self).__init__()
@property
def is_authorized(self):
return self.__is_sta... |
2b556ccd096f0998bc374302b9d4d6102e26baf2 | mash716/Python | /base/array/array0006.py | 371 | 4.09375 | 4 | #removeは指定の引数に該当する要素を削除します。最初に見つかった要素のみ削除が行われる
#ので、指定の要素がリスト内に複数存在する場合は注意が必要です。
test_list_1 = ['1','2','3','2','1']
print(test_list_1)
print('------------------------------')
test_list_1.remove('2')
print(test_list_1) |
d8872d8cd83656373c7f45b431de31eaec918f9c | sam1208318697/Leetcode | /Leetcode_env/2019/7_29/Middle_of_the_Linked_List.py | 1,521 | 4.09375 | 4 | # 876.链表的中间结点
# 给定一个带有头结点head的非空单链表,返回链表的中间结点。
# 如果有两个中间结点,则返回第二个中间结点。
# 示例1:
# 输入:[1, 2, 3, 4, 5]
# 输出:此列表中的结点3(序列化形式:[3, 4, 5])返回的结点值为3。
# (测评系统对该结点序列化表述是[3, 4, 5])。
# 注意,我们返回了一个ListNode类型的对象ans,这样:ans.val = 3, ans.next.val = 4, ans.next.next.val = 5, 以及ans.next.next.next = NULL.
# 示例2:
# 输入:[1, 2, 3, 4, 5... |
d0efc5ef74accf02b1739196b798871ce6b07567 | ziwnchen/kattis | /2016-17/calendar.py | 441 | 3.65625 | 4 | import sys
line=sys.stdin.readline()
date_line=list(map(int,line.split()))
def judge(date_line):
if date_line[0]>31:
return 'Format #3'
elif (date_line[0]>12) & (date_line[0]<=31):
if date_line[2]>31:
return 'Format #2'
else:
return 'Ambiguous'
else:
... |
b60914f9e190a43132be5943e41c8ec9cad4a3d8 | leticiadesouza/AulasParticulares | /Preparatorios/exerciciosTeste2/exercicio28.py | 125 | 3.875 | 4 | valor = int(input('Informe um numero: '))
if (valor % 2 == 0):
print ('Valor eh par')
else:
print ('Valor eh impar') |
01df6c5d9a684750938d8455a7dc6c2b2a2a55b8 | changethisusername/uzh | /Informatik1/Ex 3/friendlyPair.py | 701 | 3.65625 | 4 | #You are completely free to change this variables to check your algorithm.
__author__ = "Mert Erol"
num1 = 6
num2 = 28
def isFriendlyPair():
sum1 = 0
sum2 = 0
validity = True
if type(num1) != int:
return "Invalid"
if type(num2) != int:
return "Invalid"
if num1 == num2:
... |
468a31c913d5c3b4d4f779588f6dc0dfa7d41ca6 | feigaoxyz/gist-collection | /gui/tk/grid.py | 1,453 | 3.5625 | 4 | # http://www.tkdocs.com/tutorial/grid.html
from tkinter import *
from tkinter import ttk
root = Tk()
content = ttk.Frame(root, padding=(3, 3, 12, 12))
frame = ttk.Frame(content, borderwidth=5, relief='sunken', width=200, height=100)
namelbl = ttk.Label(content, text='Name')
name = ttk.Entry(content)
one_var = Boole... |
d2538aeba269de5cf6cbeffba063d3d00d436c67 | Strigina/Pyladies | /ukol20.py | 236 | 4 | 4 | while True:
is_even = input("Napiš mi číslo: ")
if (is_even == "konec"):
break
elif (int(is_even) % 2) == 0:
print ("Číslo je sudé")
elif(int(is_even) % 2) != 0:
print ("Číslo je liché")
|
b31ed47000da92358f19843293339a38d6fed65a | abhishekzambre/Python_Programs | /EPI/enumerate.py | 72 | 3.609375 | 4 | l = ["a","b","c"]
for item in enumerate(l):
print(item)
print(l[2]) |
e4107f706ea375929c5fd380be2478bf7d1f8315 | Yashasvii/Project-Euler-Solutions-hackerrank | /forHackerRank/002.py | 386 | 3.984375 | 4 | """
Project Euler Problem 2
=======================
"""
def fibonacci_sum(n):
i = 1
j = 2
sum = 0
while i < n:
temp = i
if i % 2 == 0:
sum += i
i = j
j = j + temp
return sum
if __name__ == '__main__':
t = int(input().strip())
for a0 in range(t):... |
1f7d16535fb0ba393c75a5f971faf2e67a9346a3 | icanttakeitanymore/python_study | /random_ip.py | 2,386 | 3.5625 | 4 | #!/usr/bin/env python3
import random
class GetAddress:
"""Класс генерации экземпляра адреса и перезагрузки оператора вывода. Аргументы a,b,c,d - октеты адреса"""
def __init__(self,a,b,c,d):
self.a = a
self.b = b
self.c = c
self.d = d
def __str__(self):
return '{0}.{... |
218927ec69fffa2373ab50442467fd72c55b8184 | Evoniuk/Fractals-with-Turtle | /Turtle.py | 1,889 | 4.03125 | 4 | """
These programs use the turtle to draw images by transformation rules
"""
import turtle
turtle.speed(0)
turtle.delay(0)
turtle.hideturtle()
def drawCell(c, size): # draws a cell
colorMap = {0: 'blue', 1: 'yellow', 2: 'orange', 3: 'red'}
turtle.color('black', colorMap[c])
turtle.begin_fill()
for i ... |
f9bf99b34b505dbb1c46ebb8192337e42f5ffb6f | charliedavidhoward/Learn-Python | /whatsTheWeather.py | 1,593 | 4.09375 | 4 | # Create a program that pulls data from OpenWeatherMap.org that prints out information about the current weather, such as the high, the low, and the amount of rain for wherever you live. Depending on how skilled you are, you can actually do some neat stuff with this project.
#
# Subgoals
#
# Print out data for the ... |
242bf3e84a72080ee7d37f0144c0da49bb36105a | telandis/pythonexercises | /reversing_coins_solution.py | 278 | 3.796875 | 4 | def reversing_coins_solution(coins):
# write your solution here
headsCount = 0
tailsCount = 0
for x in coins:
if x == 0:
headsCount += 1
else:
tailsCount += 1
return headsCount if headsCount < tailsCount else tailsCount
|
197a7039459df5fb04c54bfef2a52738e946c069 | younes38/Daily-Coding-Problem | /vmware_problems/problem_1.py | 1,070 | 4.25 | 4 | """This problem was asked by VMware.
The skyline of a city is composed of several buildings of various widths and heights,
possibly overlapping one another when viewed from a distance. We can represent the
buildings using an array of (left, right, height) tuples, which tell us where on an
imaginary x-axis a buildin... |
2eca1dcf36fe10fbb2d67337c1a477155e523d23 | lordpews/python-practice | /osmoduleex.py | 1,720 | 4.1875 | 4 | import os
# print(dir(os))
print(os.getcwd()) # shows the current directory
# example if you want to open a file as f= open("file.txt")
# and you do not provide the exact location it ll check the requested file in your current directory ie the directory
# where program is currently located that's what 'os.cwd()' w... |
79ac58b430fcaa57eaf7373b33987c57a2fb74ae | Nikkuniku/AtcoderProgramming | /ABC/ABC100~ABC199/ABC171/C.py | 613 | 3.671875 | 4 | n=int(input())
# alp='abcdefghijklmnopqrstuvwxyz'
# ########関数部分##############
# def Base_10_to_n(X, n):
# if (int(X/n)):
# return Base_10_to_n(int(X/n), n)+' '+str(X%n)
# return str(X%n)
# ############################
# l=list(Base_10_to_n(n,26).split())
# print(l)
# ans=''
# for i in range(len(l)):... |
292441006158605b32e02d5f14e18257ad62e8f5 | jakubfolta/CodecademyPython | /lesson11.py | 6,235 | 3.984375 | 4 | #Class syntax
class Animal():
pass
#Classier Classes
class Animal():
def __init__(self):
pass
#Let's not get too selfish
class Animal():
def __init__(self, name):
self.name = name
#Instantiating Your First Object
class Animal():
def __init__(self, name):
self.name = name
zebr... |
d4b86d091af13f3d6d5afdf0370a5705cfa77835 | zenmeder/leetcode | /492.py | 371 | 3.5625 | 4 | #!/usr/local/bin/ python3
# -*- coding:utf-8 -*-
# __author__ = "zenmeder"
from math import sqrt,ceil
class Solution(object):
def constructRectangle(self, area):
"""
:type area: int
:rtype: List[int]
"""
l = int(ceil(sqrt(area)))
while l < area:
if not area % l:
return [l, area//l]
l += 1
retur... |
0abe0aa355a00875b66cf982631b91231c6c5a11 | MahanthMohan/Python-Programs | /SolveMatrix.py | 1,236 | 4.125 | 4 | import numpy as np
print("*** A solver for the systems of equations Ax + By = C ***")
R = int(input("Enter the number of rows: "))
C = int(input("Enter the number of columns: "))
print("Enter the entries in a single line for the A matrix, rowwise , and spaced out using commas ")
# single line separated by space
... |
8a06e45c15c1c30c065a32dd288bac9ae12d8936 | TheTurtle3/Python-Mega-Course | /Section 2 - Getting Started/basics.py | 134 | 3.65625 | 4 | day_hours = 24
week_days = 7
week_hours = week_days * day_hours
print(week_hours)
user_input = input("Testing: ")
print(user_input) |
d586b18214e53d8044ddd031b0ca49140a89b6c7 | abilkht/attendance-bot | /code.py | 644 | 3.65625 | 4 | def miniproject(filename):
f = open(filename, 'r')
Bluelist = []
List = []
for line in f.readlines():
List.extend(line.split())
for c in List:
if c not in Bluelist:
Bluelist.append(c)
return Bluelist
d = miniproject("database.txt")
def data(filename):
f = open(filename, 'r')
List = []
Bluelist = []
... |
3198ea7524858e62a5618c77d73c81fce4568bf2 | as1k/webdev-labs | /week8/codingbat/8_list2/1.py | 95 | 3.65625 | 4 | def count_evens(nums):
cnt = 0
for n in nums:
if n % 2 == 0:
cnt+=1
return cnt
|
6abce29aaa6e8c8c475fc3f00367b08b0479ce4a | LizinczykKarolina/Python | /Regex/ex10.py | 224 | 4.375 | 4 | #12. Write a Python program that matches a word containing 'z'.
import re
my_string = "My owlz likes me and is now zzz."
p = (re.search(r'\w*z.', my_string))
if p:
print "found a match!"
else:
print "Not matched!" |
65eba48c9fdf51d6d80b4b3921d4044e2cd48c3a | igortereshchenko/amis_python | /km72/Zinchuk_Kostyantin/5/task3.py | 268 | 3.765625 | 4 | _list=(input("enter list : ")).split()
_list2=[]
for i in range(len(_list)):
for j in range(len(_list)):
if (_list[i] == _list[j]) and (i != j):
break
else:
_list2.append(_list[i])
print(' '.join([str(i) for i in _list2]))
|
737eeca8f927f982ad47a0bdb4b5390afd19e12f | JacksonJLam/python | /3.1/HoP9.py | 517 | 4.03125 | 4 | #HoP9.py
#Jackson Lambert 1-4-19
#calculates easter date
def main() :
print("This script will find the date of easter in a given year")
year = int(input("Enter a year: "))
if year >=1982 and year <=2048 :
a = year % 19
b = year % 4
c = year % 7
d = (19 * a + 24) %... |
8a41441beb3b53d81241bdd569ab73156dc6df52 | amber1406/leecode | /link/reverseList.py | 847 | 3.96875 | 4 | # Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def reverseList(self, head: ListNode) -> ListNode:
if not head or not head.next:
return head
# #迭代
# cur=head
# nexts=head.next
... |
af7b7f87e7c9d20cb3cfb0ec84ca7b90a839b8cf | aman0864/CWH_1-Python3 | /tutorial 26.py | 948 | 4.34375 | 4 | # Date 18-3-2021
file1 = open("tutorial 26.txt", "r")
content = file1.read()
print(content)
file1.close()
# Note: Do not forget to close a file, it is very important to close a file after it's use is finished
# The upper syntax will help you to read and print a file
print(10*"\n")
file1 = open("tutorial 2... |
8f4cb28d276575e1122521990bac85e11f7b786c | gnikesh/project-euler | /problem26.py | 1,578 | 4.03125 | 4 | '''
A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with
denominators 2 to 10 are given:
1/2 = 0.5
1/3 = 0.(3)
1/4 = 0.25
1/5 = 0.2
1/6 = 0.1(6)
1/7 = 0.(142857)
1/8 = 0.125
1/9 = 0.(1)
1/10 = 0.1
Where 0.1(6) means 0.166666..., and has a 1-digit recurring cycle... |
b1f3efc88845b399ceb068625f7c6902ccefc009 | dgore7/project-euler | /largest_prime_factor.py | 408 | 4 | 4 | # Problem 3
import math
def largest_prime_factor(number):
largest_prime = 2
while number % 2 == 0:
number = number // 2
for i in range(3, int(math.sqrt(number)), 2):
if number % i == 0:
largest_prime = i
while number % i == 0:
number //= i
return... |
e1325cd61cd8cba7e26623927cc67159e03b963b | RuslanMakeev/python_automation | /Functions/func_return.py | 561 | 4.28125 | 4 | def maximum(x, y):
if x > y:
return x
elif x == y:
return 'Числа равны.'
else:
return y
print(maximum(2, 3))
'''Функция maximum возвращает максимальный из двух параметров, которые в данном случае передаются ей при вызове.
Она использует обычный условный оператор if..else для определ... |
95d7b8d59bc14b48c5b275176d71dde892d7135a | cpe202spring2019/lab1-JillianQuinn | /location_tests.py | 1,885 | 3.796875 | 4 | import unittest
from location import *
class TestLab1(unittest.TestCase):
def test_repr(self):
loc = Location("SLO", 35.3, -120.7)
"""Test the string representation format"""
self.assertEqual(repr(loc), "Location('SLO', 35.3, -120.7)")
"""Whole number check."""
loc = Loca... |
479c7d3e5f82fb135b5dc6fdb440c8d968358c59 | Arjun-Pythonista/Python_Scripts-Arjun | /Palindrome.py | 456 | 4.3125 | 4 | # 1) Palindrome
# TASK 1: By-Arjun
# Enter a string to check if it is palindrome using a function.
# Write a function that takes string as input and returns if that string is palindrome or not
print ("What is the word you would like to check?")
def isPalindrome():
word1 = input ('>')
word2 = word1[::-1]
i... |
48ac2a863dfab9c737d6d7838b0e23074de9cb93 | flipthedog/CS4341 | /Homework_1/ex1.py | 4,150 | 3.75 | 4 | # Floris van Rossum
# CS4341 - Homework 1
# Professor Carlo Pinciroli
# Exercise 1
# ex1.py
class ConnectFour:
"""Connect four game"""
def __init__(self, board, w, h):
"""Class constructor"""
# Board data
self.board = board
# Board width
self.w = w
# Board heigh... |
605bfc32eef2e9134d3aa5e1facd6859fad3a189 | vporta/python-calculator | /HW03-VincentPorta.py | 12,758 | 3.90625 | 4 | """ Created on Monday Sept 19 2017
@author: Vincent Porta
Special Topics, Homework 03
Implement a class for fractions that supports addition, subtraction,
multiplication, division, <, <=, !=, ==, >, and >=.
"""
import unittest
class Fraction:
""" A Fraction class calculator that prompts t... |
8198a94c5b7747d03f956884562d793bdccf0d45 | Knighthawk-Leo/CODE-CHEF | /COOK-OFF/WhichDivision.py | 198 | 3.578125 | 4 | # cook your code here
t=int(input())
for x in range (t):
r=int(input())
if(r<1600):
print('3')
elif(1600<=r and r<2000):
print('2')
elif(r>=2000):
print('1')
|
f6d73921fd19cc540a90eaca4e2704f7c5162122 | ioannischristou/popt4jlib | /testdata/cluster_data/random_weights_vector_maker.py | 401 | 3.5 | 4 | if __name__ == '__main__':
import random
n = int(input('Enter # non-negative random numbers to generate:'))
maxw = float(input('Enter maximum (positive) weight value:'))
fname = input('Enter filename to write numbers onto:')
f = open(fname, 'w')
for i in range(n):
r = random.random()*maxw
if... |
b4cfa464e288babfc82bac07e3c653ef2cd968ec | jingweiwu26/Practice_code | /141. Linked List Cycle.py | 740 | 3.640625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Dec 22 18:34:23 2017
@author: Wu Jingwei
"""
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def hasCycle(self, head):
"""
... |
9156a3f1d99983584f71ee0648f5d9293fc0ac7c | SWB-Dev/PracticePython.org-Exercises | /Exercise9.py | 797 | 3.953125 | 4 | #Exercise 9 - Guessing Game One
#PracticePython.org
from random import randint
def get_user_guess():
guess = int(input("Pick a number between 1 and 9. "))
if guess not in range(1,10):
print("Number was not a valid guess. Please try again. ")
get_user_guess()
return guess
numToGuess = randint(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.