blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
d29b902b56c3dcd3f132d6a3d699b061ccdb3bb6 | michaeldton/Fall20-Text-Based-Adventure-Game- | /main.py | 1,859 | 4.21875 | 4 | import sys
from Game.game import Game
# Main function calls the menu
def main():
menu()
# Quit function
def quit_game():
print("Are you sure you want to quit?")
choice = input("""
1: YES
2: NO
Please enter your choice: """)
if choic... | true |
5ef61d947c51a4f5793a005629f22e6ca44e4cbf | iamdeepakram/CsRoadmap | /python/regularexpressions.py | 1,106 | 4.1875 | 4 | # find the patterns without RegEx
# some global variable holding function information
test = "362-789-7584"
# write isphonenumber function with arguments text
def isPhoneNumber(text):
global test
test = text
# check length of string
if len(text) != 12 :
return False
# check area code fro... | true |
b3a1e3ab177fac333bc9ee0a5a0b379751807f58 | aklgupta/pythonPractice | /Q4 - color maze/color_maze.py | 2,950 | 4.375 | 4 | """Team Python Practice Question 4.
Write a function that traverse a color maze by following a sequence of colors. For example this maze can be solved by the sequence 'orange -> green'. Then you would have something like this
For the mazes you always pick a spot on the bottom, in the starting color and try to get to... | true |
2e2040449bac85c3dcabef42f995a2bef7c00966 | pavit939/A-December-of-Algorithms | /December-09/url.py | 444 | 4.1875 | 4 | def https(s):
if(s[0:8]=="https://"):
return '1'
else:
return '0'
def url(s):
if (".com" in s or ".net" in s or ".org" in s or ".in" in s):
return "1"
else :
return '0'
s = input("Enter the string to check if it is an URL")
c = https(s)
if c =='1':
u = url(s)
if u... | true |
63488064897109f0ba3806912b1fcf38e759a97f | Krishna-Mohan-V/SkillSanta | /Assignment101-2.py | 964 | 4.40625 | 4 | # Python program to find the second largest number in a list
# Method 1
lst = []
num = int(input("Enter the Number of elements for the List: "))
for i in range(num):
elem = int(input("Enter the list element: "))
lst.append(elem)
print("List Elements are: ",lst)
lst.sort()
print("Second largest... | true |
e15850165397b66795497cfa10d2495139998de0 | Davenport70/python-basics- | /practice strings.py | 1,351 | 4.5625 | 5 | # practice string
# welcome to Sparta - excercise
# Version 1 specs
# define a variable name, and assign a string with a name
welcome = 'Hello and welcome!'
print(welcome)
# prompt the user for input and ask the user for his/her name
user_input = input('What is your name?')
print(user_input)
# use concatenation to... | true |
47f5e052808e5a77df1a15980e1ea37fad4756e4 | raghavgr/Leetcode | /reverse_string344.py | 862 | 4.3125 | 4 | """
Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
"""
class Solution:
""" 2 solutions """
def reverseString(self, s):
"""
in-place reverse string algorithm
i.e. another string is not used to store the result
... | true |
c834fd40f3a86542a2d81ea0297c71d1cf1853fd | JoshMez/Python_Intro | /Dictionary/Empty_Dict.py | 245 | 4.21875 | 4 | #Aim: To learn about empty dictionaries
#
#Creating an empty dictionary.
dict = {} #Put two curly braces. #No space between them.
#
#Adding values to the empty dictionay.
#
dict['Jason'] = 'Blue'
dict['Belle'] = 'Red'
dict['John'] = 'Black'
#
#
| true |
c7136ec6647afc0f3044059082e63a55d80506d5 | JoshMez/Python_Intro | /Programming_Flow/List_Comprehension.py | 298 | 4.25 | 4 | #Basic demonstration of list comprehension.
#Variable was declared.
#List was create with the square brackets.
#value ** 2 was created.
#The a for loop was created ; NOTICE : THere was not the semi:colon as the end.
squares = [ value ** 2 for value in range(1,11) ]
print(squares)
| true |
bfd57f6ad775a8c6cd91ba2db417421d9716a415 | JoshMez/Python_Intro | /Functions/Exercies_8.py | 1,645 | 4.75 | 5 | #8-1. Message: Write a function called display_message() that prints one sentence
#telling everyone what you are learning about in this chapter. Call the
#function, and make sure the message displays correctly.
#Creating a function.
def display_message():
"""Displaying the chapter focuses on"""
print("In this ... | true |
f77853c57409d16a7d23731165daa4fb70a2bf20 | JoshMez/Python_Intro | /While_Input/Dict_User_Input.py | 714 | 4.25 | 4 | #Creating an empty dictionary.
#
#Creating an empty dictionary.
responses = {}
#
#Creating a flag.
polling_active = True
####
#
while polling_active:
#Prompting the user for input.
naming = input("Whats your name: ")
response = input("Which mountain do you want to visit: ")
#Store the responses in the ... | true |
a0f6073ebcf2f8159b91f630968acb177b9b561b | JoshMez/Python_Intro | /Dictionary/Loop_Dict.py | 1,293 | 4.90625 | 5 | #Aim: Explain Loop and Dictionaries.
#
#
#There are several ways to loop through a dictionary.
#Loop through all of Key-pair values.
#Loop through keys only.
#Loop though values only.
#
#
############Example of looping through all dictionary key-pair values####################
#
#Creating a dictionary of a ... | true |
f95e10517f70584b947de934b5fa33dee7d149bc | JoshMez/Python_Intro | /Dictionary/Nesting_2.py | 601 | 4.1875 | 4 | aliens = []
#Basically creating the variable 30 times over.
#
#The range just tells Python how many times we want to loop and repeat.
#Each time loop occurs, we create a new alien and append it to the new alien list.
for alien in range(30):
new_alien = {'color': 'green',
'points': 5,
... | true |
1068634872d3d4acb23453519b7f6e3b9069bcae | JoshMez/Python_Intro | /Programming_Flow/Number_Lists.py | 1,243 | 4.53125 | 5 | #Creating lists that contain number in Python is very important.
#Making a list with even numbers in it.
even_numbers = list(range(0,11,2)) #The list function has been used to say that a lists is being created. #Passing the range arguments in that , stating arugments in that.
print(even_numbers)
#Creating ... | true |
38936a50b1ef5570cef7a9cd19e1774ddc7e21ce | shekhar270779/Learn_Python | /prg_OOP-05.py | 2,388 | 4.5625 | 5 | '''
Class Inheritance: Inheritance allows a class to inherit attributes and methods from parent class.
This is useful as we can create subclass which inherits all functionality of parent class, also if required
we can override, or add new functionality to sub class without affecting parent class
'''
class Employ... | true |
8bdc82cc4590b320da4b8f2e8462b3db0960ea59 | andu1989anand/vtu-1sem-cpl-lab-in-python | /palindrome1.py | 450 | 4.34375 | 4 | print "\n Python program to reverse a given integer number and check whether it is a"
print "PALINDROME or not. Output the given number with suitable message\n\n"
num=input("Enter a valid integer number:")
temp = num
rev=0
while(num != 0):
digit=num % 10
rev=rev * 10 + digit
num=num / 10
print "\n\n The rev... | true |
eaa8e5da435544cd8e07457a6e90e79c5a59591c | pilifengmo/Electrical-Consumption-Prediction-System | /PROJECT/website/model.py | 1,776 | 4.125 | 4 | import sqlite3 as sql
class Database(object):
""" Create database if not exist """
def __init__(self):
con = sql.connect("database.db")
cur = con.cursor()
cur.execute("create table if not exists users (id integer primary key autoincrement, username text not null UNIQUE, email text not... | true |
e9d5619d853a46cfe7f3e26f693d56ae14768567 | hashncrash/IS211_Assignment1 | /assignment1_part2.py | 559 | 4.1875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"IS 211 Assignment 1, part 2. Dave Soto"
class Book(object):
author = " "
title = " "
"Book Class information"
def __init__(self, author, title):
self.author = author
self.title = title
"Function to dsiplay the book author and title"
def... | true |
d5ed2a5b8c599a693c41178f7096995589fa4dc0 | s290717997/Python-100-Days | /day1-15/day7/day7_5.py | 657 | 4.25 | 4 | #练习5:计算指定的年月日是这一年的第几天
days_of_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
def if_leap_year(year):
if year % 400 == 0 or year % 4 == 0 and year % 100 != 0:
return True
else:
return False
def which_day(year, month, day):
sum = 0
for i in range(1, month):
sum += da... | true |
e2defc1b4568b4f52e7c4ac3249d6a67e17275b6 | Krashex/pl | /Chapter5/DaddyChooseGame.py | 2,264 | 4.53125 | 5 | pairs = {'Oleg': 'Petr',
'Artur': 'Denis',
'Ivan': 'Petr'}
choice = None
print("""
Type 1 - if you want to know smb's father's name
Type 2 - if you want to add new pairs
Type 3 - if you want to remove sm pair
Type 4 - if you want to chang... | true |
632144ea0c2dc95a6a87d20d642528339be71a52 | wilcerowii/mtec2002_assignments | /class10/labs/exceptions.py | 1,367 | 4.21875 | 4 | """
exceptions.py
=====
To handle errors, use a try/catch block:
-----
try:
# do your stuff
except SomeError:
# deal with some error
-----
optionally... you can continue catching more than one exception:
-----
.
.
except AnotherError:
# deal with another error
-----
Substitute SomeError with the kind of error yo... | true |
90952d5c964ca74bb1c221b4cf93395799f1f564 | jbrownxf/mycode | /wk1proj/gotime2 | 1,544 | 4.1875 | 4 | #!/usr/bin/env python3
#imports
import random
#This is a board game. Every player rolls a dice from 1-12 first to 100 wins
#By Josh Brown
from random import randint
#ask for number of players, creates a dic for every player
num_player = input("How many will be playing Dicequest?(2-6 players) ")
num_players =int(num... | true |
f745f56706575fc6f3e565b026029103c51cca4a | adnanhanif793/Python-Codes | /Basic/com/Anagram.py | 448 | 4.1875 | 4 | '''
Created on 18-Mar-2019
@author: adnan.hanif
'''
def check(s1, s2):
# the sorted strings are checked
if(sorted(s1)== sorted(s2)):
print("The strings are anagrams.")
else:
print("The strings aren't anagrams.")
# driver code
n=int(input... | true |
3043d49c09e87ff59adc9386745996dbfeccf057 | jonalynnA-cs29/Intro-Python-I | /src/05_lists.py | 2,269 | 4.53125 | 5 | # For the exercise, look up the methods and functions that are available for use
# with Python lists.
'''
Python List append()
Add a single element to the end of the list
Python List extend()
Add Elements of a List to Another List
Python List insert()
Inserts Element to The List
Python List remove()
Removes item fro... | true |
698c957da6315ef6124c57ca3b22aa7a6776df0b | nshattuck20/Data_Structures_Algorithms1 | /ch9/9-1.py | 630 | 4.59375 | 5 | '''
Section 9-1:
Recursive Functions
'''
#Example of recursive function
#I used the code from the animation example in the course material
def count_down(count):
if count == 0:
print('Go!')
else:
print(count)
count_down(count -1)
count_down(2) # recursively call count_down 3 tim... | true |
efcb7864f7ec7260c361402910aea5a5b9cbb091 | nshattuck20/Data_Structures_Algorithms1 | /ch8/8-6.py | 347 | 4.46875 | 4 | '''
8-6 List Comprehensions:
Form:
new_list = [expression for name in iterable]
3 components:
1. The expression to evaluate each iterable component
2. A loop variable to bind to the components
3. An iterable object
'''
#Example
my_list = [5, 10, 15]
my_list_plus5 = [(i + 5) for i in my_list]
print('New list... | true |
17786b5a311cfbb8e4c2e56f7bf0e9ce35e9269a | nshattuck20/Data_Structures_Algorithms1 | /ch9/9-5-1.py | 874 | 4.40625 | 4 | '''
9-5-1
Write a program that outputs the nth Fibonacci number, where n is a
user-entered number. So if the user enters 4, the program should
output 3 (without outputting the intermediate steps).
Use a recursive function compute_nth_fib that takes n as
a parameter and returns the Fibonacci number.
The function ha... | true |
148c9c7ffecb1938db146f2c7e263e82bdfb741e | nshattuck20/Data_Structures_Algorithms1 | /Chapter4/4.9/dictionary_basics.py | 451 | 4.34375 | 4 | '''
Simple program demonstrating the basics of Dictionaries.
'''
players = {'Lionel Messi' : 10,
'Cristiano Ronaldo' : 7
}
print(players)
#Accessing an entry uses brackets [] with the specified key
print('The value of this player is :' + str(players['Cristiano Ronaldo']))
#Editing the value of an entry ... | true |
1fa915224e3880af57d0012bd843a6d76dc184ad | nshattuck20/Data_Structures_Algorithms1 | /ch7/7-7.py | 1,097 | 4.71875 | 5 | '''Class customization
* Referes to how classes can be altered by rhe
programmer to suit her needs.
* _str_() changes how to print the output of an object
'''
class Toy:
def __init__(self, name, price, min_age):
self.name = name
self.price = price
self.min_age = min_age
truck = Toy('Monster Truck ... | true |
906a5fdf384a4825b3cfa126777f35b9d1cb0b4c | mattprodani/letter-box | /Dictionary.py | 1,049 | 4.15625 | 4 | class Dictionary():
def __init__(self, dictionary, gameboard):
""" Builds a dictionary object containing a list of words as well as groups them into a Dictionary
separated by starting letter, where starting letters are in gameboard.
"""
wordList = []
self.wordGroups = {}
... | true |
e0638d35fea87b4176d06cc0e33f136a805b7554 | CB987/dchomework | /Python/Python104/blastoff3.py | 237 | 4.1875 | 4 | # countdown that asks user where to start
n = int(input("From what number should start our countdown?")) #getting user input
while n >= 0: #setting end condition
print(n) #instructing to print number
n -=1 #incrementing downwards | true |
59c6d6de128a455c43a756ff527d25ce053e15ca | CB987/dchomework | /Python/Python104/blastoff2.py | 365 | 4.4375 | 4 | # create a countdown from 10 to 0, then prints a message
n = 10 #start point of countdown
while n >= 0: # set duration of countdown
print(n) #printing the number
n -=1 #Incrementing down, sends back up to print. loops until condition is false
if n < 0: #instructing when to print the message
print("M... | true |
f675d32ecf2cf6d0afef4b975674d4adfdfd0bb2 | alisheryuldashev/playground | /Python/classes.py | 780 | 4.4375 | 4 | #this snippet shows how to create a class in Python.
#this program will prompt for information, append same into a class, and output a message.
#create a class called Student
class Student:
def __init__(self,name,dorm):
self.name = name
self.dorm = dorm
#import custom functions from CS50... | true |
d56bdfbf76c0cbbce6c42a98844db12474e9c51b | Sandhie177/CS5690-Python-deep-learning | /ICP3/symmetric_difference.py | 610 | 4.28125 | 4 | # -*- coding: utf-8 -*-
#A={1,2,3,4}
#B={1,2}
def list1():
n=eval(input("How many numbers do you have in the list?")) #takes number of elements in the list
i=0
list1={0} #creating an empty set
list1.remove(0)
for i in range(n):
x=int(input("enter a number\n"))
list1.add(x) #adding ne... | true |
015efad385e902e83ba1d21e2e4e7bf86d29a5a2 | Sandhie177/CS5690-Python-deep-learning | /Assignment_1/Assignment_1c_list_of_students.py | 1,271 | 4.4375 | 4 | #Consider the following scenario. You have a list of students who are attending class "Python"
#and another list of students who are attending class "Web Application".
#Find the list of students who are attending “python” classes but not “Web Application”
#function to create list
def list1():
n=eval(input("Studen... | true |
5c267a5620aa7a658ccdb79e677f3998207756a3 | sciencefixion/HelloPython | /Hello - Basics of Python/sliceback.py | 857 | 4.28125 | 4 | letters = "abcdefghijklmnopqrstuvwxyz"
backwards = letters[25:0:-1]
print(backwards)
backwards2 = letters[25::-1]
print(backwards2)
# with a negative step the start and stop defaults are reversed
backwards3 = letters[::-1]
print(backwards3)
# Challenge: Using the letters string add some code to create the following ... | true |
4b1b47754908d1408d23be833869d656231ec113 | casanova98/Project-201501 | /Practical one/q1_fahrenheit_to_celsius.py | 232 | 4.21875 | 4 |
#q1_fahrenheit_to_celsius.py
answer = input("Enter the temperature you want in Celsius!")
x = float(answer)
celsius = round((5/9) * (x - 32), 1)
print("The temperature from Fahrenheit to Celsius to 1 decimal place is", celsius)
| true |
9d2ef8e3764b1709b9dfcbf68bb4af5bd4b64eae | casanova98/Project-201501 | /Practical two/q08_top2_scores.py | 552 | 4.125 | 4 |
students = int(input("Enter number of students: "))
names = []
score = []
while students != 0:
names.append(str(input("Enter your name: ")))
score.append(int(input("Enter your score: ")))
students -= 1
highest = max(score)
print("Student with highest score is:", names[score.index(highest)], "with ... | true |
783d04424384829bec20a0b6d4dddca93f46e3ae | Smily-Pirate/100DaysOfCode | /Day1.py | 971 | 4.125 | 4 | # Day1 of 100 days of coding.
# Starting from list.
# Accessing Values in Lists.
list1 = ['hi', 'there', 18, 1]
list2 = [1, 2, 3, 4, 5, 6, 7, 8]
print(list1[0])
print(list2[2])
# Updating list
list1[0] = 'ghanshyam'
list1[1] = 'joshi'
list2[7] = 'hi'
print(list1)
print(list2)
list1.append('10')
print(list1)
# Delet... | true |
49ba616fc87d3f9287ef22e444a7b872839f1aa7 | Akshay-Chandelkar/PythonTraining2019 | /Ex21_Arthimetic.py | 1,458 | 4.125 | 4 |
print("Free fall code to begin")
def add(num1,num2):
sum = num1 + num2
print("The sum of two numbers is : ", sum)
def sub(num1,num2):
sub = num2 - num1
print("The difference between the two numbers is : ", sub)
def mul(num1,num2):
mul = num1 * num2
print("The multiplication of t... | true |
c57f2c473a90a15353b101a8bd2e6b8f4031ceb3 | Akshay-Chandelkar/PythonTraining2019 | /Ex64_Stack_List.py | 2,492 | 4.125 | 4 | def IsStackFull(L1):
if IsStackEmpty(L1):
print("\nThe stack is empty.\n")
elif len(L1) >= 6:
return True
else:
print("\nThe stack is not full.\n")
def IsStackEmpty(L1):
if L1 == []:
return True
else:
return False
def Push(L1):
if not IsSt... | true |
d8dc56075b59c4790ef758177723e44a2b09bf8f | vonnenaut/coursera_python | /7 of 7 --Capstone Exam/probability.py | 854 | 4.21875 | 4 | # Fundamentals of Computing Capstone Exam
# Question 12
def probability(outcomes):
""" takes a list of numbers as input (where each number must be between 1 and 6 inclusive) and computes the probability of getting the given sequence of outcomes from rolling the unfair die. Assume the die is rolled exactly the number o... | true |
56555a338b03786e7de3d8cd5546f8d3b5f65158 | vonnenaut/coursera_python | /7 of 7 --Capstone Exam/pick_a_number.py | 1,280 | 4.15625 | 4 | # Fundamentals of Computing Capstone Exam
# Question 17
scores = [0,0]
player = 0
def pick_a_number(board):
""" recursively takes a list representing the game board and returns a tuple that is the score of the game if both players play optimally by choosing the highest number of the two at the far left and right edg... | true |
dcceddfae83a164aeae8bfa0fdb6177fad4b90de | vonnenaut/coursera_python | /2 of 7 -- Intro to Interactive Programming with Python 2/wk 6/quiz_6b_num8.py | 2,021 | 4.34375 | 4 | """
We can use loops to simulate natural processes over time. Write a program that calculates the populations of two kinds of “wumpuses” over time.
At the beginning of year 1, there are 1000 slow wumpuses and 1 fast wumpus. This one fast wumpus is a new mutation. Not surprisingly, being fast gives it an advantage, as... | true |
c9d3d1735eadee86c6601193da7690ed39d6e472 | 777shipra/dailypython | /assignment_acadview/question_9.py | 255 | 4.125 | 4 | sentence=raw_input("enter your sentence :")
uppercase_letters=0
lowercase_letters=0
for x in sentence:
if x.isupper():
uppercase_letters +=1
elif x.islower():
lowercase_letters +=1
print uppercase_letters
print lowercase_letters
| true |
b67904bd5415cde5c5ddc1a4e1cb121c47778274 | 777shipra/dailypython | /enumerate.py | 261 | 4.25 | 4 | choices=['pizza','ice','nachos','trigger']
for i,item in enumerate(choices):
print i,choices #prints the whole list
print i,item #prints the content of the list
for i,items in enumerate (choices,1):
print i,items #begins the itteration from index 1
| true |
c222489968812c65d58847cbe1b7780f9f620b4c | elormcent/centlorm | /conditional.py | 542 | 4.21875 | 4 | i = 6
if(i % 2 == 0):
print ("Even Number")
else:
print ("Odd Number")
def even():
number = int(input("Enter a whole number :- "))
if (number > 0 % 2 == 0):
print("It\'s an even number, nice work")
elif (number > 0 % 2 == 1):
print("it\'s an odd number, good job")
elif (number ... | true |
e40b81ba5afa39fdfe0b6384a5802695f53b1662 | olivianauman/programming_for_informatics | /untitled-2.py | 995 | 4.40625 | 4 | # turtle trys
import turtle # set window size
turtle.setup(800,600)
# get reference to turtle window
window = turtle.Screen()
# set window title bar
window.title("making a shape")
# set background color
window.bgcolor('purple')
the_turtle = turtle.getturtle()
# default turtle # 3 attributes: positioning... | true |
a4c327eb87a6b535eeb6a6750f86279eedf0b16b | peterlulu666/CourseraStartingWithPython | /Assignment 4.6.py | 1,064 | 4.4375 | 4 | # 4.6 Write a program to prompt the user for
# hours and rate per hour using input to
# compute gross pay. Pay should be the
# normal rate for hours up to 40 and time-and-a-half
# for the hourly rate for all hours worked above 40 hours.
# Put the logic to do the computation of pay in a function
# called computepay() an... | true |
43141dce566e017494468bec1d4ff2d904f45477 | RekidiangData-S/SQLite-Project | /sqlite_App/app.py | 751 | 4.15625 | 4 | import database
#database.create_db()
def main():
print("""
WELCOME TO STUDENTS DATABASE
############################
Select Operation :
(1) for create Table
(2) for Add Record
(3) for Show Records
(4) for Delete Records
(5) for Records Selection
""")
operation = input("Enter your ... | true |
d13dcf6e579b458d12f013700eb760936d9f2e4c | cubicova17/Python_scripts | /fib.py | 936 | 4.21875 | 4 | #-------------------------------------------------------------------------------
# Name: module1
# Purpose: FibNumbers
#
# Author: Dvoiak
#
# Created: 07.10.2014
# Copyright: (c) Dvoiak 2014
# Licence: <your licence>
#-------------------------------------------------------------------------------... | true |
b882a6c8f38065b75d2fdeff2c640cc84ac731f4 | kimchison/HardWay | /ex30.py | 424 | 4.125 | 4 | people = 20
cars = 40
buses = 50
if cars > people:
print "We should take the cars..."
elif cars < people:
print "We should not take the cars..."
else:
print "We can't decide."
if buses > cars:
print "Thats too many buses"
elif buses < cars:
print "Maybe we could take the buses"
else:
print "We still can't deci... | true |
576672d0fdacac1002b6d96deed88c7ada514fd4 | mschruf/python | /division_without_divide_operation.py | 1,493 | 4.3125 | 4 | def divide(numerator, denominator, num_decimal_places):
"""Divides one integer by another without directly using division.
Args:
numerator: integer value of numerator
denominator: integer value of denominator
num_decimal_places: number of decimal places desired in result
Returns:
... | true |
e366ffbd98c7cf6e860489e91b1f07457695b5ab | KishenSharma6/SF-Airbnb-Listings-Analysis | /Project_Codes/03_Processing/Missing_Stats.py | 1,102 | 4.15625 | 4 | import pandas as pd
import numpy as np
def missing_calculator(df,data_type = None):
"""
The following function takes a data frame and returns a dataframe with the following statistics:
data_type takes a string or list of strings referenceing data type
missing_count: Number of missing values per... | true |
320c5067f7607baedb6009db27bca5f99e60b74e | muralimandula/cspp1-assignments | /m7/p3/Functions - Assignment-3/assignment3.py | 1,521 | 4.125 | 4 | """
A program that calculates the minimum fixed monthly payment needed
in order pay off a credit card balance within 12 months
using bi-section method
"""
def payingdebt_offinayear(balance, annual_interestrate):
""" A function to calculate the lowest payment"""
def bal_d(balance, pay, annual_interestrate):
... | true |
7d25fca29ef23d397b784da8567293279cf4d0ca | alvinuy1110/python-tutorial | /oop/basic.py | 867 | 4.40625 | 4 | #####
# This is the OOP tutorial
#####
title = "OOP Tutorial"
print(title)
# Basic class
print("\nBasic Class\n")
# class definition
class A():
# constructor
def __init__(self):
print("classA initialized")
# constructor
def __init__(self, name=None):
print("classA initialized")
... | true |
2aaad3f3fe4b0a57e481f2b752266a7dc636a6e3 | alvinuy1110/python-tutorial | /loop/loop.py | 809 | 4.4375 | 4 | #####
# This is the Looping tutorial
#####
title = "Looping Tutorial"
print(title)
# Looping
print("\n\nLooping\n\n")
myMap = {"key1": "value1", "key2": 1234}
print(myMap)
# print the entries
print("\nKey-Value\n")
for k, v in myMap.items():
print(k, v)
# loop with the index
print("\nIndex-Value\n")
for (i, v) i... | true |
c115a55e98a112cbd4f2170590cfbbb219c9720a | cal1log/python | /tuples.py | 243 | 4.125 | 4 | #!/usr/bin/env python3
'''creating a tuple'''
tup = (10, 20, 30, 40)
'''getting a tuple index value'''
print(tup[2])
'''impossible to change values in a tuple'''
try:
tup[2] = 60
except:
print("a tuple can not changes your values")
| true |
69b832863c278164de52ef419b82d3c4d5bee86d | sudhanvalalit/Koonin-Problems | /Koonin/Chapter1/Exercises/Ex5.py | 1,427 | 4.1875 | 4 | """
Exercise 1.5: Write programs to solve for the positive root of x^2-5 using the Newton-Raphson
and secant methods. Investigate the behavior of the latter with changes in the initial guesses
for the root.
"""
import numpy as np
from scipy.misc import derivative
tolx = 1e-6
def f(x):
return x**2 - 5.0
def Ne... | true |
02774b2a40e58bf843a661fde07fc87b91bcdabd | Scientific-Computing-at-Temple-Physics/prime-number-finder-Scadow121 | /primes.py | 1,479 | 4.25 | 4 | # This is a comment. Python will ignore these lines (starting with #) when running
import math as ma
import time
# To use a math function, write "ma." in front of it. Example: ma.sin(3.146)
# These functions will ask you for your number ranges, and assign them to 'x1' and 'x2'
x1 = raw_input('smallest number to ch... | true |
3b7ec7522103f8d09d04e3955ffc1167c1aca47d | abdulwasayrida/Python-Exercises | /Exercise 6.18.py | 569 | 4.21875 | 4 | #Exercise 6.18
#Display a matrix of 0s and 1s
#Rida Abdulwasay
#1/12/2018
def printMatrix(n): #Create a function
from random import randint
for side1 in range (n):
for side2 in range (n):
print(randint(0, 1), end=" ") #randint generates the random number sequence
print(" ")
... | true |
e65af2007a3a9096a6dc4569338d5b84aa4e93fa | abdulwasayrida/Python-Exercises | /RegularPolygon.py | 1,418 | 4.3125 | 4 | #Exercise 7.5
#Geometry: n-sided regular polygon
#Rida Abdulwasay
#1/14/2018
import math
#Create a Class named RegularPolygon
class RegularPolygon:
def __init__(self, n = 3, side = 1, x = 0, y = 0):
self.__n = n
self.__side = side
self.__x = x
self.__y = y
#Create a function to t... | true |
e6a084c2bf6c0c34e3ffcd81ec94d893412a74db | chengming-1/python-turtle | /W7/lab-7/names.py | 612 | 4.1875 | 4 |
# Create an empty dictionary
names = {}
names['Wash'] = 'Rick'
names['Geier'] = 'Caitlin'
names['DiLisio'] = 'Armand'
names['wang']='chengming'
a = input("Enter the last name of a student: ")
b = input("Enter the First name of a student: ")
names[a]=b
while True:
last_name = input("Enter a stude... | true |
09b19aa33e576b71a463bd1aced49b14e2e0d74b | lebuingockhang123/L-p-tr-nh-python | /LeBuiNgocKhang_53157_CH03/Exercise/page_85_exercise_04.py | 657 | 4.125 | 4 | """
Author: Le Bui Ngoc Khang
Date: 12/07/1997
Problem: Assume that the variables x and y refer to strings. Write a code segment that prints these strings in
alphabetical order. You should assume that they are not equal.
Solution:
The sorted words are:
bui
khang
le
ngoc
"""
# Program to sort alphabetically the wor... | true |
53878427622bba5b8e795204524588c123540e36 | lebuingockhang123/L-p-tr-nh-python | /LeBuiNgocKhang_53157_CH06/Projects/page_203_exercise_02.py | 719 | 4.25 | 4 | """
Author: Le Bui Ngoc Khang
Date: 12/07/1997
Program: Convert Newton’s method for approximating square roots in Project 1 to a recursive function named newton.
(Hint: The estimate of the square root should be passed as a second argument to the function.)
Solution:
2.0000000929222947
"""
approximating = 0.000001
... | true |
34df6e92f6125e3408e46221b645c44b2855e728 | lebuingockhang123/L-p-tr-nh-python | /LeBuiNgocKhang_53157_CH06/Exercise/page_182_exercise_02.py | 569 | 4.21875 | 4 | """
Author: Le Bui Ngoc Khang
Date: 12/07/1997
Program: The factorial of a positive integer n, fact(n), is defined recursively as follows:
fact(n) = 1 , when n = 1
fact(n) n * fact (n-1) , otherwise
Define a recursive function fact that returns the factorial of a given positive integer
Solution:
Ent... | true |
81125a2c8610d4531755bb4a53cb19aa3d946c96 | lebuingockhang123/L-p-tr-nh-python | /LeBuiNgocKhang_53157_CH04/Projects/page_132_exercise_02.py | 640 | 4.40625 | 4 | """
Author: Le Bui Ngoc Khang
Date: 12/07/1997
Program: Write a script that inputs a line of encrypted text and a distance value and outputs plaintext using a
Caesar cipher. The script should work for any printable characters
Solution:
Enter the coded text: khoor#zruog
Enter the distance value: 3
hello world
"""
# R... | true |
7a5c1a0d7c416a8f88934c5b6daecb4c36fefa45 | lebuingockhang123/L-p-tr-nh-python | /LeBuiNgocKhang_53157_CH06/Projects/page_204_exercise_09.py | 623 | 4.125 | 4 | """
Author: Le Bui Ngoc Khang
Date: 12/07/1997
Program: Write a program that computes and prints the average of the numbers in a text
file. You should make use of two higher-order functions to simplify the design.
Solution:
Enter the file name: textnumber.txt
The average is 3.0
"""
def main():
fileName = input(... | true |
47c65a3c577e406863dba437b479719540e39061 | lebuingockhang123/L-p-tr-nh-python | /LeBuiNgocKhang_53157_CH03/Projects/page_99_exercise_02.py | 1,005 | 4.3125 | 4 | """
Author: Le Bui Ngoc Khang
Date: 12/07/1997
Problem: Write a program that accepts the lengths of three sides of a triangle as inputs. The program output should
indicate whether or not the triangle is a right triangle. Recall from the Pythagorean theorem that in a right triangle,
the square of one side equals the sum... | true |
6873aa32b9630205bbc7475864686dd85187beaa | lebuingockhang123/L-p-tr-nh-python | /LeBuiNgocKhang_53157_CH04/Projects/page_132_exercise_06.py | 1,004 | 4.375 | 4 | """
Author: Le Bui Ngoc Khang
Date: 12/07/1997
Program: Use the strategy of the decimal to binary conversion and the bit shift left operation defined in Project 5
to code a new encryption algorithm. The algorithm should add 1 to each character’s numeric ASCII value, convert
it to a bit string, and shift the bits of thi... | true |
81627d0a80c0c03f3027ff7296a3638a447c37e7 | lebuingockhang123/L-p-tr-nh-python | /LeBuiNgocKhang_53157_CH04/Projects/page_133_exercise_09.py | 941 | 4.21875 | 4 | """
Author: Le Bui Ngoc Khang
Date: 12/07/1997
Program: Write a script named copyfile.py. This script should prompt the user for the names of two text files.
The contents of the first file should be input and written to the second file.
Solution:
Enter the input file name: test9.txt
Enter the output file name: test9_... | true |
fc90debc52d5f84e0d03ab770ba10746405d657f | lebuingockhang123/L-p-tr-nh-python | /LeBuiNgocKhang_53157_CH07/Exercise/page_218_exercise_03.py | 480 | 4.46875 | 4 | """
Author: Le Bui Ngoc Khang
Date: 12/07/1997
Program: Add a function named circle to the polygons module. This function expects the same arguments as the square
and hexagon functions. The function should draw a circle. (Hint: the loop iterates 360 times.)
Solution:
"""
import turtle
def polygon(t, length, n):
... | true |
26ce3efa3df58e629c706ad5da9b8457ba0e9d52 | lebuingockhang123/L-p-tr-nh-python | /LeBuiNgocKhang_53157_CH06/Exercise/page_199_exercise_02.py | 317 | 4.21875 | 4 | """
Author: Le Bui Ngoc Khang
Date: 12/07/1997
Program: Write the code for a filtering that generates a list of the positive numbers in a list
named numbers. You should use a lambda to create the auxiliary function.
Solution:
[1, 79]
"""
numbers = [1, -2, -66, 79]
result = list(filter(lambda x: x > 0, numbers))
print... | true |
5c5fc3250152575883481aca9ee77e0a632f7c95 | Dukiemar/RSA-Encryption | /RSA_Encryption.py | 2,632 | 4.34375 | 4 | import random
def PGP_encryption():
p=input("enter the 1st prime number:")#prompts the user to enter the value for p
q=input("enter the 2nd prime number:")#prompts the user to ented the value for q
message=input("enter message:")
def isPrime(n): #this function ristricts the user to only enter p... | true |
f7df966b90cd84cadf6805203d190df700a58f9f | prastabdkl/pythonAdvancedProgramming | /chap7lists/plotting/sec5piechart.py | 511 | 4.25 | 4 | # plotting a Piechart
# Author: Prastab Dhakal
# Chapter: plotting
import matplotlib.pyplot as plt
def main():
#create a list of values
values=[20,60,80,40]
#title
plt.title("PIE CHART")
#create a list of labels for the slices.
slice_labels=['1st Qtr','2nd Qtr','3rd Qtr','4th Qtr']
... | true |
941f9950cf21e526a0cb8c50feb2a553d6e5d4c3 | prastabdkl/pythonAdvancedProgramming | /chap6FilesAndException/others/save_file_records.py | 2,541 | 4.125 | 4 | # This program gets employee data from the user and
# saves it as records in the employee.txt file.
# read the records and show until the end is reached handles the value errors,
# read file error and searches the file until the end is reached
#
# Author: Prastab Dhakal
# Chapter: Files and Exception(Complex problem)... | true |
d5fc347cad1f2a3a1cd26cab15653aea5f9bb986 | rodri0315/pythonCSC121 | /chapter3/area_of_rectangles.py | 966 | 4.59375 | 5 | # Chapter 1 Assignment
# Author: Jorge Rodriguez
# Date: February 5, 2017
print('You will enter the length and width for two rectangles')
print('The program will tell you which rectangle has the greater area')
# get length and width of 2 rectangles
rect_length1 = float(input('Enter the length of the first rectangle: '... | true |
fab42d2bbb28bff895054c136584314f4091fb20 | xis24/CC150 | /Python/FreqOfMostFrequentElement.py | 965 | 4.25 | 4 | from typing import List
class FreqOfMostFrequentElement:
'''
The frequency of an element is the number of times it occurs in an array.
You are given an integer array nums and an integer k. In one operation, you can choose an index of nums and increment the element at that index by 1.
Return the maxim... | true |
29108375b2c46d239764d70dd6b7fc4416c5e89d | xis24/CC150 | /Python/SortColors.py | 931 | 4.15625 | 4 | from typing import List
class SortColors:
# 1. discuss the approach
# 2. run the test case
# 3. ask if I can start to code
# 4. start to code
# 5. run test case with code
# 6. time complexity and space complexity
def sortColors(self, nums: List[int]) -> None:
zeros = 0 # positio... | true |
2d8c9ba19b177f95ecf6e65da4c5a5c353390d42 | travisthurston/OOP_example | /Card.py | 549 | 4.125 | 4 | #Card class is a blueprint of the card object
#This is the parent or base class for Minion
class Card:
#initializer to create the attributes of every class object
def __init__(self, cost, name):
self.cost = cost
self.name = name
#attributes - argument - parameter - describes the object
... | true |
4a2186d1443b1dcba7bd4a02c93afe9cb55e4855 | Ustabil/Python-part-one | /mini_projects/guess_the_number/guess_the_number.py | 2,497 | 4.28125 | 4 | # template for "Guess the number" mini-project
# input will come from buttons and an input field
# all output for the game will be printed in the console
#Codeskulptor URL: http://www.codeskulptor.org/#user40_06oB2cbaGvb17j2.py
import simplegui
import random
current_game = 0
# helper function to start and restart t... | true |
4523e4efe62db4005d9e09b9fa8e5f20b548ef81 | grebwerd/python | /practice/practice_problems/shortestPath.py | 1,021 | 4.15625 | 4 | def bfs_paths(graph, start, goal):
queue = [(start, [start])] #queue is a list made up of a tuple first tuple is a start and the second tuple is a list
while queue:
(vertex, path) = queue.pop(0)
for next in graph[vertex] - set(path): #for each next adjacency node not in the set already
... | true |
befb06130ebf46def192f3a33c799e7139303290 | abaker2010/python_design_patterns | /decorator/decorator.py | 861 | 4.125 | 4 | """
Decorator
- Facilitates the addition of behaviors to individual objects without
inheriting from them
Motivation
- Want to augment an object with additional functionality
- Do no want to rewrite or alter existing code (OCP)
- Want to keep new functionality separate (SRP)
- Need to be able to interact with existin... | true |
69ceec17993f350329a7f6214657fc9aae84ef1a | Zolton/Sprint-Challenge--Algorithms | /recursive_count_th/count_th.py | 806 | 4.21875 | 4 | '''
Your function should take in a single parameter (a string `word`)
Your function should return a count of how many occurences of
***"th"*** occur within `word`. Case matters.
Your function must utilize recursion. It cannot contain any loops.
'''
test = "THtHThth"
test2 = "abcthefthghith"
test3 = "abcthxyz"
count = ... | true |
7c2549bcb4f95d76184c334a4968773a0ab7e500 | Zchhh73/Python_Basic | /chap6_struct/struct_break_continue.py | 208 | 4.15625 | 4 | for item in range(10):
if item == 3:
break
print('Count is : {0}'.format(item))
print('\n')
for item in range(10):
if item == 3:
continue
print('Count is : {0}'.format(item)) | true |
4b1bb8a4e501b50680d29d4688405b1a5c0f8bf4 | mgtz505/algorithms | /implementations/sorting_algorithms/quicksort.py | 518 | 4.15625 | 4 | print("Implementation of Quicksort")
test_data = [3,11,4,0,7,2,12,7,9,6,5,10,3,14,8,5]
def quickSort(N):
length = len(N)
if length <= 1:
return N
else:
larger, smaller = [], []
pivot = N.pop()
for num in N:
if num < pivot:
smaller.append(num)
... | true |
3e36b2f72dbe1c248365e51566f81a21e6e18b3e | alex-mucci/ce599-s17 | /18-Design and Classes/Car.py | 2,655 | 4.4375 | 4 | #constansts
START_NORTH = 0
START_SOUTH = 0
START_EAST = 0
START_WEST = 0
# Define the class
class Car(object):
"""
Base class for a car
"""
def __init__(self, color,location = [0,0],direction = 'N'):
if len(location) < 2 or len(location) > 2:
print('location is the x,y coordina... | true |
8969c70857b05f92b3cec8f3339bb543498b39e3 | kolevatov/python_lessons | /simple_object.py | 550 | 4.15625 | 4 | # Simple object
class Simple(object):
"""Simple object with one propertie and method"""
def __init__(self, name):
print("new object created")
self.__name = name
def __str__(self):
return "Simple object with name - " + self.__name
@property
def name(self):
return sel... | true |
ef5efede1db142e41aba118dc0d78efa371ad209 | vishnuk1994/ProjectEuler | /SumOfEvenFibNums.py | 1,045 | 4.46875 | 4 | #!/bin/python3
import sys
# By considering the terms in the Fibonacci sequence whose values do not exceed N, find the sum of the even-valued terms.
# creating dict to store even fib nums, it helps in reducing time at cost of extra space
# by rough estimate; it is better to use space as for high value of n, it will re... | true |
f2c0bda23f4292e676e3d246d28f6f158145f7e9 | ibbur/LPTHW | /16_v4.py | 1,017 | 4.25 | 4 | print "What file would you like to open?"
filename = raw_input("> ")
print "Opening the file %r for you..." % filename
review = open(filename)
print review.read()
target = open(filename, 'w')
print "\n"
print "I will now clear the file contents..."
target.truncate()
print "I will now close the file..."
target.clos... | true |
3dc2910eea2580527783d8e35114c110e44b3f11 | GanSabhahitDataLab/PythonPractice | /Fibonacci.py | 661 | 4.3125 | 4 | # Find PI to the Nth Digit - Enter a number and have the program generate π (pi) up to
# that many decimal places. Keep a limit to how far the program will go
def fibonaccisequence_upton():
askForInput()
def askForInput():
n = int(input("Enter number of Fibonnacci sequence"))
fibgenerate... | true |
3865e1e3cf60023a368f629cb21a3b163d61fa59 | claudiamorazzoni/problems-sheet-2020 | /Task 6.py | 435 | 4.4375 | 4 | # Write a program that takes a positive floating-point number as input and outputs an approximation of its square root.
# You should create a function called sqrt that does this.
# Please enter a positive number: 14.5
# The square root of 14.5 is approx. 3.8.
import math
num = float(input("Please enter a posit... | true |
02a11bf65defec6e1280af02fabf2411dea09e85 | Nithinnairp1/Python-Scripts | /lists.py | 1,073 | 4.25 | 4 | my_list = ['p','r','o','b','e']
print(my_list[0])
print(my_list[2])
print(my_list[4])
print(my_list[-1])
n_list = ["Happy", [2,0,1,5]]
print(n_list[0][1])
print(n_list[1][3])
my_list = ['p','r','o','g','r','a','m','i','z']
# elements 3rd to 5th
print(my_list[2:5])
odd = [1, 3, 5]
odd.append(7)
print(... | true |
9e76ed8832052f6d5066700f222bea4d4df69b50 | TrihstonMadden/Python | /plot-dictionary.py | 1,226 | 4.125 | 4 | # plot-dictionary.py
import tkinter as tk
import turtle
def main():
#table is a dictionary
table = {-100:0,-90:10,-80:20,-70:30,-60:40,-50:50,
-40:40,-30:30,-20:20,-10:10,0:0,
10:10,20:20,30:30,40:40,50:50,
60:40,70:30,80:20,90:10,100:0,
}
print(" KEYS ")
print(table.keys())
print(" V... | true |
0cb9dbd2051790e0992b5a5c55456efe184911d3 | Jethet/Practice-more | /python-katas/EdabPalin.py | 778 | 4.3125 | 4 | # A palindrome is a word, phrase, number or other sequence of characters which
# reads the same backward or forward, such as madam or kayak.
# Write a function that takes a string and determines whether it's a palindrome
# or not. The function should return a boolean (True or False value).
# Should be case insensitive ... | true |
b447f6804b1aaf41f103aa9b75afd2814c207163 | Jethet/Practice-more | /small-projects/inverseRandNum.py | 720 | 4.21875 | 4 | import random
# instead of the computer generating a random number, the user is giving the number
def computer_guess(x):
low = 1
high = x
feedback = ""
while feedback != "c":
# you cannot have low and high be the same:
if low != high:
guess = random.randint(low, high)
... | true |
22800ea3b59510039284cf345034c94c1ee4b99a | Jethet/Practice-more | /python-katas/3_Sum.py | 239 | 4.1875 | 4 | # Return sum of two int, unless values are the same: then return double.
def sum_double(a, b):
if a == b:
return 2 * (a + b)
else:
return a + b
print(sum_double(1,2))
print(sum_double(3,2))
print(sum_double(2,2))
| true |
3f0aa8fd1025b9f1d919f544cbf78dbc91c44699 | Jethet/Practice-more | /python-katas/EdabAltCaps.py | 362 | 4.4375 | 4 | # Create a function that alternates the case of the letters in a string.
# The first letter should always be UPPERCASE.
def alternating_caps(txt):
print(alternating_caps("Hello")) # "HeLlO"
print(alternating_caps("Hey, how are you?")) # "HeY, hOw aRe yOu?"
print(alternating_caps("OMG!!! This website is awesome!... | true |
394c0e41664f79b95e279ff063f7584a49f675cf | Jethet/Practice-more | /python-katas/EdabCountUniq.py | 384 | 4.28125 | 4 | # Given two strings and a character, create a function that returns the total
# number of unique characters from the combined string.
def count_unique(s1, s2):
return len(set(s1 + s2))
print(count_unique("apple", "play")) #➞ 5
# "appleplay" has 5 unique characters:
# "a", "e", "l", "p", "y"
print(count_unique("so... | true |
e398b42c4309d60d59ea97a5e341532502fb0a1c | Jethet/Practice-more | /python-katas/EdabIndex.py | 686 | 4.375 | 4 | # Create a function that takes a single string as argument and returns an
# ordered list containing the indexes of all capital letters in the string.
# Return an empty array if no uppercase letters are found in the string.
# Special characters ($#@%) and numbers will be included in some test cases.
def indexOfCaps(wor... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.