blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
6f34824a78939e24f29dc71ad83496f2c7a9488f | karthikdwarakanath/PythonPrograms | /findMinSumArr.py | 625 | 4.1875 | 4 | # Minimum sum of two numbers formed from digits of an array
# Given an array of digits (values are from 0 to 9), find the minimum possible
# sum of two numbers formed from digits of the array. All digits of given array
# must be used to form the two numbers.
def findMinSum(inputList):
inList = sorted(inputList)
... | true |
194575590af98ef6cbdf73578daad8502e1c8705 | Daria-Lytvynenko/homework14 | /homework14.py | 2,444 | 4.125 | 4 | from functools import wraps
import re
from typing import Union
# task 1 Write a decorator that prints a function with arguments passed to it.
# NOTE! It should print the function, not the result of its execution!
def logger(func):
@wraps(func)
def wrap(*args):
print(f'{func.__name__} called ... | true |
680783c22a0b03f5fe6b97efc77a33731dce3894 | maxgud/Python_3 | /Exercise_38_arrays.py | 1,560 | 4.125 | 4 | #this is just a variable that is equal to a string
ten_things = "Apples Oranges Crows Telephone Light Sugar"
print("Wait there are not 10 things in that list. Let's fix that.")
#this turns the variable into an array
#it splits the array where ever there is a ' ' aka space
stuff = ten_things.split(' ')
#this is a secon... | true |
27937d9585a75e3da0480f28d811c919247390ae | siggioh/2019-T-111-PROG | /exams/retake/grades.py | 1,552 | 4.125 | 4 | def open_file(filename):
''' Returns a file stream if filename found, otherwise None '''
try:
file_stream = open(filename, "r")
return file_stream
except FileNotFoundError:
return None
def read_grades(file_object):
''' Reads grades from file stream and returns them as a list... | true |
f00e7ad1364e2e4fccf0028f943c28e49a86d3e2 | alshil/zoo | /square.py | 603 | 4.28125 | 4 | #Depends on the figure name an app calculates figure`s square
import math
figure_name = str(input("figure name "))
if figure_name == "triangle":
a = float(input ("1 side "))
b = float(input ("2 side "))
c = float(input ("3 sideа "))
if a + b > c or b + c > a or c + a > b:
p = (a + b + c) / 2
print(p * (p -a) ... | true |
4845f043a91b35d0599e68681f2030996161e541 | JaneNjeri/Think_Python | /ex_10_05.py | 569 | 4.15625 | 4 | #!/usr/bin/python
#AUTHOR: alexxa
#DATE: 28.12.2013
#SOURCE: Think Python: How to Think Like a Computer Scientist by Allen B. Downey
# http://www.greenteapress.com/thinkpython/html/index.html
#PURPOSE: Chapter 10. Lists
# Exercise 10.5
# Write a function called chop that takes a list, modifies it
# by removing the f... | true |
08a13096dd54f87860a2bfdfd89540d998ab6d71 | JaneNjeri/Think_Python | /ex_13_3.py | 2,660 | 4.125 | 4 | #!/usr/bin/python
#AUTHOR: alexxa
#DATE: 29.12.2013
#SOURCE: Think Python: How to Think Like a Computer Scientist by Allen B. Downey
# http://www.greenteapress.com/thinkpython/html/index.html
#PURPOSE: Chapter 13. Case study: data structure selection
#STATUS: check for refactoring
# Exercise 13.3
# Modify the progra... | true |
a48d58eebbac192fb4210041e733d640004d1cef | JaneNjeri/Think_Python | /ex_03_4.py | 1,522 | 4.5625 | 5 | #!/usr/bin/python
#AUTHOR: alexxa
#DATE: 24.12.2013
#SOURCE: Think Python: How to Think Like a Computer Scientist by Allen B. Downey
# http://www.greenteapress.com/thinkpython/html/index.html
#PURPOSE: Chapter 3. Functions
# Exercise 3.4
# A function object is a value you can assign to a variable or
# pass as an argu... | true |
5cc5ecde9e975a12d7e32f2c34185708d352cb52 | JaneNjeri/Think_Python | /ex_09_4_2.py | 799 | 4.34375 | 4 | #!/usr/bin/python
#AUTHOR: alexxa
#DATE: 27.12.2013
#SOURCE: Think Python: How to Think Like a Computer Scientist by Allen B. Downey
# http://www.greenteapress.com/thinkpython/html/index.html
#PURPOSE: Chapter 9. Case study: word play
# Exercise 9.4
# Can you make a sentence using only the letters acefhlo?
# Other th... | true |
8db91bd009e8a4fc9c9e5f0bddec486845f13364 | JaneNjeri/Think_Python | /ex_08_01.py | 580 | 4.71875 | 5 | #!/usr/bin/python
#AUTHOR: alexxa
#DATE: 25.12.2013
#SOURCE: Think Python: How to Think Like a Computer Scientist by Allen B. Downey
# http://www.greenteapress.com/thinkpython/html/index.html
#PURPOSE: Chapter 8. Strings
# Exercise 8.1
# Write a function that takes a string as an argument and
# displays the letters ... | true |
bd89a3468942ea72efeb8da8a24d479b905100dd | JaneNjeri/Think_Python | /ex_12_1.py | 389 | 4.375 | 4 | #!/usr/bin/python
#AUTHOR: alexxa
#DATE: 29.12.2013
#SOURCE: Think Python: How to Think Like a Computer Scientist by Allen B. Downey
# http://www.greenteapress.com/thinkpython/html/index.html
#PURPOSE: Chapter 12. Tuples
# Exercise 12.1
# Write a function called sumall that takes any number of
# arguments and return... | true |
27fba10b5b159591924eb0ab1e00a8ac92d8dbdf | JaneNjeri/Think_Python | /ex_06_8.py | 1,076 | 4.125 | 4 | #!/usr/bin/python
#AUTHOR: alexxa
#DATE: 25.12.2013
#SOURCE: Think Python: How to Think Like a Computer Scientist by Allen B. Downey
# http://www.greenteapress.com/thinkpython/html/index.html
#PURPOSE: Chapter 6. Fruitful functions
# Exercise 6.8
# The greatest common divisor (GCD) of a and b is the largest number
# ... | true |
151f141f0ed7e3dd88904c4ebc30af256887ee43 | JaneNjeri/Think_Python | /ex_06_2.py | 1,119 | 4.21875 | 4 | #!/usr/bin/python
#AUTHOR: alexxa
#DATE: 24.12.2013
#SOURCE: Think Python: How to Think Like a Computer Scientist by Allen B. Downey
# http://www.greenteapress.com/thinkpython/html/index.html
#PURPOSE: Chapter 6. Fruitful functions
# Exercise 6.2
# Use incremental development to write a function called
# hypotenuse ... | true |
915cb0ad8cddbe30e4af593993eb10b7a11a4292 | MichaelCzurda/Python-Data-Science-Beispiele | /Python_Basics/07_RegularExpression/0710_substitute_strings.py | 1,442 | 5.03125 | 5 | #! python3
#0710_substitute_strings.py - Substituting Strings with the sub() Method
#Regular expressions can not only find text patterns but can also substitute
#new text in place of those patterns. The sub() method for Regex objects is
#passed two arguments. The first argument is a string to replace any matches.
#The... | true |
55742544b628d6d08ee04f8f87a9fc0947c3578d | MichaelCzurda/Python-Data-Science-Beispiele | /Python_Basics/09_Organizing_Files/0905_folder_into_zip.py | 1,984 | 4.34375 | 4 | #!python3
#0905_folder_into_zip.py - Project: Backing Up a Folder into a ZIP File
#create ZIP file “snapshots” from an entire folder. You’d like to keep different versions, so you want the ZIP file’s filename to increment each
#time it is made; for example, {name}_1.zip, {name}_2.zip, {name}_3.zip, and so on.
#Write ... | true |
d16edae81fe36827801aa7681389c8fc42e73755 | Safal08/LearnPython | /Integers & Float.py | 852 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Apr 21 09:49:00 2020
@author: safal
"""
num=3
print(type(num)) #shows the integer
num1=3.14
print(type(num1)) #shows the float
#Arithmetic Operations
print(5+2) #Addition
print(5-2) #Subtraction
print(5/2) #Division
print(5//2) #Floor Division
print(5**2) #Exponent
print(... | true |
6fbf62b2549c9035c593df7e5bea53ee8a7ea98e | Granada2013/python-practice | /tasks/All_Balanced_Parentheses.py | 615 | 4.25 | 4 | """
Write a function which makes a list of strings representing all of the ways you can balance n pairs of parentheses
Examples:
balanced_parens(0) => [""]
balanced_parens(1) => ["()"]
balanced_parens(2) => ["()()","(())"]
balanced_parens(3) => ["()()()","(())()","()(())","(()())","((()))"]
"""
from functools import ... | true |
ae2da29ae4d1fc6346d1db65a497aa018e5d57ab | Elkip/PythonMorsels | /add.py | 1,578 | 4.25 | 4 | """
09/18/2019
a function that accepts two lists-of-lists of numbers and returns one list-of-lists with each of the corresponding
numbers in the two given lists-of-lists added together.
It should work something like this:
>>> matrix1 = [[1, -2], [-3, 4]]
>>> matrix2 = [[2, -1], [0, -1]]
>>> add(matrix1, matrix2)
[[3,... | true |
697a58f2e0289a9ea3aeef8bfd3fc2fad179c4c7 | Siddiqui-code/Python-Problems-Lab-6 | /factorial.py | 379 | 4.28125 | 4 | # Nousheen Siddiqui
# Edited on 02/19/2021
# Question 6:A for statement is used to calculate the factorial of a user input value.
# Print this value as well as the calculated value using the factorial function in the math module.
import math
factorial = int(input("Provide a number"))
x=1
for i in range(1, fa... | true |
4786d5aa3b0128ad503b2fdee1b1587fb7ec5642 | ChristopherCaysido/CPE169P-Requirements | /Mod1_PE01/recursive.py | 1,232 | 4.65625 | 5 |
'''
Write a recursive function that expects a pathname as an argument.
The path- name can be either the name of a file or the name of a directory.
If the pathname refers to a file, its name is displayed,
followed by its contents. Otherwise, if the pathname refers to a directory,
the function is applied to each nam... | true |
a114fbc6d189ae3ae0d0393eb6090ccfec1b6d95 | nicholsonjb/PythonforEverybodyExercises | /exercise4.6.py | 2,119 | 4.15625 | 4 | # Written by James Nicholson
# Last Updated March 27, 2019
#Use a costum function to do the following:
# Given (1) number of hours, and (2) rate of pay
# This program computes gross pay according to the formula: number of hours * rate of pay
#For hours worked beyond 40. pay = 1.5 * number of hours * rate of pay
#Use t... | true |
78060ff7bb9c0f4be4a3ba920430cbfe4b2cc845 | nicholsonjb/PythonforEverybodyExercises | /Data 620 Assignments/Assignment8.2-score-function.py | 1,688 | 4.21875 | 4 | #Data 620 Assignment 8.2 Python Score
#Severance Chapter 4 - Exercise 7 – ASSIGNMENT
#Written by James Nicholson
#Last Updated March 27, 2019
#Use a custome function to do the following:
# 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
... | true |
e75ca1fbf6c29ec375c0f80a1fa8514c5a7497c7 | GulzarJS/Computer_Science_for_Physics_and_Chemistry | /PW_2/circle.py | 2,338 | 4.125 | 4 | import math as mt
import random
import time as t
# Functions for finding area of circle with trapezoid method
# Function to find the angle between radius and the part until to chord
def angle_of_segment(r, a):
cos_angle = a / r
angle = mt.acos(cos_angle)
return angle
# Function to find ... | true |
218258b57bd2792615610fb9f04b18e37518678b | ChangXiaodong/Leetcode-solutions | /1/225-Implement-Stack-using-Queues.py | 1,778 | 4.1875 | 4 | '''
Implement the following operations of a stack using queues.
push(x) -- Push element x onto stack.
pop() -- Removes the element on top of the stack.
top() -- Get the top element.
empty() -- Return whether the stack is empty.
Notes:
You must use only standard operations of a queue -- which means only push to back, p... | true |
a7b5005ded6f1bc65d6fcc82aacacca7f6e41a36 | divyaparmar18/saral_python_programs | /maximum.py | 707 | 4.1875 | 4 | # here we are making a function which will take list of students marks and print their highest marks
def max_num(list_of_marks):# here we made a function of name max_num
index = 0# here we declared the index of the list as 0
while index < len(list_of_marks):# here we give the condition to run the loop till the... | true |
428636df3ef2962a5071c0d31a2dd1da4e3848aa | divyaparmar18/saral_python_programs | /Alien.py | 2,821 | 4.15625 | 4 | # here we will make a game in which we will fight with the alien
from random import randint # allows you to generate a random number
# variables for the alien
alive = True
stamina = 10
# this function runs each time you attack the alien
def report(stamin):
if stamin > 8:#here we give the condition
print... | true |
d30e41a2f8bf944b1969a547f5898b48c5d3c1ce | divyaparmar18/saral_python_programs | /nested.py | 598 | 4.21875 | 4 | age = (input("enter the age:"))# here we will se the nested condition which means condition inside a condition, so hewre we will take the age of user
if age > 5:# so if the age of user is more thn 5
print ("you can go to school")# this will be printed
if age > 18:# condition
print ("you can vote")#if condition... | true |
49df96e91a1b039335488c7ce1b2bdf4a8e2bd86 | divyaparmar18/saral_python_programs | /input.py | 1,034 | 4.4375 | 4 | #here we will take the input from the user and we will see how to work with strings ,integers and floats
name = raw_input("put your name: ")
surname = raw_input("put your surname: ")
whole_name = (name + surname)
print (whole_name)#this will add the string and print both the srting to gether bcoz raw input means that... | true |
955e48e827cd268c3f1f9ce579b238fc280cf7b4 | suraj-singh12/python-revision-track | /09-file-handling/questions/91_read_find.py | 459 | 4.1875 | 4 | try:
file = open("myfile.txt","r")
except IOError:
print("Error opening the file!!")
exit()
file = file.read()
file = file.lower() # converting all read content into lowercase, as we are ignoring the case in finding the word,
# i.e. for us twinkle and Twinkle are same
word = "t... | true |
014ccca1f5bf022a761b58747a3720981c2dc45f | publicmays/LeetCode | /implement_queue_using_stacks.py | 1,491 | 4.46875 | 4 |
class Queue(object):
def __init__(self):
self.stack1 = [] # push
self.stack2 = [] # pop
def push(self, x):
self.stack1.append(x)
def pop(self):
if not self.stack2:
self.move()
self.stack2.pop()
def peek(self):
if not self.stack2:
... | true |
af852014b50d6e1b423f6bc18ab2d6ab4da33e18 | Shri-85535/OOPS | /Class&Object.py | 695 | 4.125 | 4 | '''
"Class" is a design for an object. Without design we cannot create anything.
A class is a collection of Objects
The Object is an entity that has a state and behavior associated with it. More specifically, any single integer or any single string is an object
'''
class Computer:
#1 Attributes(Variables)
#2 ... | true |
1726c1c108097b18d5f0a8fd73a6aab037834eca | aeciovc/sda_python_ee4 | /SDAPythonBasics/tasks_/task_03.py | 525 | 4.375 | 4 | """
Write a program that based on the variable temperature in degrees Celsius - temp_in_Celsius (float),
will calculate the temperature in degrees Farhenheit (degrees Fahrenheit = 1.8 * degrees Celsius + 32.0)
and write it in the console.
Get the temperature from the user in the console using argument-less input().
""... | true |
cfe42df919522c35dc69de03d479b1fa81ba53a4 | AbhishekKumarMandal/SL-LAB | /SL_LAB/partA/q8.py | 1,112 | 4.34375 | 4 | from functools import reduce
l=[1,2,3,4,5,6]
m=[x*3 for x in l] #using list comprehension
print('list l: ',l)
print('list m: ',m)
#using reduce and lambda function
print('sum of list l: ',reduce(lambda a,b:a+b, l))
print('sum of list m: ',reduce(lambda a,b:a+b, m))
'''
A list comprehension generally consist of these ... | true |
7f2927ae1943864e1c0fcafd2a258e208b59f234 | talt001/Java-Python | /Python-Fundamentals/Loan Calculations/combs_loan_calculations_program.py | 1,840 | 4.3125 | 4 | #Step 1 write a python function that will calculate monthly payments on
# a loan.
#Step 2 pass the following to your function
#Principle of $20,000, with an APR of 4% to be paid in
# 1.) 36 months
# 2.) 48 months
# 3.) 60 months
# 4.) 72 months
#Step 3 include code for user supplied loan terms and comment out... | true |
0ee112181b34e75917e80e23dd3411f06d3a3282 | andy-buv/LPTHW | /mystuff/ex33.py | 769 | 4.1875 | 4 | from sys import argv
x = int(argv[1])
y = int(arg[2])
# Remember to cast an input as an integer as it is read in as a string
# I forgot this because I was not using the raw_input() method
def print_list_while(number, step):
i = 0
numbers = []
while i < number:
print "At the top i is %d" % i
numbers.append(i)
... | true |
b96ec4a68ba1b9b370fb9c690cbb3e8cf0f1335d | andy-buv/LPTHW | /mystuff/ex23.py | 893 | 4.25 | 4 | Reading from Python Source Code for General Assembly DAT-8 Course
github.com
launchpad.net
gitorious.org
sourceforge.net
bitbucket.org
# LISTS
nums = [5, 5.0, 'five'] # multiple data types
nums # print the list
type(nums) # check the type: list
len(nums) ... | true |
43d84ba163b1f8a4ecbfd84df0d54433b8e890f4 | Rita-Zey/python_project1 | /coffee_machine.py | 2,746 | 4.1875 | 4 | # Write your code here
import sys
ESPRESSO = [250, 0, 16, 4]
LATTE = [350, 75, 20, 7]
CAPPUCCINO = [200, 100, 12, 6]
class Coffee:
all_water = 400
all_milk = 540
all_beans = 120
all_cups = 9
all_money = 550
def coffee_machine_has():
print('The coffee machine has:')
print(Coffee.all_wate... | true |
6eba0e3cfaca03bc2754cc690c1cfa5468af787e | aprilxyc/coding-interview-practice | /ctci/ctci-urlify.py | 695 | 4.3125 | 4 | # problem 1.3 ctci
""" Write a method to replace all spaces in a string with %20. You may assume that the string
has sufficient space at the end to hold the additional characters, and that you are given
the 'true' length of the string.
E.g.
Input: 'Mr John Smith ", 13
Output: 'Mr%20John%20Smith'
"""
def urlify(str... | true |
ba3c1522f31525085aede553ba0a476e9a5ddb57 | aprilxyc/coding-interview-practice | /leetcode-problems/1252-cells-odd-values.py | 1,917 | 4.21875 | 4 | # nested list comprehension example
# answer = [[i*j for i in range(1, j+1)] for j in range(1, 8)]
indices = [[0,1],[1,1]]
matrix = [[0 for a in range(3)] for b in range(2)]
print(matrix)
def oddCells(self, n: int, m: int, indices: List[List[int]]) -> int:
# O(N^2) because it has to go through the list of indices... | true |
6cfaa8f0048bff952d17bfb591b90849423cf5f4 | aprilxyc/coding-interview-practice | /leetcode-problems/350-intersection-of-two-arrays-ii.py | 2,771 | 4.15625 | 4 | """
https://leetcode.com/problems/intersection-of-two-arrays-ii/
Good solution to look at:
https://leetcode.com/problems/intersection-of-two-arrays-ii/discuss/82247/Three-Python-Solutions
What if the given array is already sorted? How would you optimize your algorithm? Use pointers
What if nums1's size is small compa... | true |
880c9c52bc8fd1faa1ede09b498470129b007018 | aprilxyc/coding-interview-practice | /leetcode-problems/232-implement-queue-using-stacks.py | 1,773 | 4.15625 | 4 | """
https://leetcode.com/problems/implement-queue-using-stacks/
"""
# a very bad first implementation 27/01
# space is O(N)
# time complexity stays constant and is O(1) amortised
# we look at the overarching algorithm's worst case
class MyQueue:
def __init__(self):
"""
Initialize your data structu... | true |
194db0f16c84d40c6b193d54c0810579e7eba82b | emtee77/PBD_MJ | /muprog/cities.py | 634 | 4.25 | 4 | myfile = open('cities.txt', 'w') #This is used to open a file, w-writes to the file
myfile.write("Dublin\n")
myfile.write("Paris\n")
myfile.write("London\n")
myfile.close() #it is good to always close the file when you are done with it
myfile = open("cities.txt", "r") #This is used to open a file, r-reads the file
... | true |
19177be68bd64b821ed2ac20f347cfd85ca5548d | typemegan/Python | /CorePythonProgramming_2nd/ch09_files/commentFilter.py | 398 | 4.25 | 4 | #!/usr/bin/python
'''
Exercise 9-1:
display all the lines of file, filtering the line beginning with "#"
Problem:
extra credit: strip out comments begin after the first character
'''
name = raw_input('enter a filename> ')
f = open(name,'r')
i = 1 # counting file lines
for eachLine in f:
if eachLine.[0] != '#':... | true |
5e05c5a64587e06dcb7422350c90fb683fe5ef5c | typemegan/Python | /CorePythonProgramming_2nd/ch08_loops/getFactors.py | 447 | 4.15625 | 4 | #!/usr/bin/python
'''
Exercise 8-5:
get all the factors of a given integer
'''
def getFactors(num):
facts = [num]
# while
# count = num/2
# while count >= 1:
# if num % count == 0:
# facts.append(count)
# count -= 1
# for
for count in range(num/2, 0, -1):
if num % count == 0:
facts.append(count)
retu... | true |
07782b22ea28d71b07d515bca3affed7684d3193 | PxlPrfctJay/currentYear | /leapYear.py | 2,189 | 4.4375 | 4 | # A Program that has three functions to return a day of year
#Function One:
# A function that checks if a given year is a leap year
#Function Two:
# A function that returns number of days in month
# (28,29,30,31) depending on the given month(1-12) and year
# which uses isYearLeap(year) to determine a leap year
#Func... | true |
dc7570703a8820221bdbb033220db2a9d6427063 | Adioosin/DA_Algo_Problems | /Sum of pairwise Hamming Distance.py | 1,273 | 4.25 | 4 | # -*- coding: utf-8 -*-
"""
Hamming distance between two non-negative integers is defined as the number of positions at which the corresponding bits are different.
For example,
HammingDistance(2, 7) = 2, as only the first and the third bit differs in the binary representation of 2 (010) and 7 (111).
Given an array o... | true |
b1e8af4694fc7f951b4a0cc8bbb6acda2549f3be | bn06a2b/Python-CodeAcademy | /pizza_lens_slice.py | 838 | 4.625 | 5 | #addding toppings list
toppings=['pepperoni','pineapple','cheese','sausage','olives','anchovies','mushrooms']
#adding corresponding price list
prices=[2,6,1,3,2,7,2]
#number of pizzas and printing string to show no. of pizzas
num_pizzas=len(toppings)
print("We sell " +str(num_pizzas) + " different kinds of pizza!... | true |
23b372d9bc54c9d5989bc21c8af1fe1312dd1995 | Dannyh0198/Module-3-Labs | /Module 3 Labs/Working Area.py | 422 | 4.15625 | 4 | my_list = [1, 2, 4, 4, 1, 4, 2, 6, 2, 9]
list_without_duplicates = []
for number in my_list: # Browse all numbers from the source list.
if number not in list_without_duplicates: # If the number doesn't appear within the new list...
list_without_duplicates.append(number) # ...append it here.
my_list = list_without... | true |
170afd5d9894788e49bd328bce7bca8987b49458 | parveenkhatoon/python | /ifelse_question/age_comp.py | 338 | 4.25 | 4 |
age = int(input("Enter the age:"))
if age <= 2:
print("person is baby")
if age > 2 and age < 4:
print("person is a toddler")
if age >= 4 and age < 13:
print("person is the kid")
if age >= 13 and age < 20:
print("person is a teenager")
if age >= 20 and age < 65:
print("person is an adult")
if age >= 65:
print("pe... | true |
84e282e8ec93ff960e6ddf42b3605023ce875b38 | parveenkhatoon/python | /mix_logical/reverse.py | 522 | 4.1875 | 4 |
'''reverse with while loop'''
number=int(input("number:"))
reverse=0
while (number>0):
reminder=number%10
reverse=(reverse*10)+reminder
number=number//10
print("reverse number",reverse)
'''reverse is using if condition'''
num=int(input("number:"))
rev=0
if num>1:
ram=num%10
rev=(rev*10)+ram
num=num//10
i... | true |
bfd8c45b831a6d3e40b30b7645b20a8ad51051ab | englisha4956/CTI110 | /P1HW2_BasicMath_EnglishAnthony.py | 575 | 4.21875 | 4 | # Netflix MONTHLY & ANNUAL FEE GENERATOR +TAX
# 9/26/2021
# CTI-110 P1HW2 - Basic Math
# Anthony English
#
charge = 17.99
tax = charge * .06
monthly = charge + tax
annual = monthly * 12
name = ('Netflix')
print('Enter name of Expense:', end=' ')
name = input()
print('Enter monthly charge:', end=' ')
mo... | true |
d6d98709ce72d98aedc1f3eb3e287d6239d36564 | abhirathmahipal/Practice | /Python/Core Python Programming/Chapter - 2/BasicForLoops.py | 497 | 4.53125 | 5 | # Iterating over a for loop. It doesn't behave like a traditional
# counter but rather iterates over a sequence
for item in ['email', 'surfing', 'homework', 'chat']:
print item,
# Modifying for loops to behave like a counter
print "\n"
for x in xrange(10):
print x,
# Iterating over each character in a s... | true |
311b031bcd268c43ddce442463c06b62c7e550f2 | tedmcn/Programs | /CS2A/PA1/prime.py | 713 | 4.3125 | 4 | def prime(num):
"""
Tester - Takes an input number from the user and tests whether it is prime
or not. Then, it returbns True or False depending on the number and prompts
the user if it is prime or not. Returns True or False if prime or not.
Example answers:
prime(10)
prime(227)
... | true |
74c22afb2fcbc02a2ca574e6e780f62a1c6bcfce | htbo23/ITP-Final-Project | /Waiter.py | 2,793 | 4.125 | 4 | # Tiffany Bo
# ITP 115, Fall 2019
# Final Project
from Menu import Menu
from Diner import Diner
class Waiter():
def __init__(self, menu):
# sets it to an empty list
self.diners = []
self.menu = menu
# adds a diner to the list
def addDiner(self, diner):
self.diners.append(diner)
#finds how many diners there... | true |
6db19a61d62c41144e6dcdbd510e8a6c63f4c8d8 | vikasvisking/courses | /python practic/list_less_then_10.py | 850 | 4.375 | 4 | """Take a list, say for example this one:
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
and write a program that prints out all the elements of the list that are less than 5."""
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
for element in a:
if element < 5 :
print(element)
# Instead of printing the elements one by ... | true |
f36e514a1fad77868fb66799b4ea313d0708ebb1 | GuuMee/ExercisesTasksPython | /1 Basics/25_units_of_time2.py | 1,215 | 4.40625 | 4 | """
In this exercise you will reverse the process described in the previous exercise.
Develop a program that begins by reading a number of seconds from the user.
Then your program should display the equivalent amount of time in the form
D:HH:MM:SS, where D, HH, MM, and SS represent days, hours, minutes and sec�onds res... | true |
54e634be4757a88da539d5db29f0ac33efb69a82 | GuuMee/ExercisesTasksPython | /5 Lists/_116_latin_improved.py | 2,508 | 4.4375 | 4 | """
Extend your solution to Exercise 115 so that it correctly handles uppercase letters and
punctuation marks such as commas, periods, question marks and exclamation marks.
If an English word begins with an uppercase letter then its Pig Latin representation
should also begin with an uppercase letter and the uppercase l... | true |
566912a27657e29b961c7a24fcc3fa76c65d2d94 | GuuMee/ExercisesTasksPython | /4_Functions/94_random_password.py | 1,216 | 4.59375 | 5 | """
Write a function that generates a random password. The password should have a
random length of between 7 and 10 characters. Each character should be randomly
selected from positions 33 to 126 in the ASCII table. Your function will not take
any parameters. It will return the randomly generated password as its only r... | true |
279b21d9e3839e9755e24e8fdf682135caab2d6a | GuuMee/ExercisesTasksPython | /1 Basics/23_area_polygon.py | 804 | 4.5 | 4 | """
A polygon is regular if its sides are all the same length and the angles between all of
the adjacent sides are equal. The area of a regular polygon can be computed using
the following formula, where s is the length of a side and n is the number of sides:
area = (n*s^2)/4*tan(pi/n)
Write a program th... | true |
4a762a39608178aca8325026ef78449181d91656 | GuuMee/ExercisesTasksPython | /1 Basics/31_sum_of_digits.py | 594 | 4.125 | 4 | """
Develop a program that reads a four-digit integer from the user and displays the sum
of the digits in the number. For example, if the user enters 3141 then your program
should display 3+1+4+1=9.
"""
# Read the input of the digits from the user
digits = input("Enter the 4-digit integer number: ")
# Convert to int ... | true |
0845a8058a1f22565907dadcfa4460b724e0f40a | GuuMee/ExercisesTasksPython | /1 Basics/30_units_of_pressure.py | 936 | 4.59375 | 5 | """
In this exercise you will create a program that reads a pressure from the user in kilopascals.
Once the pressure has been read your program should report the equivalent
pressure in pounds per square inch, millimeters of mercury and atmospheres. Use
your research skills to determine the conversion factors between th... | true |
77e332d53b52a2e36485d1a36b3ffd2716122197 | GuuMee/ExercisesTasksPython | /5 Lists/_121_count_the_elements.py | 2,349 | 4.40625 | 4 | """
Python’s standard library includes a method named count that determines how
many times a specific value occurs in a list. In this exercise, you will create a new
function named countRange which determines and returns the number of elements
within a list that are greater than or equal to some minimum value and less ... | true |
9ce4b5a2c382c97c04d06d3b3fb2960644a1c546 | GuuMee/ExercisesTasksPython | /3 Loops/66_compute_a_grade_point_average.py | 1,778 | 4.5 | 4 | """
Exercise 51 included a table that shows the conversion from letter grades to grade
points at a particular academic institution. In this exercise you will compute the
grade point average of an arbitrary number of letter grades entered by the user. The
user will enter a blank line to indicate that all of the grades h... | true |
429e370886bb8a02b6f5bbf15d611128342b985e | GuuMee/ExercisesTasksPython | /6 Dictionaries/_132_postal_codes.py | 2,287 | 4.28125 | 4 | """
In a Canadian postal code, the first, third and fifth characters are letters while the
second, fourth and sixth characters are numbers. The province can be determined
from the first character of a postal code, as shown in the following table. No valid
postal codes currently begin with D, F, I, O, Q, U, W, or Z.
The... | true |
3537afca8701c17f277c832255b7b12efcd5118a | GuuMee/ExercisesTasksPython | /4_Functions/85_convert_an_integer_to_its_original_number.py | 1,389 | 4.75 | 5 | """
Words like first, second and third are referred to as ordinal numbers. In this exercise,
you will write a function that takes an numeger as its only parameter and returns a
string containing the appropriate English ordinal number as its only result. Your
function must handle the numegers between 1 and 12 (inclusive... | true |
9ef0f06750869ea25e47f00598e56a66a92a4453 | GuuMee/ExercisesTasksPython | /5 Lists/_125_does_a_list_contain_a_sublist.py | 2,044 | 4.375 | 4 | """
A sublist is a list that makes up part of a larger list. A sublist may be a list
containing a single element, multiple elements, or even no elements at all. For example,
[1], [2], [3] and [4] are all sublists of [1, 2, 3, 4]. The list [2, 3] is also a
sublist of [1, 2, 3, 4], but [2, 4] is not a sublist [1, 2, 3, 4... | true |
b2a8a028bc2abebeeb01f1f5bc3466b3b70caa61 | GuuMee/ExercisesTasksPython | /6 Dictionaries/_134_unique_characters.py | 711 | 4.53125 | 5 | """
Create a program that determines and displays the number of unique characters in a
string entered by the user. For example, Hello, World! has 10 unique characters
whilezzzhas only one unique character. Use a dictionary or set to solve this problem.
"""
# Compute the number of unique characters in a string using a ... | true |
564cb2f78a42a8646b5356760aef5a2fc4c7504f | GuuMee/ExercisesTasksPython | /5 Lists/_107_avoiding_duplicates.py | 884 | 4.34375 | 4 | """
In this exercise, you will create a program that reads words from the user until the
user enters a blank line. After the user enters a blank line your program should dis�play each word entered by the user exactly once. The words should be displayed in
the same order that they were entered. For example, if the user ... | true |
e9abf62577c80a6c9bea72fcd4addb2785097246 | GuuMee/ExercisesTasksPython | /2 If Statements/39_sound_levels.py | 1,676 | 4.75 | 5 | """
Write a program that reads a sound level in decibels from the user. If the user
enters a decibel level that matches one of the noises in the table then your program
should display a message containing only that noise. If the user enters a number
of decibels between the noises listed then your program should display... | true |
7b5755046b371d33bac343efb1cd0cb3e62ede8e | Tsarcastic/2018_code_wars | /6kyu_exclamation_marks.py | 623 | 4.21875 | 4 | """
Find the balance.
https://www.codewars.com/kata/57fb44a12b53146fe1000136/train/python
"""
def balance(left, right):
"""Find the balance of left and right."""
def weigh(side):
"""Find the weight of each side."""
weight = 0
for i in side:
if i == "!":
w... | true |
389ef03dd353855ebd9f08f9e94b5a17ec249cbf | SuhaybDev/Python-Algorithms | /5_implement_bubble_sort.py | 487 | 4.375 | 4 | def bubbleSort(arr):
n = len(arr)
# Iterate through all array elements
for x in range(n):
for y in range(0, n-x-1):
# Interchange places if the element found is greater than the one next to it
if arr[y] > arr[y+1] :
arr[y], arr[y+1] = arr[y+1], arr[y]
ar... | true |
624045aebcbcfae035f0d6c7dcdbfc8fc4bb1410 | Abdurrahmans/Data-Structure-And-Algorithm | /SeriesCalculation.py | 386 | 4.15625 | 4 | import math
number=int(input("Enter any positive number:"))
sum = 0
sum = number*(number + 1)/2
print("The sum of series upto {0} = {1}".format(number,sum))
total = 0
total =(number*(number+1)*(2*number+1))/6
print("The sum of series upto {0} = {1}".format(number,total))
total =math.pow(number*(number+1)/2,... | true |
b9bdc8a9d9bc5a4bb7a0e416c0034dd6cabf82bf | Abdurrahmans/Data-Structure-And-Algorithm | /SortingAlgorithm/BubbleSortDescendingOrder.py | 551 | 4.1875 | 4 | inputArray = []
ElementCount = int(input("Enter number of element in array:"))
print("Enter {} number".format(ElementCount))
for x in range(ElementCount):
value = int(input("Please inter the {} element of list:".format(x)))
inputArray.append(value)
for i in range(ElementCount-1):
for j in range(El... | true |
4af43c0a242bc188ae56cad5d6035d6cc3cc40af | candytale55/lambda-challenges-Py_3 | /rate_movie.py | 351 | 4.21875 | 4 | # rate_movie takes a number named rating. If rating is greater than 8.5, return "I liked this movie". Otherwise return "This movie was not very good"
rate_movie = lambda rating : "I liked this movie" if rating > 8.5 else "This movie was not very good"
print rate_movie(9.2)
# I liked this movie
print rate_movie(7.2)
... | true |
d977a962c7e16af4c634881646cbb0f3e0b4aad7 | abdulahad0001/Prime_number_cheker | /primalitiy.py | 429 | 4.125 | 4 | num1 = int(input("Enter your number:"))
if num1 > 1:
for integer in range(2,num1):
if(num1%integer)==0:
print(num1, "is not a prime number")
break
else:
print("Congrats!", num1,"is a prime number")
print("\n When you're checking for 0 and 1, Note that 0 and 1 are not pri... | true |
b1751095b11d6bfb0adcc764e58a0d13ace5a52e | gyuri23/tkinter_examples | /tkinter_grid.py | 1,142 | 4.1875 | 4 | import tkinter
root = tkinter.Tk()
for r in range(3):
for c in range(5):
tkinter.Label(root, text='R%s/C%s' % (r, c),
borderwidth=1).grid(row=r, column=c)
# column : The column to put widget in; default 0 (leftmost column).
#
# columnspan: How many columns wid... | true |
926bdeb78d59c57aeee972a8e72a816c227833bf | satish3922/ML_python | /sum_magic.py | 1,086 | 4.21875 | 4 | #!/usr/bin/env python3
# Program of magic Addition
#Taking input of 1st Number
num1 = int(input("Enter 1st Number :"))
#Calculating Magic Sum (result = add 2 before num-2)
result1 = '2' + str(num1 - 2)
print("User : ",num1)
print("User : *****")
print("Comp : *****")
print("User : *****")
print("Comp : *****")
pri... | true |
17d6cd0b17d82a791c56fd945ec30167335593e6 | juliano60/scripts_exo | /ch2/exo3.py | 259 | 4.15625 | 4 | #!/usr/bin/env python3
## enter a list of strings
## output them in sorted order
print("Enter a list of words on separate lines: ")
words = []
while True:
try:
words.append(input())
except:
break
print()
print(list(sorted(words)))
| true |
4cd35312a195fa64910ac773618152a52f340377 | uccgit/geekthology | /menu_a.py | 1,850 | 4.125 | 4 | import os
# This is the menu system for the game
# The plan is to create custom menus where needed
def display_title_bar():
#clears the terminal screen, and displays a title bar
os.system('cls' if os.name == 'nt' else 'clear')
print "\t*******************************************"
print "\t*** Welcome... | true |
85a1aa8da913d587c0161b010dcecb222f10cb99 | stillaman/python-problems | /Python Program to Check Prime Number.py | 211 | 4.15625 | 4 | num = int(input("Enter number:: "))
for i in range (2,num):
if num%i == 0:
print("The Given number is not Prime Number!!")
break
else:
print("The Given Number is a Prime Number!!")
| true |
193caba1bc562722fefadd6e795713a66e041ba1 | jmanning1/python_course | /IfProgramFlow/adv_ifprogramflow.py | 797 | 4.21875 | 4 | age = int(input("How old are you? "))
#if (age >=16) and (age <= 65): #looks for the Range between 16 and 65
# if 15 < age < 66:
# print("Have a good day at work")
#Brackets (Parentatesis) make things easier to read and also make you intentions in the code clearer.
if (age < 16) or (age > 65): #Or look... | true |
d7644b4c86ed96dc404b3dd96728d325b6c1bb24 | hoomanali/Python | /ClassProblems/RectArea.py | 766 | 4.40625 | 4 | #
# Ali Hooman
# alhooman@ucsc.edu
# Class Problem 2 - Area of Rectangle
#
# Ask user for inputs for height and width.
# Calculate area of rectangle and print the result
# Calculate circumference
#
# Get height
heightStr = input("Enter height: ")
heightInt = int(heightStr)
# Get width
widthStr = input... | true |
36634355781134ba0a2ff1ce4e7c18500e82e8f8 | seanjohnthom/Automatetheboringstuff | /guessing_game.py | 710 | 4.125 | 4 | #this is a guess the number game
import random
print("Hello, what is your name?")
name = input()
print("Hi " + name + "!", "I'm thinking of a number between 1 and 20.")
secret_number = random.randint(1,20)
#This will allow X number of guesses
for guesses_taken in range (1,7):
print("Take a guess")
guess = int(... | true |
148d3eb2808fc8484bf4163fbebef45e5fde9bd7 | akshar-bezgoan/python-home-learn | /Lessons/Apr17/conversation.py | 248 | 4.125 | 4 | print('NOTICE ENTER ONLY IN LOWER-CASE!')
name = raw_input('Hi, what is your name:')
print str('Hello ') + name
mood = raw_input('How are you?:')
print str('I am also ') + mood
q = raw_input('So anything happening today?:')
print ('Me as well')
| true |
e8f510d5b623a730f36e3845d10b97dc00b494f1 | mahesh671/Letsupgrade | /Prime number.py | 307 | 4.15625 | 4 | #this is mahesh kumar
#prime number assignment using functions
def PrimeorNot(n):
for i in range(2,n):
if n%i==0:
return False
else:
pass
return True
number = int(input("Enter the number: "))
if PrimeorNot(number):
print(number,":Number is prime")
else:
print(number,": is not Prime")
| true |
1d470ce86c70853849831afeead8efdb9c54f4ff | Nidhi331/Data-Structures-Lab | /BipartiteGraph.py | 1,867 | 4.21875 | 4 |
#Bipartite graph
# A graph can be divided to two sets such that there is not any two vertices
# in a single set which contain an edge
# S(x) != S(y)
# Can a tree be Bipartite tree?
"""
1
2 3
4 5 6 7
"""
# in the above eg. set1=[1,4,5,6,7] and set2=[2,3] is the solution ... | true |
6f32f9d3a99a0ca2a9d125ec422223c6a080c955 | omarsalem14/python-with-Elzero | /variables_part1.py | 1,020 | 4.78125 | 5 | # ------------------------------------------------------
# --variables --
# ----------------
# syntax => [Variable Name] [Assigment Operator] [Value]
#
# Name Convention and Rules
# [1]Cant start with (a-z A-Z) or Underscore
# [2]I Can't begin with number or Special Charecters {2myVariable},{-myVariable}
# [3]Can incl... | true |
ed2d9440951ec26852941721bf5819a670cd7a83 | ishaniMadhuwanthi/Python-Codes | /set3/Code5.py | 312 | 4.28125 | 4 | # Given a two list of equal size create a set such that it shows the element from both lists in the pair
listOne=[2,3,4,5,6,7,8]
listTwo=[4,9,16,25,36,79,68]
print('First List:',listOne)
print('Second List:',listTwo)
result=zip(listOne,listTwo)
resultList=set(result)
print('Result pairs:',resultList)
| true |
a2f6f11239ce6db80e09511c918faaf7968023fd | ishaniMadhuwanthi/Python-Codes | /set3/Code9.py | 407 | 4.375 | 4 | #Given a dictionary get all values from the dictionary and add it in a list but don’t add duplicates
myList={'jan':47, 'feb':52, 'march':47, 'April':44, 'May':52, 'June':53,
'july':54, 'Aug':44, 'Sept':54}
print('values of the dictionary:',myList.values())
newList=list()
for item in myList.values()... | true |
35ca5475df3b6351d2440e161362534e1150f2b6 | ishaniMadhuwanthi/Python-Codes | /set1/Code9.py | 490 | 4.21875 | 4 | #Given a two list of ints create a third list such that should contain only odd numbers from the first list and even numbers from the second list
def mergeList(listOne, listTwo):
thirdList = []
for i in listOne:
if(i % 2 != 0):
thirdList.append(i)
for i in listTwo:
if(i % 2 == 0):
th... | true |
63aa4993095bde9c5168b6d70b24c724c346e701 | johanesn/CTCI-Practice | /CTCI 5_1.py | 1,360 | 4.3125 | 4 | '''
Insertion : You are given two 32-bit numbers, N and M and two bit positions, i and j. Write a method to insert M into N such that M starts at bit j and ends at bit i. You can assume that bits j through i have enough space to fit all of M. That is if M = 10011, you can assume that there are at least 5 bits between ... | true |
15bec55949ce491cb086f8b0809da553e49de0b4 | johanesn/CTCI-Practice | /CTCI 10_5.py | 1,038 | 4.34375 | 4 | # Sparse Search: Given a sorted array of strings that is interspersed with empty strings, write a method to find the location of a given string.
def sparseSearch (arr, key, low, high):
while low <= high:
mid = int(low + (high-low)/2)
if arr[mid] == '':
left = mid-1
right = mid+1
while True:
print (... | true |
5afda28d2dd3996f26739ea8d527d1414daa725a | johanesn/CTCI-Practice | /TreeTraversal.py | 1,912 | 4.21875 | 4 | # Tree Traversal (Inorder, Preorder and Postorder)
'''
1
/ \
2 3
/ \
4 5
(a) Inorder (Left, Root, Right) : 4 2 5 1 3
> In case of BST, inorder traversal gives nodes in non-decreasing order
(b) Preorder (Root, Left, Right) : 1 2 4 5 3
> Used to... | true |
b4bd32a3e5a5fa2c5f93f4dc1aa6ed162889ece3 | Pratham-vaish/Harshit-Vashisth-Python-Begginer-Course-Notes | /chapter_1/center_method.py | 335 | 4.21875 | 4 | #center method is used to put any symbol in starting ad ending of a string
print("This program can center your name with any character")
print("Things you have to input :- YOUR NAME,CHARACTER,FREQUENCY")
name, x, y = input('enter your name, the character and how many times : ').split(",")
print(name.center(len(nam... | true |
31413461c1047082a86d1a9b645b83d1ff5453da | Pratham-vaish/Harshit-Vashisth-Python-Begginer-Course-Notes | /chapter_1/string_methods.py | 414 | 4.1875 | 4 | name = "pRaTHaM VaiSH"
#len() func conts number of characters including spaces
Length = len(name)
print(Length)
#.lower() method changes all characters to lower case
small_letters = name.lower()
print(small_letters)
#.upper() method changes all characters to upper case
big_letters = name.upper()
print(bi... | true |
c4b3abc532c6ac9f0d0daeb63c00b5739267879d | Pratham-vaish/Harshit-Vashisth-Python-Begginer-Course-Notes | /chapter_1/input_int.py | 428 | 4.125 | 4 | #we use input function for user in put
#for example
name = input('Enter your name ')
print('Hello ' + name)
#A input_func alwasy take input as string
# for example
age = input("whta is your age ")
print("your age is " + age)
#To take input as a integer we use int_func
number_1=int(input("enter your first numbe... | true |
f6192a855d61998b6f23cd419da2596421644cb7 | unnatural-X/Study_Introduction | /LiaoPage/example4_if.py | 452 | 4.21875 | 4 | # -*- coding: utf-8 -*-
# input your height and weight
s1 = input('please input your height(m):')
height = float(s1)
s2 = input('please input your weight(kg):')
weight = float(s2)
# calculate BMI
BMI = weight/(height*height)
# output the results
print('Your BMI is: %.1f' % BMI)
if BMI < 18.5:
print('过轻')
elif BMI ... | true |
e264ce0306efed9aa8e98b92bbd9f22812617092 | unnatural-X/Study_Introduction | /LiaoPage/example8_functiondef.py | 1,019 | 4.21875 | 4 | # -*- coding: utf-8 -*-
# the solution of quadratic equation
import math # import the math package
def quadratic(a, b, c): # define the function
if a==0:
print('The coefficient of the quadratic term cannot be zero')
elif b*b-4*a*c < 0:
print('The equation doesn\'t have solutions')
elif ... | true |
80740202b28e6126c20c12ceb65cde14c60b3278 | pushpa-ramachandran/DataStructures | /ListAccessingRemovePop.py | 2,773 | 4.53125 | 5 | ############ Accessing the list
print('\n # # # Accessing the list')
list = ['LIST4','LIST5','LIST6']
print(list)
print(list[2])
####### Accessing the multi dimensional list
print('\n # # # Accessing the multi dimensional list')
list = [['LIST4','LIST5','LIST6'],['LIST7','LIST8']]
print(list)
print... | true |
cebabf4a4d549717fe1c652d6325f0ef84627078 | renuka123new/Training | /Python-Code/occuranceOfDigit.py | 420 | 4.125 | 4 | #Find total occurrences of each digits (0-9) using function.
def countOcc(n):
l = []
while (n >= 1):
reminder = int(n % 10)
n = n / 10
l.append(reminder)
for i in range(0, 10):
count = 0
for j in l:
if (i == j):
count = count + 1... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.