blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
fd0b2f4db92b53e57857fb01fba022d9bd3e8394 | larrywork/Data_Analysis | /Outlier Detection and Treatment Using Python.py | 3,027 | 3.796875 | 4 | #importing libraries
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
#loading the dataset
df=pd.read_csv("all_seasons.csv")
#viewing a snapshot of the dataset
df.head()
print(df.shape) #Getting the number of rows and columns of the dataframe using the "shape command"
df.... |
b29d6d6ffbecc6c72760556f32bf4de64af03e07 | aviruprc/deloittetraining | /Python/Backslash/openpyxl/Backslash.openpyxl.py | 1,703 | 3.609375 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[38]:
#importing load_workbook and Workbook from openpyxl
from openpyxl import load_workbook
from openpyxl import Workbook
#importing the formatting libraries
from openpyxl.styles import Fill,Font,Color,colors
#generating the new excel file
wb3 = Workbook()
wb3.save(filena... |
a2cc6b58dae4d80cd0da230e3b25328f3ec5039e | dbarattini/ArduPy | /examples/temperature_sensor.py | 530 | 3.5625 | 4 | from ardupy import *
# arduino connected to port COM5 with baudrate 9600
arduino = Arduino("COM5", debug_mode=YES)
ts = arduino.addTemperatureSensor(A0, lambda voltage : (voltage - .5) * 100) # using a temperature sensor connected to pin A0 (analog)
... |
d5f1d10eae634fd53bbfc993b13b0955ad41d639 | harammon/Visual_Programming | /과제4/dict.py | 825 | 3.8125 | 4 | """
* 파일명 : Dict.py
* 작성일 : 2020년 11월 12일
* 작성자 : 문헌정보학과 20142611 이하람
"""
f = open('dict_test.TXT', 'r')
dictKey = []
dictValue = []
while True:
line = f.readline()
if line == '':
break
line = line[:-1]
s = line.split(':')
s[0] = s[0].rstrip()
s[1] = s[1].lstrip()
dictKey.append(... |
995b0fcf52b80a98c8f70ca679dbe8ed3341aa0a | inauski/SistGestEmp | /Tareas/Act03. Cadenas, For/ejer04/ejer04.py | 365 | 4.125 | 4 | print ("Ejer 4")
frase = input("Escribe un correo: ")
if frase.__contains__("gmail.com"):
print ("Termina en gmail.com")
else:
print ("No termina en gmail.com")
print ("Cantidad de '@': %s" % frase.count('@'))
print ("@ esta en: %s" % (frase.index('@')))
print ("Usuario: %s" % (frase.split("@")[0]))
pr... |
05e2ad3f21f80a3754a74f36f9563b726de91c87 | daniel-reich/turbo-robot | /vuSXW3iEnEQNZXjAP_20.py | 633 | 4.40625 | 4 | """
Create a function that takes a number and returns a string like square.
### Examples
create_square(-1) ➞ ""
create_square(0) ➞ ""
create_square(1) ➞ "#"
create_square(2) ➞ "##\n##"
create_square(3) ➞ "###\n# #\n###"
create_square(4) ➞ "####\n# #\n# #\n####"
... |
f1ea4298a1ffaa4e6286154c0f05dcb952538679 | francisco-igor/ifpi-ads-algoritmos2020 | /semana_5_condicionais/uri_1040_media_3.py | 775 | 3.6875 | 4 | def main():
n1, n2, n3, n4 = input().split(' ')
n1 = float(n1)
n2 = float(n2)
n3 = float(n3)
n4 = float(n4)
notas(n1, n2, n3, n4)
def notas(n1, n2, n3, n4):
media = (n1 * 2 + n2 * 3 + n3 * 4 + n4 * 1) / (2 + 3 + 4 + 1)
print('Media: {:.1f}'.format(media))
if media >= 7:... |
2da7031de3f2ab3751a6c1e52c8cb713504de13b | koushik-muthesh/python | /BST_insert.py | 617 | 3.90625 | 4 | class Node:
def __init__(self,data):
self.data=data
self.right=None
self.left=None
def insert(node,data):
if node is None:
return Node(data)
if data<node.data:
node.left=insert(node.left,data)
else:
node.right=insert(node.right,data)... |
4681d747d8f2bb01afde9b7420f559734514b8cc | porregu/unit7 | /claswork1.py | 125 | 3.515625 | 4 | original = "abcdefghij"
first = original[1:4]
print(first)
last = original[3:11]
print(last)
final = first+last
print(final)
|
c7188563ef6579310fbff9c864e513235507df14 | theCorvoX3N/Problem-Solving | /DivisibleSumPairs.py | 390 | 3.5 | 4 | # HackerRank
# - Algorithms > Implementation > Divisible Sum Pairs
# 16/12/17
(n, k) = map(int, input().strip().split(" "))
array = list(map(int, input().strip().split(" ")))
def check(i,j):
if (array[i] + array[j]) % k == 0:
return 1
else:
return 0
total = 0
for i in range(n):
j= i+1
... |
bd2aa5aebc30e28fc2982879e116a601e574ef77 | Arteche-Angelo/Programming-Examples | /Homework_3/Homework_3.py | 608 | 4.28125 | 4 | import random
directions =["North","South","East", "West"] #creates the list
int= random.randint(1,4) # makes a random int and stores int as a variable
print(int) #print the int
decision = input("would you like to continue enter 'y' for yes and 'n' for no \n") #ask user and store input
while(decision!="n"): #im assumi... |
f6bab1ef9fd6140bd7d182eda817a0427a874f27 | gaurav-gunhawk/Python | /PythonPratice/PracticeTuple.py | 310 | 3.96875 | 4 | # We can add hetrogeneous elements in the tuple.
# Elements are in the sequential form as inserted in the tuple.
# Use () for tuple defination
# Iteration in tuple is more faster than list.
# User cannot insert or delete the value once declared.
practiceTuple = (21,34,'ref')
print(practiceTuple)
|
ed71877bc614768f1ba7a51e7436106f1a3fa7ac | gauravtatke/codetinkering | /leetcode/LC14_longest_common_prefix.py | 1,516 | 3.6875 | 4 | from __future__ import annotations
class Solution:
def longestCommonPrefix(self, strs: List[str]) -> str:
return longest_common_prefix3(strs)
def longest_common_prefix1(strs: List[str]) -> str:
prefix = ''
if not strs:
return ''
min_len = min([len(s) for s ... |
d47baf7139a0a1d46b8627c3838e76583a9513ea | hgreen-akl/ProjectEuler | /Python/Problem 10.py | 429 | 3.625 | 4 | # The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
# Find the sum of all the primes below two million.
# This is a very Slow function due to the large amount of processing and memory storage
import sys, os
from tqdm import tqdm
from useful_functions.prime import is_prime
import numpy as np
prime_below_2m = 0
for... |
a6e9226349a67aa13a855c8a97104afe890602c1 | Mainnox/bootcamp_python | /Day00/ex09/guess.py | 1,133 | 3.921875 | 4 | from random import randint
import os
def header():
print("\t*******************************************")
print("\t*** GUESSING GAME ****")
print("\t*******************************************\n")
print("This is an interactive guessing game !")
print("You have to enter a number... |
534fb9c9b7127bc79d47e81fe43ac4ec7c9c6927 | bulygin69/dijkstra | /l3.py | 2,234 | 3.8125 | 4 | #!/usr/bin/python
# Листинг №3
# логика: (не существует Х) = (Х ≠ Х)
# (существует Х) = (Х = Х)
A = ('a', 'b', 'c', 'd')
B = ('e', 'c', 'd', 'f')
C = ('g', 'h')
D = ()
#
def set_intersect(set_1, set_2):
si = False
for in1Set in set_1:
for in2Set in set_2:
if in1Set == in2Set:
... |
67e5be5992ae51358e079271d5d879dd587b78f5 | dheerosaur/leetcode-practice | /python/653.two-sum-iv-input-is-a-bst.py | 3,190 | 3.59375 | 4 | #
# @lc app=leetcode id=653 lang=python3
# [algorithms] - Easy
#
# [653] Two Sum IV - Input is a BST
# https://leetcode.com/problems/two-sum-iv-input-is-a-bst/description/
#
# Given a Binary Search Tree and a target number, return true if there exist
# two elements in the BST such that their sum is equal to the given t... |
351ccee7742596996f427ef7a873c3370cb3d259 | Linzertorte/test | /generate.py | 1,205 | 3.71875 | 4 | #./generate grammar1 3
import sys
import random
def remove_comment(line):
last = line.find('#')
if last == -1:
return line
else:
return line[0:last]
def insert_rule(grammar, lhs, rhs):
if lhs not in grammar:
rules = []
rules.append(rhs)
grammar[lhs]=rules
el... |
cd3ccfba0fbbd3a96c3da6c06d8a51b6e6f5fe0d | HarshaniDil/DataStructure | /Stack_using_deque.py | 306 | 3.796875 | 4 | from collections import deque
stack = deque()
#To push some elements in to the stack
stack.append('P')
stack.append('I')
stack.append('N')
stack.append('K')
stack.append('I')
print(stack)
#POP
print(stack.pop())
print(stack.pop())
print(stack.pop())
print(stack.pop())
print(stack.pop())
print(stack) |
09ee5254261ac09911484152e84ae08351619c62 | Fareen14/Python-Projects | /Vowel Count.py | 685 | 4.0625 | 4 | print("Enter the string whose vowel count you want:\n")
s = input()
i=0
a_count = 0
e_count = 0
i_count = 0
o_count = 0
u_count = 0
for letter in s:
if letter == "a":
a_count += 1
if letter == "e":
e_count += 1
if letter == "i":
i_count += 1
if letter == "o":
o_count ... |
ef9851dd1c8739add9268f3fb1a681e5fcfb2530 | Jworboys/Learning_Python | /learning Python/11_loops/code.py | 879 | 3.921875 | 4 | number = 7
''' While loop'''
while True:
user_input = input("Would you like to play? (Y/n)")
if user_input == "n":
break
user_number = int(input("Guess our number: "))
if user_number == number:
print("You guessed correctly!")
elif abs (number - user_number) == 1:
... |
0a162b1fcdf3a3a39cdf2888495eabf555652f9b | elsandkls/SNHU_IT140_itty_bitties | /regex_extra_practice.py | 3,935 | 4.46875 | 4 | #Meta-character Description Example
#. Matches any character except a newline
#^ Matches start of a string
#$ Matches the end of a string
#* Matches 0 or more repititions of the character immediately preceding xy* will match xy, xyyyyy and will match x.
#Note: This is a greedy meta... |
9a13d411a318ebcae50b0b8231b00ce4c64bf34a | junkhp/atcorder | /abc_184_d.py | 719 | 3.59375 | 4 | # -*- coding: utf-8 -*-
class CalcMemo:
def __init__(self):
self.memo_dict = {(100, 100, 100): 0}
def calc_e(self, x, y, z):
if x == 100 or y == 100 or z == 100:
return 0
xyz = x + y + z
xyz_tuple = (x, y, z)
if xyz_tuple in self.memo_dict.keys():
... |
97c12337598845bbaded9033d2437d4465594272 | sdrendall/fishRegistration | /usefulTools/xlsxToCsv.py | 1,257 | 3.5 | 4 | #!/usr/bin/python
import xlrd
import csv
import argparse
def generate_parser():
parser = argparse.ArgumentParser(
description='Concatenates the sheets from the specified xlsx workbook into a csv file')
parser.add_argument('-x', '--xlsxPath', help='The path to the xlsx file', required=True)
parser... |
af6e0898263feceed4c35e1730eb270abc0488e8 | ntujvang/holbertonschool-higher_level_programming | /0x04-python-more_data_structures/0-square_matrix_simple.py | 144 | 3.65625 | 4 | #!/usr/bin/python3
def square_matrix_simple(matrix=[]):
new = []
for i in matrix:
new.append([n * n for n in i])
return new
|
5bd3e77d5701ca9486007351cb633d4c0af46158 | HLOverflow/school_stuffs | /Year3/AI/sudokusolver.py | 4,539 | 4.0625 | 4 | __author__ = "Tay Hui Lian"
__doc__ = '''This is sudoku solver I made from my free time after AI exam.
This uses constraint propagation where each move will propagate the
constraints(by removing the number) to other square's searchspace.'''
board = [[] for i in range(9)]
# initialization - note that changes to... |
c3c7bb7075a34bf3a31bcacc7b6f5fbf9859e1c2 | DeshanHarshana/Python-Files | /pythonfile/New folder/listexample.py | 512 | 3.65625 | 4 | lt=[]
def command(lst):
if lst[0] == 'insert':
lt.insert(int(lst[1]), int(lst[2]))
elif lst[0] == 'remove':
lt.remove(int(lst[1]))
elif lst[0] == 'append':
lt.append(int(lst[1]))
elif lst[0] == 'sort':
lt.sort()
elif lst[0] == 'print':
print(lt)
elif lst[0... |
e447647beb8a1ecc8275e79de33ad37e7fa73c3f | omurovec/COSC-marking-tool | /export-to-eclipse.py | 3,620 | 3.5 | 4 | import csv
from pathlib import Path
from zipfile import ZipFile
import os
import shutil
PACKAGE_PATH = "P:/PATH/TO/PROJECT/SRC/"
GRADEBOOK_CSV_PATH = "P:/PATH/TO/CSV.csv"
LAB_SECTIONS = ["L2M", "L2N"]
SUBMISSIONS_PATH = "Submissions.zip"
# Add/replace package name in java file
def correct_package(filepath, package_... |
e9ed3ba43cc25e6c4191ee34a064b68108f59c79 | sushantao/neosphere-exercises | /day6/funcUse.py | 200 | 3.984375 | 4 | def multiplyMe(x):
y = x * x
return y
r=multiplyMe(2)
print(r)
def multiplyMe1(x):
'''
This function returns a square.
'''
y = x * x
return y
print(help(multiplyMe1)) |
bf1c7c9e226cecb6eb887d292d029788ce520673 | DanielMoscardini-zz/python | /pythonProject/Curso Em Video Python/Mundo 1/ex026.py | 468 | 4.0625 | 4 | """
Faça um software que leia uma frase pelo teclado e mostre:
>Quantas vezes aparece a letra "a"
>Em que posição ela aparece a primeira vez
>Em que posição ela aparece a ultima vez
"""
frase = str(input('Digite uma frase: ')).strip().lower()
print(f'A letra "a" apareceu: {frase.count("a")} vezes\n'
f'A letra "a"... |
98e71a71e0ad7a6dc050c14aa335d9f2f08c3453 | NickJJFisher/DigitalSolutions2020 | /Chapter5/PaintJob.py | 455 | 3.828125 | 4 | Amount = int(input("How much in feet are you painting?"))
Cost = int(input("How much for a gallon of paint?"))
Paint = (Amount / 112)
print (Paint, "Galloons of paint is required")
Hours = (Paint / 8)
print (Hours, "hours of labour is required")
PaintCost = Paint * Cost
print (PaintCost, "dollars is required for the pa... |
1f7a3e0609e7fae1e17d41c09bd66131fe99d3fd | sbaldrich/udacity | /ud120/svm/svm_author_id.py | 1,778 | 3.625 | 4 | #!/usr/bin/python
"""
This is the code to accompany the Lesson 2 (SVM) mini-project.
Use a SVM to identify emails from the Enron corpus by their authors:
Sara has label 0
Chris has label 1
"""
import sys
from time import time
sys.path.append("../tools/")
from email_preprocess import preproce... |
219f1b0a470b1f24234096bb5552f90d6c3b8eba | 1144063098/python_source | /python_oop/file2.py | 125 | 3.9375 | 4 | a={"name":"张三","age":18,"addr":"长沙"}
s={k:v for k,v in a.items() if k=="age" or k=="addr"}
print(a.get("named",18))
|
e6ba8174109e67cf82093e7e0dd616e673418595 | huangxiaoxin-hxx/javascript_fullstack | /leetcode/candies/a.py | 260 | 3.5 | 4 | from typing import List
class Solution:
def distributeCandies(self, candies:List[int]) -> int:
# min 函数式 内置函数
return min(len(candies)>>1, len(set(candies)))
x = Solution()
print("最大的种类数",x.distributeCandies([1,1,2,2,3,3])) |
092c80df82022a827edf999d92b29ea2a0a25e39 | gioliveirass/atividades-pythonParaZumbis | /Lista de Exercicios IV/Ex02.py | 290 | 3.796875 | 4 | # Exercicio 02
print('Exercicio 02')
import random
num, impares, pares = [], [], []
num = random.sample(range(100), 20)
for x in num:
if x%2 == 0:
pares.append(x)
else:
impares.append(x)
print(f'Números: {num}')
print(f'Impares: {impares}')
print(f'Pares: {pares}') |
6e609e851af5edd4a5db63cfc72ab93ef84beceb | guimunarolo/studies | /data_structures/stack/balanced_symbols_string.py | 426 | 3.671875 | 4 | from . import Stack
SYMBOLS_PAIRS = {"(": ")", "[": "]", "{": "}"}
def is_balanced(symbols_string):
openers = SYMBOLS_PAIRS.keys()
my_stack = Stack()
for symbol in symbols_string:
if symbol in openers:
my_stack.push(symbol)
continue
last_opened = my_stack.pop()
... |
cf0d8096278dd7847101c2c590e31b966910d3ad | toolbox-and-snippets/Toolbox-Python | /src/lists.py | 3,083 | 4.21875 | 4 | ### Lists ###
# List of Lists #
# https://stackoverflow.com/questions/691946/short-and-useful-python-snippets
# Create 2-dimensional matrix
lst_2d = [[0] * 3 for i in xrange(3)]
print lst_2d
# Assign a value within the matrix
lst_2d[0][0] = 5
print lst_2d
# Enumerate #
# https://stackoverflow.com/questions/691946/... |
d8ab5ec281b21f17f17008519ef108f37d918e16 | kimje0322/Algorithm | /기타/0226/Queue.py | 168 | 3.640625 | 4 | def enqueue(n):
global rear
if rear == len(queue)-1:
print('full')
else:
rear += 1
queue[rear] = n
queue = [0]*3
front = rear = -1
|
7a2b5a841817f4daa80a4679c648bbf5552765d8 | Abishek1608/Problem-solvjng | /greater 3 no.py | 230 | 4.21875 | 4 | n1=int(input('enter the value'))
n2=int(input('enter the value'))
n3=int(input('enter the value'))
if(n1>n2 and n1>n3):
print('n1 is greater')
elif(n2>n3 and n2>n1):
print('n2 is greater')
else:
print('n3 is greater')
|
0192d036de02c0f0fb50947fd496767a69b0ad79 | claudiayunyun/yunyun_hackerrank | /python/SwapCase.py | 596 | 4.125 | 4 | # lambda expression
##syntax : lambda arguments : expression
# map function
# map(function, iterables)
# function Required. The function to execute for each item
# iterable Required. A sequence, collection or an iterator object.
# You can send as many iterables as you like,
# just make sure the f... |
e055fa59e7f2d6ed3bb871394dba58a69f37eeb2 | moskalikbogdan/CDV | /Python/Warsztaty/Week02/W02.Z05.2.py | 476 | 3.703125 | 4 | """
@author: Bogdan Moskalik,
DataScience,
Niestacjonarne,
Grupa 2
"""
n = int(input("Prosze podac liczbe: "))
def silnia_rek(n):
if n>1:
return n*silnia_rek(n-1)
elif n in (0,1):
return 1;
def silnia_iter(n):
silnia=1
if n in (0,1):
return 1
else:
for ... |
1cf3d2df6666254381eec65f8a731dd49ec4d13b | StephenAjayi/learning_py1 | /connected_caves.py | 1,079 | 3.8125 | 4 | from random import choice
# setup caves
cave_numbers = range(0,20)
caves = []
for i in cave_numbers:
caves.append([])
unvisited_caves = range(0,20)
visited_caves = [0]
unvisited_caves.remove(0)
while unvisited_caves != []:
i = choice(visited_caves)
print len(caves[i])
if len(caves[i]) >= 3:
... |
5bcf516cb1dbd462a296dd2861e7485e38a436ba | InduprasadSR/PythonFunFacts | /Fact_2.py | 131 | 4.21875 | 4 | #Palindrome
SomeString = 'MALAYALAM'
print("Palindrome!") if SomeString == SomeString[::-1] else print("Not a palindrome!")
|
cce31d4661c35965d2aa0cfa09da8d91b0d09bcf | gerosantacruz/Python | /criptrography/transpositionDecrypt.py | 1,418 | 4.1875 | 4 | # Transposition Cipher Decryption
# https://www.nostarch.com/crackingcodes/ (BSD Licensed)
import math, pyperclip
def main():
message = input('Enter the message to decrypt \n')
key = int(input('Please enter the key: \n'))
plain_text = decrypt_message(key, message)
print(plain_text + '|')
def dec... |
8ea75cb1b5dad651cf7ac45ee8f17ac2a52e4698 | andreas-anhaeuser/py_utils_igmk | /test/test_translation.py | 1,182 | 3.546875 | 4 | #!/usr/bin/python3
"""Testing suite for translation module."""
import unittest
from misc.translation import translate
class Translation(unittest.TestCase):
def setUp(self):
self.filename = 'test_files/dictionary.txt'
self.kwargs = {}
def test_regular(self):
self.term = 'Brot'
... |
fe5889e234696b7fc2904a9d13fb755b8fc1514b | jayanti-prasad/ml-algorithms | /raw/kmeans_example.py | 4,357 | 3.59375 | 4 | import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import argparse
np.random.seed (seed=292)
"""
This program is a full demo of K-means clustering without using any library.
Comments & Feedback:
- Jayanti Prasad Ph.D [prasad.jayanti@gmail.com]
"""
def get_data ():
"""
Create two dimensio... |
6aadec8764ddc87e34ffeabc2ce27ffd30a901bc | XidongHuang/PythonStudy | /projects/ex48/ex48/lexicon.py | 1,042 | 3.59375 | 4 | """*************************************************************************
> File Name: lexicon.py
> Author: XidongHuang (Tony)
> Mail: xidonghuang@gmail.com
> Created Time: Wed 12 Oct 20:53:48 2016
************************************************************************"""
# -*- coding: utf-8 -*-
... |
8f70ae2e8eceed564e916e54843eeb1747193b41 | arifkhan1990/Competitive-Programming | /Data Structure/Linked list/Circular Linked List/practice/Spoj/CLSLDR_Class_Leader.py | 2,769 | 3.671875 | 4 |
# Name : Arif Khan
# Judge: SPOJ
# University: Primeasia University
# problem: CLSLDR - Class Leader
# Difficulty: Easy
# Problem Link: https://www.spoj.com/problems/CLSLDR/
#
# this solution ... |
6a28792808879b45b8ea333c713b40afcc714bdd | dorabelme/Learn-Python-3-the-Hard-Way | /ex6.py | 750 | 4.03125 | 4 | # types of people
types_of_people = 10
x = f"There are {types_of_people} types of people."
# variable called binary
binary = "binary"
# variable don't
do_not = "don't"
# there are people who know binary and who don't
y = f"Those who know {binary} and those who {do_not}."
# printing x and y statements
print(x)
print(y... |
5df0461bc7bc0cc5fbc298e0983bc38b70187c64 | jdukosse/LOI_Python_course-SourceCode | /Chap12/riskyread.py | 165 | 3.59375 | 4 | # Sum the values in a text file containing integer values
sum = 0
f = open('mydata.dat')
for line in f:
sum += int(line)
f.close() # Close the file
print(sum)
|
a84baa95dcf9dae9b229c0bbb568578cf4dc68c9 | JankaGramofonomanka/numbering_patterns | /pckg/source/linear_formula.py | 28,309 | 3.78125 | 4 | from . import misc
class LinearFormula():
"""A class to represent a linear formula (a first degree polynomial)"""
#-INIT--------------------------------------------------------------------
def __init__(self, *args):
"""Initializes the formula"""
self.multipliers = []
se... |
0de034c6b9b380313387957d56941775047f5f63 | a100kpm/daily_training | /problem 0137.py | 1,258 | 3.953125 | 4 | '''
Good morning! Here's your coding interview problem for today.
This problem was asked by Amazon.
Implement a bit array.
A bit array is a space efficient array that holds a value of 1 or 0 at each index.
init(size): initialize the array with size
set(i, val): updates index at i with val where val is eithe... |
0e4c2aa723791f021934087b676836faab15b45b | kodfactory/AdvayaAndShubh | /OddOrEven.py | 140 | 4.15625 | 4 | num = 122
#9 -> int
#"9" -> string
#print(9%2)
#print(10%2)
if num%2 == 1:
print("Number is odd")
else:
print("Number is even")
|
9037989137481cbe2f3ce7be1c39ed7c2c8e8a4c | ywozvc/perceptron | /perceptron.py | 3,114 | 3.859375 | 4 | import numpy as np
from collections import Counter
from math import sqrt
import perceptron_errors
class Perceptron:
"""
Description:
---
Perceptron with a sigmoid activation function for binary classification
"""
def __init__(self, n_tuple, weights=None):
"""
Parameters
... |
65b876469a2c613aeb2acd10bb4609569d933028 | dyrroth-11/Information-Technology-Workshop-I | /Python Programming Assignments/Assignemt1/22.py | 523 | 4.09375 | 4 | #!/usr/bin/env python3
"""
Created on Wed Mar 25 10:17:27 2020
@author: Ashish Patel
"""
"""
Write a Python program to convert a list of multiple integers into a single integer.
Sample list: [11, 33, 50]
Expected Output: 113350
LOGIC:1)we take a list as a input.
2)Then concatenate every element of it in... |
85c7f984ad99195198970f8adf32f42e3c9d9931 | raghavendra990/python-practice | /linked_list/linked_list.py | 2,667 | 4.0625 | 4 | #Node class
class Node:
def __init__(self, data):
self.data = data
self.next = None
# linked list class
class LinkedList:
#function to initialize the linke dlist onject
def __init__(self):
self.head = Node
#t thios function will print hte contents of the linked lisr
def PrintList(self):
temp = self.h... |
64777d1e439e36ea1f7850bb8718968d0b2bec31 | YJL33/LeetCode | /old_session/session_1/_461/_461_hamming_distance.py | 903 | 3.953125 | 4 | """
461. Hamming Distance
Total Accepted: 5441
Total Submissions: 7355
Difficulty: Easy
Contributors: Samuri
The Hamming distance between two integers is:
the number of positions at which the corresponding bits are different.
Given two integers x and y, calculate the Hamming distance.
Note:
0 <= x,... |
82a166324187ccbaecb15c00f31a4885eab075f7 | Vijay1234-coder/data_structure_plmsolving | /GRAPHS/DirectedGraph.py | 889 | 3.953125 | 4 | class Graph:
def __init__(self,Nodes,is_directed =False):
self.nodes = Nodes
self.adj_lis = {}
self.is_directed = is_directed
for node in self.nodes:
self.adj_lis[node] = []
def add_edge(self,u,v):
self.adj_lis[u].append(v)
if self.is_directed==False... |
f96de0483e99d36dbc7598014f4a8a954fc10790 | Uxooss/Lessons-Hellel | /Heap/Clocks.py | 717 | 3.96875 | 4 | # С начала суток прошло n минут. Определите, сколько часов и минут будут показывать электронные часы в этот момент.
# Программа должна вывести два числа: количество часов (от 0 до 23) и количество минут (от 0 до 59).
# Учтите, что число n может быть больше, чем количество минут в сутках.
n = int(input('\nСколько минут... |
85e34346f15da1f2d67a440d6e7d290a5892419e | tkshim/leetcode | /leetcode_0000_stack.py | 457 | 3.71875 | 4 | #!/usr/bin/env python
#coding: utf-8
class mystack():
def __init__(self):
self.stack = []
def push(self, x):
self.stack.append(x)
def pop(self):
del self.stack[-1]
result = self.stack[-1]
return result
ins001 = mystack()
for i in range(20):
ins001.push(i)
pri... |
e44eea49e61472185b3c961a2226d949351defe3 | johann9911/JohannBogota | /ejercicios.py | 4,772 | 4.3125 | 4 | #!/usr/bin/env python
# coding: utf-8
# # EJERCICIOS DEL LIBRO
#
#
# De acuerdo al libro Qsdfsf se realizaran estos ejercicios de programación con el lenguaje python.
#
# 1.1 Programa que sume dos numero complejos. funcion suma_C
# 2.2
#
#
#
#
# ### 1.1 SUMA DE COMPLEJOS
# Se define los dos numeros complejos ... |
a3dffa2d9fa511e1d2f58e7055f9a3a744bf6560 | sharmisthaec/python | /ML codes/introduction/exampl1.py | 570 | 3.5625 | 4 | #standard deviation
import numpy as np
heights = [5.9, 5.5, 6.1, 6.0, 7.2, 5.1, 5.3, 6.0, 5.8, 6.0]
print("Sample average: %.2f" % np.mean(heights))
print("Sample standard deviation: %.2f" % np.std(heights, ddof=1))
print("Improper standard deviation: %.2f\n" % np.std(heights))
large_num_heights = np.random.r... |
937fc7f1f73084f4ceef6888bf7ad8909d29655c | AmberJing88/algorithm-datastructure | /Array/ArrayReview378.py | 2,339 | 3.515625 | 4 | # Array problems
"""leetcode 378: sorted matrix in ascending order, find the kth smallest element in the matrix"""
def KthSmallest(matrix, k):
m,n = len(matrix), len(matrix[0])
low, high = matrix[0][0], matrix[m-1][n-1]
while low <= high:
cnt = 0
mid = low + (high - low)//2
f... |
09e96357bb490e4a45840d53d4af52a3335e5d7d | manutdmohit/pythonprogramexamples | /accessdatafromthedictionary.py | 189 | 4.0625 | 4 | d={100:'durga',200:'ravi',300:'shiva'}
key=int(input('Enter key to find value:'))
if key in d:
print('The corresponding value:',d[key])
else:
print('The specified key not available') |
0a2b8df4218ebc0a917c54a3902a59bc59a99a31 | swapnil-sat/helloword | /Python-Set Methods_20-3-21.py | 1,798 | 3.90625 | 4 | # ====================================================================================||
# || Python- Set Methods ||
# || ||
# || ... |
012d9b5aa13c557ad958343cadf935b73c808a56 | fsym-fs/Python_AID | /month01/teacher/day14/exercise03.py | 435 | 3.625 | 4 | """
定义函数,根据年、月、日计算星期。
0 星期一
1 星期二
....
"""
import time
def get_week(year, month, day):
str_time = "%d-%d-%d" % (year, month, day)
time_tuple = time.strptime(str_time, "%Y-%m-%d")
tuple_week = ("星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日")
return tuple_week[time_tuple[6]]
... |
e046f49d63dddaf7abcfc9d8cd230f9f17d47562 | CP1401/subject | /other/score_smiles_functions.py | 2,040 | 4.0625 | 4 | """
CP1401 Example (from Help Session 01/09/2020)
Score -> Result program with menu, accumulation, etc.
(a bit similar to smiley, frowny from prac 4)
Now with added functions.
This version improves on the previous one by removing the duplication (DRY)
of the section that prints the status.
"""
MINIMUM_SCORE = 0
MAXIMU... |
ea69e3751358847c794ad11d04b7922710697d49 | kseniiaguk/Hellodarkness | /2.py | 814 | 3.5625 | 4 | def calc(x,y,z):
if y=='+' or y=='-' or y=='*' or y=='/':
if y=='+':
return (x+z)
if y=='-':
return (x-z)
if y=='*':
return (x*z)
if y=='/':
try:
return (x/z)
except ZeroDivisionError:
... |
80225c7cf6741855bac7d6d9283ca6c7cf5b47c0 | extra-virgin-olive-eul/pe_solutions | /17/PE-P17_VSX.py | 5,481 | 3.609375 | 4 | #!/usr/bin/env python3
'''
Program: PE-P17_VSX.py
Author: vsx-gh (https://github.com/vsx-gh)
Created: 20171114
Project Euler Problem 17:
If the numbers 1 to 5 are written out in words: one, two, three, four, five,
then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
If all the numbers ... |
a1b7ca05d958105b0f412ba9f61d147734935d5c | bkopjar/django-websites | /lab3/zad1.py | 616 | 4.0625 | 4 | grades = { "Pero": [2,3,3,4,3,5,3],
"Djuro" : [4,4,4],
"Marko" : [3,3,2,3,5,1]
}
# Ispisi ime studenta koji ima najvisi prosjek. Zadatak treba proci kroz
# sve studente, izracunati prosjek i ispisati ime studenta s navisim prosjekom.
# -- vas kod ide ispod -- #
def averag... |
20f065f464a6430e7fb41bee06727500c5bbbc0d | nekapoor7/Python-and-Django | /GEEKS/filehandling/read content.py | 1,260 | 4.3125 | 4 | """Python Program to Read the Contents of a File"""
with open("C:\\Users\\nekapoor\\git\\Python-and-Django\\PYTHON PROGRAMS\\file_data\\data.txt",'r',encoding='utf-8') as file1:
for line in file1.read():
print(line,end='')
"""Python Program to Count the Number of Words in a Text File"""
with open("C:\\U... |
b8d9a39a8c418dc2d2d484fd6270307f7734d979 | sainttobs/learning_python | /functions/whileloop_infunctions.py | 492 | 4.0625 | 4 | # using while loop with a function
def get_name(firstName, lastName):
fullname = firstName + ' ' + lastName
return fullname.title()
while True:
print("\nWhat is your name")
print("Press q at any time to quit this program")
firstName = input("Enter your first name: ")
if firstName == 'q'... |
2de2996ed1d47edfc1493a787c5f175b5bc3e0f4 | di0theDestroyer/blobfish-retropi | /blobfish_ascii_trend_plotter.py | 761 | 3.734375 | 4 | import aplotter
import math
class AsciiTrendPlotter(object):
def __init__(self):
print ("entered ctor")
def plot(self):
print("entered plot()")
print('****** Sin([0,2pi]) ******')
scale=0.1
n=int(2*math.pi/scale)
plotx=[scale*i for i... |
c23f458e847b1376d369e000283ba5c6d9e9e42a | sifact/Leet-Code-Problems | /leetCode/Array/Medium/Remove Duplicate from Sorted Array 2.py | 514 | 3.625 | 4 | def removeDuplicates(nums):
tail = 0
for num in nums:
if tail < 2 or num > nums[tail - 2]:
nums[tail] = num
print(nums)
tail += 1
return tail
def removeDuplicates2(nums):
tail = 0
for num in nums:
if tail < 2 or num > nums[tail - 2... |
2b4f306edd2e239194d681a2f72c8c2a1abb392b | OZ-T/leetcode | /1/116_populating_next_right_pointers_in_each_node/main.py | 1,825 | 3.984375 | 4 | class Node:
def __init__(self, val: int = 0, left: 'Node' = None, right: 'Node' = None, next: 'Node' = None):
self.val = val
self.left = left
self.right = right
self.next = next
class Solution:
def connect_recursive(self, root: 'Node') -> 'Node':
if not root:
... |
137efa4c330a1cf06050d0389e3bc5af0577e1b6 | trickaugusto/python | /exercicios urionlinejudge/1010.py | 974 | 3.828125 | 4 | # Neste problema, deve-se ler o código de uma peça 1, o número de peças 1, o valor unitário de cada peça 1, o código de uma peça 2, o número de peças 2 e o valor unitário de cada peça 2. Após, calcule e mostre o valor a ser pago.
# Entrada
# O arquivo de entrada contém duas linhas de dados. Em cada linha haverá 3 valo... |
1a68ff56556e1a2f9b54264eff08b3e327a13510 | jwylie/Project-Euler | /Python/Problem10.py | 399 | 3.625 | 4 |
def main():
max = 2000000
numbers = set(range(3, max + 1, 2))
for number in range(3, int(max ** 0.5) + 1):
if number not in numbers:
continue
num = number
while num < max:
num += number
if num in numbers:
numbers.rem... |
43014808916570fd49e9d1551a9024b419b98d7f | AleBark/Python-Basics | /list_05/ex_07.py | 641 | 3.890625 | 4 | # -*- coding: utf-8 -*-
# An algorithm that reads 4 whole numbers and calculates the sum of those that are even.
def main():
input_list = []
print("----------")
for idx in range(1, 4):
integer = input("Input: ")
if input_is_a_valid_int(integer):
if int(integer) % 2 == 0:
... |
33a0ade36fd60e1fa50891c0074e1e0e41b90c4d | khaldi505/holbertonschool-web_back_end | /0x02-python_async_comprehension/0-async_generator.py | 303 | 3.5625 | 4 | #!/usr/bin/env python3
"""
async_generator module
"""
import asyncio
import random
from typing import Generator
async def async_generator() -> Generator[float, None, None]:
"""
async_generator
"""
for x in range(10):
await asyncio.sleep(1)
yield(random.uniform(0, 10))
|
7936553f10a8ee301aa0dd3067ae525140f7f524 | f-sanges/UDEMY_EXERCISES_The_Complete_Python_Course_Go_From_Beginner_To_Advanced | /find_method.py | 995 | 4.03125 | 4 | value = "cat picture is cat picture plus picture"
# Find first index of the string
i = value.find("picture")
print("First occurrence of picture: " + str(i))
c = value.rfind("picture") # rfind
print("rfind di picture: " + str(c))
# Find first index of this string after previous index
b = value.find("picture", i + 1... |
732c6772e1de80cd4248d8f6d72b9ab644941033 | soumasish/leetcodely | /python/integer_to_english_words.py | 1,403 | 3.609375 | 4 | """Created by sgoswami on 7/4/17."""
"""Convert a non-negative integer to its english words representation. Given input is guaranteed
to be less than 2^31 - 1."""
class Solution(object):
def __init__(self):
self.units = ['', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', '... |
3de2b884bdc5c1029195dcddfe2f9ac9e8e76482 | handaeho/lab_python | /scratch11_KNN/ex02_knn_위스콘신.py | 2,479 | 3.828125 | 4 | """
R을 활용한 머신러닝에서 사용한 '위스콘신 대학교의 암 데이터'에 대한, scikit-learn 패키지 활용
"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.metrics import confusion_matrix, classification_report
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from skle... |
292efa80277d35a69280b7d5c839230e0041fbc9 | frithjofhoppe/M122_python | /fibonacci-2.py | 274 | 3.84375 | 4 | def fibonacci2(wert):
if(wert == 0):
return 0
elif(wert == 1):
return 1
else:
return (fibonacci2(wert-1) + fibonacci2(wert-2))
counter = 0
while True:
print (fibonacci2(counter))
counter+=1
if(counter == 25):
break
|
fb0ce579bb1a84d4f311e451c21bfbecdc72f38d | Harinarayan14/p97 | /p97.py | 882 | 4.1875 | 4 | # import random for finding a random number
import random;
# Random Number
number = random.randint(1,100);
# Text
print("Number Guessing Game");
print("Guess from 1 to 100");
print("You have 10 chances.");
#Chances
chances =0;
# While Loop
while chances < 10:
# Input
guess = int(input("Enter your guess ")... |
c4619c8b6923dd252b1f4af268cd2b6c0867e576 | mmunsi2/python | /pythonic/Code23_2_depth_first_search.py | 1,306 | 3.546875 | 4 | from graph import Node, buildGraph
class FoundNodeException(Exception):
pass
def recursiveDepthFirst(node, soughtValue):
try:
recursiveDepthFirstWorker(node, soughtValue, set())
return False
except FoundNodeException:
return True
def recursiveDepthFirstWorker(node, soughtValue, visitedNode... |
dc01cec503f91f0ab52f8e94c59703bfb46e5cd6 | shen1993/Drone_project | /SCVL.py | 1,341 | 3.53125 | 4 | from Display import Display
from Mapping import Mapping
import sys
# A String to Boolean method
def str_to_bool(s):
if s == 'True':
return True
elif s == 'False':
return False
else:
raise ValueError("Cannot covert '{}' to a bool. arg2 should only be either 'True' or 'False'".for... |
273f9fc8723c472bef60f332ef35272cb94645d5 | yz9527-1/1YZ | /pycharm/Practice/python 3自学/4-变量.py | 758 | 3.96875 | 4 | # 这里介绍 变量
# 变量可以是数字
var1 = 5
print(var1)
# 变量可以是字符
var2 = 'hello'
print(var2)
# 变量可以是运算表达式
var3 = 5 + 67
print(var3)
# 变量可以是函数
var4 = print('hello Python 3')
"""
总结:
变量的命名规范
1、变量名可以包括字母、数字、下划线,但是数字不能做为开头。例如:name1是合法变量名,而1name就不可以。
2、系统关键字不能做变量名使用
3、除了下划线之个,其它符号不能做为变量名使用
4、Python的变量名是除分大小写的,例如:name和Name就是两个变量名,而非相... |
bafa00b2527292e22de9bd044e6fe329ced8253e | TonyBiz9999/python | /16. Day 16/main.py | 217 | 3.5 | 4 | from turtle import Turtle, Screen
timmy = Turtle()
print(timmy)
timmy.shape("turtle")
timmy.color("red")
timmy.forward(100)
timmy.shapesize(3)
my_screen = Screen()
print(my_screen.canvheight)
my_screen.exitonclick() |
7cc8b8a9918c46dd2055fc411d64889d1cfcc323 | pratikskarnik/Leetcode_Solutions | /Palindrome Number.py | 267 | 3.609375 | 4 | class Solution:
def isPalindrome(self, x: int) -> bool:
y=0
x1=x
while(x>0):
y=y*10+x%10
x=x//10
print(y)
if y==x1:
return True
else:
return False
|
b5bde8ca78ae29233ddc769ef32d42a558e81e0d | AbhayKD/jasper-Modules | /stopwatch/stopwatch.py | 197 | 3.65625 | 4 | import time
b=0
e=0
#t = raw_input("Enter:")
while True:
t = raw_input("Enter:")
if t == "b":
b = time.time()
elif t == "e":
e = time.time()
print str(e-b)[0:3]
|
52fa4a4e67726d6ecbfe5798cf8e57b908861ddf | ndvssankar/cspp1-assignments | /M6/p3/digit_product.py | 653 | 4.125 | 4 | '''
Given a number int_input, find the product of all the digits
example:
input: 123
output: 6
'''
def main():
'''
Read any number from the input, store it in variable int_input.
'''
int_input = int(input())
product = 1
flag = False
if int_input < 0:
flag = True
int_... |
80c035b4bde4a2006e56b954046929f4143181e3 | quangdat191/tranquangdat-fundamental-c4t | /Session4/Homework_Lesson4/[8].py | 230 | 3.71875 | 4 | # a = input("Nhap tu ")
# import string
# for i in a:
# if 97 <= ord(i) <= 122:
# x = ord(i)-32
# for y in string.ascii_uppercase:
# if ord(y) == x:
# a = a.replace(i, y)
# print(a)
|
dbb9003897c6280a9d11d8e3d34c70c52be8cabe | ICS3U-Programming-Layla-M/Unit3-07-Python | /dating.py | 1,041 | 4.21875 | 4 | #!/usr/bin/env python3
# Created by: Layla Michel
# Created on: May 17, 2021
# This program asks the user to input their age
# and displays whether they are eligible to date
# some grandparents' grandchild.
import constants
def main():
try:
# get the user's age
user_age_as_string = input("Enter ... |
e1bc46feaa4e43d6b82216fd2b10e4a57d0dba7a | sincerehwh/Arithmetic | /liner_list_linked.py | 10,537 | 3.828125 | 4 |
# 单链表:
#
# ┌───┐
# │ p ├┐
# └───┘│
# │ ┌─────┬──────┐ ┌──────┬──────┐ ┌─────... |
8ac08f013ef34d6752c4fd5ebdb730be26a890a3 | shags07/python | /INC0011009_sagar_q18.py | 308 | 3.703125 | 4 | def XorLBit(int1,int2):
list1=[]
list2=[]
int1=list1.append(int1)
int2=list2.append(int2)
for value in list1:
a=list1.reverse()
for value in list2:
b=list2.reverse()
return a
return b
return ((a | b) & (~a | ~b))
print (XorLBit(1011,101))
|
9c702a2d490e8d63b3c97d97ea579a893ca7a8eb | Labannya969/Hackerrank-practice | /python/04. Sets/004. Set add().py | 169 | 3.859375 | 4 |
# Enter your code here. Read input from STDIN. Print output to STDOUT
n= int(input())
s=set()
for i in range(1,n+1):
country= input()
s.add(country)
print(len(s))
|
711dba79b76ea33db4e54f253dc02fcdb753eb1e | fanxiao168/pythonStudy | /AIDStudy/01-PythonBase/day04/homework/demo04.py | 100 | 3.65625 | 4 | '''
str编码
'''
# 字 --> 数
num = ord('a')
print(num)
# 数 --->字
str1 = chr(97)
print(str1)
|
fcc21665b05b09a5627b42d490aff37ec2cdd2e6 | Tyler-Henson/Python-Crash-Course-chapter-9 | /privileges.py | 743 | 3.59375 | 4 | """
Problem 9-8 of Python Crash Course
"""
import loginAttempts2 as lA2
class Admin(lA2.User):
def __init__(self, first_name, last_name, age, sex,):
super().__init__(first_name, last_name, age, sex)
self.privileges = Privileges()
class Privileges:
def __init__(self):
... |
a5d736a2c61ed86189d2c2ab29f8a87f243e63eb | Nithanth/Graduate-Algorithm- | /Linked List/092. Reverse Linked List II.py | 1,276 | 4.0625 | 4 | """
Reverse a linked list from position m to n. Do it in one-pass.
Note: 1 ≤ m ≤ n ≤ length of list.
Example:
Input: 1->2->3->4->5->NULL, m = 2, n = 4
Output: 1->4->3->2->5->NULL
"""
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
def myprint(self):
pri... |
370b5dba7c50774138693e14c68c3969c28c39c6 | algebra-det/Python | /Iterate_btwn_two.py | 744 | 3.890625 | 4 | players = [1,0]
choice = 1
for _ in range(10):
current_player = choice
print(current_player)
choice = players[choice]
print("val")
#OR
val =1
for _ in range(10):
val = 1 -val
print(val)
print("itertools 1")
# OR using itertools import cycle
from itertools import *
myIter... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.