blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
da8c803202a2c3e2b428e4298dac3c19b80eecdd | sojournexx/python | /Assignments/TanAndrew_assign2_problem2.py | 1,188 | 4.28125 | 4 | #Andrew Tan, 2/2, Section 010, Grade Calculator
#Ask user for name and class
name = input("What is your name? ")
course = input("What class are you in? ")
print()
#Ask user for weightage and test scores
weight_test = float(input("How much are tests worth in this class (i.e. 0.40 for 40%): "))
test1 = float... | true |
73682e4924c8d23279b3ef56c65ac5715bc2d7b2 | pulosez/Python-Crash-Course-2e-Basics | /#5: if Statements/favourite_fruits.py | 417 | 4.1875 | 4 | # 5.7.
favourite_fruits = ['orange', 'apple', 'tangerine']
if 'orange' in favourite_fruits:
print("You really like oranges!")
if 'apple' in favourite_fruits:
print("You really like apples!")
if 'tangerine' in favourite_fruits:
print("You really like tangerines!")
if 'banana' in favourite_fruits:
print("... | true |
6c383b3dc9c39f8963ef2afac3eccfba06c378f4 | Jamesong7822/Python-Tutorials | /0) Introduction To Python/tutorials.py | 2,460 | 4.125 | 4 | # def myfunction(a,b,c):
# # Myfunction checks if any number from 0 - 99 is divisible by a, b and c
# ans_list = []
# for i in range(100):
# if i % a == 0 and i % b == 0 and i % c == 0:
# ans_list.append(i)
# return ans_list
# print(myfunction(1,2,3))
# D) Write a function that randomly chooses a number fr... | true |
8fd2ebf33486069e8e7939bd54465ceefe6370a3 | Metalscreame/Python-basics | /date.py | 2,670 | 4.125 | 4 | from datetime import datetime, timedelta
# parsing date
now = datetime.now()
some_date = '01/02/1903'
date_format = '%d/%m/%Y'
parsed_date = datetime.strptime(some_date, date_format)
print(parsed_date)
one_day = timedelta(
days=1,
minutes=2
)
new_date = parsed_date-one_day
print('Parsed minus one day: ', new... | true |
fb1158f7b2802185143717b1dfc4b1ebc28c7cbd | rahulvennapusa/PythonLearning | /SquareInt.py | 240 | 4.15625 | 4 | number = input("Enter the integer :")
if int(number) > 0:
iteration = int(number)
ans = 0
while iteration != 0:
ans = ans + int(number)
iteration = iteration - 1
print("Square of %s is %s :" % (number, ans))
| true |
dc29468021664d1d55e42ac4d0121816655aeb85 | David-H-Afonso/python-basic-tests | /coinExchange.py | 818 | 4.21875 | 4 | # Function
def exchange(coin):
return coin / dollars
# Inputs
dollars = input("Write the amount of dollars you want to exchange: ")
dollars = float(dollars)
coin = input("""
Choose the coin that you want to exchange the value by typing the number. By default this value is "Euros"
1 - Euros
2 - Pesos argentinos
3 ... | true |
e922fc7376a58caf2606224a864acd068c7e975a | SelimRejabd/Learn-python | /string method.py | 552 | 4.25 | 4 | # few useful method for string
name = "reja"
# lenth of string
print(len(name))
# finding a charecter
print(name.find("a"))
# Capitalize "reja" to "Reja"
print(name.capitalize())
# uppercase of a string
print(name.upper())
# lowecase of a string
print(name.lower())
# is string digit or not
prin... | true |
893ae9a7901c8ce7030ca0efdb4c81dba293c3ba | nicolealdurien/Assignments | /week-02/day-1/user_address.py | 1,673 | 4.4375 | 4 | # Week 2 Day 1 Activity - User and Address
# Create a User class and Address class, with a relationship between
# them such that a single user can have multiple addresses.
class User:
def __init__(self, first_name, last_name):
self.first_name = first_name
self.last_name = last_name
self.ad... | true |
980c11b94a9ee491ee2095727036a6ed2b966145 | sichkar-valentyn/Dictionaries_in_Python | /Dictionaries_in_Python.py | 1,597 | 4.75 | 5 | # File: Dictionaries_in_Python.py
# Description: How to create and use Dictionaries in Python
# Environment: PyCharm and Anaconda environment
#
# MIT License
# Copyright (c) 2018 Valentyn N Sichkar
# github.com/sichkar-valentyn
#
# Reference to:
# [1] Valentyn N Sichkar. Dictionaries in Python // GitHub platfo... | true |
ca2e22bf764551e91fdaf13c469258ff3821462c | leinad520/Monty-Hall-Game | /mp_game_simulation.py | 1,867 | 4.125 | 4 | from random import randrange, choice
win_count = 0
def monty_python_game():
# print("You have three doors to choose from. Behind one door is the prize; two other doors have nothing. Which do you choose?")
choicesArr = ["1","2","3"]
prize = choice(choicesArr)
# your_choice = input("type 1 2 or 3\n> ... | true |
1d0abd1db93be3e724570699313277d0c0970653 | rbdjur/Python | /Practice_Modules/Python_object_and_Data_Structure_basics/sets/set.py | 402 | 4.15625 | 4 | myset = set()
#add number 1 to set
myset.add(1)
print(myset)
#add number 2 to the set
myset.add(2)
#add number 2 again to the set
myset.add(2)
#see what the results of a set are
print(myset)
#Only {1,2} are in set despite adding two 2's. this is because a set only holds unique values. IF the value already exist... | true |
0a79efb7b2540019d6d572528ec99a71d41313a3 | rbdjur/Python | /Practice_Modules/Errors_handling_exceptions/try_except_else.py | 696 | 4.21875 | 4 | #The try block will execute and examine the code in this block
try:
result = 10 + 10
print(result)
except:
#if the code contains an error, the code in the except block will execute
print("Adding is not happening check type")
#The try block will execute and examine the code in this block
try:
# a... | true |
c427137c075c714607fc7b740437824b7fe4aae3 | rbdjur/Python | /Practice_Modules/Python_object_and_Data_Structure_basics/variable_assignments/variable_assignments.py | 235 | 4.125 | 4 | my_dogs = 2
my_dogs = ["Sammyy", "Frankie"]
#Above is an example of dynamic typing that allows user to assign different data type
a = 5
print(a)
a = 10
print(a)
a = a + a
print("should be 20", a)
print(type(a))
print(type(my_dogs)) | true |
98806536f6a7adea80fa82bdfaf9876ce8e57b00 | laszlokiraly/LearningAlgorithms | /ch04/linked.py | 1,740 | 4.40625 | 4 | """
Linked list implementation of priority queue structure.
Stores all values in descending.
"""
from ch04.linked_entry import LinkedEntry
class PQ:
"""Heap storage for a priority queue using linked lists."""
def __init__(self, size):
self.size = size
self.first = None
self.N = 0
... | true |
f9e1c7f094f2104fa7975c4e843e8ca1cfc1e96d | arthurleemartinez/InterestTools | /high_interest_loan.py | 2,948 | 4.15625 | 4 | user_principle: float = float(input("How much is the principle amount of your loan?"))
def get_boolean_user_plans():
user_answer: str = input("Do you plan to pay off at least some of it soon? Answer 'yes' or 'no'.")
if user_answer != 'yes' or 'Yes' or 'YES' or 'y' or 'Y':
return False
else:
... | true |
6e4fd23cb4a7129f0a9b5ca3ffb6fb1647f0e321 | nawaraj-b5/random_python_problems | /Python Basics/datatype_conversion.py | 391 | 4.5 | 4 | #Find the length of the text python and convert the value to float and convert it to string
length_of_python = ( len('python') )
length_of_python_in_float = float(length_of_python)
length_of_python_in_string = str( length_of_python )
print ('Length of the python in integer is {}, float is {}, and string is {} '.format(... | true |
a78fae1eb24fbb75cf328d20e83cec97d051356d | oluwafenyi/code-challenges | /CodeWars/6Kyu/Valid Braces/valid_braces.py | 737 | 4.3125 | 4 |
# https://www.codewars.com/kata/valid-braces
# Write a function that takes a string of braces, and determines if the order
# of the braces is valid. It should return true if the string is valid,
# and false if it's invalid.
def validBraces(string):
while '[]' in string or '{}' in string or '()' in string... | true |
1db206efd070dfa46493a2cdabf2f268e8d7cad0 | oluwafenyi/code-challenges | /CodeWars/6Kyu/Find the Missing Letter/find_missing_letter.py | 294 | 4.25 | 4 |
#https://www.codewars.com/kata/find-the-missing-letter
from string import ascii_letters
def find_missing_letter(chars):
ind = ascii_letters.index(chars[0])
corr_seq = list(ascii_letters[ind:ind+len(chars)+1])
return [char for char in corr_seq if char not in chars][0]
| true |
f78d289529201648db63dbc4981b5ab121b3c61f | pathakamaresh86/python_class_prgms | /day5_assign.py | 1,119 | 4.28125 | 4 | #!/usr/bin/python
num1=input("Enter number")
print "Entered number ", num1
# if LSB(last bit) is zero then even if 1 then odd
if num1&1 == 0:
print str(num1) + " is even number"
else:
print str(num1) + " is odd number"
num1=input("Enter number")
print "Entered number ", num1
if num1&15 == 0:... | true |
e48a1567b7c529cb7a6ff50ab7cf22844dc2b19f | pathakamaresh86/python_class_prgms | /day4_assign.py | 1,011 | 4.21875 | 4 | #!/usr/bin/python
str=input("Enter string")
print "Entered string ", str
print "first tow and last two char string ", str[1:3:1]+str[-1:-3:-1]
str1=input("Enter string")
print "Entered string ", str1
print "occurance replaced string", str1[:1]+str1[1:].replace("b", "*")
str1,str2=input("Enter two strings... | true |
08ab6206785466e01758fc3df211b289d73e4fb6 | MunsuDC/visbrain | /examples/signal/02_3d_signals.py | 1,665 | 4.15625 | 4 | """
Plot a 3D array of data
=======================
Plot and inspect a 3D array of data.
This example is an extension to the previous one (01_2d_signals.py). This time,
instead of automatically re-organizing the 2D grid, the program use the number
of channels for the number of rows in the grid and the number of trial... | true |
82d1b9ee2f5a78cd095960a36a58e19b6239409e | zoeyouyu/GetAhead2020 | /Q3 - solution.py | 1,240 | 4.25 | 4 | # Longest path in the Tree
class Tree:
def __init__(self, value, *children):
self.value = value
self.children = children
# We walk the tree by iterating throught it,
# yielding the length of the path ending at each node we encounter,
# then take the max of that.
def longest_path(tree):
def rec(current, ... | true |
d386a27c06a6252f2331beff919a290887cd4825 | saikumarsandra/My-python-practice | /Day-5/variableLengthArg.py | 418 | 4.25 | 4 | # when * is added before any argument then t act as the variable length argument
#it act as a parameter that accepts N number of values to one argument act as a tuple
def myFun(a,*b):
print (a,b)
myFun("sai",2.0)
#type 2
myFun("this is 'a'",2.0,1,2,3,4,5,6,[1,2,3],(1,2,3),{9,8,10})
def avg(*vals):
... | true |
03edbcdf7a43db403c91d9499f8c7c90a1afdcbe | tsoporan/exercises_and_algos | /python/observer.py | 1,096 | 4.28125 | 4 | """
An example of the Observer pattern in Python.
A Subject keeps track of its observers and has a method of notifying them.
"""
class Subject(object):
def __init__(self):
self.observers = []
def register_observer(self, observer):
self.observers.append(observer)
def unregister_observer(self, obser... | true |
f0407174a9908c1a73ee250296d334ae73bb178a | tsoporan/exercises_and_algos | /python/utopian_tree.py | 762 | 4.34375 | 4 | """
Utopian tree goes through 2 cycles of growth a YEAR.
First cycle in spring: doubles in height
Second cycle in summer: height increases by 1
Tree is planted onset of spring with height 1.
Find the height of tree after N growth cycles.
"""
def growthAfterCycles(lst):
out = []
for cycle in lst:
h... | true |
bb8bb6ca07ad5d3793b8e24fdee189d83657e294 | wprudencio97/csc121 | /wprudencio_lab6-8.py | 1,759 | 4.40625 | 4 | #William Prudencio, Chapter 6 - Lab 8, 8/18/19
''' This program reads the random numbers that were generated into
randomNumbers.txt and will display the following: 1)Count of the
numbers in the file, 2)Total of the numbers in the file, 3)Average of
the numbers in the file, 4)Largest and smallest number in the file. '... | true |
a9caaccc5a5ade933817c50c8a8daf912b3c0255 | Tripl3Six/Rock-paper-scissors-lizard-spock | /rpsls.py | 2,206 | 4.1875 | 4 | # Rock-paper-scissors-lizard-Spock
# The key idea of this program is to equate the strings
# "rock", "paper", "scissors", "lizard", "Spock" to numbers
# as follows:
#
# 0 - rock
# 1 - Spock
# 2 - paper
# 3 - lizard
# 4 - scissors
import random as rand
# helper functions
def name_to_number(name):
if name == 'ro... | true |
af76dc1189d8b1985cd069e250ca17ee1bde6dff | MahjubeJami/Python-Programming-01 | /python essentials/mod03-exe03.py | 994 | 4.5625 | 5 | """
3. You are trying to build a program that will ask the user the following:
First Name
Temperature
Based on the user's entries, the program will recommend the user to wear
a T-shirt if the temperature is over or equal to 70º or bring a sweater if it is less than 70º.
Console Output
What s... | true |
1201f750d7ccc0c120fe4773ec50337bce5dc8c2 | MahjubeJami/Python-Programming-01 | /python strings/mod06-exe_6.7.py | 1,890 | 4.21875 | 4 | # Using the variable famous_list, write a program to check
# if a famous individual is in the list above, if they are
# then print: Sorry, the individual did not make the top 20 cut!
# Otherwise print: Yup, the individual did make the top 20 cut.
#
# Console:
#
# Please Enter the name of the famous individual? A... | true |
3ab92c4162bb89747c786a4a6975a083f06dd368 | MahjubeJami/Python-Programming-01 | /python strings/mod06-exe_6.4.py | 834 | 4.4375 | 4 | """
4. Write a Python function to create the HTML
string with tags around the word(s).
Sample function and result are shown below:
add_html_tags('h1', 'My First Page')
<h1>My First Page</h1>
add_html_tags('p', 'This is my first page.')
<p>This is my first page.</p>
add_html_tags('h... | true |
be23e3bb52a6a191041264d2430fde3a4a1ebdd6 | richardOlson/Intro-Python-I | /src/13_file_io.py | 1,172 | 4.375 | 4 | """
Python makes performing file I/O simple. Take a look
at how to read and write to files here:
https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files
"""
# importing the os to get the path to find the file
import os
fooPath = os.path.join(os.path.dirname(__file__), "foo.txt")
# Open up t... | true |
399553cdf2290f687ec9466a0ccf1353c2a1e2b9 | pratikshyad32/pratikshya | /rock paper scissor game.py | 1,833 | 4.1875 | 4 | name=input("Enter your name")
while name.isalpha()==False or len(name)<6:
name=input("your name is wrong please enter again")
else:
print("Hello",name)
age=(input("Enter your age"))
while age.isdigit()==False :
age=input("your age is wrong please enter again")
else:
print("your age is accep... | true |
a2caca192e370b9e3565139dddb0515cff9ea421 | SaiSudhaV/TrainingPractice | /ArraysI/array_square.py | 312 | 4.1875 | 4 | # 3 Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order.
def squares(ar):
return sorted([i ** 2 for i in ar])
if __name__ == "__main__":
n = int(input())
ar = list(map(int, input().split()))
print(squares(ar)) | true |
7e60df36ee9effdd2a5b732fb34ad6b33b33b89b | Ap6pack/PythonProjects | /UserMenu | 2,436 | 4.34375 | 4 | #!/usr/bin/env python3
### What and where the information is being stored
userTuples = ["Name", "Age", "Sex"]
userList = [ ]
age2 = []
sex2 = []
### I have used def to define my menu so I can use this format over and over.
def userDirectory():
print "1. Add your information to the list"
... | true |
d311436ad2902a7ccc5ea809669a280ab0aea17a | oekeur/MinProg_DataToolkit | /Homework/Week 1/exercise.py | 2,028 | 4.25 | 4 | # Name : Oscar Keur
# Student number : 11122102
'''
This module contains an implementation of split_string.
'''
# You are not allowed to use the standard string.split() function, use of the
# regular expression module, however, is allowed.
# To test your implementation use the test-exercise.py script.
# A note about... | true |
9f8efa161d8ef1b8bf35075c4723e4453cc265fc | licup/interview-problem-solving | /Module 7/kBackspace.py | 838 | 4.125 | 4 | '''
K Backspaces
The backspace key is broken. Every time the backspace key is pressed, instead of deleting the last
(non-backspace) character, a '<' is entered.
Given a string typed with the broken backspace key, write a program that outputs the
intended string i.e what the keyboard output should be when the backsp... | true |
968f323dc9381b444f1341813449e458dcc78e62 | licup/interview-problem-solving | /Module 7/sya.py | 1,342 | 4.15625 | 4 | '''
Reverse polish notation is a postfix notation for mathematical expressions.
For example, the infix expression (1 + 2) / 3 would become 1 2 + 3 /.
More detailed explanation here: https://en.wikipedia.org/wiki/Reverse_Polish_notation
Task:
Given a mathematical expression in reverse polish notation, represented by... | true |
de6836359ebbac88fe38613153af669a9af33902 | thisislola/Tutorials | /temp_calculator.py | 1,825 | 4.28125 | 4 | # Temperature Calculator by L. Carthy
import time
def intro_options():
""" Takes the option and returns the fuction
that correlates """
option = int(input("1 for Fahrenheit to Celsius \n"
"2 for Celcius to Fahrenheit \n"
"3 for Fahrenheit to Kelvin: "))
... | true |
db54e4a06079cbba0c755e0df03afbe2892eb739 | satishkr39/MyFlask | /Python_Demo/Class_Demo.py | 1,415 | 4.46875 | 4 | class Sample:
pass
x = Sample() # creating x of type Sample
print(type(x))
class Dog:
# def __init__(self, breed):
# self.breed = breed
# CLASS OBJECT ATTRIBUTE IT will always be same for all object of this class
species = 'Mammal'
# INIT METHOD CALLED EVERY TIME AN OBJECT IS CREATED
... | true |
c9685fe1d887a5f52952043f559ce6e71108ef27 | anand-ryuzagi/Data-Structue-and-Algorithm | /Sorting/merge-sort.py | 1,123 | 4.25 | 4 | # mergesort = it is divide and conquer method in which a single problem is divided in to small problem of same type and after solving each small problem combine the solution.
# Time complexity : O(nlogn)
# Space complexity : O(n)
# algorithms :
# 1. divide the array into two equal halves
# 2. recursively divide each... | true |
7b498522f914cf3f88d686578da8201adaf2bb10 | devathul/prepCode | /DP/boxStacking.py | 2,661 | 4.21875 | 4 | """
boxStacking
Assume that we are given a set of N types 3D boxes; the dimensions are defined for i'th box as:
h[i]= height of the i'th box
w[i]= width of the i'th box
d[i]= depth of the i'th box
We need to stack them one above the other and print the tallest height that can be achieved. One type of box can be used... | true |
92bcb1209ffeea2320590bd05a442c73bf492dfe | connorholm/Cyber | /Lab2-master/Magic8Ball.py | 960 | 4.125 | 4 | #Magic8Ball.py
#Name:
#Date:
#Assignment:
#We will need random for this program, import to use this package.
import random
def main():
#Create a list of your responses.
options = [
"As I see it, yes.",
"Ask again later.",
"Better not tell you now.",
"Cannot predict now.",
"Concentrat... | true |
115595d836d0f9202a444db48c5abb71020eeb00 | xMijumaru/GaddisPythonPractice | /Chapter 2/Gaddis_Chap2_ProgEX10_Ingredient/main.py | 486 | 4.125 | 4 | #this program will run the ingredients needed to produce cookies
amount=int(input('How many cookie(s) do you wish to make: '))
#this is the amount that makes 48 cookies
sugar=1.5/48.0
butter=1/48.0
flour=2.75/48.0
#reminder that // is int division and / is float division
print("Amount to make ",amount, " cookie(s)")
pr... | true |
fe5d02ecda6c3b78d3e3b418211ad508a60c000f | yms000/python_primer | /rm_whitespace_for_file.py | 820 | 4.15625 | 4 | #! /usr/bin/python
# -*- coding: utf-8 -*-
# rm_whitespace_for_file.py
# author: robot527
# created at 2016-11-6
'''
Remove trailing whitespaces in each line for specified file.
'''
def rm_whitespace(file_name):
'''Remove trailing whitespaces for a text file.'''
try:
with open(file_name, 'r+') as cod... | true |
02c841ac52ca32b61b87f71502f072c047ac38ea | BrothSrinivasan/leet_code | /cycle graph/solution.py | 1,534 | 4.1875 | 4 | # Author: Barath Srinivasan
# Given an unweighted undirected graph, return true if it is a Cycle graph;
# else return false. A Cycle Graph is one that contains a single cycle and every
# node belongs to that cycle (it looks like a circle).
# Notes:
# a cycle is only defined on 3 or more nodes.
# adj_matrix is an n-by... | true |
a85e19425d0c1ca0e7d9907fb2d7421acdbfa71e | avneetkaur1103/workbook | /DataStructure/BinaryTree/tree_diameter.py | 1,342 | 4.1875 | 4 | """ Print the longest leaf to leaf path in a Binary tree. """
class Node:
def __init__(self, value):
self.key = value
self.left = self.right = None
def diameter_util(root):
if not root:
return 0, []
left_height, left_subtree_path = diameter_util(root.left)
right_height, right_subtree_path = diameter_util(r... | true |
3fd71c526ccbfcf4ab615d8615084924088c0c3e | natanisaitejasswini/Python-Programs | /OOP/underscoreduplicte.py | 997 | 4.5625 | 5 | """
map => Take a list and a function, and return the list you get by applying that function to every item in the list
filter => Take a list and return only the values when a given function is true
my_filter([1,2,3,4,5], lambda x: x%2==0) => [2,4]
reject => The exact opposite of filter
my_reject([1,2,3,4,5], la... | true |
75b5e1c59aa553349af121218c3281442fa60a78 | shivakarthikd/practise-python | /single_linked_list.py | 1,615 | 4.28125 | 4 | class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class LinkedList:
# Function to initialize head
def __init__(self):
self.head = None
# This function prints contents of linked list
# starting from head
def printList(self):
... | true |
bddacb0f55e6d1b2332f6a48471ad8b0b31c51b6 | StRobertCHSCS/ics2o1-201819-igothackked | /life_hacks/life_hack_practice_1.3.py | 527 | 4.34375 | 4 |
'''
-------------------------------------------------------------------------------
Name: minutes_to_days.py
Purpose: converts minutes into days, hours, minutes
Author: Cho.J
Created: date in 22/02/2019
------------------------------------------------------------------------------
'''
#PRINT
minute= int(input("Ho... | true |
f680f5deb0653aa00c080a84d992f8bacb58d6d0 | StRobertCHSCS/ics2o1-201819-igothackked | /unit_2/2_6_4_while_loops.py | 276 | 4.34375 | 4 |
numerator = int(input("Enter a numerator: "))
denominator = int(input("Enter denominator: "))
if numerator // denominator :
print("Divides evenly!")
else:
print("Doesn't divide evenly.")
while denominator == 0:
denominator = int(input("Enter denominator: "))
| true |
7d05afce4800e027970c6523cb3f83abf677a020 | mihaivalentistoica/Python-Fundamentals | /python-fundamentals-master/09-flow-control/while-loop-exercise.py | 1,012 | 4.3125 | 4 | user_input = ""
# b. If the input is equal to “exit”, program terminates printing out provided input and “Done.”.
while user_input != "exit":
# a. Asks user for an input in a loop and prints it out.
user_input = input("Provide input: ")
# c. If the input is equal to “exit-no-print”, program terminates with... | true |
5f37a37f5b8d2ac55c0bdc1b6be249058c8b411e | ShivangiNigam123/Python-Programs | /regexsum.py | 381 | 4.1875 | 4 | #read through and parse a file with text and numbers. You will extract all the numbers in the file and compute the sum of the numbers.
import re
name = input ("enter file :")
sum = 0
fhandle = open(name)
numlist = list()
for line in fhandle:
line = line.rstrip()
numbers = re.findall('[0-9]+',line)
for num... | true |
5396067aa7a5580b864123469f232d1c7fce7369 | danbeyer1337/Python-Drill--item-36 | /item36Drill.py | 1,963 | 4.125 | 4 | #Assign an integer to a variable
number = 4
#Assign a string to a variable
string = 'This is a string'
#Assign a float to a variable
x = float (25.0/6.0 )
#Use the print function and .format() notation to print out the variable you assigned
print 'The variables are {0}, {1}, {2}'.format(number, strin... | true |
3506f85dcd5b448b4f0c009e1fa9a239dacc45ba | IamBikramPurkait/100DaysOfAlgo | /Day 3/Merge_Meetings.py | 1,451 | 4.25 | 4 | '''Write a function merge_ranges() that takes a list of multiple meeting time ranges and returns a list of condensed
ranges.Meeting is represented as a list having tuples in form of (start time , end time)'''
# Time complexity is O(nlogn)
def merge_meetings_time(meetinglist):
# Sort the meetings by start... | true |
41e0d6d733fba92c65018cb3df37ed00baf1eff3 | IamBikramPurkait/100DaysOfAlgo | /Day 4/FirstComeFirstServe.py | 1,258 | 4.21875 | 4 | # Recursive Approach
# Problem statement : Write a function to check if a restaurant serves first come , first serve basis
# Assumptions: 1)There are three lists dine_in_orders , take_out_orders , served_orders
# 2)The orders number will not be ordered and are randomly assigned
# 3)They are g... | true |
1e4d7b0f98b1d63b4bf82cb8f1b353176cc71c42 | IamBikramPurkait/100DaysOfAlgo | /Day1/Tower of Hanoi.py | 1,367 | 4.25 | 4 | ''' Problem Tower of Hanoi:
About: Tower of Hanoi is a mathematical puzzle where we have three rods and n disks. The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules:
1) Only one disk can be moved at a time.
2) Each move consists of taking the upper disk from one of... | true |
f93e10068776b3ab4e298bf55eae39598a38ec5d | indexcardpills/python-labs | /02_basic_datatypes/2_strings/02_09_vowel.py | 444 | 4.25 | 4 | '''
Write a script that prints the total number of vowels that are used in a user-inputted string.
CHALLENGE: Can you change the script so that it counts the occurrence of each individual vowel
in the string and print a count for each of them?
'''
#string=input("write a sentence: ")
string="the dog ate th... | true |
3c47d535501c877aae1e7c115534d309f9cfac32 | indexcardpills/python-labs | /15_generators/15_01_generators.py | 237 | 4.3125 | 4 | '''
Demonstrate how to create a generator object. Print the object to the console to see what you get.
Then iterate over the generator object and print out each item.
'''
daniel = (x+'f' for x in "hello")
for x in daniel:
print(x)
| true |
eb2128c3f33e18a27de998a58e00a0c1056d28d3 | indexcardpills/python-labs | /04_conditionals_loops/04_07_search.py | 575 | 4.15625 | 4 | '''
Receive a number between 0 and 1,000,000,000 from the user.
Use while loop to find the number - when the number is found exit the loop and print the number to the console.
'''
while True:
number = int(input("Enter a number between 0 and 1,000,000,000: "))
x = 7
if number < x:
print("no, higher... | true |
a4508650196850cea3aecd960dd0e9a06c98cbe3 | indexcardpills/python-labs | /10_testing/10_01_unittest.py | 690 | 4.34375 | 4 | '''
Demonstrate your knowledge of unittest by first creating a function with input parameters and a return value.
Once you have a function, write at least two tests for the function that use various assertions. The
test should pass.
Also include a test that does not pass.
'''
import unittest
def multiply(x, y):
... | true |
2ca18b8597a9d80d73fd7d1da52f7691664b5bf4 | indexcardpills/python-labs | /04_conditionals_loops/04_05_sum.py | 791 | 4.3125 | 4 | '''
Take two numbers from the user, one representing the start and one the end of a sequence.
Using a loop, sum all numbers from the first number through to the second number.
For example, if a user enters 1 and 100, the sequence would be all integer numbers from 1 to 100.
The output of your calculation should therefo... | true |
0ef559fbb64de7780dda09df151d2e4482bc1410 | tonynguyen99/python-stuff | /guess number game/main.py | 945 | 4.25 | 4 | import random
def guess(n):
random_number = random.randint(1, n)
guess = 0
while guess != random_number:
guess = int(input(f'Guess a number between 1 and {n}: '))
if guess > random_number:
print('Too high!')
elif guess < random_number:
print('Too low!')
... | true |
b51af61c9960b18b8829708f6a0d3a8f18a5fd2f | sathvikg/if-else-statement-game | /GameWithBasics.py | 1,463 | 4.1875 | 4 | print("Welcome to your Game")
name = input("What is your name? ")
print("hi ",name)
age = int(input("What is your age? "))
#print(age)
#print(name,"you are good to go. As you are",age,"years old")
health = 10
print("you are starting with ",health,"health")
if age > 18:
print("you can continue the game.")
... | true |
d3246fddc314795c42ec10a19be60f2c0e026675 | GaborVarga/Exercises_in_Python | /46_exercises/8.py | 1,124 | 4.34375 | 4 | #!/usr/bin/env python
#######################
# Author: Gabor Varga #
#######################
# Exercise description :
# Define a function is_palindrome() that recognizes palindromes
# (i.e. words that look the same written backwards).
# For example, is_palindrome("radar") should return True.
#
# http://www.ling.gu... | true |
e7e4117d2f583ceedce8c4cdba546523d9532ac8 | UCdrdlee/ScientificComputing_HW0 | /fibonacci.py | 2,824 | 4.5 | 4 | """
fibonacci
functions to compute fibonacci numbers
Complete problems 2 and 3 in this file.
"""
import time # to compute runtimes
from tqdm import tqdm # progress bar
# Question 2
def fibonacci_recursive(n):
if n == 0:
return 0
if n == 1:
return 1
else:
return fibonacci_recursiv... | true |
837b4fe80020202ed9b37e0ac5dc0f868ec0aa8f | Yagomfh/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/0-add_integer.py | 713 | 4.34375 | 4 | #!/usr/bin/python3
"""Module that that adds 2 integers.
Raises:
TypeError: if a or b are not int or floats
"""
def add_integer(a, b=98):
"""Function that adds 2 integers
Args:
a (int/float): first digit
b (int/float): second digit
Returns:
Int sum of both digits
"""
... | true |
c0a7efc9d8720a168c1677b413d2a86f8a494fe6 | kadahlin/GraphAlgorithms | /disjoint_set.py | 1,877 | 4.15625 | 4 | #Kyle Dahlin
#A disjoint set data structure. Support finding the set of a value, testing if
#values are of hte same set, merging sets, and how may sets are in the entire
#structure.
class Disjoint:
def __init__(self, value):
self.sets = []
self.create_set(value)
def create_set(self, value):... | true |
fb8318baba89169105e27fdc76b00e80888fb222 | Mone12/tictactoe-python | /.vscode/tictactoe.py | 1,176 | 4.1875 | 4 | import random
## Need to establish which player goes first through randomization
player = input("Please enter your name:")
cpu = "CPU"
p_order = [player,cpu]
if player:
random.shuffle(p_order)
if p_order[0] == player:
print(f"{player} you are Player 1. You go first!")
print(f"{cpu} is Playe... | true |
d867547f67b3c2697fffaabdccd39b4571ee473c | smukh93/Python_MITx | /iter_pow.py | 606 | 4.125 | 4 | def iterPower(base, exp):
'''
base: int or float.
exp: int >= 0
returns: int or float, base^exp
'''
# Your code here
prod = 1
if exp == 0:
return 1
else:
for x in range(exp):
prod *=base
return prod
def recurPower(base, exp):
'''
base: ... | true |
a3a152ffc0a8fb2fe28def7b018ef54f4a65506d | gourav287/Codes | /Codechef-and-Hackerrank/NoOfStepsToReachAGivenNumber.py | 1,304 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""
Question Link:
https://practice.geeksforgeeks.org/problems/minimum-number-of-steps-to-reach-a-given-number5234/1
Given an infinite number line. You start at 0 and can go either to the left or to the right.
The condition is that in the ith move, youmust take i steps.
Given a destinati... | true |
089e2881ecc68c06e9fd9fe958d4ccd1414d55d0 | gourav287/Codes | /BinaryTree/TreeCreation/CreateTreeByInorderAndPreorder.py | 2,259 | 4.28125 | 4 | """
Implementation of a python program to create a binary tree
when the inOrder and PreOrder traversals of the tree are given.
"""
# Class to create a tree node
class Node:
def __init__(self, data):
# Contains data and link for both child nodes
self.data = data
self.left = None
... | true |
263b8fdfdc3989979ec92e72110fd79be8ead6fd | gourav287/Codes | /Codechef-and-Hackerrank/Binary_to_decimal_recursive.py | 740 | 4.34375 | 4 | # -*- coding: utf-8 -*-
"""
Write a recursive code to convert binary string into decimal number
"""
# The working function
def bin2deci(binary, i = 0):
# Calculate length of the string
n = len(binary)
# If string has been traversed entirely, just return
if i == n - 1:
return ... | true |
a056d2b012f5d2d3c8b0cb46cd26e5a960550970 | HANZ64/Codewars | /Python/8-kyu/07. Return Negative/index.py | 1,405 | 4.15625 | 4 | '''
Title:
Return Negative
Kata Link:
https://www.codewars.com/kata/return-negative
Instructions:
In this simple assignment you are given a number and have to make it negative. But maybe the number is already negative?
Example:
make_negative(1); # return -1
make_negative(-5); # return... | true |
a93e2fab8fe0972396945484bf75634184a2bf70 | albihasani94/PH526x | /week3/word_stats.py | 645 | 4.1875 | 4 | from week3.counting_words import count_words
from week3.read_book import read_book
def word_stats(word_counts):
"""Return number of unique words and their frequencies"""
num_unique = len(word_counts)
counts = word_counts.values()
return (num_unique, counts)
text = read_book("./resources/English/shak... | true |
be8849979ce06c3cfa24cae9fb933e6673de5a3d | af94080/dailybyte | /next_greater.py | 1,066 | 4.21875 | 4 | """
This question is asked by Amazon. Given two arrays of numbers, where the first array is a subset of the second array, return an array containing all the next greater elements for each element in the first array, in the second array. If there is no greater element for any element, output -1 for that number.
Ex: Giv... | true |
3941ff68870c3b573885de1fb512c97953d29dcf | pjm8707/Python_Beginning | /py_basic_datatypes.py | 2,077 | 4.28125 | 4 | import sys
print("\npython data types -Numeric")
#create a variable with integer value
a=100
print("The type of variable having value", a, "is", type(a))
print("The maximum interger value", sys.maxsize)
print("The minimum interger value", -sys.maxsize-1)
#create a variable with float value
b=10.2345
prin... | true |
1f9bd3a166434e6f800e9f01938fd3bf615c5ec9 | inesjoly/toucan-data-sdk | /toucan_data_sdk/utils/postprocess/rename.py | 976 | 4.25 | 4 | def rename(df, values=None, columns=None, locale=None):
"""
Replaces data values and column names according to locale
Args:
df (pd.DataFrame): DataFrame to transform
values (dict):
- key (str): term to be replaced
- value (dict):
- key: locale
... | true |
6bee3da547307daf0e4245423a159b4196dcd025 | Vishal0442/Python-Excercises | /Guess_the_number.py | 480 | 4.21875 | 4 | #User is prompted to enter a guess. If the user guesses wrong then the prompt appears again until the guess is correct,
#on successful guess, user will get a "Well guessed!" message, and the program will exit
import random
while True:
a = random.randint(1,9)
b = int(input("Guess a number : "))
i... | true |
3ecfd62848650e4bfe40cb5907d31eb9398e18c5 | nikhil-jayswal/6.001 | /psets/ps1b.py | 1,002 | 4.21875 | 4 | # Problem Set 1b
# Nikhil Jayswal
#
# Computing sum of logarithms of all primes from 2 to n
#
from math import * #import math to compute logarithms
n = int(raw_input('Enter a number (greater than 2): '))
start = 3 #the second prime; don't need this can do candidate = 3
log_sum = log(2) #sum of logarithms of primes, fi... | true |
b6ccbbb9ab29a1cbe46ef64731dad597b94c337b | GaneshGoel/Basic-Python-programs | /Grades.py | 555 | 4.125 | 4 | #To print grades
x=int(input("Enter the marks of the student:"))
if(x<=100 or x>=0):
if(x>90 and x<=100):
print("O")
elif(x>80 and x<=90):
print("A+")
elif(x>70 and x<=80):
print("A")
elif(x>60 and x<=70):
print("B+")
e... | true |
ee5f0793f86f7396d38234c1ac621a387fa768f2 | kt00781/Grammarcite | /AddingWords.py | 826 | 4.1875 | 4 | from spellchecker import SpellChecker
spell = SpellChecker()
print("To exit, hit return without input!")
while True:
word = input("Input the word that you would like to add to the system: ")
if word == '':
break
word = word.lower()
if word in spell:
print ("Word ({}) already in Dictionar... | true |
d03bc8035c16bdef2486f27e59d3e430b178790c | Leofariasrj25/simple-programming-problems | /elementary/python/sum_multiples(ex5).py | 258 | 4.34375 | 4 | print("We're going to print the sum of multiples of 3 and 5 for a provided n")
n = int(input("Inform n: "))
sum = 0
# range is 0 based so we add 1 to include n
for i in range(3, n + 1):
if i % 3 == 0 or i % 5 == 0:
sum += i
print(sum)
| true |
3042b228dba1572138e2216bcef1f3dac8f0368b | CTTruong/9-19Assignments | /Palindrome.py | 455 | 4.1875 | 4 | def process_text(text):
text = text.lower()
forbidden = ("!", "@", "#")
for i in forbidden:
text = text.replace(i, "")
return text
def reverse(text):
return text[::-1]
def is_palindrome(text):
new = process_text(text)
return process_text(text) == reverse(process_text(text))
someth... | true |
d0c094920da68f24db3d489cab6c1f2e37a17787 | yeshwanthmoota/Python_Basics | /lambda_and_map_filter/map_filter.py | 1,148 | 4.3125 | 4 | nums=[1,2,3,4,5,6,7,8,9]
def double(n):
return n*2
my_list=map(double,nums)
print(my_list)
def even1(n):
return n%2==0
def even2(n):
if(n%2==0):
return n
my_list=map(even2,nums) #This doesn't return a list it returns-
#-address of the genrators of the operation performed.
print(my_list)
my_list=... | true |
4abe4684d196821bdc39592e31e3b94d21f8e22b | yeshwanthmoota/Python_Basics | /comprehensions/zip_function.py | 433 | 4.125 | 4 | names=["Bruce","Clark","Peter","Logan","Wade"]
heroes=["Batman","Superman","Spiderman","Wolverine","Deadpool"]
# Now to use the zip function
Identity_list=list(zip(names,heroes))
print(Identity_list)
Identity_tuple=tuple(zip(names,heroes))
print(Identity_tuple)
Identity_dict=dict(zip(names,heroes)) # This is importan... | true |
866832f1f7e1429b4462491be12a4891f10934f7 | rivergillis/mit-6.00.1x | /midterm/flatten.py | 614 | 4.34375 | 4 | def flatten(aList):
'''
aList: a list
Returns a copy of aList, which is a flattened version of aList
[[1,'a',['cat'],2],[[[3]],'dog'],4,5] is flattened into [1,'a','cat',2,3,'dog',4,5]
'''
if aList == []:
return []
print(aList)
for index,elem in enumerate(aList):
prin... | true |
6406ba8d6fa1df233b6bd4ed010c5061bab39066 | Gaurav-dawadi/Python-Assignment | /Data Types/question21.py | 909 | 4.28125 | 4 | """Write a Python program to get a list, sorted in increasing order by the last
element in each tuple from a given list of non-empty tuples."""
def getListOfTuples():
takeList = []
num = int(input("Enter number of tuples you want in list: "))
for i in range(num):
takeTuples = ()
for j ... | true |
79a49b8caf4291c0c762e81a851212cc509e6c6a | Joyce-O/Register | /treehouse_python_basics.py/masterticket.py | 1,514 | 4.125 | 4 | TICKET_PRICE = 10
tickets_remaining = 100
#Run tickets untill its sold out
while tickets_remaining >= 1:
# Output how many tickets are remaining using the tickets remaining variable
print("There are {} tickets remaining.".format(tickets_remaining))
# Gather the user's name and assign it to a new variable
... | true |
d5498151efd9677fe5247d12c6b4956822937f60 | erin-weeks/hello_world | /8_person.py | 777 | 4.46875 | 4 | #Building more complicated data structures
'''This exercise takes various parts of a name and then returns a dicionary.'''
def build_person(first_name, last_name, age = ''):
'''Return a dictionary of information about a person'''
person = {'first': first_name, 'last': last_name}
'''Because age is optiona... | true |
a2c94ca0ccf5569edfd3637bfeabc22c4ca84940 | Nelapati01/321810305034-list | /l1.py | 231 | 4.28125 | 4 | st=[]
num=int(input("how many numbers:"))
for n in range (num):
numbers=int(input("Enter the Number:"))
st.append(numbers)
print("Maximum elements in the list:",max(st),"\nMinimum element in the list is :",min(st))
| true |
e049d49db2e69afaa2795331bdd9500cb0ebc2de | MilesBell/PythonI | /practicep1.py | 1,916 | 4.15625 | 4 | chapter="Introduction to PythonII"
print("original chapter name:")
print(chapter)
print("\nIn uppercase:")
print(chapter.upper())
print("\nIn 'swapcase':")
print(chapter.swapcase())
print("\nIn title format:")
print(chapter.title())
print("\nIn 'strip' format:")
print(chapter.strip())
print("\n\nPress the enter key to ... | true |
3410fdab20dd9e10e148c29a69b40ef8e10bc160 | HaythemBH2003/Object-Oriented-Programming | /OOP tut/Chapter4.py | 1,478 | 4.125 | 4 | ######## INTERACTION BETWEEN CLASSES ########
class Student:
def __init__(self, name, age, grade):
self.name = name
self.age = age
self.grade = grade
def get_grade(self):
return self.grade
def get_name(self):
return self.name
class Course:
d... | true |
59e52bd9931ca75082f8d2504722e8b2bc2c976a | alitsiya/InterviewPrepPreWork | /strings_arrays/maxSubArray.py | 670 | 4.21875 | 4 | # Find the contiguous subarray within an array (containing at least one number) which has the largest sum.
# For example:
# Given the array [-2,1,-3,4,-1,2,1,-5,4],
# the contiguous subarray [4,-1,2,1] has the largest sum = 6.
# For this problem, return the maximum sum.
def maxSubArray(A):
if len(A) == 0:
retur... | true |
dea9250a810a2f87be8ee0f6bbf720dfa963d144 | nmoore32/coursera-fundamentals-of-computing-work | /2 Principles of Computing/Week 4/dice_analysis.py | 1,893 | 4.21875 | 4 | """
Program to analyze expected value of simple dice game.
You pay $10 to play.
Roll three dice.
You win $200 if you roll triples, get your $10 back if doubles, and lose the $10 otherwise
"""
def gen_all_sequences(outcomes, length):
"""
Iterative function that enumerates the set of all sequences of
outcom... | true |
bff961baa068c0a52ce669edd31222aa2b45e928 | xxw1122/Leetcode-python-xxw | /283 Move Zeroes.py | 835 | 4.15625 | 4 | """
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.
For example, given nums = [0, 1, 0, 3, 12], after calling your function, nums should be [1, 3, 12, 0, 0].
Note:
You must do this in-place without making a copy of the array.
Minimi... | true |
602a2952d43b2c43eab807be4a629af2a6fc4849 | feladie/info-206 | /hw3/BST.py | 2,481 | 4.46875 | 4 | #---------------------------------------------------------
# Anna Cho
# anna.cho@ischool.berkeley.edu
# Homework #3
# September 20, 2016
# BST.py
# BST
# ---------------------------------------------------------
class Node:
#Constructor Node() creates node
def __init__(self,word):
self.word = word
... | true |
9ce73959107cd05593c971af07ac82530e9b6a35 | chilango-o/python_learning | /seconds_calculator.py | 739 | 4.34375 | 4 | def calcSec():
""" A function that calculates a given number of seconds (user_seconds)
and outputs that value in Hour-minute-second format
"""
user_seconds = int(input('cuantos segundos? '))
hours = user_seconds // 3600 #integer division between the given seconds and the number of seconds in 1 hour ... | true |
21026c68e2fb2a211d72eaf48ab67edc023ffe32 | MulengaKangwa/PythonCoreAdvanced_CS-ControlStatements | /53GradingApplication.py | 790 | 4.15625 | 4 |
m=int(input("Enter your maths score (as an integer):"))
if m >=59:
p = int(input("Enter your physics score(as an integer):"))
if p >= 59:
c = int(input("Enter your chemistry score(as an integer):"))
if c >= 59:
if (p + m + c) / 3 <= 59:
print("You secured a C grade"... | true |
8d8e09d5241dcf6a3055e72355029a84967aa0af | ellisgeek/linux1 | /chapter7/scripts/month.py | 332 | 4.34375 | 4 | #!/usr/bin/env python
#define the months of the year
months = ["January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
print "Traditional order:"
for month in months:
print month
print "\n\nAlphabetical order:"
for month in sorted(months):
... | true |
eec1de729ffc2a62859746605198505a3f8a994a | tamjidimtiaz/CodeWars | /<8 Kyu> Logical calculator.py | 1,216 | 4.34375 | 4 | '''
Your task is to calculate logical value of boolean array. Test arrays are one-dimensional and their size is in the range 1-50.
Links referring to logical operations: AND, OR and XOR.
You should begin at the first value, and repeatedly apply the logical operation across the remaining elements
in the array sequen... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.