Python !!

Ολοκληρωμένο Αναρτήθηκε Πριν 7 χρόνια Πληρώθηκε κατά την παράδοση
Ολοκληρωμένο Πληρώθηκε κατά την παράδοση

getPassword()

Write a function that asks a user for a username and password. If the password = "stedwards" print "Password Correct" Now put this code in a while loop so that the program continues to ask for the username and password until the user guesses the correct password. Give the user five chances. If the user does not guess the correct password in five chances print "Incorrect" and return from the function.

aCounter()

Write a function that asks the user to enter a sentence. Use a for loop to count the number times the letter 'a' shows up in the sentence. Remember, when iterating through a string you can use the following form of the for loop. for letter in sentence : Print the number of instances the letter 'a' appears. For example, the output of your function would be as follows: Please enter a sentence: Computer Science is a blast! The number of 'a' instances is: 2

backwards()

Counting backwards:

You can count backwards with a for loop using the range function as follows:

for i in range(10, 0, -1) :

In this example, 10 is the starting number and 0 is the ending number. The -1 designates that counting will progress backwards one number at a time. To use the print() function and designate NOT to put a new line character at the end of the print: print(i, end=" ") This function should use a for loop to print the numbers from 100 to 0 in reverse order such that all of the numbers are on one line.

eIn()

Using the 'in' operator

The 'in' operator can be used to test if a letter is in a string.

message = input("Type a sentence.")

if 'e' in message :

If 'e' is in the message print("e is in your sentence")

otherwise print("e is not in your sentence") Write a function called eIn() to ask the user for a sentence. If the letters 'e' and 'a' are in the sentence print, "Both letters 'a' and 'e' are in the sentence". Otherwise print, "Both letters 'a' and 'e' are not in the sentence"

Python

Ταυτότητα Εργασίας: #13184374

Σχετικά με την εργασία

2 προτάσεις Απομακρυσμένη εργασία Ενεργό Πριν 7 χρόνια

Ανατέθηκε στον:

$25 USD σε 1 μέρα
(10 Αξιολογήσεις)
3.7