blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
8d8fff8b1f4ac7d1e6b2e77857d855380769d878 | kishan-pj/python_lab_exercise_1 | /pythonproject_lab2/Qno.5positive_negative_zero.py | 277 | 4.40625 | 4 | # for given integer x print true if it is positive,print false if it is negative and print
# zero if it is 0.
x=int(input("enter the number: "))
if x>0:
print("the number is positive ")
elif x<0:
print("the number is negative ")
else:
print("the number is zero ")
| true |
1d32702262eea6ddd58d869c713f7089361a5947 | cwkarwisch/CS50-psets | /vigenere/vigenere.py | 2,383 | 4.4375 | 4 | import sys
from cs50 import get_string
def main():
# Test if the user has only input two strings (the name of the program and the keyword)
if len(sys.argv) != 2:
print("Usage: ./vigenere keyword")
sys.exit(1)
# Test if the keyword is strictly alphabetic
if not sys.argv[1].isalpha():
... | true |
ce6a09f9e1b13bc8456bb3410a58aa051e553b6d | JordanKeller/data_structures_and_algorithms_python | /climbing_stairs.py | 489 | 4.21875 | 4 | def climbing_stairs(n):
"""Input a positive integer n. Climb n steps, taking either a single
stair or two stairs with each step. Output the distinct ways to
climb to the top of the stairs."""
a = 1
b = 2
if n == 1:
return a
if n == 2:
return b
# n >= 3
for i in range(n - 2):
c = a + b
a = b
b ... | true |
bbdc9a562338830d393ffaa290329b92f730b274 | manimaran1997/Python-Basics | /ch_08_OOP/Projects/ch_04_Inheritance/ex_inheritance.py | 2,861 | 4.125 | 4 |
# coding: utf-8
# In[42]:
class Employee:
employeeCounter = 0;
def __init__(self,firstName,lastName):
self.firstName = firstName
self.lastName = lastName
Employee.employeeCounter += 1
print(" hello i employee")
def displayEmployeeName(self):
... | true |
c380edaae8661d21363c2ea2fe90f59d3879306c | efitzpatrick/Tkinter | /firstRealExample.py | 2,121 | 4.375 | 4 | # www.tkdocs.com/tutorial/firstexample.html
#tells python that we need the modlues tkinter and ttk
# tkinter is the standard binding to Tk (what is a binding?)
# ttk is Python's binding to the newer themed widgets that were added to 8.5
from tkinter import *
from tkinter import ttk
#calculate procedure
def calculate(*... | true |
f1d9667058f1fc7d1dfdf70c4bf7dad6bc195bf7 | ManSleen/Graphs | /projects/ancestor/ancestor.py | 2,980 | 4.15625 | 4 | from collections import deque
class Graph:
"""Represent a graph as a dictionary of vertices mapping labels to edges."""
def __init__(self):
self.vertices = {}
self.visited = set()
def __repr__(self):
for vertex in self.vertices:
return f"{vertex}"
def add_vertex(... | true |
6635b9b2744114746ca1e5992162291bb8b9b946 | sanjit961/Python-Code | /python/p_20_logical_operator.py | 671 | 4.34375 | 4 | #Logical Operator in Python:
#If applicant has high income AND good credit
#then he is eligible for loan
# Logical and operator ----> both condition should be true
# Logical or operator ----> at least one condition should be true.
# Logica not operator ----> it converses the value True ---> False, False ---> Tru... | true |
0ac6446ca514c2308ac7db5a1db3f8ca268d44c6 | sanjit961/Python-Code | /python/p_13.Arithmetic_Operator.py | 647 | 4.6875 | 5 | #Arithmetic Operator in Python:
print(10 - 3) #Subtraction
print(10 + 4) #Addition
print( 10 / 5) #Division
print( 10 // 5) #This prints the Quotient with interger value only
print( 10 % 3) #This % (Modulo Operator) prints the remainder
print(10 * 5) #Mutltiplication operator * ("Asterisk")
print(1... | true |
f4c66c7312983e0e669251890946b7d68c65f4fb | MrCQuinn/Homework-2014-15 | /CIS_211_CS_II/GUI turn in/flipper.py | 1,146 | 4.40625 | 4 | #Flippin' Cards program
#By Charlie Quinn
from tkinter import *
from random import randint
from CardLabel import *
side = ["back","front","blank"]
n = 0
a = 2
def flip():
"""
Function that runs when "Flip" button is pressed.
a is a value that starts at 0 and goes to 8 before going back to 0
w and n a... | true |
c06e676609489425c5f00e15778a2acc831e37cf | Dvshah13/Machine-and-Deep-Learning-Code-Notes | /data_munging_basics-categorical.py | 1,701 | 4.28125 | 4 | ## You'll be working often with categorical data. A plus point is the values are Booleans, they can be seen as the presence or absence of a feature or on the other side the probability of a feature having an exhibit (has displayed, has not displayed). Since many ML algos don't allow the input to be categorical, boole... | true |
b4a49e0d08e0e8e0710f3014e2ccb28b6d9017e9 | stevenfisher22/python-exercises | /Homework 14 Nov 2018/guess-a-number.py | 1,645 | 4.125 | 4 | # STEP 1: GUESS A NUMBER
# secret_number = 2
# answer = 0
# while answer != secret_number:
# answer = int(input('I\'m thinking of a number between 1 and 10. What\'s the number? '))
# if answer != secret_number:
# print('Nope, try again ')
# print('You win!')
# STEP 2: GIVE A HIGH-LOW HINT
# secret_n... | true |
60d45067426464abb0f20b20a665dc3d6741b1a5 | Mohan-Zhang-u/From_UofT | /csc148/pycharm/csc148/labs/lab5/nested.py | 2,226 | 4.15625 | 4 | def nested_max(obj):
"""Return the maximum item stored in <obj>.
You may assume all the items are positive, and calling
nested_max on an empty list returns 0.
@type obj: int | list
@rtype: int
>>> nested_max(17)
17
>>> nested_max([1, 2, [1, 2, [3], 4, 5], 4])
5
>>> nested_max(... | true |
3f0b740dc0a0d881af1346b6064f498e84f5f984 | servesh-chaturvedi/FunGames | /Rock, Paper, Scissors/Rock Paper Scissors.py | 1,003 | 4.1875 | 4 | import random
import time
options={1:"rock", 2:"paper", 3: "scissors"} #build list
try:
again="y"
while(again == "y"):
player=int(input("Enter:\n 1 for Rock\n 2 for Paper\n 3 for Scissors\n")) #take player input
print("You entered:", options[player])
comp=random.randint (1,... | true |
223608bba840a65ed2c953ede96c797f4ad9cd63 | SiddhartLapsiwala/Software_Testing_Assign2 | /TestTriangle.py | 1,990 | 4.3125 | 4 | # -*- coding: utf-8 -*-
"""
Updated Jan 21, 2018
The primary goal of this file is to demonstrate a simple unittest implementation
@author: jrr
@author: rk
"""
import unittest
from Triangle import classifyTriangle
# This code implements the unit test functionality
# https://docs.python.org/3/library/unittest.html ha... | true |
0bf34cfec95bf6ab35d4c1b80ec42ea73dfb61ef | RiikkaKokko/JAMK_ohjelmoinnin_perusteet | /examples/13-collections/set.py | 1,047 | 4.28125 | 4 | # declare set of names and print
nameset = {"Joe", "Sally", "Liam", "Robert", "Emma", "Isabella"}
print("Contents of nameset is: ", nameset)
# print contents of the set in for loop
for name in nameset:
print(name)
# check length of the set
print("Length of the set is: ", len(nameset))
# check if certain item is ... | true |
25c16ff3deb8922b8c80f1cd92e067134e627c3f | tyerq/checkio | /most-wanted-letter.py | 975 | 4.21875 | 4 | def checkio(text):
text = text.lower()
max_freq = 0
max_letter = ''
for letter in text:
if letter.isalpha():
num = text.count(letter)
if num > max_freq or num == max_freq and letter < max_letter:
max_freq = num
max_letter = l... | true |
8336c2ce6d87cc7718a3b2af83d3bba7d7ab82b5 | KhadarRashid/2905-60-Lab5 | /sql_db.py | 2,844 | 4.28125 | 4 | import sqlite3
db = 'records_db.sqlite'
def main():
# calling functions in the order they should execute
menu()
drop_table()
create_table()
data()
def menu():
# Creating a super simple menu
choice = input('\nPlease choose one of the following here \n 1 to add \n 2 to delete\n 3 to show ... | true |
424d1d4a40d34097b15d71f502fdf5979d95d6c7 | jamesmmatt/Projects | /Python/FizzBuzz.py | 570 | 4.375 | 4 | """
Write a program that prints the numbers from 1 to 100.
But for multiples of three print "Fizz" instead of the
number and for for the multiples of five print "Buzz".
For numbers which are multiples of both three and five print
"FizzBuzz"
"""
def fizzBuz(lastNumber):
numRange = range(1, (lastNumber + 1))
for num ... | true |
c8d583db90939476c5a02e41b49f0d086400f4c7 | vivia618/Code-practice | /Reverse words.py | 593 | 4.3125 | 4 | # Write a function that reverses all the words in a sentence that start with a particular letter.
sentence = input("Which sentence you want to reverse? : ").lower()
letter = input("Which letter you want to reverse? : ").lower()
word_in_sentence = sentence.split(" ")
new_sentence = []
def special_reverse(x, y):
x... | true |
c759b9b0b77b38d773482210b6b86685f67b224d | TejshreeLavatre/CrackingTheCodingInterview | /Data Structures/Chpt1- Arrays and Strings/3-URLify.py | 871 | 4.3125 | 4 | """
Write a method to replace all spaces in a string with '%20'.
You may assume that the string has sufficient space at the end to hold the additional characters,
and that you are given the "true" length of the string.
(Note: If implementing in Java, please use a character array so that you can perform this operation i... | true |
d56969b05ab1673ebae52b003332e6f53e4003dd | CaosMx/100-Python-Exercises | /011.py | 606 | 4.28125 | 4 | """
Create a script that generates and prints a list of numbers from 1 to 20. Please do not create the list manually.
"""
x = range(1,21)
print(list(x))
# Create a script that generates and prints a list of numbers from 1 to 20. Please do not create the list manually.
# 1 Punto
# El truco es castear el resultado co... | true |
bee12643fb9c7979b52d053d7c3ac2946c26d765 | NiraliSupe/Sample-Python-Programs | /Sqlite3/Database.py | 1,660 | 4.8125 | 5 | '''
Program created to learn sqlite3
'''
import sqlite3
class Database:
def __init__(self):
self.conn = sqlite3.connect('UserInfo.db')
self.cur = self.conn.cursor()
print("success")
def createTable(self):
table_exists = 'SELECT name FROM sqlite_master WHERE type="table" AND name="USERS"'
sql = 'CREAT... | true |
e54b29af4b636fa822a4915dbe5180cffb6dc12b | aabeshov/PP2 | /String3.py | 305 | 4.28125 | 4 | b = "Hello, World!"
print(b[2:5]) # show symbold on the 2th 3th 4th positions
a = "Hello, World!"
print(b[:5]) # show symbols til the 5th position
b = "Hello, World!"
print(b[2:]) # show symbold from 2th position til the end
b = "Hello, World!" # Its the same but it starts from the ending
print(b[-5:-2]) | true |
3664d30966db44495bf24bc707f34715795552b6 | rolandoquiroz/holbertonschool-higher_level_programming | /0x0B-python-input_output/4-append_write.py | 491 | 4.46875 | 4 | #!/usr/bin/python3
"""
This module contains a function that
appends a string at the end of a text
file (UTF8) and returns the number of
characters added.
"""
def append_write(filename="", text=""):
"""
append_write- Appends a string at the end of a text file (UTF8).
Args:
filename(str): filename... | true |
6fbff7a74b6fcfd9489b5939b089dcf5f245629d | dgellerup/laminar | /laminar/laminar_examples.py | 1,574 | 4.25 | 4 | import pandas as pd
def single_total(iterable, odd=False):
"""This example function sums the data contained in a single iterable, i.e.
a list, tuple, set, pd.Series, etc.
Args:
iterable (list, tuple, set, pd.Series, etc): Any iterable that holds data
that can be added together.
... | true |
4a4127a94f0b510000be3724caa6f204ac602025 | leqingxue/Python-Algorithms | /Lecture01/Labs/Lab01/rec_cum_solution.py | 715 | 4.125 | 4 | # Write a recursive function which takes an integer and computes the cumulative sum of 0 to that integer
# For example, if n=4 , return 4+3+2+1+0, which is 10.
# This problem is very similar to the factorial problem presented during the introduction to recursion.
# Remember, always think of what the base case will loo... | true |
2a3d2d00ccba81a596ec9e9b6296c115ac1b583a | woshiZS/Snake-Python-tutorial- | /Chapter3/cube.py | 336 | 4.40625 | 4 | cubes=[value for value in range(1,11)]
for cube in cubes:
print(cube)
print("The first 3 items in the list are : ")
for num in cubes[:3]:
print(num)
print("Three items from the middle of the list are : ")
for num in cubes[4:7]:
print(num)
print("The last 3 items in the list are : ")
for num in cubes[-3:]... | true |
0d8a2dea4bdafa61851e58509bbf5adc04022818 | andres925922/Python-Design-Patterns | /src/3_examples/Structural/adapter.py | 829 | 4.125 | 4 | """
Convert the interface of a class into another interface clients expect.
Adapter lets classes work together that couldn't otherwise because of
incompatible interfaces.
"""
from abc import ABC, abstractmethod
# ----------------
# Target Interface
# ----------------
class Target(ABC):
"""
Interface for C... | true |
d63b47cc028440f91de93b4f2afe0e729bda88fd | Environmental-Informatics/building-more-complex-programs-with-python-Gautam6-asmita | /Second_attempt_Exercise5.2.py | 1,180 | 4.53125 | 5 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Created on 2020-01-24 by Asmita Gautam
Assignment 01: Python - Learning the Basics
Think Python Chapter 5: Exercises 5.2
##Check fermat equation
Modified for resubmission on 2020-03-04
"""
"""
This function 'check_fermat' takes 4 parameters: a,b,c and d
to check th... | true |
ea3a06ac165152baade99a551f6fe2d7740ba635 | mrsleveto/PythonProgrammingAssignmentSolutions | /Conversation with a computer.py | 743 | 4.1875 | 4 | #Conversation with a computer, by: Mrs. Leveto
doing_well=input("Hello, are you doing well today? (y/n): ")
if doing_well == "y" or doing_well == "Y":
print("Wonderful! I'm so glad!")
reason=input("What has you in such a great mood today? (weather/school/friends): ")
if reason == "weather":
print("... | true |
a4134eb61c9d56b6c11d4d993c18b72f92e9fdf3 | FilipDuz/CodeEval | /Moderate/ARRAY_ABSURDITY.py | 1,495 | 4.125 | 4 | #ARRAY ABSURDITY
"""
Imagine we have an immutable array of size N which we know to be filled with integers ranging from 0 to N-2, inclusive. Suppose we know that the array contains exactly one duplicated entry and that duplicate appears exactly twice. Find the duplicated entry. (For bonus points, ensure your solut... | true |
5a82cacd4bf322b1200c0f66f89e5a9d950856f9 | FilipDuz/CodeEval | /Moderate/REMOVE_CHARACTERS.py | 1,393 | 4.34375 | 4 | #REMOVE CHARACTERS
"""
Write a program which removes specific characters from a string.
INPUT SAMPLE:
The first argument is a path to a file. The file contains the source strings and the characters that need to be scrubbed. Each source string and characters you need to scrub are delimited by ... | true |
289ad787090b4a6c692fc2088213b73171add2a5 | sonalpawar2196/PythonTrainingDecember | /List/ListDemo.py | 1,637 | 4.4375 | 4 |
thisList = ['sonal','priya','abc','pqr']
print(thisList)
print(thisList[1])
thisList[1] = "jjj"
print(thisList)
# iterating over list
for x in thisList:
print(x)
if "sonal" in thisList:
print("string is in the list")
else:
print("not present ")
print("length of list = ",len(thisList))
#To add an it... | true |
525fa2c6b200496b8c9a5a748127f5e4f60a6819 | swapnilz30/python | /create-file.py | 734 | 4.4375 | 4 | #!/usr/bin/python3.6
# This script create the file.
import os
from sys import exit
def check_file_dir(file_name):
# Check user enter value is dir or file.
if os.path.isdir(file_name):
print("The ", file_name, "is directory")
exit()
elif os.path.isfile(file_name):
print("The ", fi... | true |
0f9944079b744b6d2074ca765b018fa61a3866e6 | olives8109/CTI-110-1001 | /M2_HourstoMinutes.py | 522 | 4.28125 | 4 | # Hours to Minutes
# with formatting
# CTI-110
# Sigrid Olive
# 6/7/2017
#convert minutes to hh:mm format
#input number of minutes
totalMinutes = int(input("Number of minutes: "))
print ("You entered " + str(totalMinutes) + " minutes." )
#calculate hours
hours = totalMinutes // 60
#print ("That is ",... | true |
6f3db28210ead31da475367df0416c569b69ab04 | olives8109/CTI-110-1001 | /M5T2_FeetToInches_SigridOlive.py | 539 | 4.46875 | 4 | # Feet to Inches - Converts an input of feet into inches.
# CTI-110
# Sigrid Olive
# 6/26/2017
# explains what program does
print("This program takes a number of feet and gives out the number of inches in that many feet.")
# defines the variable "feet_to_inches" which will take an input of feet and convert it... | true |
d284f26b04c9f8f44f73bf67150132d79262912a | krupadhruva/CIS41A | /home/unit_c_1.py | 2,722 | 4.46875 | 4 | """
Krupa Dhruva
CIS 41A Fall 2020
Unit C take-home assignment
"""
"""
First Script - Working with Lists
All print output should include descriptions as shown in the example output below.
Create an empty list called list1
Populate list1 with the values 1,3,5
Create list2 and populate it with the values 1,2,3,4
Cre... | true |
dad8256f39a3457447851ad0909580611603b8c8 | martiinmuriuki/python_projects | /tempconverter.py | 2,529 | 4.28125 | 4 | import math
import time
# Function
def again():
try_again = print()
User_Temp = input("your temperature,'C' for celsius, 'F' for fahrenheit 'K' for kelvin: ").upper()
convert_Temp = input("The temperature you want to convert to, 'C' for celsius, 'F' for fahrenheit 'K' for kelvin: ").upper()
# conve... | true |
382be9db811b8a824a796111e0691aea58b3c4a8 | JayT25/30-days-of-code | /arrays.py | 757 | 4.1875 | 4 | """
Task:
Given an array, A, of N integers, print A's elements in reverse order
as a single line of space-separated numbers.
Input Format:
The first line contains an integer, N (the size of our array).
The second line contains N space-separated integers describing
array A's elements.
Sample input:
4
1 4 3 2... | true |
96ea47c02375e6ec964b9cb198dfcaf87b8f3cd8 | danielreedcombs/zoo-python | /zoo.py | 703 | 4.53125 | 5 | #Create a tuple named zoo that contains your favorite animals.
zoo = tuple(["Dog","Chicken","Lama","Otter"])
#Find one of your animals using the .index(value) method on the tuple.
num_of_chicken = zoo.index("Chicken")
print(num_of_chicken)
#Determine if an animal is in your tuple by using value in tuple.
print("Chick... | true |
53261c105ebb6551e5e3a0072d952a67da1d63d6 | poofplonker/EffectivePython | /Chapter1/lesson_six.py | 1,668 | 4.15625 | 4 | """ Lesson Six: Don't use start, end and slice in a single Slice """
from itertools import islice
A = list(range(10))
#We can use the slice stride syntax like this:
print("Even: ", A[::2])
print("Odds: ", A[1::2])
# Seems good right? The problem is that :: can introduce bugs.
# Here's a cool idiom for reversing a s... | true |
d7c7217a1ce1d50f493ac86eea040675f43d0ad1 | agrisjakob/QA-Academy-Work | /Python/Python Exercises and Tasks/Grade calculator.py | 1,242 | 4.40625 | 4 | # Challenge
# • Create an application which asks the user for an input for a maths mark, a chemistry mark and a physics mark.
# • Add the marks together, then work out the overall percentage. And print it out to the screen.
# • If the percentage is below 40%, print “You failed”
# • If the percentage is 40% or higher, ... | true |
305faad0957f6d8092c4c4d3a099f2e6ef3ad338 | cubitussonis/WTAMU | /assignment4/p5-2_guesses.py | 1,574 | 4.21875 | 4 | #!/usr/bin/env python3
import random
def display_title():
print("Guess the number!")
print()
def get_limit():
limit = int(input("Enter the upper limit for the range of numbers: "))
# limit must be at least 2, otherwise the game makes no sens
while limit < 2:
print("Smallest po... | true |
f4216b05170c13a8363ebe7ad5f37dc2cf23563b | karans5004/Python_Basics | /ClassesAndObjects.py | 2,400 | 4.875 | 5 | """ # Python3 program to
# demonstrate instantiating
# a class
class Dog:
# A simple class
# attribute
attr1 = "mammal"
attr2 = "dog"
# A sample method
def fun(self):
print("I'm a", self.attr1)
print("I'm a", self.attr2)
# Driver code
# Object instantiation
Rodger ... | true |
f0511f12ac8b02f306d5b5f2a5eac9d26d53528e | karans5004/Python_Basics | /day1_solution3.py | 600 | 4.25 | 4 | # Python3 Program to check whether a
# given key already exists in a dictionary.
# Function to print sum
def checkKey(dict, key):
if key in dict.keys():
return 1
else:
return 0
# Driver Code
dict = {'a': 100, 'b':200, 'c':300}
key = input('Please Enter the Key : ')
flag = checkK... | true |
3df6ef4c4be687872ea8f2bb323fd81700ca5f2c | karans5004/Python_Basics | /AnonymousFunctions.py | 2,108 | 4.75 | 5 | """ In Python, anonymous function means that a function is without a name. As we already know that def keyword is used to define the normal functions and the lambda keyword is used to create anonymous functions. It has the following syntax:
Syntax
lambda arguments : expression
This function can have any number o... | true |
0add3d75735397e008ddce6dc18c04990428fab1 | Cobraderas/LearnPython | /PythonGround/PythonIterators.py | 1,880 | 4.71875 | 5 | # an iterator is an object which implements the iterator protocol, which consists of the methods __iter__()
# and __next__()
# return an iterator from tuple, and print each value
mytuple = ("apple", "banana", "cherry")
myit = iter(mytuple)
print(next(myit))
print(next(myit))
print(next(myit))
print(" ")
mystr = "b... | true |
87639ce4dc7891b3b325ec2c5a331c5addf1defb | Cobraderas/LearnPython | /PythonGround/DateTime.py | 516 | 4.25 | 4 | import datetime
x = datetime.datetime.now()
print(x)
print(x.year)
print(x.strftime("%A"))
# create date object
x = datetime.datetime(2020, 5, 17)
print(x)
# The datetime object has a method for formatting date objects into readable strings.
# The method is called strftime(), and takes one parameter, format, to spec... | true |
14346136e7119326a97dda86e47bdcbd35aa4cf5 | bardia-p/Raspberry-Pi-Projects | /button.py | 923 | 4.1875 | 4 | '''
A program demonstrating how to use a button
'''
import RPi.GPIO as GPIO
import time
import lcd_i2c
PIN = 25
#Setup and initialization functions of the LCD
def printLCD(string1, string2):
lcd_i2c.printer(string1, string2)
def setup():
lcd_i2c.lcd_init()
#General GPIO Setup
GPIO.setmode(GPIO.BCM) #sets h... | true |
af60ea8239d8ec4755cd6ffafcfd76753c2f4590 | VisargD/Problem-Solving | /Day-10/(3-Way Partitioning) Sort-Colors.py | 2,748 | 4.25 | 4 | """
Problem Name: Sort Colors
Platform: Leetcode
Difficulty: Medium
Platform Link: https://leetcode.com/problems/sort-colors/
"""
"""
APPROACH:
In this approach, 3 pointers will be used.
Initially zero_index will point to the first index (beginning) of list and two_index will point to the last index (end).
In order to... | true |
ef047d9fab947eae8cddb4c3a96bc5a9c17edbfd | tj3407/Python-Projects-2 | /math_dojo.py | 2,282 | 4.15625 | 4 | import math
class MathDojo(object):
def __init__(self):
self.result = 0
def add(self, arg, *args):
# Check the type() of 1st argument
# if tuple (which can be a list or another tuple), iterate through values
if type(arg) == tuple or type(arg) == list:
for i in arg:
... | true |
3e3cd7196e617b13fc28175678ec43baee4d941f | janaki-rk/silver_train | /Coding Challenge-5.py | 766 | 4.4375 | 4 | # DAILY CODING CHALLENGE 5
# Question asked by:JANE STREET
# cons(a, b) constructs a pair, and car(pair) and cdr(pair) returns the first and last element of that pair. For
# example, car(cons(3, 4)) returns 3, and cdr(cons(3, 4)) returns 4.Implement car and cdr.
# Step 1: Defining the already implemented cons functio... | true |
886dff703a512ddee03210bb0d14d922b315e314 | janaki-rk/silver_train | /Coding Challenge_14.py | 1,319 | 4.28125 | 4 | # DAILY CODING CHALLENGE 14
# Question asked by: GOOGLE
# The area of a circle is defined as πr^2. Estimate π to 3 decimal places using a Monte Carlo method.
from random import uniform
from math import pow
# Step1: Solving the area of the circle with detailed descriptions
# 1--Set r to be 1 (the unit circle)
# 2--Ra... | true |
228dca898f80a9175d8d7d612a0a8dc34d9846d7 | saurabhgrewal718/python-problems | /factorial of a number.py | 288 | 4.25 | 4 | # Write a program which can compute the factorial of a given numbers.
# The results should be printed in a comma-separated sequence on a single line.
# Suppose the following input is supplied to the program:
# 8
# Then, the output should be:
# 40320
num=input()
print("num is "+ num)
| true |
35ef3abdfd3f7a7dab0e2cc1a1f2417e830c1bea | ZacharySmith8/Python40 | /33_sum_range/sum_range.py | 804 | 4.1875 | 4 | def sum_range(nums, start=0, end=None):
"""Return sum of numbers from start...end.
- start: where to start (if not provided, start at list start)
- end: where to stop (include this index) (if not provided, go through end)
>>> nums = [1, 2, 3, 4]
>>> sum_range(nums)
10
>>>... | true |
da50ea2dbed6771f589867f84304f543dcdb6ae4 | sanjiv576/LabExercises | /Lab2/nine_leapYear.py | 469 | 4.1875 | 4 | """
Check whether the given year is leap year or not. If year is leap print ‘LEAP YEAR’ else print ‘COMMON YEAR’.
Hint: • a year is a leap year if its number is exactly divisible by 4 and is not exactly divisible by 100
• a year is always a leap year if its number is exactly divisible by 400
"""
year = int(input("Pleas... | true |
8ccdd26d1ecc5918c9736bb294ebc39b8b344c56 | sanjiv576/LabExercises | /Lab4_Data_Structure__And_Iternation/Dictionary/Four_check_keys.py | 291 | 4.46875 | 4 | # Write a Python script to check if a given key already exists in a dictionary.
dic1 = {1: 'one', 2: 'two', 3: 'three'}
keyOnly = dic1.keys()
check = int(input("Input a key : "))
if check in keyOnly:
print(f"{check} key already exists.")
else:
print(f"{check} key is not in {dic1}")
| true |
9193689da08cab23f2b621569036570ea5d03bc2 | sanjiv576/LabExercises | /Conditions/Second.py | 330 | 4.5 | 4 | """
If temperature is greater than 30, it's a hot day other wise if it's less than 10;
it's a cold day; otherwise, it's neither hot nor cold.
"""
temp = float(input("Enter the temperature : "))
if temp > 30:
print("It's s hot day ")
elif temp < 10:
print("It is a cold day")
else:
print("It is neither hot ... | true |
05bc68517729cf3bd4f2463c0b52b87f52799731 | sanjiv576/LabExercises | /Lab2/ten_sumOfIntergers.py | 456 | 4.25 | 4 |
# Write a Python program to sum of three given integers. However, if two values are equal, sum will be zero
num1 = int(input("Enter the first integer number : "))
num2 = int(input("Enter the second integer number : "))
num3 = int(input("Enter the third integer number : "))
if num1 == num2 or num1 == num3 or num2 == n... | true |
4b69189aa69becee50a00c534ac15e1cb7814b7f | sanjiv576/LabExercises | /Lab2/eight_sum_of_three-digits.py | 279 | 4.28125 | 4 | """
Given a three-digit number. Find the sum of its digits.
10.
"""
num = int(input("Enter any three-digits number : "))
copidNum = num
sum = 0
for i in range(3):
remainder = copidNum % 10
sum += remainder
copidNum //= 10
print(f"Sum of each digit of {num} is {sum}") | true |
27d6d4a16a3acb9da7f3fc436d77ec1d1433416f | sanjiv576/LabExercises | /Lab4_Data_Structure__And_Iternation/Question_answers/Four_pattern.py | 666 | 4.28125 | 4 | """
Write a Python program to construct the following pattern, using a nested for loop.
*
**
***
****
*****
****
***
**
*
"""
for rows1 in range(1,6):
for column_increment in range(1,rows1+1):
print("*", end=" ")
print()
for rows2 in range(4,0,-1):
for column_decrement in range(1,rows2+1):
... | true |
529b127ab15d54aa298124f2721c83d40a3f7aa5 | sanjiv576/LabExercises | /Conditions/Five.py | 848 | 4.125 | 4 | """
game finding a secret number within 3 attempts using while loop
import random
randomNum = random.randint(1, 3)
guessNum = int(input("Guess number from 1 to 10 : "))
attempt = 1
while attempt <= 2:
if guessNum == randomNum:
print("Congratulations! You have have found the secret number.")
break
... | true |
9f51539430d010667a5c75af4521382f4a565761 | sadashiv30/pyPrograms | /rmotr/class1-Datatypes/printNumbersWithStep.py | 864 | 4.28125 | 4 | """
Write a function that receives a starting number, an ending number (not inclusive) and a step number, and print every number
in the range separated by that step.
Example:
print_numbers_with_a_step(1, 10, 2)
> 1
> 3
> 5
> 7
> 9
Extra:
* Use a while loop
* Use a flag to denote if the ending nu... | true |
84d9e2001b0c977317c5b8a4b76f7b61f12fac76 | sadashiv30/pyPrograms | /rmotr/class2-Lists-Tuples-Comprehensions/factorial.py | 671 | 4.375 | 4 | """
Write a function that produces all the members to compute
the factorial of a number. Example:
The factorial of the number 5 is defined as: 5! = 5 x 4 x 3 x 2 x 1
The terms o compute the factorial of the number 5 are: [5, 4, 3, 2, 1].
Once you have that function write other function that will compute the
factorial... | true |
b3525d32194630f56c9fcc3597096be6bf1e4e51 | subaroo/HW08 | /mimsmind0.py | 2,341 | 4.65625 | 5 | #!/usr/bin/env python
# Exercise 1
# the program generates a random number with number of digits equal to length.
# If the command line argument length is not provided, the default value is 1.
# Then, the program prompts the user to type in a guess,
# informing the user of the number of digits expected.
# The pro... | true |
9afb638ca9a41c3b77c2ec6181f4b3f257c65196 | L7907661/21-FunctionalDecomposition | /src/m1_hangman.py | 2,152 | 4.4375 | 4 | """
Hangman.
Authors: Zeyu Liao and Chen Li.
""" # done: 1. PUT YOUR NAME IN THE ABOVE LINE.
# done: 2. Implement Hangman using your Iterative Enhancement Plan.
####### Do NOT attempt this assignment before class! #######
import random
def main():
print('I will choose a random secret word from a dictionary.'
... | true |
11bec9486cb05e5a2957249cb47d750f4a947934 | ElficTitious/tarea3-CC4102 | /utilities/math_functions.py | 848 | 4.40625 | 4 | from math import *
def next_power_of_two(x):
"""Returns the next power of two after x.
"""
result = 1 << ceil(log2(x))
return result
def is_power_of_two(x):
"""Returns if x is a power of two or not.
"""
return log2(x).is_integer()
def prev_power_of_ten(x):
"""Returns the previous powe... | true |
d5a2fa6dbe4e5ba184c1ffc6b6d6f513946e6882 | jonathanstallings/data-structures | /merge_sort.py | 1,850 | 4.15625 | 4 | """This module contains the merge_srt method, which performs an
in-place merge sort on a passed in list. Merge sort has a best case time
complexity of O(n log n) when list is nearly sorted, and also a worst case of
O(n log n). Merge sort is a very predictable and stable sort, but it is not
adaptive. See the excellent '... | true |
51433315d604c4cb973f97a875954c722674aa78 | kristinadarroch/django | /Django-Python-Full-Stack-Web-Devloper-master/Python_Level_One/my-notes/lists.py | 1,099 | 4.25 | 4 | # LISTS
my_list = ['adfsjkfdkfjdsk',1,2,3,23.2,True,'asd',[1,2,3]]
print(my_list)
# PRINTS THE LENGTH OF A LIST.
this_list = [1,2,3]
print(len(this_list))
print(my_list[0])
my_list[0] = 'NEW ITEM'
print(my_list)
# .append can add something to a list
my_list.append('another new item - append')
print(my_list)
listt... | true |
e80183defbc0fadafe7c978157eaff786387f22d | GaikwadHarshad/ML-FellowShip-Program | /WEEK 1/program41.py | 831 | 4.28125 | 4 | """ Write a Python program to convert an integer to binary keep leading zeros.
Sample data : 50
Expected output : 00001100, 0000001100 """
def convert_to_binary(num):
if num < 0:
return 0
else:
i = 1
bin1 = 0
# loop for convert integer to binary number
while num... | true |
beb2df68eb4747c631909dad5c61ab3b01e5f902 | GaikwadHarshad/ML-FellowShip-Program | /WEEK_2/String/program9.py | 1,653 | 4.40625 | 4 | """ Write a Python program to display formatted text (width=50) as output. """
from myprograms.Utility import UtilityDS
class String9:
string = ''' Python is a widely used high-level, general-purpose, interpreted,
dynamic programming language. Its design philosophy emphasizes
code readability, and its syntax... | true |
533a25953d7f4b983fb28c0895016e3c72231845 | GaikwadHarshad/ML-FellowShip-Program | /WEEK 2/List/program11.py | 1,152 | 4.125 | 4 | """ Write a Python program to generate all permutations of a list in Python. """
from myprograms.Utility import UtilityDS
class List11:
create = []
k = 0
@staticmethod
# function to perform operations on list
def specified_list():
while 1:
print("-----------------------------... | true |
cdf3c07056e0fa2a6421a02aeefb69e535947ca6 | GaikwadHarshad/ML-FellowShip-Program | /WEEK 1/program6.py | 360 | 4.1875 | 4 | """ Write a Python program to calculate number of days between two dates.
Sample dates : (2014, 7, 2), (2014, 7, 11)
Expected output : 9 days. """
from datetime import date
date1 = date(2019, 2, 14)
date2 = date(2019, 2, 26)
calculatedDays = date2 - date1
delta = calculatedDays
print("Total numbers of days be... | true |
8bab9aa97d88d37ba0b094f84a1c61c09a9e4e64 | GaikwadHarshad/ML-FellowShip-Program | /WEEK 2/Tuple/program5.py | 737 | 4.15625 | 4 | """ Write a Python program to find the repeated items of a tuple. """
from myprograms.Utility import UtilityDS
class Tuple5:
tuple1 = (3, 5, 6, 5, 4, 3)
# function performing on tuple to get items repeat or not
def repeat_items(self):
try:
print("Tuple1 : ", self.tuple1)
... | true |
77e973baa87d0c6e53dda194e49c79945f734a61 | Oyelowo/Exercise-2 | /average_temps.py | 1,161 | 4.5 | 4 | # -*- coding: utf-8 -*-
"""
Prints information about monthly average temperatures recorded at the Helsinki
Malmi airport.
Created on Thu Sep 14 21:37:28 2017
@author: oyedayo oyelowo
"""
#Create a script called average_temps.py that allows users to select a
#month and have the monthly average temperatu... | true |
cc1fdd0a07c688ee2bf9c5449765ed328f4455e4 | udbhavsaxena/pythoncode | /ex1/ex3.py | 420 | 4.1875 | 4 | print "I will now count my chickens:"
print "Hens", 25+30/6
print "Roosters", 100-25 * 3%4
print "Now I will count my eggs:"
print 3+2+1-5+4%2-1/10
print "Is it true that 3+2<5-7?"
print 3+2<5-7
print "What's 3+2?", 3+2
print "What's 5-7?", 5-7
print "Oh that is why it is false"
print "How about some more"
pri... | true |
6a0ddaf8d7fef42fb22e047150e9914dc118efb7 | derekb63/ME599 | /lab2/sum.py~ | 683 | 4.375 | 4 | #! usr/bin/env python
# Derek Bean
# ME 599
# 1/24/2017
# Find the sum of a list of numbers using a for loop
def sum_i(list):
list_sum = 0
for i in list:
list_sum += i
return list_sum
# Caclulate the sum of a list of numbers using recursion
def sum_r(list):
list_sum = 0
return list_sum
if __name__ =... | true |
c55dfb4e6512462c5d25aefeb533de1fe4579993 | derekb63/ME599 | /hw1/integrate.py | 2,485 | 4.3125 | 4 | #! usr/bin/env python
# Derek Bean
# ME 599
# Homework 1
# 1/24/2017
from types import LambdaType
import numpy as np
import matplotlib.pyplot as plt
'''
Integrate uses the right rectangle rule to determine the definite integral of
the input function
Inputs:
f: a lambda function to be inetgrated
a:... | true |
fd4c56fb77d2bca1b5837022acf9da5ab71d5082 | AR123456/python-deep-dive | /work-from-100-days/Intermediate days 15-100/Day-19/turtle-race-anne-final/main.py | 1,318 | 4.28125 | 4 | from turtle import Turtle, Screen
from random import randint
is_race_on = False
screen = Screen()
# set screen size using setup method
screen.setup(width=500,height=400)
# set the output of the screen.textinput() to user_bet
user_bet =screen.textinput(title="Make your bet", prompt="Who do you think will win the race?... | true |
4409d6ef0ae89f509322a9987188386ae484e566 | AR123456/python-deep-dive | /work-from-100-days/Intermediate days 15-100/Day-25/Day-26-pandas-rows-cols/main.py | 1,617 | 4.21875 | 4 |
#
# weather_list = open("weather_data.csv", "r")
# print(weather_list.readlines())
#
# with open("weather_data.csv") as data_file:
# data = data_file.readlines()
# print(data)
# # use pythons csv library https://docs.python.org/3/library/csv.html
# import csv
# with open("weather_data.csv") as data_file:
# ... | true |
ebb49e7ace998b22a0c5d71abdd116d0a3463b8d | AR123456/python-deep-dive | /work-from-100-days/Intermediate days 15-100/Day-24/Day-24-file-write-with/main.py | 709 | 4.1875 | 4 | #
# file= open("my_file.txt")
#
# contents =file.read()
# print(contents)
# #also need to close the file
# file.close()
####### another way to open a file that dosent require an explice file.close, does it for you
#this is read only mode - mode defaluts to "r
with open("my_file.txt")as file:
contents = file.read()... | true |
f79bc79ea4993f59665d55a4e3b5671920e575cf | AR123456/python-deep-dive | /work-from-100-days/Intermediate days 15-100/Day-21/Class-Inheritance/main.py | 814 | 4.40625 | 4 | class Animal:
def __init__(self):
#defining attributes
self.num_eyes = 2
# defining method associated with the animal class
def breathe(self):
print("Inhale, exhale.")
# passing Animal into Fish class so Fish has all the attributes
# and methonds from the Animal class, then can have some... | true |
fea9c9a4deb9d09218eb3957ed0a74fe7b760609 | DenysZakharovGH/Python-works | /HomeWork4/The_Guessing_Game.py | 624 | 4.15625 | 4 | #The Guessing Game.
#Write a program that generates a random number between 1 and 10 and let’s
#the user guess what number was generated. The result should be sent back
#to the user via a print statement.
import random
RandomVaried = random.randint(0,10)
while True:
UserGuess = int(input("try to guess the nu... | true |
47bcd9f7c97992fc73a6c7df2f318f760ed1a67e | DenysZakharovGH/Python-works | /PythonHomework_6_loops.py | 943 | 4.375 | 4 | #1
#Make a program that generates a list that has all squared values of integers
#from 1 to 100, i.e., like this: [1, 4, 9, 16, 25, 36, …, 10000]
Squaredlist = [x**2 for x in range(100)]
print(Squaredlist)
#2
#Make a program that prompts the user to input the name of a car, the program
#should save the input in a li... | true |
2213d66214f18d0bf2e78837e6de8b2ed5058a9e | vamshidhar-pandrapagada/Data-Structures-Algorithms | /Array_Left_Rotation.py | 1,169 | 4.3125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Jun 11 04:32:11 2017
@author: Vamshidhar P
"""
"""A left rotation operation on an array of size shifts each of the array's elements unit to the left.
For example, if left rotations are performed on array 1 2 3 4 5, then the array would become 3 4 5 1 2
Given an array of ... | true |
d533d93ced02eb641961555b90435128c9489dae | rohangoli/PythonAdvanced | /Leetcode/LinkedList/p1215.py | 1,863 | 4.1875 | 4 | ## Intersection of Two Linked Lists
# Example 1:
# Input: intersectVal = 8, listA = [4,1,8,4,5], listB = [5,6,1,8,4,5], skipA = 2, skipB = 3
# Output: Intersected at '8'
# Explanation: The intersected node's value is 8 (note that this must not be 0 if the two lists intersect).
# From the head of A, it reads as [4,1,8,... | true |
010f18a43932a52eb66c529dd57b85243f369b93 | rohangoli/PythonAdvanced | /Leetcode/Arrays/p1164.py | 672 | 4.25 | 4 | ## Reverse Words in a string
# Example 1:
# Input: s = "the sky is blue"
# Output: "blue is sky the"
# Example 2:
# Input: s = " hello world "
# Output: "world hello"
# Explanation: Your reversed string should not contain leading or trailing spaces.
# Example 3:
# Input: s = "a good example"
# Output: "example g... | true |
0573712cf14f4e7fb92107ddee746a70dff5d9e2 | mosesxie/CS1114 | /Lab #4/q1.py | 485 | 4.125 | 4 | xCoordinate = int(input("Enter a non-zero number for the X-Coordinate: "))
yCoordinate = int(input("Enter a non-zero number for the Y-Coordinate: "))
if xCoordinate > 0 and yCoordinate > 0:
print("The point is in the first quadrant")
elif xCoordinate < 0 and yCoordinate > 0:
print("The point is in the second... | true |
98612114f9f90aa761c9a75921703e0b96f78c5f | apaskulin/euler | /problems.py | 1,989 | 4.15625 | 4 | #!/user/bin/env python2
def problem_01():
# 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.
sum = 0
for i in range(1, 1000):
if i % 3 == 0 or i % 5 == 0:
... | true |
6fd9f34ee976576be14c02a6e9aebbd12d504a30 | jonathan-durbin/fractal-stuff | /gif.py | 1,371 | 4.125 | 4 | #! /usr/bin/env python3
# gif.py
"""Function to generate a gif from a numbered list of files in a directory."""
def generate_gif(directory: ("Folder name", "positional"),
image_format: ('Image format', 'positional') = '.png',
print_file_names=False):
"""Generate a gif from a numb... | true |
8cc2bcc6aa36aa941b90bb538609c818e6509556 | angelmtenor/AIND-deep-learning | /L3_NLP/B_read_text_files.py | 1,140 | 4.25 | 4 | """Text input functions."""
import os
import glob
def read_file(filename):
"""Read a plain text file and return the contents as a string."""
# Open "filename", read text and return it
with open(filename, 'r') as f:
text = f.read()
return text
def read_files(path):
"""Read all files that ... | true |
705d9deaa4f8bcec1980a6756d2e18cfbf7e955e | LeBoot/Practice-Code | /Python/Udemy-The-Python-Bible/name_program.py | 309 | 4.1875 | 4 | #Ask user for first then last name.
namein = input("What is your full name? ").strip()
#Reverse order to be last, first.
forename = namein[:namein.index(" "):]
surname = namein[namein.index(" ") + 1 ::]
#Create output.
output = "Your name is {}, {}.".format(surname, forename)
#Print output.
print(output)
| true |
cc596f40bc8604a4f83499ae2521c2ebf336b734 | ericachesley/code-challenges | /zero-matrix/zeromatrix.py | 1,293 | 4.25 | 4 | """Given an NxM matrix, if a cell is zero, set entire row and column to zeroes.
A matrix without zeroes doesn't change:
>>> zero_matrix([[1, 2 ,3], [4, 5, 6], [7, 8, 9]])
[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
But if there's a zero, zero both that row and column:
>>> zero_matrix([[1, 0, 3], [4, 5, 6], [7, 8,... | true |
2a32fb6338772f353e2432df396221bc027a6838 | MikeyABedneyJr/CodeGuild | /python_basic_exercises/class2(dictionaries).py | 519 | 4.4375 | 4 | dictionary = {'name':'Mikey', 'phone_number': '867-5309'} #python orders in most memory efficient manner so phone # might appear first
print dictionary['name']
dictionary['name'] = 'Mykee' #changed value of name
print dictionary['name']
dictionary['age'] = 32
print dictionary #just added a key named "age" which is 32 {... | true |
32094ffec3b86176f0856be0944f89350d9aad16 | newphycoder/USTC_SSE_Python | /练习/练习场1/练习4.py | 343 | 4.3125 | 4 | from tkinter import * # Import all definitions from tkinter
window = Tk()
label = Label(window , text = "Welcome to Python") # Create a "label
button = Button(window , text = "Click Me") # Create a button
label.pack() # PI ace the "label in the window
button.pack() # Place the button in the window
window.mainloop() ... | true |
5bfa5c7b40fa5469f5454f7edb00d366dc137000 | KyleMcInness/CP1404_Practicals | /prac_02/ascii_table.py | 579 | 4.4375 | 4 | LOWER = 33
UPPER = 127
# 1
character = input("Enter a character: ")
ascii_code = ord(character)
print("The ASCII code for {} is {}".format(character, ascii_code))
# 2
ascii_code = int(input("Enter a number between 33 and 127: "))
while ascii_code < LOWER or ascii_code > UPPER:
print("Enter a number greater than o... | true |
0865ce79212062970ef2647f3fa6243b55ce8fde | KyleMcInness/CP1404_Practicals | /prac_04/list_exercises.py | 450 | 4.28125 | 4 | numbers = []
for i in range(5):
number = int(input("Number: "))
numbers.append(number)
print("The first number is {}".format(numbers[0]))
print("The last number is {}".format(numbers[-1]))
numbers.sort()
print("The smallest numbers is {}".format(numbers[0]))
print("The largest number is {}".format(numbers[-1]... | true |
fe1ae86c4f9fb4ba800a0c7d478f617a13df498d | A01029961/TC1001-S | /Python/01_turtle.py | 663 | 4.5625 | 5 | #!/usr/bin/python3
"""
First example of using the turtle graphics library in Python
Drawing the shape of a square of side length 400
Gilberto Echeverria
26/03/2019
"""
# Declare the module to use
import turtle
#Draw a square, around the center
side = 400
# Move right
turtle.forward(side/2)
# Turn to the left
turtle... | true |
145b7416b4f46ff8fa1b60cf57ac425cfc911fae | mohsinkazmi/Capture-Internet-Dynamics-using-Prediction | /Code/kNN/kNN.py | 1,328 | 4.1875 | 4 | from numpy import *
from euclideanDistance import euclideanDistance
def kNN(k, X, labels, y):
# Assigns to the test instance the label of the majority of the labels of the k closest
# training examples using the kNN with euclidean distance.
#
# Input: k: number of nearest neighbors
# X: traini... | true |
6122e404e29b3c97b7fe2bdd8705bfc7f7bb202f | Vinay795-rgb/code | /Calendar.py | 496 | 4.3125 | 4 | # Write a program to print the calendar of any given year
import calendar
y = int(input("Enter the year : "))
m = 1
print("\n***********CALENDAR*******")
cal = calendar.TextCalendar(calendar.SUNDAY)
# An instance of TextCalendar class is created and calendar. SUNDAY means that you want to start dis[playing t... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.