blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
dc0cf84bbf13e3a61d52613f0aa7efc09761e553 | st-lee/Supervised_ML_Lab | /L2_LinearRegression/S25_PolynomialRegression/polu_reg.py | 1,067 | 3.921875 | 4 | import pandas as pd
import numpy as np
import pandas as pd
from sklearn.linear_model import LinearRegression
from sklearn.preprocessing import PolynomialFeatures
# Assign the data to predictor and outcome variables
# TODO: Load the data
data = pd.read_csv('data.csv')
data.head(10)
X = data['Var_X'].values.reshape(-1,... |
ee43d4053f2f6dee246092f2c1619f274f5ec136 | kakshay21/ML-tensorflow | /mnistv3.py | 2,480 | 3.53125 | 4 | import tensorflow as tf
''' Basic idea
input > weight > hidden layer 1 (activation function)>weights
>hidden layer 0 (activation function) > weights>hidden layer 2 (activation function) > weights > output layer
'''
from tensorflow.examples.tutorials.mnist import input_data
mnist=input_data.read_data_sets("A/", one_hot=... |
139f09a7d3cc976b884cff51ab1e5785189416ff | MarcieL-Bezerra/Gerenciador-de-Portaria | /fotobd.py | 463 | 3.71875 | 4 | import sqlite3
class Banco():
def __init__(self):
self.conexao = sqlite3.connect('SQLite_Python.db')
self.createTable()
def createTable(self):
c = self.conexao.cursor()
c.execute("""create table if not exists new_employee (
nomes TEXT NOT NULL,
fotos BLOB ... |
186de9fba51a3542a8e5c5fafe4643de6c631536 | jmullen2782/projects | /practice_classes.py | 576 | 3.859375 | 4 | '''
Created on May 13, 2019
@author: jmullen19
'''
class Car:
def __init__(self,c,m=0,s=0):
self.color = c
self.speed = s
self.mileage = m
def get_color(self):
return self.color
def get_speed(self):
return self.speed
def get_m... |
1ba037ec34f8012dc79a275b0ad564f1a65b42ea | NoireFedora/PizzaParlourAPI | /PizzaParlour.py | 14,562 | 3.65625 | 4 | import flask
import json
from flask import Flask, request, jsonify
app = Flask("Assignment 2")
# Start Code
@app.route('/pizza')
def welcome_pizza():
return 'Welcome to Pizza Planet!'
# Object Order
class Order:
def __init__(self, order_id: str, pizza_list: list = None, drink_list: list = None, address: st... |
9c159d70b5529806ad374a11f5895cd9d0ab4dbc | TovarischSukhov/learn-homework-1 | /if2.py | 1,138 | 4.3125 | 4 | """
Домашнее задание №1
Условный оператор: Сравнение строк
* Написать функцию, которая принимает на вход две строки
* Проверить, является ли то, что передано функции, строками.
Если нет - вернуть 0
* Если строки одинаковые, вернуть 1
* Если строки разные и первая длиннее, вернуть 2
* Если строки разные и вторая с... |
b463f58b7b58ae8d6ba0ba58caaea79fd57a23ae | ErNaman/python-practice | /sum2.py | 156 | 4.0625 | 4 | def sum():
x=int(input("enter value of x:- "))
y=int(input("enter value of y:- "))
z=x+y
return(z)
print("sum of x and y is:-",sum())
|
6a15d87db4c7774514cf4d143928e9f69699e8ad | Kemal001/TransferClassesOrganizer | /views/gui.py | 3,454 | 3.734375 | 4 | try:
# default python should be 3
from tkinter import *
except ImportError:
# most likely triggered by using python 2.7
from Tkinter import *
def remove_values_from_list(the_list, val):
return [value for value in the_list if value != val]
class MainWindow():
def __init__(self, parent):
self.frame = Frame(... |
720786e22b6aa24de7a02083e8f99f01a48296d6 | antonioavilesUAG/cspp10 | /unit3/aaviles_numguess.py | 432 | 3.953125 | 4 | import random
num = (random.randint(1,100))
guess = int(input("Try to guess the right number: "))
attempt = 0
while num != guess:
if num > guess:
guess = (int(input("too low try again: ")))
attempt = attempt + 1
elif num < guess:
guess = (int(input("too high try again: ")))
att... |
ddc7cb26c35dfc5d26bb45e49fbee833867d86f6 | barua-anik/python_tutorials | /truthiness.py | 176 | 4.0625 | 4 |
animal = input("enter the animal you love ")
if animal=="dog" or animal=="cat":
print(animal + " is my favoutire too")
else:
print("I dont like this " + animal + " FU")
|
1a8b0042590fe138d545db120a406480ea26e9a1 | jinwei15/java-PythonSyntax-Leetcode | /LeetCode/src/SqrtX.py | 863 | 3.703125 | 4 | import sys
class Solution:
def mySqrt(self, x):
"""
:type x: int
:rtype: int
"""
if x == 0: return 0
if x == 1 or x == 2: return 1
left = 0
right = x
while (True):
mid = (left + right) // 2
if mid * mid > x:
... |
3320804a329f20fd2793795e1cb49d16977f8c20 | slemal/MATH0499-1 | /clustering/Dendrogram.py | 3,320 | 4.0625 | 4 | #!/usr/bin/env python3
# -*- coding:utf-8 -*-
import abc
from typing import *
class Point(tuple):
"""
A class for representing points in the euclidean space.
"""
def __add__(self, other):
return Point(self[i] + other[i] for i in range(len(self)))
def __mul__(self, scalar):
return Point(scalar * self[i] for... |
6f0276de6fda4756849883ecdfd43ed299e19766 | sbhattathiri/pesolutions | /project_euler_03.py | 542 | 4.03125 | 4 | import math
def get_list_of_prime_numbers_below_x(x):
set_of_prime_factors = set()
while x%2 == 0:
set_of_prime_factors.add(2)
x = x/2
for divisor in range(3,int(math.sqrt(x))+1, 2):
while x%divisor == 0:
x = x/divisor
set_of_prime_factors.add(divisor)
... |
9fc0ffaa5aee844e7b768a89da7deb3108f87b92 | ASU-CompMethodsPhysics-PHY494/activity_10_numbers_sine_series | /series.py | 418 | 3.875 | 4 | # implementation
def sin_recursive(x, eps=1e-16):
"""Calculate sin(x) to precision eps.
Arguments
---------
x : float
argument of sin(x)
eps : float, optional
desired precision
Returns
-------
func_value, N
where func_value = sin(x) and N is the number
of term... |
51d2fd2cb1a1abce93daa7b1e6265d20a90a664a | maxsours/csc-311-final-project | /part_a/item_response.py | 6,933 | 3.625 | 4 | from utils import *
import numpy as np
import matplotlib.pyplot as plt
def sigmoid(x):
""" Apply sigmoid function.
"""
return np.exp(x) / (1 + np.exp(x))
def neg_log_likelihood(data, theta, beta):
""" Compute the negative log-likelihood.
You may optionally replace the function arguments to rece... |
6080c2a01d6a70a4a0f39cb254a22986975fe66b | davidadamojr/diary_of_programming_puzzles | /arrays_and_strings/regex_match_adv.py | 3,219 | 3.859375 | 4 | """
An efficient and elegant regular expression matcher.
Note: This has not been tested at all.
Source: http://morepypy.blogspot.com/2010/05/efficient-and-elegant-regular.html
"""
class Regex(object):
def __init__(self, empty):
# empty denotes whether the regular expression can match the empty string
... |
9ea5fed57237bb484f1b0023592e4df8448bf7ff | Parichaymandal/PythonProject | /analysis/anova.py | 6,969 | 3.859375 | 4 | import numpy as np
from scipy.stats import f
from matplotlib import pyplot as plt
def seasonal_individual_averages(y, x, i):
"""Function that computes grouped averages of y by factors x (month) and i
(individual identifier). x are considered to be months and are grouped
according to meteorological seasons... |
50f4a2a1d63024a25ab2fa9f56c7c5ebf571a3ff | asingleneuron/leetcode-solutions | /may_leetcode_challenge/Day_12/singlenonduplicate.py | 2,367 | 3.71875 | 4 | class Solution:
def singleNonDuplicate_with_Xor(self, nums: List[int]) -> int:
result = 0
for _ in nums:
result ^= _
return result
def singleNonDuplicateUtil(self, nums, low, high):
if low >= high:
# print(low, high)
return nums[high... |
e4eacf2d2dd40e5c7c923ec6cbb8bc4ca85a98eb | EydenVillanueva/Exercises | /Python/chessMatrix.py | 543 | 3.96875 | 4 | def isChess(matrix):
for i in range( len(matrix[0]) ):
for j in range( len(matrix[0]) ):
if ( i == 0 or i%2 == 0) and ( j == 0 or j%2 == 0):
if matrix[i][j] != 1:
return False
elif i%2 != 0 and j%2 != 0:
if matrix[i][j] != 1:
... |
d354192b47c105b63d9389f69b21c75f3e62f466 | ryeLearnMore/LeetCode | /069_sqrtx.py | 812 | 3.96875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#@author: rye
#@time: 2019/3/19
'''
二分法。
当时没想到。
tips:
注意return的条件
'''
class Solution(object):
def mySqrt(self, x):
"""
:type x: int
:rtype: int
"""
# 作弊
# return int(x ** (1 / 2))
if x == ... |
40bd5380029210d44b09a9ff2cc08fc9347829cd | vyahello/rent-electro-scooter | /scooter/infrastructure/numbers.py | 182 | 3.515625 | 4 | def make_int(text: str, default: int = -1) -> int:
"""Converts text into integer."""
try:
return int(text)
except (TypeError, ValueError):
return default
|
4c67876fa8e108563b99bbed7b845a192991c00a | ashcoder2020/Python-Practice-Code | /factorial using inbuilt function.py | 115 | 4.09375 | 4 | import math
n=int(input("Enter a number to find factorial : "))
print(f"Factorial of {n} is ", math.factorial(n)) |
c3552f29f258b1c05ae8ea111f1d1bbb76d58616 | chiseungii/baekjoon | /01110.py | 200 | 3.671875 | 4 | N = int(input())
before = N
cycle = 0
while 1:
cycle += 1
tmp = before % 10 + before // 10
after = before % 10 * 10 + tmp % 10
if after == N: break
before = after
print(cycle)
|
e50bda6eadc71faa6ac247c2aba8b22cf7bf9919 | bartoszmaleta/3rd-Teamwork-week | /common_elements.py | 409 | 4 | 4 | first_list = [1, 2, 3, 5, 'test', 'piwo', 0, 11, 'o']
second_list = [1, 6, 3, 7, 0, 'test']
common_elements = []
for elem in first_list:
if elem in second_list:
common_elements.append(elem)
print(common_elements)
print()
print('list of common elements: ', common_elements)
print('list of common elemen... |
93d3f061b1f4d75aa6904e8e9d93184f6b03cefb | TatsuLee/pythonPractice | /leet/l24.py | 839 | 3.90625 | 4 | # Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def swapPairs(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
if head is None or head.next is None:
... |
e3040d85188c338ac3c5c21527a22b73e0fe75f6 | erjan/coding_exercises | /shortest_path_with_alternating_colors.py | 3,987 | 3.796875 | 4 | '''
You are given an integer n, the number of nodes in a directed graph where the nodes are labeled from 0 to n - 1. Each edge is red or blue in this graph, and there could be self-edges and parallel edges.
You are given two arrays redEdges and blueEdges where:
redEdges[i] = [ai, bi] indicates that there is a directe... |
c4b56c25ddd0678b876aa087b26ca414c51b6c0d | Meghashrestha/assignment-python | /20.py | 464 | 4.03125 | 4 | #20. Write a Python program to count the number of strings where the string
#length is 2 or more and the first and last character are same from a given list of
#strings.
def string(str):
list=[]
sum = 0
list = str.split(" ")
n = len(list)
for n in list:
if n > 2:
sum = sum + lis... |
3d9d85478f3c933ca880f17e7a13a0edc0061154 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2469/60839/296065.py | 446 | 3.671875 | 4 | n=int(input())
x=input()
y=input()
if n==2 and x=="aabcbcdbca" and y=="aaab":
print(4)
print(2)
elif n==2 and x=="aabcbcdaabca" and y=="aaadacab":
print(4)
print(5)
elif n==2 and x=="aabcbcdaabca" and y=="aaacab":
print(4)
print(3)
elif n==2 and x=="aabcbcdaabca" and y=="aaab":
print(4)
... |
c28d83e05aa32ef301f553f24e11a2a1bccfbefd | hpellis/learnpythonthehardway | /harriet_ex11.py | 306 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Nov 28 17:03:34 2018
@author: 612383249
"""
print("How old are you?", end='')
age=input()
print("How tall are you?", end='')
height=input()
print("How much do you weigh?", end='')
weight=input()
print(f"So, you're {age} old, {height} tall and {weight} heavy.") |
02e18b4f8e3d36e39c330baaf133e11e955d25f2 | ppjh8263/programmersCodingTest | /dartGameKakao2018/myCode.py | 956 | 3.59375 | 4 | import re
def solution(dartResult):
answer = 0
resultStr = dartResult
score = re.findall("\d+", resultStr)
squre = re.findall("\D", resultStr)
scoreStr = re.findall("\D", resultStr)
for i in range(0, 3):
if '#' in squre:
squre.remove('#')
if '*' in squre:
... |
52adf6d6bd45767c64729fcf7c422538aa01e39b | Sabrina-AP/python-curso_em_video | /Exercícios/ex079.py | 409 | 4.1875 | 4 | #79 aula 17 listas
valores=[]
continuar='S'
while continuar!='N':
valor=int(input('Digite um valor: '))
print('Valor adicionado com sucesso...')
continuar=input('Quer continuar? [S/N] ').upper()
if valor not in valores:
valores.append(valor)
valores.sort()
print(f'Você d... |
07efebab2d31d4e678d5153625526a951fb1c9eb | zzZ5/StudyNote | /Python/abstract factory.py | 1,164 | 4.0625 | 4 | #!usr/bin/python3
# -*- coding: utf-8 -*-
# author zzZ5
import random
class PetShop:
'''一个宠物商店'''
def __init__(self, animal_factory=None):
# 宠物工厂只是一个抽象工厂, 我们可以在未来使其实例化
self.pet_factory = animal_factory
def show_pet(self):
# 使用抽象工厂创建和展示宠物
pet = self.pet_factory()
... |
209fbf05a97dcfa2f38903915cea39a4992f0edd | pawangeek/Python-codes | /Maths/sum_tillone.py | 166 | 3.796875 | 4 | # Task : Repeatedly add all its digits until the result has only one digit.
for i in range(int(input())):
p = (int(input()))%9
print(9) if p==0 else print(p) |
686c118683aa3f2a1a9579b87860057f9ce7820e | Per48edjes/Udacity-DAND-P3 | /audit.py | 8,793 | 3.90625 | 4 | # Import dependencies
import re
# Function to clean phone numbers
def update_phoneNum(phone_num):
'''
Cleans phone numbers to match (xxx) xxx-xxxx phone number convention.
Arguments:
phone number (string)
Returns:
"cleaned" phone number (string)
'''
# Dictionary containing one... |
63c7448add1e11d406a06b801005e6f1ded5d92b | krishnanunni-pr/Pyrhon-Django | /Regular expression/Rules.py | 685 | 4.0625 | 4 | # re- regular pattern matching
# 1 x='[abc]' either a b or c
# 2 x='[^abc]' except abc
# 3 x='[a-z]' a to z
# 4 x='[A-Z]' A to Z
# 5 x='[a-zA-Z]' both lower and upper case are checked
# 6 x='[0-9]' check digits
# 7 x='[^a-zA-Z0-9]' special symbols
# 8 x='\s' check space
# 9 x='\d' check the digits
# 10 x='\D' except d... |
1422c7ddfe16c6e81586dde3db6509e61bea09da | eecs110/winter2019 | /course-files/lectures/lecture_11/04_dictionary_lookup_from_file.py | 687 | 3.875 | 4 | import json
import sys
import os
# read lookup table from a file:
dir_path = os.path.dirname(sys.argv[0])
file_path = os.path.join(dir_path, 'state_capitals.json')
f = open(file_path, 'r')
capital_lookup = json.loads(f.read())
def get_state_capital(lookup, state):
return lookup[state]
# use lookup table to ans... |
60b079febe206d2196514a901fe9381d13065f6e | pratyusa98/Open_cv_Crashcourse | /opencvbasic/14. Bitwise Operations.py | 875 | 3.5625 | 4 | #Bitwise Operations includes AND, OR, NOT and XOR
#It is most important and use for various purpose like masking
#and find roi(region of intereset) which is in complex shape.
import cv2
import numpy as np
img1 = np.zeros((250, 500, 3), np.uint8)
img1 = cv2.rectangle(img1,(150, 100), (200, 250), (255, 255, 255... |
a5bd7f15fdf6a73022e58f227cc10514449b6b3f | daniel-reich/ubiquitous-fiesta | /dWeA6vWdrPYtwhxoS_11.py | 326 | 3.8125 | 4 |
import string
def count_number(lst):
digits = string.digits
count = 0
lst = ((str(lst).replace('[','')).replace(']','')).split(' ')
for eachvalue in lst:
for eachletter in eachvalue:
if eachletter in digits or eachletter == '.':
count += 1
break
else:
continue
return c... |
513bad1895d123a1329e90e26d4812c7e85127d5 | karolkocemba/final | /flight_schedule.py | 610 | 3.71875 | 4 | import csv
class FlightSchedule:
def __init__(self):
self.flights = []
self.plane_identifiers = []
self.miles = []
def read_data_from_file(self):
with open("flight_data.csv", encoding='utf-8') as file:
reader = csv.reader(file)
for row in reader:
self.flights.append(row[0])
self.miles.append(... |
7efdbd00d940a12ecee31a67b789b7ccaa30f041 | maggiebauer/homework-7.8-salesperson_report | /sales_report.py | 2,146 | 4.09375 | 4 | """
sales_report.py - Generates sales report showing the total number
of melons each sales person sold.
"""
salespeople = []
# creates an empty list to add the salespeople
melons_sold = []
# creates an empty list to track the number of melons sold
f = open("sales-report.txt")
# opens the file 'sal... |
ce981daae2eeda0038941778658b09ced578538b | kelv-yap/sp_dsai_python | /ca3_prac1_tasks/section_2/sec2_task4_submission.py | 780 | 4.3125 | 4 | number_of_months = 6
title = "Calculate the average of your last " + str(number_of_months) + "-months electricity bill"
print("*" * len(title))
print(title)
print("*" * len(title))
print()
bills = []
bill_number = 1
while bill_number <= number_of_months:
try:
input_bill = float(input("Enter Bill #{}: ".for... |
d5cf8a29dfac969d2bcbeea28ff1b55e2478596a | KevinMichelle/Vision_FIME_2015 | /package/utilities/structures.py | 2,316 | 4.5625 | 5 | import sys
# Explanation about the 'dict_to_list' function
#
# We know that the basic element in a dictionary structure is a tuple: the key and their value corresponding to that key.
#
# The key must be hashable, so it may be a number, a tuple, things like that. If am not in a mistake, the value of can be anything.
... |
ebf12acbb0e446c1b793ef712c20103f070e0cbb | rohit523/LeetCode-June-Challenge | /Week2 June 8th–June 14th/Sort Colors.py | 667 | 3.5 | 4 | class Solution:
def sortColors(self, nums: List[int]) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
d = {}
for num in nums:
if num not in d:
d[num] = 1
else:
d[num] += 1
... |
438adb533e5192dcce6070b12902f96676e852a4 | nopomi/hy-data-analysis-python-2019 | /hy-data-analysis-with-python-2020/part04-e09_snow_depth/src/snow_depth.py | 271 | 3.578125 | 4 | #!/usr/bin/env python3
import pandas as pd
def snow_depth():
wh = pd.read_csv("src/kumpula-weather-2017.csv")
max = wh["Snow depth (cm)"].max()
return max
def main():
print("Max snow depth: " + str(snow_depth()))
if __name__ == "__main__":
main()
|
4234c3e9b4ac0c1d3faf50985e00f1a55d860289 | ZimingGuo/MyNotes01 | /MyNotes_01/Step01/2-BASE02/day04_08/demo06.py | 1,695 | 3.765625 | 4 | # author: Ziming Guo
# time: 2020/2/11
"""
demo06:
函数参数
形式参数
练习:exercise09.py
练习:exercise10.py
"""
# 1. 缺省(默认)形参:如果实参不提供,可以使用默认值.
# 如果实参没给全,就会用默认参数值代替
def fun01(a=None, b=0, c=0, d=0):
print(a)
print(b)
print(c)
print(d)
# 关键字实参 + 缺省形参:调用者可以随意传递参数.
# 如果只用缺形形参,那就会一直默认是前两个参数的值,... |
797519240fa689fbfff1b39f022339ff78db84b8 | daniel-reich/ubiquitous-fiesta | /aj7JPnAuW8dy4ggdp_19.py | 172 | 3.71875 | 4 |
def parity(n):
# remander = bool(n % 2)
# if remainder == False:
# return "even"
# if remainder == True:
# return "odd"
return "even" if n % 2 == 0 else "odd"
|
192ca1743d1f2b5e4e56f76d93fd580434464bac | IvanIsCoding/OlympiadSolutions | /beecrowd/1094.py | 740 | 3.5 | 4 | # Ivan Carvalho
# Solution to https://www.beecrowd.com.br/judge/problems/view/1094
# -*- coding: utf-8 -*-
"""
Escreva a sua solução aqui
Code your solution here
Escriba su solución aquí
"""
ordem = int(input())
dicio = {"C": 0, "R": 0, "S": 0}
for i in range(ordem):
a, b = input().split()
dicio[b] += int(a)
t... |
c3595aa8d5ca9e5ec7aeb75ca88c26fe095536ee | megarocks/data_science | /keras/02/naive_relu.py | 760 | 3.5625 | 4 | import numpy as np
from numpy import array
# keras.layers.Dense(512, activation='relu')
# is equal to:
# output = relu(dot(W, input) + b)
# relu is equal to max(x, 0) - rectified linear unit
def naive_relu(x):
assert len(x.shape) == 2
x = x.copy()
for i in range(x.shape[0]):
for j in range(x.sha... |
12e9c7c6b041c1773b1894c3cd01fee49790b04f | DmytroBabenko/Data-Science-NLP-url-segmentation | /word_breaker.py | 3,047 | 3.609375 | 4 | from trie import Trie
class WordBreaker:
def __init__(self, trie: Trie):
self.trie = trie
def word_break(self, input_str: str):
#key - position, value - word
all_words = list()
self._word_break_helper(input_str, 0, all_words)
words = WordBreaker._find_the_best_comb... |
3125a85da2c7382e143f0e9e1dffd2f7aa7e61b4 | J040-M4RC0S-Z/first-programs | /índice de massa corporal em python/IMC.py | 652 | 3.640625 | 4 | import math
print("\033[1;35mIMC\033[m")
alt = float(input("Digite a sua altura (metros): "))
peso = float(input("Digite o seu peso (kilos): "))
imc = peso/math.pow(alt,2)
if imc < 18.5:
print(f"""IMC: {imc:.2f}
Situação: Abaixo do peso""")
elif 18.5 <= imc <= 25:
print(f"""IMC: {imc:.2f}
S... |
78ae4f059d69cf4a7ca53a09dc9ac30529eec7e0 | jberkow713/Super-Checkers | /logic.py | 854 | 3.8125 | 4 | def create_purpose():
favorite_events = []
print('Time to figure out your 5 favorite events')
for i in range(5):
favorite = input('Please type your favorite life events:')
favorite_events.append(favorite)
rankings = []
for x in favorite_events:
print(f'Please rank... |
7d60dd4dd82357ed74dd12dc05bc53ad3ab2b239 | Grimness/pythonDemo | /iterationDemo.py | 420 | 4.09375 | 4 | from collections import Iterable
d = {'a':1,'b':2,'c':3}
for key in d:
print(key)
for value in d.values():
print(value)
for ch in 'ABCDEFG':
print(ch)
print(isinstance('abc',Iterable))
print(isinstance([1,2,3,4],Iterable))
print(isinstance(12345,Iterable))
# enumerate() 方法可以让遍历对象生成角标
for i,value in enumerate(['... |
a787f03fd38a60d8f06e69ccdaaf3aec4a5680a3 | Medona1999/Sem1-Python-Lab | /Python Programs/3swap.py | 203 | 3.90625 | 4 | x=int(input("enter the first number:"))
y=int(input("enter the second number:"))
print("Before Swapping")
print("x=",x)
print("y=",y)
x=x+y
y=x-y
x=x-y
print("After Swapping")
print("x=",x)
print("y=",y) |
ded1825d4cd9226442393479dcd46eab4a24983d | C-CCM-TC1028-111-2113/homework-2-jennmvg | /assignments/02Licencia/src/licencia.py | 435 | 3.78125 | 4 | import math
print ("Ingresa tu edad")
edad= int(input())
if (edad>=18):
id=print (input(("¿Tienes identificación oficial?(s/n)") )
if (id=="s"):
print ("Trámite de licencia concedido")
elif (id=="n"):
print ("No cumples requisios")
else
print ("Respuesta ... |
9797fc4b5bd9aade67f003c6a8019d6c1e9cc0ec | kostacoffee/NCSSchallenge | /2014/Week 2/Aardvark!.py | 203 | 3.890625 | 4 | s = "aardvark"
c = 0
for char in input():
if s[c] == char or s[c].upper() == char:
c+=1
if (c >= len(s)):
print("Aardvark!")
break
else:
print("No aardvarks here :(")
|
72c6c2abcc890492a9a1c9e2cc74e4ccb894bc25 | nagask/Interview-Questions-in-Python | /Arrays/MaximumDrop.py | 546 | 3.96875 | 4 | '''
Given an array of integer, find the maximum drop between two array elements,
given that second element comes after the first one.
num = [13, 2, 23, 15, 6, 68, 19, 1, 12, 13, 100]
Max drop is 99. But answer is 67 because second element must come after first
element. Thus, (1,100) is not a valid case
'''
num = [1... |
c315abf452df8ce3803a1e7260941717f881b1b0 | Weless/leetcode | /python/数组/1427. 字符串的左右移.py | 460 | 3.765625 | 4 | from typing import List
class Solution:
def stringShift(self, s: str, shift: List[List[int]]) -> str:
for direction,amount in shift:
if amount == 0:
continue
if direction == 0:
s = s[amount:]+s[:amount]
else:
s = s[len(s)-am... |
7aaa71a1f89eaed610bfb2f57a6d211b9e1dd3b6 | hisonic001/project | /coding_test/add_2_out_of_list(done).py | 465 | 3.640625 | 4 |
numbers=[5,0,2,7]
def solution(numbers):
answer=[]
for setnum in numbers:
first = numbers.index(setnum)
start = first + 1
restnum = numbers[start:]
for rest in restnum:
result = setnum + rest
if result not in answer:
answer.append(result)... |
b297fd101ad12cf9ea1dd96cc10f1b6478d20c47 | douglasdl/Python | /BasicCourse/practice04-06-01.py | 535 | 3.71875 | 4 | # coding:utf-8
def showMark(symbol, number):
for n in range(number):
print(symbol, end="")
print()
def showMark2(symbol, number):
print(symbol * number)
def showMark3(columns, rows, symbol):
for c in range(columns):
for r in range(rows-c):
print(symbol, end="")
print()
def showMark4(columns, rows, s... |
4fa8fd89c603866ba50d262f1d17a7d4a10b0b2a | razzaqim/NumPy-and-Pandas | /interrogation.py | 1,482 | 3.5 | 4 | import pandas as pd
maths_results = pd.DataFrame ([[29, 40, "fail"], [18 , 85, "pass"], [21, 98, "pass"], [26, 76, "pass"], [20, 30, "fail"]],
index = ["Hana", "Bella", "Jay", "Terry", "Niya"],
columns = ["Age", "Percentage score", "Outcome",])
print(maths_results)
pri... |
3696b7c25e976e1cb4b26a0ae859ddfbd3058976 | wenjiaaa/Leetcode | /P0001_P0500/0103-binary-tree-zigzag-level-order-traversal.py | 954 | 3.84375 | 4 | # https://leetcode-cn.com/problems/binary-tree-zigzag-level-order-traversal/
from typing import List
# Definition for a binary tree node.
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
def zigzagLev... |
a93477059d37def22432536ca61fcbfd53f40430 | taanh99ams/taanh-fundamental-c4e15 | /SS02/0_to_n.py | 177 | 4.28125 | 4 | # for _ in range(2, 8, 3):
# print("Hello")
#
# print("bye")
# x = 5
# for i in range(x):
# print(i)
x = int(input("Enter a number"))
for i in range(x):
print(i)
|
ba35e826f7efd2cc2b33b58bb48e9182a19cd6db | imtiantian/Python_Awesome_Interview | /python数据结构与算法练习/sequential_search.py | 340 | 4 | 4 | #-*- coding=utf-8 -*-
# 顺序查找
def sequential_search(list,item):
pos=0
found=False
while pos<len(list)and not found:
if list[pos]==item:
found=True
else:
pos=pos+1
return found,pos
list=[1,2,32,8,17,19,13,0]
# print (sequential_search(list,3))
print (sequential_sear... |
18496257a0890d8276ab146230c51eb2d48311d2 | aryabartar/learning | /interview/stack-queue-deque/queueusingstack.py | 488 | 3.84375 | 4 | class Queue2Stack(object):
def __init__(self):
self.s1 = []
self.s2 = []
def enqueue(self, item):
self.s1.append(item)
def dequeue(self):
s1 = self.s1
s2 = self.s2
while len(s1) != 0:
s2.append(s1.pop())
value = s2.pop()
while ... |
ea9a0a944dd98c3504c916cfdea324eb9c9b5063 | kapilthakkar72/Sentiment-Mining-and-Domain-Adaptation | /General Sentiment Analyser/Data Training/rudraksh.py | 4,161 | 3.5625 | 4 | import csv
import re
#This Function removes names tagged in the tweets
def removeAtTheRate(s):
match = re.search(r'@([A-Za-z0-9_]+)', s)
if match :
start = match.start()
end = match.end()
s = s[0:start] + s[end:]
return removeAtTheRate(s)
else:
return s
# Generate F... |
0aad155bf9745bdaf0b4399ca01c979af8e448cc | meyerlazard/taffducamp | /site.py | 555 | 3.640625 | 4 | choix = ['yes','no']
print('Bonjour nous vous souhaitons la bienvenue chez LEONALMEYER, vous avez besoin de évaluer un projet dinvestissement,markusrobot va soccuper de vous')
a = input('voulez vous que markus soccupe de vous ?')
if a == choix[0]:
n = input ('combien années : ')
c = input('montant des cash flow : ')
... |
319f458e23753e214544b8236b835b081b1d63d7 | ChrisPMohr/RussianRailroads | /game_state.py | 4,939 | 3.75 | 4 | import game_board
import player_board
class GameState(object):
"""A game state consists of one game board and 2 - 4 player boards"""
def __init__(self, player_num, names):
self.player_num = player_num
self.game_board = game_board.GameBoard(player_num, self)
colors = ['red', 'blue', 'g... |
2f6245f22c6713e2a614c9e028412e486f779b8e | EtienneBrJ/holbertonschool-higher_level_programming | /0x01-python-if_else_loops_functions/9-print_last_digit.py | 143 | 3.8125 | 4 | #!/usr/bin/python3
def print_last_digit(n):
if n < 0:
n = -n
last_dig = n % 10
print(last_dig, end='')
return last_dig
|
dae268110d36954ffc465c845627cc7c0589a515 | s-nilesh/Leetcode-May2020-Challenge | /26-ContiguousArray.py | 1,603 | 3.78125 | 4 | #PROBLEM
# Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1.
# Example 1:
# Input: [0,1]
# Output: 2
# Explanation: [0, 1] is the longest contiguous subarray with equal number of 0 and 1.
# Example 2:
# Input: [0,1,0]
# Output: 2
# Explanation: [0, 1] (or [1, 0]) is ... |
a3a40441b92225c6879060a589f17dfd06ed8c2b | techrabbit58/LeetCode30DaysMay2020Challenge | /main/solutions/number_complement.py | 2,431 | 4.03125 | 4 | """
LeetCode 30-Day Challenge, May 2020, Week 1, Day 4
Given a positive integer, output its complement number. The complement strategy is
to flip the bits of its binary representation.
Example 1:
Input: 5
Output: 2
Explanation: The binary representation of 5 is 101 (no leading zero bits),
and i... |
cabe6422b7dc84ea4af16db60a4504ce84e3028d | BENMASTERSOFT/python-2020 | /numbers.py | 486 | 3.671875 | 4 | import os
os.system('clear')
name = "Ben Mastersoft"
############################################
# Data Types
# Strings
# Numbers
# Lists
# Tuple
# Dictionaries
# Boolean
##########################################
num = 10
num1 = 10.25
print(num)
print(float(num))
print(int(num1))
#Maths
print("7+2 is " + str(7+2)... |
f6bd7e1558cba48387c25c44431cc5049454c890 | yijiantao/WorkSpace | /LeetCode Algorithms/code/83.删除排序链表中的重复元素.py | 618 | 3.578125 | 4 | #
# @lc app=leetcode.cn id=83 lang=python3
#
# [83] 删除排序链表中的重复元素
#
# @lc code=start
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def deleteDuplicates(self, head: ListNode) -> ListNode:
list_set = []
... |
12610d03d1a3dcda97b72efdc50565c862dcae78 | rabiatuylek/Python | /for1.py | 1,620 | 3.890625 | 4 | #sehirler = ["adana","ankara","ardahan","amasya","edirne"]
#for sehir in sehirler:
# print(sehir)
#i = 0
#while i<len(sehirler):
# sehir = sehirler[i]
# print(sehir)
# i = i + 1
# dizi icerisinde yer alan elemanların ismi icerisinde "m" harfi bulunanların yazdırılması
#sehirler = ["adana","ankara","ardah... |
c8550cef63bc559f9f0e8fa7a9a058b4b270b3d3 | DineshNadar95/Coding-stuff | /CodeSignal/move_diagonally.py | 1,583 | 3.75 | 4 | def move_diagonally(cols, rows, home_location, mall_location):
x, y = home_location
end_x, end_y = mall_location
grid = [[set() for _ in range(cols)] for _ in range(rows)]
dx, dy = 1, 1
direction_mapping = {
(1, 1): 0,
(-1, 1): 1,
(1, -1): 2,
(-1, -1): 3
}
... |
2ff333ae0026130d43c1f2cf7c91f8a6e31bdc68 | whatnowbrowncow/projects | /game5.py | 3,294 | 4 | 4 | def game_3():
print """
Welcome to the final round of your Epic quest......
A FIGHT TO THE DEATH!!!!!!!
"""
ready = raw_input("Are you ready to play? yes - I'm ready let's go / no - I'm scared!").lower()
if ready == "yes":
print """
THEN PREPARE TO DIE!!!!
"""
elif ready ==... |
0a0430b4871785f3e16c401b0ea4dcba11775fe5 | neham0521/CS-1 | /Check point 1/monkey_trouble.py | 446 | 4.09375 | 4 |
while True:
Monkey_a= input('Hey Monkey_a: Are you smiling(Y/N)').lower()
if Monkey_a not in ('y','n'):
print('Please enter only Y or N')
continue
else:
break
while True:
Monkey_b = input('Hey Monkey_b: Are you smiling(Y/N)').lower()
if Monkey_b not in ('y','n'):
print('Please enter only Y or... |
2d5d31cae9047383606f1dab0ab183e358856471 | leemingeer/datastruct | /leetcode2.py | 2,210 | 3.765625 | 4 | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
from functools import reduce
class Solution(object):
def addTwoNumbers(self, l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
:rtype: ListNo... |
94b2a5fd51070a6e6133dfdf614d2293f99a9db6 | gtripti/PythonBasics | /Basics/Lists.py | 839 | 4.15625 | 4 | my_list= [1,2,3]
print(my_list)
my_list =['HELLO' , 100 , 2.3]
print(my_list)
# Check Length
print(len(my_list))
my_list= ['one' , 'two' , 'three']
# Indexing
print(my_list[0])
# Slicing
print(my_list[1:])
another_list = ['four' , 'five']
print(my_list + another_list)
new_list = my_list + another_list
print(new_lis... |
6feacd1794222455acfb5ae0cf31e4a470879e87 | Barthelemy-Drabczuk/reversi | /Pawn.py | 376 | 3.734375 | 4 | """
Classe qui représente un pion de Reversi
"""
class Pawn:
# True == White
# False == Black
def __init__(self, color, x, y):
self.color = color
self.x = x
self.y = y
def flip(self):
self.color = not self.color
def __str__(self):
return str(self.color)
... |
1e6c1bdc4f587cac1e1f0485b5a78d71d5967e93 | poojamadan96/code | /Inheritance/superExample.py | 512 | 4.21875 | 4 | class base:
def __init__(self):
super().__init__()
print("base")
class subchild:
def __init__(self):
print("Sub child")
class superchild(base,subchild): # vase is parent class , subchild is child class
def __init__(self):
super().__init__()
print("HEllo")
ob=superchild() # First It will go to superchild wi... |
97fb36516feb5f1362ab79c82f7798b7a1a0db54 | SHIVAPRASAD96/flask-python | /NewProject/python_youtube/continue and break.py | 353 | 3.984375 | 4 | print("continue and break");
magicnumber=26;
#this program finds a magci number depending on what you assign to the magicnumber variable
print("ramessh"+"anchan"+"jump" +"Of the roof");
for n in range(10,30):
if n is magicnumber:
print("Hey awesome the magic number is : ",n);
break;
else:
... |
195c8f32da9cc851b1b8b57500634a6b7e45a3fa | Poobalan1210/data-structures-python | /main.py | 2,042 | 3.984375 | 4 | class Node:
def __init__(self,data=None,next=None):
self.data=data
self.next=next
class Linkedlist:
def __init__(self):
self.head=None
def insertatbeginning(self,data):
node=Node(data,self.head)
self.head=node
return
def insertatlast(self,data):
... |
d11c6afeff1571e3ae8830a0e676379cb7244559 | balajich/python-crash-course | /beginners/05_functions/05_function_with_default_arguments.py | 402 | 3.953125 | 4 | '''
Function with default arguments
'''
def hello(message='Welcome to python tutorial'):
"""
Function with default arguments
:param message:
:return:
"""
print(message)
if __name__ == '__main__':
# Calling function with argument
hello('Hello world')
# Calling function with our ... |
4cd4b0686439a3a1e14120d90ef7ab2b3f3474ea | sti320a/atcoder | /b0901.py | 280 | 3.640625 | 4 | import math
x1, y1, x2, y2 = map(int, input().split())
#2点間の距離を求める
def getDistance(x_1, y_1, x_2, y_2):
result2 = pow(x_2 - x_1, 2) + pow(y_2 - y_1, 2)
result = math.sqrt(result2)
return int(result)
#1辺の長さ
L = getDistance(x1, y1, x2, y2)
|
20a6135c5f5873897127cc028a97e8d58fbd9ea7 | muxiaofefei/LearningRecords | /python/drawSnake.py | 486 | 4.03125 | 4 | # 绘制Python
import turtle
def drawSnake(rad, angle, len, neckrad):
for i in range(len):
turtle.circle(rad,angle)
turtle.circle(-rad,angle)
turtle.circle(rad,angle/2)
turtle.fd(rad)
turtle.circle(neckrad+1,180)
turtle.fd(rad*2/3)
def main():
turtle.setup(1300,800,0,0) #设置启动窗口的宽高和在屏幕的位置
pythonsize = 30
tur... |
1275170992bf7e96f800574233fb3afd48cdf27a | Rohanarekatla/python-basics | /#IMPORT MATH.py | 1,171 | 4.34375 | 4 | import math
#for using the math functions in python we need import them first
'''
we can also use only the specefic math functions by :
from math import sqrt,pow
'''
'''
1.pow()
2.abs()
3.floor()
4.ceil()
5.pi()
6.max()
7.min()
'''
x = pow(2,3)
print(x) #return th... |
3446eb35ce2241a6ec4b50940a9db9bee80a0432 | bryanh210/Algorithm_Data-Structure | /2019/search_in_rotated_and_sorted_array.py | 1,725 | 4.40625 | 4 | Find search and rotated and sorted array
3/4/19 Whiteboarding. Search in a rotated and sorted array
LOGIC:
We have to find which part of the array is sorted, and which is not, and whether the target is in the sorted portion or not
Ex: [6,8,11,15,17,4,5], 4
min mid max
If arr[min] < arr[mid] -> this par... |
6554303516d08fee92aae2bfa67cad27c42e0481 | Dexmo/pypy | /Class/battery.py | 320 | 3.796875 | 4 | class Battery:
""" Simple class with battery model"""
def __init__(self, battery_size=70):
self.battery_size = battery_size
def describe_battery(self):
print("This car has battery with " + str(self.battery_size) + "kWh.")
my_battery = Battery(battery_size=60)
my_battery.describe_battery() |
4246f91a9de85de9f4a4b82369f2d3a92711e6ee | DongIk-Jang/Python_Algorithm_Interview | /10_deque_priorityqueue/347_top_k_frequent_elements.py | 322 | 3.703125 | 4 | from collections import Counter
def topKFrequent(nums, k):
cnt = Counter()
for num in nums:
cnt[num] += 1
print(cnt)
most_common = cnt.most_common(k)
answer = list()
for i, j in most_common:
answer.append(i)
return answer
nums = [1,1,1,2,2,3]
k = 2
print(topKFrequent(nums, k... |
3b052cc6516c7d2978b75b041b401ddb06269324 | Abinash04/Python | /basic/2017/2.py | 500 | 3.78125 | 4 | #By considering the terms in the Fibonacci sequence whose values do not exceed
#four million, find the sum of the even-valued terms.
def fibonacci(n):
fib=[0,1]
my_list=[]
for i in range(2,n+1):
fib.append(fib[-1]+fib[-2])
for i in range(len(fib)):
if (fib[i] <= 4000000) and (fib[i]%2==... |
3b82f1a3c4a4ce036f6eeb3634742c45280c267c | gengyu-mamba/Python3 | /sample/basic/loop.py | 638 | 3.8125 | 4 | # 循环语句
# break语句 从循环内跳出(必须和if连用)
# continue语句 跳跃到循环开头(必须和if连用)
# pass语句 什么都不做
# else语句 用在循环语句后,如果正常结束循环就执行else语句
loop = ['pass', 'continue', 'break', 'python']
for letter in loop:
if letter == 'pass':
print(letter)
pass
elif letter == 'continue':
print(letter)
continue
elif ... |
921a6e23dad0c6f501cbec9896afca008b7feadb | cengiz1erg/HackerRank_Solutions | /Regex/DetectHTMLTags.py | 448 | 3.5 | 4 | import re
input_number = int(input()) #take input number from user
input_list = [] #list of strings of input tags
captured_tags = []
for _ in range(input_number):
input_list.append(input()) #take input tags
for x in range(input_number):
p = re.findall(r'<\s*(\w+)',input_list[x]) #return list of strings
cap... |
d37934c4aca0f7a3714fdb7cbca2fee7afc5c7bb | kt0755/tensorflow_work | /cnn.py | 3,687 | 3.578125 | 4 | ##### MNIST Classifier using CNN
import tensorflow as tf
# download MNIST data
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("/tmp/data/", one_hot=True)
# define CNN model
def build_CNN_classifier(x):
# MNIST data를 3 dimensional 형태로 reshape합니다.
# MNIST data는 gra... |
7a6aff971c523696727afb286003439f399bee01 | adriene-tien/ProblemSolving | /LeetCode/Easy/ContainsDuplicate.py | 740 | 3.75 | 4 | # LeetCode Easy
# Contains Duplicate Question
# O(n) time complexity, worst case is when all numbers are distinct (infinite numbers)
# O(n) space complexity, worst case is when all numbers are distinct (infinite numbers, new dictionary entry each time)
# Faster than 93% of other submissions, but use of dictionary incre... |
0d8da24f6cd576f624635fa4ad8c71d8f7384568 | CodevEnsenada/actividades | /alumnos/Perla/Actividades martes/actividad 1.2.py | 461 | 3.796875 | 4 | from random import randint
minumero = randint(1,15) #genero mi numero
print(minumero) #verifico mi numero
intentos = 1
numero = int(input("adivina mi número, entre 1 y 15: "))
while numero != minumero:
if numero > minumero:
numero = int(input("mi número es menor, inténtalo de nuevo:"))
else:
numero... |
e45869eb64409366f129b110d2a0daba5fc8c781 | miltonjdaz/learning_py | /Python_Practice.py/Section_8/S8_Rep1.py | 276 | 4.15625 | 4 | """ Section 8 Rep 1 """
# Nth fibonacci with loop
def main():
n = int(input("The value of n: "))
curr, prev = 1, 1
for i in range(n-2):
curr, prev = curr + prev, curr
print("The nth Fibonacci number is", curr)
if __name__ == '__main__':
main() |
269890b65715a16aa79763ccf33f213ea676f17b | 132-cabdelmalek/Programming11 | /CREATE IT YOURSELF.py | 1,337 | 4.0625 | 4 | from turtle import*
def draw(do, val):
do = do.upper()
if do == 'F':
forward(val)
elif do == 'B':
backward(val)
elif do == 'L':
left(val)
elif do == 'R':
right(val)
elif do == 'U':
penup()
elif do == 'D':
pendown()
elif do ==... |
0955ac11fe79b08411f8864676a560aab917cc10 | priteshmehta/leetcode | /group_anagrams.py | 912 | 3.546875 | 4 | def groupAnagrams(strs):
def grp_annagram(sub_str):
anagram_word1 = {}
for s in sub_str:
key = "".join(sorted(s))
try:
anagram_word1[key].append(s)
except KeyError:
anagram_word1[key] = [s]
re... |
1f03091cbfd57ee3d4a7c9797a5b9c15fe2f2ba8 | Rahulnavayath/ICTA-Full-Stack-project | /python/sringz.py | 141 | 3.640625 | 4 | a=raw_input("enter a string=")
for i in a:
#if i=="l":
print a[:-1]
print a[2]
print a[0:3]
print a[-1:]
print a[::-1]
break
|
ddd9037614f03ea6a7038376f053596814477215 | LikeLionSCH/9th_ASSIGNMENT | /19_허유빈/session03/01.py | 299 | 3.71875 | 4 | import math
n = int(input("숫자를 입력하세요 >> "))
hap = 1
print(str(n)+"! =", end=" ")
for i in range (n, 0, -1) :
hap = hap * i
if i == 1:
print(i, end="")
else :
print(i, end="x")
print(" =", hap)
# result = (math.factorial(n))
# print(n, "! =", result)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.