Practice Questions for the variables & data types
Source code here is from the activity questions of variables and data types.ppt
- Write a separate program to accomplish each of these exercises. Save each program with a filename that follows standard Python conventions, using lowercase letters and underscores, such as simple_message.py and simple_messages.py.
i. Simple Message: Store a message in a variable, and then print that message.
ii. Simple Messages: Store a message in a variable, and print that message. Then change the value of your variable to a new message, and print the new message.
message = "Start learning python Programming!" print(message) message = "Learn from bhutanpythoncoders.com" print(message)
Start learning python Programming! Learn from bhutanpythoncoders.com
2. Karma borrowed Nu 50000 to start a business from the Bank of Bhutan for 3 years at the rate of 12%. Write a program to calculate the simple interest and amount to be paid after 3 years. Use variables in the program.
principal_amount = 50000 time = 3 rate = 12/100 simple_interest = principal_amount * time * rate print(simple_interest) total_loan_repayment = principal_amount + simple_interest print(total_loan_repayment)
3. Write a python program to find the circumference of a circle with a diameter of 10cm.
PI = 3.14 radius = 10/2 # 10cm is a diameter circumference_of_circle = 2 * PI * radius print(circumference_of_circle)