blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
2ba6d3aafe82ec0849b2f021387affbfd54a6394 | rafaelperazzo/programacao-web | /moodledata/vpl_data/132/usersdata/191/41339/submittedfiles/al14.py | 125 | 3.8125 | 4 | # -*- coding: utf-8 -*-
n=int(input('digite a :'))
soma=0
for i in range (1,n+1,1):
z=int(input('digite a idade:'))
|
6f190897fb1b94acf1e049b7a8bc874757f21e90 | henrypj/HackerRank | /Implementation/FairRations.py | 3,053 | 3.796875 | 4 | #!/bin/python3
import sys
"""
# Description
# Difficulty: Easy
#
# You are the benevolent ruler of Rankhacker Castle, and today you're distributing
# bread to a straight line of N subjects. Each i'th subject (where 1 <= i <= N)
# already has B(i) loaves of bread.
#
# Times are hard and your castle's food stocks are d... |
e3dae8934fef394c17282ef2a2bcbfc3709a5877 | tank7575/100_days_of_Python | /day_9.py | 613 | 4.125 | 4 | from array import *
array_num = array('i', [1, 3, 5, 7, 9])
for i in array_num:
print(i)
print('Access first three individualls')
print(array_num[0])
print(array_num[1])
print(array_num[2])
print('starting array ', array_num)
array_num.append(11)
print('new array: ', array_num)
print(array_num[:: -1]... |
44f87de3cf359b732f247776eb0dcbda9e2a6507 | jayasree1116/code_for_network | /python/while_sum.py | 115 | 3.578125 | 4 | list=[10,20,30,40,50]
sum=0
i=0
while(i<len(list)):
print(list[i])
sum+=list[i]
i+=1
print("sum=",sum) |
63809a59f8b5f6473655c992078e2dfd0376cf24 | govkartha/Python-programs | /perfectpeak.py | 751 | 3.5625 | 4 | #Perfect Peak of an Array - interviewbit
#https://www.interviewbit.com/problems/perfect-peak-of-array/
'''Given an integer array A of size N.
You need to check that whether there exist
a element which is strictly greater than all the elements on left of it and strictly smaller than all the elements on right of it.... |
e4df68dc4b95962220de7c7e79b607c476f19895 | chenderson13/studymachine | /timertest.py | 1,236 | 3.921875 | 4 | def main():
print ("\nThis timer is a great way to get started."
"It's a way to dip your toe in knowing that you've only committed to working for a small amount of time and are 'allowed' to stop afterward.",
"\n\nSet the timer for the shortest amount of time you *know* you can work continuously. Even three minutes... |
041edd5c69f58323cdf414a4cf1fda1cc91c6f13 | eman19-meet/YL1-201718 | /my_project/agario.py | 4,682 | 3.734375 | 4 | import time
import random
import turtle
import math
from ball import Ball
turtle.tracer(0)
turtle.hideturtle()
RUNNING=True
SLEEP=0.0077
SCREEN_WIDTH=turtle.getcanvas().winfo_width()/2
SCREEN_HEIGHT=turtle.getcanvas().winfo_height()/2
turtle.speed(5)
#PART 0 : CREATING THE BALLS
MY_BALL=Ball(400,400,50,30,30,"yello... |
c46e005e435ad29ac6e4908afc0ebbf13ecffbf1 | norbchaar/Python2020entrega | /practica2_ejercicio9.py | 977 | 4.15625 | 4 | # This is a Guess the Number game.
import random
def hint(guess, number, guesses_taken):
if guess != number and guesses_taken == 3:
if number % 2 == 0:
print('Hint: The number is even.')
else:
print('Hint: The number is odd.')
guesses_taken = 0
print('Hello! Wha... |
84e47b2e3af1fb021a9a212003ab5ed5c8b71e92 | AjayKrish24/Assessment | /Python Practice/Assignment -1 Class_and_Objects.py | 684 | 3.671875 | 4 | import math
class point:
count = 0
def __new__(cls, *args, **kwargs):
cls.count += 1
if(cls.count>5):
raise TypeError("More than 5 objects are created")
else:
return object.__new__(cls)
def __init__(self,a=0,b=0):
self.x=a
self.y=b
... |
2aedf94574216ae3ef11dacb2efbeb3b9f44ba29 | jin349/Algorithm | /July14/test02.py | 2,604 | 3.90625 | 4 | # 슬라이싱
a = [10, 100, ['pen', 'banana', 'orange']]
print(a[0:2]) # 0번째부터 1번째(2는 포함 안됨) 인덱스까지 출력
print(a[2][0:2]) # 2번 인덱스에서 0번째부터 1번째까지 값 출력
print(a[:-1]) # a의 마지막 인덱스 출력
print(a[-1])
a[1:2] = [1001, 10001, 100001] # a의 1번에 값 추가
print(a)
del a[-1] # 해당 인덱스의 값을 지움
print(a)
a.reverse() # 역방향으로 정렬
print... |
ec37c53dcf2cd5768d3dfd75f812260edf5479bc | nchpmn/logbook | /newTrip.py | 3,199 | 3.90625 | 4 | # Get data for new trip and save to file
import time
import fileHandling
def data():
"""Enter and Save a new trip into the logbook!"""
print \
"""
\n\n\n\n\n\n
+--------------------+
----------------------------| ADD NEW TRIP |------------------------------
... |
8a476fa9f2614a34cdc263833eb2834eedacb39f | GeorgyZhou/Leetcode-Problem | /lc35.py | 854 | 3.796875 | 4 | class Solution(object):
def searchInsert(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: int
"""
if not nums:
return 0
n = len(nums)
left, right = 0, n - 1
while left <= right:
mid = left + (righ... |
436bb1cf48b76b3eb07553e35d341467a15ec844 | velvetarchangel/algorithm_problems | /supercomputer.py | 3,410 | 3.65625 | 4 | class Node(object):
def __init__(self, start, end):
self.start = start
self.end = end
self.total = 0
self.left = None
self.right = None
class NumArray(object):
def __init__(self,arr):
self.arr = arr
#initialize data structure
def createT... |
2b7eb9e7af6bc8facac8607e52adbe140058d5b3 | emmanavarro/holbertonschool-higher_level_programming | /0x0C-python-almost_a_circle/models/square.py | 1,316 | 3.703125 | 4 | #!/usr/bin/python3
"""Square module"""
from models.rectangle import Rectangle
class Square(Rectangle):
"""Square class that inherits from Rectangle"""
def __init__(self, size, x=0, y=0, id=None):
"""Constructor that initialize a Square"""
super().__init__(size, size, x, y, id)
def __s... |
9719c451c2c090e8def620135679dae59a59bac4 | pyaillet/Aoc2020 | /10/puzzle2.py | 1,483 | 3.734375 | 4 | #!/usr/bin/env python3
inp = 'input.txt'
from itertools import chain, combinations
def powerset(iterable):
"""
powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)
"""
xs = list(iterable)
# note we return an iterator rather than a list
return chain.from_iterable(combinations(xs,n... |
c9ba74fc021aefae20862974b0ac44f0ba399a04 | crhntr/IAA-Code | /Problems/7.6/Solution-1/csanky.py | 3,735 | 3.671875 | 4 | # Introduction to the Analysis of Algorithms (3rd ed)
# Michael Soltys
## Problem 7.6 - Csanky with matrix operations
## Ryan McIntyre
## 8/25/2017
## python 3.5.2
from numpy import matrix, identity, concatenate
from fractions import Fraction as frac
import sys
#-------------------------------------------------------... |
638d9afeac65628f8bcf41dfd59199f3a5a4c439 | xCiaraG/Kattis | /marswindow.py | 94 | 3.71875 | 4 | year = int(input())
if (((year - 2018) * 12) + 8) % 26 < 12:
print("yes")
else:
print("no") |
6b575eb121b0bd19c548f4f5f15b523f5855fe4e | reder66/Machine-Learning-Practice | /tree/test/test_tree.py | 1,185 | 3.59375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Dec 1 12:10:43 2018
@author: Administrator
"""
import numpy as np
from tree.CART import CART
from tree.DecisionTreeClassifier import DecisionTree
import pandas as pd
from sklearn.model_selection import train_test_split
'''
Because our data is continuous, so we only use all... |
db79a689b5333f9b394d7517826353378d325c0d | hivictording/s141 | /day8/test.py | 181 | 3.546875 | 4 | # Author: Victor Ding
# -*- coding: utf-8 -*-
string1 = ['aaa',' ']
for s in string1:
# if s.strip():
# print('A')
# else:
# print('B')
print(s.strip())
|
26d1615f8984f9ec59824606dc3d951d714b9ee5 | Barkha13/python | /names.py | 1,146 | 3.5 | 4 | students = [
{'first_name': 'Michael', 'last_name' : 'Jordan'},
{'first_name' : 'John', 'last_name' : 'Rosales'},
{'first_name' : 'Mark', 'last_name' : 'Guillen'},
{'first_name' : 'KB', 'last_name' : 'Tonel'}
]
for i in students:
print i["first_name"],
print i["last_name"]
# for value ... |
b75f5219b092e837b2f4dfd19691c35c73b21f75 | Yobretaw/AlgorithmProblems | /Py_leetcode/224_basic_calculator.py | 1,805 | 4.34375 | 4 | import re
"""
Implement a basic calculator to evaluate a simple expression string.
The expression string may contain open ( and closing parentheses ), the plus
+ or minus sign -, non-negative integers and empty spaces.
You may assume that the given expression is always valid.
Some examples:
... |
083fca00bb027dbfa3f8cd5dfbaf4a3e07f355ab | yogii1981/Fullspeedpythoneducative1 | /Freecodecamp_Dataanalysiswithpython/Data_Analysis_ExampleB.py | 853 | 3.578125 | 4 | import numpy as np
import pandas as pd
import matplotlib as plt
sales = pd.read_csv(
'/Users/yogeshsharma/Documents/Freecodecamp_datanalysiswithpython/sales_data.csv') # import and read the file located in a specific folder
# print(sales) #display the csv files
## Column Wrangling##
print('Sales[Revenue_p... |
c30a258f0270acb0e9a53747db30f19a127a6f7a | joseeden/notes-cbt-nuggets-devasc | /Notes_10-19/14-Parsing_XML-Method_3.py | 1,117 | 3.875 | 4 |
#******************************************************************************************************************#
# 14-Parsing_XML-Method_3
#******************************************************************************************************************#
# 2021-01-08 01:36:31
# This is the 3rd of the 3 codes ... |
29af61f750e030418011a94822c02b86ba402c50 | xababafr/Python-MPSI | /TD 3/exo5.py | 1,899 | 3.6875 | 4 | # les fonctions dont on a besoin :
# une fonction qui inverse une liste sans utiliser reverse()
def inverse(liste):
length = len(liste)
R = []
for j in range(length):
R.append('')
# on parcours la liste en sens normal
for i in range(length):
# on rempli la liste a retourner d elements vides
R[(length-1)-i]... |
df55663de4e4133a4f6c6b1d3c3ae46025162173 | zxd1997/python | /strcpy.py | 526 | 3.625 | 4 | a=input()
b=input()
c=[]
d=[]
for i in range(len(a)):
c.append(a[i])
for i in range(len(b)):
c.append(b[i])
for i in range(len(c)):
print(c[i],end='')
print()
if len(a)!=len(b):
print("no")
else:
f=True
for i in range(len(a)):
if (a[i]!=b[i]):
f=False
print("no")
... |
fc6ce53576aa09f959c9d98c7b66d7ff5605366a | Divya0406/python-assignments | /grading set/q4.py | 2,259 | 4.15625 | 4 | '''problemset : Gradingset
Author : divya.natarajan
Date : 16/12/2017
Question :A website requires the users to input username and password to register. Write a program to check the validity of password input by users. Following are the criteria for checking the password:
At least 1 letter be... |
e3331fa01d65e897116663749e505c14ef94d1a8 | owenthewizard/blackjack | /cards.py | 2,532 | 3.84375 | 4 | """
This module contains definitions for Card and Deck, as well as enums
for Suit and Face. This allows for the creation and manipulation of
cards.
"""
from enum import IntEnum
from python_terminal_color import color as colors
def _nop(*args):
"""A simple nop, to be used as color=None"""
return args[0]
c... |
cd523458815ac155cb4cc9c40313bf05959f276f | dracula1789/extrema | /maxima.py | 658 | 4.3125 | 4 | # See README.md for documentation
def find_maxima(array):
"""Returns the positions of the local maximum values in the array
array.
Example:
find_maxima([]) → []
find_maxima([1, 2, 1]) → [1]
find_maxima([2, 0, 0, -2, 2]) → [0, 4]
"""
ans = []
N = len(array)
for i in range(N):
... |
a815445e94e0f3c53ff81483981301afc3309c2c | Mahantesh856/Python-Set2 | /35.py | 511 | 3.875 | 4 | tup1=('mon','tue','wed','thur','fri','sat')
print tup1
tup2=('jan','feb','mar','apr','may','june','july','aug','sep','oct','nov','dec')
print tup2
concat=tup1+tup2
print concat
t1=(1,2,3,4,5,6)
t2=(5,7,8,9)
t3=(1,2,3,4,5,6,7,8)
if(t1>t2 and t1>t3):
print "t1 is greater:",t1
elif(t2>t1 and t2>t3):
... |
a0aa36c5bbfd6e3dd41ba2604f17672310129ea2 | SuyashLohia/Practice | /LeetCode/Algorithms/73_Set Matrix Zeroes.py | 2,393 | 3.796875 | 4 | class Solution(object):
def setZeroes(self, matrix):
"""
:type matrix: List[List[int]]
:rtype: None Do not return anything, modify matrix in-place instead.
"""
MODIFIED = -1000000
R = len(matrix)
C = len(matrix[0])
for r in range(R):
for c ... |
85c3ebbc06510ab4362c7052d196d340ba9f76dc | Stl36/python-base-gb | /lesson_1/task3.py | 102 | 3.796875 | 4 | number = input("Введите число\n")
print((int(number * 3) + int(number * 2) + int(number))) |
eb36a8209877f360a60e7b52c45cf2708b9d0b48 | xjt617/gf | /second/zip.py | 954 | 3.6875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import zipfile
def get_zip_file(input_path, result):
files = os.listdir(input_path)
for file in files:
if os.path.isdir(input_path + '/' + file):
get_zip_file(input_path + '/' + file, result)
else:
res... |
5d1efd5f8e10e714285d40a6bf85235e38a55332 | xjuric29/isj | /projects/isj5/isj_proj05_xjuric29.py | 6,935 | 3.71875 | 4 | #!/usr/bin/env python3
import re, collections
class Polynomial:
"""Class for polynomial objects"""
def __new__ (cls, *argv, **kwargs): # Arguments verification
"""This method verify arguments, if arguments are bad, new instance will not create"""
self = super().__new__(cls)
makeFlag = 0
if len (argv) ==... |
829513516a5ef4b241d54b6bec525bc92c905729 | ilaydaakbulut/PythonLearningProject | /fonksiyonlar.py | 506 | 3.71875 | 4 | def merhaba():
print("merhaba dünya")
def factoriel(numara):
faktoriyel=1
for i in range(1,numara+1):
faktoriyel*=i
return faktoriyel
def kokbul(a,b,c):
delta=(b*b-4*a*c)
if(delta<0):
print("reel kök bulunamadı")
return
x1=(-b-delta**0.5)/(2*a)
x2=(-b+delta**0.5)/... |
0956ba952a171a1d873c39c17f96f5c88b093663 | seveneightn9ne/language-identifier | /question.py | 889 | 3.828125 | 4 | class Question(object):
def __init__(self, question="", choices=None):
"""
question is question text e.g. "Are there parens?"
choices is a dict e.g. {
'yes': "Yes.",
'no': "Yes.",
}
"""
self.question = question
self.choices = choices o... |
514b76e45043c1061fddfb192d637b84a4ff6bef | kevinelong/PM_2015_SUMMER | /wk04/dictionaires_vs_classes.py | 785 | 4.25 | 4 | # To facilitate a discussion on using dictionaries vs classes to represent the
# attributes on an object
# Using a class
class Person(object):
def __init__(self, name=None, age=None, height=None):
self.name = name
self.age = age
self.height = height # in inches
person = Person(name='Rein... |
1fdb909543144c973642c45940f04a0afb5e665a | chungnguyen10012000/-Python | /Text Wrap.py | 273 | 3.859375 | 4 | import textwrap
def wrap(string, max_width):
_string = textwrap.wrap(string,max_width) #creare list
_string = "\n".join(_string) # conver list to string
return _string
if __name__ == '__main__':
result = wrap("A B C D E F G H I K L M",3)
print(result) |
a7bab3898da69068e4e6ddae799317f606499e1a | Gaya1858/DataScience-Python | /workingwithNumpyPandas-process-clean-analysis-visu/matplotlib_viz.py | 510 | 3.90625 | 4 | import pandas as pd
from matplotlib import pyplot as plt
dt =pd.read_csv("Data/csv_data.csv",
names= ["ID","NAME","PRICE","SALES","BRAND"], # you can change the names of the columns using names param
skiprows=1) # this will skip the row from beginning. in this case we aare removing the ... |
650541501b5bad4454f5f5e91b67299c6c0b8afa | avatar80/study | /HARDWAY/ex12.py | 305 | 3.53125 | 4 | # _*_ coding:utf-8 _*_
age = input("몇 살이죠?")
height = input("키는 얼마죠?")
weight = input("몸무게는 얼마죠?")
print("네, 나이는 %r살, 키는 %r, 몸무게는 %r 이네요."%(age,height,weight))
print("뜬금없지만, 태양의 각지름은 %r 정도입니다."%'''32'10"''')
|
9c4637d30306c60fabdc41f3ba814a8079576e49 | zizu1985/100daysOfCoding_Python | /day7/exercise_5_16_5.py | 368 | 3.578125 | 4 |
def allEvens(lst):
n = []
for i in lst:
if i % 2 == 0:
n.append(i)
return n
def main():
l = [1, 2, 3, 4, 32, 23, 23, 43]
print(l)
print(allEvens(l))
l = []
print(l)
print(allEvens(l))
l = [934,23, 34 ,23 ,33,44,99,101, 204, 2034]
print(l)
print(allE... |
b570e812dc8c6deddbe335b9241c368158676905 | BornRiot/Python.Udemy.Complete_Python_BootCamp | /methods_and_functions/scribbles/test_while.py | 190 | 3.859375 | 4 | the_count = 0
the_list = []
while the_count < 10:
the_list.append(the_count+1)
the_count += 1
print(the_list)
some_list = []
the_num = 5
some_list.append(the_num)
print(some_list)
|
3a4b2d117ea25e717014c38d16328bc10cedf98f | Drareeg/NeemVijfServer | /game.py | 1,716 | 3.5 | 4 | __author__ = 'Drareeg'
import logging
import random
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG)
# the abstract object representing the game
class Game:
def __init__(self):
self.players = ()
self.started = False
self.turns = 10
self.current_turn = ... |
8905c07cb50982afa89231940fc3518d642d6c10 | jamtot/LearnPythonTheHardWay | /ex45/kitchen.py | 6,504 | 3.828125 | 4 | from room import Room
from livingRoom import LivingRoom
from hall import Hall
class Kitchen(Room):
fredHidden = False
def __init__(self):
self.checkedBowl = False
#self.lRoomInst = LivingRoom()
def enter(self):
Hall.fredFell = True
print "LOCATION: KITCHEN"
... |
196e034aca9216a87615da09bfe39efa81027f62 | Innovation-tech-max/my_work2 | /Natural Language Processing/NLTK/NLTKQuestions/Homework3/c3e32.py | 527 | 3.515625 | 4 | #Course: CSCI 4140
#Name: Huan-Yun Chen
#Date: 2/6/2018
#Tabs: 8
import nltk
from nltk import word_tokenize
silly ='newly formed bland ideas are inexpressible in an infuriating way'
bland = silly.split(' ') #split silly
second ="" #store second words
space=' ' #represent space
for w in bland: #store s... |
34ba363996d315369e524f3878495b75054400de | samaxtech/web-scrapping | /web-scrapping-data.py | 2,520 | 3.71875 | 4 |
from bs4 import BeautifulSoup
response = requests.get('http://dataquestio.github.io/web-scraping-pages/simple.html')
content = response.content
# Initialize the parser, and pass in the content grabbed earlier.
parser = BeautifulSoup(content, 'html.parser')
# Get the body tag from the document by picking a branch of... |
69fdf7fd03025f9a7ef01bbd2ef8517c9040216d | ishakboufatah/cse-2021 | /pset1/a.py | 332 | 3.8125 | 4 | annual_salary= 120000
portion_saved= 0.1
total_cost = 1000000
portion_down_payment = 0.25
monthly_salary = annual_salary/12
current_savings = 0
r = 0.04
i=0
while current_savings<(total_cost*portion_down_payment):
current_savings = current_savings + (current_savings*r/12) + (monthly_salary*portion_saved)
i=i... |
b5316d6b6567ecc8f86a53d6c1619de38606ca81 | kriti-ixix/ait-fdp | /python/file handling.py | 832 | 3.859375 | 4 | '''
open(filename, mode)
r = read
r+ = read and write
w = write - overwrites an existing file
a = append - does not overwrite existing file
'''
filename = "Vacation.txt"
vacationPlaces = ["London", "Paris", "Los Angeles", "New York", "Tokyo"]
myFile = open(filename, 'w')
#myFile = open(r'\Volumes\Kriti-1\nacations.tx... |
35261ccb9c6db27ff6ddcc65cf433d60b99d1de6 | lsst-dm/meas_artifact | /python/lsst/meas/artifact/hough.py | 21,004 | 3.515625 | 4 | #!/usr/bin/env python
import copy
import time
import collections
import numpy as np
from scipy import ndimage as ndimg
import matplotlib.pyplot as plt
import satelliteUtils as satUtil
def hesseForm(thetaIn, x, y):
"""Convert theta, x, y to Hesse normal form
@param thetaIn Local position angle in radi... |
85e410852116014dbabd2c529afd23a568ae3a4f | krishnaroskin/cmdtools | /alignote | 1,027 | 3.515625 | 4 | #!/usr/bin/env python
import sys
import argparse
# program options
parser = argparse.ArgumentParser(description='Annotate two lines with the positions where they are the same')
parser.add_argument('--case-sensitive', '-s', action='store_true',
help='characters must have the same case to be called equal')
arg... |
21a9d1164b4ba8908f44f47fe68f7dc1c0bb1a9b | notgrin/algorithm-base | /lesson1/task1.py | 502 | 4.1875 | 4 | # 1. Найти сумму и произведение цифр трехзначного числа, которое вводит пользователь.
print('START')
num = int(input('Введите трехзначное положительное число: '))
a = num // 100
b = num % 100 // 10
c = num % 10
print(f'Сумма цифр числа {num} равняется: ', a + b + c)
print(f'Произведение цифр числа {num} равняется: ', ... |
0b3ef956a13c7d084765838a8e99265e6183c134 | erickmiller/AutomatousSourceCode | /AutonomousSourceCode/data/raw/squareroot/9ea7bf8c-0b02-4330-ad49-f3c2d7a532b4__problem1.py | 747 | 4.03125 | 4 | '''
Problem:
Given a positive integer n, determine whether it is prime using trial
division by all primes not exceeding its square root.
Constraints:
n - must be a positive integer
'''
def problem(n):
if (n < 1):
raise ValueError("n must be a positive integer")
elif (n == 1):
return True
elif (n =... |
cea8609dbef80a817afc4da70604db0e354470e9 | vit-aborigen/CIO_woplugin | /The-Ship-Teams.py | 818 | 3.640625 | 4 | def two_teams(sailors):
team_one = sorted([sailor for sailor in sailors if 20 <= sailors[sailor] <= 40])
team_two = sorted([sailor for sailor in sailors.keys() if sailor not in team_one])
return [team_two, team_one]
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necess... |
9d4704f6267eedd4bb3d74e932b53b2f38122a2d | alex-rantos/python-practice | /problems_solving/subsequence.py | 1,808 | 3.671875 | 4 | """
Given a string s and a string t, check if s is subsequence of t.
A subsequence of a string is a new string which is formed from the original string by deleting some (can be none)
of the characters without disturbing the relative positions of the remaining characters. (ie, "ace" is a subsequence of "abcde" while "... |
3cfbdc5b862e47ec6ad57ff84caa2aaf167c6681 | Stl36/python-base-gb | /lesson_2/task4.py | 523 | 4.15625 | 4 | """
Пользователь вводит строку из нескольких слов, разделённых пробелами.
Вывести каждое слово с новой строки. Строки необходимо пронумеровать.
Если в слово длинное, выводить только первые 10 букв в слове.
"""
words = input("Введите через пробел слова\n").split()
for id, item in enumerate(words):
print(f"{id + 1}... |
4bba79699fba0a09fdc5e9029df27635f6cf2268 | sowmyamanojna/BT3051-Data-Structures-and-Algorithms | /lab_session/pythogorean_triplets.py | 291 | 3.859375 | 4 | def phyth(n):
vals = [(i, j, k) for i in range(1, n+1) for j in range(i, n+1) for k in range(j, n+1) if i**2 + j**2 == k**2 ]
print (vals)
return vals
resp = 'y'
while True:
n = int(input("Enter the number: "))
vals = phyth(n)
resp = input("Conti? (y/n): ")
if resp == 'n':
break
|
ebfd4fea9ab64f735261a1c99359d8912eae534a | mdoradocode/REST-APIs-with-Flask-and-Python | /Python Refresher/ListComprehension.py | 332 | 3.90625 | 4 | numbers = [1,3,5]
doubled = [x * 2 for x in numbers]
print(doubled)
friends = ["Rolf", "Sam", "Samantha", "Saurabh", "Jen"]
starts_s = [friend for friend in friends if friend.startswith("S")]
print(starts_s)
##This copys values if the string starts with the correct values
print(id(friends))
##gives the memory location... |
4f8e75ee14d47c7bbf6e20452a59655e73070ece | subicWang/leetcode_aotang | /865_smallest_subtree_with_all_the_deepest_Nodes.py | 1,993 | 3.921875 | 4 | # -*- coding: utf-8 -*-
"""
Aouther: Subic
Time: 2019/8/29: 14:57
"""
from tools.binarytree import BinaryTree, draw
class Solution(object):
def __init__(self):
pass
def subtreeWithAllDeepest(self, root):
# 返回所有子树和其根节点的深度
def sub(root):
if root is None or root.value is None... |
11edb0b8970d9722ad05f5aacff3e5a2c6852791 | iptcs/cs109-demos | /Isaac_Taylor_Exercise5.py | 581 | 4.40625 | 4 | ##################################################
# AVERAGE NUMBERS, IGNORE STRINGS
#
# Assume we have a variable called stuff. In this variable,
# there is a list. The list contains numbers AND strings.
#
# Print the average of all of the numbers. Ignore the strings.
#
stuff = [2, "three", 4.5, -7, "dog", 3.14]
new_... |
9691c4a66b386fd4724b39396be9b0aed4e62977 | hasnaind/Project-Euler-Solutions | /largest_palindrome.py | 357 | 3.625 | 4 | def Largest_palindrome_product():
largestPalindrome=None
for i in range(999,99,-1):
for a in range(999,99,-1):
result=str(a*i)
if result==result[::-1]:
if largestPalindrome==None or int(result)>largestPalindrome:
largestPalindrome=int(re... |
687ea2f150915d4901368d90dd1eb777aee77179 | spadek67424/leetcode | /83. Remove Duplicates from Sorted List.py | 572 | 3.6875 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def deleteDuplicates(self, head: ListNode) -> ListNode:
check=set()
temp=head
output=head
while head!=None:
if head.val i... |
881c4d823c7eaa353b591b64e214bf854c4fd35e | brendon250891/phone_reviews_assignment | /sql_review.py | 6,057 | 3.5625 | 4 | import created_reviews as cr
TABLE_NAME = "review_summary"
OUTPUT_FILE = "sql_review_output.txt"
def create_review_summary_table():
""" Creates the review summary table. """
print("Creating table '{0}'...".format(TABLE_NAME))
cr.run_database_query("drop table if exists review_summary;")
cr.run_databa... |
280095970843d1dc4dc140fb3319b8450c7789f7 | adityakverma/Interview_Prepration | /Leetcode/Arrays/LC-457. Circlular Array Loop.py | 2,504 | 3.640625 | 4 |
class Solution(object):
def circularArrayLoop(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
def getIndex(i):
n = len(nums)
return (i + nums[i] + n ) % n
# start from every position in the array
for i, val in en... |
b8f453b2cf784699e626d729becd2cdc46b0551b | SauravJalui/data-structures-and-algorithms-in-python | /Binary Tree/binarytree.py | 1,843 | 4.03125 | 4 | from queue_linkedlist import LinkedQueue
class BinaryTree:
class Node:
__slots__ = "element", "left", "right"
def __init__(self, element, left = None, right = None):
self.element = element
self.left = left
self.right = right
def __init__(self):
... |
a5cb5b4fd73e8836b72b441b22d74692735c445a | tommy2006/hello-world | /dictionary positioner.py | 236 | 4.09375 | 4 | print "Enter your first word."
a = raw_input()
print "Enter your second word."
b = raw_input()
if a<b:
print a,"comes before",b,"and",b,"comes before",a,"."
elif a>b:
print a,"comes after",b,"and",b,"comes before",a,"."
|
1669b67541d354a65accca59f3ae9e42a447e1e1 | Sarahalq/KAUST-Project | /removing_stopwords.py | 619 | 3.578125 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 9 18:09:36 2017
@author: qabbaasa
"""
#%%
from nltk.corpus import stopwords
StopWords = stopwords.words('english')
data= '/home/qabbaasa/Documents/summer_project/data/' ##the path
inputfile = data+'medline_abstracts.txt'
outputfile = data+'prepro... |
8ef9510ad379e8b3d744921ccfde41ff784a7e8c | Toyfever/Game_PJT | /main.py | 1,636 | 4.0625 | 4 | player_settings = {
"HP": 100, "armor": 0, "attack": 0
}
spacesuit = {
"suit a": 40,
"suit b": 80,
"suit c": 120
}
weapon = {
"Classic Laser Blaster": 60,
"Destroyer of worlds": 150,
"the Cricket": 35
}
def main():
"""Game main frame."""
suit_reminder = f"C... |
10bc7408b98ee28cb4768fd3f574ef38fc52073b | 107318041ZhuGuanHan/TQC-Python-Practice | /_7_tuple_set_dictionary/702/main.py | 2,266 | 4.40625 | 4 | # ★因為tuple不能直接用sort function修改順序,所以需要先轉回list再用sort()
numbers_1 = []
numbers_2 = []
message = "請輸入整數: "
message += "\n(輸入'-9999'以離開程序)"
print("Create tuple1: ")
while True:
number = int(input(message))
if number == -9999:
break
numbers_1.append(number)
print("Create tuple2: ")
while True:
n... |
2c445bc3ed136fec8a6f2badb7eb2ece0e606684 | Gaborade/Alien-Invasion | /ship.py | 1,975 | 3.703125 | 4 | import pygame
ship_image = 'images/ship.bmp'
class Ship:
"""A class to manage the ship"""
def __init__(self, ai): # the other parameter is the alien invasion class
"""Initialise the ship and set its starting position"""
self.screen = ai.screen
self.settings = ai.settings
sel... |
08487a75e7b6e991233de69c3337f9c39434092d | gvg4991/TIL | /algorithm/coding_test/codility1.py | 1,691 | 4.09375 | 4 | # A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N.
#
# For example, number 9 has binary representation 1001 and contains a binary gap of length 2.
# The number 529 has binary representation 1000010001 and con... |
22e914129883dd6c6ff32b1319237071f90e88bf | glasscharlie/data-structures-and-algorithms | /challenges/PseudoQueue/queue_with_stacks.py | 1,240 | 3.953125 | 4 | class Node:
def __init__(self, value=None):
self.value = value
self.next = None
class Stack():
def __init__(self):
self.top = None
def push(self, item):
new_node = Node(item)
new_node.next = self.top
self.top = new_node
def pop(self):
current = sel... |
d90a04337c5ee794418cfa1f6e5fb129bbe039b1 | Frankiee/leetcode | /trie/208_implement_trie_prefix_tree.py | 2,064 | 4.15625 | 4 | # https://leetcode.com/problems/implement-trie-prefix-tree/
# 208. Implement Trie (Prefix Tree)
# History:
# Facebook
# 1.
# May 7, 2020
# Implement a trie with insert, search, and startsWith methods.
#
# Example:
#
# Trie trie = new Trie();
#
# trie.insert("apple");
# trie.search("apple"); // returns true
# trie.s... |
5cb452e7117e0707e651dfc2cb6ae1ead35923b4 | gaogaostone/Python_Learning | /001.MyFirstTest/oo.py | 483 | 3.625 | 4 | # coding=utf-8
# 类
class Hello:
# 构造方法
def __init__(self,name):
self._name=name
# 方法
def sayHello(self):
print("Hello {0}".format(self._name))
#继承
#继承自Hello
class Hi(Hello):
def __init__(self,name):
Hello.__init__(self,name)
def sayHi(self):
... |
882f0ec2de52a7510bb51bf115c62053e2dcfd4a | veeteeran/holbertonschool-higher_level_programming | /0x0C-python-almost_a_circle/models/base.py | 4,270 | 3.5 | 4 | #!/usr/bin/python3
"""Docstring for Base class"""
import json
import csv
class Base:
"""The Base class"""
__nb_objects = 0
def __init__(self, id=None):
"""
Init method for Base class
Parameter:
id: an id
"""
if id is None:
Base.__nb... |
45b435e1af6c4f348df9f748712bafb483304f7d | pooyasp/ctci | /11/evelenDotFive.py | 557 | 3.515625 | 4 | def find(l , s, start, end):
if end - start == 0:
if l[start] == s:
return start
else:
return None
mid = (start + end) / 2
if l[mid] == s:
return mid
index = mid
while l[index] == '' and index <= end:
index += 1
if l[index] == s:
return index
if l[index] == '':
return find(l, s, start, mi... |
b851d2c0bf41c71ff1e497289ee0bf2242670fbb | arkaris/gb_python_basic | /lesson1/task8.py | 300 | 3.734375 | 4 | year = int( input("Введите номер года: ") )
if year % 400 == 0:
isLeap = True
elif year % 100 == 0:
isLeap = False
else:
isLeap = year % 4 == 0
if isLeap:
print("Выбранный год високосный")
else:
print("Выбранный год не високосный") |
d762c0741fb2033859c01bff57befbf2805e25ab | baigarkalpana/Python_Numbers | /Problems_on_Numbers/divisible.py | 423 | 4.1875 | 4 | #program which contains one function that accept one number and returns true if divisible by 5 otherwise return false
#accepting number from user
num=int(input("enter number"))
#function defination to check wether number is divisible by 5 or not
def numdivisible(inum):
if(inum%5==0):
... |
33dc8b54e91a89c9dc0629f8d543a89ffef06f7d | VishalSharma2001/Python-Program | /functionargu.py | 1,155 | 3.8125 | 4 | '''
def update(x):
print(id(x))
x=8
print(id(x))
print("X=",x)
a=10
print(id(a))
update(a)
print("a=",a)
'''
'''
def update(li):
print(id(li))
li[1]=15
print(id(li))
print(li)
li=[10,30,20]
print(id(li))
update(li)
print(li)
'''
'''
def sum(... |
da179cf59ace759afe28d875f7c403dad65c5e22 | JuanPessanha/Python-Desafios | /Desafio 23.py | 836 | 3.71875 | 4 | num = input('Digite um número de 0 a 9999: ')
div_num = num.replace('', ' ').split()
comp_num = len(div_num)
if comp_num > 4:
print('O número {}, possui mais do que 4 digitos, favor inserir um número válido!!!'.format(num))
elif 1 == comp_num:
print('Unidade: {}'.format(div_num[0]))
elif 2 == comp_num:
prin... |
0c74a441c5eaf4da8cab96669277232167c1d2e1 | FabioFab/py100days | /11-15_Days.py | 11,954 | 4.28125 | 4 | # ###############################
# DAY11
# ###############################
# It creates a matrix of A x B size, where both A and B are given as input
input_size_matrix = input("Please enter 2 comma separated numbers to have an equal size matrix: ")
# I use the input numbers to create a list of 2 elements
size ... |
a8fcde00539228fa6faecb7caa21a08e7d624e10 | MoserMichael/pythoncourse | /04-calculator.py | 2,077 | 4.46875 | 4 | #import the sys module, that tells us that we can use all functions defined in the sys module.
import sys
# the fuction input display the text string that is passed to it as arguments between the ( and ) signs. it then asks for a value.
text_of_first_number=input("enter the first number: ")
# lets read the operation
... |
0e8a2487278fd9a61d7c01ac4b1da0186821e404 | jtcasper/modularityclustering | /src/node.py | 2,061 | 3.609375 | 4 | class Node:
def __init__(self, ID, connections=None):
"""
:param ID: This node's ID
:param connections: A list of edges that connect this node to its neighbors
:param community: The community that this node is a part of
"""
self.ID = ID
self.community = None... |
5a2874340cca58ed4df3410aaf20a3629108eb9b | purwar2804/python | /create_largest_number.py | 742 | 4.28125 | 4 | #PF-Assgn-36
'''Write a python function, create_largest_number(), which accepts a list of numbers and returns the largest number possible by concatenating the list of numbers.
Note: Assume that all the numbers are two digit numbers.'''
def create_largest_number(number_list):
for i in range(0,len(number_lis... |
df1c905fc22d963a155f3e1dc0127c658aa6189d | wilianrevejes/programmingrepository | /exercices/python/ex003.py | 229 | 3.921875 | 4 | # ex003 - Crie um programa que leia dois números e mostr a soma entre eles.
n1 = int(input('Digite um número: '))
n2 = int(input('Digite outro: '))
s = n1 + n2
print('A soma entre {0} e {1} resulta em {2}.'.format(n1, n2, s))
|
602bdbd12e4fc96065e6379c81c86b10124feca3 | hatanasov/dictionaryes | /oddoccur.py | 279 | 3.890625 | 4 | words = input().split()
word_occur = {}
for word in words:
word = word.lower()
if word not in word_occur:
word_occur[word] = 1
else:
word_occur[word] += 1
result = [word for word in word_occur if word_occur[word] % 2 == 1]
print(*result, sep=', ') |
ac0119b6f1ab89431b5f83385deafcc0c9a9eeb8 | microsoft/qlib | /qlib/utils/index_data.py | 21,892 | 3.546875 | 4 | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""
Motivation of index_data
- Pandas has a lot of user-friendly interfaces. However, integrating too much features in a single tool bring too much overhead and makes it much slower than numpy.
Some users just want a simple numpy dataframe wit... |
84850609b97126b9262b0585507972b137df3dec | natalie-i/gh | /HT_2/2.py | 398 | 3.765625 | 4 | """ 2. Користувачем вводиться початковий і кінцевий рік. Створити цикл,
який виведе всі високосні роки в цьому проміжку (границі включно).
"""
y1=int(input())
y2=int(input())
for i in range(y1,y2+1):
if i%400==0:
print(i)
if i%4==0 and i%100!=0:
print(i)
|
867fa65e1b01d5674edea93187c8e4b12c9512d1 | gleissonneves/software-development-python-study | /curso_em_video/modulo_1/desafios/d28.py | 148 | 3.953125 | 4 | nome_c = str(input("digite seu nome: ")).strip()
nome = nome_c.split()
print('primeiro nome {} ultimo nome {}'.format(nome[0], nome[len(nome) - 1])) |
9af77739d6337a2f5da0bfa9007a6d2bc4781206 | edu-athensoft/ceit4101python | /evaluate/evaluate_2_quiz/stem1401_python1/quiz_05.py | 469 | 3.671875 | 4 | """
quiz 5
"""
# question 5
num = 9
print(isinstance(num, int))
# question 6
# 6-2
my_list = [1,2,3,4,5,6]
print(my_list[0],my_list[-1])
print(my_list[0],my_list[5])
# 6-3
my_list[3] = 999
print(my_list[3])
# 6-4
my_tuple = (1,2,3,4,5,6)
print(my_tuple[0],my_tuple[-1])
print(my_tuple[0],my_tuple[5])
# 6-6
my_set ... |
ac39516aee799993afeaf2d1fa99291f4d382216 | PsychoLeo/Club_Informatique | /3-GaleShapley/hommes_femmes_liste.py | 953 | 4.03125 | 4 | """
==> Remplir ces dictionnaires avec des préférences
"""
import random
# Il y a AUTANT d'hommes que de femmes
#* Gens qui proposent = hommes
# Liste de longueur nombre d'hommes et comportant n sous listes de longueur nombre de femmes, les classant
# hommes = []
# *Ceux qui acceptent ou déclinent = femm... |
d74663059786b6ca3f6b1e092e1611e41d08f368 | tattarw/API-challenge | /WeatherPy.py | 4,402 | 3.71875 | 4 | #!/usr/bin/env python
# coding: utf-8
# # WeatherPy
# ----
#
# #### Note
# * Instructions have been included for each segment. You do not have to follow them exactly, but they are included to help you think through the steps.
# In[38]:
# Dependencies and Setup
import matplotlib.pyplot as plt
import pandas as pd
im... |
481ec7997e5dd6c9fbe9b8458abaa66d054001f0 | sHalnes/Algorithms_And_DataStructs | /largest_smallest_BST.py | 543 | 4.0625 | 4 | from BST import *
''' Find largest smallest BST key. Return -1 if there is no such number'''
def find_largest_smallest(root, n):
result = -1
while root is not None:
if root.cargo < n:
result = root.cargo
root = root.right
else:
root = root.left
return re... |
b8182e30ce03ce043e9518291360100bf54688a6 | wonnacry/hw | /task_plates.py | 479 | 3.671875 | 4 | N = int(input())
Msr = int(input())
while N != 0 and Msr != 0:
N -= 1
Msr -= 0.5
if Msr == 0 and N != 0:
print('Моющее средство закончилось. Осталось '+ str(N) +' тарелок')
elif N == 0 and Msr != 0:
print('Все тарелки вымыты. Осталось ' + str(Msr) + ' ед. моющего средства')
else:
print('Все тарелки ... |
35d2737f5c8f2e70b31cf763a6ee357d519f5349 | Lingrui/Learn-Python | /cookbook/1.15.py | 911 | 3.546875 | 4 | #!/usr/bin/python
rows = [
{'address':'5412 N CLARK','date': '07/01/2012'},
{'address':'5148 N CLARK','date': '07/04/2012'},
{'address':'5800 E 58TH', 'date': '07/02/2012'},
{'address':'2122 N CLARK','date': '07/03/2012'},
{'address':'5645 N RAVENSWOOD','date': '07/02/2012'},
{'address':'1060 W ADDISON','date'... |
4d28a8489da9cf5f8e834f1d05ef54998ce6d6d7 | siyile/leetcode | /src/Problem676.py | 615 | 3.578125 | 4 | class MagicDictionary:
def _can(self, w):
for i in range(len(w)):
yield w[:i] + '*' + w[i+1:]
def buildDict(self, dictionary: List[str]) -> None:
self.words = set(dictionary)
self.nei = Counter(can for w in dictionary for can in self._can(w))
def search(self, ... |
6e45d2374256e75f9fa363c45a38d714f1782c5c | csatyajith/leetcode_solutions | /september_challenge/sort_two_bst_elements.py | 1,148 | 4.0625 | 4 | from typing import List
# Definition for a binary tree node.
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
# Function to traverse the tree in-order
def traverse_in_order(self, root, result):
... |
e0456f9f43f12069c4c15ebfcfc78e9d1bc818c4 | jhapreis/Python_Scripts | /lab_mc102/lab08.py | 4,443 | 4.15625 | 4 | #MC102-7 -- LAB 08
# =============================================================================
# 1: Declaração de variáveis; importação dos valores como lista
# =============================================================================
nota_ac = [float(i) for i in input().split()] #será inserido uma sequência d... |
fc9fd2ce00ec856ea996ca1ab47b2ee38525887a | WangYangLau/learnpython | /func_para2.py | 663 | 4.03125 | 4 | # -*- coding:utf-8 -*-
def calc(*number):
sum = 0
for n in number:
sum = sum + n*n
return sum
L = [1,2,3]
s = calc(1,2,3)
print("changeable_para calc(*number) 1 2 3:\n%d"%s)
s = calc(4,5)
print("changeable_para calc(*number) 4 5:\n%d"%s)
s = calc(*L)
print("L =",L)
print("changeable_para calc(*number) *L:\n%d"%... |
d7c972d934e4ccf74256795f6892b68df1f21b3e | Bngzifei/PythonNotes | /学习路线/2.python进阶/day07/04-生成器.py | 1,492 | 3.703125 | 4 | print('生成器...')
"""
生成器是一类特殊的迭代器(既然是迭代器了,那么当然就是可迭代对象).自己就是.不需要写__iter__(),__next__()这两个方法.
自己天生就是迭代器.
仍然可以使用iter(),next() 方法.
分类:
列表推导式[]: ---> () 就是 生成器表达式 :():<generator:>
生成器里面存放的不是具体的数据,只是存放的是一个算法.
生成器表达式和列表推导式的异同:
不同: (表达式) [表达式]
---------------|------------|-----------
产生的对象 生成器对象 ... |
104844118d57f819f990f20571f9bddaae3603eb | ibicfth/python_egitim_uygulamalarim | /src_uygulamalar/7_hata/23_hata_uygulama.py | 1,318 | 3.984375 | 4 | liste=["1","2","5a","10b","abc","10","50"]
####liste içindeki sayısal degerleri bulunuz
sayısaldegerler=[]
for x in liste:
try:
a=int(x)
except Exception:
continue
else: #hata vermediğinde çalışan kısım.
sayısaldegerler.append(x)
print(sayısaldegerler)
#yada
for x in liste:
... |
9575e7a593b354b78f70ad67d4e09d4f4124f011 | cavandervoort/Project-Euler-001-to-100 | /Euler_001.py | 154 | 3.984375 | 4 | # Problem 1
# Multiples of 3 and 5
runningSum = 0
for num in range(1000):
if num % 3 == 0 or num % 5 == 0:
runningSum += num
print(runningSum) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.