Question

In: Computer Science

Homework 1 Python basics and flow control Given August 26th – Due September 8th In this...

Homework 1 Python basics and flow control Given August 26th – Due September 8th In this assignment you have to develop a security program. Inside a while loop you will ask several security questions. Be creative! When all of them are answered correctly a piece of secret information will be printed and the program will be finished. In your program: - use at least 1 time each of the following functions: print(), input(), len(), str(), int(), float() and randint(). - use at least 1 variable of each of the following data types: int, float and string. - use camelcase or underscores for variable names. Be consistent and have descriptive names! - use at least 4 different operators. One of them has to be the modulus or the integer division. - use a for loop inside your main loop to ask 3 questions using the range() function. Use the value of your iterator to ask the 3 questions. - use at least 1 time each of the following statements: if, else, elif, break and continue. - use at least one “Truthy” or “Falsey” value. Also, write some comments explaining what you do in your code and why. Submit your code file as hw1_name_surname.py. Comment everything so we know you wrote the code! On top of your file write this multiline comment with your information: ””” Homework 1, Exercise 1 (or 2…) Name Date Description of your program

The program must be written in python.

Solutions

Expert Solution

"""
This
is
multiline comment
"""
#array of secret questions

secretQuestions = ["Your favourite pet ?","Your childhood name ?","Your childhood friend ?"]
#array of answers compare with user input
answers = ["dog","nk","kp"]
#flag boolean variable storing TRUE or FALSE for user answer
flag = False

#inside for loop prompt messege to user then take input one by one
for q in range(3):
ans = input(secretQuestions[q]+" : ") #take answer in ans varibale
ans = ans.lower() #convert ans to lower case
if ans == answers[q] : #compare answer is correct
flag = True #assign true in flage when answer is correct
else :
flag = False #assign false in flage when wrong answer and print msg
print("Enter correct answer,please try again !")
break #break the loop when answer is incorrect
print() #print() function for new line
print()

#when all answer is correct print all messege with answer

if flag == True :
print("Secret Question with answers \n")
for i in range(3) :
print(secretQuestions[i] +" : "+answers[i])

"""
Sample test

Your favourite pet ? : dog
Your childhood name ? : nk
Your childhood friend ? : KP


Secret Question with answers

Your favourite pet ? : dog
Your childhood name ? : nk
Your childhood friend ? : kp

"""


Related Solutions

Question 1 - 8 Using the information given, complete following financial statements for August and September...
Question 1 - 8 Using the information given, complete following financial statements for August and September 2014. ABC s tarted its business on August 1, 2014. August September Investment by stockholders 70 Investment by stockholders 60 (Cash investment) (Cash investment) Revenue 130 Revenue 90 (Out of 130 revenue, 30 is sales on credit.) (Out of 90 revenue, 20 is sales on credit. ) (25 of cash for credit sales made in August is collected.) Expense 90 Expense 100 (Our of...
Homework 4 Due April 27, 2020 On February 1st, September call option with exercise price of...
Homework 4 Due April 27, 2020 On February 1st, September call option with exercise price of $55 written on Aztec stock is sold for $4.375 per share and September put option with exercise price of $55 written on the same stock is sold for $6 per share. At the time, T-bills coming due in September are priced to yield 12%. Aztec stock is sold for $53 per share on February 1st. The time period between Feb 1 st and expiration...
BU Curriculum Corporation issued $900,000 of 7% bonds on August 1, 2019, due on August 1,...
BU Curriculum Corporation issued $900,000 of 7% bonds on August 1, 2019, due on August 1, 2024. The interest is to be paid twice a year on February 1 and August 1. The bonds were sold to yield 9% effective annual interest. BU Curriculum Corporation closes its books annually on December 31. (b) Prepare the journal entries for the following: 1. August 1, 2019 bond issue 2. Adjusting entry for December 31, 2019 (adjusting entry should cover 5 months) 3....
BU Curriculum Corporation issued $900,000 of 7% bonds on August 1, 2019, due on August 1,...
BU Curriculum Corporation issued $900,000 of 7% bonds on August 1, 2019, due on August 1, 2024. The interest is to be paid twice a year on February 1 and August 1. The bonds were sold to yield 9% effective annual interest. BU Curriculum Corporation closes its books annually on December 31. (b) Prepare the journal entries for the following: 1. August 1, 2019 bond issue 2. Adjusting entry for December 31, 2019 (adjusting entry should cover 5 months) 3....
SE 4367, Software Testing Homework #10, Control Flow Coverage For the following program P written in...
SE 4367, Software Testing Homework #10, Control Flow Coverage For the following program P written in pseudo-code, given the test set T: T = {t1 = <4, 2>, t2 = <90, 0>, t3 = <56, 1>} What is the statement coverage for T? What is the block coverage for T? What is the decision coverage for T? What is the condition coverage for T? What is the condition/decision coverage for T? Program P integer X, Y, Z; input (X, Y);...
This task exercises your ability to use python to represent data and use flow control and...
This task exercises your ability to use python to represent data and use flow control and functions to re-organize the data. You need to submit the ipynb file to Moodle. A data scientist has collected tube information and saved the video info in multiple CSV files. Each CSV file has the following columns: ·         video_id ·         trending_date ·         title ·         channel_title ·         category_id ·         publish_time ·         tags ·         views    ·         likes      ·         dislikes ·         comment_count ·         thumbnail_link ·         comments_disabled     ·         ratings_disabled          ·         video_error_or_removed        ·         description You are asked to write python code to process CSV data...
Using the information given, complete following financial statements for August and September 2014. ABC s tarted...
Using the information given, complete following financial statements for August and September 2014. ABC s tarted its business on August 1, 2014. August September Investment by stockholders 70 Investment by stockholders 60 (Cash investment) (Cash investment) Revenue 130 Revenue 90 (Out of 130 revenue, 30 is sales on credit.) (Out of 90 revenue, 20 is sales on credit. ) (25 of cash for credit sales made in August is collected.) Expense 90 Expense 100 (Our of 90 expense, 20 is...
On July 1, $12,000 rent on building is paid for the months of July, August, and September.
On July 1, $12,000 rent on building is paid for the months of July, August, and September. Merchandize inventory $40,000 is purchased on account. The company uses perpetual inventory system. On July 1, $20,000 is borrowed from a local bank, and a note payable is signed. Credit sales for the month are $62,000, The cost of merchandize sold is $38,000. $2,000 is paid on account for office supplies. $55,000 is collected from customers on account. $10,000 is paid to employees...
Problem 1: python For the first problem of this homework, we’re going to try something a...
Problem 1: python For the first problem of this homework, we’re going to try something a little different. I’ve created the start of a file, which you’ll edit to finish the assignment: count_words_in_the_raven.py The program has three functions in it. I’ve written all of break_into_list_of_words()--DO NOT CHANGE THIS ONE. All it does is break the very long poem into a list of individual words. Some of what it's doing will not make much sense to you until we get to...
Assignment 1 (assessment worth 10%) Due Date Monday 8th May by 5pm GMT+8 [Submission will be...
Assignment 1 (assessment worth 10%) Due Date Monday 8th May by 5pm GMT+8 [Submission will be strictly observed. Make submission via Turnitin] Question 1 An Australian investor holds a one month long forward position on USD. The contract calls for the investor to buy USD 2 million in one month’s time at a delivery price of $1.4510 per USD. The current forward price for delivery in one month is F= $1.5225 per USD. Suppose the current interest rate interest is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT