Python Calculator Codes📟
# This program is a simple calculator
# Function to add two numbers
def add(x, y):
return x + y
# Function to subtract two numbers
def subtract(x, y):
return x - y
# Function to multiply two numbers
def multiply(x, y):
return x * y
# Function to divide two numbers
def divide(x, y):
return x / y
print("Select operation.")
print("1.Add")
print("2.Subtract")
print("3.Multiply")
print("4.Divide")
# Take input from the user
choice = input("Enter choice(1/2/3/4): ")
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
if choice == '1':
print(num1,"+",num2,"=", add(num1,num2))
elif choice == '2':
print(num1,"-",num2,"=", subtract(num1,num2))
elif choice == '3':
print(num1,"*",num2,"=", multiply(num1,num2))
elif choice == '4':
print(num1,"/",num2,"=", divide(num1,num2))
else:
print("Invalid input")👍8❤6
In general, the Python standard library includes many built-in functions that are available to use in your code without needing to import any additional modules. Some common examples of built-in functions include:
👉🏻 abs() : Returns the absolute value of a number.
👉🏻 all() : Returns True if all elements of an iterable are True, and False otherwise.
👉🏻 any() : Returns True if any element of an iterable is True, and False otherwise.
👉🏻 bin() : Converts an integer to a binary string.
👉🏻 bool() : Converts a value to a Boolean.
👉🏻 chr() : Returns the string representation of a Unicode character.
👉🏻 dir() : Returns a list of attributes and methods for an object.
👉🏻enumerate(): Returns an enumerate object, which contains a sequence of tuples containing the index and value of each element of an iterable.
👉🏻 filter() : Returns an iterator for elements of an iterable for which a condition is True.
👉🏻 float() : Converts a value to a floating-point number.
👉🏻 format(): Formats a string using format specifiers.
👉🏻 hash() : Returns the hash value of an object.
👉🏻 int() : Converts a value to an integer.
👉🏻 isinstance(): Returns True if an object is an instance of a given type, and False otherwise.
👉🏻 len() : Returns the length of an object.
👉🏻 list() : Converts an iterable to a list.
👉🏻 map() : Returns an iterator that applies a function to each element of an iterable.
👉🏻 max() : Returns the maximum value of an iterable.
👉🏻 min() : Returns the minimum value of an iterable.
👉🏻 next() : Returns the next element of an iterator.
👉🏻 open() : Opens a file and returns a file object.
👉🏻 ord() : Returns the Unicode code point for a character.
👉🏻 print() : Prints a message to the standard output.
👉🏻 range() : Returns a sequence of numbers.
👉🏻 repr() : Returns a string representation of an object.
👉🏻 round() : Rounds a number to a specified number of decimal places.
👉🏻 set() : Creates a set object.
👉🏻 sorted() : Returns a sorted list from an iterable.
👉🏻 str() : Converts a value to a string.
👉🏻 sum() : Returns the sum of elements in an iterable.
👉🏻 type() : Returns the type of an object.
👉🏻 zip() : Returns an iterator that combines elements from multiple iterables.
Share and Support
https://t.iss.one/free4unow_backup
👉🏻 abs() : Returns the absolute value of a number.
👉🏻 all() : Returns True if all elements of an iterable are True, and False otherwise.
👉🏻 any() : Returns True if any element of an iterable is True, and False otherwise.
👉🏻 bin() : Converts an integer to a binary string.
👉🏻 bool() : Converts a value to a Boolean.
👉🏻 chr() : Returns the string representation of a Unicode character.
👉🏻 dir() : Returns a list of attributes and methods for an object.
👉🏻enumerate(): Returns an enumerate object, which contains a sequence of tuples containing the index and value of each element of an iterable.
👉🏻 filter() : Returns an iterator for elements of an iterable for which a condition is True.
👉🏻 float() : Converts a value to a floating-point number.
👉🏻 format(): Formats a string using format specifiers.
👉🏻 hash() : Returns the hash value of an object.
👉🏻 int() : Converts a value to an integer.
👉🏻 isinstance(): Returns True if an object is an instance of a given type, and False otherwise.
👉🏻 len() : Returns the length of an object.
👉🏻 list() : Converts an iterable to a list.
👉🏻 map() : Returns an iterator that applies a function to each element of an iterable.
👉🏻 max() : Returns the maximum value of an iterable.
👉🏻 min() : Returns the minimum value of an iterable.
👉🏻 next() : Returns the next element of an iterator.
👉🏻 open() : Opens a file and returns a file object.
👉🏻 ord() : Returns the Unicode code point for a character.
👉🏻 print() : Prints a message to the standard output.
👉🏻 range() : Returns a sequence of numbers.
👉🏻 repr() : Returns a string representation of an object.
👉🏻 round() : Rounds a number to a specified number of decimal places.
👉🏻 set() : Creates a set object.
👉🏻 sorted() : Returns a sorted list from an iterable.
👉🏻 str() : Converts a value to a string.
👉🏻 sum() : Returns the sum of elements in an iterable.
👉🏻 type() : Returns the type of an object.
👉🏻 zip() : Returns an iterator that combines elements from multiple iterables.
Share and Support
https://t.iss.one/free4unow_backup
Telegram
Free Courses with Certificate - Python Programming, Data Science, Java Coding, SQL, Web Development, AI, ML, ChatGPT Expert
We provide unlimited Free Courses with Certificate to learn Python, Data Science, Java, Web development, AI, ML, Finance, Hacking, Marketing and many more from top websites.
Admin: @love_data
Admin: @love_data
❤4👍4
Q. WHAT IS PROGRAMMING ?
--> Programming is writing computer code to create a program, to solve a problem. Programs are created to implement algorithms. Algorithms can be represented as pseudocode or a flowchart, and programming is the translation of these into a computer program. To tell a computer to do something, a program must be written to tell it exactly what to do and how to do it. If an algorithm has been designed, the computer program will follow this algorithm, stepby-step, which will tell the computer exactly what it should do.
Share and Support
https://t.iss.one/free4unow_backup
--> Programming is writing computer code to create a program, to solve a problem. Programs are created to implement algorithms. Algorithms can be represented as pseudocode or a flowchart, and programming is the translation of these into a computer program. To tell a computer to do something, a program must be written to tell it exactly what to do and how to do it. If an algorithm has been designed, the computer program will follow this algorithm, stepby-step, which will tell the computer exactly what it should do.
Share and Support
https://t.iss.one/free4unow_backup
Telegram
Free Courses with Certificate - Python Programming, Data Science, Java Coding, SQL, Web Development, AI, ML, ChatGPT Expert
We provide unlimited Free Courses with Certificate to learn Python, Data Science, Java, Web development, AI, ML, Finance, Hacking, Marketing and many more from top websites.
Admin: @love_data
Admin: @love_data
👍5❤1
Q. What Is Coding?
--> Coding is an act of interpreting codes from human language to machine-based language. We can also say that it is a subset of programming that gives foundation to programming. In coding, the programmer instructs the computer, what to perform.
The key difference between programming and coding is that programming is the process of developing a program or application that trails certain standards and performs a specified task.
Share and Support
https://t.iss.one/free4unow_backup
--> Coding is an act of interpreting codes from human language to machine-based language. We can also say that it is a subset of programming that gives foundation to programming. In coding, the programmer instructs the computer, what to perform.
The key difference between programming and coding is that programming is the process of developing a program or application that trails certain standards and performs a specified task.
Share and Support
https://t.iss.one/free4unow_backup
Telegram
Free Courses with Certificate - Python Programming, Data Science, Java Coding, SQL, Web Development, AI, ML, ChatGPT Expert
We provide unlimited Free Courses with Certificate to learn Python, Data Science, Java, Web development, AI, ML, Finance, Hacking, Marketing and many more from top websites.
Admin: @love_data
Admin: @love_data
👍3❤1
# Defined function
from turtle import *
import turtle as t
def my_turtle():
# Choices
sides = str(3)
loops = str(450)
pen = 1
# Loop
for i in range(int(loops)):
forward(i * 2/int(sides) + i)
left(360/int(sides) + .350)
hideturtle()
pensize(pen)
speed(30)
left(90)
my_turtle()
t.done()👨💻10👍2❤1
from turtle import *
import turtle as t
def my_turtle():
# Choices
sides = str(3)
loops = str(450)
pen = 1
for i in range(int(loops)):
forward(i * 2/int(sides) + i)
left(360/int(sides) + .350)
hideturtle()
pensize(pen)
speed(30)
my_turtle()
t.done()👍7
Android App Development For Dummies (Michael Burton).pdf
8.1 MB
Android App development for Dummies
Learn C Programming, 2nd Edition (Jef.).pdf
15 MB
Learn C programming
Jeff Szuhay, 2022
Jeff Szuhay, 2022
👍2
👍2