current position:Home>Input and output of Python practice
Input and output of Python practice
2022-01-30 22:42:59 【Bu Xiaochan】
「 This is my participation 11 The fourth of the yuegengwen challenge 2 God , Check out the activity details :2021 One last more challenge 」.
@[toc]
Preface
From 「 Basics 」 Knowledge of programming begins , Take you to understand 「 Basic algorithm 」 as well as 「Python The beauty of 」 And 「 function 」 The convenience and quickness of . collect 「100 example Python Introduction to basic language 」, contain 「 The real exam question 」, 「LeetCode Basic questions 」, And add detailed problem-solving ideas and difficulty analysis .
this 100 The example part is 『 I am 』 collect , Part of what I think , from 『 introduction 』 Start , To 『 Advanced 』 end ,『 Actual operation 』 Add problem solving analysis , Let you 『 To master thoroughly 』Python Language foundation
1. Title Description
- Please write a program , Find the sum of any two numbers obtained from the keyboard
- Please write a program , Find the difference between any two numbers obtained from the keyboard
- Please write a program , Find the product of any two numbers obtained from the keyboard
- Please write a program , Find the remainder of any two numbers obtained from the keyboard
- Please write a program , Find the result of dividing any two numbers obtained from the keyboard ( The result is required to be an integer )
2. Program analysis
A set of templates , You can finish
- First, it's no use getting data from the keyboard
input()
function - Then you need to notice ,input The data obtained by the function is a string by default
- Note that the result of division requires an integer
3. Program source code
# The first question is
a1 = input(" Please enter the first number ")
b1 = input(" Please enter the second number ")
print(" The sum of two numbers is :",a1+a2)
# The second question is
a2 = input(" Please enter the first number ")
b2 = input(" Please enter the second number ")
print(" The difference between the two numbers is :",a1-a2)
# Third question
a3 = input(" Please enter the first number ")
b3 = input(" Please enter the second number ")
print(" The product of two numbers is :",a1*a2)
# Fourth question
a4 = input(" Please enter the first number ")
b4 = input(" Please enter the second number ")
print(" The remainder of two numbers is :",a1%a2)
# Fifth question
a5 = input(" Please enter the first number ")
b5 = input(" Please enter the second number ")
print(" The division of two numbers is :",a1//a2)
Copy code
4. Running results
Please enter the first number :1
Please enter the second number 2
The sum of two numbers is : 3
Please enter the first number :1
Please enter the second number :2
The difference between the two numbers is : -1
Please enter the first number :1
Please enter the second number :2
The product of two numbers is : 2
Please enter the first number :1
Please enter the second number :2
The remainder of two numbers is : 1
Please enter the first number :1
Please enter the second number :2
The division of two numbers is : 0
Copy code
5. Difficulty analysis
- Note that the result required in question 5 is an integer , So use
//
- input The value returned by the function defaults to string , We need to transform , Add and subtract
- The dividend cannot be zero 0
6. Knowledge points involved
- Input and output
- Type conversion
- Operator
Conclusion
copyright notice
author[Bu Xiaochan],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/01/202201302242570545.html
The sidebar is recommended
- Introduction to python (IV) dynamic web page analysis and capture
- leetcode 119. Pascal's Triangle II(python)
- leetcode 31. Next Permutation(python)
- [algorithm learning] 807 Maintain the city skyline (Java / C / C + + / Python / go / trust)
- The rich woman's best friend asked me to write her a Taobao double 11 rush purchase script in Python, which can only be arranged
- Glom module of Python data analysis module (1)
- Python crawler actual combat, requests module, python realizes the full set of skin to capture the glory of the king
- Summarize some common mistakes of novices in Python development
- Python libraries you may not know
- [Python crawler] detailed explanation of selenium from introduction to actual combat [2]
guess what you like
-
This is what you should do to quickly create a list in Python
-
On the 55th day of the journey, python opencv perspective transformation front knowledge contour coordinate points
-
Python OpenCV image area contour mark, which can be used to frame various small notes
-
How to set up an asgi Django application with Postgres, nginx and uvicorn on Ubuntu 20.04
-
Initial Python tuple
-
Introduction to Python urllib module
-
Advanced Python Basics: from functions to advanced magic methods
-
Python Foundation: data structure summary
-
Python Basics: from variables to exception handling
-
Python notes (22): time module and calendar module
Random recommended
- Python notes (20): built in high-order functions
- Python notes (17): closure
- Python notes (18): decorator
- Python notes (16): generators and iterators
- Python notes (XV): List derivation
- Python tells you what timing attacks are
- Python -- file and exception
- [Python from introduction to mastery] (IV) what are the built-in data types of Python? Figure out
- Python code to scan code to pay attention to official account login
- [algorithm learning] 1221 Split balanced string (Java / C / C + + / Python / go / trust)
- Python notes (22): errors and exceptions
- Python has been hidden for ten years, and once image recognition is heard all over the world
- Python notes (21): random number module
- Python notes (19): anonymous functions
- Use Python and OpenCV to calculate and draw two-dimensional histogram
- Python, Hough circle transformation in opencv
- A library for reading and writing markdown in Python: mdutils
- Datetime of Python time operation (Part I)
- The most useful decorator in the python standard library
- Python iterators and generators
- [Python from introduction to mastery] (V) Python's built-in data types - sequences and strings. They have no girlfriend, not a nanny, and can only be used as dry goods
- Does Python have a, = operator?
- Go through the string common sense in Python
- Fanwai 4 Handling of mouse events and solutions to common problems in Python opencv
- Summary of common functions for processing strings in Python
- When writing Python scripts, be sure to add this
- Python web crawler - Fundamentals (1)
- Pandas handles duplicate values
- Python notes (23): regular module
- Python crawlers are slow? Concurrent programming to understand it
- Parameter passing of Python function
- Stroke tuple in Python
- Talk about ordinary functions and higher-order functions in Python
- [Python data acquisition] page image crawling and saving
- [Python data collection] selenium automated test framework
- Talk about function passing and other supplements in Python
- Python programming simulation poker game
- leetcode 160. Intersection of Two Linked Lists (python)
- Python crawler actual combat, requests module, python to grab the beautiful wallpaper of a station
- Fanwai 5 Detailed description of slider in Python opencv and solutions to common problems