Answer:
// code in C++.
#include <bits/stdc++.h>
using namespace std;
// main function
int main()
{
// variables
int n;
cout<<"Enter a positive number:";
// read number
cin>>n;
// check number is positive or not
while(n<0)
{
// if number is negative
cout<<"Wrong input!!"<<endl;
// ask again to enter again
cout<<"Enter again:";
// read number again
cin>>n;
}
// generate random number between 1 to n
int ran=rand()%n +1;
// print random number
cout<<"Random number between 1 to "<<n<<" is: "<<ran<<endl;
return 0;
}
Explanation:
Read a number from user.Then if input number is negative then ask user to enter a positive number again.After this generate a random number between 1 to n.Print that random number.
Output:
Enter a positive number:-12
Wrong input!!
Enter again:9
Random number between 1 to 9 is: 2
Answer:
This answer is quite late, but data types are basically categories that differentiate stuff in python.
A few examples would be:
String - Anything that has single or double-quotes around it. The input( ) function automatically returns a string, unless changed.
Int - An integer. Any whole number.
Float - Any decimal number.
List - a variable in which you can store multiple different elements. (Strings, integers, floats, tuples, lists, etc...)
Also, sorry if my English isn't perfect. English isn't my first language.
Explanation:
Don't know. Just some stuff I remember from my python class. ∞