blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
ad6fc102c4ad03ca32dc29b84cdffb1d6108147e | VitaliiUr/wiki | /wiki | 2,978 | 4.15625 | 4 | #!/usr/bin/env python3
import wikipedia as wiki
import re
import sys
import argparse
def get_random_title():
""" Find a random article on the Wikipadia
and suggests it to user.
Returns
-------
str
title of article
"""
title = wiki.random()
print("Random article's title:")
... |
e613f8fec147ea3779275d842b9ea717c0d81b6a | jessnightshade/AE401-Python | /determining scores.py | 847 | 3.796875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Feb 14 14:46:06 2020
@author: Jamie
"""
num=input('number of students:')
scorelist=[]
namelist=[]
high=0
low=0
#highname=''
#lowname=''
for i in range (int(num)):
students_name=input('student:')
score=input('score:')
scorelist.append(int(score))
... |
352cf38d9eb30ad66982dd664484bc04a360f5b8 | LordOTime/Zork | /zork2.21.py | 1,256 | 3.859375 | 4 | #!/usr/bin/python
print("What is your name?")
name = raw_input()
print(' ')
print "Welcome to Zork 2.0, %s. Your adventure starts here." % (name)
print("You find yourself standing in the courtyard in the middle of a grand castle. Beneath your feet are gray cobbles, and you are surrounded my many bustling shops, inns, a... |
7d5351b14c26988c70ba2f25426c075f697ac75e | ShijiaLiLiLi/leetcode | /26_Remove_Duplicates_from_Sorted_Array/python.py | 464 | 3.5 | 4 | from typing import List
class Solution:
def removeDuplicates(self, nums: List[int]) -> int:
if len(nums) == 0:
return 0
cur_idx = 0
ori_idx = 1
length = 1
while (ori_idx < len(nums)):
if nums[ori_idx] != nums[ori_idx-1]:
cur_id... |
3597264c90e7ed79a2396541fdb09485550098dc | ans4572/CodingTest-with-Python | /구현/Q11 뱀.py | 1,531 | 3.640625 | 4 | from collections import deque
N = int(input()) # 보드의 크기
K = int(input()) # 사과의 개수
board = [[0] * (N + 1) for _ in range(N + 1)] # 0:빈 공간, 1:뱀 2:사과
for i in range(K):
row, col = list(map(int, input().split()))
board[row][col] = 2
L = int(input())
command = []
for i in range(L):
x, dic = list(input().sp... |
1e2fce93d89f27864c733c6c254d1b2b7597b038 | ans4572/CodingTest-with-Python | /최단 경로/다익스트라.py | 929 | 3.5 | 4 | import heapq
# 노드 개수와 간선 개수
n, m = map(int, input().split())
# 시작 노드 번호
start = int(input())
# 그래프 리스트
graph = [[] for i in range(n+1)]
distance = [float('inf')] * (n+1)
# 간선 입력 받기
for i in range(m):
a, b, w = map(int, input().split())
graph[a].append((b, w))
#다익스트라 알고리즘
def dijkstra(start):
... |
eb4b8614adcefc430b5433348d22253740350209 | ans4572/CodingTest-with-Python | /정렬/6-11 성적이 낮은 순서로 학생 출력하기.py | 224 | 3.65625 | 4 | N = int(input())
arr = []
for i in range(N):
data = input().split()
arr.append((data[0],int(data[1])))
arr = sorted(arr, key=lambda student: student[1])
for student in arr:
print(student[0], end=' ') |
901b51b5e8faba528e6b72607bc8c6bbc13f7248 | hugomst/MITx_6.00.1x_Introduction-to-Computer-Science-and-Programming-Using-Python | /Unit1_PS2.py | 431 | 4.09375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Sep 13 22:02:34 2021
@author: Hugo
"""
Assume s is a string of lower case characters.
Write a program that prints the number of times the string 'bob' occurs in s. For example, if s = 'azcbobobegghakl', then your program should print
Number of times bob occurs i... |
1cc8c34fd13484b3f56df6cb9656ed567e0ca6b0 | VenusMeow/nannonml | /nannon/scratch_nn.py | 4,429 | 3.78125 | 4 | import numpy as np
import scipy.special
# A few useful resources:
#
# NumPy Tutorial:
# https://docs.scipy.org/doc/numpy/user/quickstart.html
#
# Backpropogation Calculus by 3Blue1Brown:
# https://www.youtube.com/watch?v=tIeHLnjs5U8
#
# Make Your Own Neural Network:
# https://www.amazon.com/Make-Your-Own-Neura... |
b2b22e8264799467c43b2051c63228d1304533f6 | rdcorrigan/bmiCalculatorApp | /bmi_calculator.py | 1,070 | 4.125 | 4 | # BMI Calculator
# by Ryan
# Python 3.9 using Geany Editor
# Windows 10
# BMI = weight (kilograms) / height (meters) ** 2
import tkinter
# toolkit interface
root = tkinter.Tk()
# root.geometry("300x150") // OPTIONAL
root.title("BMI Calculator")
# Create Function(s)
def calculate_bmi():
weight = float(e... |
80d0e021194a67ff06851523210bc9f7ca635833 | jimboowens/python-practice | /dictionaries.py | 1,131 | 4.25 | 4 | # this is a thing about dictionaries; they seem very useful for lists and changing values.
# Dictionaries are just like lists, but instead of numbered indices they have english indices.
# it's like a key
greg = [
"Greg",
"Male",
"Tall",
"Developer",
]
# This is not intuitive, and the placeholders give ... |
8c40ada3b9f1b468f736c221640958379739a187 | atakangol/sat-solver | /ex/nqueens-complete-rec.py | 4,624 | 3.859375 | 4 | #!/usr/bin/python
#######################################################################
# Copyright 2019 Josep Argelich
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the... |
28914773c6065a3d262aa995274281503d42cca4 | Finveon/PythonLern | /lesson_2_15.py | 478 | 4.34375 | 4 | #1
print ("1) My name is {}".format("Alexandr"))
#2
my_name = "Alexandr"
print("2) My name is {}".format(my_name))
#3
print("3) My name is {} and i'm {}".format(my_name, 38))
#4
print("4) My name is {0} and i'm {1}".format(my_name, 38))
#5
print("5) My name is {1} and i'm {0}".format(my_name, 38))
#6
pi = 3.1415
p... |
7317cd586606f98c6459206d78b6860c59b05e73 | rocketII/project-chiphers-old | /playfair.py | 8,436 | 3.53125 | 4 | def playfair_encrypt(secret, key, junkChar):
'''
Encrypt using playfair, enter secret followed by key. Notice we handle only lists foo['h','e','l','p']
English letters only lowercase.
:param secret: text string of english letters only,
:param key: string of english letters only, thanks.
:param ... |
97cdb5c6ec41e4ed4b41c5d2310f8f6c0be1a638 | Soldanik/Works | /Операторы/Операторы.py | 8,596 | 3.59375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Nov 29 17:37:32 2018
@author: kiril
"""
#1 задание
a = int(input())
b = int(input())
c = int(input())
if a>=1 and b>=1 and c>=1:
print(a+b+c)
elif a>=1 and b>=1 and c<1:
print(a+b)
elif a>=1 and b<1 and c>=1:
print(a+c)
elif a<=1 and b>=1 and c>=1:
print(b+c)
... |
3969b5d78347e32ec2693bcd86c284e70bd447c5 | teeveeJS/5CL | /weighted_linear_regression.py | 1,127 | 3.515625 | 4 | import numpy as np
from scipy.stats import linregress
def dy_eq(x, y, dx, dy):
slope, _, _, _, _ = linregress(x, y)
return np.sqrt(dy*dy + (slope * dx) * (slope * dx))
def weighted_linear_regression(x, y, dx, dy):
# x, y, dx, and dy should be np.arrays of the data
# equivalent (y) error
deq =... |
9d028054ab5cbab00f2414dc9607e83f4bbdbb35 | nlin24/python_algorithms | /Palindrome-Checker.py | 739 | 4.03125 | 4 | import Deque
'''
Implement a palindrome checking algorithm via deque per https://interactivepython.org/runestone/static/pythonds/BasicDS/PalindromeChecker.html
'''
def palindromeChecker(aString):
stringDeque = Deque.Deque()
for letter in aString:
stringDeque.addFront(letter)
while stringDeque.size... |
735222b563750bceca379969e5cff58224ddf83e | nlin24/python_algorithms | /BinaryTrees.py | 1,982 | 4.375 | 4 | class BinaryTree:
"""
A simple binary tree node
"""
def __init__(self,nodeName =""):
self.key = nodeName
self.rightChild = None
self.leftChild = None
def insertLeft(self,newNode):
"""
Insert a left child to the current node object
Append the left chil... |
febe9542a92f8951533b52dc162c390d3e36bd20 | ruchawaghulde/Wine-Quality-Prediction | /Codes/VolatilAcidity_pH_Alcohol.py | 2,123 | 3.59375 | 4 | #This program computes the quality equation for the following parameters:
#VOLATIL ACIDITY
#pH
#ALCOHOL
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# Preprocessing Input data
data = pd.read_csv('VolatilAcidity_pH_Alcohol.csv')
volatil_acidity= data.iloc[:,0]
pH = data.iloc[:... |
5097aaf179964fe280974bdd912368d976e17e42 | ericktec/pythonBasics | /Erick/POO/Classes/StudenClass.py | 578 | 3.65625 | 4 | class Subject:
def __init__(self, name, score):
self.name = name
self.score = score
class Student:
Subjects = []
def __init__(self,name,subjects):
self.name = name
for key, value in subjects.items():
self.Subjects.append(Subject(key, value))
print(f'{... |
b947d396434da5757847794d37540a33a20d739e | qy-yang/algorithm | /test.py | 495 | 3.734375 | 4 | def insert_intervals(intervals, new_interval):
intervals.append(new_interval)
intervals.sort(key=lambda x: x[0])
inserted =[]
for interval in intervals:
if not inserted or inserted[-1][1] < interval[0]:
inserted.append(interval)
else:
inserted[-1][1... |
973f3576a93865bbbafa2bb6181f2c4bd4b139f6 | Lazzy94/python_base | /lesson_002/04_my_family.py | 988 | 3.8125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Создайте списки:
# моя семья (минимум 3 элемента, есть еще дедушки и бабушки, если что)
my_family = ['Мама','Папа','Я']
# список списков приблизителного роста членов вашей семьи
my_family_height = [
['Мама', 178],
['Папа',179],
['Я', 190]
]
# Выведите н... |
9b1211b0c7f7089db607421bb2820fd4b30a5d4e | diwadd/sport | /cc_chef_and_dice.py | 578 | 3.53125 | 4 | t = int(input())
for _ in range(t):
n = int(input())
stores = n // 4
free_cubes = n % 4
# Each side will have a 5 and a 6 visable
# and there will be 4 sides which gives 44
res = stores * 44
if free_cubes == 0:
if stores > 0:
res += 4*4
elif free_cubes == 1:
... |
40a211cebb90da400234e96b5720467e812f8849 | diwadd/sport | /cf_fit_to_play.py | 655 | 3.515625 | 4 | t = int(input())
for _ in range(t):
n = int(input())
numbers = input().split(" ")
numbers = [int(nb) for nb in numbers]
max_ele = [0 for _ in range(n)]
min_ele = [0 for _ in range(n)]
current_max = numbers[n-1]
for i in range(n-1, -1, -1):
current_max = max(current_max, nu... |
f2cbf76252d98690be310cc410540ef5ed101b33 | 8Gitbrix/Coding_Problems | /HackerRank/Bot saves princess/BotsavesPrincess.py | 786 | 3.71875 | 4 | #!/usr/bin/python
def displayPathtoPrincess(n, grid):
pos = [(n-1)/2 , (n-1)/2] #center of grid
pr = list(tuple(((x,y) for x in range (0,n) for y in range(0,n) if grid[x][y] == 'p'))[0])
st = []
while pos != pr:
if pos[1] == pr[1] and pos[0] < pr[0]: #same row
st.append('RIGHT')
... |
293d74ef5c7e2fa8e7a62b47a6844a1d4f35cb86 | 8Gitbrix/Coding_Problems | /HackerRank/FibonacciModified.py | 195 | 3.765625 | 4 | #Fibonacci Modified
def fibModified(a, b, n):
if n == 3:
return a + b*b
return fibModified(b, b*b + a, n-1)
a, b, c = (int(x) for x in input().split())
print(fibModified(a,b,c))
|
ebc79216c2ca7d8b4a988f67c727fdcf1885eaee | lonelyVoxel/network-lab-Voxel | /Network Lab/udp-server.py | 708 | 3.53125 | 4 | #!/usr/bin/env python3
"""
udp-server.py - UDP server that listens on UDP port 9000 and prints what is sent to it.
Author: Rose/Roxy Lalonde (roseernst@bennington.edu) from template by Andrew Cencini (acencini@bennington.edu)
Date: 3/4/2020
"""
import socket
# Set our interface to listen on (all of them),... |
86887eb80734e2d3d3babad1d77ff18cb0f1a64b | aduV24/python_tasks | /Task 16/Example Error Handling/example_errors_comments.py | 506 | 3.5 | 4 | name = "Tim"
surname = " Jones" #Compilation error; incorrect space indentation, needs to be in line with 'name' and 'age'
age = 21
fullMessage = name + surname + is + age + " years old" #Runtime error; 'age' needs to be indented with str()
... |
d22dd3d84f34487598c716f13af578c3d2752bc4 | aduV24/python_tasks | /Task 19/example.py | 1,720 | 4.53125 | 5 | #************* HELP *****************
#REMEMBER THAT IF YOU NEED SUPPORT ON ANY ASPECT OF YOUR COURSE SIMPLY LEAVE A
#COMMENT FOR YOUR MENTOR, SCHEDULE A CALL OR GET SUPPORT OVER EMAIL.
#************************************
# =========== Write Method ===========
# You can use the write() method in order to write to a... |
617d9a8532d2ee5546bc031c742faf94bbbb7762 | aduV24/python_tasks | /Task 13/example programs/first_while.py | 138 | 3.90625 | 4 | start = 5
while start % 2 != 0:
print(start)
start = start + 1
#loop will only execute once before condition is no longer true
|
473237b007ea679c7b55f3c4c7b5895bdf150ae5 | aduV24/python_tasks | /Task 11/task2.py | 880 | 4.34375 | 4 | shape = input("Enter the shape of the builing(square,rectangular or round):\n")
if shape == "square":
length = float(input("Enter the length of one side:\n"))
area = round(length**2,2)
print(f"The area that will be taken up by the building is {area}sqm")
#====================================================... |
3427a7d78131b4d26b633aa5f70e2dc7a7dab748 | aduV24/python_tasks | /Task 17/disappear.py | 564 | 4.78125 | 5 | # This program asks the user to input a string, and characters they wish to
# strip, It then displays the string without those characters.
string = input("Enter a string:\n")
char = input("Enter characters you'd like to make disappear separated by a +\
comma:\n")
# Split the characters given into a list... |
fe1c9794518562cdc9b39f3f3b80ed7a9657ed57 | aduV24/python_tasks | /Task 20/taskmanager(unedited).py | 5,356 | 3.9375 | 4 | # This python program helps to manage tasks assigned to each member of the team
# for a small business.
# Request for login details
user = input("Enter Username:\n")
password = input("Enter password:\n")
# Create a login control variable
access_gained = False
# Validate login details
with open('user.txt', 'r+', enco... |
55d2392b17d505045d5d80d209dc5635c47657f6 | aduV24/python_tasks | /Task 17/separation.py | 298 | 4.4375 | 4 | # This program asks the user for a sentence and then displays
# each character of that senetence on a new line
string = input("Enter a sentence:\n")
# split string into a list of words
words = string.split(" ")
# Iterate thorugh the string and print each word
for word in words:
print(word) |
28488c65d5d977cb9b48772d64be224bdce8d0bf | aduV24/python_tasks | /Task 11/task1.py | 702 | 4.25 | 4 | num1 =60
num2 = 111
num3 = 100
if num1 > num2:
print(num1)
else:
print(num2)
print()
if num1 % 2 == 0:
print("The first number is even")
else:
print("The first number is odd")
print()
print("Numbers in descending order")
print("===================================")
if (num1 > num2) and (num1 > num3 ):
... |
40df8c8aa7efb4fc8707f712b94971bae08dacea | aduV24/python_tasks | /Task 21/john.py | 344 | 4.34375 | 4 | # This program continues to ask the user to enter a name until they enter "John"
# The program then displays all the incorrect names that was put in
wrong_inputs = []
name = input("Please input a name:\n")
while name != "John":
wrong_inputs.append(name)
name = input("Please input a name:\n")
print(f"Incorrect... |
aa382979b4f5bc4a8b7e461725f59a802ffe3a4e | aduV24/python_tasks | /Task 14/task1.py | 340 | 4.59375 | 5 | # This python program asks the user to input a number and then displays the
# times table for that number using a for loop
num = int(input("Please Enter a number: "))
print(f"The {num} times table is:")
# Initialise a loop and print out a times table pattern using the variable
for x in range(1,13):
print(f"{num}... |
ab8491166133deadd98d2bbbbb40775f95c7091b | aduV24/python_tasks | /Task 24/Example Programs/code_word.py | 876 | 4.28125 | 4 | # Imagine we have a long list of codewords and each codeword triggers a specific function to be called.
# For example, we have the codewords 'go' which when seen calls the function handleGo, and another codeword 'ok' which when seen calls the function handleOk.
# We can use a dictionary to encode this.
def handleGo(x)... |
f090a5013ea570e1764cfe47652172d73a6f20bb | Akoopie/Simple-Banking-System | /banking.py | 6,142 | 3.65625 | 4 | import random
import sys
import sqlite3
registry = {}
class Card:
def __init__(self, card_number, pin):
self.card_number = card_number
self.pin = pin
self.balance = 0
def main_menu():
print('1. Create an account', '2. Log into account', '0. Exit', sep='\n')
option = int(input())... |
92b15ecff2e834f59dec4ac8ea333621a2924255 | jagritiS/pythonProgramming | /database.py | 969 | 3.71875 | 4 | import mysql.connector
#mydb is the database connector
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="",
database="Sunway"
)
print(mydb)
mycursor = mydb.cursor()
#check if the table exists and if not then create a table
mycursor.execute("SHOW TABLES LIKE 'students'")
result = mycursor.... |
8649803360db4c5443510b5485f7885700c823f2 | prateekrastogi92/python-basic-scripts | /sum.py | 140 | 4.0625 | 4 | x=int(input("enter first number"))
y=int(input("enter second number"))
sum_of_numbers = x+y
print("the sum is: {}" .format(sum_of_numbers))
|
ee04a317415c9a0c9481f712e8219c92fb719ce0 | hackettccp/CIS106 | /SourceCode/Module2/formatting_numbers.py | 1,640 | 4.65625 | 5 | """
Demonstrates how numbers can be displayed with formatting.
The format function always returns a string-type, regardless
of if the value to be formatted is a float or int.
"""
#Example 1 - Formatting floats
amount_due = 15000.0
monthly_payment = amount_due / 12
print("The monthly payment is $", monthly_payment)
#F... |
3d2c8b1c05332e245a7d3965762b2a746d6e5c3d | hackettccp/CIS106 | /SourceCode/Module4/loopandahalf.py | 899 | 4.21875 | 4 | """
Demonstrates a Loop and a Half
"""
#Creates an infinite while loop
while True :
#Declares a variable named entry and prompts the user to
#enter the value z. Assigns the user's input to the entry variable.
entry = input("Enter the value z: ")
#If the value of the entry variable is "z", break from the loop... |
824f4f86eaef9c87c082c0f471cb7a68cc72a44f | hackettccp/CIS106 | /SourceCode/Module2/converting_floats_and_ints.py | 1,055 | 4.71875 | 5 | """
Demonstrates converting ints and floats.
Uncomment the other section to demonstrate the conversion of float data
to int data.
"""
#Example 1 - Converting int data to float data
#Declares a variable named int_value1 and assigns it the value 35
int_value1 = 35
#Declares a variable named float_value1 and assigns i... |
98868a37e12fc16d5a1e0d49cb8e076a5ffb107d | hackettccp/CIS106 | /SourceCode/Module10/button_demo.py | 866 | 4.15625 | 4 | #Imports the tkinter module
import tkinter
#Imports the tkinter.messagebox module
import tkinter.messagebox
#Main Function
def main() :
#Creates the window
test_window = tkinter.Tk()
#Sets the window's title
test_window.wm_title("My Window")
#Creates button that belongs to test_window that
#calls the sho... |
b8b69427b405066c56fa51d01f38c678274ddd7b | hackettccp/CIS106 | /SourceCode/Module13/PartA/tire.py | 741 | 3.875 | 4 | """
Tire Object.
"""
#Class Header
class Tire() :
#Initializer
def __init__(self, pressure_in, radius_in) :
self.pressure = pressure_in
self.radius = radius_in
#Retrieves the pressure field
def getpressure(self) :
return self.pressure
#Changes the pressure field
def setpressure(self, pressur... |
c06408e3f4d950798bf62219205f5c8c70c787a2 | hackettccp/CIS106 | /SourceCode/Module5/parameters2.py | 405 | 4 | 4 | """
Demonstrates what happens when you change the value of a parameter.
"""
def main():
value = 99
print("The value is", value)
changeme(value)
print("Back in main the value is", value)
def changeme(arg):
print("I am changing the value.")
arg = 0 #Does not affect the value variable back in the... |
1af15c312f75e507b4acb77abc76b25ff8022318 | hackettccp/CIS106 | /SourceCode/Module5/returning_data1.py | 815 | 4.15625 | 4 | """
Demonstrates returning values from functions
"""
def main() :
#Prompts the user to enter a number. Assigns the user's
#input (as an int) to a variable named num1
num1 = int(input("Enter a number: "))
#Prompts the user to enter another number. Assigns the user's
#input (as an int) to a variable named num... |
c359aae7e1cd194eedb023b580f34e42b7663c27 | hackettccp/CIS106 | /SourceCode/Module2/mixed_number_operations.py | 1,699 | 4.46875 | 4 | """
Demonstrates arithmetic with mixed ints and floats.
Uncomment each section to demonstrate different mixed number operations.
"""
#Example 1 - Adding ints together.
#Declares a variable named value1 and assigns it the value 10
value1 = 10
#Declares a variable named value2 and assigns it the value 20
value2 = 20
... |
188486bfabc4f36413579d6d1af0aaae3da63681 | hackettccp/CIS106 | /SourceCode/Module10/entry_demo.py | 504 | 4.125 | 4 | #Imports the tkinter module
import tkinter
#Main Function
def main() :
#Creates the window
test_window = tkinter.Tk()
#Sets the window's title
test_window.wm_title("My Window")
#Creates an entry field that belongs to test_window
test_entry = tkinter.Entry(test_window, width=10)
#Packs the entry field o... |
2a4a94e8b6c246060f69cae069a9024055e8315b | jackbryan1/Biology-Analysis-Project | /uniplot/analysis.py | 1,020 | 3.59375 | 4 | def average_len(records):
"""Returns the average len for records"""
RecordLength = [len(i) for i in records]
return sum(RecordLength) / len(RecordLength)
def average_len_taxa(records, depth):
"""Returns the average length for the top level taxa"""
if depth is None:
depth = int(0... |
a81aa6362cb19f60ecac87f27c25cc55c81f7c4f | edu-sense-com/OSE-Python-Course | /SP/Modul_06/cyfry_skrypt.py | 568 | 4.03125 | 4 | print("Hi, i will check all singns in value.")
some_value = input("Please enter value (as integer):")
signs_list = []
for one_sign in some_value:
signs_list.append(one_sign)
print(f"Total list is: {signs_list}")
# dla chętnych
for one_sign in some_value:
print(f"{one_sign} => {int(one_sign) * '@'}")
# efekt... |
b4c3e22d4917bcc9adec48ca952cb2298a5b9a39 | edu-sense-com/OSE-Python-Course | /SP/Modul_03/input_02.py | 235 | 3.5 | 4 | # przykładowy skrypt do wykonywania w trybie skyptowym
python_version = 3.8
print("Hi, I want to say hello to you!")
name = input("Please, give me your name:")
print(f"Welcome {name}, my name is Python (version {python_version}).")
|
ee0d1300143d4fb921359f2509ac695d9170efa1 | wllmcdl/hackerrank | /singleSellProfit.gyp | 797 | 4.03125 | 4 | def DynamicProgrammingSingleSellProfit(arr):
# If the array is empty, we cannot make a profit.
if len(arr) == 0:
return 0
# Otherwise, keep track of the best possible profit and the lowest value
# seen so far.
profit = 0
cheapest = arr[0]
# Iterate across the array, updating our an... |
ec69ab4430000ffac0816510691002ebe97eada7 | vijayroykargwal/Infy-FP | /Python by Educator/Demos-Day1/Demos/demos/3-LinkedList.py | 2,829 | 4.0625 | 4 | class Node:
def __init__(self,data):
self.__data=data
self.__next=None
def get_data(self):
return self.__data
def set_data(self,data):
self.__data=data
def get_next(self):
return self.__next
def set_next(self,next_node):
... |
e6ae4cc9d5c1cdb482b8cd6a836db552a02d93e7 | vijayroykargwal/Infy-FP | /MAIN_DSA/Day3/src/Excer7.py | 2,879 | 3.75 | 4 | #DSA-Exer-7
class Stack:
def __init__(self,max_size):
self.__max_size=max_size
self.__elements=[None]*self.__max_size
self.__top=-1
def is_full(self):
if(self.__top==self.__max_size-1):
return True
return False
def is_empty(self):
... |
07446c60f900a859c67cb9235eb3163ddc74f1b4 | vijayroykargwal/Infy-FP | /PF/Day2/src/Assignment17.py | 600 | 3.796875 | 4 | #PF-Assgn-17
'''
Created on Feb 21, 2019
@author: vijay.pal01
'''
def find_new_salary(current_salary,job_level):
# write your logic here
if(job_level==3):
new_salary = 0.15*current_salary + current_salary
elif(job_level==4):
new_salary = 0.07*current_salary + current_salary
... |
9022c29ad620cc63dcdbb962114722f8715cf47c | vijayroykargwal/Infy-FP | /DSA/Day2/src/Excer.py | 1,348 | 3.828125 | 4 | '''
Created on Mar 14, 2019
@author: vijay.pal01
'''
class Node:
def __init__(self,data):
self.__data=data
self.__next=None
def get_data(self):
return self.__data
def set_data(self,data):
self.__data=data
def get_next(self):
return... |
6734a88448568bb6ea98ba902eb36c68044684e7 | vijayroykargwal/Infy-FP | /PF/Day9/src/Assign38.py | 483 | 3.65625 | 4 | '''
Created on Mar 21, 2019
@author: vijay.pal01
'''
def build_index_grid(rows, columns):
result_list = []
for i in range(rows):
list1 = []
for j in range(columns):
list1.append(str(i)+","+str(j))
result_list.append(list1)
return result_list
... |
c1a54f0539877ae5cb9385fccebb74497748e887 | vijayroykargwal/Infy-FP | /MAIN_DSA/Day6/src/Assign24.py | 705 | 3.75 | 4 | #DSA-Assgn-24
'''
Created on Mar 20, 2019
@author: vijay.pal01
'''
def count_decoding(digit_list):
#Remove pass and write your logic here
n=len(digit_list)
count = [0]*(n+1)
count[0]=1
count[1]=1
for i in range(2, n+1):
count[i] = 0
if(digit_list[i-1] > 0):... |
b94a306012d1af7bb6ab9b83c0ce143d3e0758d6 | vijayroykargwal/Infy-FP | /PF/Day2/src/Assignment16.py | 1,016 | 3.953125 | 4 | #PF-Assgn-16
'''
Created on Feb 21, 2019
@author: vijay.pal01
'''
def make_amount(rupees_to_make,no_of_five,no_of_one):
five_needed=rupees_to_make//5
one_needed=rupees_to_make%5
if(five_needed<=no_of_five and one_needed<=no_of_one):
print("No. of Five needed :", five_needed)
prin... |
a68af395a6d75c41ef6858a9dcb7fb3a0a36e31e | vijayroykargwal/Infy-FP | /OOPs/Day5/src/Assign30.py | 3,622 | 3.921875 | 4 | #OOPR-Assgn-30
'''
Created on Mar 12, 2019
@author: vijay.pal01
'''
#Start writing your code here
class Customer:
def __init__(self,customer_name,quantity):
self.__customer_name=customer_name
self.__quantity=quantity
def validate_quantity(self):
if(self.__quantity ... |
0ee599db1abb522bdd6b1ebbc8f5efac0e555269 | vijayroykargwal/Infy-FP | /DSA/Day4/src/Assign18.py | 604 | 4.03125 | 4 | #DSA-Assgn-18
'''
Created on Mar 18, 2019
@author: vijay.pal01
'''
def find_unknown_words(text,vocabulary):
#Remove pass and write your logic here
list1 = []
text = text.split()
for i in text:
if i not in vocabulary:
list1.append(i)
if(len(list1)!=0):
r... |
c5ccf1f31931a42d0a0107468906b154a6be3a00 | vijayroykargwal/Infy-FP | /Python by Educator/Demos-Day1/Demos/demos/1-List.py | 614 | 3.734375 | 4 |
def list_details(lst):
print("Present size of the list:")
print("Size:", len(lst))
lst.append("Mango")
lst.append("Banana")
lst.append("Apple")
print("\nSize of the list after adding some items")
print("Size:", len(lst))
print("\nInserting a new item at the... |
0995c50c3951a585b7bec778680e336a69433bbf | vijayroykargwal/Infy-FP | /OOPs/Day1/src/Assign3.py | 553 | 3.859375 | 4 | #OOPR-Assgn-3
'''
Created on Mar 5, 2019
@author: vijay.pal01
'''
#Start writing your code here
class Customer:
def __init__(self):
self.customer_name = None
self.bill_amount = None
def purchases(self):
bill_amount = self.bill_amount
amount = 0.95*bill_amount
... |
ee18aba9cf78cd81f195d5421bc164708abad080 | vijayroykargwal/Infy-FP | /PF/Day2/src/Assignment18.py | 961 | 3.859375 | 4 | '''
Created on Feb 21, 2019
@author: vijay.pal01
'''
#PF-Tryout
def convert_currency(amount_needed_inr,current_currency_name):
current_currency_amount=0
#write your logic here
if(current_currency_name=="Euro"):
current_currency_amount = 0.01417*amount_needed_inr
elif(current_curren... |
faa8ed79d52a44bdd042d3a09ffda6e7d69d98b9 | vijayroykargwal/Infy-FP | /OOPs/Day2/src/Assign11.py | 2,197 | 3.953125 | 4 | #OOPR-Assgn-11
'''
Created on Mar 6, 2019
@author: vijay.pal01
'''
#Start writing your code here
class Flower:
def __init__(self):
self.__flower_name = None
self.__price_per_kg = None
self.__stock_available = None
def get_flower_name(self):
return self.__flower_na... |
47156f9110245c9e66bf569a37e0a68d618c51ca | vijayroykargwal/Infy-FP | /PF/Day2/src/sample.py | 399 | 4.03125 | 4 | #PF-Assgn-15
def find_product(num1,num2,num3):
product=0
if(num1==7):
product = num2*num3
elif(num2==7):
product = num3
elif(num3==7):
product = -1
else:
product = num1*num2*num3
return product
#Provide different values for num1... |
b95b21ff1f9cf7710c9d87f58b7b32cb5202de62 | vijayroykargwal/Infy-FP | /PF/Day2/src/Assignment20.py | 3,510 | 3.6875 | 4 | #PF-Assgn-20
'''
Created on Feb 21, 2019
@author: vijay.pal01
'''
def calculate_loan(account_number,salary,account_balance,loan_type,loan_amount_expected,customer_emi_expected):
eligible_loan_amount=0
bank_emi_expected=0
eligible_loan_amount=0
#Start writing your code here
if(acc... |
10e486440db7308ddea1772b01621d043d927f1b | vaibhavk039/python-coding | /binary search.py | 515 | 4 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[5]:
a=eval(input("enter a list"))
n=len(a)
num=int(input("a number to find"))
beg=0
end=n-1
for beg in range(0,end+1):
mid=(beg+end)//2
if num==a[mid]:
flag=1
break
elif num<a[mid]:
end=mid-1
... |
4f2f5d67c3e89198b7781c94fd94face395b470c | vaibhavk039/python-coding | /pallindrome.py | 178 | 3.984375 | 4 | s=input()
a=[]
for i in s:
a.append(i)
a.reverse()
listToStr = ''.join(map(str, a))
if(s== listToStr):
print("Pallindrome")
else:
print("Not a Pallindrome")
|
6e470e6f8219a39ebdb2b862ea9bf85c7710c576 | alexbehrens/Bioinformatics | /rosalind-problems-master/alg_heights/FibonacciNumbers .py | 372 | 4.21875 | 4 | def Fibonacci_Loop(number):
old = 1
new = 1
for itr in range(number - 1):
tmpVal = new
new = old
old = old + tmpVal
return new
def Fibonacci_Loop_Pythonic(number):
old, new = 1, 1
for itr in range(number - 1):
new, old = old, old + new
return new
print(Fib... |
71f35fdf946fcec415e53ef247d0980b4a97a1dd | elk1o/starting_pyhton | /Ejercicios_python/Ej5.py | 1,690 | 3.5 | 4 | # -*- coding: utf-8 -*-
import time
# 5) Diseñar un presupuesto con una clase ModeloPresupuesto pidiendo los siguientes datos:
# Nombre de la empresa, nombre del cliente, fecha del presupuesto, descripción del
# servicio, importe bruto, fecha de caducidad , iva e importe total
class ModeloPresupuesto(object):
est... |
e63d8436e30b37537a77f1c61057148099b80167 | pokepetter/brython | /www/src/Lib/asyncio/futures.py | 7,102 | 3.515625 | 4 |
from .events import get_event_loop
class InvalidStateError(Exception):
pass
class CancelledError(Exception):
pass
class TimeoutError(Exception):
pass
class Future:
"""
A class representing the future result of an async action.
Implementations should override the :method:`start` ... |
30bd097010d0007335b49506a945731503b9b5bf | ronnynijimbere/basic-intro-python | /lessons/filters.py | 354 | 4.03125 | 4 | grades = ['A', 'C', 'E', 'F', 'F', 'B', 'D']
def remove_fails(grade):
return grade != 'F'
#print(list(filter(remove_fails, grades)))
# using for loop
#filtered_grades = []
#for grade in grades:
# if grade != 'F':
# filtered_grades.append(grade)
#print(filtered_grades)
#using comprehension method
print([grade fo... |
32e3b00cbc5cdb5a0dc755f4f57a33f81be98baf | eduhmik/Ita_Waiter_App | /tests.py | 233 | 3.578125 | 4 | def remove_duplicates(x,y):
if x > y:
for i in the range of(x,y):
if m % 2 == 0:
return m
elif x < y:
for i in the range of(x,y):
if m % 2 != 0:
return m |
5af688c66904d3d6b0ad57fbb008c93d2797ddd8 | alexeahn/UNC-comp110 | /exercises/ex06/dictionaries.py | 1,276 | 4.25 | 4 | """Practice with dictionaries."""
__author__ = "730389910"
# Define your functions below
# Invert function: by giving values, returns a flip of the values
def invert(first: dict[str, str]) -> dict[str, str]:
"""Inverts a dictionary."""
switch: dict[str, str] = {}
for key in first:
value: str = ... |
ecc6c223791fdc1abd8877cb75270242efeb34e1 | alexeahn/UNC-comp110 | /exercises/ex06/dictionaries_test.py | 1,541 | 3.5625 | 4 | """Unit tests for dictionary functions."""
# TODO: Uncomment the below line when ready to write unit tests
from exercises.ex06.dictionaries import invert, favorite_color, count
__author__ = "730389910"
# tests for invert
def test_invert_one() -> None:
"""Test for first."""
tester: dict[str, str] = {}
... |
8c07973b4801ccec257382cba5a7becbed73c950 | Laylaaaaaa/ECE143-Programming-for-Data-Analysis | /Function Code/read_data_from_excel.py | 6,716 | 3.5625 | 4 | import csv
features, salaries=[], []
headers = {}
def read_data_from_excel(file_path='/Users/shawnwinston/Desktop/ece_143/Train_rev1_salaries.csv'):
'''
reads raw data from an execl file and stores it in a dxn list
where n is the number of data examples and d is the number
of categories
input: fi... |
661465d06478d0a00a74f1c996c45d242d15f0ed | issone/leetcode | /0048_rotate-imag/solution.py | 595 | 3.65625 | 4 | from typing import List
class Solution:
def rotate(self, matrix: List[List[int]]) -> None:
"""
将旋转,转换为先水平翻转,再左对角线翻转
"""
n = len(matrix)
# 先沿水平中线水平翻转
for i in range(n // 2):
for j in range(n):
matrix[i][j], matrix[n - 1 - i][j] = matrix[n ... |
362fb6d0f1a0511432698c2fd6eb3541c8e1315a | issone/leetcode | /0073_set-matrix-zeroes/solution.py | 1,335 | 3.6875 | 4 | from typing import List
class Solution:
def setZeroes(self, matrix: List[List[int]]) -> None:
"""
Do not return anything, modify matrix in-place instead.
"""
if not matrix:
return
row = len(matrix)
col = len(matrix[0])
is_sign = False
for... |
0e4812f02dc8c63932319ac7f1eb4e6a0083bb50 | issone/leetcode | /0056_merge-intervals/solution.py | 814 | 3.640625 | 4 | from typing import List
class Solution:
def merge(self, intervals: List[List[int]]) -> List[List[int]]:
new_intervals = []
intervals.sort(key=lambda x: x[0]) # 先按左区间端点进行排序
for interval in intervals:
if not new_intervals or new_intervals[-1][1] < interval[0]: # 上一个区间的右端点比当前区间... |
447dacc2a84daf98f12d0265ffba6dce84246428 | issone/leetcode | /interview_question/replace_spaces/solution.py | 1,056 | 3.515625 | 4 | class Solution(object):
def replaceSpace(self, s):
"""
时间复杂度和空间复杂度都是O(n)
"""
list_s = list(s)
# 记录原本字符串的长度
original_end = len(s)
# 将空格改成%20 使得字符串总长增长 2n,n为原本空格数量。
# 所以记录空格数量就可以得到目标字符串的长度
n_space = 0
for ss in s:
if ss == '... |
cd834bb1a8bd026ef9bf027a3c11105dcbf51f40 | brenhertel/Pearl-ur5e | /MetaLfD-fork/scripts/screen_capture.py | 2,827 | 3.78125 | 4 | #!/usr/bin/python
'''
-----------------------------------
Capture Trajectory Demonstrations
from a Pointer Device
Usage:
1- run the file
2- press mouse left-button and hold
3- start drawing
4- release mouse left-button to stop
5- program shows the captured data
6- use terminal to save data
... |
152b6e24d03e0d1b9657b1ed46c3a25de9e5126b | btg-work-experience-2019/testing-demo | /src/secret_formula.py | 554 | 3.6875 | 4 | '''
Exposes a class and three functions that perform an amazing calculation
based on user inputs.
'''
def add_two_then_square(value):
return 2 + value * value
def plus_ten(value):
return value + 10
def subtract_one(value):
return value - 1
class FormulaRunner:
def __init__(self, input):
se... |
04d3ec877c01989f96bf4b21297f9d49d5df15b5 | davidorourke1990/ProjectMLS | /main.py | 8,941 | 3.796875 | 4 | import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
MLS19 = pd.read_csv("MLS19.csv")
##print the head
print(MLS19.head())
##print the tail
print(MLS19.tail())
##get the shape of dataset
MLS19.shape
print(MLS19.shape)
##show the dataframe info
MLS19.info()
print(MLS19.info()... |
ded0e835b4d99fdd99764a212c9135cd5411b918 | johnmdelgado/SRE-Project | /scripts/convert_input_to_set.py | 541 | 3.546875 | 4 | #!/usr/bin/python
'''
FileName: convert_input_to_set.py
Author: John Delgado
Created Date: 8/7/2020
Version: 1.0 Initial Development
This will take the sys.stdin input and convert it into a set and then return the set
'''
def convert_input_to_set(inputVales,debug):
if(not inputVales):
raise Exception("In... |
f1abc2a691bff70c89dd53237e84ec1bda634f01 | ericgroom/mcserver-bot | /bot/formatter.py | 433 | 3.6875 | 4 | def format_player_list(players):
if players.online == 0:
return "There is currently nobody online"
if players.max:
result = f"There are {players.online}\{players.max} players online"
else:
result = f"There are {players.online} players online"
if players.sample:
plist = ... |
57b357c1cd9d9e2eed8996564724f488f8e18539 | Padmabala/codekata | /FiboSavings.py | 470 | 3.796875 | 4 | def calculateTotalSavings(month,pastSavings):
if(month in pastSavings):
return pastSavings[month]
else:
total=calculateTotalSavings(month-1,pastSavings)+calculateTotalSavings(month-2,pastSavings)
pastSavings[month]=total
return total
noOfMonths=int(input())
pastSavings={}
pastSavings... |
886ee264c101045c93241d1a9499b03c8360710d | marcelo-rufino/projetopython | /server.py | 1,100 | 3.71875 | 4 | from flask import Flask, render_template, request #importando um modulo do python Flask
app = Flask(__name__,template_folder="./src/views")#joguei dentro de uma variavel app o metodo Flask
@app.route("/",methods = ["GET", "POST"])
def home():
if(request.method == "GET"):
return render_template('index.html... |
43fff8b5123088e2fa7416157b729b0ddb3542a8 | cassjs/practice_python | /practice_mini_scripts/math_quiz_addition.py | 1,687 | 4.25 | 4 | # Program: Math Quiz (Addition)
# Description: Program randomly produces a sum of two integers. User can input the answer
# and recieve a congrats message or an incorrect message with the correct answer.
# Input:
# Random Integer + Random Integer = ____
# Enter your answer:
# Output:
# Correct = Congratulations!
# In... |
85bf56c7e7da9dc7fa11903de41767383492170e | ThomasNam-study/py_sample | /sqliteSample/sl_sample.py | 798 | 3.796875 | 4 | import sqlite3
# 디비 연결
conn = sqlite3.connect("my.db")
# 커서 추출
c = conn.cursor()
# SQL 실행
c.execute("DROP TABLE IF EXISTS cities")
c.execute('''CREATE TABLE cities (rank integer, city text, population integer)''')
c.execute('INSERT INTO cities VALUES(?, ?, ?)', (1, '상하이', 2415000))
c.execute('INSERT INTO cities VA... |
a4f67a429746bf75d5f71e4e031f5929b2610fb8 | ThomasNam-study/py_sample | /scraping/fastcampus/bs_test.py | 1,736 | 3.625 | 4 | from bs4 import BeautifulSoup
html = """
<html>
<head>
<title>The Dormouse's story</title>
</head>
<body>
<h1>this is h1 area</h1>
<h2>this is h2 area</h2>
<p class="title"><b>The Dormouse's story</b></p>
<p class="story">Once upon a time there were three little sisters
<a href="http://example.com/elsie" class="sister... |
3f249f1f491ada7e973d8a1cd27a28831d70efd1 | ThomasNam-study/py_sample | /conc/0601.py | 2,635 | 3.859375 | 4 | # yield from 사용
t = 'ABCDEF'
# For
for c in t:
print('EX1-1 - ', c)
print()
# ITer
w = iter(t)
while True:
try:
print('EX1-2 - ', next(w))
except StopIteration:
break
print()
from collections import abc
# 반복형 확인
print('EX1-3 - ', hasattr(t, '__iter__'))
print('EX1-3 - ', isinstance(t... |
4e1c5d281b58a5eebc7fdcd951fe98ee2f36a8e7 | MFlatley/adventofcode2018 | /Day1/Day1.py | 633 | 3.515625 | 4 | inputList = []
fileName = ".\\adventofcode2018\\Day1\\input.txt"
def calibrateOutput (input, output):
output = output + input
return output;
def findRepeatedFrequency(providedList):
processedList = {0}
frequency = 0
while True:
for change in providedList:
frequency ... |
ba3b8a9489dae42f6164f756dd424f18db07b33d | Shubham07-pawar/Python--Set | /no_common_element.py | 290 | 4.09375 | 4 | # Write a Python program to check if two given sets have no elements in common
s1 = {1, 2, 3, 4, 5}
s2 = {5, 6, 7, 8}
s3 = {9, 10, 11}
print(s1.isdisjoint(s2))
print(s1.isdisjoint(s3))
print(s2.isdisjoint(s3)) # return True if none of item present in both sets otherwise False
|
6bbd6eb8fc67b0d44450332db31d0945a35ea0ef | AveDemid/MITx-6.00.1x | /problems/001-003.py | 466 | 3.5 | 4 | s = 'vwmfkxdz'
temp = ""
total = ""
# TODO refactoring this shit :|
for i in range(len(s)-1):
if len(temp) == 0:
temp = s[i]
if temp[-1] <= s[i+1]:
temp += s[i+1]
if temp == s:
total = temp
if len(s) == i + 2 and len(temp) > len(total):
total = temp
... |
a8e6dd677088f55ab8497fdcc435e9191d11e45b | agpmilli/adaepfl | /Homework/04 - Applied ML/aggregater_helper.py | 1,606 | 3.921875 | 4 | """
Helper function to apply reduction for each column of the dataframe grouped by a key.
Example of call:
grouped_df = original_df.groupby('some_column')
aggregating_functions = [
(['column1'], np.mean,
(['column2', 'column3'], sum),
([('column_name_new_df', 'column_4_from_original_df'), ('column_name_... |
7bae961476f0c48eff4679f17dfbe0d36fe54951 | joshroybal/python_numbers | /otp.py | 4,206 | 3.84375 | 4 | #!/usr/bin/env python
import sys, random
# subprogram encodes checkerboard encodes text to numbers
def encode(text):
checkerboard = { 'A': 0, 'T': 1, 'O': 3, 'N': 4, 'E': 5, 'S': 7, 'I': 8,
'R': 9, 'B': 20, 'C': 21, 'D': 22, 'F': 23, 'G': 24, 'H': 25,
'J': 26, 'K': 27, 'L': 28, 'M': 29, ... |
60b66dd338dac673c719d3ab1c630711a749ff8f | carlosdiaz723/concepts_assignments | /four/student.py | 1,454 | 3.828125 | 4 | '''
Names / Email:
Carlos Diaz cdiaz29@students.kennesaw.edu
College of Computing and Software Engineering
Department of Computer Science
---------------------------------------------
CS4308: CONCEPTS OF PROGRAMMING LANGUAGES
SECTION W01 – SPRING 2020
---------------------------------------------
Module 4
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.