jupyter notebook basic for python (other)

# def p(a):
# 	d = a + " " + a
# 	return d
# print(p("new days"))
# type(print("did again"))
# #
# def twogril(one,two):
# 	result = "I love " + one.title() + " " + two.title()
# 	# print(result)
# 	return result

# someday = twogril("lisa","pear")
# print(someday)

# def hat_available(color):
#     hat_colors = 'black, red, blue, green, white, grey, brown, pink'
#     return(color.lower() in hat_colors)

# have_hat = hat_available('green')  
# print('hat available is', have_hat)


##judge color in list,does it exist. 
# def colorIn(color):
# 	colors = "red,blue,green,white,yellow,black,pink"
# 	print(color in colors)

# colorIn("red")

##one tool to find anything in somewhere!
# def anythingIn(something):
# 	li = [1,3,5,6]
# 	if something in li:
# 		print(True)

# anythingIn(3)
# 
#
##find a book in library!
# def library(someone):
# 	books = ["science","math","literal","english","history","design"]
# 	if someone in books:
# 		print(books.index(someone))
# 	else:
# 		print(someone.upper()+" is not in this library!")
# 		print("***************************************************************")
# 		print("if you want find someother,you can enter what book you want to find again!")
# 		print("if you want to quit,you can enter 'q'")
# 		print("***************************************************************")
# 		# someone = input("you want:")
# while True:
# 	someone = input("please enter what you want:")
# 	library(someone)
# 	if someone == "q":
# 		break
# 
# # define function how_many
# def how_many():
#     requested = input("enter how many you want: ")
#     return requested

# # get the number_needed
# number_needed = how_many()
# print(number_needed, "will be ordered")
		
		
# hot_tea = True
# if hot_tea:
# 	print()
# else:
# 	print()
# 	
# 	#改写,由用户决定输出什么
# # 
# hot_tea = input("喜欢的口味,热的输入数字,否则输入其他:") 
# # # if hot_tea.isdigts():
# if hot_tea.isdigit():
#     flag = True
# else:
#     flag = False
# # 
# if flag:
#     print("enjoy some hot tea!")
# #     flag = False
# else:
#     print("enjoy some tea, and perhaps try hot tea next time.")
#     # 	

# what = input("what you want hot, cool or normal :")
# if what == hot:
# 	print()
# elif what == cool:
# 	print()
# elif what == normal:
# 	print()
# 	
#
# someone_i_know = False
# if someone_i_know:
#     print("how have you been?")
# else:
#     # use pass if there is no need to execute code 
#     pass
#     
#   
# #
# if student_name.isalpha():
# .isalnum()
# .istitle()
# .isdigit()
# .islower()
# .startswith()      
# #     
#     
# #changed the value of someone_i_know
# #正确的时候,什么都不输出,是一个很奇妙的事情,程序在默默的运行,不声不响,这时候,那种默默的做好事,坏事,各种校验,各种体检什么的……感觉可以做很多事情
# #出错,才说,会太晚?所以需要设置一个阈值
# someone_i_know = True
# if someone_i_know:
#     print("how have you been?")
# else:
#     pass
#     
#     
#     

# # review code and run cell
# favorite_book = input("Enter the title of a favorite book: ")

# if favorite_book.istitle():
#     print(favorite_book, "- nice capitalization in that title!")
# else:
#     print(favorite_book, "- consider capitalization throughout for book titles.")

# # review code and run cell
# a_number = input("enter a positive integer number: ")

# if a_number.isdigit():
#     print(a_number, "is a positive integer")
# else:
#     print(a_number, "is not a positive integer")
    
# # another if
# if a_number.isalpha():
#     print(a_number, "is more like a word")
# else:
#     pass
#     
#     
#    # review code and run cell
# vehicle_type = input('"enter a type of vehicle that starts with "P": ')

# if vehicle_type.upper().startswith("P"):
#     print(vehicle_type, 'starts with "P"')
# else:
#     print(vehicle_type, 'does not start with "P"')
#     

# x = 18
# test_value = 18
# if x != test_value:
#     print('x is not', test_value)
# else:
#     print('x is', test_value)



# age = 100
# name_djsjsj = "ducksssssssss"
# print("NAMEd kkks\t\tAGE")
# print(name_djsjsj + "\t" + str(age))


# # review and run code using \t (tab)
# student_age = 17
# student_name = "Hiroto Yamaguchi"
# print("STUDENT NAME\t\tAGE")
# print(student_name,'\t' + str(student_age))
# 
# 
# print("Hello" + "\n" + "World!")

#  [ ] review WHAT TO WEAR code then run testing different inputs
# while True:
#     weather = input("Enter weather (sunny, rainy, snowy, or quit): ") 
#     print()

#     if weather.lower() == "sunny":
#         print("Wear a t-shirt and sunscreen")
#         break
#     elif weather.lower() == "rainy":
#         print("Bring an umbrella and boots")
#         break
#     elif weather.lower() == "snowy":
#         print("Wear a warm coat and hat")
#         break
#     elif weather.lower().startswith("q"):
#         print('"quit" detected, exiting')
#         break
#     else:
#         print("Sorry, not sure what to suggest for", weather +"\n")

# age = 100
# name = "ducksss"
# print("NAMEdkkks\tAGE")
# print(name+ "\t\t" + str(age))



#投票系统,核心
#
# seat_count = 0
# while True:
#     print("seat count:",seat_count)
#     seat_count = seat_count + 1

#     if seat_count > 4:
#         break
#         
#
# initialize variables
# seat_count = 0         
# soft_seats = 0
# hard_seats = 0
# num_seats = 4

# # loops tallying seats using soft pads vs hard, until seats full or user "exits"
# while True:
#     seat_type = input('enter seat type of "hard","soft" or "exit" (to finish): ')
    
#     if seat_type.lower().startswith("e"):
#         print()
#         break
#     elif seat_type.lower() == "hard":
#         hard_seats += 1
#     elif seat_type.lower() == "soft":
#         soft_seats += 1
#     else:
#         print("invalid entry: counted as hard")
#         hard_seats += 1  
#     seat_count += 1
#     if seat_count >= num_seats:
#         print("\nseats are full")
#         break
        

# seat_count = 0         
# S_seats = 0
# M_seats = 0
# L_seats = 0
# num_seats = 4

# # loops tallying seats using soft pads vs hard, until seats full or user "exits"
# while True:
#     seat_type = input('enter seat type of "S","M","L" or "exit" (to finish): ')
    
#     if seat_type.lower().startswith("e"):
#         print()
#         break
#     elif seat_type.lower() == "s":
#         S_seats += 1
#     elif seat_type.lower() == "m":
#         M_seats += 1
#     elif seat_type.lower() == "l":
#         L_seats += 1
#     else:
#         print("invalid entry: counted as M")
#         M_seats += 1  
#     seat_count += 1
#     if seat_count >= num_seats:
#         print("\nseats are full")
#         break
# print(seat_count,"Seats Total: ",M_seats,"Medium",S_seats,"Small",L_seats,"Large" )
# 
# 
# #自己写的
# small_cout = 0
# large_cout = 0
# medium_cout = 0
# couts = 0
# seat_cout = 5
# while True: 
#     size = input("please enter S,M,L or exit:")
#     if size == "s":
#         small_cout += 1
#     elif size == "m":
#         medium_cout += 1
#     elif size == "l":
#         large_cout += 1
#     elif size == "e":
#         print()
#         break
#     else:
#         medium_cout += 1
        
        
#     couts += 1
#     if couts >= seat_cout:
#         break
# #     else:
# #         continue

# print(small_cout,medium_cout,large_cout,couts)
# 
# 
# 
# 
# 

# # review and run GREET COUNT
# greet_count = 5

# # loop while count is greater than 0
# while greet_count > 0:
#     print(greet_count, "!")
#     greet_count -= 1
# print("\nIGNITION!")
# 
# 

# # review and run example that loops until a valid first name format is entered
# student_fname = ""
# while student_fname.isalpha() == False:
#     student_fname = input("enter student\'s first (Letters only, No spaces): ")
# print("\n" + student_fname.title(),"has been entered as first name")
# 

##同样效果,不同的写法,简洁性很重要
# count = 1
# # loop 5 times
# while count > 0:
#     print(count, "x", count, "=", count*count)
#     count +=1
#     if count > 5:
#         break

# count = 1
# # loop 5 times
# while count < 6:
#     print(count, "x", count, "=", count*count)
#     count +=1
#     
#     
#    

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值