How to display A B C D E if a input 5 numbers 1 2 3 4 5

Related searches
import random
a = input('')
b = input('')
c = input('')
d = input('')
e = input('')
var1 = random.randrange(1,26)
var2 = random.randrange(1,26)
var3 = random.randrange(1,26)
var4 = random.randrange(1,26)
var5 = random.randrange(1,26)

What I want to do is when I input numbers from 1 to 26 it should display a corresponding result. As you can see, the user must input 5 numbers. For example, if we input 1 2 3 4 5 the result must be A B C D E. Also, we have random numbers. For example, if our random numbers are 4 5 3 1 2 the result must be D E C A B. I don't know what to do to display the result.


This is wrong. Random's second parameter is non-inclusive, meaning you'll get numbers from 1 to 25.

You should use:

random.randrange(1, len(ltr))

Then your result letter is just accessing the correct index in your ltr string - simply doing ltr(var1)

As for user input, you need to invert it to integer values like this:

a = int(input(''))

C# Sharp programming exercises: For Loop, 1. Write a program in C# Sharp to display the first 10 natural numbers. 1 + 1/2 + 1/3 + 1/4 + 1/5 1/n terms. Test Data : Input the number of� A truth table of this circuit can be designed by the inputs combinations for every decimal digit. For instance, decimal number ‘1’ would control a blend of b & c. The second step is the truth table design by listing the display input signals-7, equivalent four-digit binary numbers as well as decimal number.

strip() your ltr and find element at (entered_position-1) , repeat for five times ,and join the list separated by a space

print(' '.join([ltr.strip()[int(input('number 1-26: '))-1] for _ in range(5)]))
print(' '.join([ltr.strip()[random.randrange(1,27)-1] for _ in range(5)]))

Top 30 Patterns in Java: How to Print Star, Number and Character , System.out.println("Enter the number of rows: "); //takes input from user int rows = sc.nextInt(); void display(int n) { // Outer for loop for 1 2 3 4 5. Let's write the java code to understand this pattern better. public class Edureka 4. Triangle Character Pattern Program in Java. A A B A B C A B C D A B C D E Contribute your code and comments through Disqus. Previous: Write a program in Java to display n terms of natural numbers and their sum. Next: Write a program in Java to display the cube of the number upto given an integer.

What you want to do is to print the letter in the alphabet which is at the position the user entered. In other words, the user enters the index of that letter inside the alphabet. Since you can access a character inside a string using its index in python using letter = string[index] you can do this:


a = input('')
b = input('')
c = input('')
d = input('')
e = input('')
print(ltr[a], ltr[b], ltr[c], ltr[d], ltr[e])

Note that due to the space at the start of ltr, A will be output when entering 1.

Edit: Update according to question in comments. You can sort the inputs if you put them in a list and sort() them. Then you can get the characters at the positions from the input list:


inputs = []
for _ in range(5):
    inputs.append(int(input("Enter a number:")))

print(', '.join(map(str, inputs)))
print(', '.join(ltr[i] for i in inputs))

20 Different Number Pattern Programs In Java, How to print numbers in different patterns in java, Number Pattern 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 5 6 1 2 3 4 5 6 7. Java Program :� We can refer each segment "a,b,c,d,e,f,g" and for dot character we will use "h". There are 10 pins, in which 8 pins are used to refer a,b,c,d,e,f,g and h/dp, the two middle pins are common anode/cathode of all he LEDs. These common anode/cathode are internally shorted so we need to connect only one COM pin. 7 Segment Display Pinout

How to Print Pyramid Pattern in Java? Program Example, You can also use Scanner class to get input from the user and draw pyramid up to that For example in above diagram, the pyramid has 5 levels. Pyramid of numbers in Java : 0 0 1 0 1 2 0 1 2 3 0 1 2 3 4 how to write program to display Reply. Anonymous August 6, 2016 at 1:18 AM. How to print. A AB ABC ABCD C Input Output (I/O) In this tutorial, you will learn to use scanf() function to take input from the user, and printf() function to display output to the user.

Java Basics Exercises - Java Programming Tutorial, Try dayNumber = 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 and verify your results. Decimal (used by human beings for input and output); Binary (used by computer for storage Define variables int sumOdd = 0; // Accumulating sum of odd numbers int sumEven = 0; Find the absolute difference and display if (sumL2R > sumR2L) .. . else . C Program to Print Pyramids and Patterns In this example, you will learn to print half pyramids, inverted pyramids, full pyramids, inverted full pyramids, Pascal's triangle, and Floyd's triangle in C Programming.

TOP Interview Coding Problems/Challenges Run-length encoding (find/print frequency of letters in a string) Sort an array of 0's, 1's and 2's in linear time complexity

  • change use of random.randrange to var1 = ltr[a], and repeat for each variable
  • i can't sir it is part of the code the given must 10 numbers in total 5 user input and 5 random numbers
  • convert string to int ?
  • In this case it is done implicitly and not necessary but you are right it would be good to have this explicit.
  • i intetionally put a space to start the count to 1
  • my program is when i enter numbers from 1 to 26 it will display the corresponding letters
  • Yes, thats exactly what it does?