blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
528c6f8f092cadea3bccfa513d6027ad2b4e5fb6 | hoangdinhdat54k1/Hoangdat8695 | /Th1.2.py | 127 | 3.828125 | 4 |
# Kiem tra so chan le
n=int(input("Nhap 1 so-->"))
if n%2==0:
print("EVEN Number")
else:
print("ODD Number")
|
cb6ffda0c76ef2e3edd824ca0592a7c135c463ac | TITHI007/Python | /loop_3.py | 102 | 3.765625 | 4 | a=[0,1,2,3,4,5]
for x in a:
if x==2:
continue
print(x)
print("--X+9",x+9)
|
3f9faf0b73625cd94ba85c7c74e5674dc5d76ca5 | alar0330/ProjectEuler | /problems/p006/solution.py | 932 | 3.625 | 4 | """
Project Euler: Problem #006
"""
def solve(max):
"""
Semi-brute-force solution (using only arith. series formula).
.. note:: There is a purely mathematical solution.
.. warning:: I UNintentionally overloaded built-in max-function :)
:param max: Max number in the series.
:returns: ... |
f4d621441d5f26ee0b92113d34a61302aa84f900 | qiaozhi827/leetcode-1 | /03-单链表/3-虚拟头结点/01-203.py | 1,540 | 3.921875 | 4 | # Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
def list_to_list_node(l):
p = head = ListNode(-1)
for v in l:
p.next = ListNode(v)
p = p.next
return head.next
def list_node_to_list(list_node)... |
f92308300f70ab3b643d0273677282c0c927cb7d | klbinns/project-euler-solutions | /Solutions/Problem48.py | 668 | 3.75 | 4 | '''
Problem 48:
The series, 1^1 + 2^2 + 3^3 + ... + 10^10 = 10405071317.
Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000.
'''
# calculate all the factorials and sum (really wasteful, but easy to code)
s = sum([i**i for i in range(1,1001)])
#convert to string, print last 10 dig... |
f14e7f2da6bc0795e71871b5607a6e4ec84829cb | Arifiot/Kwyk-Solver | /solvers/solver_20119.py | 954 | 3.640625 | 4 | import numpy as np
from fractions import Fraction
from functions import int_input
def solve():
print("Les coordonnées du point A sont :")
Ax = int_input("Ax = ")
Ay = int_input("Ay = ")
Az = int_input("Az = ")
print("Les coordonnées du point B sont :")
Bx = int_input("Bx = ")
By = int_inpu... |
d79c473e0317d2dde97654d5f1c446e2a2611082 | VeroLaznova/DomaciUlohy | /lekce3/ukol10-11.py | 289 | 3.890625 | 4 | from turtle import forward, left, exitonclick
n = int(input('zadej pocet uhlu, zacnu kreslit spiralu'))
opakovani = int(input('kolikrat se ma zatocit?'))
delka_strany = 5
for spirala in range (1,opakovani):
forward (delka_strany*1/spirala)
left(180-(180*(1-2/n)))
exitonclick()
|
bd9a901bb5029814062e3013b2bc6bcd7d60e90c | Gottskalksson/FirstWindowGames | /DrawGame.py | 1,002 | 3.609375 | 4 | from tkinter import *
import random
t = Tk()
t.title("Choose the button")
t.geometry("300x350")
def trafiony():
for i in przyciski:
i.destroy()
global etykieta
etykieta = Label(t, text = "You won!")
etykieta.pack(fill=BOTH, expand=YES)
t.after(3000, restart)
def pudlo():
for i in prz... |
d5b878923c79d599c48836ebce64b7746938e1c0 | iceycode/python-src-edx | /inclass_code/lecture_code/lect6-random2/montyhall.py | 1,811 | 3.609375 | 4 | import pylab
import random
# Simulation of Monty Hall Problem
# prize door = car; wrong door = goat
# problem based on game show - choose 1 of 3 doors, Monty opens door, then guest chooses last door
# Monty KNOWS that door HE opens does not contain car
def montyChoose(guessDoor, prizeDoor):
'''
Monty ... |
880125f710977b1d55bc5a4e002839a14c478aac | kaiopomini/PythonExercisesCursoEmVideo | /ex096.py | 385 | 4.375 | 4 | '''
Exercício Python 096: Faça um programa que tenha uma função chamada área(), que receba as dimensões de um terreno
retangular (largura e comprimento) e mostre a área do terreno.
'''
def area(larg, comp):
print(f'A área de um terreno de {larg:.2f} x {comp:.2f} é de {larg*comp:.2f}m2.')
a = int(input('Largura ... |
c8bfba74f832259a51be401c99b9a798ccdc272e | gjtjdtn201/practice | /SWEA/2월/2월17일/계산기3.py | 1,554 | 3.515625 | 4 | import sys
sys.stdin = open("계산기3.txt", "r")
def cal(val1, val2, oper):
if oper == '+':
return val2 + val1
elif oper == '-':
return val2 - val1
elif oper == '*':
return val2 * val1
else:
return val2 // val1
def isp(val):
if val == '(':
return 0
elif val ... |
aef5edf419aef7d0c804c55bc16718c6aaa8d2ac | Sam-Coon/PPC---Book-1 | /ChallengeNo7.py | 619 | 3.984375 | 4 | ######################################################
#Title: ChallengeNo8.py
#Author: Sam Coon
#Date: 9/29/14
######################################################
width = int(input("Please enter width: "))
height = int(input("Please enter height"))
print("The area is:",width*height)
##################... |
9e13b7ad8457c4e2c6d2aa24f7193fa94d7d78c5 | Skipp-it/Ask_Mate | /IDgenerator.py | 927 | 4.125 | 4 | import random
import string
def generate_id(number_of_small_letters=2,
number_of_capital_letters=2,
number_of_digits=2,
number_of_special_chars=2,
allowed_special_chars=r"_+-!"):
"""
The funcion generates a random string allowing the user to inpu... |
6ba48e09fb8cbabdbc2cdfe2bdf7f72e40a2630e | Fergoth/Euler_Proj | /6. Sum square difference.py | 637 | 3.828125 | 4 | # The sum of the squares of the first ten natural numbers is,
# 12 + 22 + ... + 102 = 385
# The square of the sum of the first ten natural numbers is,
# (1 + 2 + ... + 10)2 = 552 = 3025
# Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640.... |
1e49b984c8353838e97a50b573a0c40886c9905f | abespitalny/CodingPuzzles | /Leetcode/move_zeroes.py | 1,042 | 3.734375 | 4 | '''
Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements.
Note that you must do this in-place without making a copy of the array.
'''
from leetcode import *
class Solution:
# Time: O(n^2)
# Space: O(1)
def moveZeroes(self, nums: List[int]... |
88028c1f1313c7ba89a018699e6fbd458b3117b3 | thesparkvision/DS-Algo | /LinkedList/OrderedList.py | 2,936 | 4.03125 | 4 | class Node:
def __init__(self,data):
self.data=data
self.next=None
def setData(self,data):
self.data=data
def getData(self):
return self.data
def getNext(self):
return self.next
def setNext(self,next):
self.next=next
class OrderedList:
def __init__(self):
self.head=None
def add(self,new_dat... |
ecbb9f770354b22285fc56230fdc2c6c1f084ae1 | DanischKhurshid/CaesarEncryption | /caesar_verschluesslung.py | 3,114 | 4.1875 | 4 | # -*- coding: utf-8 -*-
from __future__ import division # important package for precise division of floats
class Caesar: # create Class Caesar => Python OOP
def __init__(self): # Constructor which initialize and declare a attribute alphabet
self.alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
# D... |
be9ef009200fa20eb8d71da20d9b999df8ff66df | mjkilian/4thYearFinalProject | /Numberjack-master/examples/JobshopSimple.py | 4,520 | 3.515625 | 4 | from Numberjack import *
# Job Shop Scheduling
# Given a set of N job of various sizes, the job shop scheduling problem is to
# schedule these on M machies such that the overall makespan is minimized. The
# makespan is the total length of the schedule.
###############################################
####### Clas... |
16358676c342994e05c327ea7f015b08b1cc6641 | tmfahall/fractions | /main.py | 1,515 | 3.890625 | 4 | #Author: Ronni Kurtzhals
#Date: 12/4/18
#Class: CSIS 152
#Instructor: Dr. Brekke
#Assignment: Program 13
import string
import math
def main():
print("Enter two fractions to find their sum, difference, product, and quotient.")
fraction1 = input("Enter your first fraction: ")
fraction2 = input("Enter your se... |
e138e7e5d8a900121bbaa41d61a679b2e809fe44 | shivakumar978/code | /For-loop practice.py | 2,802 | 4.75 | 5 | # Loops and Iterations:
# FOR-Loop: A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string).
# With the for loop we can execute a set of statements, once for each item in a list, tuple, set etc.
sports = ["Hockey", "Football", "Basketball", "Tennis"]
fo... |
8814cdfefd645d58021be4e6857b2acee262db7a | HugoDuret/Aristote_puzzle | /common.py | 2,862 | 3.671875 | 4 | # Made by HugoDuret
# Started on January, 22, 2020
# Common functions to help resolve the Aristote puzzle.
# The game set is represented by a list of 19 objects, starting from top left at 0, going left to right
# going back at the left side for each row
from random import shuffle
# CONSTANTS
MAX_TRIES = 10_000
# T... |
8b10b4d22325a5ed122032ab9d6bbb9212496384 | oskar404/aoc | /aoc2019/day01.py | 1,110 | 4 | 4 | #!/usr/bin/env python3
import sys
# First 'simple' solution
def solve_part1(file):
total = 0
with open(file) as f:
for line in f:
total += int(line) // 3 - 2
return total
def fuel_requirement(mass):
total = 0
fuel = mass
while True:
fuel = fuel // 3 - 2
... |
a2f6cb329543fd7d3b2956ab0a03719ff8025a20 | Ostap2003/stack-queue | /queue_to_stack.py | 509 | 3.546875 | 4 | """
Queue to stack converter.
"""
from arrayqueue import ArrayQueue # or from linkedqueue import LinkedQueue
from arraystack import ArrayStack # or from linkedstack import LinkedStack
def queue_to_stack(queue):
'''Convert queue to stack, without modifying the queue
peek of the stack must be first eleme... |
2da453f8a6f2683ebdf4b5338e2de2fc8f73421b | vmanvitha3/PythonLabAssignments | /LabAssignment2/Source/ContactList.py | 5,524 | 4.3125 | 4 | #In any mobile , there is contact list. Create a list of contacts and then prompt the user to do the following:
#a) Display contact by name b) Display contact by number c) Edit contact by name d) Exit
def displayByName(Name): #method to display contact by name
list = [] #create empty list
flag = F... |
36b241d86d24d645ac0c779c49cea9e4aaf8292e | rjowell/TheosCode | /TheosCar.py | 1,473 | 3.921875 | 4 | #HOMEWORK - Write a class for an Airplane
class Car:
#Constructor Method
#"sedan" "coupe" "truck"
maxSpeed = 70
fuelTankSize = 25
carIsOn = False
def slowDown(self):
print("Screeeeech")
def turn(self,direction):
print("We are turning " + directio... |
fdc28b2b0f7060a57015043997de6fcc4d3403c4 | lholliger/ShiftPass | /shiftpass.py | 2,867 | 3.734375 | 4 | import string
import sys
current_arg_pos = 0
import binascii
current_version = "01" # THIS CHANGES WITH EVERY ENCODING UPDATE TO PREVENT ERRORS
askpass = True
askstr = True
asktype = True
force = False
for x in sys.argv:
if (x == "-e" or x == "--encrypt"):
fc = "-e"
asktype = False;
if (x == "... |
c3c749bd31b6154880766091314d12e72fe6639f | SayedSibgath27/Data-Analytics | /readingdata.py | 683 | 3.890625 | 4 | # For extra dependency we need to import the package.
import pandas
# Read the data from the excel file
def student(name,marks):
selectedstudents=list()
n=len(name)
for i in range(n):
if marks[i]>=70:
selectedname=name[i]
selectedstudents.append(selectedname)
... |
a44f7df1df2a78d4603eb9d1ae458034986039a6 | ddavy94/PlayMe | /connectfour.py | 4,390 | 3.671875 | 4 |
##Creates dictionary representation of 6X7 connect4 gameboard with keys representing row number and values representing lists
connect4 = {}
for i in range(6):
connect4[i] = [0,0,0,0,0,0,0]
#checks if board column is full
def checkFull(inp,gameboard):
for i in range(6):
if gameboard[i][inp] == 0:
... |
453fd93a31b4341eee7fb1cc020d18a8f42b9fc1 | LuckyLay/fluent-python | /Demo_6-9.py | 367 | 3.5 | 4 | """
使用函数作为对象,替换"命令"模式
这里只是一个测试
"""
class MacroCmomand:
"""
一个执行一组命名的命令
"""
def __init__(self, commands):
self.commands = list(commands)
def __call__(self, *args, **kwargs):
for command in self.commands:
command()
print("这里只是一个测试") |
5d7b7323debfc15780482fa0a770b6a7184e7247 | min10262000/XY | /start.py | 4,592 | 3.65625 | 4 |
import random
import time
filePath = "rank.txt"
maxRankUser = 5
numberProblem = 10
def numberToOperator(number):
if number == 0:
return "+"
elif number == 1:
return "-"
elif number == 2:
return "*"
elif number == 3:
return "/"
return ""
def getAnswer(number1,oper... |
cbca4459246d8be296764c22bce32f34c7bcc671 | bmiller1009/linkedin-miner | /parserhelper.py | 1,208 | 3.515625 | 4 | import re
#Utility class for matching and parsing HTML strings using regular expressions
class ParserHelper:
@staticmethod
#Returns the first match of a regular expression
def match_first_pattern(html, pattern):
r = re.search(pattern, html)
if r:
return html[r.start():r.e... |
81aa1a71450a4fd225e148bf5a38fb433adcc78d | Soulor0725/PycharmProjects | /python3/南京大学/第二周/function_example.py | 434 | 3.71875 | 4 | # r = lambda x:x+x
# print (r(5))
# def fib(n):
# a,b = 0,1
# count=1
# while count<n:
# a,b=b,a+b
# count+=1
# print(a)
# fib(9)
def fib(n):
if n == 0 or n == 1:
return n
else:
return fib(n-1)+fib(n-2)
print(fib(9))
import os
print(os.getcwd())
import mat... |
d924e843d2c9ea88c5c22f6ff75be9046acd8fe6 | wenjiazhangvincent/leetcode | /1105-1112/637.py | 962 | 3.609375 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def __init__(self):
self.res = []
self.count = []
def check(self,root,i):
if not roo... |
7664967591e7516ee9b172f1980fb07de8bec354 | davidhuangdw/leetcode | /python/282_ExpressionAddOperators.py | 1,958 | 3.875 | 4 | from unittest import TestCase
# https://leetcode.com/problems/expression-add-operators/
class ExpressionAddOperators(TestCase):
def addOperators(self, num, target):
"""
:type num: str
:type target: int
:rtype: List[str]
"""
n = len(num)
ret = []
def ... |
b2b97bbe0276f6620b055f51e123cca3c8076193 | YuriiKhomych/ITEA_course | /KabanovMax/4_iterations_KabanovMax/hw/hm_1_kabanovMax.py | 498 | 4.125 | 4 | '''
Homework #1 KabanovMax
'''
# Input of string
input_text = str(input("Type your message here: "))
# Calculating digits
number_of_digits = [d for d in input_text if d.isdigit()]
# Calculating letters
number_of_letters = [l for l in input_text if l.isalpha()]
# Output string and quantity
digit_numbers = len(number... |
a84973cccddedc84b4ee137712272fcabad3b340 | SeYearSt/Modeling_methods | /Solutions/lab1.py | 3,487 | 3.5 | 4 | import numpy as np
from scipy.stats import t as t_student
from scipy.stats import chi2
import matplotlib.pyplot as plt
def calc_stat(distr):
mean = np.mean(distr)
var = np.var(distr, ddof=1)
std = np.sqrt(var)
return mean, var, std
def print_stat(*info: tuple) -> None:
template = '{}\n Mean: {} \n Deviatio... |
46797029d46c612503e8849f2fda461e25e27db5 | vishnutejakandalam/python_learning_2020 | /submissions/mandarin_chinese_russian.py | 472 | 3.546875 | 4 | t=int(input("no of test cases"))
for i in range(t):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
rectangle = set([a,b,c,d])
if len(rectangle) == 2:
print("YES")
else:
print("NO")
# count=0
# if a==b or a==c or a==d:
# count+=1
# if b==c or b== d or b== a:
# count+=1
# if c==d or c... |
a38d27d1a6785ebc443491b7c3a2815967741929 | NicoleeeTian/CS111 | /PS9/ps9part1/ps9pr3.py | 2,141 | 3.765625 | 4 | #
# ps9pr3.py (Problem Set 9, Problem 3)
#
# Playing the game
#
from ps9pr1 import Board
from ps9pr2 import Player
import random
def connect_four(p1, p2):
""" Plays a game of Connect Four between the two specified players,
and returns the Board object as it looks at the end of the gam... |
33b0ba23e46623a9745e1f65c44626a8162cbae9 | utshav2008/python_training | /tree/average_level_tree.py | 1,483 | 3.8125 | 4 | from collections import deque
class Node(object):
def __init__(self, value):
self.value = value
self.left = None
self.right = None
class BinaryTree(object):
def __init__(self, root):
self.root = Node(root)
# def average(self, root):
# res = []
# q = deque(... |
f59bfee913e32c51e3e4a671e2eb52b303d69f04 | BoyanH/Freie-Universitaet-Berlin | /OOP/Python/Homework3/Aufgabe20.py | 662 | 4.15625 | 4 | while B:
S
if C:
T
if D:
U
V #V is only executed, when D is true, therefore could easily be moved in the statement
if (not C) | D
W #W is executed, if C is false, as we have no chance of getting in the code-block with continue statement,
#OR if C is true and D is true as well, so we don't get in ... |
04a246492bd6bb641d46b5fb56b1f1b4d99860a5 | Abdelhamid-bouzid/problem-Sovling- | /Medium/setZeroes.py | 1,254 | 4.28125 | 4 | '''
Given an m x n matrix. If an element is 0, set its entire row and column to 0. Do it in-place.
Follow up:
A straight forward solution using O(mn) space is probably a bad idea.
A simple improvement uses O(m + n) space, but still not the best solution.
Could you devise a constant space solution?
Example 1:
Inp... |
3c70b345f58aaf7525f6dcfebb9e0166ef4dc3dc | MannazX/mannaz | /Learning Python/Monte Carlo Integration.py | 588 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Dec 9 20:35:10 2018
@author: magge
"""
import numpy as np
import matplotlib.pyplot as plt
def MCint(f,a,b,n):
x = np.random.uniform(a,b,n)
s = np.sum(f(x))
I = (b-a)/n
return I
def funk(x):
return x**2 - 2*x + 1
a = 10
b = 30
n = 1000000
MCint = MCint(... |
84086ac3feb515ac4358d2a6806f1db440cc462a | devMEremenko/Coding-Challenges | /Python/LeetCode/205. Isomorphic Strings.py | 687 | 3.515625 | 4 | # https://leetcode.com/problems/isomorphic-strings/
class Solution:
# Time: O(n), Space(n)
def using2Map(self, s: str, t: str) -> bool:
m1 = {}
m2 = {}
for idx in range(len(s)):
item1 = s[idx]
item2 = t[idx]
if item1 not in m1:
if it... |
5109daa2561d623dbbf20a57b9e99977de909dd6 | Indhuja09/myrep | /splitting strings.py | 213 | 3.796875 | 4 | print("Enter 2 short sentences")
sentence1 = input("Enter your first sentence")
sentence2 = input("Enter your second sentence")
words1 = sentence1.split()
words2 = sentence2.split()
print(words1+words2)
|
0b3f6288d8f4dae5e3e07f41596506f701b83347 | sirawit-suk/KMITL-Python-Grader | /KMITL_grader_lab/ch5_Stack_02_Brokenplate.py | 1,330 | 4.125 | 4 | # week 3
class Stack:
"""< Default Stack >"""
def __init__(self, list=None):
if list == None:
self.weight = []
self.sound = []
else:
self.weight = list
self.sound = list
def __str__(self):
s = 'stack of ' + str(self.size()) + ' items ... |
348e20869136ff19aecf359aa1b463e98894a8b9 | technologyMz/ALL_IN_ML | /yanghui/334reverseString.py | 540 | 3.734375 | 4 |
import List
import typing
class Solution:
def reverseString(self, s: List[str]) -> None:
"""
Do not return anything, modify s in-place instead.
"""
left_index = 0
right_index = len(s) - 1
while left_index <= right_index:
temp = s[left_index]
... |
7d998e6177d5ea77d6f8d45d2b8570cdb9fb0c33 | niki4/leetcode_py3 | /medium/820_short_encoding_of_words.py | 4,606 | 4.15625 | 4 | """
A valid encoding of an array of words is any reference string s and array of indices indices such that:
* words.length == indices.length
* The reference string s ends with the '#' character.
* For each index indices[i], the substring of s starting from indices[i] and up to (but not including) the next ... |
7dd9adeb8546a16428a8e044a5047a411e3900bb | grapeeffect/De-identification-Step | /Email_Preprocessing/test_de_identify.py | 2,384 | 3.65625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
from de_identify import de_identify, remSpecChar, remNum, remPN, remCAP
TestMessages0 = ["Contact me at @ucsb",
"Contact me at mondrian@ucsb.edu",
"website: www.mondrian.com",
"Please visit http://sec.org",
... |
48bcb902bb6ed95c005da4c4954334e21a698fc6 | quolc/chainer-ML-examples | /simple-perceptron/gen_data.py | 255 | 3.640625 | 4 | # (x, y) in [0, 1] * [0, 1]
# x > y なら0, x < y なら1
import sys
import random
n = int(sys.argv[1])
print(n)
for i in range(0, n):
x = random.random()
y = random.random()
t = 0 if x > y else 1
print("{0}\t{1}\t{2}".format(x, y, t))
|
f27de92638b413d1e8de2e478bf71168332a97f8 | audreyemmely/Python-programming | /estruturas compostas/ex002.py | 800 | 3.671875 | 4 | '''
Crie uma tupla preenchida com os 20 primeiros colocados da Tabela do Campeonato Brasileiro de Futebol (2019), na ordem de colocação. Depois mostre:
a) Os 5 primeiros times.
b) Os últimos 4 colocados.
c) Times em ordem alfabética.
d) Em que posição está o time da Chapecoense.
'''
times = ('Flamengo', 'Santos', 'Pal... |
17373996c401d7c79e175ca9f1800f7151840714 | ash92kr/s_code | /2018.12.18/string_test.py | 1,133 | 4.09375 | 4 | # python 과거(2버전)
'일은 영어로 %s, 이는 영어로 %s' % ('one', 'two')
# one과 two가 각각 %s로 들어간다
# python 현재(3버전) - pyformat
'{} {}'.format('one', 'two')
name = '홍길동'
e_name = 'Hong Gil Dong'
print("안녕하세요. {}입니다. My name is {}.".format(name, e_name))
# 변수의 순서 바꾸기 - 처음의 변수가 0, 나중의 것이 1
print("안녕하세요. {1}입니다. My name is {0}.".format... |
1e3bbc1662cd77508eae01e3fc5be8608ccbeca4 | KoryHunter37/code-mastery | /python/codewars/numerical-palindrome-number-4/solution.py | 500 | 3.921875 | 4 | # https://www.codewars.com/kata/numerical-palindrome-number-4/train/python
def is_palindrome(num):
if num < 10:
return False
s = str(num)
return s == s[::-1]
def palindrome(num):
if type(num) is not int or num < 0:
return 'Not valid'
if is_palindrome(num):
ret... |
18500750e494ad9f454ea29482444551832087db | Gafanhoto742/Python-3 | /Python (3)/Ex_finalizados/ex027.py | 369 | 4.15625 | 4 | # Exercício Python 027: Faça um programa que leia o nome completo de uma pessoa, mostrando em seguida o primeiro e o último nome separadamente.
nome = str(input('Digite o seu nome completo: ')).strip().upper()
n = nome.split()
print ('Muito prazer em te conhecer!')
print('Seu primeiro nome é:{}' .format(n[0]))
print('... |
ea63cf74e80fe6dff6f9de82b2c7e256b7502b4f | codewithdhruv22/Basic-Python-Projects | /Program-6__slicer.py | 834 | 4.3125 | 4 | print("**---Welcome To String Cutter Program---**")
string = input("Enter Any String:\n")
last_index = int(input("Enter The Number "
"Till Where You Want "
"To Cut Your "
f"String {string}:\n"))
if last_index > len(string):
print(f"... |
9a27c3a62c9e80b8825419f46b5d179081c5c007 | Optimistickeshav/Python-Basics | /10-oop.py | 1,835 | 3.984375 | 4 | # -*- coding: utf-8 -*-
"""
@author: Keshav
"""
#Object Oriented Programming - Program...
'''
DataTypes are of 3 types -
Inbuilt - (Int, String, FLoat)
- (Tuple, Set, Dictionary, Lists)
Custom - Object Orient.
'''
#pokemon, digimon, dragonballz, naruto
# =============================... |
58ef20ce77f6e36918b63895c26af3699ef574c3 | bamboodew/jackfrued_Python-100-Days | /src/Day005_ConstructProgramLogic/HundredMoneyHundredChicken.py | 663 | 3.546875 | 4 | '''
Created on 2019年8月29日
我国古代数学家张丘建在《算经》一书中提出的数学问题:鸡翁一值钱五,鸡母一值钱三,鸡雏三值钱一。百钱买百鸡,问鸡翁、鸡母、鸡雏各几何?
@author: jinshuang1
'''
# cock,hen,chick
for num_cock in range(1, 20):
# num_hen = int((100 - 5 * num_cock) / 3)
# print('%d %d' % (num_cock, num_hen))
for num_hen in range(1, int((100 - 5 * num_cock) / 3) + 1):
... |
cc64bf073d7df040dfead1897d13ea6d6c02ffe9 | cs-fullstack-fall-2018/python-review-exercise1-jpark1914 | /python_review_exercises.py | 1,713 | 4.125 | 4 | #====Phase 0======
#
# print("loop")
#
# #====Phase 1=====
#
# def printLoop():
#
# userInput = input("Enter something here")
# print("loop")
# printLoop()
# #====Phase 2=====
#
# def printLoop2():
# userInput2 = input("Enter something here")
# print(userInput2)
# printLoop2()
#
# #====Phase 3=====
# d... |
b06db9bc407ab6946b61c3f71d83a6080cb7d71e | TAEKnical/python | /~2020/Binary_Search.py | 385 | 3.53125 | 4 | def bin_search_closest(s,key):
distance=[]
tmp=s[:]
while(s !=[]):
mid=len(s)//2
if key not in s:
for i in range(len(s)):
distance.append(abs(key-s[i]))
return distance.index(min(distance))
else:
if key ==s[mid]:
return tmp.index(key)
elif key<=s[mid]:
s=s[:mid]
else:
s=s[mid... |
4dba70798cc2ddab22f847504f5616a4c743561a | basnetaakash23/leetcode_solution | /coding_exercises/gas_station.py | 433 | 3.5625 | 4 | def gasStation(gas, cost):
if(sum(gas)-sum(cost) < 0):
return -1
start_index = 0
gas_tank = 0
for i in range(len(gas)):
gas_tank += gas[i]-cost[i]
if(gas_tank < 0):
start_index = i+1
gas_tank = 0
print("i",i)
return start_index
gas = [1,2... |
c1d0bc4868beea69eaa1dc02f50e057136d2ba2a | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_200/3921.py | 390 | 3.5 | 4 | n = int(input())
numbers = [input() for i in range(n)]
def check_neat(num):
for i in range(len(num)-1,0,-1):
if num[i]<num[i-1]:
return False
return True
for j in range(n):
count = int(numbers[j])
while count>= 0:
if check_neat(str(count)):
print("C... |
afe024b08ae29eb94616533e396c4e21802f3e6a | kraftp/Leginon-Feature-Detection-Modification | /sinedon/examples/user_group.py | 1,610 | 3.625 | 4 | '''
This is a simple example showing some subclasses of sinedon.Data. Each
will correspond to a table in a database. The fields (columns) of the
table are defined by the typemap class attribute. typemap must be a tuple
which extends the typemap of the base class. In this example, an instance
of TData has a field th... |
10140e21167f9b2fc4a240f6c0de4b2b13139854 | rudolfslogins/py-snake | /grid.py | 1,985 | 3.859375 | 4 | """Game grid method object"""
import random
from cell import Cell
class Grid():
"""Game grid method object"""
def __init__(self, snake, apples, configurations):
self.snake = snake
self.apples = apples
self.config = configurations
def check_snake_state(self):
"""Check state ... |
5be3e4780d1b7e732efc5455230d0ace872cf262 | fearlessfreap24/pcap | /digitOfLife.py | 418 | 3.890625 | 4 | def sum_of_digits(digits):
sum = 0
for i in digits:
sum += int(i)
return str(sum)
def digit_of_life(bdate):
sum = sum_of_digits(bdate)
while len(sum) != 1:
sum = sum_of_digits(sum)
return sum
user_bdate = input("Enter a birthday using only digits i.e... |
248d0fe50af8bc9ce30fbe53ea0b21ea95c26fbc | dtulpa16/Battleship_proj | /fleet.py | 2,233 | 3.8125 | 4 | from game_board import Game_Board
class Fleet(Game_Board):
def __init__(self):
super().__init__()
self.destroyer = [0,0]
self.sub = [0,0,0]
self.battleship = [0,0,0,0]
self.carrier = [0,0,0,0,0]
self.user_fleet = []
self.create_fleet()
self.show_board... |
c8f77640a71c70195cd146411339365798d56714 | anatulea/codesignal_challenges | /Intro_CodeSignal/12_Land of Logic/52_longestWord.py | 480 | 4.375 | 4 | '''
Define a word as a sequence of consecutive English letters. Find the longest word from the given string.
Example
For text = "Ready, steady, go!", the output should be
longestWord(text) = "steady".'''
import string
def longestWord(text):
for char in string.punctuation:
text = text.replace(char,' ')
text... |
51353463059550d250e6bc343dd06226a54c6455 | KonradJankowski/python-poczatek | /argumenty_pozycyjne_i_nazwane.py | 2,105 | 4.1875 | 4 | <<<<<<< HEAD
# Wywołuj funkcję z zastosowaniem argumentów nazwanych
def average(distance, time):
return distance / time
def run_avg_speed_calculator(vehicle_name):
distance = float(input(f"Ile km pokonałeś/pokonałaś za pomocą {vehicle_name}? "))
time = float(input("Ile czasu Ci to zajęło? "))
average... |
7a0f72dd6ef926a1d8238f3c47d92d4ab2ecd4be | bomendez/bomendez.github.io | /Password/password.py | 3,699 | 4.1875 | 4 | '''
Bo Mendez
This function checks whether the user's string is a valid password.
'''
def lowercase(user_in):
'''
Function -- lowercase
This function checks whether the string contains a lowercase letter
Parameters:
user_in -- a string, expecting length of string > 0
... |
0a4e6be74aae07f68118a1bc08859dbb65712ec3 | zxquan123/number-theory-lab | /1_repeated_squaring.py | 713 | 3.90625 | 4 | # calculate: a^m % n, m >= 0
def repeated_squaring(a, m, n):
if m == 0:
return 1
result = repeated_squaring(a, m // 2, n)
if m % 2 == 0:
return (result * result) % n
else:
return (((result * result) % n) * a) % n
def unit_test_repeated_squaring():
# 2^5 % 7 = 4
assert re... |
317ddf1f03b3824c1ea7831b729b240d28879736 | rubiyadav18/list_questions | /prime_perfect_harshad_amsrong_num.py | 1,238 | 3.578125 | 4 | num=int(input("enter a number"))
i=0
e=[ ]
while i<num:
k=int(input("enter a number"))
e.append(k)
i=i+1
print(e)
prime=[]
prime.append("prime")
harshad=[ ]
harshad.append("harshad")
perfect=[ ]
perfect.append("perfect")
amstrong= [ ]
amstrong.append("amstrong")
strong=[]
strong.append("strong")
i=0
while i... |
47a032b2c98a389a8838b0ceadcd8d022aadbb8c | leticiadedeus/learningPython | /matrixWithComplexLists.py | 591 | 3.984375 | 4 | matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
even = []
sumC = 0
for line in range(0, 3):
for n in range(0, 3):
matrix[line][n] = int(input(f'Number[{line}, {n}]: '))
for line in range(0, 3):
for n in range(0, 3):
print(f'[{matrix[line][n]:^5}]', end='')
print()
for line in matrix:
for n in... |
7d7b1b5fac55f3655b0329a7740da9f447c6d076 | omidziaee/DataStructure | /Algorithm_And_Data_Structure/Array/meduim/diagonal_sort.py | 996 | 4.09375 | 4 | '''
Created on Jan 30, 2020
@author: omidziaee
Given a m * n matrix mat of integers, sort it diagonally in ascending order from the top-left to the bottom-right then
return the sorted array.
Example 1:
Input: mat = [[3,3,1,1],[2,2,1,2],[1,1,1,2]]
Output: [[1,1,1,1],[1,2,2,2],[1,2,3,3]]
'''
class Solution():
def... |
2d9b8fb7eb107ed648daaa3124c7f9eb51f9bb85 | ashwinvprabhu/SamplePrograms | /Ex1_2-CheckPermutation.py | 1,112 | 4.0625 | 4 | # 1.2 Check Permutation: Given two strings, write a method to decide if one is a permutation of the other.
# Clarification: Does the whitespace matter? Is the string case sensitive (is God and permutation of dog?)
def CheckPermutationForStrings1(str1, str2):
sorted_str1 = ''.join(sorted(str1))
sorted_str2 = ''... |
aea4fb129ec252942d247c82bdbae0d41852268e | RebornX10/b2_software | /gui_register.py | 2,134 | 3.5 | 4 | # coding: utf-8
from tkinter import *
import mysql.connector
mydb = mysql.connector.connect(
host="127.0.0.1",
port=8889,
user="root",
password="root",
database="Software"
)
mycursor = mydb.cursor()
# Creating object 'window' of Tk()
window = Tk()
window.geometry("500x500")
window.title('Registra... |
a74042d92ca38058736dcafd19872de1abec3f77 | adhishvishwakarma/DS-Algo | /Trees/depth_first.py | 1,244 | 4.15625 | 4 | # three forms of depth first traversal, namely in-order, pre-order and post-order
class Node:
def __init__(self, data):
self.data = data
self.right_child = None
self.left_child = None
a = Node("A")
b = Node("B")
c = Node("C")
d = Node("D")
e = Node("E")
f = Node("F")
g = Node("G")
h = No... |
b2585aed5f6127de11e15bc39ad89b51be04f9bf | jakekausler/Greek-Language-Learner | /lib/generators/VerbGenerator.py | 156,847 | 3.734375 | 4 | # -*- coding: utf-8 -*-
'''
Created on Apr 28, 2014
@author: Jake
Generate verb forms based on morphological features, a morphological
code, and the root.
'''
import sys
def formTense(verb,form,tense):
'''Generates the forms of an verb based on a certain
morphological code, as well as the mood, voice, and ten... |
c1d305a1246d6d58c03e62467bd3ddc2e0d23376 | ske-kr/Myalgorithm | /DFSBFS/leetcode_PathSumII.py | 1,757 | 3.65625 | 4 | # 답자체는 상위권이었으나
# 매번 틀리는 실수를 고쳐야할것
# Solution2가 왜틀렸는가를 생각해보자
# python에서 list를 parameter로 옮겨줄땐
# call by reference방식이다. 그렇기 때문에 그 당시의 경로를 답에 저장해준다고하더라도
# 경로가 탐색마다 바뀌게 되면 마지막에 바뀐 경로가 답안에 들어가게 되있을것이다.
# 그럴땐 copy()함수를 활용할것(line 25와 line 44비교)
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, v... |
4a22d51e219703f0ec1b293db04436df3cd3fd2a | DmitryVlaznev/leetcode | /1046-last-stone-weight.py | 3,267 | 3.65625 | 4 | # Last Stone Weight
# We have a collection of stones, each stone has a positive integer
# weight.
# Each turn, we choose the two heaviest stones and smash them together.
# Suppose the stones have weights x and y with x <= y. The result of
# this smash is:
# If x == y, both stones are totally destroyed;
# If x != ... |
701b76dbad9260518948355b19f134a2dc4f0d47 | JhordanRojas/t07_Rojas.Linares | /Rojas/While/ejercicio03.py | 583 | 3.90625 | 4 | import os
# Mostrar "Invalido" mientras no se ingrese un curso correcto
curso=os.sys.argv[1]
invalido=True
while(invalido):
print("##########################################")
print("Ingrese el curso a consultar:", curso)
print("##########################################")
invalido=(curso != "Matematic... |
491d1d36949c7d60384d9d6e020222420327fe65 | Jo-wan/project | /python/1、数据类型/ex4_数据类型相加减.py | 109 | 3.6875 | 4 | s1 = "120"
s2 = "3.1415"
m = int(s1)
n = float(s2)
print("m,n")
print("m+m:",m+n)
print("s1+s2:",s1+s2) |
3e21f8ec93c31e6b4c661f4e825699196e458661 | tkhan1994/CS-230 | /ASG2/recever.py | 1,556 | 3.640625 | 4 | import socket
import json
# This function returns a string
# which contains the messages sent
# by the sender. The protocol is
# that a message ends with a new line
# character "\n"
def get_message(conn):
length_str = b''
char = conn.recv(1)
while char != b'\n':
length_str += char
char = conn.recv(1)
total ... |
4c27c602c376f033c7d134ba479b89b89428b367 | Levva/GeekPythonAlg | /lesson7/Task_2.1.py | 702 | 3.75 | 4 | import random
size = 10
array = [random.randint(0, 9) for i in range(size)]
# array = [random.uniform(0, 50) for i in range(size)]
print(array)
def merde_sort(array):
n = len(array)
if n < 2:
return array
l = merde_sort(array[:n//2])
r = merde_sort(array[n//2:n])
i = 0
j = 0
res ... |
017a8b20d151b2e0476388740b5b5e54d8679bde | Rajkumar21098/Rajkumar-R | /test5.1.py | 142 | 3.796875 | 4 | a=float(input())
b=float(input())
c=float(input())
if(a>b) and (a>c):
print(a)
elif(b>a) and (b>c):
print(b)
else:
print(c)
|
987fc591b6d6fbb124dd9e16a49ac84c3b12521b | pengzihe/python | /test/class.py | 377 | 3.53125 | 4 | #!/usr/bin/python
class Dog:
def __init__(self,name,age=18):
self.name = name
self.age = age
def bulk(self):
print "hehehehe....,my name is %s, i am %s years old." % (self.name,self.age)
def __auth(self):
print "cannot be called outside of this class."
def eat(self,food):
print "i like eat %s." % food... |
5718ed5ecfa2cc8743ebc3c720251f6f0f7260e4 | DomenZero/Tasks_Python | /les_1_task_4.py | 685 | 4.15625 | 4 | """
4. Пользователь вводит две буквы. Определить, на каких местах
алфавита они стоят, и сколько между ними находится букв.
"""
b1 = ord(input('Введите первую букву: '))
b2 = ord(input('Введите вторую букву: '))
print(f'Номер первой буквы = {int(b1)-97+1}' ) # строчные английские буквы находятся в ASCII в диап... |
dddd4e1a1265cbd530dce8ff8f79b705a2f1f713 | siva4646/DataStructure_and_algorithms | /python/list/return_robot.py | 663 | 3.53125 | 4 | class Solution:
def isRobotBounded(self, instructions: str) -> bool:
a=0
b=0
dir=0 # 0 N ,1 W , 2 S ,3 E
directions = [[0,1],[1,0],[0,-1],[-1,0]]
for i in instructions:
if i =='G':
a+=directions[dir][0]
b+=directions[d... |
a18514476ecbf5423cc3209a9bf8d9148122f6de | KyleMiles/A-Walk-Through-x86 | /Stage-1/Server-Files/stage-1-server.py | 2,007 | 3.609375 | 4 | #!/usr/bin/env python3
from time import sleep
def input_answer(prompt, answer):
user_input = input(prompt)
if user_input == answer:
return 1
else:
return 0
def main():
# Question 1
if not input_answer("What is the value of dh after line 129 executes? (Answer with a one-byte hex v... |
50fae97d9e03f711fbf053a594bb572e06ff043a | pkray91/laravel | /loop/nested.py | 126 | 3.953125 | 4 | plist=["red","green","yellow","blue"];
fruits = ["apple", "banana", "cherry"];
for x in plist:
for y in fruits:
print(x,y); |
dca6a1285938333cf93e8252683728d4d4b33906 | dodgejesse/Temporal | /resources/scriptForLex.py | 342 | 3.5 | 4 | #!/usr/local/bin/python
tens = ["twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety"]
ones = ["", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
counter = 1920
for i in tens:
for j in ones:
print "nineteen {0} {1} :- NP : {2}:r".format(i,j,counter)
... |
33571feac8bc6e04ce0ec71c2424ad8a6538ba17 | rafaelperazzo/programacao-web | /moodledata/vpl_data/59/usersdata/230/46338/submittedfiles/testes.py | 93 | 3.546875 | 4 | # -*- coding: utf-8 -*-
a=0
b=0
for j in range (10,100,10):
a=a+1
b=b+2
print(j)
|
f6ac54ad7b247608195ad94451ec11963e3021e8 | msorce/dsa | /reverse-words.py | 759 | 3.859375 | 4 |
def reverse_words(message):
reverse_characters(message, 0, len(message) - 1)
# Decode the message by reversing the words
current_word_start = 0
# need to reverse each word now after reversing entire message
for i in range(len(message) + 1):
# find the end of the current word here
if... |
2159f6e376a8db037758a7b40274618c06debfcd | niceyilin/fullstack-nanodegree-vm | /vagrant/tournament/tournament.py | 4,388 | 3.609375 | 4 | #!/usr/bin/env python
#
# tournament.py -- implementation of a Swiss-system tournament
#
import psycopg2
def connect():
"""Connect to the PostgreSQL database. Returns a database connection."""
return psycopg2.connect("dbname=tournament")
def deleteMatches():
"""Remove all the match records from the database."... |
95a23f015520c84dd60248f0872d918fbdf60030 | terrycts0101/Reversi | /Control/control.py | 8,988 | 4 | 4 | #!/usr/bin/env python
"""control.py: Reversi Game General Control Code.
This program provides the general functions that are used in the reversi game.
The AI control functions are included in a separate file "AI.py". When called
by "model.py" module, it returns the corresponding results that are needed by
the ... |
cc664da74a01e31497502ea64f2305ba3ccf8dfd | TomaszOdrzygozdz/gym-splendor | /alpaca/alpacka/trainers/base.py | 709 | 3.796875 | 4 | """Base class for training_data."""
class Trainer:
"""Base class for training_data.
Trainer is something that can train_raw a neural network using data from memory.
In the most basic setup, it just samples data from a replay buffer. By
abstracting Trainer out, we can also support other setups, e.g. t... |
030d337c12eb46cc5487a7976592c464b4816630 | kassenna/projekt-inz | /points.py | 2,637 | 3.96875 | 4 | import copy
class Point:
def __init__(self, point: tuple):
self.x = point[0]
self.y = point[1]
def __eq__(self, point):
return (self.x == point.x) and (self.y == point.y)
def __gt__(self, point):
return (self.x > point.x) and (self.y > point.y)
def __lt__(self, point... |
6e0755921ed27edf83c0635677e70b1a384f96b4 | dannymulligan/Project_Euler.net | /Prob_112/prob_112.py | 1,596 | 3.765625 | 4 | #!/usr/bin/python
#
# Project Euler.net Problem 112
#
# Working from left-to-right if no digit is exceeded by the digit to
# its left it is called an increasing number; for example, 134468.
#
# Similarly if no digit is exceeded by the digit to its right it is
# called a decreasing number; for example, 66420.
#
# We ... |
cdda7ad68e3916b531211860d2f76e6cbc0d0a41 | brian09088/basic-python | /2-8.py | 123 | 3.828125 | 4 | n = int(input(">"))
for j in range(2*n):
if j<n:
print("*"*n+"-"*2*n)
else:
print("+"*n+"-"*2*n)
|
e70a625ef768c3fb4cfcb49f0ff7687be0c7f3c2 | ataylor89/leetcode | /problem0374.py | 732 | 3.546875 | 4 | import math
class Solution(object):
def guessNumber(self, n):
if guess(n) == 0:
return n
m = n/2
if guess(m) > 0:
while guess(m * 2) > 0:
m *= 2
while guess(m + int(math.sqrt(m))) > 0:
m += ... |
a361f51e6cda567cf1bf3705c2f831bc099e5c50 | CCedricYoung/bitesofpy | /263/islands.py | 1,293 | 4.28125 | 4 | def count_islands(grid):
"""
Input: 2D matrix, each item is [x, y] -> row, col.
Output: number of islands, or 0 if found none.
Notes: island is denoted by 1, ocean by 0 islands is counted by continuously
connected vertically or horizontally by '1's.
It's also preferred to check/mark t... |
93e44e78ef213a9bcffa0150f3296c7e3657ed43 | JosephLevinthal/Research-projects | /5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/224/users/4375/codes/1832_3179.py | 259 | 3.640625 | 4 | from numpy import*
n=array(eval(input("digite um vetor: ")))
d=zeros(size(n), dtype=int)
for i in range(size(n)):
d[i]=n[i]
for i in range (size(n)):
if(n[i]==1):
for j in range(i,size(n)-1):
d[j]=n[j+1]
print(j)
d[-1]=1
print(d)
|
e10c412a95c79030aecd6f9097602c71e840b879 | panumas300/project1 | /testplus.py | 105 | 4 | 4 | num1 = int(input('Enter num1 : '))
num2 = int(input('Enter num2 : '))
print('num1 + num2 = ',num1+num2) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.