blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
ab1e05252677187acfc65b8ead99de1a9288a8e3 | Srishti325/elif | /elif ladder.py | 392 | 3.5625 | 4 |
# coding: utf-8
# In[7]:
s1 = int(input("enter s1 marks: "))
s2 = int(input("enter s2 marks: "))
s3 = int(input("enter s3 marks: "))
s4 = int(input("enter s4 marks: "))
s5 = int(input("enter s5 marks: "))
g_m = s1+s2+s3+s4+s5
avg = g_m/500
per = avg*100
if (per > 70):
print("A")
elif(per > 60):
print("B")
e... |
8c4bf2d7bc53e3d3f828fd705487a776a43ff978 | wallacewong82/catalog2 | /lotsofcatalog.py | 9,550 | 3.515625 | 4 | # This file is meant to help create a repository of data in order to
# have some data in the database; rather than start from scratch.
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
import datetime
from model import Catalog, I... |
f5817a34a744b998399960a27382330bf3c93790 | activeion/Books_SourceCode | /Fluent_Python/ch02-array-seq/listcomps.py | 1,021 | 3.765625 | 4 | print('----------------')
symbols = 'A中国人'
codes = []
for symbol in symbols:
codes.append(ord(symbol)) # ord() 返回相应编码的单个字符的数值
print(codes)
print('----------------')
symbols = 'A中国人'
codes = [ord(symbol) for symbol in symbols] # 更加简洁/易懂
print(codes)
# 列表推导有自己的作用域,内部变量x不影响外部的x
print('----------------')
x = 'my prec... |
e5e5ddbd5786d528888a864836fcdb0d7b534832 | eoaud0012/Backjoon-Algorithm | /백준-2941.py | 1,116 | 3.53125 | 4 | # 특정 요소 다 지우는 방법
# https://hashcode.co.kr/questions/1158/%EB%A6%AC%EC%8A%A4%ED%8A%B8-%EC%95%88%EC%97%90-%ED%8A%B9%EC%A0%95%EA%B0%92%EC%9D%84-%EB%8B%A4-%EC%A7%80%EC%9A%B0%EB%8A%94-%EB%B0%A9%EB%B2%95%EC%9D%B4-%EA%B6%81%EA%B8%88%ED%95%A9%EB%8B%88%EB%8B%A4
# x = [1,2,3,2,2,2,3,4]
# filter(lambda a: a != 2, x)
#
# x = [1,2... |
31bfaef13ee775d02da995856a9e51aaf22f39c5 | bvignau/The_Botnet_Game | /The_BotGame/Victime.py | 1,569 | 3.625 | 4 | class Victime():
def __init__(self, numero, vulnerables):
self.numero = numero
self.vulnerables = list()
self.infection = list()
for i in vulnerables :
self.vulnerables.append(i)
def AddBot(self,vul):
self.vulnerables.extend(vul)
def vulnerable(self,... |
be3ed4f9183d6b97780ca238683c78b7a2aec5fa | shill7/Game | /Learning Python.py | 7,728 | 4.0625 | 4 | """ Number = 5 #var Number = 5 """
"""
addition = 77+ 49
print (addition)
subtraction = 77-49
print (subtraction)
multiplication = 7*14
print (multiplication)
division = 28/7
print (division)
expo = 2**8
print (expo)
modulo = 7%3
print (modulo)
mealCost = 45
restaurant = 0.0675
tip = 0... |
6fb980d88cec41095985e48b397bb16bc02ab77b | iitwebdev/lectures | /WSGI/ianb/makeuni.py | 836 | 3.875 | 4 | __all__ = ['makeuni']
import random
characters = {
'a': 228,
'A': 916,
'e': 603,
'E': 276,
'i': 5029,
'I': 207,
'o': 4592,
'O': 10752,
'u': 3745,
'U': 1062,
}
def makeuni(s=None):
"""
Converts the vowels (AEIOU) in its bytestring input into Unicode
characters. ... |
2847abaf135057cedaa9cad7c22703727baf2808 | pluwum/slc | /breakfast.py | 752 | 3.625 | 4 | def mix():
print("get the ingredients")
print("mix the ingredients")
def cook():
print("Warm the pan on the stove")
print("pour oil and let it warm")
print("When oil is warm, pour the mixture")
def makeBreakfast(type_of_breakfast,ingredients = []):
mix()
cook()
print("Flip %s from side to side"%type_of_brea... |
7b54250a102cefcf35b7560e78eedc30645bc9df | IgnacioBorassi/Batalla_Naval | /tablero.py | 3,291 | 3.546875 | 4 | import random
import celdas
class Tablero():
'''Tablero de Batalla Naval'''
def __init__(self):
self.coordenadas = []
self.listatablero = []
self.crearCeldas()
self.contador = 0
self.numeros = ['1','2','3','4','5','6','7','8']
def crearCeldas(self):
'''... |
06b15f56eefeecd50e954fc1620bb4cd823233e6 | Grulice/python-practice-book | /67.py | 645 | 4.125 | 4 | # Problem 67: Write a program myip.py to print the external IP address of the machine. Use the response
# from http://httpbin.org/get and read the IP address from there. The program should print only the
# IP address and nothing else.
import re
import json
import urllib.request
def getExtIP():
response = urllib.... |
79c1811f437d7456a13840dec4adbb63c8cc647b | PutkisDude/Developing-Python-Applications | /week3/3_6_highestvalues.py | 1,619 | 4.21875 | 4 | #Author Lauri Putkonen
#Variables a, b and c have different values. Create a program that finds the
#biggest one.
#Show 3 different ways to solve the problem.
a = 4
b = 2
c = 0
print("variables a, b, c with values {}, {}, {}".format(a,b,c))
# simple MAX function with variables
print("max function:")
highest = max(a... |
7050fd404dcd421f5acdd57b0a6b38cc73325bb3 | MykhayloSharapov/Symbols-bruteforcer | /Symbols_bruteforcer.py | 1,219 | 3.859375 | 4 | # this module generates all possible combination of commands
# to be performed on numbers
# there are three kind of command: add('+'), minus ('-') and concatenate ('c')
# number of their combination equals
# three raised to the power of positions available
# n = number of positions available
n=8
def comb... |
1ec60f6284e0455c6d7d7e2d74db7bb8dff45bea | pythonbootcamp19/Boot_Camp_19 | /ex20.py | 927 | 4.25 | 4 | from sys import argv
script, input_file = argv
def print_all(f):
print(f.read())
#seek will go back to the position 0. Take the cursor to position 0. If you say f.seek(4) it'll print from character 5 (it starts with 0).
def rewind(f):
f.seek(0)
def print_a_line(line_count, f):
print(line_count... |
679c74ebc8686f8b52785d828307aedee22606fa | simonseo/Intro-to-CS-Projects | /matttt.py | 357 | 3.71875 | 4 | import matplotlib.pyplot as plt
import math
'''theta=0
increment=0.24
x=[]
y=[]
for r in range(200):
theta+=increment
if r%10==0: increment-=0.01
x.append(r*math.cos(math.pi*theta))
y.append(r*math.sin(math.pi*theta))
plt.plot(x,y)
plt.show()'''
def square(a):
return(a**2)
x=list(range(-100,100))
y=list(map(s... |
6d1589be1958b0b40771532d66041cf10ae7ab53 | henriquecl/Aprendendo_Python | /Exercícios/Lista 4 - Seção 7 - Coleções/Questão 1 - Enunciado no código.py | 451 | 3.78125 | 4 | # Questão 1 - Faça um programa que possua um vetor denominado A, que armazene 6 numeros inteiros
# a) atribuir os valores abaixo para ele
A = [1, 0, 5, -2, -5, 7]
print(A)
# letra b) somas a posições ditas
soma = A[0] + A[1] + A[5]
print(soma)
# letra c) modificar o valor de uma posição
A.pop(3)
A.insert(3, 100)
pri... |
4c2c4a1f913883785d8fac63dab7b7fa0033feb4 | Davide039/python-password-manager | /passwordManager.py | 2,617 | 4.03125 | 4 | from string import ascii_letters as letters, digits, punctuation
from random import choice
passwords = {}
file = open("passwords.txt", 'a+')
file.seek(0)
# check if file contains something and if it's the case, add data to passwords
for line in file.readlines():
passwords[line.split(": ")[0]] = line.split(": ")[1... |
aceefee7a984f387d38855a952a65a1b7435cadd | s1bel/Simple_Chatty_Bot_Python | /Problems/Healthy sleep/main.py | 234 | 3.65625 | 4 | min_sleep = int(input())
max_sleep = int(input())
current_sleep = int(input())
if current_sleep >= min_sleep:
if current_sleep <= max_sleep:
print('Normal')
else:
print('Excess')
else:
print('Deficiency')
|
20e58e680c954a5fde8dac4f72cbf24e2b18b3a9 | kimotot/aizu | /itp/itp1_9_d.py | 669 | 3.984375 | 4 | def fprint(str, a, b):
print(str[a:b+1])
def freverse(str, a, b):
n_str = list(str)
t = n_str[a: b+1]
t.reverse()
for i in range(b - a + 1):
n_str[a + i] = t[i]
return "".join(n_str)
def freplace(str, a, b, p):
n_str = list(str)
for i in range(b - a + 1):
n_str[a + i]... |
2acba5efeedef35002abed256a03fed8ef5d5918 | 810Teams/pre-programming-2018-solutions | /Onsite/1047-Password Validation.py | 239 | 3.84375 | 4 | """
Pre-Programming 61 Solution
By Teerapat Kraisrisirikul
"""
def main():
""" Main function """
if len(input()) < 8:
print('Password too short, try again.')
else:
print('Password is valid, you can use this password.')
main()
|
bfba0143f3992bf9236b4eb25f660f30fbe91a29 | Czhang0727/pythonAlgro | /mergeSortedArray.py | 1,073 | 3.765625 | 4 | class Solution:
"""
@param A: sorted integer array A which has m elements,
but size of A is m+n
@param B: sorted integer array B which has n elements
@return: void
"""
def mergeSortedArray(self, A, m, B, n):
# write your code here
posB = n-1;
posA = m-1;
... |
9e2c56b72f27165e11ea485a772a1b64588e6f72 | Artur-Aghajanyan/VSU_ITC | /Van_Marukyan/python/perfect_number/perfect.py | 232 | 3.65625 | 4 | def is_perfect_num(n):
s = 0
for i in range(1, n):
if n % i == 0:
s = s + i
if s == n:
print(n, "-is perfect number")
else :
print(n, "-isn't perfect number")
is_perfect_num(8128)
|
9e121e09474d952a65a62abcfd5b387bf8e6e2ca | eduardofmarcos/Python | /51 - criando_menu_opcoes.py | 1,630 | 3.9375 | 4 | import time
opcao = ''
while opcao != '5' and opcao != 'S':
numero1 = float(input('Digite o primeiro numero: '))
numero2 = float(input('Digite o segundo numero: '))
print('-='*20)
print('Selecione a opção desejada:\n'
'[1] - Somar\n'
'[2] - multiplicar\n'
'[3] - Maior\n'... |
3e224fedf589d76f8fc3fb6417b9068f3ccd7fd1 | newfull5/LeetCode | /1137. N-th Tribonacci Number.py | 1,079 | 3.5 | 4 | """
# Runtime: 28 ms, faster than 80.98% of Python3 online submissions for N-th Tribonacci Number.
# Memory Usage: 14 MB, less than 98.67% of Python3 online submissions for N-th Tribonacci Number.
class Solution:
def tribonacci(self, n: int) -> int:
if n == 0:
return 0
if n < 3:
... |
0817a8673491e5ebb1c24eee6780704672eaeab0 | ZaidanNur/PojectProjectan | /Rekursif/TugasDefRek1.py | 976 | 3.53125 | 4 | import os
Input_user = int(input("Masukkan jumlah menu : ")) # Memasukkan jumala menu
Data = list() # Menampung menu
# Data = [["1","0","Menu_1"],["2","1","Menu_2"]]
#3 -> (3 -1 ) -> (3-1)-1 -> (3-1)-1)-1 -> n = 0
def menu(n=Input_user,Parent=None,identitas=None): # fungsi buat menu
if n == 0: # Awal masuk... |
64135ca2d8ef07bc5583bd364919e1cc3680ac03 | jonm8116/Undergrad_Coursework | /CSE_373/python/editDistance.py | 2,217 | 3.625 | 4 | class cell(object):
cost=0
parent=0
__init__(self, cost, parent):
self.cost=0
self.parent=0
def set_cost(cost):
self.cost = cost
def set_parent(parent):
self.parent = parent
MAXLEN=50
cell m[MAXLEN+1][MAXLEN+1]
m = [[cell(0, 0) for j in range(MAXLEN)] for i in ran... |
1c25a3a285b329b3d5e08aa799881d3b99d500da | MallelaJayakumar/jaipython | /setoperartio.py | 322 | 3.578125 | 4 | '''
Created on 01-May-2019
@author: jai
'''
days=set(["tue","wed","thu","fri","sat","sun"])
print(days)
days.add("jaya")
print(days)
py=set(["mon","tom","jam","fri"])
print(py)
days.discard("tue")
print(days)
qq=days
print(qq)
alldays=py|qq
print(alldays)
dd=py&qq
print(dd)
ee=py-qq
print(e... |
49505557cfa4b45a0be796bc8c2bda7aaa0e54b2 | 418011010/2021 | /pand_excel.py | 710 | 3.546875 | 4 | import pandas as pd
from pandas import DataFrame
#读
data = pd.read_excel('1.xlsx')
#查看所有的值
print(data.values)
#查看第一行的值
print(data.values[0])
#查看某一列所有的值
print(data['姓名'].values)
#新增列
data['性别'] = None
#新增行
data.loc[6] = ['SNOW', 'C', 89, '男']
print(data.values)
#删除行:axis=0
data = data.... |
f20c915b100e82d65cec465677eda706cfaae1d5 | Anirudh-Swaminathan/kNN_py | /kNN.py | 4,266 | 4.125 | 4 | """ The program to classify the randomly generated data using the k-Nearest
Neighbours algorithm
"""
import sys
import numpy as np
import math
import matplotlib.pyplot as plt
def loadData(fname='train.txt'):
""" Function to load the randomly generated data
Keyword arguments:
fname -- The file name... |
c9c31d0ce7fbe8bd624227d49bff74f19b201871 | lauritsriple/TTK4145-Sanntid | /Exercises/EX01/ex1.py | 458 | 3.671875 | 4 | #!/bin/python
from threading import Thread
i=0
def func1 ():
global i
for j in range (0,100000):
i+=1
def func2 ():
global i
for j in range (1000000,0):
i-=1
def main():
thread1= Thread(target=func1,args=(),)
thread2= Thread(target=func2,args=(),)
... |
eb3d24a302ba9737440865b3cdc50d6068e33c8e | AmeenDarwish/Graph-implementation | /Vertex.py | 2,875 | 3.8125 | 4 | import collections
import warnings
'''
object:type
should take any data type since python allows it
'''
class Vertex(object):
"""
A class used to represent an Animal
...
Attributes
----------
key : primitive
the name of the animal
sound : str
... |
23ed3ee5db93e881fadfab31f388d4df4ea48112 | nashfleet/codefights | /arcade/the_core/book_market/findEmailDomain.py | 532 | 3.703125 | 4 | """
An email address such as "John.Smith@example.com" is made up of
a local part ("John.Smith"), an "@" symbol, then a domain
part ("example.com").
The domain name part of an email address may only consist of
letters, digits, hyphens and dots. The local part, however,
also allows a lot of different special c... |
d914d1ee1cbe020c75327634e60e5998b99fc411 | rainandwind1/Leetcode | /rota_AB.py | 271 | 4.03125 | 4 | A = 'abcde'
B = 'bcdea'
def rotateString(A, B):
A_ = list(A)
B_ = list(B)
for i in range(len(A)):
target = A_[0]
A_.remove(A_[0])
A_.append(target)
if A_ == B_:
return True
return False
print(rotateString(A,B)) |
6f4eafb9c0c2b4fccecc1e3e53ef71d5b15f7e08 | whitew1994WW/SudukuSolver | /sudukusolver.py | 3,748 | 3.625 | 4 | import pandas as pd
from coord import Coord
import itertools
class SudukuSolver:
"""
Suduku object class representing the grid of numbers
coord_list: List of coordinate, value pairs for starting the suduku
e.g. [{'x': 1, 'y': 2, 'value': 5}, {{'x': 5, 'y': 7, 'value': 5}}]
Note: The grid st... |
d0e32a6fe002427954237bb588a68d676d31d18e | fendouluo/py_demo | /countwords.py | 290 | 3.90625 | 4 | #!/usr/bin/env python3
s = input("Enter a line: ")
print("The number of words in the line are %d " % (len(s.split(" "))))
#%s 字符串(用 str() 函数进行字符串转换)
#%r 字符串(用 repr() 函数进行字符串转换)
#%d 十进制整数
#%f 浮点数
#%% 字符“%”
|
726b72fdfd8bbb40ccd2acad344e6d9ed5040053 | JustinDRui/Lab-5 | /lab 5 draft.py | 4,146 | 3.90625 | 4 | #Jusitn Ruiloba
#lab 5
#CS2302 Data structures
#4/5/19
class HashTableC(object):
# Builds a hash table of size 'size'
# Item is a list of (initially empty) lists
# Constructor
def __init__(self,size):
self.item = []
self.num_items= size
for i in range(size):
... |
9cf10d992bea1fec1d72b923e6a635bbbbf85b0b | dgeoffri/adventofcode | /2022/day08a.py | 1,912 | 3.53125 | 4 | #!/usr/bin/env python3
def count_visible_trees(data):
NUM_ROWS = len(data)
NUM_COLS = len(data[0])
visible_map = []
visible_map.append([True] * NUM_COLS)
for _ in range(1, NUM_ROWS - 1):
visible_map.append([True] + [False] * (NUM_COLS - 2) + [True])
visible_map.append([True] * NUM_COLS)... |
31294ff512e698e09316449695c882410d344c2c | vulmoss/practice | /0625/Node.py | 641 | 3.78125 | 4 | #!/usr/bin/env python
# coding=utf-8
class Node(object):
def __init__(self,initdata):
self.data = initdata
self.next =Node
def getData(self):
return self.data
def getNext(self):
return self.next
def setData(self,newdata):
self.data = newdata
def setNext(self,n... |
0abda62ef96f4d22109502039444cf1ddd1401bd | prasadhpshenoy1908/Algorithms | /LinkedListOperations.py | 3,569 | 3.625 | 4 | ##################################################################
#
#Linked List Operations
# Add
# Delete
# InPlaceReversal
# SplitBasedonPivot
#
###################################################################
###################################################################
#LinkedListNode
# V... |
d93cbf3a529cabe89bb8c8bc25743ba8a1ef103f | chriskopacz/python_practice | /Problems/lev1/lev1_q1.py | 546 | 3.9375 | 4 | #Chris Kopacz
#Python Exercises from Github
#Level 1, question 1
#created: 20 June 2017
"""
Question 1
Level 1
Question:
Write a program which will find all such numbers which are divisible by 7 but are not a
multiple of 5, between 2000 and 3200 (both included).
The numbers obtained should be printed in a comma-separ... |
4ba73d393867436778f371ba27f0a3c0b8e7c3e1 | bele-french/blab | /operations/while loops.py | 88 | 4.09375 | 4 | a =5
while a>0:
print("This is a:", a)
a = a - 1
print("This is a - 1:", a)
|
78d5dc02238008ed9d9f3517e26095248898d720 | domantasjurkus/python | /euler/25_euler.py | 354 | 3.578125 | 4 | fibs = {}
def fib(n):
if n < 3:
return 1
else:
if fibs.has_key(n):
return fibs[n]
else:
num = fib(n-1) + fib(n-2)
fibs[n] = num
return num
i = 1
while True:
num = fib(i)
if len(str(num)) >= 1000:
print "found it:"
... |
0c5b5aaaa28d836acbc363b24efe64d851cbe5cf | mikerojaswa/PythonSnippets | /Graphs/Graph_BFS_Iterative.py | 536 | 4 | 4 | #Breadth First Search on a graph w/ cycles
graph = {
'A': ['B', 'C'],
'B': ['D', 'E', 'B'],
'C': ['A', 'D', 'B', 'C', 'D', 'E'],
'D': ['E', 'D', 'F'],
'E': ['F'],
'F': ['A', 'B']
}
def BFS(graph, start, target):
visited = set(start)
current = graph[start]
while current:
#need to pop first element
s = c... |
055dfebf5910836622d2efb5176191e9bdd15e23 | dataAlgorithms/algorithms | /dynamicProgram/dynamicProgram.py | 7,062 | 3.984375 | 4 | '''
1. Find minimum sum such that one of every three consecutive elements is taken
Given an array of n non-negative numbers, the task is to find the minimum sum of
elements (picked from the array)
such that at least one element is picked out of every 3 consecutive elements in
the array.
Examples:
Input : arr[] = {1,... |
ecfcd6d9ed483db8e18a18094beec7f96708ae91 | ruizcauich/python-exercises | /ex009_a_very_big_sum.py | 2,266 | 4.1875 | 4 | """In this challenge, you are required to calculate
and print the sum of the elements in an array, keeping
in mind that some of those integers may be quite large.
https://www.hackerrank.com/challenges/a-very-big-sum/problem?
isFullScreen=true
Input:[1000000001, 1000000002, 1000000003, 1000000004, 1000000005]
Output: ... |
644e01d09ad1298a2928c24ace41d553e1c11b10 | anilkumar0470/git_practice | /practiceFibanacci.py | 298 | 3.875 | 4 |
def special(num):
print "hai"
a = 0# 0
print a # 0
b = 1
for i in range(num):
c = a + b#1 1 2 3 5 8 13 21
print c#1 1 2 3 5 8 13 21
b = a# 0 1 1 2 3 5 8 13
a = c# 1 1 2 3 5 8 13 21
d = input("enter a value ")
num = d
special(num) |
9e56d1983526143d4ab24c76cbec5ca71e646627 | jonjeans24/tcp-over-udp | /message.py | 3,249 | 3.546875 | 4 | # message.py
# Jonathan Jeans
# 11/10/2017
# Networking
# Assignment 2 - Phase 2
import random
import pickle
import checksum
class Message:
# initiate message with an empty list
def __init__(self):
self.original_message = []
# function used to create a packet
def create_packet(self, state,... |
df0e025e3c1813f02ba332faa41b361914449788 | Artimi/engeto_pa_praha_18_9_2019 | /07/50_caesar.py | 538 | 3.859375 | 4 | import string
message = 'abc def ghi jkl mno pqr stu vwx Yz'
alphabet = string.ascii_letters
def transform_letter(letter, delta):
letter_code = alphabet.index(letter)
new_code = (letter_code + delta) % len(alphabet)
return alphabet[new_code]
def caesar(text, delta):
result = ''
for letter in t... |
160df82dcf5e9b5f78fa7b3e23081db3b11f75a5 | VictorTruong93/list_exercises_python | /list_worksheet.py | 1,679 | 4.28125 | 4 |
# # Uppercase/Capitalize a string
# # print(string_example.upper())
# # print(string_example.capitalize())
# # print(string_example[::-1]) **reverses the entire string. to reverse order of string, turn into list
# # string_example=string_example.replace('a','4')
# # string_example=string_example.replace('e','3')... |
31f1c2ac8cc2a9ffd89affe180168cd7bf0572c8 | GhostDovahkiin/Introducao-a-Programacao | /Monitoria/Estruturas de Repetição/15.py | 115 | 3.578125 | 4 | fib = int(input("Numº: "))
ult = 0
pen = 1
for i in range(fib):
pen += ult
ult = pen - ult
print(ult)
|
0354ac8f24b4470d367351c13abe83e644b9964f | GustavoSousaPassos/Estudos | /python/ex015.py | 256 | 3.71875 | 4 | al = int(input('Digite o número de dias que o carro foi alugado: \033[1;30;35m'))
km = float(input('Digite o quantidade de quilometros rodados: '))
vt = (al*60) + (km*0.15)
print('O valor a ser pago será: R${}{:.2f}{}.'.format('\033[0;32m',vt,'\033[m'))
|
16f2fa110a759bf8677b59c66acb1afc5528882e | Lehcs-py/guppe | /Seção_04/Exercício_27.py | 400 | 3.875 | 4 | print("""
27. Leia um valor de área em Hectares e apresente-o convertido em Metros Quadrados m².
A fórmula de conversão é: M = H * 10000, sendo M A área em metros quadrados e H A área em hectares.
""")
hectare = float(input('Insira o valor da área em Hectares para A conversão em Metros Quadrados: '))
metro_quadr... |
af20fc9e86f9bfe3bf3db8d47c735bc92233c48d | eric496/leetcode.py | /graph/1319.number_of_operations_to_make_network_connected.py | 2,489 | 4.3125 | 4 | """
There are n computers numbered from 0 to n-1 connected by ethernet cables connections forming a network where connections[i] = [a, b] represents a connection between computers a and b. Any computer can reach any other computer directly or indirectly through the network.
Given an initial computer network connections... |
ed4c965d515ea7050dfb0ac2c51f607286fa6e0d | moon0331/PyYacht | /dice.py | 1,545 | 3.703125 | 4 | from score_function import __sum, __sum_of_number
from random import randint
from recordtype import recordtype
Dice = recordtype('Dice', 'number value is_fixed roll')
# 이전값 저장해야 함 (익명함수로 불가능) -> 클래스로?
def roll(dice):
if dice.is_fixed:
return str(dice.value)+'f'
else:
dice.value = randint(1,6)... |
cbfe8fc8edbec49441d6c557b5ca98292744256d | yingjun-wu/Blockchain-Ballot | /input.py | 2,903 | 3.546875 | 4 | # Import custom modules
import output
import ballot
import keys
import geth
# Get a saved ballot of the user's choice
def getBallotSelection():
# Show a list of all the ballots with indexes
output.allBallots(True)
# Ask the user which ballot they want to select
print ''
ballotId = raw_input("Plea... |
6c9653ac877480058ba84b91fa119eab4e6fcc9e | Sengming/leetcode_solutions | /253.meeting-rooms-ii.py | 2,426 | 3.96875 | 4 | """
Definition of Interval.
class Interval(object):
def __init__(self, start, end):
self.start = start
self.end = end
"""
import heapq
class Solution:
"""
@param intervals: an array of meeting time intervals
@return: the minimum number of conference rooms required
"""
def minMee... |
8ae02360f2823fca3f508d2df5541cddeaa32b1f | mohanapriya-09/Python | /single user xo/rowcheck.py | 734 | 3.84375 | 4 | def row(row, column, matrix):
for i in range(0, len(matrix), 1):
if row == i:
if column == 0:
return matrix[row][column] == matrix[row][column + 1] == matrix[row][column+2]
elif column == 1:
return matrix[row][column - 1] == matrix[row][column] == matr... |
0e51ff48b1e3e52a20dc6797edb407a7667af53a | tsaijc/IntroductionToPython | /src/m5_your_turtles.py | 1,654 | 3.796875 | 4 | """
Your chance to explore Loops and Turtles!
Authors: David Mutchler, Dave Fisher, Valerie Galluzzi, Amanda Stouder,
their colleagues and Jocelyn Tsai.
"""
########################################################################
# DONE: 1.
# On Line 5 above, replace PUT_YOUR_NAME_HERE with your own name.
#... |
38384fbac17838bdf65b3a4e4599d06efd942f62 | ravenswing/phd_tools | /pymol_scripts/draw_funnel_xy.py | 2,747 | 3.53125 | 4 | #!/usr/bin/python
# Script for drawing a funnel in PyMol.
#
# USAGE:
#
# draw_funnel selection [, dimension [, s_cent [, beta_cent [, wall_width,
# [, wall_buffer [, lower_wall [, upper_wall [, dim_step [, angle_sample ]]]]]]]]]
#
# ARGUMENTS:
#
# selection = string, a single atom or pseudoatom that will be the or... |
40c935536bbf1a8d2a20bfa99cef068188b95cda | jsanon01/python | /python-folder/test2.py | 185 | 4.3125 | 4 | # This script prints a for-loop
names = ['pascal lafontant', 'jude l jean-jacques', 'karlo simon']
prompt = input('Press Enter to display the names: ')
for name in names:
print(f'Your name is {name.title()}')
|
bd59541cd125cf9635fba011799256a57a106d15 | Hadis-Hashemi/PyBank-python- | /PyBank/main.py | 2,108 | 4.09375 | 4 | #This code read the data from a csv file and analyzes the records to calculate the following parameters:
#total months
#total net profit/loss
#max changes in profit/loss
#min changes in profit/loss
#finally, the results are exported to a text file
##Import packages and read input file
import os
import csv
# Path to c... |
491b80c7777466d5c8f09f325448f89115ea4303 | DiksonSantos/Curso_Intensivo_Python | /Pagina_253_Incrementando_Valor_Com_Atributo.py | 3,393 | 3.96875 | 4 | class Car():
def __init__(self, make, model, year):
"""Inicializa os atributos que descrevem um carro."""
self.make = make # Este MAKE depois do = é o mesmo dos Parametros a cima.
self.model = model
self.year = year
self.odometer_reading = 0
def get_descriptiv... |
512f9b9c8fba73f7c41dedaa9d9d2f67ff9acfaa | kszymankiewicz/workoutWithPython | /exercise.py | 488 | 4.03125 | 4 | import random
secretNumber = random.randint(1,20)
print('I am thinking about one number from the 1 to 20. You have 7 trails ')
for guessTaken in range(1,8):
print('Take guess. ')
guess = int(input())
if guess < secretNumber:
print('The number is too low. ')
elif guess > secretNumber:
... |
a55a74761e2dfea40d90f3a17201ec3b428069fd | sushmita2609/Coding-Prep | /test_calc1.py | 898 | 3.53125 | 4 | import unittest
import calc
class TextCalc(unittest.TestCase):
def test_addition(self):
self.assertEqual(calc.addition(10, 5), 15)
def test_subtract(self):
self.assertEqual(calc.subtract(18, 4), 14)
self.assertEqual(calc.subtract(-1, -8), 7)
self.assertEqual(calc.... |
a965af2d866f758c77ce4fd4f56378e43b52cc06 | 316060064/Taller-de-herramientas-computacionales | /Clases/Programas/Practica/Problema7.py | 1,101 | 3.953125 | 4 | #!/usr/bin/python2.7
# -*- coding: utf-8 -*-
'''
Josue Artemio Hernandez Rodriguez, 316060064
Lo que hice fue hacer la funcion con if, elif,
y else, donde los valores que dan 1 y 0 ponerlos dentro de
if y elif y todos los valores que no sean los que tiene de
condicion if y elif los puse en else.
El inciso b) solo es ha... |
00d31f5f2522216e0a815f423e27d89b88fc1781 | josephdviviano/interview-basics | /ds.py | 9,334 | 3.71875 | 4 | import sys
from string import ascii_lowercase, ascii_uppercase
class ListNode:
def __init__(self, value):
self.value = value
self.next = None
self.previous = None
class TreeNode:
def __init__(self, value):
self.value = Value
self.parent = None
self.children = [... |
9dc4e3d7daec5f239cdcd813cd5a09b8084ca7f2 | khanmaster/python_dev | /01_python_dev/06_OOP/03_library_&_modules_&_packages/pip_request_package/post_code_api.py | 1,135 | 3.921875 | 4 | import requests
url = 'http://api.postcodes.io/postcodes/'
postcode = 'e147le'
# postcode = input("please enter your postcode ")
url_arg = url + postcode
print(url_arg)
# make request and capture response
response = requests.get(url_arg)
# print(response)
# print(type(response))
# how can we parse the data
# print... |
13e0834cb9b74ca2fa22934b7978a031add3b24c | masijiaqiu/AI-projects | /q-learning-robot/my_assign3QL.py | 5,836 | 3.796875 | 4 | '''
HEADER:
Introduction to Artificial Intelligence: Assignment 3, Reinforcement Learning(QLearning)
Teach the kid to wear clothes in a proper manner.
(1) Representations of states:
At any given state of the program the state is defined as a 4 character string, where each character denotes the position of the cloth d... |
eed4d1d89d664674fd15034668c58e326c394819 | parky83/python0209 | /st01.Python기초/py11문자열/py11_05ex1.문자열연산자.py | 1,340 | 3.90625 | 4 | # 0번째부터 12번째 자리까지 있음.
# prov 길이는 13이다.
prov = "A barking Dog"
#################################
# 문자열 연산자
#################################
# 문자열 결합 연산자 : +
# "A barking Dog never Bites!"를 출력하시오.
str2 = " never Bites!"
str3 = prov+str2
print(str3)
# 문자열 반복 연산자 : *
str4 = str3*3
print(str4)
# 문자열 일치 연산자 : ==
s09 = ... |
1e08d355a768d4036673a81d55d42e87cf82b796 | jaebradley/leetcode.py | /maximum_length_of_repeated_subarray.py | 1,624 | 4 | 4 | """
https://leetcode.com/problems/maximum-length-of-repeated-subarray/
Given two integer arrays A and B, return the maximum length of an subarray that appears in both arrays.
Example 1:
Input:
A: [1,2,3,2,1]
B: [3,2,1,4,7]
Output: 3
Explanation:
The repeated subarray with maximum length is [3, 2, 1].
Note:
1 <= l... |
51c4bd3932c404ea9b51c1f256c75b9b4ffb3210 | AditiGarg09/Python | /palindrome_num.py | 335 | 4.21875 | 4 | def check_palindrome(num):
temp=num
rem=0
rev=0
while num>0:
rem=num%10
rev=rev*10+rem
num=num//10
if temp==rev :
return "Yes! Number is a Palindrome"
else:
return "No! Number is not a Palindrome"
num=int(input("Enter num: "))
print(check_pa... |
fe3befe1130546f7ec8761c19b4e3314ffd0c957 | lakhera2017/python3 | /boboccurence.py | 192 | 3.84375 | 4 | #!/usr/local/bin/python3.6
s = 'azcbobobegghakl'
count = 0
val = len(s)
for i in range(val):
if s[i:i+3] == "bob":
count += 1
print("Number of times bob occurs is: " + str(count))
|
593f703daed63236c28401c0aa8447fd759c23dd | jurentie/price_is_right | /Game.py | 2,639 | 3.765625 | 4 | from Player import Player
from randItem import RandAmazon
class Game:
def __init__(self):
self.amazon_items = RandAmazon('AmazonData.JSON')
self.player_list = []
self.num_players = 0
self.price = 20
def play_game(self):
self.item = self.amazon_items.generateRand()
... |
0e0665c1099fe6e6a779486a1c25b89e02a5c8c6 | ShushantLakhyani/200-Python-Exercises | /sq_root_complex_number.py | 296 | 4 | 4 | # Q4) Find the square root of a real or a complex number
#SOLUTION:
#import the complex numbers math module
import cmath
#let us have a complex number declared in a variable
num = 1 + 2j
#calculate the square root using .sqrt
num_sqrt = cmath.sqrt(num)
#print the square root
print(num_sqrt)
|
d316ad638b6df54487c6a00db455a87bc6138426 | minh14496/rpg_sql | /sprint/demo_data.py | 1,453 | 3.984375 | 4 | import sqlite3
demo_value = [('g', 3, 9), ('y', 5, 7), ('f', 8, 7)]
CREATE_demo = """
CREATE TABLE IF NOT EXISTS demo(
s VARCHAR(5) NOT NULL,
x INT NOT NULL,
y INT NOT NULL
);"""
INSERT_demo = 'INSERT INTO demo(s, x, y) VALUES (?, ?, ?)'
# Count how many rows you have - it should be 3!
row_count = "SEL... |
cba52c7e525c50275a3bcffb4df128ee9237acfd | mansip6495/DataStructure | /linkedlist.py | 1,518 | 4.03125 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
class single_linkedlist:
def __init__(self):
self.head = None
def add_node(self,data):
new_node = Node(data)
if self.head is None:
self.head = new_node
else:
te... |
2d4b50cd6fdc920ce7dcda0f2a423612ed27a66b | ahmcpsc/Python- | /Lessons/WorkingWithNumbers.py | 4,532 | 4.46875 | 4 | # python numbers:
# Variables of numeric types are created when you assign a value to them:
x = 1
y = 2.8
z = 1j
print(type(x))
print(type(y))
print(type(z))
# 1. Int
# Int, or integer, is a whole number, positive or negative, without decimals, of unlimited length.
x = 1
y = 35656222554887711
z = -325... |
bfa6fb059cf91af9e8aa3c715e7af5c345fcc887 | aaskorohodov/Learning_Python | /Обучение/Многомерные массивы.py | 1,181 | 4.125 | 4 | a = [1,2,3,"asd"]
print(a)
print(a[2])
arr_2d = [[1,2,3],
[4,5,6],
[7,8,9]]
print(arr_2d)
print(arr_2d[0][2])
arr_2d_2 = [[1,2,3],
[4,5,6,-1,-5],
[7]]
print(arr_2d_2)
def print_matrix(x):
for eo in x: #проходим по всем элементам списка
for... |
9513a56ddddd892fb2f78a33619a58e62217c095 | kandarpck/leetcode | /trees/symmetric_tree.py | 2,037 | 4 | 4 | # Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
def __repr__(self):
return "{}".format(self.val)
class Solution(object):
def isSymmetric(self, root):
"""
Time: N
Spa... |
bb537ad4ff7362bdb04c80efbe40c807c2394729 | rohitranjan19/mozio | /Desktop/My_SQL_DB.py | 2,946 | 3.53125 | 4 | '''
#Show Databases/ create databases
import mysql.connector
mydb = mysql.connector.connect(
host ="localhost",
user="root",
passwd="")
print(mydb)
#mycursor = mydb.cursor()
#mycursor.execute("SHOW DATABASES")
#for x in mycursor:
# print(x)
'''
'''
==============================================... |
8fe21999ab9a3323c43f47476e7a80235154a1ff | srijeetabiswas532/srijeetabiswas532.github.io | /Poker.py | 18,833 | 3.734375 | 4 | # File: Poker.py
# Description: This program simulates a 5-Draw Poker game and returns a winner.
# Date Created: 2/16/2019
# Date Last Modified: 2/18/2019
import random
from collections import Counter
# creates class Card which inherits from object
class Card(object):
# defining class variab... |
4384c76742086ca5bb1a92e3a4b7c621680000c3 | Rubenoo/Python | /Les4/5. Nested loop.py | 186 | 3.90625 | 4 | def nesting():
for row in range(1,11,1):
for item in range(1,11,1):
uitkomst = row * item
print('{} x {} = {}'.format(row, item, uitkomst))
nesting() |
8ffcd11e90d9e6557b74f3497c6aac7b2a002592 | Queena77Y/Data-Structure-and-Algorithm | /topic_exercises/dfs_bfs.py | 1,649 | 3.9375 | 4 | from collections import deque
class Node:
def __init__(self, val, children):
self.val = val
self.children = children
class Solution(object):
def dfs(self, root, target):
# *** Stack ***
# LIFO
if not root:
return False
stack = [root]
visited... |
39f9dd15887a938b02db8c0e15299d0f2cf55ec1 | Vanyali/100-Python-challenging-programming-exercises | /Question58.py | 619 | 4.0625 | 4 | '''
The Fibonacci Sequence is computed based on the following formula:
f(n)=0 if n=0
f(n)=1 if n=1
f(n)=f(n-1)+f(n-2) if n>1
Please write a program to compute the value of f(n) with a given n input by console.
Example:
If the following n is given as input to the program:
7
Then, the output of the program should be:... |
3dc922ef17a09cd6c13f81f4a092f42c46b15e1e | Sushmi-pal/pythonassignment2 | /Q18.py | 469 | 3.59375 | 4 | import json
info={"about_me":[{"name":"Sushmita Palikhe",
"age":22}]}
# File representation of json data
with open("info.json",'w') as f:
json.dump(info,f,indent=2)
# String representation of json data
serialize_info=json.dumps(info,indent=2)
print('Serializing')
print(serialize_info)
print('Deserializing'... |
aed6734640495affff997ad2debd43a31126bd49 | kucherskyi/python-for-qa | /lesson2-1/level1-3.py | 385 | 4.09375 | 4 | """
Print unique elements from any given list or tuple.
"""
import random
def unique(given):
return "List of unique elements :{}".format(list(set(given)))
"""
Examples
"""
l = [random.randint(0, 100) for i in range(50)]
t = tuple(random.randint(0, 100) for i in range(50))
print "List " + st... |
047f063e891be25b2a9cf7e79060360c886512ea | caitmcmahan/class-work | /count1.py | 214 | 4.1875 | 4 | def count(word, letter):
count = 0
for char in word:
if char == letter:
count = count + 1
print(count)
word = input('enter word:')
letter = input('enter letter:')
count(word, letter) |
4aef6fb48a8bfa1ba1fec806348839c5eb69ed6f | UX404/Leetcode-Exercises | /#167 Two Sum II - Input array is sorted.py | 1,235 | 4.0625 | 4 | '''
Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.
The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2.
Note:
Your returned answers (both inde... |
7028cac02722cd80f63e410317ccfdfeef86bfea | pedrohcf3141/CursoEmVideoPython | /CursoEmVideoExercicios/Desafio099.py | 691 | 3.875 | 4 | def maior(* nro):
from time import sleep
maior = contador = 0
print('=-' * 40)
print('Analizando os valores passados')
if len(nro) == 0:
mai = 0
else:
mai = max(nro)
for item in nro:
print(item, end=' ')
sleep(0.5)
if item > maior:
maior = ... |
082de7192860a2367a0b1dc9444669b551b295d4 | agcoder/python-digraphtools | /digraphtools/topsort.py | 1,997 | 3.828125 | 4 | #! /usr/bin/env python
def partial_order_to_grid(poset, n):
'''poset is given in 2tuples of indexes into a list containing a linear extension
as the indicies are into a list containing a valid topological sort,
i must be < j for every (i,j) in the poset'''
grid = [[False for j in xrange(n+1)]+[True] for i in xrang... |
faddc9663d0cfe2ab89cde5154c454c6a67bd92b | Rookiee/Python | /Python2.7/text2number.py | 123 | 3.78125 | 4 | #text2number
message = raw_input("Input your message: ")
print "Here is your number: "
for ch in message:
print ord(ch),
|
321d126ba6922858143087c0a700f247838a9f7b | dyhuang125/Content_Generator | /ComputationalCreativity/PythonPractice/practice.py | 559 | 3.625 | 4 | from Tkinter import Tk, Canvas, Frame, BOTH
class Example(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("Shapes")
self.pack(fill=BOTH, expand=1)
canvas = Canvas(self)
canvas.create_oval(40, 10, 110, 80, outl... |
b1edeaaac89a53cc074ef48d3193f76d3f1ca456 | chauncyfxm/niPython | /python/01.py | 608 | 3.609375 | 4 | #这是练习用的,向屏幕输出‘我是???’.
'''
print ('hello word')
print ('hello hahahahahahahahahahahahahah')
'''
print ('我是爱玲')
print ('我是宫本武藏')
print ('我是鲁班')
print ('我是赵云')
print ('我是关羽')
print ('我是妲己')
print ('我是小乔')
print ('我是大桥')
#print ('我是张飞')
print ('我是武则天')
print ('我是墨子')
print ('我是韩信')
print ('我是曹操')
print ('我是卢布')
print ('我是黄... |
c7c8d0d3b86296e97ca8e8221d5ce559dcf05fb9 | Faikamajid/Faikamajid-project1 | /city.py | 592 | 3.90625 | 4 | import pandas as pd
from IPython.core.display import display
df=pd.options.display.float_format='{:.2f}'.format
df= pd.read_csv("original.csv")
#display(df)
print("AVERAGE OF each column")
print(df[['population','average_temperature','average_rainfall']].mean())
print("MIN VALUE OF each column")
print(df[['population',... |
5451bd3b1ed60db3cd5cb28678a8505c6d6c5f1e | timmwrite/Python-Fundamentals-ICodeAI- | /set1.py | 728 | 3.84375 | 4 | #Add Items
#Pop an Element
#UPdate an Element
#Union
class Sets:
def __init__(self):
self.my_list = my_list()
def add_items(self, elements):
self.my_list = my_list.append(elements)
self.set_1 = set_1.append(elements)
def pop_item(self, element):
self.my_list.pop(el... |
100de6c5fb36af32c098a423e890c45f0b99f2ce | undercase/KevinWei | /formatCat.py | 351 | 3.546875 | 4 | # python formatCat.py cat.txt => outputs formatted contents
# of cat.txt to the console
import fileinput
if __name__ == "__main__":
lines = []
for line in fileinput.input():
lines.append("\"{0}\\n\" +".format(line.replace("\\", "\\\\")[:-1]))
lines[-1] = "{0}\"".format(lines[-1][:-5])
for line... |
521c8f262b6845c891a36e606cf542c8745c5658 | LXC19980829/Dating-with-python-this-winter | /homework/第 5 课/JonDoe297_第5次作业/JonDoe297_py_5_2.py | 331 | 3.875 | 4 | # -*- coding: utf-8 -*-
# @Time : 2021/1/1212 3:44 PM
# @Author : agrroc
# @File : py_5_2.py
# 用递归实现阶乘函数factorial(n),
# 对于任意的整数n都能返回其对应的阶乘。
def factorial(n):
if n == 1 or n == 0:
return 1
else:
return n * factorial(n-1)
print(factorial(6))
|
c1a1747b81ce719c1fabbc00dfdd802ccf643440 | biocodify/commit | /phase2.py | 433 | 4.125 | 4 | #To demonstrate the input and output statement in python
#A python program that computes the AREA OF A CIRCLE in PHASE 2
#Since PIE is constant as 3.142, and RADIUS is given to be any value
#Using the FORMULA : Area of a circle = pie * (radius**2)
#Constant value...
pie = 3.142
#Inputing...
radius = int(input("enter ... |
fe8ad300c4f562907073b4fe3adb5d4335532e08 | mdbacau/python2 | /object and data structures/sets.py | 344 | 4.28125 | 4 | # Sets are UNORDERED collections of UNIQUE elements
myset = set()
myset.add(1)
print(myset)
myset.add(2)
print(myset)
# Adding a value that already is in the set, it will not repeat it
myset.add(2)
print(myset)
# We can retrieve the unique variables in lists and other things
mylist = [1,1,1,1,1,1,2,2,2,2,2]
print(my... |
d90e840f517140586324f50a1f29a5cea35bf0b5 | lucaciraolo/BIO-MayanCalendar | /MayanCalendar.py | 2,441 | 3.71875 | 4 |
class MayanDate:
def __init__(self, dateString):
split = dateString.split(' ')
integers = map(lambda x: int(x), split)
self.baktuns, self.katuns, self.tuns, self.uinals, self.kins = integers
def days_since_origin(self):
mayan_origin = MayanDate('13 20 7 16 3')
# baktun_... |
07e96d52c30a5500b5abaec2cc4018e82a887dc9 | anshika-sharma24/loop | /Python/loop_folder/question_1.py | 177 | 4.3125 | 4 | sum = 0
number = 1
while number > 0:
number = int(input('Enter a positive number: '))
if number > 0:
sum = sum + number
print("The sum of the numbers is", sum)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.