blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
208a814d1ffce74cd1bd7eaedb39395b76ddba70 | huangichen97/SC101-projects | /SC101 - Github/Class&Object (Campy, Mouse Event)/draw_line.py | 1,837 | 4.125 | 4 | """
File: draw_line
Name:Ethan Huang
-------------------------
TODO:
This program opens a canvas and draws circles and lines in the following steps:
First, it detect if the click is a "first click" or a "second click".
If first click, the program will draw a hollow circle by SIZE.
If second click, the it wi... | true |
45b1b9758b34f9ce252ff72bb3334c2e3f60e3aa | huangichen97/SC101-projects | /SC101 - Github/Weather_Master/weather_master.py | 2,050 | 4.25 | 4 | """
File: weather_master.py
-----------------------
This program will implement a console program
that asks weather data from user to compute the
average, highest, lowest, cold days among the inputs.
"""
EXIT = -1
def main():
"""
This program asks weather data from user to compute the
average, highest, l... | true |
9b5bf68a2f25bfdb2a276fbaa481d28859a9acdf | dhyani21/Hackerrank-30-days-of-code | /Day 25: Running Time and Complexity.py | 576 | 4.1875 | 4 | '''
Task
A prime is a natural number greater than 1 that has no positive divisors other than 1 and itself. Given a number, n, determine and print whether it is Prime or Not prime.
'''
for _ in range(int(input())):
num = int(input())
if(num == 1):
print("Not prime")
else:
if(num % 2 == 0 and... | true |
fe6db5c4e41116d07e7d1c2990fe6ec5fd59d29f | Cathryne/Python | /ex12.py | 581 | 4.34375 | 4 | # Exercise 12: Prompting People
# http://learnpythonthehardway.org/book/ex12.html
# request input from user
# shorter alternative to ex11 with extra print ""
height = float(raw_input("How tall are you (in m)? "))
weight = int(raw_input("How many kilograms do you weigh? "))
print "So, you're %r m tall and %d kg heavy.... | true |
e8b2fd46e39711a75e83f590a86ffa5433116a1e | Cathryne/Python | /ex38sd6c.py | 2,251 | 4.6875 | 5 | # Exercise 38: Doing Things To Lists
# http://learnpythonthehardway.org/book/ex38.html
# Study Drill 6: other examples of lists and what do do with them
# comparing word lists
# quote examples for testing
# Hamlet = "To be, or not to be, that is the question."
# https://en.wikipedia.org/wiki/To_be,_or_not_to_be#Text
#... | true |
88e7900015a7c199e6e605beb15189e211af78d0 | Cathryne/Python | /ex03.py | 1,550 | 4.21875 | 4 | # Exercise 3: Numbers and Math
# http://learnpythonthehardway.org/book/ex3.html
# general advice: leave space around all numbers & operators in mathematical operations, to distinguish from other code & esp. negative numbers
print "I will now count my chickens:"
print "Hens", 25 + 30 / 6
# , comma forces calculation r... | true |
71d9d2c25a82558c813523cd9c7a935ffcbf5d78 | Cathryne/Python | /ex19sd3.py | 1,477 | 4.21875 | 4 | # Exercise 19: Functions and Variables
# http://learnpythonthehardway.org/book/ex19.html
# Study Drill 3: Write at least one more function of your own design, and run it 10 different ways.
def milkshake(milk_to_blend, fruit_to_blend, suggar_to_blend):
"""
Calculates serving size and prints out ingredient amounts
fo... | true |
42f65b2819021a0201c2ce3ee82ba39318beb466 | RahulSundar/DL-From-Scratch | /MLP.py | 1,821 | 4.1875 | 4 | import numpy as np
#import matplotlib.pyplot as plt
'''This is a code to implement a MLP using just numpy to model XOR logic gate.Through this code, one can hope to completely unbox how a MLP model is setup.'''
# Model Parameters
'''This should consist of the no. of input, output, hidden layer units. Also, no.of inp... | true |
c2b21f2737be09db89a51add64f1d86907b28c00 | arsenijevicn/Python_HeadFirst | /chapter4/vsearch.py | 243 | 4.15625 | 4 | def search4vowels():
"""Displays any vowels found in asked-for word"""
vowels = set('aeiou')
word = input("Upisite rec: ")
found = vowels.intersection(set(word))
for vowels in found:
print(vowels)
search4vowels()
| true |
4dcb541a4c110aee3f795e990b3f096f5d00014d | AyushGupta22/RandomNumGenerator | /test.py | 749 | 4.25 | 4 | from rand import random
#Testing our random function by giving min , max limit and getting output as list and then compute percentage of higher number for reference
print('Enter min limit')
min = int(input())
print('Enter max limit')
max = int(input())
while max <= min:
print('Wrong max limit\nEnter Again:... | true |
5a0f54795e5b2777ebe9b2e9fdbdb07ee7db5e33 | adilarrazolo83/lesson_two_handson | /main.py | 714 | 4.28125 | 4 | # Part 1. Create a program that will concatenate string variables together to form your birthday.
day = "12"
month = "October"
year = "1983"
my_birthday = month + " " + day + "," + year
print(my_birthday)
# Part 2. Concatenate the variables first, second, third, and fourth and set this concatenation to the variabl... | true |
96dd3709ac413db258d3ab38be0bd957b51c117a | ktgnair/Python | /day_2.py | 602 | 4.3125 | 4 | #Datatypes
#String
#Anything inside a "" is considered as string
print("Hello"[1]) #Here we can find at position 1 which character is present in word Hello
print("1234" + "5678") #Doing this "1234" + "5678" will print just the concatenation of the two strings
print("Hello World")
#Integer
print(1234 + 5678) #For ... | true |
b3b3a3063b53e18e792d25c07f74d7a4d8441905 | ktgnair/Python | /day_10.py | 1,362 | 4.34375 | 4 | # Functions with Outputs.
# In a normal function if we do the below then we will get an error as result is not defined
# def new_function():
# result = 3*2
# new_function()
# print(result)
# But using 'return' keyword in the below code we are able to store the output of a function i.e Functions with Outputs
def m... | true |
addc5679ff65e1454f5168d63ba1a72d098fbbe8 | ktgnair/Python | /day_8-2.py | 1,059 | 4.28125 | 4 | # Prime Number Checker
# You need to write a function that checks whether if the number passed into it is a prime number or not.
# e.g. 2 is a prime number because it's only divisible by 1 and 2.
# But 4 is not a prime number because you can divide it by 1, 2 or 4
user_input = int(input("Enter the number of your choic... | true |
70ef560b7cc262f805a8b18c0fa269444276b665 | ktgnair/Python | /day_5-5.py | 1,685 | 4.1875 | 4 | # Password Generator Project
import random
letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
number... | true |
9d2c5436378129d0f27f90a77aea9dd6249bab94 | ktgnair/Python | /day_4-4.py | 1,247 | 4.71875 | 5 | # Treasure Map
# Write a program which will mark a spot with an X.
# You need to add a variable called map.This map contains a nested list.
# When map is printed this is what the nested list looks like:
# ['⬜️', '⬜️', '⬜️'],['⬜️', '⬜️', '⬜️'],['⬜️', '⬜️', '⬜️']
# Format the three rows into a square, like this:
# ['⬜️'... | true |
27e08761ba250ff3ddf19c454df05fdf0acade2d | Alexanderdude/PythonInvestments | /finance_calculators.py | 2,651 | 4.28125 | 4 | import math # Imports the math module
print("\n" + "Choose either 'investment' or 'bond' from the menu below to proceed: " + "\n" + "\n" +
"investment \t - to calculate the amount of interest you'll earn on interest" + "\n" +
"bond \t \t - to calculate the amount you'll have to pay on a home loan") # D... | true |
c26242104a494b3a38fb578e1d437cc6853dd2ae | Jlemien/Beginner-Python-Projects | /Guess My Number.py | 893 | 4.4375 | 4 | 7"""Overview: The computer randomly generates a number.
The user inputs a number, and the computer will tell you if you are too high, or too low.
Then you will get to keep guessing until you guess the number.
What you will be Using: Random, Integers, Input/Output, Print, While (Loop), If/Elif/Else"""
from random impor... | true |
a956f3b23892c56326cddaccf4b14b75e660706b | DKojen/HackerRank-Solutions | /Python/Text_wrap.py | 552 | 4.15625 | 4 | #https://www.hackerrank.com/challenges/text-wrap/problem
#You are given a string and width .
#Your task is to wrap the string into a paragraph of width .
import textwrap
string = 'ABCDEFGHIJKLIMNOQRSTUVWXYZ'
max_width = 4
def wrap(string, max_width):
return textwrap.fill(string,max_width)
if __name... | true |
275a568b7ccd4adb102c768fd74f8b8e78a04515 | nickborovik/stepik_python_advanced | /lesson1_3.py | 1,237 | 4.21875 | 4 | # functions
"""
def function_name(argument1, argument2):
return argument1 + argument2
x = function_name(2, 8)
y = function_name(x, 21)
print(y)
print(type(function_name))
print(id(function_name))
"""
"""
def list_sum(lst):
result = 0
for element in lst:
result += element
return result
def sum... | true |
f85cb21075e1320782d29d9f0b0063d95df2bc23 | shreyas710/Third-Year-Programs-Computer-Engineering-SPPU | /Python & R programming/prac5.py | 474 | 4.21875 | 4 | #Title: Create lambda function which will return true when no is even:
import mypackage.demo
mypackage.demo.my_fun()
value=lambda no:no%2==0
no=input("Enter the no which you want to check : ")
print(value(int(no)))
#title:filter function to obtain or print even no or print even no
num_list=[1,2,3,4,5]
x=list(filter... | true |
f7c25f4592050bcb9df83d514d2f8df110c5d449 | w-dayrit/learn-python3-the-hard-way | /ex21.py | 1,595 | 4.15625 | 4 | def add(a, b):
print(f"ADDING {a} + {b}")
return a + b
def subtract(a, b):
print(f"SUBTRACTING {a} - {b}")
return a - b
def multiply(a, b):
print(f"MULTIPLYING {a} * {b}")
return a * b
def divide(a, b):
print(f"DIVIDING {a} / {b}")
return a / b
print("Let's do some math with just fu... | true |
e3cd5279375fc9b78d13676b76b98b76768f38a7 | umaralam/python | /method_overriding.py | 426 | 4.53125 | 5 | #!/usr/bin/python3
##Extending or modifying the method defined in the base class i.e. method_overriding. In this example is the call to constructor method##
class Animal:
def __init__(self):
print("Animal Constructor")
self.age = 1
class Mammal(Animal):
def __init__(self):
print("Mammal Constructor")
self.we... | true |
019b266b1aa9f3ce7251acb5959f93f175df1d9d | umaralam/python | /getter_setter_property.py | 1,555 | 4.3125 | 4 | #!/usr/bin/python3
class Product:
def __init__(self, price):
##No data validation in place##
# self.price = price
##Letting setter to set the price so that the validation is performed on the input##
# self.set_price(price)
##Since using decorator for property object our constructor will get modified as##
self.p... | true |
ad6fd41bd59eed17e8d504fcb6fdfa9d7da7f7c7 | ArsathParves/P4E | /python assingments/rduper.py | 326 | 4.15625 | 4 | #fname = input("Enter file name: ")
#fh = open(fname)
#inp=fh.read()
#ufh=inp.upper()
#sfh=ufh.rstrip()
#print(sfh)
## Read a file and print them the characters in CAPS and strip /n from right of the lines
fname = input("Enter file name: ")
fh = open(fname)
for lx in fh:
ly=lx.rstrip()
print(ly.uppe... | true |
8a9f103b3ff3222d1b2b207c30fed67fee1c1450 | ArsathParves/P4E | /python assingments/ex7-2.py | 872 | 4.25 | 4 | # 7.2 Write a program that prompts for a file name, then opens that file and reads through the file, looking for lines of the form:
# X-DSPAM-Confidence: 0.8475(eg)
# Count these lines and extract the floating point values from each of the lines and compute the average of those
# values and produce an output as s... | true |
32836815b3d948376d26030dff4fe454c654b591 | nortonhelton1/classcode | /classes_and_objects (1)/classes_and_objects/customer-and-address.py | 1,103 | 4.4375 | 4 |
class Customer:
def __init__(self, name):
self.name = name
self.addresses = [] # array to represent addresses
class Address:
def __init__(self, street, city, state, zip_code):
self.street = street
self.city = city
self.state = state
self.zip_code = zip_co... | true |
05acb84502e7e62ea9da1088ee08c1c945652c71 | dylantzx/HackerRank | /30 Days Of Code/DictionariesAndMaps.py | 635 | 4.125 | 4 | ############################# Question ###########################
# https://www.hackerrank.com/challenges/30-dictionaries-and-maps/problem
##################################################################
# Enter your code here. Read input from STDIN. Print output to STDOUT
count = int(input())
list_of_queries = [... | true |
c1f1c50534463aea935f74526059a3760f2bbfc7 | abbasjam/abbas_repo | /python/dev-ops/python/pythan-class/string14.py | 212 | 4.15625 | 4 | print ("String Manipulations")
print ("-------------------")
x=input("Enter the String:")
print ("Given String is:",x)
if x.endswith('.txt'):
print ("Yes!!!!!!!text file")
else:
print ("Not textfile")
| true |
5864a1d2a032b9379e2ce6118c2e77598116c81a | abbasjam/abbas_repo | /python/dev-ops/python/pythan-class/string7.py | 234 | 4.15625 | 4 | print ("String Manipulations")
print ("-------------------")
x=input("Enter the String:")
print ("Given String is:",x)
if x.isspace():
print ("String Contains only spaces ")
else:
print ("one or more chars are not spaces")
| true |
6ffce6b6ba40bad4d70bd8dc847cfcabc9dfdcbd | chapman-cs510-2017f/cw-03-sharonjetkynan | /sequences.py | 610 | 4.4375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
def fibonacci(n):
"""
object: fibonacci(n) returns the first n Fibonacci numbers in a list
input: n- the number used to calculate the fibonacci list
return: retList- the fibonacci list
"""
if type(n) != int:
print(n)
print(":inp... | true |
f671a071f6f111ea4f63e2b6aea4dd8e1844d056 | KyleHu14/python-alarm-clock | /main.py | 1,704 | 4.28125 | 4 | import time
import datetime
def print_title() -> None:
# Prints the title / welcome string when you open the app
print('#' * 26)
print('#' + '{:^24s}'.format("Alarm Clock App") + '#')
print('#' * 26)
print()
def take_input() -> str:
# Takes the input from the user and checks if the input is ... | true |
97e49ed0257e6f87dd9dd55ccaa7034b2f50ca9f | foleymd/boring-stuff | /more_about_strings/advanced_str_syntax.py | 1,051 | 4.1875 | 4 | #escape characters
#quotation
print('I can\'t go to the store.')
print("That is Alice's cat.")
print('That isn\'t Alice\'s "cat."')
print("Hello, \"cat\".")
print('''Hello, you aren't a "cat."''')
#tab
print('Hello, \t cat.')
#newline
print('Hello, \n cat.')
print('Hello there!\nHow are you?\nI\'m fine!')
#backslas... | true |
7939df2c4af30d7527ab8919d69ba5055f43f7ce | vishwaka07/phython-test | /tuples.py | 1,048 | 4.46875 | 4 | # tuples is also a data structure, can store any type of data
# most important tuple is immutable
# u cannot update data inside the tuple
# no append, no remove, no pop, no insert
example = ( '1','2','3')
#when to use : days , month
#tuples are faster than lists
#methods that can be used in tuples : count,index, len f... | true |
0b15fd9864c222c904eef1e7515b5dd125e05022 | Randheerrrk/Algo-and-DS | /Leetcode/515.py | 1,209 | 4.1875 | 4 | '''
Find Largest Value in Each Tree Row
------------------------------------
Given the root of a binary tree, return an array of the largest value in each row of the tree (0-indexed).
Input: root = [1,3,2,5,3,null,9]
Output: [1,3,9]
Input: root = [1,2,3]
Output: [1,3]
Input: root = [1]
Output: [1]
Input: root = [1... | true |
e6eada3e5ad01097e132123a75d6c2b3a134d977 | shulme801/Python101 | /squares.py | 451 | 4.21875 | 4 | squares = [value**2 for value in range(1,11)]
print(squares)
# for value in range(1, 11):
# # square = value ** 2
# # squares.append(square)
# squares.append(value**2)
# print(f"Here's the squares of the first 10 integers {squares}")
odd_numbers = list(range(1,20,2))
print(f"Here's the odd numbers from 1 th... | true |
0b9e29c79c892215611b5cdb3e64ee2210d6f2a3 | shulme801/Python101 | /UdemyPythonCertCourse/Dunder_Examples.py | 1,017 | 4.3125 | 4 | # https://www.geeksforgeeks.org/customize-your-python-class-with-magic-or-dunder-methods/?ref=rp
# declare our own string class
class String:
# magic method to initiate object
def __init__(self, string):
self.string = string
# print our string object
def __repr__(self):
... | true |
9bd76fe2cca59bd95d2a5237d8bf34a13ed13c60 | lawtonsclass/s21-code-from-class | /csci1/lec14/initials.py | 742 | 4.21875 | 4 | import turtle # imports the turtle library
import math
turtle.shape("turtle") # make the turtle look like a turtle
turtle.up()
turtle.backward(150)
turtle.right(90)
turtle.down() # put the turtle down so that we can draw again
turtle.forward(200) # draw first line of L
turtle.left(90)
turtle.forward(... | true |
f14f7efaf33491f9758099e639e1adf4fbc55c50 | lawtonsclass/s21-code-from-class | /csci1/lec19/random_squares.py | 1,136 | 4.21875 | 4 | import turtle
import random
turtle.shape('turtle')
turtle.speed('fastest')
colors = ['red', 'orange', 'yellow', 'green', 'blue', 'purple']
i = 1
while i <= 50:
# draw a square with a random side length and a random color
random_index = random.randint(0, len(colors) - 1)
turtle.fillcolor(colors[rand... | true |
0d613768179d34123018a637a31ce1327587c5fc | lawtonsclass/s21-code-from-class | /csci1/lec30/recursion.py | 961 | 4.1875 | 4 | def fact(n):
# base case
if n == 1:
return 1
else: # recursive case!
x = fact(n - 1) # <-- this is the "recursive call"
# the answer is n * (n-1)!
return n * x
print(fact(5))
def pow(n, m):
if m == 0: # base case
return 1
else: # recursive case
return n * pow(n, m-... | true |
919bc6acd1abd0d772c86c501de1aa4e9395d103 | Nihadkp/MCA | /Semester-01/Python-Programming-Lab/Course-Outcome-1-(CO1)/02-Leap-Year/Leap_year.py | 300 | 4.375 | 4 | # purpose - to find leap years of future year from current year
startYear = 2021
print("Enter any future year")
endYear = int(input())
print("List of leap years:")
for year in range(startYear, endYear):
if (0 == year % 4) and (0 != year % 100) or (0 == year % 400):
print(year)
| true |
1407338619c9f08438e00a72f20ee2a1796ffaa2 | Nihadkp/MCA | /Semester-01/Python-Programming-Lab/Course-Outcome-1-(CO1)/20-Remove-even-numbers-form-a-list-of-integers/Removing_Even_numbers_in_LIST.py | 419 | 4.1875 | 4 | # purpose- removing even numbers in list
numberList = []
even_numberList = []
n = int(input("Enter the number of elements "))
print("\n")
for i in range(0, n):
print("Enter the element ", i + 1, ":")
item = int(input())
numberList.append(item)
print(" List is ", numberList)
even_numberList = [x for x in n... | true |
31dabba934c1b70d75263ef9bf71549651baa464 | Nihadkp/MCA | /Semester-01/Python-Programming-Lab/Course-Outcome-1-(CO1)/03-List-Comprehensions/List_Operations.py | 1,445 | 4.125 | 4 | # purpose - program to perform some list operations
list1 = []
list2 = []
print("Select operation.")
print("1.Check Length of two list's are Equal")
print("2.Check sum of two list's are Equal")
print("3.whether any value occur in both ")
print("4.Display Lists")
while True:
choice = input("Enter any choi... | true |
7c9d95660844b66ff9becf9f656ed9f16f78ed79 | mengeziml/sorepy | /sorepy/sorting.py | 2,472 | 4.625 | 5 | def bubble_sort(items):
"""Return array of items, sorted in ascending order.
Args:
items (array): list or array-like object containing numerical values.
Returns:
array: sorted in ascending order.
Examples:
>>> bubble_sort([6,2,5,9,1,3])
[1, 2, 3, 5, 6, 9]
"""
n... | true |
4663b089240b5f113c3c49e7918204417dff77f7 | BenWarwick-Champion/CodeChallenges | /splitStrings.py | 581 | 4.125 | 4 | # Complete the solution so that it splits the string into pairs of two characters.
# If the string contains an odd number of characters then it should replace
# the missing second character of the final pair with an underscore ('_').
# Example:
# solution('abc') # should return ['ab', 'c_']
# solution('abcdef'... | true |
992ad23ed86e3c42cebb5d4130acaba5dca70eda | ktsmpng/CleverProgrammerProjects | /yo.py | 447 | 4.28125 | 4 | # print from 1 to 100
# if number is divisble by 3 -- fizz
# if number is divisble by 5 -- buzz
# if divisible by both -- fizzbuzz
# 2
# fizz
# 3
def fizzbuzz(start_num, stop_num):
print('_________________')
for number in range(start_num, stop_num + 1):
if number % 3 == 0 and number % 5 == 0:
print("fizzbuzz"... | true |
661171d9cc55d2b4c5ef7bbfe5c02f9cc5760c43 | Topperz/pygame | /5.first.pygame.py | 2,986 | 4.65625 | 5 | """
Show how to use a sprite backed by a graphic.
Sample Python/Pygame Programs
Simpson College Computer Science
http://programarcadegames.com/
http://simpson.edu/computer-science/
Explanation video: http://youtu.be/vRB_983kUMc
"""
import pygame
import time
import math
# Define some colors
BLACK = (0, 0, ... | true |
39984a91ad8bc8209dca055467c40ad7560a898e | applecool/Python-exercises | /key_value.py | 594 | 4.125 | 4 | # Write a function that reads the words in words.txt and stores
# them as keys in a dictionary. It doesn't matter what the values
# are.
#
# I used the python's in-built function random to generate random values
# One can use uuid to generate random strings which can also be used to
# pair the keys i.e., in this case... | true |
d3210816dac9893a01061a6687f17b13304c3289 | subreena10/dictinoary | /existnotexistdict.py | 249 | 4.46875 | 4 | dict={"name":"Rajiu","marks":56} # program to print 'exist' if the entered key already exist and print 'not exist' if entered key is not already exists.
user=input("Enter ur name: ")
if user in dict:
print("exist")
else:
print("not exists") | true |
090de8d31c4ea6ce5b30220d8e3f7679d8328db3 | adreher1/Assignment-1 | /Assignment 1.py | 1,418 | 4.125 | 4 | '''
Rose Williams
rosew@binghamton.edu
Section #B1
Assignment #1
Ava Dreher
'''
'''
ANALYSIS
RESTATEMENT:
Ask a user how many people are in a room and output the total number of
introductions if each person introduces themselves to every other person
once
OUTPUT to monitor:
introductions (i... | true |
29a9472bf05258a090423ef24cc0c64311a6272b | acc-cosc-1336/cosc-1336-spring-2018-Miguelh1997 | /src/midterm/main_exam.py | 561 | 4.40625 | 4 | #write import statement for reverse string function
from exam import reverse_string
'''
10 points
Write a main function to ....
Loop as long as user types y.
Prompt user for a string (assume user will always give you good data).
Pass the string to the reverse string function and display the reversed string
'''
def m... | true |
f16f06d76cb51cff2e10bc64d9310890e041231b | abalidoth/dsp | /python/q8_parsing.py | 673 | 4.3125 | 4 | # The football.csv file contains the results from the English Premier League.
# The columns labeled ‘Goals’ and ‘Goals Allowed’ contain the total number of
# goals scored for and against each team in that season (so Arsenal scored 79 goals
# against opponents, and had 36 goals scored against them). Write a program to r... | true |
645e285a751310786073fefba08294bf7850b051 | 40309/variables | /assignment_improvement_exercise_py.py | 402 | 4.28125 | 4 | #john bain
#variable improvement exercise
#05-09-12
import math
radius = float(input("Please enter the radius of the circle: "))
circumference = int(2* math.pi * radius)
circumference = round(circumference,2)
area = math.pi * radius**2
area = round(area,2)
print("The circumference of this circle is {... | true |
73760296f75889f8eaba190a9bc38c2d03555c95 | 40309/variables | /Development Exercise 3.py | 342 | 4.1875 | 4 | #Tony K.
#16/09/2014
#Development Exercise 3
height = float(input("Please enter your height in inches: "))
weight = float(input("Please enter your height in stones: "))
centimeter = height* 2.54
kilogramm = weight * (1/0.157473)
print("You are {0} cenimeters tall and you weigh {1} kilogramm".format(ce... | true |
5e20c1fde5e1ebd93f22d718ac78f699f31a387c | lloydieG1/Booking-Manager-TKinter | /data.py | 1,013 | 4.1875 | 4 | import sqlite3
from sqlite3 import Error
def CreateConnection(db_file):
''' create a database connection to a SQLite database and check for errors
:param db_file: database file
:return: Connection object or None
'''
#Conn starts as 'None' so that if connection fails, 'None' is returned
conn = ... | true |
f5c41d06bb1137f0d1aac5b0f1dbedc9604cc91b | NickNganga/pyhtontake2 | /task3.py | 547 | 4.125 | 4 | def list_ends(a_list):
return (a_list[0], a_list[len(a_list)-1])
# number of elements
num = int(input("Enter number of elements : "))
# Below line read inputs from user using map() function
put = list(map(int,input("\nEnter the numbers : ").strip().split()))[:num]
# Below Line calls the function created above.
p... | true |
80282dbf6abf81960e5714850eb1455cd147009a | kgomathisankari/PythonWorkspace | /function_and_class_programs/palindrome_calling_function_prgram.py | 561 | 4.25 | 4 | user_input = input("Enter your name : ")
def reverseString(user_input) :
reverse_string = ""
for i in range (len(user_input) - 1, -1 , -1) :
reverse_string = reverse_string + user_input[i]
return reverse_string
def isPalindrome(user_input) :
palindrome = "What you have entered is a Palindrome"... | true |
b61cc6e6fbac22a3444fd6827d4cbf84cc554924 | kgomathisankari/PythonWorkspace | /for_loop_programs/modified_odd_and_even_program.py | 503 | 4.3125 | 4 | even_count = 0
odd_count = 0
getting_input = int(input("How many numbers do you want to enter? "))
for i in range (getting_input) :
getting_input_2 = int(input("Enter the number : "))
even = getting_input_2 % 2
if even == 0 :
even_count = even_count + getting_input_2
elif even != 0 :
odd... | true |
f4ad192198588faed881318cbee95bed57fbbdd2 | kgomathisankari/PythonWorkspace | /for_loop_programs/largest_smallest_program.py | 421 | 4.21875 | 4 | no_count = int(input("How many numbers do you want to enter? "))
list = []
for i in range (no_count) :
num = int(input("Enter the number : "))
list.append(num)
largest = list[0]
smallest = list[1]
for j in list :
if largest < j :
largest = j
elif smallest > j :
smallest = j
print("The l... | true |
fe9366843f9bdeac7a0687b6bb2abb26357007aa | vTNT/python-box | /test/func_doc.py | 290 | 4.4375 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
def printmax(x, y):
'''print the max of two numbers.
the two values must be integers.'''
x = int(x)
y = int(y)
if x > y:
print x, 'is max'
else:
print y, 'is max'
printmax(3, 5)
#print printmax.__doc__
| true |
d331f247e1ad6183997de06a8323dd27f56794ad | vTNT/python-box | /app/Tklinter2.py | 932 | 4.21875 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
from Tkinter import *
class LabelDemo( Frame ):
"""Demonstrate Labels"""
def __init__( self ):
"""Create three Labels and pack them"""
Frame.__init__( self ) # initializes Frame instance
# frame fills all available space
self.... | true |
658a3ba9560615ba04aebaa444e09e91f763c668 | dscheiber/CodeAcademyChallenge | /binaryconversion.py | 2,185 | 4.46875 | 4 | # 3. Convert a decimal number into binary
# Write a function in Python that accepts a decimal number and returns the equivalent binary number.
# To make this simple, the decimal number will always be less than 1,024,
# so the binary number returned will always be less than ten digits long.
##author note: ok, so i h... | true |
206bfc1fc295e7803c04d70a69ee8445ad308201 | yellowb/ml-sample | /py3_cookbook/_1_data_structure/deduplicate_and_maintain_order.py | 979 | 4.125 | 4 | """ Sample for removing duplicated elements in list and maintain original order """
import types
names = ['tom', 'ken', 'tim', 'mary', 'ken', 'ben', 'berry', 'mary']
# Use `set()` for easy deduplicate, but changes the order
print(set(names))
# Another approach: use loop with a customized hash function
def dedupe(it... | true |
892801363f4edc79ed1ed9ce38f9bdbd483ab02d | wjaneal/ICS3U | /WN/Python/VectorField.py | 1,295 | 4.34375 | 4 | #Vector Field Program
#Copyleft 2013, William Neal
#Uses Python Visual Module to Display a Vector Field
#as determined by an equation in spherical coordinates
#Import the required modules for math and graphics:
import math
from visual import *
#Set a scale factor to determine the time interval for each calculation:... | true |
ae30d9d7532905ac7e32a7b728a9a42c24c55db8 | shripadtheneo/codility | /value_part_array/same_val_part_arr.py | 910 | 4.1875 | 4 | """
Assume the input is an array of numbers 0 and 1. Here, a "Same Value Part Array" means a part of
an array in which successive numbers are the same.
For example, "11", "00" and "111" are all "Same Value Part Arrays" but "01" and "10" are not.
Given Above, implement a program to return the longest "Same Value Part ... | true |
12f98922c3aaeaed6e05d773976ac18892897b27 | aishwarya-narayanan/Python | /Python/Turtle Graphics/turtleGraphicsAssignment.py | 812 | 4.34375 | 4 | import turtle
# This program draws import turtle
# Named constants
START_X = -200
START_Y = 0
radius = 35
angle = 170
ANIMATION_SPEED = 0
#Move the turtle to its initial position.
turtle.hideturtle()
turtle.penup()
turtle.goto(START_X, START_Y)
turtle.pendown()
# Set the animation speed.
turtle.speed(ANIMATION_SPEED)... | true |
a035fc1998182c99f9b9d3f6a007f023584f532e | LeviMollison/Python | /PracticingElementTree.py | 2,682 | 4.4375 | 4 | # Levi Mollison
# Learning how to properly use the XML Tree module
try:
from lxml import etree
print("running with lxml.etree")
except ImportError:
try:
# Python 2.5, this is the python we currently are running
import xml.etree.cElementTree as etree
print("running with cElementTree ... | true |
6fea835bad3e56232e2c9dfd965f8834fe1b7ceb | topuchi13/Res_cmb | /res.py | 952 | 4.125 | 4 | try:
file = open ("./list.csv", "r")
except FileNotFoundError:
print ("*** The file containing available resistor list doesn't exist ***")
list = file.read().split('\n')
try:
target = int(input("\nPlease input the target resistance: "))
except ValueError:
print("*** Wrong Value Entered!!! Please enter only o... | true |
224cebe24edb6007f91782c94bfbcc61210a2604 | kzd0039/Software_Process_Integration | /Assignment/makeChange.py | 1,261 | 4.15625 | 4 | from decimal import Decimal
def makeChange(amount = None):
"""
Create two lists:
money: store the amount of the bill
To perform exact calculations, multiply all the amount of bills by 1000,
which should be [20,10,5,1,0.25,0.1,0.05,0.1] at first, then all the calculations
... | true |
3adbd132cc9b8ebefb006fd7868a41ff1d9c485c | BadAlgorithm/juniorPythonCourse1 | /BitNBites_JuniorPython/Lesson3/trafficLightProgram.py | 1,292 | 4.3125 | 4 | # %%%----------------Standard task------------------%%%
lightColour = input("Light colour: ")
if lightColour == "green":
print("go!")
elif lightColour == "orange":
print("slow down")
elif lightColour == "red":
print("stop")
else:
print("Invalid colour (must be; red, orange or green)")
# %%%------------... | true |
a47d166561f94e27e1759b83b6c9a62e585de59e | KevinKnott/Coding-Review | /Month 02/Week 01/Day 02/d.py | 2,222 | 4.1875 | 4 | # Binary Tree Zigzag Level Order Traversal: https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/
# Given the root of a binary tree, return the zigzag level order traversal of its nodes' values. (i.e., from left to right, then right to left for the next level and alternate between).
# Definition for... | true |
ecd2a22e759163ce69be192752e81a19f023f98e | KevinKnott/Coding-Review | /Month 03/Week 01/Day 02/a.py | 1,059 | 4.125 | 4 | # Invert Binary Tree: https://leetcode.com/problems/invert-binary-tree/
# Given the root of a binary tree, invert the tree, and return its root.
# Definition for a binary tree node.
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right... | true |
7f886aacfb48d99bcfe6374cc0c819a24d90bc02 | KevinKnott/Coding-Review | /Month 02/Week 03/Day 05/a.py | 2,835 | 4.34375 | 4 | # Convert Binary Search Tree to Sorted Doubly Linked List: https://leetcode.com/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/
# Convert a Binary Search Tree to a sorted Circular Doubly-Linked List in place.
# You can think of the left and right pointers as synonymous to the predecessor and successo... | true |
1d8e25cdf7d3725c40c4f4f156fb1e13d375ed2b | KevinKnott/Coding-Review | /Month 03/Week 03/Day 03/b.py | 1,363 | 4.25 | 4 | # Symmetric Tree: https://leetcode.com/problems/symmetric-tree/
# Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center).
# Definition for a binary tree node.
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self... | true |
53b49618af403a3a0d416f3297e7e2a9ca9db70f | KevinKnott/Coding-Review | /Month 03/Week 02/Day 06/a.py | 2,135 | 4.15625 | 4 | # Merge k Sorted Lists: https://leetcode.com/problems/merge-k-sorted-lists/
# You are given an array of k linked-lists lists, each linked-list is sorted in ascending order.
# Merge all the linked-lists into one sorted linked-list and return it.
# This problem can be broken down into two steps one merging two separate... | true |
ea7d70f36d68d9f544b31b6e0419d643aed7826e | VEGANATO/Learned-How-to-Create-Lists-Code-Academy- | /script.py | 606 | 4.1875 | 4 | # I am a student trying to organize subjects and grades using Python. I am organizing the subjects and scores.
print("This Year's Subjects and Grades: ")
subjects = ["physics", "calculus", "poetry", "history"]
grades = [98, 97, 85, 88]
subjects.append("computer science")
grades.append(100)
gradebook = list(zip(grades... | true |
2fdd7901f6ff2b80df39194d6c47e81d2e9cf9c8 | dilayercelik/Learn-Python3-Codecademy-Course | /8. Dictionaries/Project-Scrabble.py | 1,800 | 4.25 | 4 | #Module: Using Dictionaries - Project "Scrabble"
letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
points = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10]
#Question 1 Create a dictionary regro... | true |
69c588b6f00b5cb6ce9ab31141b6f9d0e8639854 | HaydnLogan/GitHubRepo | /algorithms/max_number.py | 547 | 4.21875 | 4 | # Algorithms HW1
# Find max number from 3 values, entered manually from a keyboard.
# using built in functions
# 0(1) no loops
def maximum(a, b, c):
list = [a, b, c]
# return max(list)
return max(a, b, c)
# not using built in functions
def find_max(a, b, c):
if a > b and a > c:
return a
if... | true |
b3fd7bfe7bf698d287bb30ce2d5e161120f83f2e | HaydnLogan/GitHubRepo | /algorithms/lesson_2/anagrams.py | 1,004 | 4.21875 | 4 | """
Write a function to check whether two given strings are anagram of each other or not.
An anagram of a string is another string that contains the same characters, only the order
of characters can be different. For example, "abcd" and "dabc" are an anagram of each other.
"""
def is_anagram(s1, s2):
if len(s1) ... | true |
a98f95088d163de04f30c58ce03e8ee770ec4a63 | meagann/ICS4U1c-2018-19 | /Working/Classes Practice/practice_point.py | 1,302 | 4.375 | 4 | """
-------------------------------------------------------------------------------
Name: practice_point.py
Purpose:
Author: James. M
Created: 21/03/2019
------------------------------------------------------------------------------
"""
import math
class Point(object):
def __init__(self, x, y):... | true |
5b494b06748c5e2a319d8bcaf82668c02c7cd5cc | amdslancelot/stupidcancode | /questions/group_shifted_strings.py | 1,672 | 4.15625 | 4 | """
Given a string, we can "shift" each of its letter to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which forms the sequence:
"abc" -> "bcd" -> ... -> "xyz"
Given a list of strings which contains only lowercase alphabets, group all strings that belong to the same shifting sequence.
For... | true |
eacc496766f745c8df335d462d8846427f04d229 | jtambe/Python | /ArrayOfPairs.py | 503 | 4.3125 | 4 | # this function checks if all elements in array are paired
# it uses bitwise XOR logic
def IsArrayOfPairs(arr):
var = arr
checker = 0
for i in range(len(arr)):
checker ^= ord(arr[i])
if checker == 0:
print("All pairs")
else:
print("At least one odd entry")
def main():
... | true |
f0968a9c1fbc572a482ba161d0c19d2d846d8f41 | greece57/Reinforcement-Learning | /cardgame/player.py | 2,346 | 4.25 | 4 | """ Abstract Player """
class Player():
""" This class should not be initialized. Inherit from this to create an AI """
def __init__(self, name):
""" Initialize Variables """
self.name = name
self.cards = []
#inGame
self.last_enemy_move = -1
self.points = 0
... | true |
b8414a54bb25b12fed98ebd497433d10eae8c591 | tjnovak58/cti110 | /M6T1_Novak.py | 473 | 4.6875 | 5 | # CTI-110
# M6T1 - Kilometer Converter
# Timothy Novak
# 11/09/17
#
# This program prompts the user to enter a distance in kilometers.
# It then converts the distance from kilomters to miles.
#
conversion_factor = 0.6214
def main():
kilometers = float(input('Enter the distance traveled in kilometers:'... | true |
1bc7f7295f1c8ad8d8f3cf278a976cedcef64895 | tjnovak58/cti110 | /M2HW1_DistanceTraveled_TimothyNovak.py | 581 | 4.34375 | 4 | # CTI-110
# M2HW1 - Distance Traveled
# Timothy Novak
# 09/10/17
#
# Define the speed the car is traveling.
speed = 70
# Calculate the distance traveled after 6 hours, 10 hours, and 15 hours.
distanceAfter6 = speed * 6
distanceAfter10 = speed * 10
distanceAfter15 = speed * 15
# Display the distance trav... | true |
75e0f2685f912d3fa048ef83ecdfd0eb11dca378 | NiamhOF/python-practicals | /practical-13/p13p5.py | 1,073 | 4.46875 | 4 | '''
Practical 13, Exercise 5
Program to illustrate scoping in Python
Define the function f of x:
print in the function f
define x as x times 5
define y as 200
define a as the string I'm in a function
define b as 4 to the power of x
print the values of x, y, z, a and b
return x
define val... | true |
5e11d2d9c14c56b9ad0686eff5b6754b7989b50d | NiamhOF/python-practicals | /practical-9/p9p2.py | 685 | 4.21875 | 4 | '''
Practical 9, Exercise 2
Ask user for a number
Ensure number is positive
while number is positive
for all integers in the range of numbers up to and including the chosen number
add each of these integers
print the total of these integers
ask the user to enter a number again
If the number is les... | true |
29856ffe797d9b60da6735c46773a9d005f7d59d | NiamhOF/python-practicals | /practical-9/p9p5.py | 1,958 | 4.125 | 4 | '''
Practical 9, Exercise 5
Ask user for number of possible toppings
Ask user for numer of toppings on standard pizza
Get the number of the possible toppings minus the number of toppings on a pizza
Tell the user if either number is less than 0 or if the difference is less than zero
else:
calculate factorial of al... | true |
22cf0ac6f1532d8bce0c66d1f95201a092b3680a | NiamhOF/python-practicals | /practical-9/p9p4.py | 849 | 4.1875 | 4 | '''
Practical 9, Exercise 4
Ask user for a number
while the number is greater than or equal to 0
if the number is 0, the factorial is 1
if the number is 1, the factorial is 1
if the number is greater than 1:
define fact as 1
for all numbers i of the integers from 1 to number
fac... | true |
7b698768332c8b9d5a78dd1baee6b3e0c0f65ac9 | NiamhOF/python-practicals | /practical-2/p2p4.py | 630 | 4.34375 | 4 | #Practical 2, exercise 4
#Note: index starts at 0
#Note: going beyond the available letters in elephant will return an error
animal='elephant'
a=animal[0]
b=animal[1]
c=animal[2]
d=animal[3]
e=animal[4]
f=animal[5]
g=animal[6]
h=animal[7]
print ("The first letter of elephant is: " + a)
print ("The second letter of el... | true |
63f49c0b8878c2cf5871e726c2115a10acfc51c9 | NiamhOF/python-practicals | /practical-18/p18p5-2.py | 1,500 | 4.125 | 4 | '''
Practical 18, Exercise 5 alternate
Define a function hasNoPrefix that takes two parameters index and s:
if index is equal to zero return true
else if the index position - 1 is a period return False
else:
return True
Define a function is XYZ that takes the parameter s:
assign containsXYZ th... | true |
eb7d25ee8fd40c35ab061dde337f1b185b01607f | edwardmoradian/Python-Basics | /List Processing Part 1.py | 290 | 4.1875 | 4 | # Repetition and Lists
Numbers = [8,6,7,5,3,0,9]
# Using a for loop with my list of numbers
for n in Numbers:
print(n,"",end="")
print()
# Another example, list processing
total = 0
for n in Numbers:
Total = n + Total
print ("Your total is", Total) | true |
4b600ba28bb297ca75b0880b746510576afcc4d6 | edwardmoradian/Python-Basics | /Read Lines from a File.py | 645 | 4.21875 | 4 | # read lines from a file
# steps for dealing with files
# 1. Open the file (r,w,a)
# 2. Process the file
# 3. Close the file ASAP.
# open the file
f = open("words.txt", "r")
# process it, remember that the print function adds a newline character - two different ways to remove newline character
line1 = f.r... | true |
cbb70013b4ff8ee5d2218244d58d67180aa4d2d1 | edwardmoradian/Python-Basics | /List Methods and Functions.py | 1,735 | 4.59375 | 5 |
# Let's look at some useful functions and methods for dealing with lists
# Methods: append, remove, sort, reverse, insert, index
# Access objects with dot operator
# Built-in functions: del, min, max
# Append = add items to an existing list at the end of the list
# takes the item you want added as an argument
... | true |
dc1d00f4d881c456baff43f1a54cb24bd34392f1 | Sandip-Dhakal/Python_class_files | /class7.py | 824 | 4.1875 | 4 | # String formating using % operator and format method
# name='Sam'
# age=20
# height=5.7
# txt='Name:\t'+name+"\nAge:\t"+str(age)+"\nHeight:\t"+str(height)
# print(txt)
# txt="Name: %s Age: %d Height: %f"%(name,age,height)
# print(txt)
# num=2.54
# txt="Numbers in different decimal places %f,%.1f,%.2f,%.3f"%(num,num,nu... | true |
d72fb44e0d0b9d0e7fbcb16a11cb76fd9b66f605 | dragonsarebest/Portfolio | /Code/5October2020.py | 1,535 | 4.3125 | 4 | class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
# Function to print the list
def printList(self):
node = self
output = ''
while node != None:
output += str(node.val)
output += " "
nod... | true |
8d532130ed4482209e92f343cb947eafdd639357 | francisrod01/udacity_python_foundations | /03-Use-classes/Turtle-Mini_project/drawing_a_flower.py | 660 | 4.25 | 4 | #!~/envs/udacity-python-env
import turtle
def draw_flower(some_turtle):
for i in range(1, 3):
some_turtle.forward(100)
some_turtle.right(60)
some_turtle.forward(100)
some_turtle.right(120)
def draw_art():
window = turtle.Screen()
window.bgcolor("grey")
# Create the ... | true |
e8b187cf82b994c099b135796eb251459f17b1e9 | Aryank47/PythonProgramming | /sanfoundary.py | 377 | 4.125 | 4 | # sanfoundary program to add element to a list
n=int(input("Enter the no of elements to be read:"))
a=[]
for i in range(0,n):
y=int(input("Enter the elements: "))
a.append(y)
print(a)
# sanfoundary program to print the multiplication table of the input number
res=sum(a)/n
print(res)
n=int(input("Enter the numb... | true |
747991d9889ebfa7f627f7a54e706e8d7ba1eaa3 | AbhishekBabuji/Coding | /Leetcode/balaned_paranthesis.py | 1,832 | 4.1875 | 4 | """
The following contains a class and methods
to check for a valid patanthesis
"""
import unittest
class ValidParanthesis:
"""
The following class contains a static method
to check for valid paranthesis
"""
def check_paran(self, input_paran):
"""
Args:
input_paran(s... | true |
4e914e273e91739c55e8f9f95532e2dcfa778e3d | ioqv/CSE | /Edgar lopez Hangman.py | 1,198 | 4.28125 | 4 | """
A general guide for Hangman
1.Make a word bank - 10 items
2.Pick a random item from the list
3.Hide the word (use *)4.Reveal letters already guessed
5.Create the win condition
"""
import string
import random
guesses_left = 10
list_word = ["School", "House", "Computer", "Dog", "Cat", "Eat", "Hospital", "supreme", ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.