Coding & Data Science Resources
30.4K subscribers
331 photos
515 files
334 links
Official Telegram Channel for Free Coding & Data Science Resources

Admin: @love_data
Download Telegram
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")
👍86
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
4👍4
Thanks For Completing 100 Subscribers❤️
1
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
👍51
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
👍31
Drawing Beautiful Design Using Python
👇👇
👍4
# 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👍21
Drawing Beautiful Design Using Python
👇👇
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
Drawing Spiderman face using Python 👇👇
👍1
Best Telegram channels for jobs and interview guide
👇👇
https://t.iss.one/addlist/fIzEnNS8RP4xOTYx
👍2
Python Data Structures and Algorithms.pdf
11.5 MB
Python Data Structures and Algorithms
👍41