blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
593bf9cbfc1ff4cad5229151d01cb17c8abb690c | rayupton/ACM2-ContinuousIntegration | /fibonacci.py | 354 | 4.25 | 4 | def Fibonacci(n):
"""
Return the n-th value of the Fibonacci sequuence [0, 1, 1, 2, 3, 5, 8, 13, ...]
"""
if n<0:
raise ValueError("n<0 is not valid")
elif round(n) !=n:
raise ValueError("Fractional values of n are not allowed")
elif n<2:
return n
else:
retur... | false |
20b50f60051983da8b258f76966a78ac9e629ba9 | RomanSchigolev/Python__Lessons | /Input_Print/sep_and.py | 1,853 | 4.3125 | 4 | # 1. Напишите программу, которая считывает строку-разделитель и три строки,
# а затем выводит указанные строки через разделитель.
# Формат входных данных
# На вход программе подаётся строка-разделитель и три строки, каждая на отдельной строке.
# Формат выходных данных
# Программа должна вывести введённые три строки ч... | false |
cf81870ed59589c1e6a9aebc3d3e64d200907446 | wlong799/conv-nets | /tensorflow-tutorials/tensorflow-mnist-basic.py | 2,292 | 4.46875 | 4 | """
Introduction to core machine learning concepts and how TensorFlow works, by
creating a simple softmax regression model with no hidden layers to classify
handwritten digits in the MNIST data set.
Achieves approximately 91% accuracy
Walkthrough found here:
https://www.tensorflow.org/get_started/mnist/beginners
Wil... | true |
633e42f4399c37a1d2d04690d668e8a790300414 | janat-t/titech_comp | /CS2/Project2_Sort/bubblesort.py | 619 | 4.15625 | 4 | from sort_core import swap
#
# BUBBLE SORT
#
# IN: arbitrary array
# OUT: array with all values sorted in increasing order
#
# METHOD:
# check online by yourself :)
def sort(array):
""" Non-destructive bubblesort sort.
array is unchanged; returns a sorted copy
"""
res = array.copy()
sort_in... | true |
e1f242ef1a9adb0d25ea6eec0f46f3cb64156b40 | janat-t/titech_comp | /CS1/Hw3_Caesar/caesar.py | 847 | 4.15625 | 4 | # Note that you can change the structure of the function.
# For example, you can change the type of loop.
def enc(k, m):
"""Encode the message m (aka plaintext)
with Caesar cipher and shift key k.
Change only lowercase characters,
Keep other characters.
Return the ciphertext.
"""
# Conv... | true |
e30492de52c01190b004a79444f6f174ccbfe90c | gabrielsalesls/curso-em-video-python | /ex022.py | 1,110 | 4.25 | 4 | nome = str(input("Digite seu nome: "))
'''mai = nome.upper() # deixa a frase em maiusculo
min = nome.lower() # deixa a frase em minusculo
letras = nome.replace(' ', '') # substitui os espaços por algo, nesse caso por nada pra deixar as letras juntas
num = len(letras) # conta o numero de letras e espaços, ness... | false |
899312a4b3aaec069904e97b51e9e67c46aa86d7 | LGRN424/Python-Project | /range_list-rework.py | 341 | 4.46875 | 4 | print "Ascending Order"
print
my_list = ['0', '1', '2', '3','4','5','6', '7', '8']
my_list_len = len(my_list)
for i in range(0,3,1):
print (my_list[i])
print
print "Descending Order"
for i in range(3,-1,-1):
print (my_list[i])
print
print "Even Numbers and Reverse"
for i in range(8,0,-2):
pri... | false |
4b86918f31a7031bfa8d2f43486d13103edcd33c | ege-erdogan/comp125-jam-session-02 | /23_11/vectors.py | 1,195 | 4.15625 | 4 | '''
COMP 125 - Programming Jam Session #2
November 23-24-25, 2020
Implement the following functions for vectors given as a list of size 3
* add_vector: input two vectors, returns resulting vector
* length_vector: input a vector, returns the magnitude of the vector
* dot_product: input two vectors, re... | true |
9aa4f2cdd6f615eca8948f8d0388771e056efb4f | nikitaty/CardsGame | /deck.py | 2,518 | 4.4375 | 4 | # Design a class deck of cards that can be used for different card game
# applications.
# What is the deck of cards: A "standard" deck of playing cards consists of 52 Cards
# in each of the 4 suits of Spades, Hearts, Diamonds, and Clubs. Each suit contains
# 13 cards: Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, Kin... | true |
99ac92a32834d9648c9c46e8eb9175bfd84ddc6c | derrickweiruluo/OptimizedLeetcode-1 | /LeetcodeNew/python/LC_785.py | 2,579 | 4.1875 | 4 | """
Given an undirected graph, return true if and only if it is bipartite.
Recall that a graph is bipartite if we can split it's set of nodes into two independent subsets A and B such that every edge in the graph has one node in A and another node in B.
The graph is given in the following form: graph[i] is a list of ... | true |
767ec58084b63e8c2f87bb04781e2f4f6d4235ad | derrickweiruluo/OptimizedLeetcode-1 | /LeetcodeNew/python/LC_519.py | 1,082 | 4.25 | 4 | """
This is a sampling n elements without replacement problem. It is the same as the operation that random shuffe an array and then return the first n elements.
Here come the trick. When we random pick an element in the array we can store its new position in a hash table
instead of the array because n is extremely les... | true |
f6f30ced739de4689347377433543aff695540d4 | derrickweiruluo/OptimizedLeetcode-1 | /LeetcodeNew/python/LC_774.py | 1,685 | 4.125 | 4 | """
On a horizontal number line, we have gas stations at positions stations[0], stations[1], ..., stations[N-1], where N = stations.length.
Now, we add K more gas stations so that D, the maximum distance between adjacent gas stations, is minimized.
Return the smallest possible value of D.
Example:
Input: stations =... | true |
25e87d060d63f179dc61a8cfe10961e6faaa6377 | Margarita-Sergienko/codewars-python | /7 kyu/String doubles.py | 1,647 | 4.375 | 4 | # 7 kyu
# String doubles
# https://www.codewars.com/kata/5a145ab08ba9148dd6000094
# In this Kata, you will write a function doubles that will remove double string characters that are adjacent to each other.
# b) The 2 b's disappear because we are removing double characters that are adjacent.
# c) Of the 3 c's, we ... | true |
c9c360f3bf43b8cc36a3a4f7f31cf84e447d1783 | Margarita-Sergienko/codewars-python | /7 kyu/Unique string characters.py | 737 | 4.21875 | 4 | # 7 kyu
# Unique string characters
# https://www.codewars.com/kata/5a262cfb8f27f217f700000b
# In this Kata, you will be given two strings a and b and your task will be to return the characters that are not common in the two strings.
# For example:
# solve("xyab","xzca") = "ybzc"
# --The first string has 'yb' whic... | true |
ccf3b7008b39cad355a9c637a92fe4f3099beeaf | Margarita-Sergienko/codewars-python | /7 kyu/Responsible Drinking.py | 939 | 4.1875 | 4 | # 7 kyu
# Responsible Drinking
# https://www.codewars.com/kata/5aee86c5783bb432cd000018
# Welcome to the Codewars Bar!
# Codewars Bar recommends you drink 1 glass of water per standard drink so you're not hungover tomorrow morning.
# Your fellow coders have bought you several drinks tonight in the form of a string... | true |
e86a74dc2ce51d33be8dd3a126db31ea43c92787 | hamna314/iacc_python | /week2/passwordChecker.py | 1,828 | 4.34375 | 4 |
#Password strength checker : Create a function to accept a string and verify if it conforms to the following format
#between 8 to 12 characters long, atleast 1 upper case character,
#atleast 1 number and 1 special character which can be one of '@','#','$','#' ,'%','&'
#Create a function to verify if password length... | true |
dcfda91b7c058b6518e73e960e40af90654402e5 | hamna314/iacc_python | /week1/sum_of_items_in_list.py | 602 | 4.3125 | 4 | '''
Write a python program to sum all the items in a list
'''
#Create a new list with some random numbers
newList = [1,5,19,4,5,8]
#Create a new variable sum_of_List to hold the sum of the items in the list and assign it a value of 0.
sum_of_list = 0
#Create a for loop to iterate over the elements of the list
for it... | true |
228a04513d195e81f06420981ea0d46885d43cd9 | seenureddy/problems | /python-problems/largest_sub_array.py | 1,542 | 4.15625 | 4 | """
Largest sub-array problem
You have an array containing positive and negative numbers (no zeros). How will you find the sub-array with the largest sum.
Example: If the array is: 1, 4, -6, 8, 1, -4, 5, -3, 1, -1, 6, -5
The largest sub-array is: 8, 1, -4, 5, -3, 1, -1, 6
NOTE: You've to print the largest sub-array ... | true |
8991de3e9f56ce86ffd7d8e51c1a6f1f994478a5 | bittercruz/python | /Exercicios/ex1_b_input.py | 480 | 4.15625 | 4 | #!/usr/bin/python3
# -*- coding: UTF-8 -*-
#Retornar a soma de elementos de uma lista
def soma(lista):
soma_item = 0
#tamanho = len(lista)
for item in lista:
#soma_item = soma_item + int(item)
soma_item += int(item)
return soma_item
#lista = [x for x in input("Insira a lista: ").split()]
def get_lista():
... | false |
5d7daff83796a4cbe62e2962ddcfebbe1e8e002a | volodiny71299/04_assessment | /03_assessment.py | 525 | 4.21875 | 4 | # Component three, choose what game to play
game_multi_choice = "multi-choice"
game_other = "other"
error = "please enter 1 or 2"
keep_going = ""
while keep_going == "":
choose = input("Multi-choice(1) or other(2)? ").lower()
if choose == "1":
print()
print("you chose", game_multi_choice)
... | true |
f24e8fbfba3777295b8097710c72af625eee42a3 | prakashtanaji/DSAndAlgo | /dailycode/python/bintreecompletenodescount.py | 1,717 | 4.125 | 4 | # give a binary tree which is complete, find the number of nodes
import queue
def treeSz(root):
curr = root
sz = 1
while True :
if curr.left == None: break
curr = curr.left
sz +=1
return sz
class Node:
val = 0
left = None
right = None
def __init__(self, _val):
... | true |
96a9e48c298c359a2ca9bbf46248e6e89a857b6e | G8A4W0416/Module7 | /fun_with_collections/basic_list_exception.py | 688 | 4.375 | 4 | """
Program basic_list.py
Author: Greg Wilhelm
Last date modified: 03/04/2020
This is just a simple list builder taking in a integer entered by the user and creating a list by repeating the value
three times.
"""
def get_input():
user_input = int(input("Please enter a number: "))
return user_input
def m... | true |
cc50c7f0a4a88f49659214785ff3c422ecc7b250 | ethanmyers92/90COS_IQT_Labs | /Lab3D.py | 425 | 4.375 | 4 | #Lab3D
#Write a program that prompts a user to input an integer and calculates the factorial of that number using a while loop.
def factorial(n):
num = 1
while n >= 1:
num = num * n
n = n - 1
return num
count = 0
while count <= 100:
print factorial(count)
count += 1
else:
... | true |
76651f4059bbd69cbc52ceb1cb71fad5a0943b97 | ethanmyers92/90COS_IQT_Labs | /Lab 2H.py | 1,172 | 4.125 | 4 | #Lab 2H
print "Enter the grades for your four students into your gradebook! Enter grade first then name!"
student_dict = {raw_input("Enter first student's name: ") : int(raw_input("Enter first student's grade: "))}
student_dict[raw_input("Enter second student's name: ")] = int(raw_input("Enter second student's gra... | true |
7feeebca071b5069612d76429b5ef19df7eea6eb | coleMarieG/wcc | /Python/input.py | 597 | 4.15625 | 4 | # name = raw_input('What is your name? ')
# print('Hi ' + name)
# name = raw_input('What is your name?')
# age = raw_input('How old are you?')
# print(name + ' is ' + age + ' years old.')
# # raw_input value is always a string
# age = raw_input('How old are you?')
# dog_years = int(age) * 7
# print('You are ' + str(... | true |
974ffc78548a2192d9a45dfa54f75c1d919f579d | smiley16479/AI_bootcamp | /week_0/Day00/ex03/count.py | 1,694 | 4.25 | 4 | # **************************************************************************** #
# #
# ::: :::::::: #
# count.py :+: :+: :+: ... | false |
5068eb26f4664e523efae0bc297df86978158cfd | mgarchik/P2_SP20 | /Problems/Sorting/05_sorting_problems.py | 2,673 | 4.1875 | 4 | '''
Sorting and Intro to Big Data Problems (22pts)
Import the data from NBAStats.py. The data is all in a single list called 'data'.
I pulled this data from the csv in the same folder and converted it into a list for you already.
For all answers, show your work
Use combinations of sorting, list comprehensions, filter... | true |
6af0a51afcde8bd59eb4bbfb51932c4749993094 | ezgikaradag/Rock-Paper-Scissors-Game | /gamecode.py | 1,139 | 4.1875 | 4 | import random
rock = '''
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
'''
paper = '''
_______
---' ____)____
______)
_______)
_______)
---.__________)
'''
scissors = '''
_______
---' ____)____
______)
__________)
(__... | false |
288b4fc71075613636b9e6713d55603e65a67c7f | DrimTim32/py_proj_lights | /core/data_structures/vector.py | 1,211 | 4.375 | 4 | """This file contains Vector class"""
class Vector:
""" Vector class represents and manipulates x,y coords. """
def __init__(self, x, y):
""" Create a new point """
self.x = x
self.y = y
def __mul__(self, other):
if not isinstance(other, int):
raise ValueError... | false |
5acbd00c44698d654e64145585a619290e097eb1 | RyhanSunny/myPythonJourney | /Common _String_methods.py | 1,582 | 4.1875 | 4 | # A string variable
name = "michael jackson"
# character at index 0
print(name[0])
# character at index -1: first letter backwards
print(name[-1])
# length of string
print(len(name))
# # STRING[START:END:STEP] ex: name[0:10:2]
# Slicing
print(name[0:4]) # slice from index 0 til index 4 (including 0th excluding 4th)
... | true |
3ea4dabedc8f530e4ccbeaab24d898e964fbb379 | avoajaugochukwu/python_mooc | /my_work/stuff.py | 807 | 4.375 | 4 | balance = float(raw_input("Enter the outstanding balance on your credit car: "))
annualInterestRate = float(raw_input("Enter the annual credit card interest rate as a decimal: "))
monthlyPayment = 10
monthlyInterestRate = annualInterestRate/12
newbalance = balance - 10
while (newbalance > 0):
monthlyPayment +... | true |
88b281726cb00301c1d77d76ce70a7bdc56a7c8a | ankhangkieu/CS61A | /hw/hw01/quiz/quiz01.py | 979 | 4.125 | 4 | def multiple(a, b):
"""Return the smallest number n that is a multiple of both a and b.
>>> multiple(3, 4)
12
>>> multiple(14, 21)
42
"""
"*** YOUR CODE HERE ***"
multi = max(a, b)
while multi % a != 0 or multi % b != 0 :
multi = multi + 1
return multi
def has_digit(n, ... | false |
b7f0cb150a1b4087e53e6aa443ff97efd4ed9cae | explodes/euler-python | /euler/lib/seq.py | 2,406 | 4.28125 | 4 | #!/usr/bin/env python
def bin_index(L, item, low=0, high=None):
"""
Perform a binary search on ordered sequence L
If the item is not found, return the index in which it should be inserted
O(lg n)
:param L: ordered sequence to scan
:param item: `item` to search for
:param low: lowest bound ... | true |
7d0896295fae62b13ccfbec05c9777feffd22b9b | explodes/euler-python | /euler/lib/maths.py | 1,956 | 4.21875 | 4 | #!/usr/bin/env python
import math
from euler.lib.gen import lrange
from euler.lib.seq import insert_in_order
def product(seq):
"""
Multiply each item in the list and return the value
"""
total_product = 1
for item in seq:
total_product *= item
return total_product
def divisors(n):
... | true |
e34a14df70505f795977b18c82875b8916ad7461 | ryantanch/PythonOOP-Practice | /oop.py | 2,593 | 4.1875 | 4 | ##################################################
# Python OOP tutorials by Corey Schafer
# Source: Youtube - Corey Schafer
# Practice Done by RyanTanCH 2019
# Ver Python 3.6
##################################################
class Employee:
#Class Variable
No_of_emps = 0;
raise_amount = 1.04
#constructor 1 ... | true |
77be6f889c59ba66824029fb4cf4088d8766905a | azrodriquez/MyPythonCourse | /CH06-functions/movie_info.py | 855 | 4.40625 | 4 | #Bonus material #1
def print_movie(movie, year):
print(f'The movie {movie} is from year {year}.')
movie = "The Matrix"
year = 1999
print(print_movie(movie, year))
# Bonus material #2
def movie_info(user_movie, user_movie_year):
print(f'The movie {user_movie} was released in {user_movie_year}.')
user_movie ... | true |
c93628c22529dbf7a97ed2167e23ed26a74c61ef | azrodriquez/MyPythonCourse | /CH03/display_movie_info.py | 1,320 | 4.1875 | 4 | import sys
#get file name
program_name = sys.argv[0]
print('original name\t\t', program_name)
print('uppercase\t\t', program_name.upper())
print('original name\t\t', program_name)
#replace underscore with space
program_name = program_name.replace('_', ' ')
print('removed underscore\t', program_name)
#replace .\ if ... | false |
d6a977cc012b7963002de1826ce1ebef07b71a71 | balayanr/Daily-Interview-Pro | /problems/count_invalid_parenthesis.py | 444 | 4.28125 | 4 | """
This problem was recently asked by Uber:
You are given a string of parenthesis.
Return the minimum number of parenthesis that would need to be removed
in order to make the string valid. "Valid" means that each open parenthesis
has a matching closed parenthesis.
Example:
"()())()"
The following input should retu... | true |
e10e75d06a31af1a782ce77654e85093ad201e35 | Akhileshbhagat1/All-prectice-of-python | /opps/checkLeapYEAR.py | 461 | 4.15625 | 4 |
while True:
print("Enter a year for check Leap year or not (or q for quit) : ")
year = input()
if year == 'q':
break
else:
if int(year) % 400 == 0:
print(f'{year}' " is a leap year")
elif int(year) % 4 == 0:
print(f'{year}' " is a leap year")
eli... | false |
12ebeaec5b2d9701642b19514aff4578a0e6dd51 | Akhileshbhagat1/All-prectice-of-python | /specialisedCOLLECTIONdataTYPES/namedTUPLE.py | 484 | 4.375 | 4 | # namedtuple() returns the tuple with named value for esch element in the tuple
# details = (name = 'akhilesh', age = '24', language = 'python')
from collections import namedtuple
a = namedtuple('courses', 'name, technology, age, address ')
s = a('akhilesh', 'python', '24', 'bhagaiya')
print(s)
# yo... | true |
ce0aaf7ab12e020f0ace539cb112b682effb5e29 | fosskers/alg-a-day | /day07-linked-list/linked_list.py | 2,189 | 4.21875 | 4 | # A linked list in Python.
# Pretty pointless due to the existence of built-in non-homogenious lists,
# but whatever.
class LinkedList():
'''A linked list. Hurray.'''
def __init__(self, initial_data):
self.root = Node(initial_data)
self.end = self.root
def __str__(self):
nodes = ... | true |
e5bcea62de995b020b566248b41937e390132211 | fosskers/alg-a-day | /day11-circular-bin-search/circ_bs.py | 810 | 4.1875 | 4 | # Circular Binary Search
def circ_bs(items, target):
'''Finds a value in a given list using a circular binary search.
Returns -1 if the value was not found.
'''
size = len(items)
lower = 0
upper = size - 1
result = -1 # Assume failure.
while lower <= upper:
mid = (upper + lower... | true |
2ba97990c6b589b4f53120eaa775d89d431b651f | nokap/exam1jacobkapasi | /donuts.py | 1,881 | 4.125 | 4 | grades = [62, 79, 82, 81, 92, 74, 84, 95, 85, 78, 88]
#This is an array that holds all of the grades of the class
ans = () #This is a variable that holds the answer
for avg in grades: #I am creating a for loop that holds the averages for the grades
if avg ==: #I am saying that if the average variable in grades... | true |
8af6b3625023ca12c94735679076a1fa2ac855b1 | JennyShalai/data-science-prep | /tuple-dictionary-set.py | 2,933 | 4.4375 | 4 | # Tuple, Dictionary and Set checkpoint
# Challenge 1:
# Write a script that prompts the user to input a series of numbers separated by
# commas. Your script will then take these inputted numbers and store them
# as a list of tuples, two at a time. Finally, your script will print that list
# of tuples to the user. If ... | true |
77ee2388db3dddcf57c75525c1115008592bc798 | DustyQ5/CTI110 | /P3T1_AreasOfRectangles_ChazzSawyer.py | 1,384 | 4.25 | 4 | # CTI-110
# P3T1 - Areas Of Rectangles
# Chazz Sawyer
# 9/25/2018
#Program welcomes user
#Progames ask for rectangle legnth and width. Then repeats.
#programs states the area of both rectangles
#programs announces which rectangle has a larger area or if
#they are equal
pri... | true |
3bf50aaf9347137d12099872cdefbdd467a7413f | Austin-deMora/ICS3U-Assignment6-Python-Pyramid_Volume | /pyramid_volume.py | 1,670 | 4.375 | 4 | #!/usr/bin/env python3
# Created by Austin de Mora
# Created in May 2021
# Program finds volume of a right rectangular pyramid
import math
def volume(length, width, height):
# Function calculates volume and returns it
# Process
volume = (length * width * height) / 3
return volume
def main():
... | true |
a29b0ca626fcd82d1802636feb52f07a0533a796 | mistrydarshan99/Leetcode-3 | /interviews/amazon/implement_stack_using_deque.py | 1,201 | 4.15625 | 4 | from collections import deque
# Pop from queue: deque.popleft()
# append to the queue: deque.append()
# Initialize: queue = deque()
"""
stack:
- first in, last out
"""
class Stack:
def __init__(self):
self.stackleft = deque()
self.stackright = deque()
def append(self, item):
if not self.stackleft:
... | false |
cd6166e3fb6320e8c646a485ba28e62bbcba4b32 | mistrydarshan99/Leetcode-3 | /interviews/lyft/lyft_ouptut_last_n_row_of_file.py | 1,184 | 4.5 | 4 | """
given a file or file_handler.
Implement a function that:
tail(file, n =10): #default n = 10
- give last 10 rows of line in the file
tail(file, n):
- give last n rows of lines in the file
Thought:
- since we need to read the file line by line:
- but we only want to last n rows of file
- so we wish to pop out / t... | true |
58a01495d07cc25e0be70c39686f4728b178ac0e | bigmantings69/01-Lucky-Unicorn | /HL_yes_no.py | 2,364 | 4.25 | 4 | import random
# instruction if user did not play the game before
def instructions():
print()
print("**** How to Play ****")
print()
print("For each game you will be asked to...")
print("- Enter a 'low' and 'high' number. "
"The computer will randomly generate a 'secret' number between ... | true |
59e469c28a514a750fc43b61de86f8df642b3114 | RoboneClub/Hab-Lab-Analysis | /temperature_plotter.py | 1,698 | 4.28125 | 4 | #Pandas is used to open csv files and convert to lists
import pandas as pd
#Used for making plots
import matplotlib.pyplot as plt
#Library used to do maths
import numpy as np
#Load data to pandas
data = pd.read_csv('data.csv')
#Give time from data
time = data['Time']
sesnor_temperature_values = data['Te... | true |
cc862467514be24cd815fce7b1fb50c316a505aa | YannMoskovitz/Python-crash-course- | /class user.py | 2,839 | 4.3125 | 4 | class User:
"""Class of user stores a tipical user info"""
def __init__(self, first_name, last_name, username, location, email, middle_name=''):
self.first_name = first_name
self.last_name = last_name
self.middle_name = middle_name
self.username = username
self.location ... | true |
2da0812f53c518622b80e008d9263109efe8eec3 | Fange-Wu/Getting-Lucky | /07_job_v1.py | 904 | 4.15625 | 4 | import random
for item in range (0,10) :
operation = random.randint(1,3)
num1 = random.randint(1,10)
num2 = random.randint(1,10)
if operation == 1:
question = int(input("What is " + str(num1) + "+" + str(num2) + ": "))
answer = num1 + num2
if question == answer:
pri... | true |
9b319fc716ba4ba97c1024cc5110a91d674e8305 | nbglink/ExamPythonBasics2018 | /CatWalk.py | 551 | 4.125 | 4 | minutes_walks_day = int(input())
count_walks_day = int(input())
calories_day = int(input())
summary_minutes_for_walk = minutes_walks_day * count_walks_day
summary_calories_burned = summary_minutes_for_walk * 5
half_of_taken_calories = calories_day - (50 * calories_day) / 100
if summary_calories_burned >= half_of_ta... | true |
a823d5c9b0f9417d6d95201a604d312377a627f3 | huytn1219/algorithm | /bestTimeToBuyandSellStock.py | 838 | 4.21875 | 4 | # You are given an array prices where prices[i] is the price of a given stock on the ith day.
# You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock.
# Return the maximum profit you can achieve from this transaction. If you cannot ach... | true |
e4e6b947fe90a002055d4f62165cb10e599358f3 | ShioMura/astr-hw-1 | /operators.py | 327 | 4.21875 | 4 | x = 9
y = 3
print(x+y)
print(x-y)
print(x*y)
print(x/y)
print(x%y)
print(x**y)
x = 9.191823
print(x//y)
#assignment operators
x = 9
x += 3
print(x)
x = 9
x -= 3
print(x)
x = 9
x *= 3
print(x)
x = 9
x /= 3
print(x)
x **= 3
print(x)
# Comparison operators
x = 9
y = 3
print(x==y)
print(x!=y)
print(x>y)
print(x<y)
prin... | false |
1f31b496ab6ab081bcf8543c62205b5a77f949e8 | Damnful/210CT | /Question10.py | 925 | 4.1875 | 4 | def find_maximum_subsequence(sequence):
subsequenceList = []
currentSubsequence = []
maximumSubsequence = []
last = 0
for integer in sequence:
if integer <= last:
# basically, if the next value continues the increasing subsequence
subsequenceList.append(current... | true |
dec4c475c48b85738c9103788dd20e811cb147cb | AmitabhK-je/PythonForEverybody | /Exercise_3/Exercise3.py | 697 | 4.1875 | 4 | """
Write a program to prompt for a score between 0.0 and
1.0. If the score is out of range, print an error message. If the score is
between 0.0 and 1.0, print a grade using the following table:
"""
try :
score = input('Enter score: ')
score = float(score)
if score >=0.0 and score <=1.0:
... | true |
9a0c57528493155d91051fd13c45fa42917932de | gulci-poz/py_basics | /13_for.py | 602 | 4.1875 | 4 | # string - sequence of characters
for letter in 'Python':
print(letter, end='*')
print()
for name in ['Wiki', 'Mela', 'Ema']:
print(name, end=' ')
print()
sum_of_prices = 0
prices = [1, 2, 3, 4, 5]
for price in prices:
sum_of_prices += price
print('Sum of prices:', sum_of_prices)
sum_of_numbers = 0
... | true |
6fa5c46cccd6a2e49f6a2d90480e296e66cfce18 | Fisik-Yadershik/L10 | /z3.py | 795 | 4.125 | 4 | #!/usr/bin/evn python3
# -*- config: utf-8 -*-
# Решите следующую задачу: напишите функцию, которая считывает с клавиатуры числа и
# перемножает их до тех пор, пока не будет введен 0. Функция должна возвращать
# полученное произведение. Вызовите функцию и выведите на экран результат ее работы.
def composition():
... | false |
6a30c2124bb7c57d935fdde5fcd82b2f732eea47 | t0etag/Python | /Python3/DemoProgs/comp_ifelse.py | 755 | 4.40625 | 4 | """Comprehension with If/Else
This program demonstrates the way if/else constructs can be
used within a comprehension. This particular example examines
each entry in a list containing numbers. For numbers >= 45,
one is added to the new number. Otherwise, five is added to
the new number. At some point in time... | true |
a00e865fcc8fbbdd21d1900765bf906fc7115c38 | t0etag/Python | /Python1/Labs/LastLabPy1/lab08b_func.py | 1,091 | 4.25 | 4 | """lab08b_func.py
This program reads a temperature from the keyboard. It then reads a
character that determines what type of conversion to perform. A 'c'
causes a fahrenheit-to-centigrade coversion while a 'f' causes the
opposite conversion. Separate functions provide the conversion as
well as print statement... | true |
4a1f75311937c0d224a507222c2e14f99e4f1d2e | t0etag/Python | /Python3/Labs/Lab12b.py | 1,648 | 4.375 | 4 | """Lab 12b - Comparisons
When you compare for equality, the default version of __eq__ is called
automatically and it will blindly compare two instances which will never be equal.
To override this result, implement one or more of the newer magic methods – in
our case __eq__. Use this magic method to compare the bala... | true |
977f3f5c4bd8b57b45f9cdc89684ad08ca55da47 | t0etag/Python | /py4e/banana_index.py | 410 | 4.28125 | 4 | """
Write a while loop that start at the last characeter in the string and works ins way backwards to the first
character in the string, printing each letter on a seperate line.
"""
fruit = "banana"
length = len(fruit)
#last = fruit[length - 1]
last = fruit[-1] # this works better
print(last)
index = len(f... | true |
177ca0bebfb911304e56d6e91a6f11c5fa03d8c4 | t0etag/Python | /Python3/DemoProgs/varyargs.py | 610 | 4.625 | 5 | """Variable Positional Arguments
This demo program has a function that takes a variable number of
parameters and shows how a collector assembles them all in a tuple.
By tradition, we use *args for positional parameters and **kwargs
for keyword parameters.
"""
def myfnc(*args):
print(len(args), type(args))
pri... | true |
dacc17ecb937360b01bb52bb4a8b7fcffc35bd9c | t0etag/Python | /Python2/Class Data/DemoProgs/sort_by_count.py | 836 | 4.34375 | 4 | """Sorting by Count
This program creates a dictionary containing counters. Then it
unloads the values and keys separately and zips the two together
with the count preceding the key. Then the sorted function is used
to sort each tuple in ascending order by count. Finally, the list
created by sorted is parsed i... | true |
5953c9e6ab5a9829732a62a2dc9a29331881b994 | t0etag/Python | /Python3/DemoProgs/counter.py | 1,898 | 4.25 | 4 | """Demo the Counter class
This program demonstrates some of the capabilities of the Counter class
"""
from collections import Counter
x = 'abracadabra'
ltrs = Counter(x)
print(ltrs) # This object is not act exactly the same as a dictionary
print('Unloaded:', ltrs.most_common()) # This method unloads the object the
#... | true |
57977064c1194ace521008e3f7f1cbeb1977d572 | t0etag/Python | /py4e/grades.py | 461 | 4.1875 | 4 | """
prompt for score between 0.0 and 1.0. If score is out of range, print error.
If in range, print grade.
"""
score = input("Enter score between 0.0 and 1.0:")
score = float(score)
if(score < 0.0 or score > 1.0):
print("Invalid score.")
elif(score >= 0.9):
print("Grade: A")
elif(score >= 0.8):
... | true |
3602d74c9e268d133efe4d19b05c15d677a93d66 | t0etag/Python | /Python2/Labs/Lab06cX.py | 2,381 | 4.15625 | 4 | """LAB 06c
In your data file is a program named servercheck.py. It reads two files
(servers and updates) and converts the contents into two sets. The
updates are not always correct. You will find all of the set
operations/methods in Python Notes. Using just these
operations/methods, your job is as follows:
1. Det... | true |
aaabf4c649303af4afddef6b3de08100f18c6f61 | TeenageMutantCoder/Calculator-with-GUI | /calculator-with-gui/Libraries/Menus/HelpMenu.py | 938 | 4.3125 | 4 | import tkinter as tk # GUI Library
from tkinter import messagebox # Allows a messagebox to be displayed on screen
class HelpMenu(tk.Menu):
''' Help submenu '''
def __init__(self, parent):
tk.Menu.__init__(self, parent)
self.parent = parent
self.window = self.parent.parent
... | true |
9ccf24642a475a6c87a11c91e947ed910d31dbc2 | RodriDFC/aprendiendo-python | /bucles/bucle-for-2.py | 595 | 4.21875 | 4 | # para usar la funcion print cuando se quiere imprimir mensajes y el valor de las variables hacer
# print(f"mensaje de la variable: {variable}")
for i in range(7):
print(f"mensaje de la variable: {i}")
print("-------------")
# con range(n,m)..... empieza en n y termina en m-1..... teniendo una longitud de m-n
for j... | false |
e6907c4ccb3d39ff820ee18f76bc5917d44a9bd5 | sandeepm96/cormen-algos | /Sai/kahn_topoSort.py | 1,404 | 4.25 | 4 | # A Python program to print topological sorting of a graph
# using indegrees
from collections import defaultdict
#Class to represent a graph
class Graph:
def __init__(self,vertices):
self.graph = defaultdict(list) #dictionary containing adjacency List
self.V = vertices #No. of vertices
# fun... | true |
bde4e246bf03d4b1af52de27ff283368257affb1 | kuldeep-dev/Python_Functions | /recursion_in_python.py | 816 | 4.15625 | 4 | # Recursions in python
# Resursion means use function in function
def print2(str1):
print("This is " + str1)
print2("kuldeep")
print("factorial itrative method")
def factorial_itrative(n):
"""
param n : integer
return : n*n-1 * n-2 * n-3......1
means n! : 5*4*3*2*1
"""
fac = 1
for i ... | false |
ae87eba08abf182fde332134ef2b1904e91e8d60 | rodolfoip/Python | /ExerciciosExtras/exercicio002.py | 391 | 4.21875 | 4 | #Faça um Programa que verifique se uma letra digitada é vogal ou consoante.
letra = str(input('Digite uma letra: ')).lower()
if len(letra)== 1:
if(letra == 'a'or letra == 'b' or letra == 'c' or letra == 'd' or letra == 'e'):
print('A letra digitada é uma VOGAL!!!')
else:
print('A letra digit... | false |
d5437c8480538a0bd41bc2a3b36dddf50ea0ceae | mfalcirolli1/Python-Exercicios | /Aula 9 M 1.py | 1,047 | 4.15625 | 4 | # Manipulando Texto
f = 'curso em vídeo python'
print(f[15:])
# [:5] - [15:] - [9:14] - [9::3] = [9:21:3]
print('O comprimento da frase é de: {} caracteres'.format(len(f))) #Comprimento
print(len(f))
print(f.count('o', 0, 21)) #Contador de caracteres
print(f.find('y')) #Localizador de caractere em relação ao compri... | false |
d646e0c9dd330ad29c3376a5ee49c1f70c6348bd | GalihRakasiwhi/DCC-PythonBeginners | /Exercise/exercise.py | 1,039 | 4.15625 | 4 | numbers = []
strings = []
names = ["Anakin Skywalker", "Padme Amidala", "Han Selo", "Qui-Gon Jinn", "Luke Skywalker", "Obi-an Kenobii"]
#write
second_name = None
#print Number
numbers.append(1)
numbers.append(2)
numbers.append(3)
strings.append("Satu")
strings.append("Dua")
strings.append("Tiga")
#this code should ... | true |
168c37edec6a17d03f44ca047e5d0cd5dd30a7ab | Elza-MerilGucic/HW9 | /HW9.1/main.py | 413 | 4.34375 | 4 | print("Welcome to distance unit converter")
while True:
kilometers = float(input("Please enter number of kilometers: "))
miles = 0.621371 * kilometers
print(str(kilometers) + " kilometers equals " + str(miles) + " miles")
repeat = input("Do you want to do another conversion? (yes / no): ")
if repe... | true |
329f502e7bd2098dca7204d88b9ded699421d6f9 | ghezalsherdil/Web_Fundamentals | /Python/Python_assignments/type-list.py | 1,620 | 4.34375 | 4 | '''Assignment: Type List
Write a program that takes a list and prints a message for each element in the list, based on that element's data type.
Your program input will always be a list. For each item in the list, test its data type. If the item is a string, concatenate it onto a new string. If it is a number, add it ... | true |
9562b71e46986b31bf317471b5703f34215d4c5e | RahulRj09/pythonprograms | /primenumber.py | 225 | 4.125 | 4 | # this program check number is prime or not
prime = input("enter number is prime or not")
s = 0
for i in range(2,prime):
if prime % i == 0:
s +=1
if s == 0:
print "number is prime"
else:
print "nmuber not prime" | true |
e9767c9681860453593aa4843f997993b43a2e19 | hsfear/exercises | /python/100steps/hello-world/if_examples.py | 427 | 4.15625 | 4 | first = int(input("Enter the first number: "))
second = int(input("Enter the second number: "))
operation = input("Enter the operation [+-*/]: ")
if operation == '+':
result = first + second
elif operation == '*':
result = first * second
elif operation == '-':
result = first - second
elif operation == '/... | true |
646581b644ac8de68ab4d1736662e9d38e1bc398 | thapaliya123/Python-Practise-Questions | /data_types/problem_16.py | 226 | 4.15625 | 4 | """
Q.a Python program to sum all the items in a list.
"""
def sum_list_items(target_list):
sum=0
for item in target_list:
sum+=item
return sum
print("The sum of list is:", sum_list_items([1, 2, 3, 4, 5])) | true |
2e833a906a810bafa9185e337f175f29c8522241 | thapaliya123/Python-Practise-Questions | /functions/problem_17.py | 310 | 4.3125 | 4 | """
17.Write a Python program to find if a given string starts with a given character
using Lambda.
"""
string_with_given_char = lambda sample_string, sample_char: True if sample_string[0]==sample_char else False
sample_string="anish"
sample_char = "a"
print(string_with_given_char(sample_string, sample_char)) | true |
29c8946c0305a9dd70a66680c1c15f175afac969 | thapaliya123/Python-Practise-Questions | /functions/problem_12.py | 306 | 4.3125 | 4 | """
12. Write a Python program to create a function that takes one argument, and
that argument will be multiplied with an unknown given number.
"""
def multiply_with_unknown(sample_number):
return lambda x:sample_number*x
sample_number=10
result = multiply_with_unknown(sample_number)
print(result(3)) | true |
c1c2dabfe1305a88554e8b6264db862057343f96 | Jkoss172/ChatBotProject | /main.py | 1,635 | 4.125 | 4 | # Class Project - sprint01 - Base Code Design - 06/17/2021
# Here we put the import files
import random
# Here we declare global variables
program_over = True # sets the main loop to run
# Here we will define our classes and functions
class MainMenu: # This is the main menu
def intro():
... | true |
ea2e41ee0aabed72fcee1e7d0e130c03ead62658 | cwb4/Impractical_Python_Projects | /Chapter_4/permutations_practice.py | 1,465 | 4.28125 | 4 | """For a total number of columns, find all unique column arrangements.
Builds a list of lists containing all possible unique arrangements of
individual column numbers including negative values for route direction
(read up column vs. down).
Input:
-total number of columns
Returns:
-list of lists of unique column orde... | true |
b49e95e05c2c6f5749890eca608231291d12438d | piyushc0/Python | /src/String.py | 1,279 | 4.21875 | 4 | course = "Python's course for Beginners"
print(course)
message = '''
Hi Piyush,
Here is an example of 3 quotes
So you see it is fun in "Python"
- From Omni
'''
print(message)
name = "Piyush"
print(name[0]) # First Index
print(name[-1]) # Index from end
print(name[0:3]) # Index Range(excludes last index e.g- 3 i... | true |
189a85c447639974ff339b9919af9e35f4a17bcb | rohanwarange/TCS | /untitled0.py | 969 | 4.1875 | 4 | # -*- coding: utf-8 -*-
#"""
#Created on Fri Jul 2 08:11:58 2021
#
#@author: ROHAN
#"""
##Prime Numbers with a Twist
#Ques. Write a code to check whether no is prime or not. Condition use function check() to find whether entered no is positive or negative ,if negative then enter the no, And if yes pas no as a paramete... | true |
32f808f78d940ba922717ef7a68cc06605bbc337 | jaarmore/holbertonschool-higher_level_programming | /0x0B-python-input_output/2-read_lines.py | 619 | 4.375 | 4 | #!/usr/bin/python3
"""
Function that read a text file
"""
def read_lines(filename="", nb_lines=0):
"""
Function that reads n lines of a text file
Args:
filename: name of the file
nb_lines: number of lines to read
"""
tlines = 0
with open(filename, encoding='utf-8') as a_file:
... | true |
e7ffe55940e92ed673dfb059f5cba28859b47efd | jaarmore/holbertonschool-higher_level_programming | /0x0B-python-input_output/0-read_file.py | 291 | 4.25 | 4 | #!/usr/bin/python3
"""
Function that reads a text file encoding UTF-8
"""
def read_file(filename=""):
"""
Function that reads a text file
Args:
filename: name of the file
"""
with open(filename, encoding='utf-8') as a_file:
print(a_file.read(), end='')
| true |
214891106b0d01783bf4b01adbd6bde052e6f229 | xiyiwang/leetcode-challenge-solutions | /2021-03/2021-03-15-Codec.py | 1,297 | 4.15625 | 4 | """
LeetCode Challenge: Encode and Decode TinyURL (2021-03-15)
TinyURL is a URL shortening service where you enter a URL
such as https://leetcode.com/problems/design-tinyurl and it
returns a short URL such as http://tinyurl.com/4e9iAk.
Design the encode and decode methods for the TinyURL service.
There is no restr... | true |
fae6011dd3de9425b309e2bf4e4d311371ecdbb7 | 214031230/Python21 | /day3/第三周小练习/练习3.py | 2,290 | 4.21875 | 4 | #!/usr/bin/env python3
# 2、写函数,接收n个数字,求这些参数数字的和。(动态传参)
# def fun1(*args):
# sums = 0
# for i in args:
# sums += i
# return sums
#
#
# res = fun1(1, 2, 3, 4)
# print(res)
# 3、读代码,回答:代码中,打印出来的值a,b,c分别是什么?为什么?
# a = 10
# b = 20
#
#
# def test5(a, b): # a = 20 b = 10
# print(a, b)
#
#
# c ... | false |
35b4aec82f1effe51f5ed4e5e2f07db5695fc6df | LEUNGUU/data-structure-algorithms-python | /Recursion/exercises/r417.py | 582 | 4.125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# def is_palindrome(s: str) -> bool:
# def judge(s: str, start: int, end: int) -> bool:
# n = end - start + 1
# if n <= 1:
# return True
# return (s[start] == s[end]) and judge(s, start+1, end-1)
# return judge(s, 0, len(s)-1)
def i... | false |
af7eb5e873b6466253e644eb88f35db1de315220 | LEUNGUU/data-structure-algorithms-python | /Sorting-Selection/ArrayBasedMergeSort.py | 648 | 4.34375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
def merge(S1, S2, S):
"""Merge two sorted Python list S1 and S2 into properly sized list S"""
i = j = 0
while i + j < len(S):
if j == len(S2) or (i < len(S1) and S1[i] < S2[j]):
S[i + j] = S1[i]
i += 1
else:
... | false |
fb6218fcf5ea020e46c07bd60b9dbce9a965231a | LEUNGUU/data-structure-algorithms-python | /Recursion/exercises/r401.py | 292 | 4.25 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# find the largest element in a list
def find_maximum(nums: list) -> int:
if len(nums) == 1:
return nums[0]
return max(nums[0], find_maximum(nums[1:]))
if __name__ == "__main__":
print(find_maximum([1, 2, 3, 6, 4, 3, 7]))
| true |
112f2592429a19aabb3173420e9c9f9e593b8a50 | LEUNGUU/data-structure-algorithms-python | /Recursion/fibonacci.py | 535 | 4.1875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Running time is exponential in n.
def bad_fibonacci(n):
"""Return the nth Fibonacci number"""
if n <= 1:
return n
else:
return bad_fibonacci(n - 1) + bad_fibonacci(n - 2)
# Running time is linear time
def good_fibonacci(n):
"""Return p... | false |
84673b1c1dbcc360060ff262baf293a341bbddb6 | stevedeNero/MIT_OCW_6.0001 | /ps1a.py | 1,354 | 4.21875 | 4 | ####################################
# Gather Salary Information
annual_salary = float(input("How much $ do you make a year?"))
portion_saved = float(input("How much can you set aside to save for down-payment?\n(Enter value in range of 0.0 to 1.0)"))
current_savings = 0.0
####################################
# ... | true |
026072a67c2f075ac0361937fa50923b0b6263cc | seemaPatl/python | /mergesort.py | 1,205 | 4.34375 | 4 | import pdb
pdb.set_trace()
def mergesort(lst1,lst2,lst3=[],idx1=0,idx2=0):
'''
objective:to merge two sorted list into third list
input parameters:
lst1,lst2:two sorted list
lst3:third list with elements of the lst1 and lst2 sorted
approach:using recursion
'''
if (len(... | false |
974e35b53ed0318244f7f5afe881bc97a5ab5ad7 | mlitsey/Learning_Python | /IntroPY4DS/day3/austin-pw.py | 937 | 4.34375 | 4 | # Password entering exercise
# 01. Allow the user to enter a password that matches a secret password
# 02. Allow them to make 5 attempts
# 03. Let them know how many they have made
# 04. Display if password is correct or if max attempts has been reaced.
SECRET_PW = 'katana'
pw_in = ''
cur_attempts = 0
MAX_ATT... | true |
d72179aafd311b6c8edc4e63c8cf6d62786920de | Venkatesh0000/python | /week 4/week.4.2.py | 331 | 4.125 | 4 | string1=input('enter the first string')
string2=input('enter the second string')
if(len(string2)==len(string1)):
if(sorted(string1)== sorted(string2)):
print("The strings are anagrams.")
else:
print("The strings aren't anagrams.")
else:
print("process not ... | true |
0a16b3f12dc12bd221f719645e95b66e7be45fd3 | jmontes50/Codigo10 | /Backend/VirtualBack/Dia1/03-operadores.py | 1,596 | 4.4375 | 4 | # Operadores aritmeticos
# + suma
# - resta
# * multiplicacion
# / division
# % modulo
# ** exponente
# // cociente (SOLO PYTHON)
num1 = 10
num2 = 20
num3 = num1+num2
print(num3)
num3 = num1 ** num2
print(num3)
num3 = num2 // num1
print(num3)
# -----------------------
# Operadores asignacion
# = Igual
# += Incremento... | false |
c132b13c693e2536c5cd40db9ff88301a2b3b527 | SRI-VISHVA/Electoral_Result_Management_2019_DBMS_PROJECT | /sample1.py | 1,809 | 4.34375 | 4 | import csv
import sqlite3
csv_reader = csv.reader("election_result2k19sonali.csv")
con = sqlite3.connect(":memory:")
cur = con.cursor()
# create the required table
#all the attributes with their respective constraint
cur.execute("Create table voting_list ( Aadhar number(3),Voter_name varchar(100) PRIMARY KEY, Age nu... | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.