blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
9c93949912fc77ad1833f767013569f4c4ddc4f6 | ilante/exercises_python_lpthw | /ex11.py | 325 | 4.15625 | 4 | #software
# 1 takes input
# 2 does something with it
# prints out something to show how it changed
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} hea... | true |
35ff67f966de50a59ebe73912169f829ef41b71c | adam-weiler/GA-Reinforcing-Exercises-Functions | /exercise.py | 284 | 4.1875 | 4 | def word_counter(string): #Counts how many words in a string.
if string:
return(len(string.split(' ')))
else:
return(0)
print(word_counter("Hello world")) # returns 2
print(word_counter("This is a sentence")) # returns 4
print(word_counter("")) # returns 0
| true |
c65c1051989e32dbee0e7b0ab6a784c654ba9f78 | yummychuit/TIL | /homework/submit/homework05.py | 260 | 4.28125 | 4 | # 1
for sth in my_list:
print(sth)
# 2
for index, num in enumerate(my_list):
print(index, num)
# 3
for key in my_dict:
print(key)
for value in my_dict.values():
print(value)
for key, value in my_dict.items():
print(key, value)
# 4
None | true |
5f56e3b131b35a1367a22251f498aff54239f17b | beexu/testlearngit | /requests git/learnpy/learn1.py | 410 | 4.1875 | 4 | # -*- coding: utf-8 -*-
# 题目:有四个数字:1、2、3、4,能组成多少个互不相同且无重复数字的三位数?各是多少?
for i in range(1, 5):
# print(i)
for a in range(1, 5):
# print(a)
for d in range(1, 5):
# print(d)
if i != a and a != d and i != d:
print(i, a, d)
else:
prin... | false |
ae79fa9452ac79299955911627f82bf38ad08032 | lenngro/codingchallenges | /RotateMatrix/RotateMatrix.py | 1,279 | 4.15625 | 4 | import numpy as np
class RotateMatrix(object):
def rotate90(self, matrix):
"""
To rotate a matrix by 90 degrees, transpose it first, then reverse each column.
:param matrix:
:return:
"""
tmatrix = self.transpose(matrix)
rmatrix = self.reverseColumns(tmatrix)... | true |
0d793adfea8dab3384fdde15731feaffd19cee28 | Mistik535/Zadachi | /zad/zad10.py | 803 | 4.1875 | 4 | # ZAD 1
# Создать массив N и заполнить его числами с клавиатуры.
# Вывести на консоль первый и последний элемент массива.
# Поменять местами первый и последний элемент в массиве.
# ZAD 2
# Программа должна переводить число, введенное с клавиатуры в метрах, в километры.
print("Input N:")
N = int(input())
list = []
fo... | false |
5d7c61e72a8cf91579e0598dab6aa4ed365ed3b4 | MattMacario/Poly-Programming-Team | /Detect_Cycle_In_Linked_List.py | 1,001 | 4.125 | 4 | # Matthew Macario Detecting a Cycle in a Linked Lists
# For reference:
#class Node(object):
# def __init__(self, data=None, next_node=None):
# self.data = data
# self.next = next_node
def has_cycle(head):
# Creates a list to store the data that has already been passed over
dataList... | true |
1211efb7146a21086cd036062ccd9ff04fbeebdd | Hardik12c/snake-water-gun-game | /game.py | 1,154 | 4.1875 | 4 | import random # importing random module
def game(c,y):
# checking condition when computer turn = your turn
if c==y:
return "tie"
#checking condition when computer chooses stone
elif c=="s":
if y=="p":
return "you win!"
else:
return "you loose!"
#chec... | true |
dfe21c343e5740ccdb60d083f0c3dc9046eae1fd | ShaamP/Grocery-program | /Cart.py | 1,647 | 4.28125 | 4 | #####################################
# COMPSCI 105 S2 C, 2015 #
# Assignment 1 Question 1 #
# #
# @author YOUR NAME and UPI #
# @version THE DATE #
#####################################
from Item import Item
class Cart:
# the constructor
... | true |
84d1e9eca4618180e1c2ed5b23e153695322f930 | alexmontolio/Philosophy | /wikipedia_game/tree_node.py | 1,469 | 4.28125 | 4 | """
The Node class for building trees
"""
class Node(object):
"""
The basic Node of a Tree data structue
Basic Usage:
>>> a = Node('first')
>>> b = Node('second')
>>> a.add_child(b)
"""
def __init__(self, name):
self.name = name
self.children = []
def add_child(sel... | true |
64b5b695e053404803633ce7673e414b37dafb25 | thiagotato/Programing-Python | /decorators.py | 865 | 4.21875 | 4 | import functools
def trace_function(f):
"""Add tracing before and after a function"""
@functools.wraps(f)
def new_f(*args):
"""The new function"""
print(
'Called {}({!r})'
.format(f, *args))
result = f(*args)
print('Returing', result)
r... | true |
80df817700d692076b0583fd641fbf57afd69483 | Tommy8109/Tkinter_template | /Tkinter template.py | 2,779 | 4.28125 | 4 | "This is a template for the basic, starting point for Tkinter programs"
from tkinter import *
from tkinter import ttk
class gui_template():
def __init__(self):
"This is the init method, it'll set up all the variables needed in the app"
self.__title = "Test ... | true |
53e768354e681a632924d599661e04d67790111a | austinthemassive/first-py | /lambda calculator.py | 840 | 4.34375 | 4 | #!/usr/bin/python
#This file is meant to demonstrate using functions. However since I've used functions before, I will attempt to use lamdas.
#add
add = lambda x,y: x+y
#subtract
subtract = lambda x,y: x-y
#multiply
multiply = lambda x,y: x*y
#divide
divide = lambda x,y: x/y
#while
while True:
try:
num1 = fl... | true |
cae804a30e3de12689b0d2d4f33a1d237431d6cc | SekalfNroc/03_list_less_than_ten | /__main__.py | 358 | 4.1875 | 4 | #!/usr/bin/env python
numbers = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
try:
divider = int(input("Enter a number: "))
except:
print("That's silly")
exit()
less_than = []
for number in numbers:
if number < divider:
less_than.append(str(number))
print("The numbers in the list less than %d are %s... | true |
093d43f6865f140f58654f6986a1ce3f5cd532dd | edwardjthompson/resilience_data | /keovonm/normalize.py | 1,397 | 4.15625 | 4 | import pandas as pd
import sys
import os
def normalize(filename, column_name):
'''
This method normalizes a column and places the normalized values
one column to the right of the original
:param filename: name of csv file
:param column_name: column that should be normalized
:r... | true |
6f6b3ba920bd014fb03effa672fb7df7acaf8933 | zhubw91/Leetcode | /Add_and_Search_Word.py | 1,684 | 4.15625 | 4 | class TrieNode(object):
def __init__(self):
self.children = {}
self.is_word = False
class WordDictionary(object):
def __init__(self):
"""
initialize your data structure here.
"""
self.root = TrieNode()
def addWord(self, word):
"""
Ad... | true |
fe15490ff1fc0d6f78069083d9dcbd28df2a0c56 | ronliang6/A01199458_1510 | /Lab01/my_circle.py | 765 | 4.53125 | 5 | """Calculate area and radius of a circle with given radius, and compares to circumference and area of circle with
double that radius"""
Pi = 3.14159
radius = 0
print("Please enter a number for a radius")
radius = float(input())
radius_doubled = radius * 2
circumference = 2 * Pi * radius
circumference_doubled_radius = ... | true |
67a6dec5b87cd0de6437d2c75c5970edc8e68eb9 | ronliang6/A01199458_1510 | /Lab07/exceptions.py | 2,111 | 4.5625 | 5 | import doctest
def heron(num: int):
"""
Return the square root of a given integer or -1 if that integer is not positive.
:param num: an integer.
:precondition: provide the function with a valid argument according to the PARAM statement above.
:postcondition: return an object according to the retu... | true |
05c8cd898bbe6e7a9bf754c4d7c45a373f6f9fbd | nia-ja/Sorting | /src/iterative_sorting/iterative_sorting.py | 1,052 | 4.1875 | 4 | # TO-DO: Complete the selection_sort() function below
def selection_sort( arr ):
# loop through n-1 elements
for i in range(0, len(arr) - 1):
smallest_index = i
# TO-DO: find next smallest element
# (hint, can do in 3 loc)
for e in range(i + 1, len(arr)):
if arr[e] ... | true |
e69de86af9107c4b4d72a132b5b809bb64de7199 | HoldenCaulfieldRye/python | /functional/functional.py | 2,216 | 4.1875 | 4 | # http://docs.python.org/2/howto/functional.html
################################################################################
# ITERATORS #
################################################################################
# important foundation fo... | true |
801e6955a7b89d863ac53f2fc3ea9ff21d241e83 | denamyte/Hyperskill_Python_06_Coffee_Machine | /Coffee Machine/task/previous/coffee_machine4.py | 1,434 | 4.1875 | 4 | from typing import List
buy_action, fill_action, take_action = 'buy', 'fill', 'take'
resources = [400, 540, 120, 9, 550]
coffee_costs = [[-250, 0, -16, -1, 4], # espresso
[-350, -75, -20, -1, 7], # latte
[-200, -100, -12, -1, 6]] # cappuccino
add_prompts = ['Write how many ml of wate... | true |
61b7ba4f2ecb877a19a0b20ad22ce13cc02ac7db | bvishal8510/Coding | /python programs/List insertion.py | 1,733 | 4.40625 | 4 | print "Enter 1. to insert element at beginning."
print "Enter 2. to insert element at end."
print "Enter 3. to insert element at desired position."
print "Enter 4. to delete element from beginning."
print "Enter 5. to delete last element."
print "Enter 6. to delete element from desired position."
print "Enter 7. ... | true |
b74ee930f04695da23898292ceceb21f3252979b | holmes1313/Leetcode | /746_Min_Cost_Climbing_Stairs.py | 1,437 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Oct 8 15:13:03 2019
@author: z.chen7
"""
# un solved
# 746. Min Cost Climbing Stairs
"""
On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed).
Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to r... | true |
9c5c513abd1c40791bdc1972f326f2a6e5a6e888 | holmes1313/Leetcode | /518_Coin_Change_2.py | 1,288 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Nov 12 10:57:29 2019
@author: z.chen7
"""
# 518. Coin Change 2
"""
You are given coins of different denominations and a total amount of money.
Write a function to compute the number of combinations that make up that amount.
You may assume that you have infinite number of e... | true |
8af5c04d70fc72c4f0046e8da167e8ef8af2628e | holmes1313/Leetcode | /array_and_strings/500_Keyboard_Row.py | 1,196 | 4.15625 | 4 | """
Given an array of strings words, return the words that can be typed using letters of the alphabet on only one row of American keyboard like the image below.
In the American keyboard:
the first row consists of the characters "qwertyuiop",
the second row consists of the characters "asdfghjkl", and
the third row con... | true |
0bb1c537af47523a326c80b8776196b74b03fa11 | holmes1313/Leetcode | /array_and_strings/check_408_Valid_Word_Abbreviation.py | 1,621 | 4.40625 | 4 | """
lengths. The lengths should not have leading zeros.
For example, a string such as "substitution" could be abbreviated as (but not limited to):
"s10n" ("s ubstitutio n")
"sub4u4" ("sub stit u tion")
"12" ("substitution")
"su3i1u2on" ("su bst i t u ti on")
"substitution" (no substrings replaced)
The following are n... | true |
0667e42e73b0c4eb8a2f2e8752573ce40543cfb2 | liuhuipy/Algorithm-python | /greedy/lemonade-change.py | 2,146 | 4.28125 | 4 | """
柠檬水找零:
在柠檬水摊上,每一杯柠檬水的售价为 5 美元。
顾客排队购买你的产品,(按账单 bills 支付的顺序)一次购买一杯。
每位顾客只买一杯柠檬水,然后向你付 5 美元、10 美元或 20 美元。你必须给每个顾客正确找零,也就是说净交易是每位顾客向你支付 5 美元。
注意,一开始你手头没有任何零钱。
如果你能给每位顾客正确找零,返回 true ,否则返回 false 。
示例 1:
输入:[5,5,5,10,20]
输出:true
解释:
前 3 位顾客那里,我们按顺序收取 3 张 5 美元的钞票。
第 4 位顾客那里,我们收取一张 ... | false |
ec271a49ddd1d9d93989b0e1c913fb7c6fbeccf6 | liuhuipy/Algorithm-python | /array/flatten.py | 610 | 4.25 | 4 | # -*- coding:utf-8 -*-
"""
Implement Flatten Arrays.
Given an array that may contain nested arrays,
give a single resultant array.
function flatten(input){
}
Example:
Input: var input = [2, 1, [3, [4, 5], 6], 7, [8]];
flatten(input);
Output: [2, 1, 3, 4, 5, 6, 7, 8]
"""
def list_flatten(alist, res=None):
if res i... | true |
47144145ecbd0966df05394ae6de495c07f62d8b | liuhuipy/Algorithm-python | /tree/validate-binary-search-tree.py | 1,391 | 4.15625 | 4 | """
验证二叉搜索树:
给定一个二叉树,判断其是否是一个有效的二叉搜索树。
假设一个二叉搜索树具有如下特征:
节点的左子树只包含小于当前节点的数。
节点的右子树只包含大于当前节点的数。
所有左子树和右子树自身必须也是二叉搜索树。
示例 1:
输入:
2
/ \
1 3
输出: true
示例 2:
输入:
5
/ \
1 4
/ \
3 6
输出: false
解释: 输入为: [5,1,4,null... | false |
03cf9108fddb23e91a30d43ac9d985fb17fb4a88 | Navaneeth442000/PythonLab | /CO1/program03.py | 412 | 4.1875 | 4 | #List Comprehensions
list=[3,6,-2,0,-6,-2,5,1,9]
newlist=[x for x in list if x>0]
print(newlist)
N=int(input("Enter number of no:s "))
list=[]
for x in range(N):
x=int(input("Enter no: "))
list.append(x)
print(list)
squarelist=[x**2 for x in list]
print(squarelist)
word="umberella"
vowels="aeiou"
list=[x for x... | true |
5d2f4f8f8c2d6deadde1f35100cb56baf0158d80 | ximonsson/python-course | /week-5/main_input_from_file.py | 663 | 4.28125 | 4 | """
Description:
This script will read every line in 'sequence.txt' and factorize the value on it and then
print it out to console.
As an optional exercise try making the script take as a command line argument of the file
that it should read for input.
"""
from mathfuncs import fact
# Exercise: make t... | true |
c7a696d47b67e2e40a1e889ed646fb157c6dd0df | prathyushaV/pyalgorithm | /merge_sort.py | 1,753 | 4.28125 | 4 | from abstract import AbstractAlgorithm
class MergeSort(AbstractAlgorithm):
name = ""
o_notation = ""
def implement(self,array,start,stop):
"""
Merge sort implementation a
recursive one :)
"""
if start < stop:
splitter = (start+stop)/2
self.im... | true |
334faf370f8b54adde42f3e60c1f456e0b40ca19 | cnshuimu/classwork | /If statement.py | 1,331 | 4.125 | 4 | # Q34
try:
num = int(input("enter a number: "))
except ValueError:
print('Value must be an integer')
else:
if num % 2 == 0:
print("it is an even number")
elif num % 2 == 1:
print("it is an odd number")
# Q35
human_year = float(input("enter a human year: "))
if human_year <= 2 and human_... | true |
b77d47c301e45a7446d7e0785687194b4e6a47e3 | vvakrilov/python_basics | /03. Conditional Statements Advanced/02. Training/02. Summer Outfit.py | 902 | 4.40625 | 4 | outside_degrees = int(input())
part_of_the_day = input()
outfit = ""
shoes = ""
if part_of_the_day == "Morning" and 10 <= outside_degrees <= 18:
outfit = "Sweatshirt"
shoes = "Sneakers"
elif part_of_the_day == "Morning" and 18 < outside_degrees <= 24:
outfit = "Shirt"
shoes = "Moccasins"
elif part_of_th... | true |
7a5c7864f2e4be8b80c9fc1a8aeb90eade2c0715 | JEPHTAH-DAVIDS/Python-for-Everybody-Programming-for-Everybody- | /python-data-structures-assignment7.1.py | 478 | 4.59375 | 5 | ''' Write a program that prompts for a file name, then opens that file and reads through the file,
and print the contents of the file in upper case. Use the file, words.txt to produce to the output below. You
can download the sample data at https://www.py4e.com/code3/words.txt?PHPSESSID=88c95d597d36e3db919cbef32f4ce6... | true |
23362101fcf09380b72fe260028c7b42d078577d | AnkitMitraOfficial/yash_friend_python | /4.py | 312 | 4.28125 | 4 | # Task:
# To check a given number is prime
prime_number = int(input('Write down a number to find whether it is prime or not!: '))
def find_prime(n=prime_number):
if n % 2 == 0:
print(f'Number {n} is a prime number :)')
else:
print(f'Number {n} is not a prime number :(')
find_prime() | true |
49b9f5b36a059a7681d0a43bb464d33c9a64f1cd | noodlles/pathPlaner-A- | /student_code.py | 2,644 | 4.125 | 4 | import math
import copy
def shortest_path(M,start,goal):
print("shortest path called")
path_list=[]
solution_path=[]
knownNode=set()
#init
path1=path(M,start,goal)
path_list.append(path1)
while(not(len(path_list)==0)):
#get the minimum total_cost path
... | true |
2332b026ad042a60a61c60e5b6420f564721290d | alexbarsan944/Python | /Lab1/ex9.py | 620 | 4.25 | 4 | # 9 Write a functions that determine the most common letter in a string. For example if the string is "an apple is
# not a tomato", then the most common character is "a" (4 times). Only letters (A-Z or a-z) are to be considered.
# Casing should not be considered "A" and "a" represent the same character.
def most_commo... | true |
22664285c944e3d570a041368bf0cbb82e320a38 | alexbarsan944/Python | /Lab1/ex5.py | 1,019 | 4.125 | 4 | # 5. Given a square matrix of characters write a script that prints the string obtained by going through the matrix
# in spiral order (as in the example):
def printRow(matrix):
size = len(matrix) - 1
k = 0
for i in matrix[k][0][size]:
print(i)
def five():
def ptrOuter(matrix, level):
... | false |
1c35777a6133fb51eabc3120b51bfdedbd2a3edc | naresh2136/oops | /threading.py | 2,315 | 4.34375 | 4 | run() − The run() method is the entry point for a thread.
start() − The start() method starts a thread by calling the run method.
join([time]) − The join() waits for threads to terminate.
isAlive() − The isAlive() method checks whether a thread is still executing.
getName() − The getName() method returns the name o... | true |
6e4e62a52b16a9452437d2efa8ad94d4f1a6fbd1 | antadlp/pythonHardWay | /ex5_studyDrill_03.py~ | 957 | 4.28125 | 4 | #Search online for all of the Python format characters
print "%d : Signed integer decimal"
print "%i : Signed integer decimal"
print "%o : Unsigned octal"
print "%u : Unsigned decimal"
print "%x : Unsigned hexadecimal (lowercase)"
print "%X : Unsigned hexadecimal (uppercase)"
print "%e : Floating point exponential for... | true |
cf4a064e95f153869ea27f689877f86dbbcd1888 | ethan786/hacktoberfest2021-1 | /Python/ReplaceDuplicateOccurance.py | 808 | 4.15625 | 4 | # Python3 code to demonstrate working of
# Replace duplicate Occurrence in String
# Using split() + enumerate() + loop
# initializing string
test_str = 'Gfg is best . Gfg also has Classes now. \
Classes help understand better . '
# printing original string
print("The original string is : " + str(... | true |
c8492f83cf1ebd331aa4f3946324c9ecc4d727e9 | ethan786/hacktoberfest2021-1 | /Python/mathematical calculator.py | 461 | 4.4375 | 4 | # take two input numbers
number1 = input("Insert first number : ")
number2 = input("Insert second number : ")
operator = input("Insert operator (+ or - or * or /)")
if operator == '+':
total = number1 + number2
elif operator == '-':
total = number1 - number2
elif operator == '*':
total = number... | false |
412aa8efb5779739eed62eca2bf84d46dbd5da52 | ethan786/hacktoberfest2021-1 | /Python/VerticalConcatination.py | 626 | 4.21875 | 4 | #Python3 code to demonstrate working of
# Vertical Concatenation in Matrix
# Using loop
# initializing lists
test_list = [["Gfg", "good"], ["is", "for"], ["Best"]]
# printing original list
print("The original list : " + str(test_list))
# using loop for iteration
res = []
N = 0
while N != len(test_list):
... | true |
6545a85e1e3a7a1f2791dc266483b559c824e4ed | Dakontai/-. | /cs/3/5.py | 376 | 4.21875 | 4 | num1 = int(input("Введите первое число: "))
num2 = int(input("Введите второе число: "))
num1 *= 5
print("Result:", num1 + num2)
print("Result:", num1 - num2)
print("Result:", num1 / num2)
print("Result:", num1 * num2)
print("Result:", num1 ** num2)
print("Result:", num1 // num2)
word = "Hi"
print(word... | false |
98db41c342b502dadb0c1a41470f07b48a1557eb | qianjing2020/cs-module-project-hash-tables | /applications/crack_caesar/crack_caesar.py | 1,216 | 4.15625 | 4 | # Use frequency analysis to find the key to ciphertext.txt, and then
# decode it.
# Your code here
special = ' " : ; , . - + = / \ | [] {} () * ^ & '
def alphabet_frequency(filename):
#obtain text from txt file
f = open(filename, 'r')
s = f.read()
f.close
# list contains list of alphabets
lst ... | true |
2b56d5789f94816a770ea759a6e3d5b336a70aba | luizfboss/MapRender | /main.py | 1,076 | 4.1875 | 4 | import folium
# A little help: add this code to a folder to open the map after running the code
a = float(input('x coordinate: ')) # Asks for the x coordinate
b = float(input('y coordinate: ')) # Asks for the y coordinate
city = str(input("Place's name: ")) # Asks for the city's name
# The city name won't change any... | true |
b806b42c533faa0c2cde79d4d067b53fb70abbcc | marcmatias/challenges-and-studies | /Edabit/python/Moving to the End.py | 420 | 4.3125 | 4 | '''
Flip the Boolean
Create a function that reverses a boolean value and returns the
string "boolean expected" if another variable type is given.
Examples
reverse(True) ➞ False
reverse(False) ➞ True
reverse(0) ➞ "boolean expected"
'''
def reverse(... | true |
4abd2567d26205e70109e9d2358c9869809850f3 | marcmatias/challenges-and-studies | /Edabit/python/Return the Factorial.py | 378 | 4.28125 | 4 | '''
Return the Factorial
Create a function that takes an integer and returns the factorial of that integer.
That is, the integer multiplied by all positive lower integers.
Examples
factorial(3) ➞ 6
factorial(5) ➞ 120
factorial(13) ➞ 6227020800
'''
def factorial(num):
... | true |
51f406d423ce8c6e7cdfc427f2025709d8656443 | ayamschikov/python_course | /lesson_3/2.py | 922 | 4.21875 | 4 | # 2. Реализовать функцию, принимающую несколько параметров, описывающих данные пользователя: имя, фамилия, год рождения, город проживания, email, телефон. Функция должна принимать параметры как именованные аргументы. Реализовать вывод данных о пользователе одной строкой.
def user_info(name='', last_name='', year='', c... | false |
2b4fcc0a88ba50f20630d7c6965714c275860e5b | ayamschikov/python_course | /lesson_3/3.py | 467 | 4.15625 | 4 | # 3. Реализовать функцию my_func(), которая принимает три позиционных аргумента, и возвращает сумму наибольших двух аргументов.
def my_func(a, b, c):
if a >= b and b >= c:
return a + b
elif a >= b and c > b:
return a + c
else:
return b + c
a = int(input('a: '))
b = int(input('b: '... | false |
d925271c57d03ecd51a1ae4633d6bf468a8a09ae | ayamschikov/python_course | /lesson_1/2.py | 501 | 4.28125 | 4 | # 2. Пользователь вводит время в секундах. Переведите время в часы, минуты и секунды и выведите в формате чч:мм:сс. Используйте форматирование строк.
seconds = int(input('enter number of seconds: '))
hours = seconds // 3600
minutes = (seconds - hours * 3600) // 60
seconds = seconds - hours * 3600 - minutes * 60
print... | false |
c2e2bc9e26a478b6df3944327769f7bf23c567d4 | ayamschikov/python_course | /lesson_1/5.py | 1,272 | 4.1875 | 4 | # 5. Запросите у пользователя значения выручки и издержек фирмы. Определите, с каким финансовым результатом работает фирма (прибыль — выручка больше издержек, или убыток — издержки больше выручки). Выведите соответствующее сообщение. Если фирма отработала с прибылью, вычислите рентабельность выручки (соотношение прибыл... | false |
21ffdb0c183029ea8f2a7d7a1052fb4b2ea5947b | lemonella/Dogs_project | /nearest_cafe.py | 2,863 | 4.3125 | 4 | '''
Let's find the nearest cafe by given coordinates
'''
import csv
import math
def get_coordinates_from_user():
# Getting the longitude and latitude from the user
# lat_point = input("Введите широту: ")
# lng_point = input("Введите долготу: ")
lat_point = 37.230884
lng_point = 56.036111
try:
... | false |
0cc6b0e73b5b22af969492ec7001163552e0a513 | syedfarazhus/Beginner-programs | /3. is_even and is_odd.py | 213 | 4.40625 | 4 | def is_even(num:int) -> bool:
"""
Returns true if a number is even
"""
return num % 2 == 0
def is_odd(num:int) -> bool:
"""
returns true if a number is odd
"""
return num % 2 == 1
| false |
de78b70d84464edf5f136bafd10d98c9f3695773 | 112358Sean/Kalkulator-Sederhana | /Kalkulator Sederhana.py | 1,305 | 4.15625 | 4 | while True:
print("Note: Untuk pangkat, bilangan b adalah nilai pangkatnya.Untuk akar, bilangan b adalah nilai akarnya."
"Untuk hasil pengakaran agak sedikit error, sehingga untuk beberapa akar sempruna dibulatkan ke angka satuannya."
"Selamat Mencoba.")
a = input("Masukkan bilangan 1: "... | false |
772ebe0e48e44ce7f40861d41ebddad75e094c45 | JanhaviBorsarkar/Ineuron-Assignments | /Programming assignments/Programming Assignment 4.py | 1,825 | 4.40625 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[2]:
# Q1. Write a Python Program to Find the Factorial of a Number
n = int(input("Enter a number: "))
fact = 1
if n < 0:
print("Please enter a positive integer")
elif n == 0:
print("Factorial of 0 is 1")
else:
for i in range(1, n + 1):
fact = fact * i
... | false |
40f5bd514abcfb94d581ce838eebed35c176d427 | FarabiHossain/Python | /Python Program/5th program.py | 321 | 4.125 | 4 | #How to get input from the user
fname = input("Enter your first name: ")
lname = input("Enter your last name: ")
school = input("Enter your school name: ")
age = input("Enter your age: ")
name = fname +" "+ lname
print("my name is " +name)
print("my school name is "+school)
print("i am " ,age, "years old"... | true |
4c35c58813cfb2697a8e00c7497b05f290aea394 | anniequasar/session-summaries | /Red_Hat/sess_10/10a_modules.py | 1,303 | 4.375 | 4 | """
Modules - Beginners Python Session 10
Demonstrates how program can tell if it has been run as script or imported as module
@author: Tim Cummings
Every python program file is a module.
A module is a group of python functions, classes, and/or a program which can be used from other python programs.
The module nam... | true |
a5063e58428fc5053b8248c9c684378d67713bdc | heggy231/final_coding_challenges | /practice_problems/non_repeat_substring.py | 334 | 4.15625 | 4 | """
Given a string as input, return the longest substring which does not return repeating characters.
"""
def non_repeat_substring(word):
"""
>>> non_repeat_substring("abbbbc")
'ab'
"""
start = 0
iterator = 0
maximum_substring = ""
# iterate through the string
# have an end coun... | true |
55d4008280c22a62a031019d82ed0434c7ffdcec | sidkushwah123/pythonexamples | /calsi.py | 1,701 | 4.3125 | 4 | def calculator():
print("Hello! Sir, My name is Calculator.\nYou can follow the instructions to use me./n")
print("You can choose these different operations on me.")
print("Press 1 for addition(x+y)")
print("Press 2 for subtraction(x-y)")
print("Press 3 for multiplication(x*y)")
print("Press 4 f... | true |
f42a13e83415ed2c2554365b31f8bb649fba64df | sidkushwah123/pythonexamples | /stone_paper.py | 2,662 | 4.21875 | 4 | # stone paper seaser game
import random
option = ["STONE","PAPER","SISER"]
user_score = 0
computer_score = 0
turn = 0
print("Let's play STONE PAPER SISER")
k="y"
while(k !="n"):
user_score = 0
computer_score = 0
for i in range(3):
if i != 2:
print("\n"+"*"*15+"... | false |
5f6bba95c9799f4095c1f7e4db2d5f50e07da791 | mkseth4774/ine-guide-to-network-programmability-python-course-files | /TSHOOT/TSHOOT#2/higher.py | 237 | 4.125 | 4 | ##
##
number1 = int(input("Please enter your first number: "))
number2 = input("Please enter your first number: "
if number1 > number2
HIGHEST = nubmer1
else
HIGHEST = number2
print("The higher of the two numbers was" HIHGEST)
| false |
8ee3f7247112e5afb3efdc0c41d303b1426fa216 | prophecyofagod/Python_Projects | /mario_saiz_Lab4c.py | 1,451 | 4.15625 | 4 | #Author: Mario Saiz
#Class: COSC 1336
#Program: Lab 4c
#Getting grades that are entered, determining the letter grade, and
#then calculating the class average by adding all the grades up, and
#dividing by the number of entered grades
print("\n"*25)
name = input("What is your name?: ")
grade = float(input("Ple... | true |
3bab3c4f57880b7fe63df4af07a62fc4f14531dc | BSN2000/SL_Lab | /selection_constructs.py | 254 | 4.1875 | 4 | a = int(input("enter the value of a "))
print("the value of a:",a)
b = int(input("enter the value of b "))
print("the value of a:",b)
if a>b:
print("a is greater than b")
elif b>a:
print("b is greater than a")
else:
print("both are equal")
| false |
c123862957de1163da3601eb2a5ccfb1fb0073ec | Yi-Hua/HackerRank_practicing | /Python_HackerRank/BasicDataTypes/Lists.py | 1,567 | 4.375 | 4 | # Lists
''' Consider a list (list = []). You can perform the following commands:
1. insert i e: Insert integer e at position i.
2. print: Print the list.
3. remove e: Delete the first occurrence of integer e.
4. append e: Insert integer e at the end of the list.
5. sort: Sort the list.
... | true |
6742ecb3ce433a551fbe480c9de0b6cb40469489 | Yi-Hua/HackerRank_practicing | /Python_HackerRank/Sets/Set_DifferenceOperation.py | 1,233 | 4.125 | 4 | # Set .difference() Operation 差集
# ______
# | |
# | A __|.... A difference B : A.difference(B) or A-B
# |___| :
# : B :
# :......:
# Sample Input
'''
9
1 2 3 4 5 6 7 8 9
9
10 1 2 3 11 21 55 6 8 '''
# Sample Output
''' 4 '''
a = input()
A = set(input().spli... | false |
2b7d71339c21528b07b3af83ed06c15d013a2a01 | chrisdavidspicer/code-challenges | /is_prime.py | 617 | 4.1875 | 4 | # Define a function that takes one integer argument
# and returns logical value true or false depending on if the integer is a prime.
# Per Wikipedia, a prime number (or a prime) is
# a natural number greater than 1 that has no
# positive divisors other than 1 and itself.
def is_prime(num):
# print(range(num))
if... | true |
616186ec59d49fbf3b4437a1ddaf8a40a2ab816a | parth04/Data-Structures | /Trees/symmetricTree.py | 1,574 | 4.375 | 4 | """
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).
For example, this binary tree [1,2,2,3,4,4,3] is symmetric:
1
/ \
2 2
/ \ / \
3 4 4 3
But the following [1,2,2,null,3,null,3] is not:
1
/ \
2 2
\ \
3 3
"""
# Definition for a b... | true |
d8f3d005639d4bf74738072c79381721c929a3a3 | parth04/Data-Structures | /misc/rotateImage.py | 1,456 | 4.4375 | 4 | """
48. Rotate Image
Medium
You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise).
You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation.
Example 1:
Input: matrix = [[... | true |
f1b39bf74c7844753d0a02832e73018cc344b11e | ZTcode/csc150Python | /convert3.py | 458 | 4.125 | 4 | # convert.py
# A program to convert Celsius to Fahreheit
def main():
print("Converting from celcius to fahrenheit")
celsius = eval(input("What is the Celsius Temperature? "))
fahrenheit = 9/5 * celsius + 32
if fahrenheit > 90:
print("It's hot as hell out!")
if fahrenheit < 30:
... | true |
592fd0e7cefd02922163db3857875dc5b1be4b24 | pwang867/LeetCode-Solutions-Python | /1367. Linked List in Binary Tree.py | 2,089 | 4.125 | 4 | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class ... | false |
f92cf43577af65a94f924d83123734bf7eafbd20 | pwang867/LeetCode-Solutions-Python | /0874. Walking Robot Simulation.py | 2,330 | 4.3125 | 4 | # cartesian coordinate
# time O(n), space O(1)
class Solution(object):
def robotSim(self, commands, obstacles):
"""
:type commands: List[int]
:type obstacles: List[List[int]]
:rtype: int
"""
dir = (0, 1) # current moving direction
pos = (0, 0)
obstac... | true |
902e5293b4ce676efe711da81d8015b9c383d4d1 | pwang867/LeetCode-Solutions-Python | /0225. Implement Stack using Queues.py | 2,197 | 4.5 | 4 | # rotate the queue whenever push a new node to stack
from collections import deque
class MyStack(object):
def __init__(self):
"""
Initialize your data structure here.
"""
self.queue = deque()
def push(self, x): # time O(n)
"""
Push elemen... | true |
aa8393d6d5d39c4b48c6034fefecef226ca67c93 | pwang867/LeetCode-Solutions-Python | /0092. Reverse Linked List II.py | 1,201 | 4.125 | 4 | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def reverseBetween(self, head, m, n):
"""
:type head: ListNode
:type m: int
:type n: int
:rtype: ListNode
... | false |
fec96f7d0cd28d6151e7d100a72597a178e2e67d | pwang867/LeetCode-Solutions-Python | /0543. Diameter of Binary Tree.py | 1,790 | 4.125 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
# time O(n), space O(depth)
# same as method 1, but use attributes
# diameter: count of edges, not count of nodes
class Solution(object):
def dia... | true |
7a5f58683cea86a8770142cf57c7b6fa2f420150 | eejay73/python-bootcamp | /ch20-lambdas-builtin-functions/main.py | 1,273 | 4.53125 | 5 | #!/usr/bin/env python3
"""
Chapter 20 - Lambdas and builtin functions
@author Ellery Penas
@version 2018.04.07
"""
import sys
def main():
"""main line function"""
# Normal function definetion
def square(x):
return x * x
# lambda version of the same function
# square2 = lambda num: num * n... | true |
590935d4f552690e09fb61e25da08a4c57befcf9 | Woosiq92/Pythonworkspace | /5_list.py | 1,124 | 4.15625 | 4 | #리스트
subway1 = 10
subway2 = 20
subway3 = 30
subway = [10, 20, 30]
print(subway)
subway = ["유재석", "조세호", "박명수"]
print(subway)
#조세호가 몇번 째 칸에 타고 있는가?
print(subway.index("조세호"))
# 하하씨가 다음 정류장에 탐
subway.append("하하") # 항상 맨뒤에 삽입
print(subway)
# 정형돈씨를 유재석과 조세호 사이에 태워봄
subway.insert(1, "정형돈")
print(subway)
# 지하철... | false |
185ae423da8786ee4454391f2de6c9c216cb9d92 | matthew-t-smith/Python-Archive | /Merge-Sort.py | 1,464 | 4.125 | 4 | ## Merge-sort on a deck of cards of only one suit, aces high
import math
## We will assign a number value to face cards so the computer can determine
## which is higher or lower
J = 11
Q = 12
K = 13
A = 14
## Here is our shuffled deck
D = [4, 9, Q, 3, 10, 7, J, 5, A, 6, K, 8, 2]
## We define the merge... | true |
b9e10a145429022614da4426e4d461b77cb12007 | Raolaksh/Python-programming | /If statement & comparision.py | 466 | 4.15625 | 4 |
def max_num(num1, num2, num3):
if num1 >= num2 and num1>= num3:
return num1
elif num2 >= num1 and num2 >= num3:
return num2
else:
return num3
print(max_num(300, 40, 5))
print("we can also compare strings or bulleans not only numbers")
print("these are comparision ope... | true |
a0788ac07a593928ed83bcaee802c3459538022f | miquelsi/intro-to-python-livelessons | /Problems/problem_6_lucky_number_guess.py | 446 | 4.21875 | 4 | """
Guess the number between 1 and 10
"""
import random
answer = random.randint(1, 10)
guess = int(input("I'm thinking of a number between 1 and 10: "))
# If the number is correct, tell the user
# Otherwise, tell them if the answer is higher or lower than their guess
if answer == guess:
print("It is correct!")
e... | true |
eebd61d9ea854d09ecdf645d594f949bcce30ee0 | ViniciusDanielpps/ViniciusDanielpps | /diferencas_divididas.py | 578 | 4.15625 | 4 | import matplotlib.pyplot as plt
from numpy import linspace as np
"""programa com a finalidade de objter um polinomio generico de grau n, a partir de seus coeficientes .
"""
def fu(x,coeficiente):
funcao=0
n=0
for i in coeficiente:
funcao+=i* x **n
n+= 1
return funcao
constantes=[1,2,-3,5,-5]
"""
for i in con... | false |
22b98de5c1195b2101bd649fed279cefbff98b67 | decadevs/use-cases-python-Kingsconsult | /static_methods.py | 899 | 4.21875 | 4 | # Document at least 3 use cases of static methods
# This method don't rely on the class attributes
# They are completely independent of everythin around them
# example 1
class Shape:
def __init__(self, name):
self.radius = name
@staticmethod
def calc_sum_of_angle(n):
return (2 * n... | true |
2dcf1f9b20227194ee543bf4d07fd10792fb9256 | RibRibble/python_june_2017 | /Rib/multiply2.py | 514 | 4.40625 | 4 | # Multiply:
# Create a function called 'multiply' that iterates through each value in a list (e.g. a = [2, 4, 10, 16])
# and returns a list where each value has been multiplied by 5. The function should multiply each value in the
# list by the second argument. For example, let's say:
# a = [2,4,10,16]
# Then:
# b ... | true |
7b575dc10ab4460b380d40c6971fedd097f9cecc | RibRibble/python_june_2017 | /Rib/ave2.py | 241 | 4.21875 | 4 | # Average List
# Create a program that prints the average of the values in the list: a = [1, 2, 5, 10, 255, 3]
print 'For the following list: '
a = [1, 2, 5, 10, 255, 3]
print a
print 'The average of the values in the list is: ' ,sum(a)/2
| true |
6d3c76402feb77a15890b728883722196df4094a | Amertz08/ProjectEuler | /Python/Problem005.py | 519 | 4.15625 | 4 | '''
Takes in a value, start point, and end point
returns true if value is evenly divisible from start to end
'''
def eDiv(value, start, end):
for a in range(start, end + 1):
if (value % a != 0): return False
return True
#Prompt input
print('''
Program will find smallest number than can be evenly divis... | true |
e8c3afdb41c2b9f095f29a42f07b43140f309ba1 | maggie-leung/python_exercise | /02 Odd Or Even.py | 401 | 4.21875 | 4 | num = int(input('Input the number you want to check'))
if (num % 4 == 0):
print('This is a multiple of 4')
elif (num % 2 == 0):
print('This is an even number')
else:
print('This is an odd number')
check = int(input('Check for the multiple'))
if (num % check == 0):
print(str(num) + ' is a multiple of '... | true |
e2e55c6c6561d91489e06f710835379e9cbc771e | cybersquare/G12_python_solved_questions | /files_exception/count_chars.py | 821 | 4.25 | 4 |
# Read a text file and display the number of vowels/ consonants/uppercase/ lowercase
# characters in the file.
file = open('hash.txt', "r")
vowels = set("AEIOUaeiou")
cons = set("bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ")
upper = set('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
lower = set('abcdefghijklmnopqrstuvwxyz')
text =... | true |
a6bb1b1effc36daa8021e53a0a05a64c49a0274e | mikaelaberg/CIS699 | /Ch2_Work/Ch2_4.py | 1,048 | 4.5625 | 5 | '''R-2.4 Write a Python class, Flower, that has three instance variables of type str,
int, and float, that respectively represent the name of the flower, its number
of petals, and its price. Your class must include a constructor method
that initializes each variable to an appropriate value, and your class should
includ... | true |
7a9ea799d19d80b1c22d070ac2588905bcd91dd2 | thomaslast/Test | /Python/Codeacademy/dice_game.py | 1,118 | 4.15625 | 4 | from random import randint
from time import sleep
"""
Program that rolls a pair of dice and asks the user to guess the sum.
"""
number_of_sides = 6
def check_guess(guess):
if guess > max_val:
print ("Guess is too high, guess again")
guess = get_user_guess()
elif guess <= 0:
print ("Guess must be Va... | true |
fe4c8c4e20eb92cacc4ae61803b7b2bda8b243f3 | mrpodkalicki/Numerical-Methods | /lab_1/tasks.py | 686 | 4.125 | 4 | #TASKS (4p)
#1 calculate & print the value of function y = 2x^2 + 2x + 2 for x=[56, 57, ... 100] (0.5p)
#2 ask the user for a number and print its factorial (1p)
#3 write a function which takes an array of numbers as an input and finds the lowest value. Return the index of that element and its value (1p)
#4 looking at ... | true |
6c8dfee1a9d82c98efb5ef9fd3379433bf68407f | LalithK90/LearningPython | /privious_learning_code/OS_Handling/os.readlink() Method.py | 708 | 4.15625 | 4 | # Description
#
# The method readlink() returns a string representing the path to which the symbolic link points. It may return an absolute or relative pathname.
# Syntax
#
# Following is the syntax for readlink() method −
#
# os.readlink(path)
#
# Parameters
#
# path − This is the path or symblic link for which we are... | true |
72f57e54a9390cb5b076ea4cc409da0e7759713d | LalithK90/LearningPython | /privious_learning_code/OS_Handling/os.popen() Method.py | 1,048 | 4.21875 | 4 | # Description
#
# The method popen() opens a pipe to or from command.The return value is an open file object connected to the pipe, which can be read or written depending on whether mode is 'r' (default) or 'w'.The bufsize argument has the same meaning as in open() function.
# Syntax
#
# Following is the syntax for pop... | true |
5a1a68b0a693a534361db3206bceab00e68106fc | LalithK90/LearningPython | /privious_learning_code/String/String rfind() Method.py | 808 | 4.375 | 4 | str1 = "this is really a string example....wow!!!"
str2 = "is"
print(str1.rfind(str2))
print(str1.rfind(str2, 0, 10))
print(str1.rfind(str2, 10, 0))
print(str1.find(str2))
print(str1.find(str2, 0, 10))
print(str1.find(str2, 10, 0))
# Description
#
# The method rfind() returns the last index where the substring str is... | true |
4a234927f0f6f3fb11abc4ae52f147ba59b197cb | LalithK90/LearningPython | /privious_learning_code/List/List extend() Method.py | 438 | 4.21875 | 4 |
# Description
#
# The method extend() appends the contents of seq to list.
# Syntax
#
# Following is the syntax for extend() method −
#
# list.extend(seq)
#
# Parameters
#
# seq − This is the list of elements
#
# Return Value
#
# This method does not return any value but add the content to existing list.
# Example
aLi... | true |
98d84207ce7c25952584fcbfabad329cc4690d40 | LalithK90/LearningPython | /privious_learning_code/List/List max() Method.py | 491 | 4.40625 | 4 |
# Description
#
# The method max returns the elements from the list with maximum value.
# Syntax
#
# Following is the syntax for max() method −
#
# max(list)
#
# Parameters
#
# list − This is a list from which max valued element to be returned.
#
# Return Value
#
# This method returns the elements from the list with m... | true |
14c1c4bdd5817b28b1b758d5b3d3fe51bb959f95 | LalithK90/LearningPython | /privious_learning_code/QuotationInPython.py | 448 | 4.40625 | 4 | print("Quotation in Python")
# Python accepts single ('), double (") and triple (''' or """) quotes to denote string literals,
# as long as the same type of quote starts and ends the string.
# The triple quotes are used to span the string across multiple lines.
word = 'word'
sentence = "This is a sentence."
paragraph... | true |
14c050442a17bf7f8ffd71aa476d582735789d7d | LalithK90/LearningPython | /privious_learning_code/String/String isupper() Method.py | 509 | 4.53125 | 5 | str = "THIS IS STRING EXAMPLE....WOW!!!"
print(str.isupper())
str = "THIS is string example....wow!!!"
print(str.isupper())
# Description
#
# The method isupper() checks whether all the case-based characters (letters) of the string are uppercase.
# Syntax
#
# Following is the syntax for isupper() method −
#
# str.isup... | true |
367c5c5015d27b792d9c1e905dff7a72992ad186 | LalithK90/LearningPython | /privious_learning_code/String/String lower() Method.py | 400 | 4.21875 | 4 | str = "THIS IS STRING EXAMPLE....WOW!!!"
print(str.lower())
# Description
#
# The method lower() returns a copy of the string in which all case-based characters have been lowercased.
# Syntax
#
# Following is the syntax for lower() method −
#
# str.lower()
#
# Parameters
#
# NA
#
# Return Value
#
# This method returns ... | true |
65329c697810fa82fb33abcfcdf3d452ca4da93f | LalithK90/LearningPython | /privious_learning_code/Dictionary/dictionary update() Method.py | 467 | 4.1875 | 4 | # Description
#
# The method update() adds dictionary dict2's key-values pairs in to dict. This function does not return anything.
# Syntax
#
# Following is the syntax for update() method −
#
# dict.update(dict2)
#
# Parameters
#
# dict2 − This is the dictionary to be added into dict.
#
# Return Value
#
# This method d... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.