blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
3259d55b1aa7a9a2112a9eafe5ef2234966e0adc | udhayprakash/PythonMaterial | /python3/13_OOP/b_MRO_inheritance/01_single_inheritance.py | 1,521 | 4.28125 | 4 | """
Purpose: Single Inheritance
Parent - child classes relation
Super - sub classes relation
NOTE: All child classes should make calls to the parent class
constructors
MRO - method resolution order
"""
class Account:
"""
Parent or super class
"""
def __init__(self):
self.balanc... | true |
b92994e333cf4ef258773b508a5107d81a1d321c | udhayprakash/PythonMaterial | /python3/13_OOP/a_OOP/11_static_n_class_methods.py | 1,243 | 4.28125 | 4 | #!/usr/bin/python
"""
Methods
1. Instance Methods
2. class Methods
3. static Methods
Default Decorators: @staticmethod, @classmethod, @property
"""
class MyClass:
my_var = "something" # class variable
def display(self, x):
print("executing instance method display(%s,%s)" % (self, x))
... | true |
23978697bff6a4c96fa402731c3a700a5ab6a6ab | udhayprakash/PythonMaterial | /python3/06_Collections/02_Tuples/04_immutability.py | 471 | 4.3125 | 4 | #!/usr/bin/python3
"""
Purpose: Tuples are immutable
- They doesnt support in-object changes
"""
mytuple = (1, 2, 3)
print("mytuple", mytuple, id(mytuple))
# Indexing
print(f"{mytuple[2] =}")
# updating an element in tuple
try:
mytuple[2] = "2.2222"
except TypeError as ex:
print(ex)
print("t... | true |
c81f107aece79ddbbddbe4b9185f3dd2ab40f8a7 | udhayprakash/PythonMaterial | /python3/14_Code_Quality/00_static_code_analyses/e_ast_module.py | 1,820 | 4.15625 | 4 | #!/usr/bin/python
"""
Purpose: AST(Abstract Syntax Tree) Module
Usage
- Making IDEs intelligent and making a feature everyone knows as intellisense.
- Tools like Pylint uses ASTs to perform static code analysis
- Custom Python interpreters
- Modes of Code Compilation
- exec: We ... | true |
089032f1e919883ee09451761df8261fe17c238a | udhayprakash/PythonMaterial | /python3/02_Basics/02_String_Operations/t_string_module.py | 1,412 | 4.25 | 4 | #!/usr/bin/python3
"""
Purpose: String Module
"""
import string
# print(dir(string))
print(string.__doc__, end="\n\n")
print(f"{string.ascii_letters =}")
print(f"{string.ascii_lowercase =}")
print(f"{string.ascii_uppercase =}")
print(f"{string.digits =}")
print(f"{string.hexdigits =}")
print(f"{strin... | false |
52d5d2268407c434c4ca567c1cf52bc3d8c72783 | udhayprakash/PythonMaterial | /python3/03_Language_Components/09_Loops/i_loops.py | 916 | 4.28125 | 4 | #!/usr/bin/python3
"""
Purpose: Loops
break - breaks the complete loop
continue - skip the current loop
pass - will do nothing. it is like a todo
sys.exit - will exit the script execution
"""
import sys
i = 0
while i <= 7:
i += 1
print(i, end=" ")
print("\n importance of break")
i ... | true |
151a7dcf87ee5c6458eac386a5831f90dcc746a3 | udhayprakash/PythonMaterial | /python3/15_Regular_Expressions/a_re_match.py | 734 | 4.5 | 4 | """
Purpose: Regular Expressions
Using re.match
- It helps to identify patterns at the starting of string
- By default, it is case-sensitive
"""
import re
# print(dir(re))
target_string = "Python Programming is good for health"
search_string = "python"
print(f"{target_string.find(search_string) =... | true |
31fcb6bff7762bc0fb0ea7aa7911c04d21ca77ad | udhayprakash/PythonMaterial | /python3/10_Modules/03_argparse/a_arg_parse.py | 1,775 | 4.34375 | 4 | #!/usr/bin/python3
"""
Purpose: importance and usage of argparse
"""
# # Method 1: hard- coding
# user_name = 'udhay'
# password = 'udhay@123'
# server_name = 'issadsad.mydomain.in'
# # Method 2: input() - run time
# user_name = input('Enter username:')
# password = input('Enter password:')
# server_name = input('Ent... | false |
6473f82475a39c63e9c3cdd46726b15656253137 | udhayprakash/PythonMaterial | /python3/07_Functions/030_closures_ex.py | 492 | 4.59375 | 5 | #!/usr/bin/python3
"""
Purpose: closure example demo
"""
def outer(num1):
num3 = 30
def hello_world():
print("Hello world")
def wrapper(num2): # closure function
result = num1 + num2 + num3
return result
print(f"{hello_world.__closure__ =}")
print(f"{wrapper.__closure__... | false |
696622f014f6ab152e691c301c2ae66a054aa1c9 | udhayprakash/PythonMaterial | /python3/07_Functions/032_currying_functions.py | 1,944 | 5.03125 | 5 | #!/usr/bin/python3
"""
Purpose: Currying Functions
- Inner functions are functions defined inside another function that can be used for various purposes, while
currying is a technique that transforms a function that takes multiple arguments into a sequence of functions that each take a single argument.
-... | true |
713d449e4646683292f37d3e16792f2eaa58052d | udhayprakash/PythonMaterial | /python3/11_File_Operations/01_unstructured_file/i_reading_large_file.py | 757 | 4.1875 | 4 | #!/usr/bin/python3
"""
Purpose: To read large file
"""
from functools import partial
def read_from_file(file_name):
"""Method 1 - reading one line per iteration"""
with open(file_name, "r") as fp:
yield fp.readline()
def read_from_file2(file_name, block_size=1024 * 8):
"""Method 2 - reading bloc... | true |
208da5282d2ac39f6a51343025bd78f422d2441b | alecbw/Learning-Projects | /Bank Account.py | 1,147 | 4.34375 | 4 | """ This code does the following things
Top level: creates and manipulates a personal bank account
* accepts deposits
* allows withdrawals
* displays the balance
* displays the details of the account """
class BankAccount(object):
balance = 0
def __init__(self, name):
self.name = name
def __repr__(self... | true |
13408db5de2e32cd359d691ac80ad724b2495253 | TaiPham25/PhamPhuTai---Fundamentals---C4E16 | /Session04/clera.py | 742 | 4.15625 | 4 |
print ('Guess your number game')
print ('Now think of a number from 0 to 100, then press " Enter"')
input()
print("""
All you have to do is to asnwer to my guess
'c' if my guess is 'C'orrect
'l' if my guess is 'L'arge than your number
's' if my guess is 'S'mall than your number
""")
#string formatting
from random imp... | true |
ef28f1eb265cb90c47a2c1fec8c714d3542f7d8c | Toruitas/Python | /Practice/Daily Programmer/DP13 - Find number of day in year.py | 2,659 | 4.40625 | 4 | __author__ = 'Stuart'
"""
http://www.reddit.com/r/dailyprogrammer/comments/pzo4w/2212012_challenge_13_easy/
Find the number of the year for the given date. For example, january 1st would be 1, and december 31st is 365.
for extra credit, allow it to calculate leap years, as well.
https://docs.python.org/3.4/library/date... | true |
185f03b68bac3ca937ecee2d5b4b033314fb3d06 | Toruitas/Python | /Practice/Daily Programmer/Random Password Generator.py | 811 | 4.15625 | 4 | __author__ = 'Stuart'
"""
Random password generator
default 8 characters, but user can define what length of password they want
"""
def password_assembler(length=8):
"""
Takes user-defined length (default 8) and generates a random password
:param length: default 8, otherwise user-defined
:return: pass... | true |
47567240773ccbedbccd4a4f098e3911419cd163 | Toruitas/Python | /Practice/Daily Exercises/day 11 practice.py | 1,409 | 4.25 | 4 | _author_ = 'stu'
#exercise 11
#time to complete: 15 minutes
"""Ask the user for a number and determine whether the number is prime or not.
(For those who have forgotten, a prime number is a number that has no divisors.)
You can (and should!) use your answer to Exercise 4 to help you.
Take this opportunity to practi... | true |
e825be3736c83d1579e2e155ac0a1c2d3bc8255c | fabiancaraballo/CS122-IntroToProg-ProbSolv | /project1/P1_hello.py | 213 | 4.25 | 4 | print("Hello World!")
print("")
name = "Fabian"
print("name")
print(name)
#print allows us to print in the console whenever we run the code.
print("")
ambition = "I want to be successful in life."
print(ambition)
| true |
634ad3c17d105f95cd627425354fd78826177710 | meridian-school-computer-science/pizza | /src/classes_pizza.py | 930 | 4.53125 | 5 | # classes for pizza with decorator design
class Pizza:
"""
Base class for the building of a pizza.
Use decorators to complete the design of each pizza object.
"""
def __init__(self, name, cost):
self.name = name
self.cost = float(cost)
def __repr__(self):
return... | true |
684ada57ad12df9053cad5f14c71452e1625c0f2 | bear148/Bear-Shell | /utils/calculatorBase.py | 637 | 4.28125 | 4 | def sub(num1, num2):
return int(num1)-int(num2)
def add(num3, num4):
return int(num3)+int(num4)
def multiply(num5, num6):
return int(num5)*int(num6)
def divide(num7, num8):
return int(num7)/int(num8)
# Adding Strings vs Adding Ints
# When adding two strings together, they don't combine into a different number, ... | true |
bf3a5caa3e68bdf5562bf7270ba11befeb5ab21c | jijo125-github/Solving-Competitive-Programs | /LeetCode/0001-0100/43-Multiply_strings.py | 832 | 4.28125 | 4 | """ Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.
Note: You must not use any built-in BigInteger library or convert the inputs to integer directly.
Example 1:
Input: num1 = "2", num2 = "3"
Output: "6"
Example 2:... | true |
f3901e5c758a2fc0d785d9c20769d5f0169a797f | daniloaugusto0212/EstudoPython | /Python-Udemy/Básico/aula15Listas.py | 788 | 4.125 | 4 |
idade = [] #inicializando lista vazia
idade.append(18) #adiciona o valor 18 à lista
idade.append(50)
idade.append(35)
idade.append(48)
idade.append(40) #adiciona o valor 18 ao final da lista
idade.insert(1, 30) #adiciona o valor 30 na posição 1 da lista
idade.pop() #remove o valor da última posição da lista
idade.po... | false |
95e04761f619193d2190a9d62d5ec9c0ffe0beea | SharmaManish/crimsononline-assignments | /assignment1/question2.py | 863 | 4.15625 | 4 | def parse_links_regex(filename):
"""question 2a
Using the re module, write a function that takes a path to an HTML file
(assuming the HTML is well-formed) as input and returns a dictionary
whose keys are the text of the links in the file and whose values are
the URLs to which those links correspond... | true |
130b0896fc57c51d0601eea2483449f51de4142d | xfLee/Python-DeepLearning_CS5590 | /Lab_2/Source/Task_1.py | 640 | 4.1875 | 4 | """
Python program that accepts a sentence as input and remove duplicate words.
Sort them alphanumerically and print it.
"""
# Taking the sentence as input
Input_Sentence = input('Enter any sentence: ')
# Splitting the words
words = Input_Sentence.split()
# converting all the strings to lowercase
words = [elemen... | true |
eec458d8c6806cacabeef7b0188edd7db65306bc | xfLee/Python-DeepLearning_CS5590 | /Lab_2/Source/Task_2.py | 433 | 4.28125 | 4 | """
Python program to generate a dictionary that contains (k, k*k).
And printing the dictionary that is generated including both 1 and k.
"""
# Taking the input
num = int(input("Input a number "))
# Initialising the dictionary
dictionary = dict()
# Computing the k*k using a for loop
for k in range(1,num+1):
... | true |
591d265f4773fab8be1362b349278cd8ed41574a | mercy17ch/dictionaries | /dictionaries.py | 2,262 | 4.375 | 4 | '''program to show dictionaries'''
#A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets, and they have keys and values
#
#creating dictionary#
thisdict={"name":"mercy",
"sex":"female",
"age":23}
print(thisdict)
#... | true |
d4e2cb6d1dac6e74e0097146360ac77b5e7132ea | sajjad065/assignment2 | /Function/function5.py | 270 | 4.1875 | 4 | def fac(num):
fact=1;
if(num<0):
print(int("Please enter non-negative number"))
else:
for i in range(1,(num+1)):
fact=fact*i
print("The factorial is: ")
print(fact)
number=int(input("Enter number "))
fac(number)
| true |
b1282fc3cf4bfe3895451cbbbd18fa6517f92dce | sajjad065/assignment2 | /Function/function17.py | 295 | 4.28125 | 4 | str1=input("Enter any string:")
char=input("enter character to check:")
check_char=lambda x: True if x.startswith(char) else False
if(check_char(str1)):
print(str1 +" :starts with character :" +char)
else:
print(str1 +": does not starts with character: " +char)
| true |
d6c476378fac0c7a2ce31678cb34da2f1977ee57 | sajjad065/assignment2 | /Datatype/qsn28.py | 637 | 4.21875 | 4 | total=int(input("How many elements do you want to input in dictionary "))
dic={}
for i in range(total):
key1=input("Enter key:")
val1=input("Enter value:")
dic.update({key1:val1})
print("The dictionary list is :")
print(dic)
num=int(input("please input 1 if you want to add key to the given dictionary "))
if... | true |
ddf383029c7040717604fa0ee2d79cef71cd0140 | 15271856796/python_study | /day05 拷贝/02 copy库.py | 739 | 4.1875 | 4 | import copy
a=[1,2,3,4]
b=copy.copy(a)
b.append(7)
print(a,b) #[1, 2, 3, 4] [1, 2, 3, 4, 7]
a={'1':2,'2':3}
b=copy.copy(a)
b['3']=4
print(a,b) #{'1': 2, '2': 3} {'1': 2, '2': 3, '3': 4}
#copy.copy()只能实现最外层的copy值
a=[1,2,3,[7,8]]
b=copy.copy(a)
print("a=%s,b=%s"%(a,b)) #a=[... | false |
218bc4a2009026a338abad42c9ac11c4818bf0d7 | pasqualespica/my-realpyhton-tutorial | /InheritanceCompositionOOPGuide/Decorators/simple_decorator.py | 1,512 | 4.34375 | 4 | import functools
# def my_decorator(func):
# def wrapper():
# print("Something is happening before the function is called.")
# func()
# print("Something is happening after the function is called.")
# return wrapper
# def say_whee():
# print("Whee!")
# say_whee = my_decorator(say... | false |
8e22e05cf4401dd89fa578671472c856cd9e824c | danielvillanoh/datatypes_operations | /primary.py | 2,323 | 4.5625 | 5 | #author: Daniel Villano-Herrera
# date: 7/1/2021
# --------------- Section 1 --------------- #
# ---------- Integers and Floats ---------- #
# you may use floats or integers for these operations, it is at your discretion
# addition
# instructions
# 1 - create a print statement that prints the sum of two numb... | true |
12d70ddace6d64ace1873bd5e1521efe579daf6f | pedronobrega/ine5609-estrutura-de-dados | /doubly-linked-list/__main__.py | 967 | 4.21875 | 4 | from List import List
from Item import Item
if __name__ == "__main__":
lista: List = List(3)
# This will throw an exception
# lista.go_ahead_positions(3)
# This will print None
print(lista.access_actual())
# This will print True
print(lista.is_empty())
# This will print False
print(lista.is_full(... | true |
54a38474bcfc39ee234c64a8b7808d3df7e31c7d | payal-98/Student_Chatbot-using-RASA | /db.py | 1,205 | 4.15625 | 4 | # importing module
import sqlite3
# connecting to the database
connection = sqlite3.connect("students.db")
# cursor
crsr = connection.cursor()
# SQL command to create a table in the database
sql_command = """CREATE TABLE students (
Roll_No INTEGER PRIMARY KEY,
Sname VARCHAR(20),
Class VARCHAR(30... | true |
f3543b7840f1d43d53abfe9c303836825ddacc63 | javaInSchool/python1_examples | /les2/example1.py | 363 | 4.34375 | 4 | print("Почему сегодня идет снег?")
fred = "Привет, меня зовут фред!"
text = "Как дела?"
string = 'Что-то пошло не так'
print(string)
name = "д'Артаньян"
#name = 'д'Артаньян'
print(name)
name2 = 'д\'Артаньян'
name3 = '''д'Арта"нья"н
и три
мушкетера''' | false |
bf0e360370d704920509e4a61e7c0b79f983c2de | Maxim1912/python | /list.py | 352 | 4.15625 | 4 | a = 33
b = [12, "ok", "567"]
# print(b[:2])
shop = ["cheese", "chips", "juice", "water", "onion", "apple", "banana", "lemon", "lime", "carrot", "bacon", "paprika"]
new_element = input("Что ещё купить?\n")
if new_element not in shop:
shop.append(new_element)
print('We need to buy:')
for element in shop:
pri... | true |
86de52a241ae3645d41c693383b7b232c95126c5 | gcnTo/Stats-YouTube | /outliers.py | 1,256 | 4.21875 | 4 | import numpy as np
import pandas as pd
# Find the outlier number
times = int(input("How many numbers do you have in your list: "))
num_list = []
# Asks for the number, adds to the list
for i in range(times):
append = float(input("Please enter the " + str(i+1) + ". number in your list: "))
num_list.append(ap... | true |
03362a677a4b090f092584c63197e01151937781 | ihanda25/SCpythonsecond | /helloworld.py | 1,614 | 4.15625 | 4 | import time
X = raw_input("Enter what kind of time mesurement you are using")
if X == "seconds" :
sec = int(raw_input("Enter num of seconds"))
status = "calculating..."
print(status)
hour = sec // 3600
sec_remaining = sec%3600
minutes = sec_remaining // 60
final_sec_remaining = sec_remaini... | true |
4785fd11ab80f0e29f7f8ef7ec60a8dab5c893de | japneet121/Python-Design-Patterns | /facade.py | 1,006 | 4.21875 | 4 | '''
Facade pattern helps in hiding the complexity of creating multiple objects from user and encapsulating many objects under one object.
This helps in providing unified interface for end user
'''
class OkButton:
def __init__(self):
pass
def click(self):
print("ok clicked")
class Can... | true |
2f9f0e381ba3e08a5a2487967a942d82292ab48c | Kenny-W-C/Tkinter-Examples | /drawing/draw_image.py | 866 | 4.1875 | 4 | #!/usr/bin/env python3
"""
ZetCode Tkinter tutorial
In this script, we draw an image
on the canvas.
Author: Jan Bodnar
Last modified: April 2019
Website: www.zetcode.com
"""
from tkinter import Tk, Canvas, Frame, BOTH, NW
from PIL import Image, ImageTk
class Example(Frame):
def __init__(self):
super()... | true |
5a9c60245722eb710122e1af18778d212db4a84a | johnnymcodes/computing-talent-initiative-interview-problem-solving | /m07_stacks/min_parenthesis_to_make_valid.py | 1,008 | 4.25 | 4 | #
# Given a string S of '(' and ')' parentheses, we add the minimum number of
# parentheses ( '(' or ')', and in any positions ) so that the resulting
# parentheses string is valid.
#
# Formally, a parentheses string is valid if and only if:
# It is the empty string, or
# It can be written as AB (A concatenated with B)... | true |
e978f07ced6f205af8593c88b55503e436f75a88 | catwang42/Algorithm-for-data-scientist | /basic_algo_sort_search.py | 2,886 | 4.4375 | 4 |
#Algorithms
"""
Search: Binary Search , DFS, BFS
Sort:
"""
#bubble sort -> compare a pair and iterate though 𝑂(𝑛2)
#insertion sort
"""
Time Complexity: 𝑂(𝑛2),
Space Complexity: 𝑂(1)
"""
from typing import List, Dict, Tuple, Set
def insertionSort(alist:List[int])->List[int]:
#check from index 1
for i... | true |
fd84dcb1ea5513f1a8447155147761d345f2e0dd | Taranoberoi/PYTHON | /practicepython_ORG_1.py | 580 | 4.28125 | 4 | # 1 Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old.
import datetime as dt
Name = input("Please Enter the Name :")
# Taking input and converting into Int at the same time
Age = int(input("Plea... | true |
de4dd804df9777ac13b9e1f4ba3b0b96c701da3a | Taranoberoi/PYTHON | /Practise1.py | 874 | 4.15625 | 4 | #1 Practise 1 in favourites
#1Write a Python program to print the following string in a specific format (see the output). Go to the editor
#Sample String : "Twinkle, twinkle, little star, How I wonder what you are! Up above the world so high, Like a diamond in the sky. Twinkle, twinkle, little star, How I wonder what... | true |
39a34d0c8e530b0a5a55cb177677886e57a0e6f4 | pghanem/Data-Structures-Algorithms | /3_1_threeInOne.py | 1,372 | 4.3125 | 4 | class Stack:
def __init__(self):
self.items = []
def isEmpty(self):
return self.items == []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
def peek(self):
return self.items[len(self.items)-1]
def size(s... | false |
b5c65b127bd73e309ab64b3a81a059adcd995da6 | saurabh-deochake/DS | /sorting/bubblesort.py | 541 | 4.25 | 4 | #!/bin/python
"""
Copyright 2016 Saurabh Deochake
1. Bubble Sort
O(n^2)
"""
def sort_bubblesort(my_list):
for pos_upper in xrange(len(my_list)-1,0,-1):
for i in xrange(pos_upper):
if my_list[i] > my_list[i+1]:
my_list[i], my_list[i+1] = my_list[i+1], my_list[i]
... | false |
81e5bd642345c074b4ac9c55ee4e630a7d6ebd73 | BSchweikart/CTI110 | /M3HW1_Age_Classifier_Schweikb0866.py | 726 | 4.25 | 4 | # CTI - 110
# M3HW1 : Age Classifier
# Schweikart, Brian
# 09/14/2017
def main():
print('Please enter whole number, round up or down')
# This is to have user input age and then classify infant, child,...
# Age listing
Age_a = 1
Age_b = 13
Age_c = 20
# 1 year or less = infant
# 1 y... | true |
4bd2765c5c80cdb85fa9a2f6c1d9603ac6f26bd6 | Varunaditya/practice_pad | /Python/stringReversal.py | 1,454 | 4.125 | 4 | """
Given a string and a set of delimiters, reverse the words in the string while
maintaining the relative order of the delimiters.
For example, given "hello/world:here", return "here/world:hello"
"""
from sys import argv, exit
alphabets = ['a', 'b', 'c', 'd', 'e',
'f' , 'g', 'h', 'i', 'j',
'k', 'l', 'm', ... | true |
91c5976e429e09729f3857b8e5a633073837b368 | Varunaditya/practice_pad | /Python/merge_accounts.py | 1,915 | 4.28125 | 4 | """
Given a list accounts, each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name,
and the rest of the elements are emails representing emails of the account.
Now, we would like to merge these accounts. Two accounts definitely belong to the same person if there is some email
tha... | true |
dc363f27cc6e52277b539fbaabd2aedae1691933 | gpastor3/Google-ITAutomation-Python | /Course_2/Week_2/iterating_through_files.py | 971 | 4.5 | 4 | """
This script is used for course notes.
Author: Erick Marin
Date: 11/28/2020
"""
with open("Course_2/Week_2/spider.txt") as file:
for line in file:
print(line.upper())
# when Python reads the file line by line, the line variable will always have
# a new line character at the end. In other words, the ne... | true |
77efe1b0c6dce387b29f9719ec8be6c217373b86 | gpastor3/Google-ITAutomation-Python | /Course_1/Week_4/iterating_over_the_contents_of_a_dictionary.py | 1,835 | 4.6875 | 5 | """
This script is used for course notes.
Author: Erick Marin
Date: 10/20/2020
"""
# You can use for loops to iterate through the contents of a dictionary.
file_counts = {"jpg": 10, "txt": 14, "csc": 2, "py": 23}
for extension in file_counts:
print(extension)
# If you want to access the associated values, you ca... | true |
2d593998eaf8c47e2b476f7d5c50143ef75f409a | gpastor3/Google-ITAutomation-Python | /Course_2/Week_5/charfreq.py | 873 | 4.1875 | 4 | #!/usr/bing/env python3
"""
This script is used for course notes.
Author: Erick Marin
Date: 12/26/2020
"""
# To use a try-except block, we need to be aware of the errors that functions
# that we're calling might raise. This information is usually part of the
# documentation of the functions. Once we know this we ca... | true |
7c1386e726f4867617ac9682657532da2425df07 | gpastor3/Google-ITAutomation-Python | /Course_1/Week_2/returning_values.py | 1,324 | 4.25 | 4 | """
This script is used for course notes.
Author: Erick Marin
Date: 10/08/2020
"""
def area_triangle(base, height):
""" Calculate the area of triange by multipling `base` by `height` """
return base * height / 2
def get_seconds(hours, minutes, seconds):
""" Calculate the `hours` and `minutes` into sec... | true |
aa96e9acb44032b35e1b53784b117d989af43758 | gpastor3/Google-ITAutomation-Python | /Course_1/Week_4/iterating_over_lists_and_tuples.py | 2,405 | 4.59375 | 5 | """
This script is used for course notes.
Author: Erick Marin
Date: 10/20/2020
"""
animals = ["Lion", "Zebra", "Dolphin", "Monkey"]
chars = 0
for animal in animals:
chars += len(animal)
print("Total characters: {}, Average length: {}".format(chars, chars/len(animals)))
# The 'enumerate' function returns a tuple... | true |
b0570c87b7a5d7389973b315aca7d79de585a452 | gpastor3/Google-ITAutomation-Python | /Course_1/Week_2/defining_functions.py | 919 | 4.125 | 4 | """
This script is used for course notes.
Author: Erick Marin
Date: 10/08/2020
"""
def greeting(name, department):
""" Print out a greeting with provided `name` and department
parameters. """
print("Welcome, " + name)
print("Your are part of " + department)
# Flesh out the body of the print_second... | true |
123187441133b573b5058569e0a972964d11221b | gpastor3/Google-ITAutomation-Python | /Course_1/Week_4/the_parts_of_a_string.py | 1,668 | 4.34375 | 4 | """
This script is used for course notes.
Author: Erick Marin
Date: 10/11/2020
"""
# String indexing
name = "Jaylen"
print(name[1])
# Python starts counting indices from 0 and not 1
print(name[0])
# The last index of a string will always be the one less than the length of
# the string.
print(name[5])
# If we tr... | true |
2eb52a42c37125937cbffd68468398956aa7d575 | foofaev/python-project-lvl1 | /brain_games/games/brain_progression.py | 1,454 | 4.25 | 4 | """
Mini-game "arithmetic progression".
Player should find missing element of provided progression.
"""
from random import randint
OBJECTIVE = 'What number is missing in the progression?'
PROGESSION_SIZE = 10
MIN_STEP = 1
MAX_STEP = 10
def generate_question(first_element: int, step: int, index_of_missing: int):
... | true |
5f1d89b45c61f68d2b23aa01bfb4c83d6e88fd1b | Sungmin-Joo/Python | /Matrix_multiplication_algorithm/Matrix_multiplication_algorithm.py | 1,284 | 4.1875 | 4 | # -*- coding: utf-8 -*-
import numpy as np
if __name__ == '__main__':
print("Func_called - main")
A = np.array([[5,7,-3,4],[2,-5,3,6]])
B = np.array([[3,0,8],[-5,1,-1],[7,4,4],[2,4,3]])
len_row_A = A.shape[0]
len_col_A = A.shape[1]
len_col_B = B.shape[1]
result = np.zeros((len_row_A,len_col_... | true |
73d9af8a966990d3c06060b56516c7e22e637fda | andyly25/Python-Practice | /data visualization/e01_simplePlot.py | 761 | 4.34375 | 4 | '''
1. import pyplot module and using alias plt to make life easier.
2. create a lit to hold some numerical data.
3. pass into plot() function to try plot nums in meaningful way.
4. after launching, shows you simple graph that you can navigate through.
'''
# 1
import matplotlib.pyplot as plt
# input values will help ... | true |
69681798f10be785c5e6d247222832f32e7fcf91 | andyly25/Python-Practice | /AlgorithmsAndChallenges/a001_isEven.py | 1,008 | 4.34375 | 4 | '''
I've noticed the question of determining if a number is an even number
often, and it seems easy as you can just use modulo 2 and see if 0 or some
other methods with multiplication or division.
But here's the catch, I've seen a problem that states:
You cannot use multiplication, modulo, or divi... | true |
1a3689681b252e87b0c323aa73b32166bb3e8469 | oktaran/LPTHW | /exercises.py | 1,367 | 4.21875 | 4 |
"""
Some func problems
~~~~~~~~~~~~~~~~~~
Provide your solutions and run this module.
"""
import math
def add(a, b):
"""Returns sum of two numbers."""
return a + b
def cube(n):
"""Returns cube (n^3) of the given number."""
# return n * n * n
# return n**3
return math.pow(n, 3)
def is_od... | true |
89cd8a2e36b129a705836170fb6a0a48e4b6bbbb | ParthikB/Data-Structures | /Data Structures/quickSort.py | 1,428 | 4.125 | 4 | class Sort:
def __init__(self, list_):
self.list = list_
def quickSort(self):
pivot = -1
arr = self.list
def quickSortRecurse(arr):
l, r = 0, len(arr) - 2
# print("recursing :::::::::::::::::::::", arr)
... | false |
a7c29d07ecaff79c7890dc20d201dabd2c2c0213 | MksYi/Python3-NPCTU-TQC-Example | /Problem2/PYD02.py | 525 | 4.1875 | 4 | #-*- codeing: utf-8 -*-
import sys
"""
input
55
36
92
15
output
55 is a multiple of 5.
36 is a multiple of 3.
92 is not a multiple of 3 or 5.
15 is a multiple of 3 and 5.
"""
number = int(input())
anwser = 0
if not number % 3:
anwser += 3
if not number % 5:
anwser += 5
if anwser == 3:
print('%d is a multiple... | false |
bcb369678e7debc40c1ce49ab3e9d409f5e13d19 | vaibhavyesalwad/Basic-Python-and-Data-Structure | /Python Data Structure/Tuple/03_Unpacking.py | 351 | 4.4375 | 4 | """program to unpack a tuple in several variables"""
a, b, c = (4, 'hello', [1, 2, 3]) # unpacking of in several variables
print(a, b, c)
'''
x = (4, 'hello', [1, 2, 3]) # packing
(a, b, c) = x # unpacking
print(a, b, c)
a, _, c = x # ignoring 2nd item '_' holds 2nd item '_' used a... | false |
3a097f2425a884b0869818f8bf2646854f2ef6af | vaibhavyesalwad/Basic-Python-and-Data-Structure | /Basic Programs/Factorial.py | 556 | 4.25 | 4 | """Find factorial of given number"""
def fact(num):
if num < 0:
return 'factorial of negative number not possible'
elif num == 0:
return 1
else:
factorial= 1
for i in range(1, num+1):
factorial *= i
return factorial
def recurse_fact(num):
if num < ... | true |
7aa66e034df46248f0a8cc6d12617137533fc4ab | vaibhavyesalwad/Basic-Python-and-Data-Structure | /Python Data Structure/Strings/03_ReplaceChar.py | 377 | 4.1875 | 4 | """program to get a string from a given string where all occurrences of its first char have been
changed to '$', except the first char itself"""
string = 'restart'
ch = 'r'
i = string.index(ch) # using str.replace() method returns new string with all replacements
print(string[:i+1]+string[i+1:].replace(c... | true |
546f755653d647de1c8afec21f7b630aab5ef626 | vaibhavyesalwad/Basic-Python-and-Data-Structure | /Python Data Structure/Dictionary/13_CountValuesAsList.py | 343 | 4.125 | 4 | """Program to count number of items in a dictionary value that is a list"""
dict1 = {'a': [1, 2, 3, 4], 'b': [2, 3, 4, 5], 'c': 1, 'd': 'z', 'e': (1,)}
# if value is list added True i.e. 1 else False i.e. 0
count = sum(isinstance(value, list) for value in dict1.values()) # sum fn & generator expression
print(f'{co... | true |
25778e07eadbe6059b64b6d79cc384bc7150525c | vaibhavyesalwad/Basic-Python-and-Data-Structure | /Python Data Structure/Dictionary/01_SortByValue.py | 418 | 4.4375 | 4 | """Sort (ascending and descending) a dictionary by value"""
d = {'a': 26, 'b': 25, 'y': 2, 'z': 1}
# to access and map key value pairs dict.item gives list of tuples of key, value pairs
print(f'Ascending order by value {dict(sorted(d.items(),key=lambda x: x[1]))}') # using second element of tuple
print(f'Descending or... | true |
dcca3f992e91118ce37e7bb14a2942cef6ea431c | vaibhavyesalwad/Basic-Python-and-Data-Structure | /Sorting Algorithms/InsertionSort.py | 488 | 4.15625 | 4 | """Sort numbers in list using Insertion sort algorithm"""
numbers = [int(i) for i in input('Enter list of numbers:').split()]
print(numbers)
for i in range(1, len(numbers)): # first element already sorted
j = i # insert element at j index in left part of array at it's appr... | true |
33bb259270a1bc8fd006b9f441a6b3267cff63b5 | vaibhavyesalwad/Basic-Python-and-Data-Structure | /Python Data Structure/List/06_RemoveDuplication.py | 205 | 4.15625 | 4 | """Program to remove duplicates from a list"""
numbers = [10, 15, 15, 20, 50, 55, 65, 20, 30, 50]
print(f'Unique elements: {set(numbers)}') # set accepts only unique elements so typecasting to set
| true |
79cd83079e88f7d62fc64f5398d00bb70cabf4f7 | Bakalavr163/Alexander_Donskoy | /Easy_homework 6.py | 2,992 | 4.46875 | 4 | # Задача-1:
# Следующая программа написана верно, однако содержит места потенциальных ошибок.
# используя конструкцию try добавьте в код обработку соответствующих исключений.
# Пример.
# Исходная программа:
def avg(a, b):
"""Вернуть среднее геометрическое чисел 'a' и 'b'.
Параметры:
- a, b (in... | false |
74207f09ecbe9354d93ace2c3d0edd34613997fb | thesayraj/DSA-Udacity-Part-II | /Project-Show Me Data Structures/problem_2.py | 863 | 4.21875 | 4 | import os
def find_files(suffix = "", path = "."):
"""
Find all files beneath path with file name suffix.
Note that a path may contain further subdirectories
and those subdirectories may also contain further subdirectories.
There are no limit to the depth of the subdirectories can be.
... | true |
258decfc38f5f05740389356d78bcdfaf780bfc8 | lujamaharjan/pythonAssignment2 | /question5.py | 791 | 4.75 | 5 | """
5. Create a tuple with your first name, last name, and age. Create a list,
people, and append your tuple to it. Make more tuples with the
corresponding information from your friends and append them to the
list. Sort the list. When you learn about sort method, you can use the
key parameter to sort by any field in th... | true |
6065ac1867f7dafea2872a50162e1b8f4f2a2527 | lujamaharjan/pythonAssignment2 | /question15.py | 700 | 4.3125 | 4 | """
Imagine you are designing a bank application.
what would a customer look like? What attributes
would she have? What methods would she have?
"""
class Customer():
def __init__(self, account_no, name, address, email, balance):
self.account_no = account_no
self.name = name
self.add... | true |
14569d9e12b63f29b2002c014fe8fdb79d990bcf | babbgoud/maven-project | /guess-numapp/guessnum.py | 765 | 4.15625 | 4 | #! /usr/bin/python3
import random
print('Hello, whats your name ?')
myname = input()
print('Hello, ' + myname + ', I am thinking of a number between 1 and 20.')
secretNumber = random.randint(1,20)
for guesses in range(1,7):
print('Take a guess.?')
guessNumber = int(input())
if int(guessNumber) > se... | true |
0dcc567b62cb6e81893fd99471a32737388d04b2 | ramyanaga/MIT6.00.1x | /Pset2.py | 2,332 | 4.3125 | 4 | """
required math:
monthly interest rate = annual interest rate/12
minimum monthly payment = min monthly payment rate X previous balance
monthly unpaid balance = previous balance - min monthly payment
updated balance each month = monthly unpaid balance + (monthly interest rate X monthly unpaid balance)
NEED TO PRINT:... | true |
3eb482c7861a7a2ea0e293cacce0d75d2f41de77 | AlexDT/Playgarden | /Project_Euler/Python/001_sum.py | 542 | 4.1875 | 4 | # coding: utf-8
#
# ONLY READ THIS IF YOU HAVE ALREADY SOLVED THIS PROBLEM!
# File created for http://projecteuler.net/
#
# Created by: Alex Dias Teixeira
# Name: 001_sum.py
# Date: 06 Sept 2013
#
# Problem: [1] - Multiples of 3 and 5
# If we list all the natural numbers below 10 that are multiples of
... | true |
059b1b036fd32d0df3d23ef4fed084586b92202a | softwarefaith/PythonFullStack | /PythonFullStack/000Basic/Day02-集合遍历/day02/11-拆包.py | 481 | 4.21875 | 4 | #拆包通俗理解:把容器类型(字符串,列表,元组,字典,结合)
#每一个数据使用不同的变量保存一下
#字符串
my_str = "abc"
a,b,c = my_str
print(a,b,c)
#列表
my_list = [1,5]
num1,num2 = my_list
print(num1,num2)
#元组
my_tuple = (1,5)
num1,num2 = my_tuple
print(num1,num2)
#拆字典(默认拆取的是key)
my_dict = {"name":"胡亮","age":"20"}.values()
key1,key2 = my_dict
print(key1,key2)
#集合
my_set... | false |
ec97c964601cfb0e8f6b37dbaa0b14b96d0728f0 | softwarefaith/PythonFullStack | /PythonFullStack/000Basic/Day02-集合遍历/day02/03-元组.py | 1,236 | 4.28125 | 4 | #元组:以小括号形式的数据集合,比如(1,2,"abc")
#可以存储任意数据类型
#注意,元组可以根据下标获取数据,但是不能对元组进行数据修改
my_tuple = (1,4,"abc",True,1.2)
print(my_tuple)
#根据下标取值
value = my_tuple[-1]
print(value)
# #元组不能根据下标删除数据
# del my_tuple[2]
# print(my_tuple)
#修改也是不可以
# my_tuple[0] = 3
# # print(my_tuple)
# #直接根据下标修改数据是不可以的,不论元组里面装的是什么数据类型
# my_tuple = (1,[3,5... | false |
8b342f9279fd4a380434b2f01d874f0fd3171894 | softwarefaith/PythonFullStack | /PythonFullStack/004Exception/000exception.py | 1,357 | 4.1875 | 4 | # 异常处理
""""""
"""
内置了一套try...except...finally...的错误处理机制
"""
try:
print('try...')
r = 10 / int('a')
print('result:', r)
except ValueError as e:
print('ValueError:', e)
except ZeroDivisionError as e:
print('ZeroDivisionError:', e)
else:
print('no error!')
finally:
print('finally...')
print(... | false |
e69c10620674ce54416070ef1b8c2fdc08cdd452 | softwarefaith/PythonFullStack | /PythonFullStack/000Basic/day04/10-切片.py | 701 | 4.40625 | 4 | #切片:根据下标的范围获取一部分数据:字符串,列表可以使用切片
#正数下标的切片
my_str = "hello"
result = my_str[0]
print(result)
#[起始下标,结束下标,步长](下标从0开始)
#切片结束下标不取
result = my_str[0:4:1]
print(result)
#前三个数据(默认步长为0)
result = my_str[0:3]
print(result)
#前两个可以省略
result = my_str[::3]
print(result)
#快速获取整个字符串
result = my_str[:]
print(result)
#使用负数下标切片的方式获取数据
my_... | false |
fbe7386c2a4425dc87bf76982cf9dc23c54f938b | softwarefaith/PythonFullStack | /PythonFullStack/000Basic/day07-类/06-类的定义.py | 654 | 4.21875 | 4 | #类的定义需要使用class关键字 人有特征和行为(动作)
#类有属性(特征)和方法(行为)
#定义一个老师类(继承父类)
#创建类的方式,是旧式类方式创建
#python3默认继承object
#python2中里面就没有父类
class Teacher():
#国籍(属性)
country = "中国"
#方法
def show(self):
print("大家好,我是大家的授课老师")
#通过类来创建对象,类好比是一个图纸,根据图纸创建对象
teacher = Teacher()
#通过对象调用方法
teacher.show()
#通过对象查看方法
print(teache... | false |
0adc3d68701d28d0094280378b9cb2e068a4ae3b | softwarefaith/PythonFullStack | /PythonFullStack/000Basic/day07-类/10-__str_魔法方法.py | 397 | 4.125 | 4 | #__str_:当使用print打印对象的时候回自动调用
class Person(object):
def __init__(self,name,age):
self.name = name
self.age = age
def __str__(self):
#返回一个字符串信息
return "我叫:%s 年龄:%d" %(self.name,self.age)
#创建对象
person = Person("张三",18)
#打印对象的属性值
print(person.name,person.age)
print(person) | false |
caa473a30bcfab1f491e58b5f017ab4eb4eb99e2 | SamNel2000/FreshmenProjects | /Fibonacci and Lucas Sequences.py | 773 | 4.15625 | 4 | name = input("Enter 'A' for Fibonacci Sequence and 'B' for Lucas Sequence: ")
def fib(a, b):
n = int(input("Enter the ordinal value of the term you want: ")) - 1
for x in range(n):
a = a + b
b = a - b
print("The " + str(n + 2) + "th term of the fibonacci sequence is:", a, "\nThe appr... | false |
34534abc70987c7c05910c3436868db6b0a97148 | sasathornt/Python-3-Programming-Specialization | /Python Basics/Week 4/assess_week5_01.py | 331 | 4.34375 | 4 | ##Currently there is a string called str1. Write code to create a list called chars which should contain the characters from str1. Each character in str1 should be its own element in the list chars
str1 = "I love python"
# HINT: what's the accumulator? That should go here.
chars = []
for letter in str1:
chars.app... | true |
aff493107f2fe0b300cb3c222480c48161ae51f0 | Neves-Roberto/python-course | /soma_hipotenusas.py | 1,771 | 4.125 | 4 | '''
Exercício 2 - (Difícil) Soma das hipotenusas
Escreva uma função soma_hipotenusas que receba como parâmetro um número
inteiro positivo n e devolva a soma de todos os inteiros entre 1 e n que
são comprimento da hipotenusa de algum triângulo retângulo com catetos
inteiros.
DIca1: um mesmo número pode ser hipotenusa ... | false |
8c3568887faf1683f43f2b8fce66ab007f98be63 | Neves-Roberto/python-course | /pontos.py | 858 | 4.125 | 4 | '''Exercício 1 - Distância entre dois pontos
Receba 4 números inteiros na entrada. Os dois primeiros devem corresponder,
respectivamente, às coordenadas x e y de um ponto em um plano cartesiano.
Os dois últimos devem corresponder, respectivamente, às coordenadas x e y
de um outro ponto no mesmo plano.
Calcule a distâ... | false |
1d71ab1f3585ef7d344998afffe54b01ab443c59 | KazuoKitahara/challenge | /cha45.py | 275 | 4.125 | 4 |
def f(x):
"""
Returns float of input string.
:param x: int,float or String number
try float but if ValueError, print "Invalid input"
"""
try:
return float(x)
except ValueError:
print("Invalid input")
print(f(10))
print(f("ten"))
| true |
d14fecadef87c5fe1cbb2c7dc1a321e21fa51f60 | ReddivariShalini/fibanocci-mycaption | /extension.py | 243 | 4.15625 | 4 | def fibonacci(n):
if n<=1:
return n
else:
return(fibonacci(n-1) + fibonacci(n-2))
n = int(input('Enter a number, N, N>=2 : '))
fibo_series = []
for i in range(0,n):
fibo_series.append(fibonacci(i))
print(fibo_series)
| false |
1aba84f4c9ccb999895378980f14101ba10d3adb | Fang-Molly/CS-note | /python3 for everybody/exercises_solutions/ex_09_05.py | 897 | 4.375 | 4 | '''
Python For Everybody: Exploring Data in Python 3 (by Charles R. Severance)
Exercise 9.5: This program records the domain name (instead of the address) where the message was sent from instead of who the mail came from (i.e., the whole email address). At the end of the program, print out the contents of your diction... | true |
537ab14e1654a023e4de4c0cd4c3dc37ab2394e1 | paulcockram7/paulcockram7.github.io | /10python/l05/Exercise 2.py | 261 | 4.125 | 4 | # Exercise 2
# creating a simple loop
# firtly enter the upper limit of the loop
stepping_variable = int(input("Enter the amount of times the loop should run "))
#set the start value
i = 0
for i in range(stepping_variable):
print("line to print",str(i))
| true |
92a8edcc1b4419cda07813c301607d0e036de96f | Biytes/learning-basic-python | /loops.py | 749 | 4.15625 | 4 | '''
Description:
Author: Biytes
Date: 2021-04-12 17:55:57
LastEditors: Biytes
LastEditTime: 2021-04-12 18:50:23
FilePath: \python\basic\loops.py
'''
# A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string).
people = ['John', 'Paul', 'Sara', 'Susan']
# Simpl... | true |
ca4aabd62635f10edb934d941c09e1865b02f5b2 | applepie787/Cloud_AI_Study | /python_workspace/tuple_test.py | 608 | 4.15625 | 4 | # 튜플 - 리스트와 유사한 자료형
# 한번 결정된 요소는 바뀔 수 없습니다.
tuple_data = (10, 20, 30)
tuple_data2 = 10, 20, 30 # 괄호가 없어도 튜플로 선언됩니다.
print(tuple_data)
print(tuple_data2)
print(type(tuple_data))
print(type(tuple_data2))
# tuple_data[0] = 100 튜플에 새로운 값을 할당 할 수는 없다.
name, age, major = "이루다", 28, "전자전기공학"
print(name,"|", age,"|", major... | false |
1d1795475f2656f95beaaeadcc30daca4d5c5c67 | applepie787/Cloud_AI_Study | /python_workspace/loops.py | 963 | 4.3125 | 4 | array_ = [1, 2, 3, 4, 5]
for data in array_:
print(data, end="") # print로 인한 라인 변경을 막아준다.
print("")
for data in array_:
print(data)
print("_______________________________________________")
for i in range(len(array_)):
print(array_[i])
print("_______________________________________________")
for i in ... | false |
e690dad132239e95a67f7d735ea872ba9f2da917 | anik511/My_Python | /Basic/25_list_comprehensions.py | 671 | 4.28125 | 4 | # normal method
# making double of list
li = [1, 2, 3, 4, 5, 6, 7, 8, 9]
NewLi = []
for x in li:
NewLi.append(2*x)
print("New List:", NewLi)
# List Comprehension Method
Comprehension = [2 * x for x in li]
print("List Comprehension: ", Comprehension)
# Finding Even Numbers
# normal method
even = ... | false |
14e5b26ac617c4e2f871fd162b8c07d64132ce9f | koltpython/python-slides | /Lecture7/lecture-examples/lecture7-1.py | 828 | 4.34375 | 4 |
# Free Association Game
clues = ('rain', 'cake', 'glass', 'flower', 'napkin')
# Let's play a game. Give the user these words one by one and ask them to give you the first word that comes to their mind.
# Store these words together in a dictionary, where the keys are the clues and the values are the words that the us... | true |
ec9a757fbf7807641a17c4f4eb73feab391f8033 | koltpython/python-slides | /Lecture3/code-examples/branching_example.py | 238 | 4.15625 | 4 | operation = int(input())
num1 = int(input())
num2 = int(input())
if operation == 1:
sum_two_numbers(num1, num2)
elif operation == 2:
multiply_two_numbers(num1, num2)
else:
divide_two_numbers(num1, num2)
print('I am here')
| false |
8013c5a1d5760cd65eca1c8c3c009003dc53b8a3 | JulianTrummer/le-ar-n | /code/01_python_basics/examples/02_lists_tuples_dictionaries/ex4_tuples.py | 333 | 4.34375 | 4 | """Tuple datatypes"""
# A tuple is similar to a list, however the sequence is immutable.
# This means, they can not be changed or added to.
my_tuple_1 = (1, 2, 3)
print(my_tuple_1, type(my_tuple_1))
print(len(my_tuple_1))
my_tuple_2 = tuple(("hello", "goodbye"))
print(my_tuple_2[0])
print(my_tuple_2[-1])
print(my_... | true |
483d8c2a95519c1e81242ec1420e7b80640595bc | JulianTrummer/le-ar-n | /code/01_python_basics/examples/05_classes/ex1_class_intro.py | 606 | 4.25 | 4 | # Classes introduction
# Class definition
class Vehicle():
# Initiation function (always executed when the class object is being initiated)
def __init__(self, colour, nb_wheels, name):
self.colour = colour
self.nb_wheels = nb_wheels
self.name = name
# Creating objects from class
vehicl... | true |
44712e0fbd75dd14e249a32416a4d47a55df1280 | JulianTrummer/le-ar-n | /code/01_python_basics/examples/01_datatypes_operators_conditionals/ex4_arithmetic_operators.py | 315 | 4.15625 | 4 | """Arithmetic Operators"""
# using values:
a = 10
b = 5.5
c = 3
# Addition and Subtraction
d = a + c
e = d - b
print(d)
print(e)
# Multiplication and Division
f = c / 10 + b * 5
print(f)
# Exponentation
f_square = f**2
print(f_square)
# Modulus
f_modulus_2 = f_square % 2
print(f_modulus_2)
print(f_square % 3)
| false |
1d7659b09b39394fbc031fe4799a21530d5cf8f1 | jarrettdunne/coding-problems | /daily/problem1.py | 1,077 | 4.21875 | 4 | import unittest
class TestStringMethods(unittest.TestCase):
def test_upper(self):
self.assertEqual('foo'.upper(), 'FOO')
def test_isupper(self):
self.assertTrue('FOO'.isupper())
self.assertFalse('Foo'.isupper())
def test_split(self):
'''
input:
[1, 2, 3]
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.