Variables, python operators,data types,string slicing, range of string using list, python conditional statements,user input, looping statement s, python function s, exception handling, file handling, module concept write a demart code using all these things
Reducing Fraction to Lowest Term
Create a Python script that will reduce an input fraction to its lowest term.
2. Define a function that will split a VALID fraction and return a list that consists the numerator and denominator.
Sample Output 1:
Input a fraction: 4/6
Reduced fraction is 2/3
Reducing Fraction to Lowest Term
Create a Python script that will reduce an input fraction to its lowest term.
1. Define a function that will check first if the input fraction is a VALID fraction.
Sample Output 1:
Input a fraction: 4/6
Reduced fraction is 2/3
1. Write a simple decryption program using string functions which will apply the Substitution Method. Here is the given Substitution Table.
1. Write a program using string functions that determine if the input word is a palindrome. A palindrome word is a word that produces the same word when it is reversed.
Write a program using standard string functions that
accepts a price of an item and display its coded value. The
base of the key is:
X C O M P U T E R S
0 1 2 3 4 5 6 7 8 9
Write a program to read the content of a file and copy its content to another file after converting all the capital case letters in the file to small case letters.
Create a Python script that will reduce an input fraction to its lowest term. The program requirements will be:
Sample Output:
Input a fraction? : 4/6
Reduced fraction is 2/3
I need the code to have an output stated above and that the requirements are met in the code.
The following code is supposed to display the positive even numbers less than 12. That is, it will
output the numbers 2, 4, 6, 8 and 10. However, there is a logical error in the code. Explain what the output
of the code below will be. Then write a small program including the code below and make the necessary
changes to fix the code so that it displays what it is intended to display. Ensure that your program works
correctly. Only submit the program, not the output.
Hint: Use variable diagrams to trace the program to help you find the logical error.
int x = 1;
while (x
!= 12)
{
cout << x <<
endl; x = x +
2;
}
Include the for loop below in a small program and complete the program. The loop should execute 10
times. Do not change the for loop below. Compile and run your program to see for yourself that it works.
You do not have to submit this program and output.
for (int i = 1; i <= n;
i++) cout << i * i;
Now convert the for loop into a while loop and add any variable initialisations that you think are
necessary. Compile and run your program and submit only the program containing the while loop and its
output