blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
030d32c1d9e1f809046976a7e1bb2aea87736aed | NixonRosario/crytography-using-Fernet | /main.py | 2,419 | 4.21875 | 4 | # This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
from cryptography.fernet import Fernet # install cryptography and import Fernet
key = Fernet.generate_key() # gen... | true |
ec823e35ba2387cca400cea55d8916034f0123d1 | RayWLMo/Eng_89_Python_Collections | /dict_sets.py | 2,064 | 4.8125 | 5 | # Dictionaries and Sets are both data collections in Python
# Dictionaries
# Dict are another way to manage data but can be a little more Dynamic\
# Dict work as a KEY AND VALUE
# KEY = THE REFERENCE OF THE OBJECT
# VALUE + WHAT THE DATA STORAGE MECHANISM YOU WISH TO USE
# Dynamic as it we have Lists, and anot... | true |
374a8d5bbe59f30f7d8b1a6b9f02c9be92120e91 | group1BSE1/BSE-2021 | /src/chapter5/exercise2.py | 292 | 4.15625 | 4 | largest = None
smallest = None
while True:
num = input('Enter a number: ')
if num =='done':
break
elif largest is None or num > largest:
largest = num
elif smallest is None or num < num:
smallest = num
print('maximum',largest)
print('minimum',smallest) | true |
9250e0bab7e1c634b3aa416c66bce8cddd5ec048 | timurkurbanov/firstPythonCode | /firstEx.py | 463 | 4.46875 | 4 |
# Remember, we get a string from raw_input, but we need an int to compare it
weather = int(25);
# if the weather is greater than or equal to 25 degrees
if weather >= 25:
print("Go to the beach!")
# the weather is less than 25 degrees AND greater than 15 degrees
elif weather < 25 and weather > 15:
print("Go ho... | true |
7bc262beb842765e249819a987fd68c68f3bd0b1 | MTaylorfullStack/flex_lesson_transition | /jan_python/week_one/playground.py | 1,191 | 4.15625 | 4 | print("Hello World")
## Data Types
## String
collection_of_characters="hrwajfaiugh5uq34ht834tgu89398ht4gh0q4tn"
collection_of_characters+="!!!!!!!!!!!!!"
name="Adam"
stack="Python"
# print(f"The student {name} is in the {stack} stack")
## Numbers
## Operators: +, -, /, *, %
ten=10
one_hundred=100
# print(one_hu... | true |
6a0b6f550fbd00cf80b035789b7364626d2b55d1 | wesleyhooker/assign1 | /ccpin.py | 1,355 | 4.40625 | 4 | #!/usr/bin/env python3
"""
Validates that the user enteres the correct PIN number
"""
def valid_input(input):
"""
Checks for valid PIN Number
Argument:
input = the users inputted PIN
Returns:
Any Errors with the input
TRUE if it passes, False if it doenst
"""
if(len(inp... | true |
384cb75137c4702da88da4a227e2af8c72f3a0a8 | jeffvswanson/DataStructuresAndAlgorithms | /Stanford/10_BinarySearchTrees/red_black_node.py | 2,069 | 4.25 | 4 | # red_black_node.py
class Node:
"""
A class used to represent a Node in a red-black search tree.
Attributes:
key: The key is the value the node shall be sorted on. The key can be an integer,
float, string, anything capable of being sorted.
instances (int): The number o... | true |
2c6883f73522c971670cae797200f454968a635f | Neeragrover/HW04 | /HW04_ex00.py | 1,265 | 4.21875 | 4 | #!/usr/bin/env python
# HW04_ex00
# Create a program that does the following:
# - creates a random integer from 1 - 25
# - asks the user to guess what the number is
# - validates input is a number
# - tells the user if they guess correctly
# - if not: tells them too high/low
# - only lets t... | true |
3ec08d9e5985e5ab19eae234835ae990bd31d8ac | lamngockhuong/python-guides | /basic/dictionaries/dictionaries-1.py | 1,106 | 4.46875 | 4 | # https://www.w3schools.com/python/python_dictionaries.asp
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
print(thisdict)
x = thisdict["model"]
print(x)
y = thisdict.get("model")
print(y)
# Change values
thisdict["year"] = 2019
print(thisdict)
# Return values of a dictionary
for x in ... | true |
524b7612faa6b189b228d9f8e6aca0f69fbf6364 | lamngockhuong/python-guides | /basic/strings/strings-2.py | 497 | 4.375 | 4 | # https://www.w3schools.com/python/python_strings.asp
x = "Hello, world!"
print(x[2:5])
y = " Hello world "
print(y.strip()) # remove any whitespace from the beginning or the end
print(len(y)) # return the length of a string
print(y.lower()) # return the string in lower case
print(y.upper()) # return the strun... | true |
de9b2cef5eea479083e2932d8291e8ba6a4188bf | kisa411/CSE20211 | /isPalindrom.py | 476 | 4.15625 | 4 |
word = raw_input("Enter a word:")
list = []
start = 0
end = len(word) - 1
def isPalindrome(word):
global start
global end
for letter in word:
list.append(letter)
while (start < end):
if list[start] != list[end]:
return False
else:
return True
s... | true |
b0f26fc98716307747c63e4bbc3921dd660ac6b1 | waddahAldrobi/RatebTut- | /Python Algs copy/print bst by level.py | 504 | 4.125 | 4 | def print_bst(tree):
current_level = [tree.root]
while current_level:
next_level = []
for node in current_level:
print(node.value,end='')
# Logic to start building the next level
##Added
if node.left:
next_level.append(node.left)
... | true |
8fc3791795ba4f7be4da91cf325c64d2a3810572 | alexnicolescu/Python-Practice | /lambda/ex1.py | 289 | 4.1875 | 4 | # Write a Python program to create a lambda function that adds 15 to a given number passed in as an argument, also create a lambda function that multiplies argument x with argument y and print the result.
def l1(x): return x + 15
def l2(x, y): return print(x*y)
print(l1(15))
l2(12, 10)
| true |
c82870abca988247ab2a07c841550bf1e57d36b8 | Adamrathjen/MOD1 | /Module1.py | 1,073 | 4.125 | 4 | import os
print("Character Creator!")
selected = 1
while "4" != selected:
print("Make new Character: 1")
print("Delete character: 2")
print("See current characters: 3")
print("Quit: 4")
selected = input("Make your selection: ")
if selected == "1":
print("you selected 1")
char... | true |
7b67bdcd6f6dfef936e27507d5b5390562475359 | sohinipattanayak/Fundamentals_Of_Python | /p2_palindrome_num.py | 638 | 4.21875 | 4 | #Check if num is plaindrome
num=int(input("Enter the number: "))
num_str=str(num) #Type-casting the number to String
flag=0
#No need to iterate throught the whole of string
#Just iterate till the half of the string
#If the last two match it is automatically a reverse
for i in range(len(num_str)//2): #halfing the list... | true |
a94426f5e57d3027080f43255a23b785fc829bae | alaamarashdeh92/CA06---More-about-Functions-Scope | /P3.py | 2,132 | 4.375 | 4 | # Shopping List
# Your shopping list should keep asking for new items until nothing is entered (no input followed by enter/return key).
# The program should then print a menu for the user to choose one of the following options:
# (A)dd - To add a new item to the list.
# (F)ind - To search for an item in the list.... | true |
d6482340a7a0125c28ac00e22c30974bb3edf79d | riteshsharma29/Python_data_extraction | /ex_2.py | 501 | 4.28125 | 4 | #!/usr/bin/python
# coding: utf-8 -*-
#This example shows reading a dataset using csv reader
import csv
#creating an empty list
MonthlySales = []
with open('data/MonthlySales.csv', 'r') as f:
reader = csv.DictReader(f)
for row in reader:
MonthlySales.append(row)
for a in MonthlySales:
print a
... | true |
6a296745a5d413d0f2c23635425fba1e751d1af1 | DanielOjo/Iteration | /Classroom exercises/Development/Iteration Class Exercise (Development Part 2).py | 347 | 4.21875 | 4 | #DanielOgunlana
#31-10-2014
#Iteration Class Exercise (Development Part 2)
number_stars = int(input("How many stars do you want on each row:"))
number_display = int(input("How many times would you like this to display?:"))
stars_printed = "*"
for stars in range(1,number_display+1):
print(stars_printed*n... | true |
d223031deac627cd02f4c4cb223534b185b07579 | asterane/python-exercises | /other/friend/Multiplication Tables.py | 204 | 4.21875 | 4 | print("What multiplication table would you like? ")
i = input()
print("Here's your table: ")
for j in range(11):
print(i, " x ", j, "=", i * j)
# The code above creates the table... I hope. #
| true |
a0208582f00a6f392e80905246e296dd45e843ca | b-ark/lesson_4 | /Task3.py | 820 | 4.375 | 4 | # Create a program that reads an input string and then creates and prints 5 random strings
# from characters of the input string.
# For example, the program obtained the word ‘hello’, so it should print 5 random strings(words)
# that combine characters ‘h’, ‘e’, ‘l’, ‘l’, ‘o’ -> ‘hlelo’, ‘olelh’, ‘loleh’ …
# Tips: Use ... | true |
14a4b02855d5b08a9a4c3b2eb8ee8e69474fed12 | Atularyan/Letsupgrade-Assignment | /Day_3_Assignment/Day_3(Question2).py | 338 | 4.25 | 4 | """
Question 2
Define a function swap that should swap two values and print the swapped variables outside the
swap function.
"""
def swap(n):
rev=0
while(n>0):
rem=n%10
rev=(rev*10)+rem
n=n//10
return (rev+n)
n=int(input("Enter the number = "))
res=swap(n)
print("swap... | true |
e47a5b27a63194e1a59814f5ce3d9d5fe1f0c5cc | vijay-Jonathan/Python_Training | /bin/44_classes_static_methods.py | 2,156 | 4.15625 | 4 | """
Client Requiremnt is :for 43rd example, add method to compute percentage,
if student pass marks, method should return percentage.
Now,
for this compute_percentage method, not required to pass instance object OR
class object, only passing 2 marks is enough method will return perecnetage.
Other methods inside the ... | true |
f14ac23d41d53f6cb09d94da5facd833aa3bb7f6 | vijay-Jonathan/Python_Training | /bin/2_core_datatypes.py | 1,842 | 4.25 | 4 | """
CORE DATA TYPES :
Similar to other languages, in python also we ALREADY have SOME options to store SOME kind of data.
In that,
1. int,float,hex,bin classes : ALREADY have option to store numbers like int, float, hex, bin, oct etc
2. str class : ALREADY have option to store Strings like "My Name", "My Addess" etc
3... | true |
ba07cec6d0f3f8f0131b8ac1680314dedb04dd89 | dmonzonis/advent-of-code-2019 | /day3/day3.py | 2,192 | 4.28125 | 4 | def compute_path(path):
"""Return a set with all the visited positions in (x, y) form"""
current = [0, 0]
visited = {}
total_steps = 0
for move in path:
if move[0] == 'U':
pos = 1
multiplier = 1
elif move[0] == 'D':
pos = 1
m... | true |
17baad513d548bf71b1ec6eea648fa0ca2917d7d | Ads99/python_learning | /python_crash_course/names.py | 924 | 4.15625 | 4 | name = "ada lovelace"
print(name.title())
print(name.upper())
print(name.lower())
first_name = "ada"
last_name = "lovelace"
full_name = first_name + " " + last_name
print(full_name)
message = "Hello, " + full_name.title() + "!"
print(message)
# whitespace demo
print("\tPython")
print("Languages:\nPython\nC\nJavaScri... | true |
1eb80efb19d1ef10b0b5ef2cfe6db47a3d3dc2ff | Ads99/python_learning | /python_crash_course/_11_3_example_employee_class.py | 1,023 | 4.46875 | 4 | # Example 11.3 - Employee
# Write a class called Employee. The __init__() method should take in a first
# name, last name and an annual salary and store each of these as attributes.
# Write a method called give_raise() that adds $5000 to the annual salary by
# default but also accepts a different raise amount
class Em... | true |
8b918360be7f45468c503e81f9c32b52e174ca17 | AdarshSubhash/C-97- | /hwpro.py | 351 | 4.15625 | 4 | number=6
guess=int(input("Guess a number between 1 to 10"))
if(guess==number):
print("You Guessed The Right Number")
elif(guess>number):
print("Try a bit lower number")
guess=int(input("Guess a number between 1 to 10"))
else :
print("Try a bit higher number")
guess=int(input("Guess a number... | true |
bb9d7c309c187c7106e758685a02ffb1a9279c24 | sourav9064/coding-practice | /coding_10.py | 746 | 4.1875 | 4 | ##Write a code to check whether no is prime or not.
##Condition use function check() to find whether entered no is
##positive or negative ,if negative then enter the no,
##And if yes pas no as a parameter to prime()
##and check whether no is prime or not?
num = int(input())
def check(n):
if n >= 0:
... | true |
9be112de553bec1a1af362c51ecd2877e622c214 | sourav9064/coding-practice | /coding_22.py | 1,385 | 4.21875 | 4 | ##A doctor has a clinic where he serves his patients. The doctor’s consultation fees are different for different groups of patients depending on their age. If the patient’s age is below 17, fees is 200 INR. If the patient’s age is between 17 and 40, fees is 400 INR. If patient’s age is above 40, fees is 300 INR. Write ... | true |
f2e698e05e449961409b844e9bc4b667a2042cab | sourav9064/coding-practice | /coding_8.py | 1,058 | 4.15625 | 4 | ##The program will recieve 3 English words inputs from STDIN
##
##These three words will be read one at a time, in three separate line
##The first word should be changed like all vowels should be replaced by *
##The second word should be changed like all consonants should be replaced by @
##The third word should b... | true |
f39aa64260dbce9cbe7d34c12129b2427f91a2f8 | Krista-Pipho/BCH-571 | /Lab_5/Lab_5.2.py | 811 | 4.4375 | 4 | # Declares an initial list with 5 values
List1 = [1,2,3,4,5]
# Unpacks this list into 5 separate variables
a,b,c,d,e = List1
# Prints both the list and one of the unpacking variables
print(List1)
print(a)
# Changes the value of a to 6
a = 6
# Prints both the list and a, and we can see that changing a d... | true |
d9fbf08a599b0a04491081eece5292114ba12039 | hamburgcodingschool/L2CX-November | /lesson 6/dashes.py | 413 | 4.21875 | 4 | # ask the user for a word
# seperate the letters with dashes:
# ex: banana becomes b-a-n-a-n-a
def dashifyWord(word):
dashedWord = ""
firstTime = True
for letter in word:
if firstTime:
firstTime = False
else:
dashedWord += "-"
dashedWord += letter
retur... | true |
6a79b8a8424d83855aa72aefdf873be19b1a9ecd | manishg2015/python_workpsace | /python-postrgress/main.py | 1,625 | 4.25 | 4 | from sqlitedatabase import add_entry,get_entries,create_connection,create_table
menu = """ Welcome to the programming diary!
Please select one of the following options:
1) Add new entry for today.
2) View entries.
3) Exit.
Your selection:
"""
welcome = "**Welcome to the programing diary!**"
# entries = [
# {"c... | true |
66703e13e0e831b7472ac1d5bb3df64e0af61a59 | RobRoseKnows/umbc-cs-projects | /umbc/CMSC/2XX/201/Homeworks/hw8/hw8_part1.py | 685 | 4.4375 | 4 | # File: hw8_part1.py
# Author: Robert Rose
# Date: 11/24/15
# Section: 11
# E-mail: robrose2@umbc.edu
# Description:
# This program takes a list from user input and outputs it in reverse using
# recursion.
def main():
integers = []
number = int(input("Enter a number to append to the list, or -1 to st... | true |
e97487959ffb477fed5bb5dde9019144a7f6536b | RobRoseKnows/umbc-cs-projects | /umbc/CMSC/2XX/201/Homeworks/hw2/hw2.py | 2,425 | 4.34375 | 4 | # File: hw2.py
# Author: Robert Rose
# Date: 9/12/15
# Section: 11
# Email: robrose2@umbc.edu
# Description:
# This file contains mathmatical expressions as
# part of Homework 1.
print("Robert Rose")
print("Various math problem solutions as part of Homework 1.")
# Question 1:
# Expected output: 24
num1 = (7 ... | true |
120b363afdecbbc5f67640a53cad242b5c97ad01 | huangdaweiUCHICAGO/CAAP-CS | /Assignment 1/cash.py | 890 | 4.1875 | 4 | # Dawei Huang
# 07/17/2018
# CAAP Computer Science Assignment 1
# Programs for Part 1 of the assignment is contained in the file hello.py
# Programs for Part 2 of the assignment is contained in the file cash.py
# Part 2
print("Part 2: Change Program\n")
print("This program will prompt user for the amount of change an... | true |
daabf510c6a6fd05ec5338da302af3c071c34015 | bogdanlungu/learning-python | /rename_files.py | 727 | 4.21875 | 4 | """
Renames all the files from a given directory by removing the numbers from
their names - example boston221.jpg will become boston.jpg
"""
import os
from string import digits
# define the function
def rename_files():
# get the file names from a folder
file_list = os.listdir(r"C:\Python\tmp\prank")
... | true |
1e38094a5fa47b540c7a5350010c74bc389ab13c | bogdanlungu/learning-python | /combinations.py | 752 | 4.46875 | 4 | """This programs computes how many combinations are possible
to be made from a collection of 'n' unique integers grouped under 'g' elements.
You need to specify the length of the collection and how many elements at a time you
want to group from the collection.
The number of possible combinations will be printed."""
# p... | true |
f59a50d4c5a1d9fdf489097819905c086ee06df5 | CoranC/Algorithms-Data-Structures | /Cracking The Coding Interview/Chapter Nine - Recursion and Dynamic Programming/9_2__xy_grid.py | 734 | 4.25 | 4 | """
Imagine a robot sitting on the upper left corner of an X by Y grid. The robot can
only move in two directions: right and down. How many possible paths are there for the robot to go
from (0,0) to (X,Y)?
"""
#Workings
"""
Grid
[
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]
]
Answer
[
[6, 3, 1],
[3, 2, 1],
[1, 1, 0]... | true |
4ef0fe0dfebb3c739f8d52ea017b78b75a4076a0 | shadman19922/Algorithm_Practice | /H_Index/h_index_sorted_array.py | 783 | 4.21875 | 4 | def compute_h_index(Input):
#Input.sort()
left = 0
right = len(Input) - 1
h_idx = -2
while left < right:
middle = (int)(left + (right - left)/2)
middle_element = Input[middle]
remaining_elements = right - middle + 1
if middle_element <= remaining_elements:
... | true |
9ec4277cb9d0f88290a5f1c7abd4815d12677a90 | mdisieno/Learning | /Python/FCC_PythonBeginner/14_ifStatements.py | 278 | 4.15625 | 4 | isMale = True
isTall = False
if isMale and isTall: #checks if either true
print("You are a tall male")
elif isMale and not(isTall):
print("You are a male")
elif not(isMale) and isTall:
print(("You are not a male, but are tall"))
else:
print("You are a female")
| true |
916e34cc0cce126412c21d0c4cb71fc640f2e73d | SaM-0777/OOP | /Strings.py | 462 | 4.3125 | 4 | ##Strings in Python
str1 = "Python is Easy"
print(str1[:])
print(str1[::])
print(str1[:3]) ##Print first 3 characters
print(str1[-2:3])
##Slicing of String in Python
s = "Computer Science"
slice_1 = slice(-1, -6, -1)
slice_2 = slice(1, 6, -1)
slice_3 = slice(0, 5, 2)
print(s[slice_1])
print(s[slice_2])
print(s[sli... | true |
2624adf68591e885926d1a3fea74a5c4183b126d | SaM-0777/OOP | /Dictionary.py | 1,781 | 4.59375 | 5 | ##Dict is an unordered set or collection of items or objects where unique keys are mapped yhe values
##These keys are used to access the corresponding paired value. While the keys are unique, values can be common and repeated
##The data type of a value is also mutable and can change whereas, the data type of keys mus... | true |
f0d0f136058ba7b063ff00fe6e4e9165f106d0c2 | Sjaiswal1911/PS1 | /python/Lists/methods_1.py | 1,030 | 4.25 | 4 | # LIST METHODS
# Append
# list.append(obj)
# Appends object obj to list
list1 = ['C++', 'Java', 'Python']
print("List before appending is..", list1)
list1.append('Swift')
print ("updated list : ", list1)
del list1
# Count
# list.count(obj)
# Returns count of how many times obj occurs in list
aList = [123, 'xyz', 'za... | true |
15449e1043649cf221e878405e1db4437bb74bfb | manish711/ml-python | /regression/multiple_linear_regression/multiple_linear_regression.py | 1,688 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
@author: manishnarang
Multiple Linear Regression
"""
#Importing Libraries
import numpy as np #contains mathematical tools.
import matplotlib.pyplot as plt #to help plot nice charts.
import pandas as pd #to import data sets and manage data sets.
#Importing Data Set - difference bet... | true |
9aae48aeae5c81ef96ed1e28e6764e67a89fc4fa | FordMcLeod/witAdmin | /python/rockpaperscissors.py | 2,234 | 4.53125 | 5 | # Rock Paper scissors demo for python introduction. SciCamps 2017
# Extentions: Add options for lives, an option to ask the player to play again.
# 2 player mode. Add another option besides rock/paper/scissors. etc.
import random
import time
computer = random.randint(0,2) # Le... | true |
d81c8918a31ad2299039cdcc2517d1eeacb72599 | RyuAsuka/python-utils | /color-code-change.py | 2,192 | 4.125 | 4 | import sys
usage = """
Usage:
python color-code-change.py <rgb|hex> <number>
Arguments:
rgb: Convert RGB color to hex number style.
hex: Convert hex number color code to RGB color number.
Examples:
python color-code-change.py rgb 100 90 213 -> #645AD5
python color-code-change.py hex... | true |
6fb000907798ff6426fd8fc933ecf2cc5656ab40 | ravularajesh21/Python-Tasks | /Count number of alphabets,digits and special characters in STRING.py | 532 | 4.28125 | 4 | # Count number of alphabets,digits and special characters
string=input('enter string:')
alphabetcount=0
digitcount=0
specialcharactercount = 0
for x in string:
if x>='A' and x<='Z' or x>='a' and x<='z':
alphabetcount = alphabetcount + 1
elif x>='0' and x<='9':
digitcount=digitcou... | true |
c7cf39004c6961400afcb2983112060aba156f44 | ravularajesh21/Python-Tasks | /Palindrome 1.py | 553 | 4.5 | 4 | # Approach 1
date = input('enter the date in dd/mm/yyyy format:')
given_date = date.replace('/', '')
reversed_date = given_date[::-1]
if given_date == reversed_date:
print(date,'is palindrome')
else:
print('It is not palindrome')
# Approach 2
day = input('enter day:')
month = input('e... | true |
85e1e5c1adbc4daf79aaebaa31a2514e523dcef9 | KotaCanchela/PythonCrashCourse | /6 Dictionaries/pizza.py | 774 | 4.34375 | 4 | # Store information about a pizza being ordered.
pizza = {
'crust': 'thick',
'toppings': ['mushrooms', 'extra cheese']
}
# Summarise the order
print(f"You ordered a {pizza['crust']}-crust pizza with the following toppings: ")
for topping in pizza['toppings']:
print("\t" + topping)
# favourite languages... | true |
b3f906c56f714ca8d5e724b607dbe2e8d071b662 | KotaCanchela/PythonCrashCourse | /6 Dictionaries/favourite_languages.py | 1,860 | 4.5 | 4 | # Break a large dictionary into several lines for readability
# Add a comma after last key-value pair to be ready to add any future pairs
favourite_languages = {
'jen': 'python',
'sarah': 'c',
'edward': 'ruby',
'phil': 'python',
}
sarah_language = favourite_languages['sarah'].title()
print(f"Sarah's f... | true |
9656f8e78d643569f078cf363ca57b4af32cb8ad | KotaCanchela/PythonCrashCourse | /9 Classes/9-8_Privileges.py | 1,844 | 4.28125 | 4 | # Write a separate Privileges class. The class should have one attribute, privileges,
# that stores a list of strings as described in Exercise 9-7. Move the show_privileges()
# method to this class. Make a Privileges instance as an attribute in the Admin class.
# Create a new instance of Admin and use your method to ... | true |
4d440d271bd189b22db644b888408fd001330c81 | KotaCanchela/PythonCrashCourse | /4 working with lists/4-6 Odd Numbers.py | 932 | 4.78125 | 5 | # “4-6. Odd Numbers: Use the third argument of the range() function
# to make a list of the odd numbers from 1 to 20.
# Use a for loop to print each number.
odd_number = [value for value in range(1, 21, 2)]
print(odd_number)
# 4-7. Threes: Make a list of the multiples of 3 from 3 to 30.
# Use a for loop to print the n... | true |
4262c4943e75c83ce8b337b8ec7a7802400760e5 | KotaCanchela/PythonCrashCourse | /10 Files and Exceptions/favourite_number.py | 784 | 4.46875 | 4 | # Write a program that prompts for the user’s favorite number. Use json.dump()
# to store this number in a file. Write a separate program that reads in this
# value and prints the message, “I know your favorite number! It’s _____.”
import json
def ask_number():
"""Asks the user for their favourite number and store... | true |
332454e2039df29fa6c379252da70dcbd5c8a532 | KotaCanchela/PythonCrashCourse | /7 User input and While statements/Counting.py | 609 | 4.375 | 4 | # Using continue in a loop
# continue allows the user to return to the beginning of the loop rather than breaking out entirely
# The continue statement tells Python to ignore the rest of the loop
# Therefore, when current_number is divisible by 2 it loops back
# otherwise when it is odd it goes to the next line (print... | true |
cefb4142ffda596bf0e822678abdabac4209538b | OldLace/Python_the_Hard_Way | /may_19.py | 1,844 | 4.1875 | 4 | #May 19 - Paul Gelot
#Python the Hard Way - Exercise 12
num1 = int(input("Please enter a number: "))
num2 = int(input("Please enter another number: "))
total_sum = num1 + num2
subtract = num1 - num2
product = num1 * num2
division1 = num1 / num2
print("The sum of the two numbers is:", total_sum)
print("The difference... | true |
180c892336d6a048da555972c923c8968874cafc | OldLace/Python_the_Hard_Way | /hw4.py | 1,723 | 4.4375 | 4 |
# 1. Write a Python program to iterate over dictionaries using for loops
character = {"name": "Walter", "surname": "White", "nickname": "Isenberg", "height": "6 foot 7", "hobby": "trafficking"}
for i in character:
print(i,":", character[i])
# 2. Write a function that takes a string as a parameter and returns a ... | true |
51f72b65f476209ce78a087d0c401548be8dbb34 | nivedipagar12/PracticePython | /E7_ListComprehensions.py | 882 | 4.28125 | 4 | '''
************* DISCLAIMER: THESE TASKS WERE POSTED ON https://www.practicepython.org ***********************************
************************* I AM ONLY PROVIDING SOLUTIONS ***************************************************************
Project/Exercise 7 : List Comprehensions (https://www.practicepython.... | true |
76100afdfbeaabc631e5375da7ce9d06553957d3 | nivedipagar12/PracticePython | /E24_DrawAGameBoard.py | 2,666 | 4.4375 | 4 | '''
************* DISCLAIMER: THESE TASKS WERE POSTED ON https://www.practicepython.org ***********************************
************************* I AM ONLY PROVIDING SOLUTIONS ***************************************************************
Project/Exercise 24 : Draw a Game Board (https://www.practicepython.o... | true |
17e09b72eba9b69ffed63b90d1ab3ceaec8b225a | nivedipagar12/PracticePython | /E1_CharacterInput.py | 1,894 | 4.28125 | 4 | '''
************* DISCLAIMER: THESE TASKS WERE POSTED ON https://www.practicepython.org************************************
************************* I AM ONLY PROVIDING SOLUTIONS ***************************************************************
Project/Exercise 1 : Character Input (https://www.practicepython.org/... | true |
a81f36182dee04cd838b6ce101acd217d309ab66 | poojajunnarkar11/CTCI | /CallBoxDevTest-3.py | 567 | 4.53125 | 5 | def is_power_two (my_num):
if my_num == 0:
return False
while (my_num != 1):
if my_num%2 != 0:
return False
my_num = my_num/2
return True
print is_power_two(18)
# Why this will work for any integer input it receives?
# -Because the while loop works until the number is... | true |
00404a17c4abb680cc7424d8e968d4b5bce4de82 | bsakers/Introduction_to_Python | /classes_three.py | 1,976 | 4.3125 | 4 | class Computer(object):
condition = "new"
def __init__(self, model, color, ram, storage):
self.model = model
self.color = color
self.ram = ram
self.storage = storage
def display_computer(self):
return "This is a %s %s with %s gb of RAM and %s gb SSD." %(self.color, se... | true |
c4f1a54798667c53eb6952afc1d0fe923c052803 | bsakers/Introduction_to_Python | /classes.py | 1,977 | 4.34375 | 4 | #general sytax for a class:
class NewClassName(object):
# code
pass
#in the above, we simply state the keyword 'class' and whatever we want to name it
#then we state what the class will inherit from (here we inherit from python's object)
#the 'pass' keyword doesnt do anything, but can act as a placeholder to n... | true |
027342a1e6c8fa72fc03ea820f4770209fa04f77 | bsakers/Introduction_to_Python | /enumerate.py | 463 | 4.6875 | 5 | #enumerate supplies a corresponding index as we loop
options = ["pizza", "sushi", "gyro"]
#normal for loop:
for option in options:
print option
#enumerator (note that "index" could be replaced by anything; it's just a placeholder)
for index, option in enumerate(options):
print index, option
#we can ev... | true |
325ab3f4d26130fd386bbdb3473ae5c7dbe9ca63 | bsakers/Introduction_to_Python | /pig_latin_translator.py | 376 | 4.125 | 4 | print 'Welcome to the Pig Latin Translator!'
original_word = raw_input("Enter a word you would like translated: ").lower()
ending = "ay"
if len(original_word) > 0 and original_word.isalpha():
translated_word = original_word[1:len(original_word)] + original_word[0] + ending
print translated_word
else:
prin... | true |
3aae270f26e6a22bf805081abfee3ed682002282 | ayecoo-103/Python_Code_Drills | /03_Inst_ATM_Application_Logic/Unsolved/atm.py | 656 | 4.15625 | 4 | """This is a basic ATM Application.
This is a command line application that mimics the actions of an ATM.
Example:
$ python app.py
"""
accounts = [
{
"pin": 123456,
"balance" : 1436.19},
{
"pin" : 246802,
"balance": 3571.87},
{
"pin": 135791,
"balance" : 543.79},
{
"pi... | true |
ac51a04b6213e9a8b96e8b1b5d8e4310b56a945a | sarahdepalo/python-classes | /pokemon.py | 2,834 | 4.125 | 4 | #Below is the beginnings of a very basic pokemon game. Still needs a main menu built in. Someday I'd like to add the ability to maybe find new pokemon and battle random ones!
class Pokemon:
def __init__(self, name, health, attack, defense):
self.name = name
self.health = health
self.attack ... | true |
b2478988fed601e0c3b2bbcba70605d0940622b4 | seshu141/20-Projects | /19th Program.py | 715 | 4.125 | 4 | # 19th program Find second biggest number of a list
print(" enter the range of no. and stop")
def Range(list1):
largest = list1[0]
largest2 = None
for item in list1[1:]:
if item > largest:
largest2 = largest
largest = item
elif largest2 == None or largest2 < ... | true |
40f42faa9ff184914e9725e845f69113d73634a2 | stevenckwong/learnpython | /ex06.py | 590 | 4.3125 | 4 | #String formatting
hilarious = False
joke_evaluation = "Isn't that joke so funny?! {}"
print (joke_evaluation.format(hilarious))
a = "Adam"
b = "Bob"
c = "Cathryn"
friends = "There were once 3 friends named {}, {} and {}"
print (friends.format(a,b,c))
# positioning of the variables corresponds to the location of th... | true |
9b67263e7c33c532840bd950c7fc055053e70cd7 | stevenckwong/learnpython | /ex32.py | 676 | 4.53125 | 5 | #Loops and Lists
the_count = [1,2,3,4,5]
fruits = ['apples','oranges','pears','apricots']
change = [1,'pennies',2,'dimes',3,'quarters']
#the first kind of for loop that goes through a list
for number in the_count:
print(f"This is count {number}")
for fruit in fruits:
print(f"A fruit of type: {fruit}")
# not... | true |
66fa6d629d9ddfe80b4255e1ba72f95bff31ad4a | kwikl3arn/python-tutorial | /Python-Palindrome-Number.py | 290 | 4.25 | 4 | # Python Program for Palindrome Number
num = int(input("Enter a number: "))
temp = num
rev = 0
while num>0:
remain = num % 10
rev = (rev * 10) + remain
num = num // 10
if temp == rev:
print("Number is palindrome")
else:
print("Number is not palindrome")
| true |
4a369bff7a8797951f2ab3c7af2fef2b4ae75ba3 | CraGL/Hyperspectral-Inverse-Skinning | /PerVertex/util.py | 2,478 | 4.21875 | 4 | import re
import numpy as np
def veclen(vectors):
""" return L2 norm (vector length) along the last axis, for example to compute the length of an array of vectors """
return np.sqrt(np.sum(vectors**2, axis=-1))
def normalized(vectors):
""" normalize array of vectors along the last axis """
return vec... | true |
3667fe3935484f27411ba2d9522f282b98cd9d26 | adsr652/Python | /fact2.py | 534 | 4.1875 | 4 | def recu_fact(num):
if num==1:
return num
else:
return num * recu_fact(num-1)
num= int(input("Enter any no. : "))
if num < 0:
print("Factorial cannot be found for negative integer")
print("Reenter the value again ")
num= int(input("Enter any no. : "))
if num==0:
... | true |
7bf3ded502ca212e55ebdb24b40b27cdf9c020df | shillwil/cs-module-project-iterative-sorting | /src/searching/searching.py | 908 | 4.125 | 4 | def linear_search(arr, target):
# Your code here
if len(arr) is not 0:
for i in range(len(arr)):
if arr[i] == target:
return i
return -1
return -1
# Write an iterative implementation of Binary Search
def binary_search(arr, target):
# Your code here
if l... | true |
ec747b85a18d2962577e2e24547981b3d70be38b | kemar1997/TSTP_Programs | /Chapter13_TheFourPillarsOfObjectOrientedProgramming/Inheritance.py | 2,766 | 4.90625 | 5 | """
Inheritance in programming is similar to genetic inheritance. In genetic inheritance, you inherit attributes like eye
color from your parents. Similarly, when you create a class, it can inherit methods and variables from another class.
The class that is inherited from is the parent class, and the class that inherit... | true |
ced65aca9c260388d36e6d84939b29e3d60660c2 | kemar1997/TSTP_Programs | /Loops/range.py | 750 | 4.90625 | 5 | """
You can use the built-in range function to create a sequence of integers, and use a for-loop to iterate through them.
The range function takes two parameters: a number where the sequence starts and a number where the sequence stops. The
sequence of integers returned by the range function includes the first paramete... | true |
52c6816d339f1140d7da3fd7c97c9df468084f7f | kemar1997/TSTP_Programs | /String_Manipulation/Concatenation.py | 321 | 4.25 | 4 | """
You can add two (or more) strings together using the addition operator. HTe result is a string made up of the characters
from the first string, followed by the characters from the next string(s). Adding strings together is called
concatenation:
"""
print("cat" + "in" + "hat")
print("cat" + " in" + " the" + " hat"... | true |
56329c35e37e044922969f696523bd39b76281fb | kemar1997/TSTP_Programs | /Challenges/Ch12_Challenges/Triangle.py | 565 | 4.1875 | 4 | # Create a Triangle class with a method called area that calculates and returns
# its area. Then create a Triangle object, call area on it, and print the result.
# a,b,c are the sides of the triangle
class Triangle():
def __init__(self, a, b, c):
self.s1 = a
self.s2 = b
self.s3 = c
def... | true |
17601476e7b674a9900d695a47a4cecc327ae2cf | kemar1997/TSTP_Programs | /Challenges/Ch13_Challenges/Challenge4.py | 415 | 4.34375 | 4 | """
Create a class called Horse and a class called Rider. Use composition to model a horse that has a rider
"""
class Horse:
def __init__(self,
name,
owner):
self.name = name
self.owner = owner
class Rider:
def __init__(self, name):
self.name = name
... | true |
25da8767ef0a8ec27bfc216ca40c4cdf9967adf9 | kemar1997/TSTP_Programs | /Challenges/Ch4_Challenges/ch4_challenge1.py | 236 | 4.25 | 4 | """
1. Writing a function that takes a number as an input and returns that number squared.
"""
def square_a_number():
num = input("Enter a number: ")
num = int(num)
return num*num
result = square_a_number()
print(result) | true |
9b7c6e30ca621c5796db893acbb3eab3a7b7d1f5 | paskwal/python-hackerrank | /Basic_Data_Types/04_finding_the_percentage.py | 1,169 | 4.21875 | 4 | # -*- coding: utf-8 -*-
#
# (c) @paskwal, 2019
# Problem
# You have a record of N students. Each record contains the student's name, and their percent marks in Maths, Physics and Chemistry.
# The marks can be floating values. The user enters some integer N followed by the names and marks for N students.
# You are re... | true |
3c530015d9a9088feb6ce024b49fc3cd51717ba9 | shobha-bhagwat/Python | /games/RockPaperScissors.py | 1,554 | 4.15625 | 4 | import random
rock = 1
paper = 2
scissors = 3
names = {rock: "Rock", paper: "Paper", scissors: "Scissors"}
rules = {rock: scissors, paper: rock, scissors: paper}
player_score = 0
computer_score = 0
def start():
print("Lets play Rock, Paper, Scissors!!")
while game():
pass
scores()
def game()... | true |
3eed1469ae90561bb9a21487579d822b21d09f8b | shobha-bhagwat/Python | /algorithms/binarySearch.py | 440 | 4.125 | 4 | def binarySearch(arr, start, end, x):
while start <= end:
mid = (start + end)//2
if arr[mid] == x:
return mid
elif arr[mid] < x:
start = mid + 1
else:
end = mid -1
return -1
arr = [-5, 3.0, 10, 20, 50, 80]
x = 3
result = binarySearch(arr... | true |
1a257fddb2c63d53423544a9737d3dca62e85968 | xperrylinn/whiteboard | /algo/easy/branch_sums.py | 1,328 | 4.1875 | 4 | # Write a function that takes in a Binary tree and retuns a list of
# its branch sums ordered from leftmost branch to rightmost branch
#
# A branch is the sum of all values in a Binary Tree branch. A
# binary tree branch is a path of nodes in a tree that starts at the
# root and ends at any leaf
# This is the class ... | true |
9ae2ccf4e88e93d0c47565cd6b0b9d18825faa2f | supercp3/code_leetcode | /basedatestructure/stack_run_class.py | 822 | 4.15625 | 4 | class Node:
def __init__(self,value):
self.value=value
self.next=None
class Stack:
def __init__(self):
self.top=None
def push(self,value):
node=Node(value)
node.next=self.top
self.top=node
def pop(self):
node=self.top
if node is None:
raise Exception("this is an empty stack")
self.top=node.n... | true |
877ee9220c82d773f6b8e7e83b281e1be3b455dc | vedashri15/new1 | /Basic1.6.py | 717 | 4.84375 | 5 | #Write a Python program to accept a filename from the user and print the extension of that.
filename = input("Input the Filename: ")
f_extns = filename.split(".")
print ("The extension of the file is : " + f_extns[-1])
#The function returns a list of the words of a given string using a separator as the delimiter ... | true |
85c53dbee3db530435a9f69c43fac32606b6b476 | tonylattke/python_helpers | /5_functions_methods.py | 1,154 | 4.34375 | 4 | ######################## Example 1 - Create a function and using ########################
# Even or not
# @number : Number to decide
# @return : True if the number is even, otherwise Flase
def even(number):
return number % 2 == 0
# Testing Function
for aux in xrange(0,10):
if even(aux):
print "%d - Even" % aux
e... | true |
8f6f34a49a9920138306f43dca03aaf9d4952df3 | MilanaShhanukova/programming-2021-19fpl | /shapes/circle.py | 803 | 4.125 | 4 | """
Programming for linguists
Implementation of the class Circle
"""
from math import pi
from shapes.shape import Shape
class Circle(Shape):
"""
A class for circles
"""
def __init__(self, uid: int, radius: int):
super().__init__(uid)
self.radius = radius
def get_area(self):
... | true |
1c14f80470bc5c858587261c932b8fe958f1b1c3 | yvonneonu/Test8 | /test8.py | 774 | 4.34375 | 4 | # A Simple Python 3 program to compute
# sum of digits in numbers from 1 to n
#Returns sum of all digits in numbers from 1 to n
def countNumberWith3(n) :
result = 0 # initialize result
# One by one compute sum of digits
# in every number from 1 to n
for x in range(1, n + 1):
if(has3(x) == True... | true |
0efc63ac7d07f35ae5d978169adb8849f175bad4 | eawww/BI_HW | /HW1/seqid.py | 2,201 | 4.125 | 4 | #Bridget Mohn and Eric Wilson
#CS 466R
#Homework 1
#Reads an input filename from command line, opens the file, reads each character
#in the file to see whether the file contains a DNA, RNA, or Protein sequence
import sys
#Input filename is taken from the command line which is the second argument
InputFile... | true |
3267bcaa907a1eda60abe8c60ff69b7cc7cff0a9 | Ryan-Lawton-Prog/IST | /IST Assessment Program/I1.py | 2,768 | 4.28125 | 4 | def a():
while = True:
print """
\tGuide Contents:
\t* raw_input() = Gives the user the option to input data to the user,
anything inbetween the '()' will be displayed before
the users input.
"""
raw_input()
break
test = True
while te... | true |
9bc1edb29c6feb34e3384611c3353014579821d0 | Ryan-Lawton-Prog/IST | /IST Assessment Program/Run.py | 1,632 | 4.15625 | 4 | import Beginner
# Program Varriable is now True
Program = True
# 'while' Program is true run and loop this
while Program:
# select your difficulty text
print "Please select your Stream"
print "Beginner:"
print "Intermediate:"
print "Advanced:"
# difficulty input
Difficulty = raw_inpu... | true |
40917733d3f5c754297756d8e440bdb2c96d5607 | calvinwalterheintzelman/Computer-Security-Algorithms | /Finding Primes/Fields.py | 1,307 | 4.125 | 4 | # Calvin Walter Heintzelman
# ECE 404
# Homework 3
# Python 3.7.2
import os
import sys
print("Please enter a small digit: ")
number = input()
while(number.isdigit() is False or int(number) < 1):
print("Error! Please only input a single small positive integer!")
number = input()
if(int(number)... | true |
42efd486938984bf55bb1699472c9abca16e3106 | Pratik180198/Every-Python-Code-Ever | /factorial.py | 480 | 4.375 | 4 | num1=input("Enter number: ")
try:
num=int(num1)
fact=1
for i in range(1,num+1): #Using For Loop
fact=fact*i
print("Factorial of {} is {}".format(num,fact)) #For Loop Answer
def factorial(num): #Using Recursive Method
if num == 0 or num ==1:
return 1
else:
... | true |
1af7bd227c2e2a919baeda39d55c27d631b93908 | maimumatsumoto/prac04 | /list_exercises.py | 2,474 | 4.28125 | 4 | #//1. Basic list operations//#
numbers=[]
for i in range(5):
value= int(input("Number: "))
numbers.append(value)
print("The first number is {}".format(numbers[0]))
print("The last number is {}".format(numbers[-1]))
print("The smallest number is {}".format(min(numbers)))
print("The largest number is {}".format... | true |
d7a241d07e554b6b0b56913e51aa3a853ee5c6b9 | gagnongr/Gregory-Gagnon | /Exercises/sum up odd ints.py | 718 | 4.40625 | 4 | # Sum up a series of even numbers
# Make sure user input is only even numbers
# Variable names without types are integers
print("Allow the user to enter a series of even integers. Sum them.")
print("Ignore non-even input. End input with a '.'")
# Initialize input number and the sum
number_str = input("Number: ")
the_... | true |
f55ae7e36f0430c48633e5b032f0adf57c57c9b0 | cserajeevdas/Python-Coding | /decorator.py | 701 | 4.5625 | 5 | #assigned a method to a variable and called the method
# def f1():
# print("in f1")
# x = f1
# x()
#calling f2 from the rturn value of f1
# def f1():
# def f2():
# print("in f2")
# return f2
# x = f1()
# x()
#calling the nested method through passed method
# def f1(f):
# def f... | true |
5c36b47de38425bf90e47c7348b525a35c173305 | annewoosam/shopping-list | /shoppinglist.py | 628 | 4.21875 | 4 | print("create a quick, no duplicate, alphabetical shopping list by entering items then hitting enter when done.")
shopping_list=[]
while True:
add_item=input("add item>")
if add_item.lower()!="":
shopping_list.append(add_item.lower())
shopping_list=set(shopping_list)
print( "\no... | true |
987650133ed8611b645aef9a6c2ef0fef97dc2be | tasnia18/Python-assignment-certified-course-in-Coursera- | /Python Data Structure/7_2.py | 954 | 4.125 | 4 | """ 7.2 Write a program that prompts for a file name, then opens that file and reads through the file,
looking for lines of the form:
X-DSPAM-Confidence: 0.8475
Count these lines and extract the floating point values from each of the lines and compute the average of those values
and produce an output as shown ... | true |
33791e76660c95af96ae04c7b45fd8b1bcfb5646 | snowd25/pyPract | /stringPermutation.py | 611 | 4.25 | 4 | #Python Program to Print All Permutations of a String in Lexicographic Order using Recursion
#without using permutations builtin
def permuteStr(lst,l,r):
if l == r:
print("".join(lst))
else:
for i in range(l,r+1):
lst[l],lst[i] =lst[i],lst[l]
permuteStr(lst,l+1,r)
lst[l],lst[i] =lst[i],lst[l]
# permuta... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.