blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
a0c4aa10f743459ad35a6bb2aef1a02f690f4063 | poojataksande9211/python_data | /python_tutorial/excercise_4/creat_tuple_num_with_one_item.py | 192 | 4.25 | 4 | # Write a Python program to create a tuple with numbers and print one item.
# num=(1,2,3,4,5,6)
# print(num[0])
# print(num[2])
#------------------
num=1,2,3,4,5,6
print(num)
num=5
print(num)
|
81bf553c24ba92ebac6b4abda0243178233657ad | poojataksande9211/python_data | /python_tutorial/excercise/ip_more_than_one_digit_addition.py | 169 | 3.84375 | 4 | num=input("enter number")
i=0
total=0
# while i < int(num[-1]): #(-1 means last digit of string)
while i < len(num):
total=total + int(num[i])
i=i+1
print(total) |
9d135a4b16e3074f5bb6ec52723d3c831b09316f | poojataksande9211/python_data | /python_tutorial/great_learning_python_tutorial/intro_python_string.py | 967 | 4.78125 | 5 | #intro to python string
#string is a sequence of character enclosed in 'single quote',"double quote",''' triple quote'''
# str1="this is my first string"
# str2='this is my second string'
# str3='''
# this string
# has
# lots of
# lines in it
# '''
# print(str1)
# print(str2)
# print(str3)
#------------------
#extrac... |
e1230d0b737a376b531255a25de637afbbe8a7c7 | poojataksande9211/python_data | /python_tutorial/excercise_3/min_max_function.py | 261 | 4.0625 | 4 | #min and max function
# numbers=[55,90,12]
# print(min(numbers))
# print(max(numbers)) #max func is used for finding greatest no
#----------------------------------
def min_max_diff(l):
return (max(l) - min(l))
numbers=[10,1,9]
print(min_max_diff(numbers))
|
f591fdb23aa86417cb8d8bba2ed8dbe22bc0c8ee | poojataksande9211/python_data | /python_tutorial/excercise_6_sets/more_about_set.py | 486 | 4.21875 | 4 | #more about python
s={1,2,3,4,5,6}
#check if item present in set or not
if 1 in s:
print("present")
else:
print("not present")
#-----------------------
for i in s:
print(i)
#---------------------
#remove duplicate data from tuple
sa=(1,2,3,2,4,5)
print(type(sa))
sa=set(sa)
print(sa)
#---------------------
#... |
66f766018cc8a1fb6eadbc698e929c860aa16676 | poojataksande9211/python_data | /python_tutorial/excercise_9_lamda_expression/lambda_expression_practice.py | 757 | 4.125 | 4 | # def is_even(a):
# if a % 2 ==0:
# return True
# return False
#orrrrr
def is_even(a):
return a%2 ==0
print(is_even(4))
#--------------------------
is_even_2=lambda a:a%2==0
print(is_even_2(5))
#--------------------------
# def last_char(s):
# return s[-1]
# print(last_char('pooja'))
last_char2=... |
fc64e6c40d1e5dd3dd5f8e9bb1acbfef2edf5447 | poojataksande9211/python_data | /python_tutorial/excercise_13_oops_concept/inheritance.py | 883 | 4.21875 | 4 | #inheritance
class Phone:#base class/parent class
def __init__(self,model_name,brand,price):
self.model_name=model_name
self.brand=brand
self._price=max(price,0)
def full_name(self):
return f"{self.model_name} {self.brand}"
def calling_no(self,phone_no):
return f"call... |
3f5f69c4e6367e25c885f5fc1217284ac665e4c2 | poojataksande9211/python_data | /python_tutorial/excercise_2/func_range.py | 227 | 4.1875 | 4 | #Write a Python function to check whether a number is in a given range
def range_with(n):
if n in range(3,9):
print("%s is in the range"%str(n))
else:
print("%s is out of the range"%str(n))
range_with(8) |
8c208c29d62d6e90f9059873b3bc17412c233305 | poojataksande9211/python_data | /python_tutorial/excercise_10_enumerate_function/filter.py | 494 | 4.25 | 4 | #filter function
# def is_even(a):
# return a%2==0
# numbers=[1,2,3,4,5,6,7,8,9]
# evens=tuple(filter(is_even,numbers))
# print(evens)
#---------------------
#by using lambda expression
# def is_even(a):
# return a%2==0
# numbers=[1,2,3,4,5,6,7,8,9]
# evens=tuple(filter(lambda a:a%2==0,numbers))
# print(evens)... |
b56df72642fe42b967cbe8becc1a3908870c1c8e | poojataksande9211/python_data | /python_tutorial/excercise/assignment_operater.py | 221 | 4 | 4 | name="pooja" #(suppose we want to add ji)
# name=name + "ji"
# print(name)
#..................
name += "ji"
print(name)
age=23
# age=age + 1
# print(age)
# age += 1
# print(age)
# age -=2
# print(age)
age *=2
print (age) |
e7313865459227a22e270f7b6e8d23f1b4f4acc7 | poojataksande9211/python_data | /python_tutorial/excercise_2/func_pangram.py | 529 | 4.0625 | 4 | #A pangram is a unique sentence in which every letter of the alphabet is used at least once.
import string
string='the quick brown fox jumps over the lazy dog'
def unique(str):
list2="abcdefghijklmnopqrstuvwxyz"
for i in list2:
if i not in str.lower():
# list2.append(i) #The append() method... |
9ae7b66868e1759d931ba706eb58708bb6d13815 | poojataksande9211/python_data | /python_tutorial/excercise_13_oops_concept/property_and_setter_decoration.py | 1,185 | 4.09375 | 4 | #property and setter decoration
class Phone:
def __init__(self,model_name,brand,price):
self.model_name=model_name
self.brand=brand
self._price=max(price,0)
# if price > 0:
# self._price= price
# else:
# self._price=0
# self.complete_specificat... |
9436c20bce0c057d67739e0269af8f59a9f45c54 | poojataksande9211/python_data | /python_tutorial/excercise_8_args/kwargs.py | 750 | 3.828125 | 4 | #kwargs/keyword argument/double star operator
# def func(**kwargs): #*args gather argument in to tuple
# print(kwargs) #**kwargs gather argument in dictionary
# for k,v in kwargs.items():
# print(f"{k} : {v}")
# func(first_name='harshit',last_name='vaishista')
#-------------------------------
# def fu... |
c7aa7c1cd786e8648d9aaae6c8059a11b2624465 | poojataksande9211/python_data | /python_tutorial/excercise_10_enumerate_function/find_pos_of_string_using_enumerate.py | 233 | 4.25 | 4 | #program to find pos of string
names=['pooja','harshit','amit','ganvir','aaji']
def find_pos(names,target):
for pos,i in enumerate(names):
if i==target:
return pos
return -1
print(find_pos(names,'ganvir')) |
aafad75b2bf76b19ac40380cb0ee452be4baaa78 | poojataksande9211/python_data | /python_tutorial/excercise_4/colon.py | 262 | 4.21875 | 4 | #Write a Python program to create the colon of a tuple.
from copy import deepcopy
mixed=("pooja",1,2,3,[],"amit") #create a tuple
print(mixed)
mixed_colon=deepcopy(mixed) #make copy by using deepcopy func
mixed_colon[4].append(70)
print(mixed_colon)
print(mixed) |
926c3269be17c1cbae5d978ba350422109ad977b | jmplz14/PTC-programacion-tecnica-y-cientifica | /Sesion3/ejercicio5.py | 1,060 | 3.65625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 25 11:14:15 2019
@author: jose
"""
def devolverMayus(letra):
return chr( ord(letra) - 32)
def esVocal(letra):
encontrada = False
vocales = "aeiou"
i = 0
while i < 5 and not encontrada:
mayuscula = devolverMayus(vocal... |
cd478f8eb4ac0b000f9642270842e34410f968b0 | emmalala123/cta_training_paradigm | /training_paradigm_sept/calibration_menu.py | 427 | 3.96875 | 4 | """
calibration_menu() runs a submenu of main_menu() for navigating calibration of taste valves.
"""
def calibration_menu():
while True:
for x in range(1, 5):
print(str(x) + ". calibrate line " + str(x))
print("5. main menu")
line = int(input("enter your choice: "))
if li... |
660b7cc75b503208c36fc6ee93b1acbf354fa4d3 | Jessicarryly/ECGReader | /Analyser/tag_searching.py | 1,078 | 4.125 | 4 | def search(entries, types, tags):
"""
Look for given tags in given entries
:param entries: A list of Entry
:param types: a list of types to filter in the entries list
:param tags: a List of tag to search
:return: a dict with the types, tags and number of occurrence
"""
results = {}
f... |
dbc6a509f93c387132789527ea31e25f606611e5 | 20160719/python | /NPythonDemo/src/py/__init__.py | 722 | 4.0625 | 4 |
print "welcome to python"
def add(x, y) :
return x + y
def multi(x):
return x ** 2
def f(x):
return x % 2 == 0
lam = lambda x: x ** 3
list = [1, 3, 5, 7, 9, 12]
print "x + y = ", add(3, 5)
for r in range(5):
print "r1: ", r
for r in range(0, 5):
print "r2: ", r
for r in range(0, 5,... |
c50c0e813149bbf4486d74d0c9baa0e440fe6158 | KillyBOT/SHAPE-Projects | /othello_gui_client.py | 9,121 | 3.5625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
COMS W4701 Artificial Intelligence - Programming Homework 2
This module contains a simple graphical user interface for Othello.
@author: Daniel Bauer
"""
from tkinter import *
from tkinter import scrolledtext
import socket, json
import sys, os
port = 5000
host =... |
45003c6e5b3beeb29caf1e873be3b0f3646626e0 | KillyBOT/SHAPE-Projects | /Graphs.py | 3,274 | 3.734375 | 4 | import math
class Vertex(object):
def __init__(self,name,connections):
self.name = name
self.connections = connections
def __str__(self):
return str("Name: %s\t Connections: %s\n" % (self.name, self.connections))
#return str(self.name)
def __repr__(self):
return str(self)
class Queue(object):
def __i... |
1bc79650aaccd7a6196a7f854b16b2016d435d1e | FatimaTasnim/ML_Learnings | /Pytorch/pytorch for Image/Tensors.py | 1,912 | 3.75 | 4 | import torch
import numpy as np
# Pytorch tensors can be used on a GPU
## initialize a empty tensor
zero = torch.empty(5, 3)
print("Printing Zero:\n", zero)
## Randomly initiazed Matrix
random = torch.rand(5,3)
print("Printing randomly initialzed matrix:\n", random)
## Matrix filled with zero with long datatype
lon... |
23833d6e3cce227dc3fdb64c14a0f287990c7acb | SabhyaC26/Coding-Interview-Questions | /Blind75/maxDepthBST.py | 1,138 | 4.0625 | 4 | from collections import deque
"""
Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root
node down to the farthest leaf node.
LeetCode Rating: Easy
Link: https://leetcode.com/problems/maximum-depth-of-binary-tree/
"""
# tree definition
class TreeNode... |
b289bdda195738936b4644a070aa2c6f59b638f7 | SabhyaC26/Coding-Interview-Questions | /Others/countNodes.py | 700 | 3.90625 | 4 | """
Given a complete binary tree, count the number of nodes.
"""
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
# easy way in linear time
def countNodes(self, root):
return 1 + self.countNodes(root.right) + self.countNodes(ro... |
ddb3bfb13c613079cf0388eec0db689b7b9fe70c | SabhyaC26/Coding-Interview-Questions | /Others/productExceptItself.py | 1,212 | 3.546875 | 4 | """
Given an array nums of n integers where n > 1, return an array output such that
output[i] is equal to the product of all the elements of nums except nums[i].
LeetCode Rating: Medium
Link: https://leetcode.com/problems/product-of-array-except-self/
"""
# this is the easy method with division
def easyMethod(arr)... |
fbfa8901de2fc1f8bdc66d05beaf68e65ae8eec1 | SabhyaC26/Coding-Interview-Questions | /DynamicProgramming/climbingStairs.py | 298 | 3.65625 | 4 | def climbStairs(n):
if n == 1:
return 1
DP = [0 for x in range(n)]
DP[0], DP[1] = 1, 2
for j in range(2, n):
DP[j] = DP[j-1] + DP[j-2]
return DP[-1]
def main():
print(climbStairs(3))
print(climbStairs(20))
if __name__ == "__main__":
main()
|
b6865298b8d0d8f0c2d07527815d2ef8db230bd8 | SabhyaC26/Coding-Interview-Questions | /Blind75/linkedListCycle.py | 940 | 3.859375 | 4 | """
Given a linked list, determine if it has a cycle in it.
LeetCode Rating: Easy (Const Space is Medium)
Link:
"""
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
# linear space solution
def linearSpace(head):
if head is None or head.next is None:
retu... |
d69f2fdc2a49652dff4fe2cd4be1bb820cc22026 | SabhyaC26/Coding-Interview-Questions | /Binary Search Tree/inorderSuccessor.py | 513 | 3.734375 | 4 | class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
def inorderSuccessor(self, root: 'TreeNode', p: 'TreeNode') -> 'TreeNode':
stack = []
res = []
while True:
while root:
stack.append(root)
root = root.l... |
237cde1cd0557d126477daa3f68c208703348d9c | SabhyaC26/Coding-Interview-Questions | /DynamicProgramming/houseRobber.py | 774 | 3.8125 | 4 | """
In the House Robber Problem, you are a robber who has
found a block of houses to rob. Each house i has a
non-negative v(i) worth of value inside that you can steal.
However, due to the way the security systems of the houses
are connected, you’ll get caught if you rob two adjacent houses.
What’s the maximum value yo... |
a054e885e03367d8ecc15c878203fc904f423df2 | SabhyaC26/Coding-Interview-Questions | /CrackingTheCodingInterview/Arrays and Strings/IsUnique.py | 311 | 3.84375 | 4 | """
Is Unique: implement an algorithm to determine if a string has all unique values.
"""
# this solution levarages standard python library functions
def isUnique(s):
return len(set(s)) == len(s)
def main():
print(isUnique("SABY"))
print(isUnique("SABHYA"))
if __name__ == "__main__":
main()
|
81d836b44c342240a28b48addf7f965b05157870 | SabhyaC26/Coding-Interview-Questions | /Others/cycleDetectBinTree.py | 426 | 3.578125 | 4 | class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
def detectCycle(self, root, seen):
if root in seen:
return True
seen.add(root)
if root.left and self.detectCycle(root.left, seen):
return True
... |
a62500812b00c7c07272a2a9cd677421a1ca1b5f | SabhyaC26/Coding-Interview-Questions | /Others/leftmostone.py | 459 | 3.6875 | 4 | def leftmostoneindex(matrix):
rows = len(matrix)
cols = len(matrix)
candidate = -1
r = 0
c = cols - 1
while r < rows and c >= 0:
if matrix[r][c] == 1:
candidate = c
c -= 1
else:
r += 1
return candidate
if __name__ == "__main__":
matri... |
5ca542c82ecba1e9bd416992f121734623a8fcf3 | Reik96/HR_Analytics | /src/preprocessing/cleaning.py | 2,364 | 3.65625 | 4 |
def data_cleaning(df):
import pandas as pd
import numpy as np
# Drop id
df.drop(columns= ["enrollee_id"],inplace=True)
# Create a new feature to indicate wheter an individual provided all information or not
df.loc[df.isnull().values.any(), 'all_information'] = 0
df.loc[df.notnull().values.... |
6192c1773d538c5978fec40aaa2c7383e59e4533 | Reik96/HR_Analytics | /src/preprocessing/data_split.py | 830 | 3.734375 | 4 | class Split:
""" Class to determine the dataframe and name of the target column
to split it into a X and y Variable and training and test set."""
def __init__(self, df,target_name,test_size=0.3,seed=42,shuffle=True):
self.df = df
self.y = target_name
self.test_size = test_siz... |
cfddb428969c0b576dca42f3693eb8ec8e69befe | JupiterNguyen/AdventofCode | /2020/Day1/report_repair.py | 330 | 3.640625 | 4 | #!/usr/bin/python
# Desc: find two numbers that add up to 2020 and multiply them
text_file = open("numbers.dat", "r")
lines = text_file.readlines()
numbers = [x.replace('\n', '') for x in lines]
numbers = list(map(int, numbers))
for i in enumerate(numbers):
sum = i + i+1
print(sum)
print("sum == {}".format(su... |
1731bf41f05ddf9a711517d4a52e476506801a7e | svinodha/python-practice | /ValuesLessThanGivenNumber.py | 370 | 4.25 | 4 | a_list = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
#Code to print list that has values less than 5
new_list = []
for a in a_list:
if (a<5):
new_list.append(a)
print new_list
#Code to print list that has values less than the given number
num = int(raw_input("Enter a number: "))
new_list2=[]
for a in a_list:
if ... |
87153324cd98df051a0d741c88a7d3fcd865907f | trips2821/practice | /test_linked_list.py | 2,264 | 3.953125 | 4 | from linked_list import LinkedList, Node
def test_create_linked_list():
ll = LinkedList()
assert ll.head is None
def test_append_node_no_head():
n = Node(1)
ll = LinkedList()
ll.append_node(n)
assert ll.head is n
def test_append_node_w_head():
n1 = Node(1)
n2 = Node(2)
ll = ... |
32a97705024a0bdbfa2a1856a85bf5e6e4ef1f89 | trips2821/practice | /minimal_bst.py | 504 | 3.609375 | 4 |
class Node:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
def create_minimal_bst(values, start_index, end_index):
mid_index = (start_index + end_index ) // 2
node_value = values[mid_index]
node = Node(node_value)
if end_index < start_in... |
fa946936f2b3175a38b76a279d77cab21d5c64ec | trips2821/practice | /test_4_3_and_4_4.py | 1,790 | 3.515625 | 4 | import pytest
from linked_list import LinkedList
# implement an algorithm which creates a linked lists of all nodes at each depth of a binary tree
from minimal_bst import create_minimal_bst, Node
def create_depth_lists(node, depth_list, prev_depth):
if node is not None:
current_depth = prev_depth + 1
... |
321176782a1d015aefa6bfbd2b0e5d37d08fae9e | qarchli/Multi-Layer-Neural-Network | /utils/activation_functions.py | 1,281 | 3.5 | 4 | import numpy as np
def sigmoid(z):
"""
Computes the sigmoid activation function for a given numpy array.
"""
return (1 / (1 + np.exp(-z)))
def sigmoid_p(z):
"""
Computes the gradient of the sigmoid for a given numpy array.
"""
return (sigmoid(z) * (1 - sigmoid(z)))
def relu(z):
... |
7d2a93e1a4d5eeb5595970184649f4ef6fa14f1b | LJohnnes/ga-advanced-python | /20150309/rock.py | 959 | 3.515625 | 4 | from collections import Counter
import csv
csvfile = open('rock.csv', 'rb')
reader = csv.DictReader(csvfile)
rows = [row for row in reader]
eightyone = [row for row in rows if row['Release Year'] == '1981']
def is_valid_year(candidate):
# return candidate.isdigit()
return candidate[0:2] in ['19', '20']
# ... |
5c79d0729f0088d856c58732d481590eec4f9964 | iam3mer/NivelatorioEnAlgoritmia | /MetodosDeOrdenamiento/randomQuickSort.py | 1,311 | 4.1875 | 4 | #! /usr/bin/python2.7.8
# -*- coding: utf-8 -*-
# Python program for implementation of Random Quick Sort
import argparse
from math import floor
from random import randint
from time import clock
def PARTITION(A,p,r):
x = A[r]
i = p - 1
for j in range(p,r):
if A[j] <= x:
i ... |
a7fb727266d19ba6c697c2eefc23b79ee7965634 | GOWRAPPAGARIHARISHBABU/DSP-Lab | /append.py | 534 | 4.28125 | 4 | #APPENDING OPERATION ON LISTS
#appendig list as a element
print("\nAppending using list as a element:\n")
list_A = ['DIGITAL', 'SIGNAL']
print ("list_A before appendig",list_A )
list_A.append('PROCESSING')
print ("list_A after appendig",list_A )
#appending using two lists
print("\nAppending using two lists\n")
list1 ... |
9bee5ffa23a9d1613874a4f98a56ad02fe19b651 | ltliuta/algorithm | /insertionSort/insertionSort.py | 396 | 3.953125 | 4 | def insertionSort(a, n):
if(n < 1): return
for i in range(1,n):
j = i - 1
tmp = a[i]
while j >= 0:
if a[j] > tmp:
a[j+1] = a[j]
j = j - 1
else: break
a[j+1] = tmp
print 'after sort data:'
print a
a = [9, 4, 3, 1,... |
107d34520c45214a2be425a3ff3062849a4880b7 | tonyli1121/Project_euler_scripts | /19._Counting_Sundays.py | 1,161 | 4.125 | 4 | # 50mins
# ----------algorithm--------
#count how many days there will be on that year
#count what the date is when it's Sunday based on above info
# date -= (1+days%7)
# if date==0:
# date = 7
# elif date == -1:
# date = 6
# num_of_sundays+=1+(31-date)//7
#--------------------------------
import time
sta... |
03e07c54f10305dff159f5fcf9654a38c86525ed | austinschrader/pythonguide | /ex3.py | 595 | 3.6875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Oct 7 11:08:17 2019
@author: austin.schrader
"""
# class declaration
class Jungle:
# constructor with default values
def __init__(self, name="Unknown"):
self.visitorName = name
def welcomeMessage(self):
print("Hello %s, Welcome to the Ju... |
2d8b7f9ffd905a61e5b9eb80e4ae180ffde94655 | cs360f14/JungleJamboree | /GamePlay/unittestPerson.py | 1,606 | 3.734375 | 4 | #!/usr/bin/python
##################################
# File Name: unittestPerson.py
# Author: Group 3
# Date: 12/1/2014
# Project: Jungle Jamboree
# Purpose: unittest for Person module
##################################
import unittest
from Person import *
"""
The Unittest for Person Module
"""
# tests not ne... |
6dba90d5be176e819efc4876a1a0d3f02ef6e994 | cs360f14/JungleJamboree | /GamePlay/Party.py | 4,263 | 3.96875 | 4 | #!/usr/bin/python
##################################
# File Name: Party.py
# Author: Group 3
# Date: 11/10/2014
# Project: Jungle Jamboree
# Purpose: Party to class to handle a group of persons
##################################
from Person import *
from Inventory import *
"""
The Party Module
"""
class Part... |
a72a2579bd590aaaef7728c96acb00db25322365 | deKronkelers/NWI-IBC027_assignment3 | /answers/code/universal_sink.py | 924 | 3.5625 | 4 | # author: Hendrik Werner s4549775
# author: Constantin Blach s4329872
from numpy import matrix, sum
def is_sink(m, i):
"""
Check whether element i is a universal sink of matrix m.
Time complexity: O(n)
:param m: an adjacency matrix
:param i: the index of the element to check
:return: whether... |
6c4891f5df4541c11da0f154fb65ee4b66215bd1 | geekmuse/exercism-python | /meetup/meetup.py | 2,927 | 4.09375 | 4 | from datetime import date
import calendar
"""Set Sunday to first day of week for calendar module (defaults to Monday)"""
calendar.setfirstweekday(calendar.SUNDAY)
"""Define custom exception class"""
class MeetupDayException(Exception):
pass
def meetup_day(year, month, day, ord_date):
"""
Compute date ba... |
deb61ddfa8d4753b041273c1c4db01219d607736 | Kalo7o/VUTP-Python | /exercise_03/02.Simple_calculator.py | 652 | 4.3125 | 4 | print("Operations +, -, *, /")
num1 = int(input("Enter first number: "))
choice = input("Enter operation:")
num2 = int(input("Enter second number: "))
def add(n1, n2):
return n1 + n2
def subtract(n1, n2):
return n1 - n2
def multiply(n1, n2):
return n1 * n2
def divide(n1, n2):
return n1 / n2
if c... |
9a25a5241727bed4ea38201dee9c25318ebaf223 | Kalo7o/VUTP-Python | /exercise_05/02.Text_analize.py | 743 | 3.890625 | 4 | string = input("Enter the stringing : ")
vowels = 0
digits = 0
consonants = 0
spaces = 0
symbols = 0
string = string.lower()
vowels_list = ['a', 'e', 'i', 'o', 'u']
number_list = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
for i in range(0, len(string)):
if(any(ele in string[i] for ele in vowels_list)):
... |
02d438a70ce3dbf7e214866453ca3840a0939c11 | smathj/python1 | /while/while_break.py | 491 | 3.78125 | 4 | coffee = 10
while True:
money = int(input("돈을 넣어주세요: "))
if money == 300:
print("커피를 줍니다")
coffee -= coffee
print("-" * 40)
elif money > 300:
print("거스름돈 %d 를 주고 커피를 줍니다" %(money - 300))
coffee -= coffee
print("-" * 40)
elif money < 300:
print("... |
9aed322cf36c3a95887016baed25dba61b8852d4 | shaniphankar/RecSystemIR | /compare.py | 3,902 | 3.671875 | 4 | import numpy as np
import pprint
import os
from random import randint
import math
''' Loading the dataset '''
mID_uID_rating=np.zeros(shape=(3952,6040))
f=open(os.getcwd()+'/ml-1m/ratings.dat',encoding='latin-1')
for line in f:
mID_uID_rating[int(line.split('::')[1])-1][int(line.split('::')[0])-1]=line.split('::')[2... |
5d3dd4c57f4bf4b700ab4ed1a6642dbfb603e47a | Amanskywalker/pyaudio | /english_sentiment_module.py | 2,489 | 3.59375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
def func(rev):
def readfile(fileName):
import io
f=io.open(fileName,'r',encoding='utf-8')
ret = []
for line in f:
ret += line.split()
return ret
goodWords=readfile('goodwords.txt')
badW... |
1659e38e5cac1f3b00d5ff239a284c5ab75ee0dd | IsolatedRain/code_wars | /completed/String incrementer.py | 349 | 3.59375 | 4 | def increment_string(s: str):
digit = s[(len(s.rstrip("0123456789"))):]
if not digit: return s + "1"
v = str(int(digit) + 1).zfill(len(digit))
if len(digit) == len(s):
return v
return s[:len(s) - len(digit)] + v
word = "foo"
# word = "foobar001"
# word = "009"
# word = "8129461190440702"
p... |
9a946120ecd967820dd39d11dc546370bb12ad6f | IsolatedRain/code_wars | /completed/First non-repeating character.py | 263 | 3.75 | 4 | import collections
def first_non_repeating_letter(string):
s1 = s.lower()
count = collections.Counter(s1)
for i, v in enumerate(s1):
if count[v] == 1:
return s[i]
return ""
s = 'sTreSS'
print(first_non_repeating_letter(s))
|
777919d396d56f67352a67217fe3d065caa1a2b5 | IsolatedRain/code_wars | /completed/Land perimeter.py | 809 | 3.515625 | 4 | def land_perimeter(arr):
land = list(map(list, arr))
row, col = len(land), len(land[0])
dir4 = [[0, 1], [0, -1], [1, 0], [-1, 0]]
def neighbor(x, y):
for m in dir4:
nx, ny = x + m[0], y + m[1]
if 0 <= nx < row and 0 <= ny < col:
yield nx, ny
perimete... |
e1d13ab8944728b53ffd14b3131b467e2f8578b8 | IsolatedRain/code_wars | /completed/Calculating with Functions.py | 1,915 | 3.65625 | 4 | ops = {"+": lambda x, y: x + y, "*": lambda x, y: x * y, "-": lambda x, y: x - y, "/": lambda x, y: x / y, }
def zero(*args): # your code here
if args == ():
return 0
else:
op, value = args[0].split()
return ops[op](0, int(value))
def one(*args): # your code here
if args == ():... |
d33b8008e0898709e0736eeac2f638f92730dc70 | IsolatedRain/code_wars | /trying/Help your granny!.py | 622 | 3.65625 | 4 | import collections
def tour(friends, friend_towns, home_to_town_distances):
# https://www.codewars.com/kata/5536a85b6ed4ee5a78000035/train/python
n = len(friends)
dist = {}
for k, v in distTable1.items():
dist[k] = [v, ""]
for f, t in fTowns1:
if t not in dist:
dist[t] ... |
ea6863f24c8b6f64f5e5620269036341c6cbd4d0 | IsolatedRain/code_wars | /completed/Counting String Subsequences.py | 841 | 3.609375 | 4 | from functools import lru_cache
@lru_cache(maxsize=None)
def count_subsequences(a, b):
if len(a) == 1: return b.count(a)
if not a or len(a) > len(b): return 0
curRes = 0
for i, c in enumerate(b):
if a[0] == b[i]:
curRes += count_subsequences(a[1:], b[i + 1:])
return curRes
# ... |
557f838e085d2417333ee00c03deebf1132cd6b3 | IsolatedRain/code_wars | /completed/Are we alternate.py | 248 | 3.875 | 4 | def is_alt(s):
vowels = {*"aeiou"}
t = ""
for i in s:
if i in vowels:
t += "0"
else:
t += "1"
if "00" in t or "11" in t:
return False
return True
s = "banana"
print(is_alt(s))
|
65f8799f229c3b2da3d4507193573c6ddc8d9d1b | nadimwasim/fisrtprogram | /python_project/app.py | 885 | 3.734375 | 4 | import json
from difflib import get_close_matches
data=json.load(open("data.json"))
def translate(word):
to_smaller=word.lower()
if to_smaller in data:
return data[to_smaller]
elif to_smaller.title() in data:
return data[to_smaller.title()]
elif to_smaller.upper() in data:
re... |
ce7760d7a5371d863e782b59fad4a0a7572dff04 | AMfalme/MIT-Academy-solutions. | /problem set 1/ps1b.py | 1,040 | 4.34375 | 4 | '''
We calculate the number of months it will take to afford the downpayment of a house.
This takes into consideration a semi annual raise in the salary.
'''
annual_salary = float(input("Kindly input your annual salary?"))
portion_saved = float(input("Kindly input your desired savings as a decimal?"))
total_cost = floa... |
674d02afc2a2b0786e5b55aa1aceaac6b8b045bf | rmr327/personal | /artificial_intelligence/puzzle/puzzle_rmr327.py | 7,367 | 3.6875 | 4 | import pandas as pd
import copy
import random
import string
class State:
"""
Consists of the grid and words left to be placed in the grid. This class also keeps track of the size of the grid.
"""
def __init__(self, m=13, n=13, words=False):
"""
Initializes the grid
:param m: ... |
8328b093aba8c126e04858d572afb0b9763b92e5 | puletevinnkoni/task1_project | /hello_world.py | 237 | 3.78125 | 4 |
git = input("Do you think Git is Awesome?")
if git == "yes":
print("Use it")
print("For professionals")
else:
program = input("Do you recommend another program?")
if program =="yes":
print("what features does it have")
|
3334e8d16cd476dead3c336b4a683a92ab131468 | cgomez5609/machine-learning | /algorithms/naive_bayes/main.py | 1,214 | 3.703125 | 4 | """
Naive Bayes implementation for text classification.
I used dictionaries to display probabilities for the labels and words.
This can be optimized by using matrices, but for the sake of instruction I used dictionaries.
Preprocessing was not considered here, but in real applications there will be a great deal
of prepr... |
5f5658407adac88a74e287a2b07a0217b124c34f | renatronic/night_snake | /night_snake.py | 1,398 | 3.625 | 4 | import tkinter as tk
import turtle
from PIL import ImageTk, Image
from pygame import mixer
root = tk.Tk()
root.title('NightSnake')
# root.iconbitmap('snake.ico')
root.state('zoomed')
def on_closing():
mixer.music.stop()
root.destroy()
root.protocol('WM_DELETE_WINDOW', on_closing)
mixer.init()
mixer.music.lo... |
a34a9c9933ae3c91ee3a7493aaf2f57a5b776edc | FrankLynCode/Simpleprojects | /estemated_humanResource.py | 692 | 3.75 | 4 | import math
standar_Size = 80
size = 0
timeOrPeople = 0
def estemated(type=1,size=None,timeOrPeople=None):
if type == 1 and timeOrPeople != None:
return math.ceil(size*standar_Size/timeOrPeople)
if type == 2 and timeOrPeople != None:
return size*standar_Size/timeOrPeople
while True:
type = int(... |
c2664840668339c89688ba65523f2a39b8082093 | wesenu/intro-comp-thinking-data-sci | /week4/lect_7_prob2_experiment_pdf.py | 1,776 | 3.53125 | 4 | '''
Experimenting with probability distribution to model errors when modeling PDF
as the sum of n number of random samples.
'''
import pylab
import random
def testErrorsGaussian(ntrials=10000,npts=100):
results = [0] * ntrials
for i in xrange(ntrials):
s = 0 # sum of random points
for j in x... |
3c4759fcb716d63084c4ddf633f950e23a877773 | PixelyIon/A-Conjecture-of-Mine | /script.py | 1,681 | 3.953125 | 4 | # This script is a simple test for the following conjecture:
# Let S: N -> N be the sum of the digits of a positive integer.
# For all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger.
from time import time
def sum_digits(n: int) -> int:
parc = abs(n)
sum_d = 0
while parc > 0:
s... |
75d1f9943c10569d207e5645ed563539b9d40b5d | tobyoxborrow/adventofcode | /2017/04-entropy-passphrases/4b.py | 1,349 | 3.953125 | 4 | #!/usr/bin/env python3
"""
Day 4: High-Entropy Passphrases
abcde fghij is a valid passphrase.
abcde xyz ecdab is not valid - the letters from the third word can be
rearranged to form the first word. a ab abc abd abf abj is a valid passphrase,
because all letters need to be used when forming another word.
iiii oiii o... |
5fd7a8d153b777e02cf59774dd8832728ec353c3 | easy-tensorflow/Easy-TensorFlow-for-Biomedical-Data-Analysis | /1_Basics/utils.py | 395 | 3.53125 | 4 | import numpy as np
def randomize(x, y):
""" Randomizes the order of data samples and their corresponding labels"""
permutation = np.random.permutation(y.shape[0])
shuffled_x = x[permutation, :]
shuffled_y = y[permutation]
return shuffled_x, shuffled_y
def get_next_batch(x, y, start, end):
x_... |
a102aa7b08cd205d937fad9fc0cbcaba197ae11c | annie2010/py | /scientitist/chpt18_linkedlist/linkedlist.py | 523 | 4.125 | 4 | class Node:
def __init__(self, name, next=None):
self.name = name
self.next = next
def __str__(self):
return str(self.name)
def print_forward(node):
while (node):
print (node)
node = node.next
print
def print_backward(list):
if list == None:
return
... |
ca47eaa927dc7a4d6aadc0e15b41d8926b513304 | nulijiushimeili/python_training | /training/面向对象1.py | 2,371 | 3.734375 | 4 |
class SweetPotato:
"""这是一个烤地瓜的类"""
# 第一初始化方法
def __init__(self):
self.cookedLevel = 0
self.cookedStatus = "生的"
self.condiments = []
# toString()方法
def __str__(self):
msg = "地瓜"
if len(self.condiments) > 0:
msg = msg + "加了("
for tem... |
88fa7634185dcf2fc082abd0bb8355fa847f1724 | toliahoang/Pandafordata | /lambda_split_text.py | 194 | 3.75 | 4 | import codecademylib
import pandas as pd
df = pd.read_csv('employees.csv')
# Add columns here
get_last_name=lambda x: x.split(' ')[-1]
df['last_name'] = df.name.apply(get_last_name)
print(df)
|
d18d976d8c2bcca474c353c477bae8d137f6c241 | JustasHastas/AQA-A-Level-Computer-Science | /section_1/chapter_1_programming_basics/3.data_structure.py | 522 | 3.78125 | 4 | float_number = 3.14
integer_number = 3
string = "Mouse 1"
list_= [float_number, integer_number, string, 7289357] # It can be fully edited
print(list_[])
tuple_ = (float_number, string) # The advantages of this is that it functions faster, requires less memory.
dictionary = {'mouse':'kate', 'car': 'masina', 'marsas':'... |
d903aa0d1a52168c49e0e107610309360af911d4 | JustasHastas/AQA-A-Level-Computer-Science | /section_1/chapter_1_programming_basics/4.datatypes_import_module.py | 420 | 3.96875 | 4 | import datetime #Imported a module
birthday = datetime.datetime(1940, 1, 1, 15, 15, 15) # Double datetime shows calendar date and hourly date.
data = datetime.date(1940, 2, 5)
laikkas = datetime.time(15, 16) #If only two numbers are written, it only shows hours and minutes
birthday1 = datetime.datetime(1999, 8, 3, 18, ... |
e0f81e80772bf712662df06c03c93d20ca7167b5 | RicCheng/dsp | /python/advanced_python_regex.py | 513 | 3.765625 | 4 | import pandas as pd
import numpy as np
# To load the CSV data into dataframe
df = pd.read_csv('faculty.csv')
# PART 1 Q1:
degree_formatted = [x.strip().replace('.', '').split() for x in df[' degree']]
set(reduce(lambda x,y: x+y,degree_formatted))
# PART 1 Q2:
title_formatted = [x.strip().replace(' of Biostatistics... |
c4eb9ef31aaee2cbecccb7e1761c1f722e7369dc | jogloran/advent-of-code-2020 | /d23.py | 1,364 | 3.71875 | 4 | cups = list('463528179')
cups = list(map(int, cups))
cur_index = -1
def remove_slice(L, start, end):
result = []
for i in range(start, end):
result.append(L[i % len(L)])
# Removing a slice that goes off the end of the array
# [1,2,3,4,5] remove_slice(3,6) should remove three elements 4,5,1
... |
1a858c0fd1aa8cd5d70ba31699e14831af6f6f70 | sjain93/Object_Oriented_Programming_Python | /OOP02_20_19/bank02.py | 1,764 | 4.34375 | 4 | class BankAccount:
interest_rate = float(1.0)
#This is the prime interest rate
accounts = []
#All accounts, start as an empty list - to append to later
#These are all the class methods that operate on all accounts hollistically
@classmethod
def create(cls):
new_account = cls()
#c... |
afb2b9120dd11f97ec90813c0d46ce94e7bb0d07 | grafandreas/CarND-LaneLines-P1-Sol | /P1.py | 8,444 | 3.59375 | 4 | #importing some useful packages
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import cv2
#AGR: short fix
rootDir = '../CarND-LaneLines-P1/'
roiY=330
#reading in an image
image = mpimg.imread(rootDir+'test_images/solidWhiteRight.jpg')
#printing out some stats and plotting
print('T... |
1a19326104ba81becd059e57cfe5b7e814324a58 | Jaiaid/random_code | /lorenz_curve/lorenz_curve.py | 2,917 | 3.859375 | 4 | import argparse
import turtle
import math as m
"""This is 3d lorenz curve generator in any 2 dimension plane using turtle
Lorenz curve equ.
dx/dt = sigma * (y - x)
dy/dt = x * (rho - z) - y
dz/dt = x * y - beta * z
"""
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=
... |
e3e92cee5f1a01c702747fb3d656e1163a169dcd | thomaslorincz/alberta-elevation | /common.py | 1,858 | 3.5 | 4 | import math
import os
import numpy as np
ELEVATION_DICT = {}
SAMPLES = 3601
def get_elevation(filename, lon, lat):
"""
Get the elevation at the provided lat/lon in meters. The resolution of the
data is 1 arc-second (~30m). For SRTM data with 3 arc-second resolution,
change the number of samples from... |
a1e0f6e73061ae8348a70ddb91efa3beed87c26e | CatalinaR/CryptoDNA | /encryption.py | 1,239 | 3.890625 | 4 |
from array import array
sequence = raw_input('Introduce sequence:\n')
xkey = raw_input('Introduce a key:\n')
def change(sequence):
xcode = []
for letter in sequence:
if letter =='A':
xcode.append(0)
elif letter == 'T':
xcode.append(1)
elif... |
f53f7406f0ab215a2783614e7961ee1f8b532300 | jamespoffenroth/pyapi20191111 | /listreview.py | 614 | 4.1875 | 4 | #!/usr/bin/python3
def main():
mylist = []
# Append works by opening up a single slot a the END of the list and inserting the value
mylist.append("192.168.102.55")
mylist.append("10.10.0.1")
print(mylist)
## Extend works by intereating access the value passed, and opening up that may slot... |
65a0f607412f0638639729e4033a9b4e11dafdf6 | maoxifeng/gitex | /fold1/c2.py | 2,594 | 3.953125 | 4 | # -*- coding: utf-8 -*-
class Student( object):
'this is a student class'
count = 0
books = []
def __init__( self, name, age):
self.name = name
self.age = age
pass
wilber = Student( "Wilber", 28)
print "Student.count is wilber.count: ", Student.count is wilber.count
wil... |
2afd0cf69a45cb16f9f3c032aff4e7af2965cc6e | lava12005/hydroplaningpy-dev | /hydroplaningpy/general_func.py | 391 | 3.671875 | 4 | import numpy as np
import math
__all__ =['deg_to_rad', 'rad_to_deg']
def _mat_rotation(theta_d):
"""Convert angle into rotation matrix. Input is in degree"""
theta = theta_d*math.pi/180
return np.array([[np.cos(theta), -np.sin(theta)],[np.sin(theta), np.cos(theta)]])
def deg_to_rad(theta_d):
return t... |
e0c3c56c242eba4dbc6ac42bc7d708ba67a02c0d | MichiMar/lottery_python | /spmain.py | 436 | 3.5625 | 4 | import numpy as np
def balance_loteria(otros_balances):
lista_contenedora = []
for (name, balance) in otros_balances.items():
for _ in range(balance):
lista_contenedora.append(name)
return lista_contenedora
balances = {
'gano': 1,
'perdio': 10
}
print(balance_loteria(bal... |
a03379bc71af236b98cc6c5f75ecceac9885f7e0 | nastya204/python_files | /17.04(дом).py | 788 | 3.6875 | 4 | def build_roof(r,rc):
pass
def build_walls(r,wc):
pass
def build_door(r,dc):
pass
def build_house(my_dream,colors):
house = False
roof_color = colors[0]
house_color = colors[1]
door_color = colors[2]
roof = my_dream[0]
walls = my_dream[1]
while not house:
... |
ed5494b074427d3a22dfd3c6f710e89dc15519f4 | Panamera-Turbo/MyPython | /leetcode/19-removeNthFromEnd.py | 700 | 3.65625 | 4 | # Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode:
if head.next == None:
return None
pre = head
cur... |
8ffec07a2469e54e54ac82f7bd7b93eca2332a00 | Panamera-Turbo/MyPython | /loop/while.py | 754 | 3.640625 | 4 | '''
while循环
'''
number = 0
while number < 5:
print(number+10)
number += 1
# 让用户选择何时退出
print('\n--------------------------------\n第一次实验')
a = '\n输入的内容会被重复'
a += '\nwq保存退出:'
message = ''
while message != 'wq':
message = input(a)
if message != 'wq':
print(message)
print('-------... |
cba1a79745570da7a768ca887f12ca4681d46219 | Panamera-Turbo/MyPython | /01-hello,world/input.py | 294 | 3.75 | 4 | '''
输入
'''
#input()终止程序,在屏幕显示括号内的内容,
#并把输入以字符串返回给变量
# message = input('type in sth. ,I will repeat:\n')
# print(message)
#int()、float()等用来获取数值输入
age = input("your age:")
print(float(age)+1.037492879) |
3aac76993a5ed9cf0425e0dced21e12987c13115 | Panamera-Turbo/MyPython | /leetcode/35-searchInsert.py | 599 | 3.8125 | 4 | from typing import List
class Solution:
def searchInsert(self, nums: List[int], target: int) -> int:
n = len(nums)
if target > nums[n-1]:
return n
elif target < nums[0]:
return 0
l = 0
r = n-1
while l < r:
m = ... |
b9be0e55630b696eb260972e1e05ca75595c91c3 | Panamera-Turbo/MyPython | /list/use_a_part.py | 663 | 4.28125 | 4 | '''
这一章学习如何处理部分元素
'''
cars = ['audi', 'BMW', 'porsche', 'ducati', 'farrari', 'VW', 'bugatti']
#打印指定片段
#list[a:b]从a到b号(从0开始计数,不处理b)。如果没有a,默认a=0;没有b,默认到结尾
print(cars[2:5])
#['porsche', 'ducati', 'farrari']
print(cars[:6])
#['audi', 'BMW', 'porsche', 'ducati', 'farrari', 'VW']
print(cars[:])
#全部打印
print(cars... |
21cf0dbf0df314ffd1214e28e37f02613a94a1b3 | Panamera-Turbo/MyPython | /list/traverse.py | 785 | 4.25 | 4 | '''
循环
'''
# 用for循环打印
cars = ['audi', 'BMW', 'porsche', 'ducati', 'farrari', 'VW', 'bugatti']
for car in cars:
#注意,不要遗漏冒号
print(car.upper())#car是临时变量,随便取,这样便于理解而已
print(car.title() , "is a(n) nice car\n")
print("That's all. Thanks")#注意缩进
print('------------------------------------------')
#数值... |
2c90b6e5c0795695eaf6900c93d2dcd150fca779 | cptcanuck/advent2020 | /dec1/day1.py | 525 | 3.71875 | 4 | #!/opt/local/bin/python
with open('input.txt') as f:
lines = [line.rstrip() for line in f]
#print(lines)
for line in lines:
number = int(line)
for otherline in lines:
othernumber = int(otherline)
for anotherline in lines:
anothernumber = int(anotherline)
answer = num... |
8cfc30786e84a2ee6119d4b42bfb0dd2bee199db | qwangzone/app_python | /dingzhilei.py | 519 | 3.609375 | 4 | from typing import Iterable, Iterator
from datetime import datetime,timedelta
class Fib():
def __init__(self):
print("调用__init__")
self.a,self.b = 0,1
def __iter__(self):
print("调用__iter__")
return self
def __next__(self):
print("调用__next__")
self.a, self... |
96ff40e4645daf7955eeb11c71cfe4cb328368ef | qwangzone/app_python | /getmaxsamesStr.py | 269 | 3.640625 | 4 | def get_maxSubStr(str1, str2):
str_all_sub = [str1[i:i + x + 1] for x in range(len(str1)) for i in range(len(str1) - x)]
str_all_sub.reverse()
for i in str_all_sub:
if i in str2:
return i
print(get_maxSubStr("abcdee", "qwsaabcdeq"))
|
b4c0e42fc4105f9f601ec7580b81c3bb4da8db77 | ubercareerprep2021/Uber-Career-Prep-Homework-Jacqueline-Tapia | /Assignment1/Part3.py | 1,694 | 4.125 | 4 | # Implement the Stack class from scratch (do not use your language’s standard stack or queue library/package methods).
# In this challenge, your Stack will only accept Integer values.
# Implement the following methods:
#push() → Pushes an integer on top of the stack
#pop() → Removes what is on the top of the stack, a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.