blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
62c0eb6baa5ce9f8127352ec4e158d8787c897dc | arjungoel/Real-Python | /str_repr_2_demo.py | 500 | 4.375 | 4 | # __str__ vs __repr__
# __str__ is mainly used for giving an easy-to-read representation of your class.
# __str__ is easy to read for human consumption.
# __repr__ is umambiguous and the goal here to be as explicit as possible about what this object is and more meant
# for internal use and something that would make thi... | true |
217ce0434583b1cc99869a06e419f9f12a15e8f0 | knight-furry/Python-programming | /x-shape.py | 288 | 4.125 | 4 | num = input("Enter the odd digit number : ")
length = len(num)
if length % 2 != 0 :
for i in range(length):
for j in range(length):
if i==j or i+j==length-1 :
print (num[i],end=" ")
else:
print (" ",end=" ")
print ()
else:
print ("The number is NOT odd digit......!")
| true |
bdfe9405c236a02b47767da3d7cd5ccde339f1bb | knight-furry/Python-programming | /permit.py | 1,134 | 4.28125 | 4 | # Python 3 program to print all permutations with
# duplicates allowed using prev_permutation()
# Function to compute the previous permutation
def prevPermutation(str):
# Find index of the last element
# of the string
n = len(str) - 1
# Find largest index i such that
# str[i ? 1] > str[i]
i = n
whil... | true |
ed07a08f36e349ec938df07c2eb02aeafa32a043 | abvillain22/python | /SubFun.py | 239 | 4.25 | 4 | import re
str1="hello, welcome in the world of python"
pattern1="hi"
pattern2="hello"
print((re.sub(pattern2,pattern1,str1)))
#the sub fun in the re module can be used to search a pattern in the string and replace it with another string
| true |
71d2238b97e5836cc4429dd62c194e2ec34e6566 | 3228689373/excercise_projecteuler | /sum_of_mul_of_3or5.py | 487 | 4.125 | 4 | def sum_of_mul_of_3or5(n=1000):
'''
https://projecteuler.net/problem=1
If we list all the natural numbers below 10 that are multiples of 3 or 5,
we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
'''
arr = list(ran... | true |
c5a59b325a2b01ffccab8ccb84affa2246d2c038 | DracoHawke/python-assignments | /Assignment4/Assignment4.py | 2,024 | 4.5625 | 5 | import copy as c
# Q.1 - Reverse the whole list using list methods.
# A.1 ->
num = int(input("Enter the number of elements\n"))
print("Enter the elements")
list1 = []
for i in range(0, num):
ele = int(input())
list1.append(ele)
print(list1)
print("Reversed list is: ")
list1.reverse()
print(list1)
# Q.2 - Pri... | true |
069dc38c40f3a0223c8dd650c65a60ce172601e2 | HenrryHernandez/Python-Projects | /DataStructuresUdacity/Trees/tree order/binaryTree.py | 1,853 | 4.15625 | 4 | class Node:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
class BinaryTree:
def __init__(self, root):
self.root = root
self.nodes = ""
def search(self, find_val):
"""Return True if the value
is in the tree, return
... | true |
6c09b38d0502bdedee9dc1c42c890511f9d3a79f | RizkiAsmoro/python | /File-Handling/File_handling.py | 1,136 | 4.4375 | 4 | '''
"w" - Write
"r" - Read
"a" - Append
"x" - Create
"r+"- write and read mode
'''
#write mode 'w' - Opens a file for writing,
#creates the file if it does not exist
file = open("data.txt","w")
file.write("This is data text, created by python")
file.write("\nthis is 2nd row data text")
file.write("\nthis is 3rd ... | true |
42d5c1f18bbe06f5db0f414ead1e6f2cb789fd56 | RizkiAsmoro/python | /For_loop2.py | 1,434 | 4.125 | 4 | '''
FOR,Else Loop
Continue, pass
'''
# print range number
print(20*"=","RANGE")
for i in range(0,5):
print(i)
print(20*"=","range increment")
for i in range (10,30,5): #range 10 to 30, increment 5
print(i)
# For Else
print(20*"=","FOR ELSE")
number = 3
for i in range (1,6):
print(i) # print range number ... | true |
4ffe624d4ca2a7fc52fbf496a87a5036688cb5e6 | chiayinf/MastermindGame | /count_bulls_and_cows.py | 2,291 | 4.34375 | 4 | '''
CS5001
Spring 2021
Chiayin Fan
Project: A python-turtule built mastermind game
'''
def count_bulls_and_cows(secret_code, guess):
'''
function: count_bulls_and_cows: count how many black and red pegs the player has
parameters: secret_code: 4 colors secret code list
guess: 4 ... | true |
0630bc008d61731144e41d2da5a473b929530d3d | guyrux/udacity_statistics | /Aula 25.29 - Extract First Names.py | 322 | 4.46875 | 4 | '''
Quiz: Extract First Names
Use a list comprehension to create a new list first_names containing just the first names in names in lowercase.
'''
names = ["Rick Sanchez", "Morty Smith", "Summer Smith", "Jerry Smith", "Beth Smith"]
first_names = [name.lower().split()[0] for name in names] # write your list comprehens... | true |
996dbf33c8f16d6f99d714c49c9039af0d8f4514 | Potokar1/Python_Review | /sorting_algorithms/quick_sort.py | 2,546 | 4.3125 | 4 | # Select a pivot, which we will use to split the list in half by comparing every other number to the pivot
# We will end up with a left partition and a right partition. Best splits list in half
# This can be better if there is less than a certain amount of values, then we can use selection sort
# Helps the user by ju... | true |
8fc9d5a8e60bcac345468ed59382ee1848061d2b | Potokar1/Python_Review | /data_structures/stack_divide_by_two.py | 896 | 4.40625 | 4 | '''
Use a stack data structure to convert integer values to binary
Example: 242 (I learned this in class!) (bottom up of remainder is bin of 242)
remainder
242 / 2 -> 0
141 / 2 -> 1
60 / 2 -> 0
30 / 2 -> 0
15 / 2 -> 1
7 / 2 -> 1
3 / 2 -> 1
1 / 2 -> 1
'''
from s... | true |
9b2f97a9a34750879cde3e23fb3219211e31638f | Jcarlos0828/py4eCourses-excercisesCode-solved | /Using Databases with Python/Week 2/countEmailWithDB.py | 1,382 | 4.3125 | 4 | #Code Author: José Carlos del Castillo Estrada
#Excercise solved from the book "Python for Everybody" by Dr. Charles R. Severance
#Following the Coursera program "Using Databases with Python" by the University of Michigan
'''
Count the number of emails sent by each domain and order them in a DESC way.
The data extract... | true |
6542bb2afe9b53282b8276a06ef142874aaa8fb2 | marquesarthur/programming_problems | /leetcode/regex/mini_parser.py | 2,397 | 4.21875 | 4 | # """
# This is the interface that allows for creating nested lists.
# You should not implement it, or speculate about its implementation
# """
class NestedInteger(object):
def __init__(self, value=None):
"""
If value is not specified, initializes an empty list.
Otherwise initializes a single in... | true |
c4d0acf509af5620273ae604f23777776fc1baf9 | gcharade00/programs-hacktoberfest | /lenlist.py | 431 | 4.4375 | 4 | # Python code to demonstrate
# length of list
# using naive method
# Initializing list
test_list = [ 1, 4, 5, 7, 8 ]
# Printing test_list
print ("The list is : " + str(test_list))
# Finding length of list
# using loop
# Initializing counter
counter = 0
for i in test_list:
# incrementing counter
count... | true |
a8575326c07c78421ad1340f45c36b51958dc2a8 | drussell1974/a-level | /recursion/recursion_factorial.py | 437 | 4.28125 | 4 | def iterative_factorial(num):
factorial = 1
for x in range(1, num+1):
factorial = factorial * x
return factorial
def recursive_factorial(num):
if num < 2:
""" stop the recursion when num = 1 or less """
return 1
else:
""" recursive call """
return num * recur... | true |
c171054c698c293d887a043f832cca3323fe3518 | abaah17/Programming1-examples | /w12s1_rps.py | 1,617 | 4.53125 | 5 | # This example will show case various ways to create a rock paper scissors program
# using functions from the random library
# More information here:
from random import *
# In this approach, we pick a random number between 1 and 3, then connect each number with a
# move in an if statement:
def taiwo_bot():
x = ran... | true |
73cb2e4ada1d9727b65198ef1f7152adeda5067a | abaah17/Programming1-examples | /w7s1_string_demo.py | 1,173 | 4.21875 | 4 | alu_quote = "take ownership"
# Indexing into Strings
print(alu_quote[10])
# Length of String: len returns how many characters are in a string
# Think of a character as the act of typing a key. Spaces and punctuation are characters too!
print(len(alu_quote))
# Strings are immutable
# The following line will trigger a... | true |
aba6b636759d7bbd52f488da76d3307a72df5757 | perryriggs/Python | /mindstorms.py | 1,534 | 4.46875 | 4 | #mindstorms - from the book by the same name
import turtle
#define a function to draw a square
def draw_square(t):
x = 1
while x <= 4:
t.right(90)
t.forward(100)
x = x+1
# define a function to draw a circle
def draw_circle():
circ = turtle.Turtle()
circ.shape("arrow")
circ... | true |
d6674bf9af185d6ac97df47396f46ace4af3adef | dgranillo/Projects | /Classic Algorithms/sorting.py | 1,698 | 4.3125 | 4 | #!/usr/bin/env python2.7
"""
Sorting - Implement two types of sorting algorithms: Merge sort and bubble
sort.
Author: Dan Granillo <dan.granillo@gmail.com>
ToDo: Merge sort does not append remaining values from one half if the other's
counter has reached the limit. Generally 2nd half's last number is ommitted.... | true |
175c0fad6f626e3c813cf55450b581f73b660267 | dimaalmasri/pythonCodes | /Functions/built-in-functions.py | 1,918 | 4.40625 | 4 | """
This file contains some examples for built-in functions in python
they are functions that do certain things
I will explain
"""
#example 1 = .upper()
#added by @basmalakamal
str1 = "hello world"
print str1.upper()
#this how we use it and it is used to return the string with capital letters
#example 2 = isupper(... | true |
b45fcda91797777b337cf5e426cf5d225413662d | pythonshiva/Pandas-Ex | /Lesson5/lesson5.py | 485 | 4.53125 | 5 | #Stacking and unstacking functions
import pandas as pd
#Our small dataset
d = {'one':[1,1], 'two': [2,2]}
i = ['a', 'b']
#Form DataFrame
df = pd.DataFrame(data= d, index=i)
# print(df)
#Bring the column and place them in the index
stack = df.stack()
print(stack)
#now it became the multi level index
# print(stack.ind... | true |
21bec91a2b0ba523b2d99b1ed30d43a934709f91 | bc-maia/udacity_python_language | /A - Basics/10 - LambdaFilter.py | 808 | 4.40625 | 4 | # Quiz: Lambda with Filter
# filter() is a higher-order built-in function that takes a function
# and iterable as inputs and returns an iterator with the elements
# from the iterable for which the function returns True. The code
# below uses filter() to get the names in cities that are fewer than
# 10 characters long t... | true |
2526043e6fdc0407bb5746c00b1ca6b9c134e118 | prowrestler215/python-2020-09-28 | /week1/day2/afternoon/for_loop_basic_II.py | 1,097 | 4.15625 | 4 | # Ultimate Analysis - Create a function that takes a list and returns a dictionary that has the sumTotal, average, minimum, maximum and length of the list.
# Example: ultimate_analysis([37,2,1,-9]) should return {'sumTotal': 31, 'average': 7.75, 'minimum': -9, 'maximum': 37, 'length': 4 }
def ultimate_analysis(list_pa... | true |
6973aa76eff67755325892efe399c0454b22145b | danny237/Python-Assignment2 | /palindrome.py | 883 | 4.21875 | 4 | """ Program to check the given word is palindrome or not """
# check using reverse method
# def is_palindrome(str1):
# reverse_string = list(reversed(str1))
# if list(str1) == reverse_string:
# return True
# else:
# return False
def is_palindrome(str1):
"""
Function to check palin... | true |
ea7b1c878e51f549714901af7cda5cea24a4b5a3 | danny237/Python-Assignment2 | /valid_string_paren.py | 803 | 4.46875 | 4 | """Program to valid a string of parenthese."""
class Parenthese:
"""
Class for validating parenthese
Attribute:
str1(string): given parentheses
"""
def __init__(self, str1):
self.str1 = str1
def is_valid(self):
"""function that return True if valid parenthese"""
... | true |
7583c18f0bae28b4e05b3e677d30f1a295da24d6 | HenrikSamuelsson/exercism-python-track | /python/pangram/pangram.py | 859 | 4.15625 | 4 | import string
def is_pangram(sentence):
"""Check if all the characters in the alphabet (a - z) is used in a given sentence."""
# Convert the input to all lower case letters.
lower_case_sentence = sentence.lower()
# Get a list of all the ASCII lower case letters i.e. a-z.
all_lower_case_ascii_lett... | true |
c220c282db5e1453430dbcfd7843b1f8cebfc04e | morrisunix/python | /projects/list_overlap.py | 1,245 | 4.125 | 4 | from random import randint
def get_intersection(list_1, list_2):
""" Returns a new list with the intersecion of both lists
Parameters
----------
list_1: list
First given list
listd_2: list
Second given list
Returns
-------
list
The intersection list
"""
... | true |
48089f24a5b66de04df58c61d050b74171f986cc | Favi0/python-scripts | /MIT/ps1/ps1b.py | 834 | 4.3125 | 4 | portion_down_payment = 0.25
current_savings = 0
investment_return = 0.04
months = 0
annual_salary = float(input("Enter your annual salary: "))
portion_saved = float(input("Enter the percent of your salary to save, as a decimal: "))
total_cost = float(input("Enter the cost of your dream home: "))
semi_annual_raise ... | true |
58651ca614673607d7f6af83fd7c547f119a6d3a | srmcnutt/100DaysOfCode | /d8-caesar_cipher/main.py | 1,183 | 4.125 | 4 | # 100 days of code day 8 - Steven McNutt 2021
from resources import logo, alphabet
print(logo)
#super awesome ceasar cipher function w00t!
def caesar(text="foo", shift=0, direction = "e"):
transformed_text = ""
cipher_direction = "encode"
if direction[:1] == 'd':
cipher_direction = "decode"
shif... | true |
3760de65a11afb88923d8a409d9973994d94dccb | VishalGohelishere/Python-tutorials-1 | /programs/Conditionals.py | 243 | 4.25 | 4 | x=5
if x==5 :
print("Equals 5")
if x>4 :
print("Greater then 4")
if x>=5:
print("Greater then or equal to 5")
if x<6:
print("Less then 6")
if x<=5:
print("Less then or equal to 5")
if x!=6 :
print("Not equal to 6")
| true |
34bd49ebdd08097ee10ab002bdb93ce558efc45c | MariusArhaug/RPNCalculator | /container.py | 812 | 4.21875 | 4 | """Container superclass"""
from abc import ABC, abstractmethod
class Container(ABC):
"""
Super class for Queue and Stack
"""
def __init__(self):
self._items = []
def size(self):
"""
Get number of items
:return: int number of items
"""
return len(se... | true |
0ecc7fff80aba73ccf12bee5907d190ffcc200bc | Praveenstein/Intern_Assignment | /autocorrelation_for_all_lags.py | 1,482 | 4.59375 | 5 | # -*- coding: utf-8 -*-
""" Computing autocorrelation for a given signal
This script allows the user to compute the autocorrelation value
of a given signal for lags = 1, 2, 3.....N-2, where N is the length
of the signal
This file contains the following function:
* main - the main function of the script
... | true |
c2c3eb6e0230082565cd461d481464aaede738af | mt-digital/flask-example | /files_example.py | 957 | 4.3125 | 4 | '''
Run this like so:
python example.py
It will create a directory 'files_dir' if it
doesn't exist then put a new random text file in there.
The file name before ".txt" will be one greater
for each new file added to the files directory.
'''
import os
dirname = 'files_dir'
# Check if directory exists.
if not os.... | true |
b7ca9d69fe171766db59c39d846109d2b37659af | Faybeee/Session-2-homework | /session 2 task 3 homework.py | 1,599 | 4.375 | 4 | #Write a program which will ask for two numbers from a user.
#Then offer a menu to the user giving them a choice of maths operators.
#Once the user has selected which operator they wish to use,
# perform the calculation by using a procedure and passing parameters.
def procedure_a(first,second):
print(first +... | true |
6c5d690754798e80ef8d8a261700cca7eeb472ee | HamplusTech/PythonCodes2021Update | /AnswersToTask - Week 1 Task 1.py | 1,629 | 4.46875 | 4 | print("Answers to online task by Hampo, JohnPaul A.C.")
print()
print("Week 1 Answers")
print("Answer to last week's task No.1\
Hello Dear! Here is a little task for us in python.\
\
1] Write a program to find the sum of the data structure below\
[[1,2,3],[4,5,6,7],[8,9]]\
\
2] Write a program to convert... | true |
1aee7f38b51816f3cb4361cac64668722f39fbd9 | HamplusTech/PythonCodes2021Update | /AnswersToTask - Week 1 Task 2.py | 1,794 | 4.625 | 5 | print("Answers to online task by Hampo, JohnPaul A.C.")
print()
print("Week 1 Answers - Task 2")
print("Answer to last week's task No.1\
Hello Dear! Here is a little weekend task for us in python.\
Consider the data structure below:\
menu = {'meal_1': 'Spaghetti',\
'meal_2': 'Fries',\
'meal_3': 'Cheeseb... | true |
49a439f7914640a0ed185871ec8d2d6b2ddc90db | HamplusTech/PythonCodes2021Update | /tryExcept.py | 336 | 4.5 | 4 | numCar = input("Please enter how many cars do you have\n")
try:
numCar = int(numCar)
if numCar.__neg__():
print("You have entered a negative number")
elif numCar >= 3:
print("You have many cars")
else:
print ("You have not many cars")
except:
print("You haven't ente... | true |
0d4eb88906b569b5553d84f3f024665d6e0af0e3 | HamplusTech/PythonCodes2021Update | /breakContinuePass.py | 1,062 | 4.3125 | 4 | # using BREAK, CONTINUE and PASS statements
print ("To end this script type 'end' not 'END'. Enjoy!")
count = 0
while True:
name = input("Please enter your name\n")
print("You type ", name)
if name == "end":
break
elif name == "END":
pass
elif name:
count += 1
... | true |
6d8977dcce04e80570fb94408e5dc50dc9dd1410 | joshuajz/grade12 | /1.functions/Assignment 1.py | 1,921 | 4.4375 | 4 | # Author: Josh Cowan
# Date: October 8, 2020
# Filename: Assignment #1.py
# Descirption: Assignment 1: Function Based Calculator
def calc():
# Asks for the first number (error checking)
try:
num1 = int(input("Number 1: "))
except ValueError:
print("Invalid Input -> Provide a num... | true |
8c3e3680b1bfb94e79a23d72d45494f9134b5f33 | joshuajz/grade12 | /0.review/5. multiply.py | 1,065 | 4.28125 | 4 | # Author: Josh Cowan
# Date: October 5, 2020
# Filename: multiply.py
# Descirption: Assignment 5: Multipcation Table
# Stores the actual table
table = []
# The row value (top value)
row = 1
# Iterates from 1 to 12
for i in range(1, 13, 1):
# a row value stored in a list
l = []
# The column... | true |
941047f4b1bb82e4588fab7d6a80794cf56d7bc2 | joshuajz/grade12 | /1.functions/Assignment 3b.py | 1,160 | 4.1875 | 4 | # Author: Josh Cowan
# Date: October 8, 2020
# Filename: Assignment #3b.py
# Descirption: Assignment 3: Hypotenuse
import math
# Hypoten^2use function a^2 + b^2 = c
def pyth(a, b):
ab = (a * a) + (b * b)
return math.sqrt(ab)
# Function to ask the user for an integer
def get_int(dialog):
w... | true |
1f267aa4fd9ba74fe06b23c83cb5e69b0c0810fd | coxd6953/cti110 | /P2HW2_MealTip_DamienCox.py | 558 | 4.15625 | 4 | # Meal Tip Calculator
# 3/3/19
# CTI-110 P2HW2 - Meal Tip Calculator
# Damien Cox
#
#Enter the cost of the meal.
cost = int(input('Enter the total cost of the meal: '))
#Calculate the amount of the following tip percentages: 15%, 18% and %20.
fifteen = .15 * cost
eighteen = .18 * cost
twenty = .20 * cost
... | true |
e68db92bb6ef2bb9c140beec9394dd26d53df5a9 | SardulDhyani/MCA3_lab_practicals | /MCA3HLD/20712004_Garima Bisht/Answers_Codes/Ques11_Dictionaries.py | 322 | 4.15625 | 4 |
test_str = 'She is Good Girl'
print("The original string is : " + str(test_str))
lookp_dict = {"Good" : "very good", "Girl" : "She is also Beautiful"}
temp = test_str.split()
res = []
for wrd in temp:
res.append(lookp_dict.get(wrd, wrd))
res = ' '.join(res)
print("Replaced Strings : " + str(res... | true |
67cca33a6f7d91f8d5e596a2740c8a1e2887878b | SardulDhyani/MCA3_lab_practicals | /MCA3C/Saurabh_Suman_Section_C/ques_7.py | 360 | 4.28125 | 4 | #Write a program to demonstrate the use of the else clause.
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
if num1 > num2:
print("largest number is : ", num1)
else:
print("largest number is : ", num2)
#output:
#Enter the first number: 8
#Enter the sec... | true |
107f47f702084bd146b462fd8ffc2a5d0abe7e8e | b20bharath/Python-specialization | /Python-fundamentals/indefinite loop.py | 817 | 4.1875 | 4 | # Program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number
largest = 0
... | true |
2305c87b9c7128b1c75bee43208a10e793fef79f | hansamalhotra/learn-python-the-hard-way | /ex33 study drills 5.py | 343 | 4.125 | 4 | #Now changing while loop to for loop
#Do not need the i += increment part anymore
numbers = []
def make_a_list(last, increment):
for i in range(0,last, increment):
numbers.append(i)
last = int(input("Enter the last number ")) + 1
inc = int(input("Enter the increment "))
make_a_list(last, inc)
print(... | true |
433c2beeb9a7ec415713a2204b881d1f482d8490 | jerrywu65/Leetcode_python | /problemset/007 Reverse Integer.py | 2,156 | 4.21875 | 4 | '''
Given a 32-bit signed integer, reverse digits of an integer.
Example 1:
Input: 123
Output: 321
Example 2:
Input: -123
Output: -321
Example 3:
Input: 120
Output: 21
Note:
Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For the pu... | true |
a6ce2c96ee05be77b390674cd3fee3ab39771cd8 | ralevn/Python_scripts | /hackerranked/evallistcmd.py | 1,351 | 4.3125 | 4 | """
Lists
onsider a list (list = []). You can perform the following commands:
nsert i e: Insert integer e at position i.
rint: Print the list.
emove e: Delete the first occurrence of integer e.
ppend e: Insert integer e at the end of the list.
ort: Sort the list.
op: Pop the last element from the list.
reverse... | true |
039a21334b04575a8bfe49c7c2e70bdefa68314a | rkmsh/Cracking-The-Coding-Interview | /Linked LIsts/Kth_to_last.py | 2,117 | 4.40625 | 4 | # It is an iterative solution
# Defining the Node
class Node:
def __init__(self, data = None):
self.data = data
self.next = None
#Defining the Linked List class
class linkedList:
def __init__(self):
self.head = None
self.tail = None
# Method to add data to the linked List
... | true |
fe7ee2f14a108ec6b2916047bd78a9d2de814b7b | rkmsh/Cracking-The-Coding-Interview | /Stacks_and_Queues/Stack_min.py | 1,767 | 4.15625 | 4 | #!/usr/bin/python3
#
#
# This program always return the minnimum element in the stack
# Defining the class min_stack()
#
class min_stack:
def __init__(self):
self.stack = []
self.stack_min = []
self.tail = -1
self.small = None
# Defining a method push() to add data into the stack... | true |
38366a23768de52af0ed9bb449b7acb1abc2a6a3 | saqibwaheed786/100DayofCode | /Day22/exercise6.3.py | 916 | 4.5 | 4 | # 6-3. Glossary: A Python dictionary can be used to model an actual dictionary.
# However, to avoid confusion, let’s call it a glossary.
# • Think of five programming words you’ve learned about in the previous
# chapters. Use these words as the keys in your glossary, and store their
# meanings as values.
# • Print each... | true |
0af09664e9f0f59c9d9cceb3acdc6544f5e9034c | saqibwaheed786/100DayofCode | /Day18/cars.py | 1,010 | 4.625 | 5 | #Organizing a List
#Sorting a List Permanently with the sort() Method
#..................................................................
cars = ['bmw', 'audi', 'toyata', 'subaru']
#cars.sort()
#print(cars)
#reverse alphabetical order
#...................................................................
#cars.sort(reve... | true |
f6997fa0958705d2caa9a09634288764f93ff4fb | saqibwaheed786/100DayofCode | /DAY28/exercise8.4.py | 646 | 4.625 | 5 | # 8-5. Cities: Write a function called describe_city() that accepts the name of
# a city and its country. The function should print a simple sentence, such as
# Reykjavik is in Iceland. Give the parameter for the country a default value.
# Call your function for three different cities, at least one of which is not in t... | true |
99120e4273b991b291d2b93c757488d1d70a9ae6 | AnkithaBH/Python | /Basics/Armstrong.py | 300 | 4.3125 | 4 | #Armstrong number is a number that is equal to the sum of cubes of its digits
num=int(input("Enter any number:"))
num=str(num)
sum=0
for i in num:
sum=sum+((int(i))**3)
num=int(num)
if num==sum:
print("It is an armstrong number")
else:
print("It is not an armstrong number")
| true |
7c2dc69e4f05e974d0bce71d6f50f2cb1f1c07ab | MrVJPman/Teaching | /ICS3U1/Exercise Solutions/Exercise 15 Solutions.py | 1,621 | 4.40625 | 4 | #Question 1) https://www.w3schools.com/python/exercise.asp?filename=exercise_functions1
#Question 2)
#Create a function with no input that also return None as an output. You must write the return statement!
#Call the function, and verify that the function call output None via print()
def no_input_return_None() : ret... | true |
f2ef69222b15ad8d9ec8c27914e8efb207960082 | ursstaud/PCC-Basics | /admin.py | 1,251 | 4.21875 | 4 | class Users:
"""simple class example with users"""
def __init__(self, first_name, last_name, age, location):
self.first_name = first_name
self.last_name = last_name
self.age = age
self.location = location
def describe_user(self):
"""describing the user example"""
print(f"This user's full name ... | true |
5ba68977acc13f9a1950725fec6801ba75a56364 | ursstaud/PCC-Basics | /roller_coaster.py | 226 | 4.21875 | 4 | height = input("How tall are you in inches?")
height = int(height)
if height >= 48:
print("\nYou are tall enought to ride!")
else:
print("\nSorry, you cannot ride. You'll be able to ride when you're a little older.") | true |
b0dd78793d95a2967eaedf9650d6c9d9d5a5346b | samyak1903/Data-Types-1 | /A7.py | 356 | 4.1875 | 4 | #Q.1- Count even and odd numbers in that list.
l=[]
even,odd=0,0
elements=int(input("Enter the number of elements to be added in list"))
for num in range(elements):
num=int(input("Enter the value"))
l.append(num)
for n in l:
if n%2==0:
even=even+1
else:
odd=odd+1
print("Even count=%d\n O... | true |
6a8647d83cd511344e06c8f2519fff71e88f5347 | Jackson201325/Python | /Python Crash Course/Chapter 3 Lists/More_guest(3.6).py | 824 | 4.46875 | 4 | # You just found a bigger dinner table, so now more space is available. Think of three more guest to invite
# Use insert() to add new guesto to the beginning of your list
# Use insert() to add one new guest to the middle of the list
# Use append() to add new guest to the end of your list
names = ['Jackson', 'David', '... | true |
790e577ae58d26aed9e2806cd77c874ad6056771 | Jackson201325/Python | /Python Crash Course/Chapter 3 Lists/Seeing_the_world(3.8).py | 989 | 4.625 | 5 | # Store the locations in a list. Make sure the list is not in alphabetical order
# Print your list in its iriginal order
# Use sorted() to print your list in alphabetical order
# Show that your list is still in its original order by printing it
# Use sorted() to print your list in reverse alphaetical order without chan... | true |
d848d874f72772dfdddfb9b90213a6758e19dc75 | kmg1905/algorithms | /computer_science/algorithms/sorting/randomized_quick_sort.py | 1,820 | 4.1875 | 4 | """
Intuition: Since quicksort algorithm has a worst case time complexity of O(n*2) for certain input arrays. We need
to some how mitigate this problem and make sure the worst case time complexity is made equal to average case time
complexity. For this purpose, we can use new sorting algorithm called as "randomized qu... | true |
6fe3bcd9fafcec2375b35812674090c504b8a68c | clubofcodes/python_codes | /Ass 1.2/O&E_Label_Till_N.py | 247 | 4.125 | 4 | def showNumbers(limit):
print("List of Odd & Even Numbers till index :",limit-1)
for n in range(0,limit):
if n%2==0:
print(n,"EVEN")
else:
print(n,"ODD")
showNumbers(int(input("Enter the limit : "))) | true |
7a34fa348cb1f5f3a2045a20bbb67f4988d778f0 | lerahkp/Tip-Calculator | /main.py | 635 | 4.125 | 4 | #If the bill was $150.00, split between 5 people, with 12% tip.
#Each person should pay (150.00 / 5) * 1.12 = 33.6
#Format the result to 2 decimal places = 33.60
#Tip: You might need to do some research in Google to figure out how to do this.
print("Welcome to the tip calculator")
bill = float(input("What was the tota... | true |
037c7de9aadf7a8f204234538d8d1b2ab7c44646 | Marcin-Marcinek/Python | /script1.py | 292 | 4.125 | 4 | #!/usr/bin/python3
print("Debt calculator")
debt = float(input("Ammount of debt (in PLN):"))
daily_interest = float(input("Late fees per day: "))
days = int(input("Number of days since paydate: "))
total_debt = debt + daily_interest * days
print("Total ammount of debt: ", total_debt, "PLN")
| true |
8bd98e5cb50e1c3d290da4520cb9cc41ba5245c6 | vinnykuhnel/MethodsToolsUnitTest | /homework4/functions.py | 2,146 | 4.1875 | 4 | #Della Jones dj1069
#Teddy Lander tel127
#Raleigh Bumpers reb560
#Adam Kuhnel vak58
import math
## opens a file in read mode
## filename received as a parameter
def openFile(filename):
try:
infile = open(filename, "r")
print("File opened.")
except ValueError:
print("T... | true |
0b5b5f32bb9c6cfe64bd664e35e0a8c3617efa72 | Sarlianth/python-problems | /07-palindrome.py | 522 | 4.46875 | 4 | # Function that tests whether a string is a palindrome
# Author: Adrian Sypos
# Date: 23/09/2017
# Ask user to input a string
print("Please enter a word to check for palindrome: ")
# Read in the string
word = input()
# Bring the string to lower case for obvious comparison reasons
word = word.casefold()
# Logical state... | true |
b92a50ad18a8aca63b7c6a6af48fdae124818fb1 | jaford/thissrocks | /daily_code/JF_Daily_Code_10:26_input+reverse.py | 362 | 4.4375 | 4 | #Write a Python program which accepts the user's first and last name
# and print them in reverse order with a space between them.
first_name = input('What is your first name? ')
last_name = input('What is your last name? ')
print('I will now attempt to print the last name first followed by the first name')
print(f'Y... | true |
43c8784d884e799caf5fba76f59c61f5a1c441b1 | jaford/thissrocks | /jim_python_practice_programs/15.60_voting.py | 247 | 4.28125 | 4 | # Write a program that will let the user know if they can vote or not
def voting():
age = int(input('How old are you? '))
# check if eligible to vote
if age >= 18:
print('Can Vote')
else:
print('Cannot Vote')
voting() | true |
23ecedd3b431e13c9c9f1048e32db3c55fe86820 | jaford/thissrocks | /jim_python_practice_programs/29.60_print_user_input_fibonacci_numbers.py | 440 | 4.34375 | 4 | # Write a program that will list the Fibonacci sequence less than n
def fib_num_user():
n = int(input('Enter a number: '))
t1 = 1
t2 = 1
result = 0
# loop as long as t1 is less than n
while t1 < n:
# print t1
print(t1)
# assign sum of t1 and t2 to result
result... | true |
96eef37fd0286a7e063d61a83e1e460007f7bc05 | jaford/thissrocks | /daily_code/JF_Daily_Code_8:2.py | 744 | 4.21875 | 4 | #random number guessing game
#TODO: add guess counter
import random
correct_guess = random.randint(1,10)
print("Random number is", correct_guess) #error checking for number
guess = 0
attempts = 3
while correct_guess != guess:
guess = int(input("I'm thinking of a number between 1 and 10, can you guess it in three gu... | true |
e303b8bcd7c9e2c212617fbc80ea4e5940117734 | jaford/thissrocks | /daily_code/JF_Daily_Code_9:23_C_to_f_v2.py | 711 | 4.3125 | 4 | # This program is desgined to convert fahrenheit to celcius
user_choice = int(input('Choose 1 or 2. CHOICE 1 will convert Celcius to Fahrenheit. CHOICE 2 will convert Fahrenheit to Celcius.'))
if user_choice == 1:
celcius_temp = int(input('Enter a temperature in Celcius: '))
f_to_c_temp = (celcius_temp * 9 / 5... | true |
2a8a8c3f1ef8ad752ec0d918bd2a4221f12d907d | jaford/thissrocks | /jim_python_practice_programs/26.60_numbers_until_0.py | 319 | 4.375 | 4 | # Write a program that will print the number the user enters except 0.
# run a while loop that is always true
while True:
# take input for number
number = int(input('Enter a number: '))
# terminate the loop if the user input is 0
if number == 0:
break
# print the number
print(number) | true |
2cd997338553f3d3297869b28418cad32f0f66fb | jaford/thissrocks | /daily_code/JF_Daily_Code_10:13_Interview_Question.py | 565 | 4.125 | 4 | #You have two strings 'abcde' and 'abcdXe' write a function that would print the difference
def string_comparison (str1, str2):
first_set = set(str1)
second_set = set(str2)
difference = first_set.symmetric_difference(second_set)
print(difference)
string_comparison('abcde', 'abcdXe')
## print(... | true |
823b05a2f5f1df65bf2fcb1459db377897c7b2e0 | RiflerRick/codemonk2017 | /NumberTheory/ClosedGiftFinalSolution.py | 1,732 | 4.25 | 4 | """
This solution uses a very efficient method of finding out whether a number is prime or not.
This algorithm is really fast for finding if a number is prime or not.
The loop part is executed for numbers greater then 25. We start from 5 and alternately add 2 and 4 at each step. Remember that primes are always in the f... | true |
9e23255dcba3742c9caffbcb17a720e7e5dbb6fd | haptikfeedback/python_basics | /masterticket.py | 1,078 | 4.1875 | 4 | SERVICE_CHARGE = 2
TICKET_PRICE = 10
tickets_remaining = 100
def calculate_price(number_of_tickets):
return (number_of_tickets * TICKET_PRICE) + SERVICE_CHARGE
while tickets_remaining >= 1:
print("There are {} tickets remaining".format(tickets_remaining))
name = input("What is your name? ")
num_tic... | true |
8e4751931f1fc41b1b720e38e2774d0010550e9f | MAMBA-python/course-material | /Exercise_notebooks/Intermediate/04_modules_and_packages/example_package/somepackage/shout.py | 655 | 4.15625 | 4 | from .add import my_add
def shout_and_repeat(text):
"""
Describe here what this function does,
its input parameters, and what it returns.
In this example the function converts the input string
to uppercase and repeats it once.
"""
t = _shout(text)
result = my_add(t, t)
return resu... | true |
25867f1be45091c3f969ff874c955cf5e417423e | HYnam/Python-basic | /list_length.py | 416 | 4.28125 | 4 | # Write code to create a list of word lengths for the words in original_str using the accumulation pattern
# and assign the answer to a variable num_words_list. (You should use the len function).
original_str = "The quick brown rhino jumped over the extremely lazy fox"
split_str = original_str.split()
num_words_... | true |
d2240aea2debd56e1690e736165b184992707785 | KayleighPerera/COM411 | /Basics/Week2/or_operator.py | 394 | 4.28125 | 4 | # Ask user to enter type of adventure
print ("what is the adventure type?")
adventure_type = input()
# detrmine what the type of adventure is
if ( (adventure_type == "scary") or (adventure_type == "short") ):
print("\nEntering the dark forest!")
elif ( (adventure_type == "safe") or (adventure_type == "long") ):
pr... | true |
32e239e5a27031de5df104824df9f6425f7ce8b7 | devmohit-live/Adv_Python_Rev | /Collections files/ordered_dictionaries.py | 1,330 | 4.125 | 4 | # Keeps track of keys order (order in which the key,values are added)
from collections import OrderedDict
od = OrderedDict()
normal_dict = {}
od['Name'] = 'Mohit'
od['Branch'] = 'IT'
od['Year'] = 3
od['City'] = 'xyz'
od2=OrderedDict()
od2['Year'] = 3
od2['City'] = 'xyz'
od2['Name'] = 'Mohit'
od2['Branch'] = 'IT'
norma... | true |
e7b7507a053b8ea026876b12c2cf35e3a4736a03 | mkeita94/OOP-Practice | /Python/abstract.py | 575 | 4.1875 | 4 | # Cannot create an instance of an abstract class
# Abstraction in Python
# ABC- Abstract Base
# All classes that extend or inherit an abstract class
# should implements all the methods in in the abstract class
from abc import ABC, abstractmethod
class Computer(ABC):
@abstractmethod
def process(self)... | true |
74bae85dd8a1e73c26996a2c80c9a2ed9febd8c3 | Luksos9/LearningThroughDoing | /automateboringstuff/someSimplePrograms/TablePrinter.py | 928 | 4.40625 | 4 | #!/usr/bin/python3
tableData = [['apples', 'oranges', 'cherries', 'banana'],
['Alice', 'Bob', 'Carol', 'David'],
['dogs', 'cats', 'moose', 'goose']]
def printTable(table):
#Create a list with each element representing columns that will store each column max width
columnWithds = [0]... | true |
d10f7b805e2229dad381280cbf2dc817235f08e5 | dhananjay-arora/Coin-Changes-Greedy-Algorithm | /Answer3.py | 1,002 | 4.3125 | 4 | # Assumption: One coin_denominations should be penny.
# O(nk)-time algorithm that makes change for any set of k different coin denominations
n = int(input("Enter the value in cents you want change for:"))
denomination_number = int(input("Enter how many coin_denominations you want to enter: "))
print("Enter the co... | true |
32bf723ebd71f8ae30fa1c5f56d3a712a55280fd | danielscarvalho/FTT-Compiladores-Python-2 | /p12.py | 401 | 4.28125 | 4 |
while True:
number = input("Entre com um valor: ")
if len(number) == 0:
break
number = float(number)
if number > 2:
print("Number is bigger than 2.")
elif number < 2: # Optional clause (you can have multiple elifs)
print("Number is smaller than 2.")
else: #... | true |
dbf474b0b2a9fccb8cd8b3fbe5b5c7379bc4c108 | hinsonan/ThinkPython | /ThinkPython/Chap8/8.2.py | 428 | 4.3125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jun 21 08:00:54 2018
@author: hinson
There is a string method called count that is similar to the function in Section 8.7.
Read the documentation of this method and write an invocation that counts the number of a’s in
'banana'.
"""
def main():
string = 'bana... | true |
8ecd0ce4a6322306888bf8b93a06f8091785f63c | hinsonan/ThinkPython | /ThinkPython/Chap3/3.1.py | 303 | 4.125 | 4 | #Write a function named right_justify that takes a string named s as a parameter
#and prints the string with enough leading spaces so that the last letter of the string is in column 70
#of the display.
def right_justify(s):
print (' '*(70-len(s))+s)
def main():
right_justify('Becca')
main() | true |
62383654407fafcea774eb6a7928e564efd143be | adang1345/Project_Euler | /5 Smallest Multiple.py | 855 | 4.25 | 4 | """Computes the smallest number that is divisible by 1 through 20"""
def isdivisible(num):
"""Determines whether num is divisible by 1 through 20. If and only if num is divisible by 11, 13, 14, 16, 17, 18,
19, and 20, then num must be divisible by all numbers from 1 through 20. Assume num is a positive integer... | true |
f5b3a50f2885bc847caf3b55daca9c58b7b241d0 | adang1345/Project_Euler | /3 Largest Prime Factor.py | 1,379 | 4.15625 | 4 | """Computes the largest prime factor of 600851475143"""
def isprime(num):
"""Determine whether num is prime.
If any integer from 2 to the square root of num divides evenly into num, then num is composite.
Otherwise, num is prime. Assume that num is an int greater than or equal to 2."""
for x in range... | true |
55280d87e90267b0f9d9355ef944f72b32afa817 | adang1345/Project_Euler | /60 Prime Pair Sets.py | 2,383 | 4.25 | 4 | """The primes 3, 7, 109, and 673, are quite remarkable. By taking any two primes and concatenating them in any order the
result will always be prime. For example, taking 7 and 109, both 7109 and 1097 are prime. The sum of these four primes,
792, represents the lowest sum for a set of four primes with this property.
Fi... | true |
b8043956a641116eaf01cf334bd15e01bf5d5e8c | adang1345/Project_Euler | /41 Pandigital Prime.py | 1,301 | 4.1875 | 4 | """We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example,
2143 is a 4-digit pandigital and is also prime.
What is the largest n-digit pandigital prime that exists?"""
from itertools import permutations
def isprime(num):
"""Determine whether num is p... | true |
ad9134b038e359b4ebdf81b9b797db5cbe768576 | OcanoMark/CodingBat | /Python/String-1/03_make_tags.py | 346 | 4.34375 | 4 | # The web is built with HTML strings like "<i>Yay</i>" which draws Yay
# as italic text. In this example, the "i" tag makes <i> and </i> which
# surround the word "Yay". Given tag and word strings, create the HTML
# string with tags around the word, e.g. "<i>Yay</i>".
def make_tags(tag, word):
return "<" + tag + ">" ... | true |
111695137d815680b1701cd420e75a34ba89e801 | DrCarolineClark/CtCI-6th-Edition | /Python/Chapter2/24Partion.py | 1,656 | 4.15625 | 4 | class node:
def __init__(self):
self.data = None # contains the data
self.next = None # contains the reference to the next node
class linked_list:
def __init__(self):
self.head = None
self.last_element = None
def add_node(self, data):
new_node = node() # create a ne... | true |
8584ffe1668412fb151552496023ce7ca32a3721 | alexh13/practicing-using-pandas | /pandas-intro.py | 1,188 | 4.5625 | 5 | # -pandas is a library used for data structures and data analysis tools.
# -used for loading data, web-scraping, loading & analyzing data from excel files
# * type ipython into to terminal *
import pandas
df1 = pandas.DataFrame([[2, 4, 6], [10, 20, 30]]) # Create a dataframe named df1
print(df1) # output dataFrame,... | true |
08fcdf096a5476868f6c0c66a7db9619003f306d | Nvardharutyunyan/group-sudo | /nvard/python/#2/sumDigits_R.py | 297 | 4.21875 | 4 | #!usr/bin/env python3
def sumOfNum_R(number):
if number == 0:
return 0
else:
return (number % 10) + sumOfNum_R(number // 10)
num = int(input("Enter the number : "))
if num < 0 :
print ("Your number is not natural!")
else :
print("The sum of number is equal ", sumOfNum_R(num))
| true |
8a651d47bd71be5a3b86d3c74ac7d07959bd516d | LaKeshiaJohnson/MasterTicket | /masterticket.py | 1,547 | 4.3125 | 4 | #Run code until tickets run out
#Output how many tickets remaining using tickets_remaining variable
#Gather the user's name and assign it to a new variable
#Prompt user by name to ask how many tickets they would like
#Calculate price and output to screen
#Prompt user if they want to continue. Y/N
#if they want to proce... | true |
a2dd2109b50309900c072eec2a595f18527b4339 | nutcheer/pythonlearning | /pr6_6.py | 346 | 4.15625 | 4 | favorite_languages = {
'jen': 'python',
'sarah': 'c',
'edward': 'ruby',
'phil': 'python',
}
names = ['jen', 'sarah', 'tiffany', 'nutcheer']
for name in favorite_languages.keys():
if name in names:
print(name+", thank you for your attending!")
else:
print(name+", I am glad to in... | true |
cd045d94572fd6ae5c50ef2a06c5d33055411977 | AYAN-AMBESH/learning-Python | /ex17.py | 391 | 4.1875 | 4 | #Write a Python program to calculate the sum of three given numbers, if the values are equal then return thrice of their sum.
num1 = input("ENTER NUMBER: ")
num3 = input("ENTER NUMBER: ")
num2 = input("ENTER NUMBER: ")
def Sum_of_num(num1,num2,num3):
sum = num1 + num2 + num3
if num1 == num2 == num3:
sum... | true |
7d0b68ff37e131779042de77c5510b177cc86fba | AYAN-AMBESH/learning-Python | /ex25.py | 281 | 4.40625 | 4 | #Write a Python program to find whether a given number (accept from the user) is even or odd,
#print out an appropriate message to the user
n = int(input("Enter a number: "))
if n%2==0:
print("{} is a even number. ".format(n))
else:
print("{} is a odd number. ".format(n)) | true |
296f5548557486ae7a0e4127e179e4944ed2ff03 | AYAN-AMBESH/learning-Python | /ex7.py | 245 | 4.125 | 4 | #Write a short Python function that takes a positive integer n and returns
#the sum of the squares of all the positive integers smaller than n
def Square(n):
Sum=0
for i in range(0,n):
Sum += i**2
return Sum
print(Square(5))
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.