In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "how to use the python function". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
# 13 function
# 13.1 write a function to print your name in capital letters.
Def printName ():
Print ("CCCC A RRRRR TTTTTTT EEEEEE RRRRR")
Print ("C C An A R R T E R R")
Print ("C An A R R T EEEEEE R R")
Print ("C AAAAAAAAA RRRRRR T E RRRRRR")
Print ("C CA A R R T E R R")
Print ("CCCC An AR R T EEEEEE R R")
Print ()
For i in range (5):
PrintName () # if you add print (printName ()), the none value will appear.
# 13.2 create a function that can print names, addresses, streets, cities, states, provinces, zip codes and countries all over the world
Def printAdress (name,address,street,city,code,country):
Print (name)
Print (address)
Print (street)
Print (city)
Print (code)
Print (country)
PrintAdress ("jack", "309", "NO1", "North", "01001", "RUSSIA")
# 13.3 13-7 columns, which requires my_price to be a global variable
Def calculateTax (price,tax_rate):
Total = price + (price * tax_rate)
Global my_price
My_price = 1000
Print ("my_price (inside function) =", my_price)
Return total
My_price = float (input ("Enter a price:"))
TotalPrice = calculateTax (my_price,0.06)
Print ("price =", my_price, "Total price =", totalPrice)
Print ("my_price (outside function) =", my_price)
# 13.4 calculate the total value of change
Def countNo (quarters,dimes,nickels,pennies):
Total = quarters * 5 + dimes * 2 + nickels * 1 + pennies
Return total # return value
Quarters = int (input ())
Dimes = int (input ())
Nickels= int (input ())
Pennies = int (input ())
Total = countNo (quarters,dimes,nickels,pennies)
Print (total)
This is the end of the content of "how to use the python function". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.