No prob. Let's go over the Python code,
Here's your complete Python program with the added function `check_username()`:
```
import json
filename = 'username.json'
def get_stored_username():
try:
with open(filename, 'r') as f:
username = json.load(f)
except FileNotFoundError:
return None
else:
return username
def get_new_username():
username = input("What's your username? ")
with open(filename, 'w') as f:
json.dump(username, f)
return username
def check_username():
username = get_stored_username()
if username:
correct = input(f"Are you {username}? (y/n) ")
if correct.lower() == 'y':
return username
return get_new_username()
def greet_user():
username = check_username()
print(f"Welcome back, {username}!")
greet_user()
```
Remember to call `greet_user()` to start the whole shebang. Let me know if anything needs clearing up!
Answer:
int count = 0; //int variables
int longest =0; // int variables
Scanner input = new Scanner(System.in); // given input is reference variable
String str= new String(); // creating object of sting class
while (input.hasNext()) // taking the input by using scanner reference
{
str= input.next(); // taking input in string
if (str.length() == longest) // checking condition
++count; // increment the count
else
if (Str.length() > longest) // if string is greater then longest
{
longest = str.length(); // calculating length
count = 1; // assign count to 1
}
}
Explanation:
Following are the description of the code :
The code that examines all the strings in the input source and determines how long the longest string (or strings are) is the following:
total = 0;% initial value is zero, in every while loop it will be incremented
while(input.hasNextInt()){
total += input.nextInt( );
}
B. Increase in Income
C. Increase in Interest Rates
Answer:
The solution code is written in Python:
m = 1
n = 5
d = random.randint(m, n)
Explanation:
To get a random integer between m and n inclusive, we can make use of Python randint method. It will take two parameters, m and n. By giving two integers as an input (e.g. 1 and 5) to randint, it will generate a random integer between 1 to 5 inclusive.
Answer: One Space
Explanation: